Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d7d5c685
Commit
d7d5c685
authored
Nov 27, 2009
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If no result is given NOTFOUND should be returned. Check for empty result
string too.
parent
81a82a13
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
239 additions
and
277 deletions
+239
-277
src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/ecpglib/data.c
+239
-277
No files found.
src/interfaces/ecpg/ecpglib/data.c
View file @
d7d5c685
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.4
5 2009/10/01 18:03:54
meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.4
6 2009/11/27 13:32:17
meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
...
...
@@ -62,6 +62,17 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
ecpg_log
(
"ecpg_get_data on line %d: RESULT: %s offset: %ld; array: %s
\n
"
,
lineno
,
pval
?
(
binary
?
"BINARY"
:
pval
)
:
"EMPTY"
,
log_offset
,
isarray
?
"yes"
:
"no"
);
/* pval is a pointer to the value */
if
(
!
pval
)
{
/*
* This should never happen because we already checked that we
* found at least one tuple, but let's play it safe.
*/
ecpg_raise
(
lineno
,
ECPG_NOT_FOUND
,
ECPG_SQLSTATE_NO_DATA
,
NULL
);
return
(
false
);
}
/* We will have to decode the value */
/*
...
...
@@ -122,11 +133,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
value_for_indicator
==
-
1
)
return
(
true
);
/* pval is a pointer to the value */
/* let's check if it really is an array if it should be one */
if
(
isarray
==
ECPG_ARRAY_ARRAY
)
{
if
(
!
pval
||
*
pval
!=
'{'
)
if
(
*
pval
!=
'{'
)
{
ecpg_raise
(
lineno
,
ECPG_DATA_NOT_ARRAY
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
NULL
);
...
...
@@ -150,8 +160,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
do
{
if
(
binary
)
{
if
(
pval
)
{
if
(
varcharsize
==
0
||
varcharsize
*
offset
>=
size
)
memcpy
((
char
*
)
((
long
)
var
+
offset
*
act_tuple
),
...
...
@@ -192,7 +200,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
pval
+=
size
;
}
}
else
{
switch
(
type
)
...
...
@@ -209,8 +216,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_short
:
case
ECPGt_int
:
case
ECPGt_long
:
if
(
pval
)
{
res
=
strtol
(
pval
,
&
scan_length
,
10
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
...
...
@@ -219,9 +224,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
return
(
false
);
}
pval
=
scan_length
;
}
else
res
=
0L
;
switch
(
type
)
{
...
...
@@ -243,8 +245,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_unsigned_short
:
case
ECPGt_unsigned_int
:
case
ECPGt_unsigned_long
:
if
(
pval
)
{
ures
=
strtoul
(
pval
,
&
scan_length
,
10
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
...
...
@@ -253,9 +253,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
return
(
false
);
}
pval
=
scan_length
;
}
else
ures
=
0L
;
switch
(
type
)
{
...
...
@@ -277,8 +274,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
#ifdef HAVE_LONG_LONG_INT_64
#ifdef HAVE_STRTOLL
case
ECPGt_long_long
:
if
(
pval
)
{
*
((
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
strtoll
(
pval
,
&
scan_length
,
10
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
...
...
@@ -286,16 +281,11 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
return
(
false
);
}
pval
=
scan_length
;
}
else
*
((
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
(
long
long
)
0
;
break
;
#endif
/* HAVE_STRTOLL */
#ifdef HAVE_STRTOULL
case
ECPGt_unsigned_long_long
:
if
(
pval
)
{
*
((
unsigned
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
strtoull
(
pval
,
&
scan_length
,
10
);
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
!
(
INFORMIX_MODE
(
compat
)
&&
*
scan_length
==
'.'
)
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
...
...
@@ -304,9 +294,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
return
(
false
);
}
pval
=
scan_length
;
}
else
*
((
unsigned
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
(
long
long
)
0
;
break
;
#endif
/* HAVE_STRTOULL */
...
...
@@ -314,8 +301,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_float
:
case
ECPGt_double
:
if
(
pval
)
{
if
(
isarray
&&
*
pval
==
'"'
)
dres
=
strtod
(
pval
+
1
,
&
scan_length
);
else
...
...
@@ -331,9 +316,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
return
(
false
);
}
pval
=
scan_length
;
}
else
dres
=
0
.
0
;
switch
(
type
)
{
...
...
@@ -350,8 +332,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break
;
case
ECPGt_bool
:
if
(
pval
)
{
if
(
pval
[
0
]
==
'f'
&&
pval
[
1
]
==
'\0'
)
{
if
(
offset
==
sizeof
(
char
))
...
...
@@ -381,7 +361,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
/* NULL is valid */
break
;
}
}
ecpg_raise
(
lineno
,
ECPG_CONVERT_BOOL
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
...
...
@@ -391,7 +370,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_char
:
case
ECPGt_unsigned_char
:
case
ECPGt_string
:
if
(
pval
)
{
char
*
str
=
(
char
*
)
((
long
)
var
+
offset
*
act_tuple
);
if
(
varcharsize
==
0
||
varcharsize
>
size
)
...
...
@@ -446,7 +424,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break
;
case
ECPGt_varchar
:
if
(
pval
)
{
struct
ECPGgeneric_varchar
*
variable
=
(
struct
ECPGgeneric_varchar
*
)
((
long
)
var
+
offset
*
act_tuple
);
...
...
@@ -495,8 +472,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_decimal
:
case
ECPGt_numeric
:
if
(
pval
)
{
if
(
isarray
&&
*
pval
==
'"'
)
nres
=
PGTYPESnumeric_from_asc
(
pval
+
1
,
&
scan_length
);
else
...
...
@@ -545,9 +520,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
}
pval
=
scan_length
;
}
else
nres
=
PGTYPESnumeric_from_asc
(
"0.0"
,
&
scan_length
);
if
(
type
==
ECPGt_numeric
)
PGTYPESnumeric_copy
(
nres
,
(
numeric
*
)
(
var
+
offset
*
act_tuple
));
...
...
@@ -558,8 +530,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break
;
case
ECPGt_interval
:
if
(
pval
)
{
if
(
isarray
&&
*
pval
==
'"'
)
ires
=
PGTYPESinterval_from_asc
(
pval
+
1
,
&
scan_length
);
else
...
...
@@ -604,16 +574,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
}
pval
=
scan_length
;
}
else
ires
=
PGTYPESinterval_from_asc
(
"0 seconds"
,
NULL
);
PGTYPESinterval_copy
(
ires
,
(
interval
*
)
(
var
+
offset
*
act_tuple
));
free
(
ires
);
break
;
case
ECPGt_date
:
if
(
pval
)
{
if
(
isarray
&&
*
pval
==
'"'
)
ddres
=
PGTYPESdate_from_asc
(
pval
+
1
,
&
scan_length
);
else
...
...
@@ -655,12 +621,9 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
*
((
date
*
)
(
var
+
offset
*
act_tuple
))
=
ddres
;
pval
=
scan_length
;
}
break
;
case
ECPGt_timestamp
:
if
(
pval
)
{
if
(
isarray
&&
*
pval
==
'"'
)
tres
=
PGTYPEStimestamp_from_asc
(
pval
+
1
,
&
scan_length
);
else
...
...
@@ -702,7 +665,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
*
((
timestamp
*
)
(
var
+
offset
*
act_tuple
))
=
tres
;
pval
=
scan_length
;
}
break
;
default:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment