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
Hide 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
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
#include "postgres_fe.h"
...
@@ -62,6 +62,17 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -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"
);
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 */
/* 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,
...
@@ -122,11 +133,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
value_for_indicator
==
-
1
)
if
(
value_for_indicator
==
-
1
)
return
(
true
);
return
(
true
);
/* pval is a pointer to the value */
/* let's check if it really is an array if it should be one */
/* let's check if it really is an array if it should be one */
if
(
isarray
==
ECPG_ARRAY_ARRAY
)
if
(
isarray
==
ECPG_ARRAY_ARRAY
)
{
{
if
(
!
pval
||
*
pval
!=
'{'
)
if
(
*
pval
!=
'{'
)
{
{
ecpg_raise
(
lineno
,
ECPG_DATA_NOT_ARRAY
,
ecpg_raise
(
lineno
,
ECPG_DATA_NOT_ARRAY
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
NULL
);
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
NULL
);
...
@@ -151,47 +161,44 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -151,47 +161,44 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
{
if
(
binary
)
if
(
binary
)
{
{
if
(
pval
)
if
(
varcharsize
==
0
||
varcharsize
*
offset
>=
size
)
memcpy
((
char
*
)
((
long
)
var
+
offset
*
act_tuple
),
pval
,
size
);
else
{
{
if
(
varcharsize
==
0
||
varcharsize
*
offset
>=
size
)
memcpy
((
char
*
)
((
long
)
var
+
offset
*
act_tuple
),
memcpy
((
char
*
)
((
long
)
var
+
offset
*
act_tuple
),
pval
,
varcharsize
*
offset
);
pval
,
size
);
else
{
memcpy
((
char
*
)
((
long
)
var
+
offset
*
act_tuple
),
pval
,
varcharsize
*
offset
);
if
(
varcharsize
*
offset
<
size
)
if
(
varcharsize
*
offset
<
size
)
{
/* truncation */
switch
(
ind_type
)
{
{
/* truncation */
case
ECPGt_short
:
switch
(
ind_type
)
case
ECPGt_unsigned_short
:
{
*
((
short
*
)
(
ind
+
ind_offset
*
act_tuple
))
=
size
;
case
ECPGt_short
:
break
;
case
ECPGt_unsigned_short
:
case
ECPGt_int
:
*
((
short
*
)
(
ind
+
ind_offset
*
act_tuple
))
=
size
;
case
ECPGt_unsigned_int
:
break
;
*
((
int
*
)
(
ind
+
ind_offset
*
act_tuple
))
=
size
;
case
ECPGt_int
:
break
;
case
ECPGt_unsigned_int
:
case
ECPGt_long
:
*
((
int
*
)
(
ind
+
ind_offset
*
act_tuple
))
=
size
;
case
ECPGt_unsigned_long
:
break
;
*
((
long
*
)
(
ind
+
ind_offset
*
act_tuple
))
=
size
;
case
ECPGt_long
:
break
;
case
ECPGt_unsigned_long
:
*
((
long
*
)
(
ind
+
ind_offset
*
act_tuple
))
=
size
;
break
;
#ifdef HAVE_LONG_LONG_INT_64
#ifdef HAVE_LONG_LONG_INT_64
case
ECPGt_long_long
:
case
ECPGt_long_long
:
case
ECPGt_unsigned_long_long
:
case
ECPGt_unsigned_long_long
:
*
((
long
long
int
*
)
(
ind
+
ind_offset
*
act_tuple
))
=
size
;
*
((
long
long
int
*
)
(
ind
+
ind_offset
*
act_tuple
))
=
size
;
break
;
break
;
#endif
/* HAVE_LONG_LONG_INT_64 */
#endif
/* HAVE_LONG_LONG_INT_64 */
default:
default:
break
;
break
;
}
sqlca
->
sqlwarn
[
0
]
=
sqlca
->
sqlwarn
[
1
]
=
'W'
;
}
}
sqlca
->
sqlwarn
[
0
]
=
sqlca
->
sqlwarn
[
1
]
=
'W'
;
}
}
pval
+=
size
;
}
}
pval
+=
size
;
}
}
else
else
{
{
...
@@ -209,19 +216,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -209,19 +216,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_short
:
case
ECPGt_short
:
case
ECPGt_int
:
case
ECPGt_int
:
case
ECPGt_long
:
case
ECPGt_long
:
if
(
pval
)
res
=
strtol
(
pval
,
&
scan_length
,
10
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
{
res
=
strtol
(
pval
,
&
scan_length
,
10
);
ecpg_raise
(
lineno
,
ECPG_INT_FORMAT
,
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
{
return
(
false
);
ecpg_raise
(
lineno
,
ECPG_INT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
pval
=
scan_length
;
}
}
else
pval
=
scan_length
;
res
=
0L
;
switch
(
type
)
switch
(
type
)
{
{
...
@@ -243,19 +245,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -243,19 +245,14 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_unsigned_short
:
case
ECPGt_unsigned_short
:
case
ECPGt_unsigned_int
:
case
ECPGt_unsigned_int
:
case
ECPGt_unsigned_long
:
case
ECPGt_unsigned_long
:
if
(
pval
)
ures
=
strtoul
(
pval
,
&
scan_length
,
10
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
{
ures
=
strtoul
(
pval
,
&
scan_length
,
10
);
ecpg_raise
(
lineno
,
ECPG_UINT_FORMAT
,
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
{
return
(
false
);
ecpg_raise
(
lineno
,
ECPG_UINT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
pval
=
scan_length
;
}
}
else
pval
=
scan_length
;
ures
=
0L
;
switch
(
type
)
switch
(
type
)
{
{
...
@@ -277,36 +274,26 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -277,36 +274,26 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
#ifdef HAVE_LONG_LONG_INT_64
#ifdef HAVE_LONG_LONG_INT_64
#ifdef HAVE_STRTOLL
#ifdef HAVE_STRTOLL
case
ECPGt_long_long
:
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
))
{
{
*
((
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
strtoll
(
pval
,
&
scan_length
,
10
);
ecpg_raise
(
lineno
,
ECPG_INT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
return
(
false
);
{
ecpg_raise
(
lineno
,
ECPG_INT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
pval
=
scan_length
;
}
}
else
pval
=
scan_length
;
*
((
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
(
long
long
)
0
;
break
;
break
;
#endif
/* HAVE_STRTOLL */
#endif
/* HAVE_STRTOLL */
#ifdef HAVE_STRTOULL
#ifdef HAVE_STRTOULL
case
ECPGt_unsigned_long_long
:
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 */
{
{
*
((
unsigned
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
strtoull
(
pval
,
&
scan_length
,
10
);
ecpg_raise
(
lineno
,
ECPG_UINT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
return
(
false
);
||
(
!
isarray
&&
!
(
INFORMIX_MODE
(
compat
)
&&
*
scan_length
==
'.'
)
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
{
ecpg_raise
(
lineno
,
ECPG_UINT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
pval
=
scan_length
;
}
}
else
pval
=
scan_length
;
*
((
unsigned
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
(
long
long
)
0
;
break
;
break
;
#endif
/* HAVE_STRTOULL */
#endif
/* HAVE_STRTOULL */
...
@@ -314,26 +301,21 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -314,26 +301,21 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_float
:
case
ECPGt_float
:
case
ECPGt_double
:
case
ECPGt_double
:
if
(
pval
)
if
(
isarray
&&
*
pval
==
'"'
)
{
dres
=
strtod
(
pval
+
1
,
&
scan_length
);
if
(
isarray
&&
*
pval
==
'"'
)
else
dres
=
strtod
(
pval
+
1
,
&
scan_length
);
dres
=
strtod
(
pval
,
&
scan_length
);
else
dres
=
strtod
(
pval
,
&
scan_length
);
if
(
isarray
&&
*
scan_length
==
'"'
)
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
scan_length
++
;
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
{
ecpg_raise
(
lineno
,
ECPG_FLOAT_FORMAT
,
ecpg_raise
(
lineno
,
ECPG_FLOAT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
return
(
false
);
}
pval
=
scan_length
;
}
}
else
pval
=
scan_length
;
dres
=
0
.
0
;
switch
(
type
)
switch
(
type
)
{
{
...
@@ -350,37 +332,34 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -350,37 +332,34 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break
;
break
;
case
ECPGt_bool
:
case
ECPGt_bool
:
if
(
pval
)
if
(
pval
[
0
]
==
'f'
&&
pval
[
1
]
==
'\0'
)
{
{
if
(
pval
[
0
]
==
'f'
&&
pval
[
1
]
==
'\0'
)
if
(
offset
==
sizeof
(
char
))
{
*
((
char
*
)
(
var
+
offset
*
act_tuple
))
=
false
;
if
(
offset
==
sizeof
(
char
))
else
if
(
offset
==
sizeof
(
int
))
*
((
char
*
)
(
var
+
offset
*
act_tuple
))
=
false
;
*
((
int
*
)
(
var
+
offset
*
act_tuple
))
=
false
;
else
if
(
offset
==
sizeof
(
int
))
else
*
((
int
*
)
(
var
+
offset
*
act_tuple
))
=
false
;
ecpg_raise
(
lineno
,
ECPG_CONVERT_BOOL
,
else
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
ecpg_raise
(
lineno
,
ECPG_CONVERT_BOOL
,
NULL
);
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
break
;
NULL
);
}
break
;
else
if
(
pval
[
0
]
==
't'
&&
pval
[
1
]
==
'\0'
)
}
{
else
if
(
pval
[
0
]
==
't'
&&
pval
[
1
]
==
'\0'
)
if
(
offset
==
sizeof
(
char
))
{
*
((
char
*
)
(
var
+
offset
*
act_tuple
))
=
true
;
if
(
offset
==
sizeof
(
char
))
else
if
(
offset
==
sizeof
(
int
))
*
((
char
*
)
(
var
+
offset
*
act_tuple
))
=
true
;
*
((
int
*
)
(
var
+
offset
*
act_tuple
))
=
true
;
else
if
(
offset
==
sizeof
(
int
))
else
*
((
int
*
)
(
var
+
offset
*
act_tuple
))
=
true
;
ecpg_raise
(
lineno
,
ECPG_CONVERT_BOOL
,
else
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
ecpg_raise
(
lineno
,
ECPG_CONVERT_BOOL
,
NULL
);
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
break
;
NULL
);
}
break
;
else
if
(
pval
[
0
]
==
'\0'
&&
PQgetisnull
(
results
,
act_tuple
,
act_field
))
}
{
else
if
(
pval
[
0
]
==
'\0'
&&
PQgetisnull
(
results
,
act_tuple
,
act_field
))
/* NULL is valid */
{
break
;
/* NULL is valid */
break
;
}
}
}
ecpg_raise
(
lineno
,
ECPG_CONVERT_BOOL
,
ecpg_raise
(
lineno
,
ECPG_CONVERT_BOOL
,
...
@@ -391,7 +370,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -391,7 +370,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_char
:
case
ECPGt_char
:
case
ECPGt_unsigned_char
:
case
ECPGt_unsigned_char
:
case
ECPGt_string
:
case
ECPGt_string
:
if
(
pval
)
{
{
char
*
str
=
(
char
*
)
((
long
)
var
+
offset
*
act_tuple
);
char
*
str
=
(
char
*
)
((
long
)
var
+
offset
*
act_tuple
);
if
(
varcharsize
==
0
||
varcharsize
>
size
)
if
(
varcharsize
==
0
||
varcharsize
>
size
)
...
@@ -446,7 +424,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -446,7 +424,6 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break
;
break
;
case
ECPGt_varchar
:
case
ECPGt_varchar
:
if
(
pval
)
{
{
struct
ECPGgeneric_varchar
*
variable
=
struct
ECPGgeneric_varchar
*
variable
=
(
struct
ECPGgeneric_varchar
*
)
((
long
)
var
+
offset
*
act_tuple
);
(
struct
ECPGgeneric_varchar
*
)
((
long
)
var
+
offset
*
act_tuple
);
...
@@ -495,59 +472,54 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -495,59 +472,54 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case
ECPGt_decimal
:
case
ECPGt_decimal
:
case
ECPGt_numeric
:
case
ECPGt_numeric
:
if
(
pval
)
if
(
isarray
&&
*
pval
==
'"'
)
nres
=
PGTYPESnumeric_from_asc
(
pval
+
1
,
&
scan_length
);
else
nres
=
PGTYPESnumeric_from_asc
(
pval
,
&
scan_length
);
/* did we get an error? */
if
(
nres
==
NULL
)
{
{
if
(
isarray
&&
*
pval
==
'"'
)
ecpg_log
(
"ecpg_get_data on line %d: RESULT %s; errno %d
\n
"
,
nres
=
PGTYPESnumeric_from_asc
(
pval
+
1
,
&
scan_length
);
lineno
,
pval
?
pval
:
""
,
errno
);
else
nres
=
PGTYPESnumeric_from_asc
(
pval
,
&
scan_length
);
/* did we get an error? */
if
(
INFORMIX_MODE
(
compat
))
if
(
nres
==
NULL
)
{
{
ecpg_log
(
"ecpg_get_data on line %d: RESULT %s; errno %d
\n
"
,
/*
lineno
,
pval
?
pval
:
""
,
errno
);
* Informix wants its own NULL value here
* instead of an error
if
(
INFORMIX_MODE
(
compat
))
*/
{
nres
=
PGTYPESnumeric_new
();
/*
if
(
nres
)
* Informix wants its own NULL value here
ECPGset_noind_null
(
ECPGt_numeric
,
nres
);
* instead of an error
*/
nres
=
PGTYPESnumeric_new
();
if
(
nres
)
ECPGset_noind_null
(
ECPGt_numeric
,
nres
);
else
{
ecpg_raise
(
lineno
,
ECPG_OUT_OF_MEMORY
,
ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY
,
NULL
);
return
(
false
);
}
}
else
else
{
{
ecpg_raise
(
lineno
,
ECPG_
NUMERIC_FORMAT
,
ecpg_raise
(
lineno
,
ECPG_
OUT_OF_MEMORY
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY
,
NULL
);
return
(
false
);
return
(
false
);
}
}
}
}
else
else
{
{
if
(
isarray
&&
*
scan_length
==
'"'
)
ecpg_raise
(
lineno
,
ECPG_NUMERIC_FORMAT
,
scan_length
++
;
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
free
(
nres
);
ecpg_raise
(
lineno
,
ECPG_NUMERIC_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
}
pval
=
scan_length
;
}
}
else
else
nres
=
PGTYPESnumeric_from_asc
(
"0.0"
,
&
scan_length
);
{
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
free
(
nres
);
ecpg_raise
(
lineno
,
ECPG_NUMERIC_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
pval
=
scan_length
;
if
(
type
==
ECPGt_numeric
)
if
(
type
==
ECPGt_numeric
)
PGTYPESnumeric_copy
(
nres
,
(
numeric
*
)
(
var
+
offset
*
act_tuple
));
PGTYPESnumeric_copy
(
nres
,
(
numeric
*
)
(
var
+
offset
*
act_tuple
));
...
@@ -558,151 +530,141 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
...
@@ -558,151 +530,141 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break
;
break
;
case
ECPGt_interval
:
case
ECPGt_interval
:
if
(
pval
)
if
(
isarray
&&
*
pval
==
'"'
)
ires
=
PGTYPESinterval_from_asc
(
pval
+
1
,
&
scan_length
);
else
ires
=
PGTYPESinterval_from_asc
(
pval
,
&
scan_length
);
/* did we get an error? */
if
(
ires
==
NULL
)
{
{
if
(
isarray
&&
*
pval
==
'"'
)
ecpg_log
(
"ecpg_get_data on line %d: RESULT %s; errno %d
\n
"
,
ires
=
PGTYPESinterval_from_asc
(
pval
+
1
,
&
scan_length
);
lineno
,
pval
?
pval
:
""
,
errno
);
else
ires
=
PGTYPESinterval_from_asc
(
pval
,
&
scan_length
);
/* did we get an error? */
if
(
INFORMIX_MODE
(
compat
))
if
(
ires
==
NULL
)
{
{
ecpg_log
(
"ecpg_get_data on line %d: RESULT %s; errno %d
\n
"
,
/*
lineno
,
pval
?
pval
:
""
,
errno
);
* Informix wants its own NULL value here
* instead of an error
if
(
INFORMIX_MODE
(
compat
))
*/
{
ires
=
(
interval
*
)
ecpg_alloc
(
sizeof
(
interval
),
lineno
);
/*
if
(
!
ires
)
* Informix wants its own NULL value here
* instead of an error
*/
ires
=
(
interval
*
)
ecpg_alloc
(
sizeof
(
interval
),
lineno
);
if
(
!
ires
)
return
(
false
);
ECPGset_noind_null
(
ECPGt_interval
,
ires
);
}
else
{
ecpg_raise
(
lineno
,
ECPG_INTERVAL_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
return
(
false
);
}
ECPGset_noind_null
(
ECPGt_interval
,
ires
);
}
}
else
else
{
{
if
(
isarray
&&
*
scan_length
==
'"'
)
ecpg_raise
(
lineno
,
ECPG_INTERVAL_FORMAT
,
scan_length
++
;
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
free
(
ires
);
ecpg_raise
(
lineno
,
ECPG_INTERVAL_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
}
pval
=
scan_length
;
}
}
else
else
ires
=
PGTYPESinterval_from_asc
(
"0 seconds"
,
NULL
);
{
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
free
(
ires
);
ecpg_raise
(
lineno
,
ECPG_INTERVAL_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
pval
=
scan_length
;
PGTYPESinterval_copy
(
ires
,
(
interval
*
)
(
var
+
offset
*
act_tuple
));
PGTYPESinterval_copy
(
ires
,
(
interval
*
)
(
var
+
offset
*
act_tuple
));
free
(
ires
);
free
(
ires
);
break
;
break
;
case
ECPGt_date
:
case
ECPGt_date
:
if
(
pval
)
if
(
isarray
&&
*
pval
==
'"'
)
ddres
=
PGTYPESdate_from_asc
(
pval
+
1
,
&
scan_length
);
else
ddres
=
PGTYPESdate_from_asc
(
pval
,
&
scan_length
);
/* did we get an error? */
if
(
errno
!=
0
)
{
{
if
(
isarray
&&
*
pval
==
'"'
)
ecpg_log
(
"ecpg_get_data on line %d: RESULT %s; errno %d
\n
"
,
ddres
=
PGTYPESdate_from_asc
(
pval
+
1
,
&
scan_length
);
lineno
,
pval
?
pval
:
""
,
errno
);
else
ddres
=
PGTYPESdate_from_asc
(
pval
,
&
scan_length
);
/* did we get an error? */
if
(
INFORMIX_MODE
(
compat
))
if
(
errno
!=
0
)
{
{
ecpg_log
(
"ecpg_get_data on line %d: RESULT %s; errno %d
\n
"
,
/*
lineno
,
pval
?
pval
:
""
,
errno
);
* Informix wants its own NULL value here
* instead of an error
if
(
INFORMIX_MODE
(
compat
))
*/
{
ECPGset_noind_null
(
ECPGt_date
,
&
ddres
);
/*
* Informix wants its own NULL value here
* instead of an error
*/
ECPGset_noind_null
(
ECPGt_date
,
&
ddres
);
}
else
{
ecpg_raise
(
lineno
,
ECPG_DATE_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
}
else
else
{
{
if
(
isarray
&&
*
scan_length
==
'"'
)
ecpg_raise
(
lineno
,
ECPG_DATE_FORMAT
,
scan_length
++
;
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ecpg_raise
(
lineno
,
ECPG_DATE_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
}
}
else
{
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
*
((
date
*
)
(
var
+
offset
*
act_tuple
))
=
ddres
;
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
pval
=
scan_length
;
{
ecpg_raise
(
lineno
,
ECPG_DATE_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
}
*
((
date
*
)
(
var
+
offset
*
act_tuple
))
=
ddres
;
pval
=
scan_length
;
break
;
break
;
case
ECPGt_timestamp
:
case
ECPGt_timestamp
:
if
(
pval
)
if
(
isarray
&&
*
pval
==
'"'
)
tres
=
PGTYPEStimestamp_from_asc
(
pval
+
1
,
&
scan_length
);
else
tres
=
PGTYPEStimestamp_from_asc
(
pval
,
&
scan_length
);
/* did we get an error? */
if
(
errno
!=
0
)
{
{
if
(
isarray
&&
*
pval
==
'"'
)
ecpg_log
(
"ecpg_get_data on line %d: RESULT %s; errno %d
\n
"
,
tres
=
PGTYPEStimestamp_from_asc
(
pval
+
1
,
&
scan_length
);
lineno
,
pval
?
pval
:
""
,
errno
);
else
tres
=
PGTYPEStimestamp_from_asc
(
pval
,
&
scan_length
);
/* did we get an error? */
if
(
INFORMIX_MODE
(
compat
))
if
(
errno
!=
0
)
{
{
ecpg_log
(
"ecpg_get_data on line %d: RESULT %s; errno %d
\n
"
,
/*
lineno
,
pval
?
pval
:
""
,
errno
);
* Informix wants its own NULL value here
* instead of an error
if
(
INFORMIX_MODE
(
compat
))
*/
{
ECPGset_noind_null
(
ECPGt_timestamp
,
&
tres
);
/*
* Informix wants its own NULL value here
* instead of an error
*/
ECPGset_noind_null
(
ECPGt_timestamp
,
&
tres
);
}
else
{
ecpg_raise
(
lineno
,
ECPG_TIMESTAMP_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
}
else
else
{
{
if
(
isarray
&&
*
scan_length
==
'"'
)
ecpg_raise
(
lineno
,
ECPG_TIMESTAMP_FORMAT
,
scan_length
++
;
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ecpg_raise
(
lineno
,
ECPG_TIMESTAMP_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
}
}
else
{
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
*
((
timestamp
*
)
(
var
+
offset
*
act_tuple
))
=
tres
;
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
pval
=
scan_length
;
{
ecpg_raise
(
lineno
,
ECPG_TIMESTAMP_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
}
}
}
*
((
timestamp
*
)
(
var
+
offset
*
act_tuple
))
=
tres
;
pval
=
scan_length
;
break
;
break
;
default:
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