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
87758314
Commit
87758314
authored
Nov 08, 2003
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made sure an internal array is not treated as a user defined one.
parent
449593a9
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
172 additions
and
118 deletions
+172
-118
src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/ecpglib/data.c
+48
-24
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/execute.c
+116
-91
src/interfaces/ecpg/ecpglib/extern.h
src/interfaces/ecpg/ecpglib/extern.h
+6
-1
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+2
-2
No files found.
src/interfaces/ecpg/ecpglib/data.c
View file @
87758314
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.2
0 2003/09/20 09:10:09
meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.2
1 2003/11/08 19:46:27
meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
...
...
@@ -16,21 +16,39 @@
#include "pgtypes_timestamp.h"
#include "pgtypes_interval.h"
static
bool
garbage_left
(
enum
ARRAY_TYPE
isarray
,
char
*
scan_length
,
enum
COMPAT_MODE
compat
)
{
/* INFORMIX allows for selecting a numeric into an int, the result is truncated */
if
(
isarray
==
ECPG_ARRAY_NONE
&&
INFORMIX_MODE
(
compat
)
&&
*
scan_length
==
'.'
)
return
false
;
if
(
isarray
==
ECPG_ARRAY_ARRAY
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
return
true
;
if
(
isarray
==
ECPG_ARRAY_VECTOR
&&
*
scan_length
!=
' '
&&
*
scan_length
!=
'\0'
)
return
true
;
if
(
isarray
==
ECPG_ARRAY_NONE
&&
*
scan_length
!=
' '
&&
*
scan_length
!=
'\0'
)
return
true
;
return
false
;
}
bool
ECPGget_data
(
const
PGresult
*
results
,
int
act_tuple
,
int
act_field
,
int
lineno
,
enum
ECPGttype
type
,
enum
ECPGttype
ind_type
,
char
*
var
,
char
*
ind
,
long
varcharsize
,
long
offset
,
long
ind_offset
,
bool
isarray
,
enum
COMPAT_MODE
compat
,
bool
force_indicator
)
long
ind_offset
,
enum
ARRAY_TYPE
isarray
,
enum
COMPAT_MODE
compat
,
bool
force_indicator
)
{
struct
sqlca_t
*
sqlca
=
ECPGget_sqlca
();
char
*
pval
=
(
char
*
)
PQgetvalue
(
results
,
act_tuple
,
act_field
);
int
value_for_indicator
=
0
;
ECPGlog
(
"ECPGget_data line %d: RESULT: %s offset: %ld
\n
"
,
lineno
,
pval
?
pval
:
""
,
offset
);
ECPGlog
(
"ECPGget_data line %d: RESULT: %s offset: %ld
array: %d
\n
"
,
lineno
,
pval
?
pval
:
""
,
offset
,
isarray
);
/* pval is a pointer to the value */
/* let's check i
s
it really is an array if it should be one */
if
(
isarray
)
/* let's check i
f
it really is an array if it should be one */
if
(
isarray
==
ECPG_ARRAY_ARRAY
)
{
if
(
*
pval
!=
'{'
)
{
...
...
@@ -126,9 +144,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
pval
)
{
res
=
strtol
(
pval
,
&
scan_length
,
10
);
/* INFORMIX allows for selecting a numeric into an int, the result is truncated */
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
!
(
INFORMIX_MODE
(
compat
)
&&
*
scan_length
==
'.'
)
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ECPGraise
(
lineno
,
ECPG_INT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
...
...
@@ -160,8 +176,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
pval
)
{
ures
=
strtoul
(
pval
,
&
scan_length
,
10
);
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
!
(
INFORMIX_MODE
(
compat
)
&&
*
scan_length
==
'.'
)
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ECPGraise
(
lineno
,
ECPG_UINT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
...
...
@@ -193,8 +208,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
pval
)
{
*
((
long
long
int
*
)
(
var
+
offset
*
act_tuple
))
=
strtoll
(
pval
,
&
scan_length
,
10
);
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
!
(
INFORMIX_MODE
(
compat
)
&&
*
scan_length
==
'.'
)
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ECPGraise
(
lineno
,
ECPG_INT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
...
...
@@ -236,8 +250,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ECPGraise
(
lineno
,
ECPG_FLOAT_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
...
...
@@ -411,8 +424,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ECPGraise
(
lineno
,
ECPG_NUMERIC_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
...
...
@@ -455,8 +467,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ECPGraise
(
lineno
,
ECPG_INTERVAL_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
...
...
@@ -495,8 +506,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ECPGraise
(
lineno
,
ECPG_DATE_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
...
...
@@ -534,8 +544,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
isarray
&&
*
scan_length
==
'"'
)
scan_length
++
;
if
((
isarray
&&
*
scan_length
!=
','
&&
*
scan_length
!=
'}'
)
||
(
!
isarray
&&
*
scan_length
!=
'\0'
&&
*
scan_length
!=
' '
))
/* Garbage left */
if
(
garbage_left
(
isarray
,
scan_length
,
compat
))
{
ECPGraise
(
lineno
,
ECPG_TIMESTAMP_FORMAT
,
ECPG_SQLSTATE_DATATYPE_MISMATCH
,
pval
);
return
(
false
);
...
...
@@ -551,7 +560,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
return
(
false
);
break
;
}
if
(
isarray
)
if
(
isarray
==
ECPG_ARRAY_ARRAY
)
{
bool
string
=
false
;
...
...
@@ -566,7 +575,22 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if
(
*
pval
==
','
)
++
pval
;
}
}
while
(
isarray
&&
*
pval
!=
'}'
);
else
if
(
isarray
==
ECPG_ARRAY_VECTOR
)
{
bool
string
=
false
;
/* set array to next entry */
++
act_tuple
;
/* set pval to the next entry */
for
(;
string
||
(
*
pval
!=
' '
&&
*
pval
!=
'\0'
);
++
pval
)
if
(
*
pval
==
'"'
)
string
=
string
?
false
:
true
;
if
(
*
pval
==
' '
)
++
pval
;
}
}
while
((
isarray
==
ECPG_ARRAY_ARRAY
&&
*
pval
!=
'}'
)
||
(
isarray
==
ECPG_ARRAY_VECTOR
&&
*
pval
!=
'\0'
));
return
(
true
);
}
src/interfaces/ecpg/ecpglib/execute.c
View file @
87758314
This diff is collapsed.
Click to expand it.
src/interfaces/ecpg/ecpglib/extern.h
View file @
87758314
...
...
@@ -12,13 +12,18 @@ enum COMPAT_MODE
#define INFORMIX_MODE(X) ((X) == ECPG_COMPAT_INFORMIX || (X) == ECPG_COMPAT_INFORMIX_SE)
enum
ARRAY_TYPE
{
ECPG_ARRAY_NOT_SET
,
ECPG_ARRAY_ARRAY
,
ECPG_ARRAY_VECTOR
,
ECPG_ARRAY_NONE
};
/* Here are some methods used by the lib. */
/* Returns a pointer to a string containing a simple type name. */
void
ECPGadd_mem
(
void
*
ptr
,
int
lineno
);
bool
ECPGget_data
(
const
PGresult
*
,
int
,
int
,
int
,
enum
ECPGttype
type
,
enum
ECPGttype
,
char
*
,
char
*
,
long
,
long
,
long
,
bool
,
enum
COMPAT_MODE
,
bool
);
enum
ECPGttype
,
char
*
,
char
*
,
long
,
long
,
long
,
enum
ARRAY_TYPE
,
enum
COMPAT_MODE
,
bool
);
struct
connection
*
ECPGget_connection
(
const
char
*
);
char
*
ECPGalloc
(
long
,
int
);
char
*
ECPGrealloc
(
void
*
,
long
,
int
);
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
87758314
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.26
3 2003/10/22 16:43:42 tgl
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.26
4 2003/11/08 19:46:27 meskes
Exp $ */
/* Copyright comment */
%{
...
...
@@ -2056,7 +2056,7 @@ access_method_clause: USING access_method
;
index_params: index_elem { $$ = $1; }
| index_params ',' index_elem { $$ =
$1
; }
| index_params ',' index_elem { $$ =
cat_str(3, $1, make_str(","), $3)
; }
;
index_elem: attr_name opt_class
...
...
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