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
991b9740
Commit
991b9740
authored
Feb 22, 2000
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
62f06459
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
623 additions
and
333 deletions
+623
-333
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+5
-0
src/interfaces/ecpg/TODO
src/interfaces/ecpg/TODO
+2
-0
src/interfaces/ecpg/include/ecpgerrno.h
src/interfaces/ecpg/include/ecpgerrno.h
+2
-0
src/interfaces/ecpg/include/ecpglib.h
src/interfaces/ecpg/include/ecpglib.h
+1
-0
src/interfaces/ecpg/include/ecpgtype.h
src/interfaces/ecpg/include/ecpgtype.h
+20
-0
src/interfaces/ecpg/lib/Makefile.in
src/interfaces/ecpg/lib/Makefile.in
+2
-2
src/interfaces/ecpg/lib/descriptor.c
src/interfaces/ecpg/lib/descriptor.c
+152
-1
src/interfaces/ecpg/lib/dynamic.c
src/interfaces/ecpg/lib/dynamic.c
+19
-8
src/interfaces/ecpg/lib/ecpglib.c
src/interfaces/ecpg/lib/ecpglib.c
+12
-12
src/interfaces/ecpg/preproc/descriptor.c
src/interfaces/ecpg/preproc/descriptor.c
+39
-122
src/interfaces/ecpg/preproc/ecpg_keywords.c
src/interfaces/ecpg/preproc/ecpg_keywords.c
+12
-0
src/interfaces/ecpg/preproc/extern.h
src/interfaces/ecpg/preproc/extern.h
+3
-2
src/interfaces/ecpg/preproc/keywords.c
src/interfaces/ecpg/preproc/keywords.c
+3
-1
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/pgc.l
+79
-53
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+191
-119
src/interfaces/ecpg/preproc/type.c
src/interfaces/ecpg/preproc/type.c
+62
-3
src/interfaces/ecpg/preproc/type.h
src/interfaces/ecpg/preproc/type.h
+3
-3
src/interfaces/ecpg/preproc/variable.c
src/interfaces/ecpg/preproc/variable.c
+3
-2
src/interfaces/ecpg/test/dyntest.pgc
src/interfaces/ecpg/test/dyntest.pgc
+9
-1
src/interfaces/ecpg/test/test2.pgc
src/interfaces/ecpg/test/test2.pgc
+2
-2
src/interfaces/ecpg/test/test3.pgc
src/interfaces/ecpg/test/test3.pgc
+2
-2
No files found.
src/interfaces/ecpg/ChangeLog
View file @
991b9740
...
...
@@ -819,5 +819,10 @@ Thu Feb 17 19:37:44 CET 2000
- Synced preproc.y with gram.y.
- Started to clean up preproc.y.
Tue Feb 22 13:48:18 CET 2000
- Synced preproc.y with gram.y.
- Much more clean ups.
- Set library version to 3.1.0.
- Set ecpg version to 2.7.0.
src/interfaces/ecpg/TODO
View file @
991b9740
...
...
@@ -28,6 +28,8 @@ instead of libpq so we can write backend functions using ecpg.
make ECPGnumeric_lvalue more accurate by using something like ECPGdump_a_*
remove space_or_nl and line_end from pgc.l
Missing statements:
- exec sql ifdef
- SQLSTATE
src/interfaces/ecpg/include/ecpgerrno.h
View file @
991b9740
...
...
@@ -32,6 +32,8 @@
/* dynamic SQL related */
#define ECPG_UNKNOWN_DESCRIPTOR -240
#define ECPG_INVALID_DESCRIPTOR_INDEX -241
#define ECPG_UNKNOWN_DESCRIPTOR_ITEM -242
#define ECPG_VAR_NOT_NUMERIC -243
/* finally the backend error messages, they start at 400 */
#define ECPG_PGSQL -400
...
...
src/interfaces/ecpg/include/ecpglib.h
View file @
991b9740
...
...
@@ -61,6 +61,7 @@ extern "C"
bool
ECPGallocate_desc
(
int
line
,
const
char
*
name
);
void
ECPGraise
(
int
line
,
int
code
,
const
char
*
str
);
bool
ECPGget_desc_header
(
int
,
char
*
,
int
*
);
bool
ECPGget_desc
(
int
,
char
*
,
int
,
...);
#ifdef __cplusplus
...
...
src/interfaces/ecpg/include/ecpgtype.h
View file @
991b9740
...
...
@@ -49,6 +49,26 @@ extern "C"
ECPGt_EORT
,
/* End of result types. */
ECPGt_NO_INDICATOR
/* no indicator */
};
enum
ECPGdtype
{
ECPGd_count
,
ECPGd_data
,
ECPGd_di_code
,
ECPGd_di_precision
,
ECPGd_indicator
,
ECPGd_key_member
,
ECPGd_length
,
ECPGd_name
,
ECPGd_nullable
,
ECPGd_octet
,
ECPGd_precision
,
ECPGd_ret_length
,
ECPGd_ret_octet
,
ECPGd_scale
,
ECPGd_type
,
ECPGd_EODT
,
/* End of descriptor types. */
};
#define IS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2)
...
...
src/interfaces/ecpg/lib/Makefile.in
View file @
991b9740
...
...
@@ -6,7 +6,7 @@
# Copyright (c) 1994, Regents of the University of California
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.5
8 2000/02/16 16:18
:05 meskes Exp $
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.5
9 2000/02/22 19:57
:05 meskes Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -23,7 +23,7 @@ ifdef KRBVERS
CFLAGS
+=
$(KRBFLAGS)
endif
OBJS
=
ecpglib.o typename.o
OBJS
=
ecpglib.o typename.o
descriptor.o
SHLIB_LINK
=
-L
../../libpq
-lpq
...
...
src/interfaces/ecpg/lib/descriptor.c
View file @
991b9740
...
...
@@ -10,6 +10,157 @@ ECPGget_desc_header(int lineno, char * desc_name, int *count)
return
false
;
*
count
=
PQnfields
(
ECPGresult
);
ECPGlog
(
"ECPGget
-desc_header: found %d s
ttributes.
\n
"
,
*
count
);
ECPGlog
(
"ECPGget
_desc_header: found %d a
ttributes.
\n
"
,
*
count
);
return
true
;
}
static
bool
get_int_item
(
int
lineno
,
void
*
var
,
enum
ECPGdtype
vartype
,
int
value
)
{
switch
(
vartype
)
{
case
ECPGt_short
:
*
(
short
*
)
var
=
value
;
break
;
case
ECPGt_int
:
*
(
int
*
)
var
=
value
;
break
;
case
ECPGt_long
:
*
(
long
*
)
var
=
value
;
break
;
case
ECPGt_unsigned_short
:
*
(
unsigned
short
*
)
var
=
value
;
break
;
case
ECPGt_unsigned_int
:
*
(
unsigned
int
*
)
var
=
value
;
break
;
case
ECPGt_unsigned_long
:
*
(
unsigned
long
*
)
var
=
value
;
break
;
case
ECPGt_float
:
*
(
float
*
)
var
=
value
;
break
;
case
ECPGt_double
:
*
(
double
*
)
var
=
value
;
break
;
default:
ECPGraise
(
lineno
,
ECPG_VAR_NOT_NUMERIC
,
NULL
);
return
(
false
);
}
return
(
true
);
}
bool
ECPGget_desc
(
int
lineno
,
char
*
desc_name
,
int
index
,
...)
{
va_list
args
;
PGresult
*
ECPGresult
=
ECPGresultByDescriptor
(
lineno
,
desc_name
);
enum
ECPGdtype
type
;
bool
DataButNoIndicator
=
false
;
va_start
(
args
,
index
);
if
(
!
ECPGresult
)
return
(
false
);
if
(
PQntuples
(
ECPGresult
)
<
1
)
{
ECPGraise
(
lineno
,
ECPG_NOT_FOUND
,
NULL
);
return
(
false
);
}
if
(
index
<
1
||
index
>
PQnfields
(
ECPGresult
))
{
ECPGraise
(
lineno
,
ECPG_INVALID_DESCRIPTOR_INDEX
,
NULL
);
return
(
false
);
}
ECPGlog
(
"ECPGget_desc: reading items for tuple %d
\n
"
,
index
);
--
index
;
type
=
va_arg
(
args
,
enum
ECPGdtype
);
while
(
type
!=
ECPGd_EODT
)
{
char
type_str
[
20
];
long
varcharsize
;
long
offset
;
long
arrsize
;
enum
ECPGttype
vartype
;
void
*
var
;
vartype
=
va_arg
(
args
,
enum
ECPGttype
);
var
=
va_arg
(
args
,
void
*
);
varcharsize
=
va_arg
(
args
,
long
);
arrsize
=
va_arg
(
args
,
long
);
offset
=
va_arg
(
args
,
long
);
switch
(
type
)
{
case
(
ECPGd_indicator
):
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
-
PQgetisnull
(
ECPGresult
,
0
,
index
)))
return
(
false
);
break
;
case
ECPGd_name
:
strncpy
((
char
*
)
var
,
PQfname
(
ECPGresult
,
index
),
varcharsize
);
break
;
case
ECPGd_nullable
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
1
))
return
(
false
);
break
;
case
ECPGd_key_member
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
0
))
return
(
false
);
break
;
case
ECPGd_scale
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
(
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
)
&
0xffff
))
return
(
false
);
break
;
case
ECPGd_precision
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfmod
(
ECPGresult
,
index
)
>>
16
))
return
(
false
);
break
;
case
ECPGd_ret_length
:
case
ECPGd_ret_octet
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQgetlength
(
ECPGresult
,
0
,
index
)))
return
(
false
);
break
;
case
ECPGd_octet
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfsize
(
ECPGresult
,
index
)))
return
(
false
);
break
;
case
ECPGd_length
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfmod
(
ECPGresult
,
index
)
-
VARHDRSZ
))
return
(
false
);
break
;
case
ECPGd_type
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
ECPGDynamicType
(
PQftype
(
ECPGresult
,
index
))))
return
(
false
);
break
;
default:
snprintf
(
type_str
,
sizeof
(
type_str
),
"%d"
,
type
);
ECPGraise
(
lineno
,
ECPG_UNKNOWN_DESCRIPTOR_ITEM
,
type_str
);
return
(
false
);
}
type
=
va_arg
(
args
,
enum
ECPGdtype
);
}
if
(
DataButNoIndicator
&&
PQgetisnull
(
ECPGresult
,
0
,
index
))
{
ECPGraise
(
lineno
,
ECPG_MISSING_INDICATOR
,
NULL
);
return
(
false
);
}
return
(
true
);
}
src/interfaces/ecpg/lib/dynamic.c
View file @
991b9740
...
...
@@ -2,7 +2,7 @@
*
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
*
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.
4 2000/02/18 16:02:49
meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.
5 2000/02/22 19:57:05
meskes Exp $
*/
/* I borrowed the include files from ecpglib.c, maybe we don't need all of them */
...
...
@@ -198,7 +198,7 @@ bool ECPGdo_descriptor(int line,const char *connection,
/* free previous result */
if
(
i
->
result
)
PQclear
(
i
->
result
);
i
->
result
=
NULL
;
i
->
result
=
NULL
;
status
=
do_descriptor2
(
line
,
connection
,
&
i
->
result
,
query
);
...
...
@@ -206,7 +206,8 @@ bool ECPGdo_descriptor(int line,const char *connection,
return
(
status
);
}
}
ECPGraise
(
line
,
ECPG_UNKNOWN_DESCRIPTOR
,
NULL
);
ECPGraise
(
line
,
ECPG_UNKNOWN_DESCRIPTOR
,
descriptor
);
return
false
;
}
...
...
@@ -219,7 +220,7 @@ PGresult *ECPGresultByDescriptor(int line,const char *name)
if
(
!
strcmp
(
name
,
i
->
name
))
return
i
->
result
;
}
ECPGraise
(
line
,
ECPG_UNKNOWN_DESCRIPTOR
,
NULL
);
ECPGraise
(
line
,
ECPG_UNKNOWN_DESCRIPTOR
,
name
);
return
NULL
;
}
...
...
@@ -238,7 +239,7 @@ bool ECPGdeallocate_desc(int line,const char *name)
return
true
;
}
}
ECPGraise
(
line
,
ECPG_UNKNOWN_DESCRIPTOR
,
NULL
);
ECPGraise
(
line
,
ECPG_UNKNOWN_DESCRIPTOR
,
name
);
return
false
;
}
...
...
@@ -259,7 +260,7 @@ ECPGraise(int line, int code, const char *str)
{
struct
auto_mem
*
am
;
sqlca
.
sqlcode
=
code
;
sqlca
.
sqlcode
=
code
;
switch
(
code
)
{
case
ECPG_NOT_FOUND
:
...
...
@@ -294,15 +295,25 @@ ECPGraise(int line, int code, const char *str)
case
ECPG_UNKNOWN_DESCRIPTOR
:
snprintf
(
sqlca
.
sqlerrm
.
sqlerrmc
,
sizeof
(
sqlca
.
sqlerrm
.
sqlerrmc
),
"descriptor
not found, line %d."
,
line
);
"descriptor
%s not found, line %d."
,
str
,
line
);
break
;
case
ECPG_INVALID_DESCRIPTOR_INDEX
:
snprintf
(
sqlca
.
sqlerrm
.
sqlerrmc
,
sizeof
(
sqlca
.
sqlerrm
.
sqlerrmc
),
"descriptor index out of range, line %d."
,
line
);
break
;
case
ECPG_UNKNOWN_DESCRIPTOR_ITEM
:
snprintf
(
sqlca
.
sqlerrm
.
sqlerrmc
,
sizeof
(
sqlca
.
sqlerrm
.
sqlerrmc
),
"unknown descriptor item %s, line %d."
,
str
,
line
);
break
;
case
ECPG_VAR_NOT_NUMERIC
:
snprintf
(
sqlca
.
sqlerrm
.
sqlerrmc
,
sizeof
(
sqlca
.
sqlerrm
.
sqlerrmc
),
"variable is not a numeric type, line %d."
,
line
);
break
;
default:
default:
snprintf
(
sqlca
.
sqlerrm
.
sqlerrmc
,
sizeof
(
sqlca
.
sqlerrm
.
sqlerrmc
),
"SQL error #%d, line %d."
,
code
,
line
);
break
;
...
...
src/interfaces/ecpg/lib/ecpglib.c
View file @
991b9740
...
...
@@ -190,7 +190,7 @@ ecpg_alloc(long size, int lineno)
if
(
!
new
)
{
ECPGlog
(
"out of memory
\n
"
);
ECPGraise
(
ECPG_OUT_OF_MEMORY
,
lineno
,
NULL
);
ECPGraise
(
lineno
,
ECPG_OUT_OF_MEMORY
,
NULL
);
return
NULL
;
}
...
...
@@ -206,7 +206,7 @@ ecpg_strdup(const char *string, int lineno)
if
(
!
new
)
{
ECPGlog
(
"out of memory
\n
"
);
ECPGraise
(
ECPG_OUT_OF_MEMORY
,
lineno
,
NULL
);
ECPGraise
(
lineno
,
ECPG_OUT_OF_MEMORY
,
NULL
);
return
NULL
;
}
...
...
@@ -634,7 +634,7 @@ ECPGexecute(struct statement * stmt)
default:
/* Not implemented yet */
ECPGraise
(
ECPG_UNSUPPORTED
,
stmt
->
lineno
,
ECPGtype_name
(
var
->
type
));
ECPGraise
(
stmt
->
lineno
,
ECPG_UNSUPPORTED
,
ECPGtype_name
(
var
->
type
));
return
false
;
break
;
}
...
...
@@ -657,7 +657,7 @@ ECPGexecute(struct statement * stmt)
* We have an argument but we dont have the matched up string
* in the string
*/
ECPGraise
(
ECPG_TOO_MANY_ARGUMENTS
,
stmt
->
lineno
,
NULL
);
ECPGraise
(
stmt
->
lineno
,
ECPG_TOO_MANY_ARGUMENTS
,
NULL
);
return
false
;
}
else
...
...
@@ -694,7 +694,7 @@ ECPGexecute(struct statement * stmt)
/* Check if there are unmatched things left. */
if
(
next_insert
(
copiedquery
)
!=
NULL
)
{
ECPGraise
(
ECPG_TOO_FEW_ARGUMENTS
,
stmt
->
lineno
,
NULL
);
ECPGraise
(
stmt
->
lineno
,
ECPG_TOO_FEW_ARGUMENTS
,
NULL
);
return
false
;
}
...
...
@@ -742,7 +742,7 @@ ECPGexecute(struct statement * stmt)
{
ECPGlog
(
"ECPGexecute line %d: Incorrect number of matches: %d
\n
"
,
stmt
->
lineno
,
ntuples
);
ECPGraise
(
ECPG_NOT_FOUND
,
stmt
->
lineno
,
NULL
);
ECPGraise
(
stmt
->
lineno
,
ECPG_NOT_FOUND
,
NULL
);
status
=
false
;
break
;
}
...
...
@@ -756,7 +756,7 @@ ECPGexecute(struct statement * stmt)
if
(
var
==
NULL
)
{
ECPGlog
(
"ECPGexecute line %d: Too few arguments.
\n
"
,
stmt
->
lineno
);
ECPGraise
(
ECPG_TOO_FEW_ARGUMENTS
,
stmt
->
lineno
,
NULL
);
ECPGraise
(
stmt
->
lineno
,
ECPG_TOO_FEW_ARGUMENTS
,
NULL
);
return
(
false
);
}
...
...
@@ -778,7 +778,7 @@ ECPGexecute(struct statement * stmt)
{
ECPGlog
(
"ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d
\n
"
,
stmt
->
lineno
,
ntuples
,
var
->
arrsize
);
ECPGraise
(
ECPG_TOO_MANY_MATCHES
,
stmt
->
lineno
,
NULL
);
ECPGraise
(
stmt
->
lineno
,
ECPG_TOO_MANY_MATCHES
,
NULL
);
status
=
false
;
break
;
}
...
...
@@ -853,7 +853,7 @@ ECPGexecute(struct statement * stmt)
}
break
;
default:
ECPGraise
(
ECPG_UNSUPPORTED
,
stmt
->
lineno
,
ECPGtype_name
(
var
->
ind_type
));
ECPGraise
(
stmt
->
lineno
,
ECPG_UNSUPPORTED
,
ECPGtype_name
(
var
->
ind_type
));
status
=
false
;
break
;
}
...
...
@@ -1057,7 +1057,7 @@ ECPGexecute(struct statement * stmt)
break
;
default:
ECPGraise
(
ECPG_UNSUPPORTED
,
stmt
->
lineno
,
ECPGtype_name
(
var
->
type
));
ECPGraise
(
stmt
->
lineno
,
ECPG_UNSUPPORTED
,
ECPGtype_name
(
var
->
type
));
status
=
false
;
break
;
}
...
...
@@ -1067,7 +1067,7 @@ ECPGexecute(struct statement * stmt)
if
(
status
&&
var
!=
NULL
)
{
ECPGraise
(
ECPG_TOO_MANY_ARGUMENTS
,
stmt
->
lineno
,
NULL
);
ECPGraise
(
stmt
->
lineno
,
ECPG_TOO_MANY_ARGUMENTS
,
NULL
);
status
=
false
;
}
...
...
@@ -1123,7 +1123,7 @@ ECPGexecute(struct statement * stmt)
}
bool
ECPGdo
(
int
lineno
,
const
char
*
connection_name
,
char
*
query
,...)
ECPGdo
(
int
lineno
,
const
char
*
connection_name
,
char
*
query
,
...)
{
va_list
args
;
struct
statement
*
stmt
;
...
...
src/interfaces/ecpg/preproc/descriptor.c
View file @
991b9740
...
...
@@ -11,15 +11,14 @@
struct
assignment
*
assignments
;
void
push_assignment
(
char
*
var
,
char
*
value
)
void
push_assignment
(
char
*
var
,
enum
ECPGdtype
value
)
{
struct
assignment
*
new
=
(
struct
assignment
*
)
mm_alloc
(
sizeof
(
struct
assignment
));
new
->
next
=
assignments
;
new
->
variable
=
mm_alloc
(
strlen
(
var
)
+
1
);
strcpy
(
new
->
variable
,
var
);
new
->
value
=
mm_alloc
(
strlen
(
value
)
+
1
);
strcpy
(
new
->
value
,
value
);
new
->
variable
=
mm_alloc
(
strlen
(
var
)
+
1
);
strcpy
(
new
->
variable
,
var
);
new
->
value
=
value
;
assignments
=
new
;
}
...
...
@@ -32,7 +31,6 @@ drop_assignments(void)
assignments
=
old_head
->
next
;
free
(
old_head
->
variable
);
free
(
old_head
->
value
);
free
(
old_head
);
}
}
...
...
@@ -61,7 +59,7 @@ static void ECPGnumeric_lvalue(FILE *f,char *name)
static
void
ECPGstring_buffer
(
FILE
*
f
,
char
*
name
)
{
const
struct
variable
*
v
=
find_variable
(
name
);
const
struct
variable
*
v
=
find_variable
(
name
);
switch
(
v
->
type
->
typ
)
{
...
...
@@ -177,17 +175,18 @@ static struct descriptor *descriptors;
void
add_descriptor
(
char
*
name
,
char
*
connection
)
{
struct
descriptor
*
new
=
(
struct
descriptor
*
)
mm_alloc
(
sizeof
(
struct
descriptor
));
struct
descriptor
*
new
=
(
struct
descriptor
*
)
mm_alloc
(
sizeof
(
struct
descriptor
));
new
->
next
=
descriptors
;
new
->
name
=
mm_alloc
(
strlen
(
name
)
+
1
);
new
->
next
=
descriptors
;
new
->
name
=
mm_alloc
(
strlen
(
name
)
+
1
);
strcpy
(
new
->
name
,
name
);
if
(
connection
)
{
new
->
connection
=
mm_alloc
(
strlen
(
connection
)
+
1
);
strcpy
(
new
->
connection
,
connection
);
{
new
->
connection
=
mm_alloc
(
strlen
(
connection
)
+
1
);
strcpy
(
new
->
connection
,
connection
);
}
else
new
->
connection
=
connection
;
descriptors
=
new
;
else
new
->
connection
=
connection
;
descriptors
=
new
;
}
void
...
...
@@ -217,13 +216,13 @@ drop_descriptor(char *name,char *connection)
}
struct
descriptor
*
lookup_descriptor
(
char
*
name
,
char
*
connection
)
*
lookup_descriptor
(
char
*
name
,
char
*
connection
)
{
struct
descriptor
*
i
;
for
(
i
=
descriptors
;
i
;
i
=
i
->
next
)
for
(
i
=
descriptors
;
i
;
i
=
i
->
next
)
{
if
(
!
strcmp
(
name
,
i
->
name
))
if
(
!
strcmp
(
name
,
i
->
name
))
{
if
((
!
connection
&&
!
i
->
connection
)
||
(
connection
&&
i
->
connection
...
...
@@ -233,8 +232,8 @@ struct descriptor
}
}
}
snprintf
(
errortext
,
sizeof
errortext
,
"unknown descriptor %s"
,
name
);
mmerror
(
ET_WARN
,
errortext
);
snprintf
(
errortext
,
sizeof
errortext
,
"unknown descriptor %s"
,
name
);
mmerror
(
ET_WARN
,
errortext
);
return
NULL
;
}
...
...
@@ -246,10 +245,11 @@ output_get_descr_header(char *desc_name)
fprintf
(
yyout
,
"{ ECPGget_desc_header(%d,
\"
%s
\"
, &("
,
yylineno
,
desc_name
);
for
(
results
=
assignments
;
results
!=
NULL
;
results
=
results
->
next
)
{
if
(
!
strcasecmp
(
results
->
value
,
"count"
)
)
if
(
results
->
value
==
ECPGd_count
)
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
else
{
snprintf
(
errortext
,
sizeof
errortext
,
"unknown descriptor header item '%s'"
,
results
->
value
);
{
snprintf
(
errortext
,
sizeof
errortext
,
"unknown descriptor header item '%d'"
,
results
->
value
);
mmerror
(
ET_WARN
,
errortext
);
}
}
...
...
@@ -260,114 +260,31 @@ output_get_descr_header(char *desc_name)
}
void
output_get_descr
(
char
*
desc_name
)
output_get_descr
(
char
*
desc_name
,
char
*
index
)
{
struct
assignment
*
results
;
int
flags
=
0
;
const
int
DATA_SEEN
=
1
;
const
int
INDICATOR_SEEN
=
2
;
fprintf
(
yyout
,
"{
\t
PGresult *ECPGresult=ECPGresultByDescriptor(%d,
\"
%s
\"
);
\n
"
,
yylineno
,
desc_name
);
fputs
(
"
\t
if (ECPGresult)
\n\t
{"
,
yyout
);
fprintf
(
yyout
,
"
\t
if (PQntuples(ECPGresult)<1) ECPGraise(%d,ECPG_NOT_FOUND);
\n
"
,
yylineno
);
fprintf
(
yyout
,
"
\t\t
else if (%s<1 || %s>PQnfields(ECPGresult))
\n
"
"
\t\t\t
ECPGraise(%d,ECPG_INVALID_DESCRIPTOR_INDEX);
\n
"
,
descriptor_index
,
descriptor_index
,
yylineno
);
fputs
(
"
\t\t
else
\n\t\t
{
\n
"
,
yyout
);
for
(
results
=
assignments
;
results
!=
NULL
;
results
=
results
->
next
)
fprintf
(
yyout
,
"{ ECPGget_desc(%d,
\"
%s
\"
,%s,"
,
yylineno
,
desc_name
,
index
);
for
(
results
=
assignments
;
results
!=
NULL
;
results
=
results
->
next
)
{
if
(
!
strcasecmp
(
results
->
value
,
"type"
))
{
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=ECPGDynamicType(PQftype(ECPGresult,(%s)-1));
\n
"
,
descriptor_index
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"datetime_interval_code"
))
{
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=ECPGDynamicType_DDT(PQftype(ECPGresult,(%s)-1));
\n
"
,
descriptor_index
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"length"
))
{
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=PQfmod(ECPGresult,(%s)-1)-VARHDRSZ;
\n
"
,
descriptor_index
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"octet_length"
))
{
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=PQfsize(ECPGresult,(%s)-1);
\n
"
,
descriptor_index
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"returned_length"
)
||
!
strcasecmp
(
results
->
value
,
"returned_octet_length"
))
{
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=PQgetlength(ECPGresult,0,(%s)-1);
\n
"
,
descriptor_index
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"precision"
))
{
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=PQfmod(ECPGresult,(%s)-1)>>16;
\n
"
,
descriptor_index
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"scale"
))
{
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=(PQfmod(ECPGresult,(%s)-1)-VARHDRSZ)&0xffff;
\n
"
,
descriptor_index
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"nullable"
))
{
mmerror
(
ET_WARN
,
"nullable is always 1"
);
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=1;
\n
"
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"key_member"
))
{
mmerror
(
ET_WARN
,
"key_member is always 0"
);
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=0;
\n
"
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"name"
))
{
fputs
(
"
\t\t\t
strncpy("
,
yyout
);
ECPGstring_buffer
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
",PQfname(ECPGresult,(%s)-1),"
,
descriptor_index
);
ECPGstring_length
(
yyout
,
results
->
variable
);
fputs
(
");
\n
"
,
yyout
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"indicator"
))
{
flags
|=
INDICATOR_SEEN
;
fputs
(
"
\t\t\t
"
,
yyout
);
ECPGnumeric_lvalue
(
yyout
,
results
->
variable
);
fprintf
(
yyout
,
"=-PQgetisnull(ECPGresult,0,(%s)-1);
\n
"
,
descriptor_index
);
}
else
if
(
!
strcasecmp
(
results
->
value
,
"data"
))
{
flags
|=
DATA_SEEN
;
ECPGdata_assignment
(
results
->
variable
,
descriptor_index
);
}
else
const
struct
variable
*
v
=
find_variable
(
results
->
variable
);
switch
(
results
->
value
)
{
snprintf
(
errortext
,
sizeof
errortext
,
"unknown descriptor header item '%s'"
,
results
->
value
);
mmerror
(
ET_WARN
,
errortext
);
case
ECPGd_nullable
:
mmerror
(
ET_WARN
,
"nullable is always 1"
);
break
;
case
ECPGd_key_member
:
mmerror
(
ET_WARN
,
"key_member is always 0"
);
break
;
default:
break
;
}
}
if
(
flags
==
DATA_SEEN
)
/* no indicator */
{
fprintf
(
yyout
,
"
\t\t\t
if (PQgetisnull(ECPGresult,0,(%s)-1))
\n
"
"
\t\t\t\t
ECPGraise(%d,ECPG_MISSING_INDICATOR);
\n
"
,
descriptor_index
,
yylineno
);
fprintf
(
yyout
,
"%s,"
,
get_dtype
(
results
->
value
));
ECPGdump_a_type
(
yyout
,
v
->
name
,
v
->
type
,
NULL
,
NULL
,
NULL
,
NULL
);
}
drop_assignments
();
fputs
(
"
\t\t
}
\n\t
}
\n
"
,
yyout
);
fputs
(
"
ECPGd_EODT);
\n
"
,
yyout
);
whenever_action
(
2
|
1
);
}
src/interfaces/ecpg/preproc/ecpg_keywords.c
View file @
991b9740
...
...
@@ -28,6 +28,10 @@ static ScanKeyword ScanKeywords[] = {
{
"connect"
,
SQL_CONNECT
},
{
"connection"
,
SQL_CONNECTION
},
{
"continue"
,
SQL_CONTINUE
},
{
"count"
,
SQL_COUNT
},
{
"data"
,
SQL_DATA
},
{
"datetime_interval_code"
,
SQL_DATETIME_INTERVAL_CODE
},
{
"datetime_interval_precision"
,
SQL_DATETIME_INTERVAL_PRECISION
},
{
"deallocate"
,
SQL_DEALLOCATE
},
{
"descriptor"
,
SQL_DESCRIPTOR
},
{
"disconnect"
,
SQL_DISCONNECT
},
...
...
@@ -40,12 +44,20 @@ static ScanKeyword ScanKeywords[] = {
{
"identified"
,
SQL_IDENTIFIED
},
{
"indicator"
,
SQL_INDICATOR
},
{
"int"
,
SQL_INT
},
{
"key_member"
,
SQL_KEY_MEMBER
},
{
"length"
,
SQL_LENGTH
},
{
"long"
,
SQL_LONG
},
{
"name"
,
SQL_NAME
},
{
"nullable"
,
SQL_NULLABLE
},
{
"octet_length"
,
SQL_OCTET_LENGTH
},
{
"off"
,
SQL_OFF
},
{
"open"
,
SQL_OPEN
},
{
"prepare"
,
SQL_PREPARE
},
{
"reference"
,
SQL_REFERENCE
},
{
"release"
,
SQL_RELEASE
},
{
"returned_length"
,
SQL_RETURNED_LENGTH
},
{
"returned_octet_length"
,
SQL_RETURNED_OCTET_LENGTH
},
{
"scale"
,
SQL_SCALE
},
{
"section"
,
SQL_SECTION
},
{
"short"
,
SQL_SHORT
},
{
"signed"
,
SQL_SIGNED
},
...
...
src/interfaces/ecpg/preproc/extern.h
View file @
991b9740
...
...
@@ -35,6 +35,7 @@ extern struct descriptor *descriptors;
/* functions */
extern
const
char
*
get_dtype
(
enum
ECPGdtype
);
extern
void
lex_init
(
void
);
extern
char
*
make_str
(
const
char
*
);
extern
void
output_line_number
(
void
);
...
...
@@ -50,8 +51,8 @@ extern void mmerror(enum errortype, char * );
extern
ScanKeyword
*
ScanECPGKeywordLookup
(
char
*
);
extern
ScanKeyword
*
ScanCKeywordLookup
(
char
*
);
extern
void
output_get_descr_header
(
char
*
);
extern
void
output_get_descr
(
char
*
);
extern
void
push_assignment
(
char
*
,
char
*
);
extern
void
output_get_descr
(
char
*
,
char
*
);
extern
void
push_assignment
(
char
*
,
enum
ECPGdtype
);
extern
struct
variable
*
find_variable
(
char
*
);
extern
void
whenever_action
(
int
);
extern
void
add_descriptor
(
char
*
,
char
*
);
...
...
src/interfaces/ecpg/preproc/keywords.c
View file @
991b9740
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.2
2 2000/02/15 12:15:54
meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.2
3 2000/02/22 19:57:10
meskes Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -108,6 +108,7 @@ static ScanKeyword ScanKeywords[] = {
{
"fetch"
,
FETCH
},
{
"float"
,
FLOAT
},
{
"for"
,
FOR
},
{
"force"
,
FORCE
},
{
"foreign"
,
FOREIGN
},
{
"forward"
,
FORWARD
},
{
"from"
,
FROM
},
...
...
@@ -197,6 +198,7 @@ static ScanKeyword ScanKeywords[] = {
{
"public"
,
PUBLIC
},
{
"read"
,
READ
},
{
"references"
,
REFERENCES
},
{
"reindex"
,
REINDEX
},
{
"relative"
,
RELATIVE
},
{
"rename"
,
RENAME
},
{
"reset"
,
RESET
},
...
...
src/interfaces/ecpg/preproc/pgc.l
View file @
991b9740
...
...
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.5
0 2000/01/27 19:00:39
meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.5
1 2000/02/22 19:57:10
meskes Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -70,29 +70,26 @@ static struct _if_value {
} stacked_if_value[MAX_NESTED_IF];
%}
%option yylineno
%s C SQL incl def def_ident
/* OK, here is a short description of lex/flex rules behavior.
/*
* OK, here is a short description of lex/flex rules behavior.
* The longest pattern which matches an input string is always chosen.
* For equal-length patterns, the first occurring in the rules list is chosen.
* INITIAL is the starting condition, to which all non-conditional rules apply.
* When in an exclusive condition, only those rules defined for that condition apply.
* INITIAL is the starting state, to which all non-conditional rules apply.
* Exclusive states change parsing rules while the state is active. When in
* an exclusive state, only those rules defined for that state apply.
*
* Exclusive states change parsing rules while the state is active.
* There are exclusive states for quoted strings, extended comments,
* and to eliminate parsing troubles for numeric strings.
* We use exclusive states for quoted strings, extended comments,
* and to eliminate parsing troubles for numeric strings.
* Exclusive states:
* <xb> binary numeric string - thomas 1997-11-16
* <xc> extended C-style comments - tgl 1997-07-12
* <xd> delimited identifiers (double-quoted identifiers) - tgl 1997-10-27
* <xh> hexadecimal numeric string - thomas 1997-11-16
* <xq> quoted strings - tgl 1997-07-30
*
* The "extended comment" syntax closely resembles allowable operator syntax.
* So, when in condition <xc>, only strings which would terminate the
* "extended comment" trigger any action other than "ignore".
* Be sure to match _any_ candidate comment, including those with appended
* operator-like symbols. - thomas 1997-07-14
*/
%x xb
...
...
@@ -109,15 +106,15 @@ static struct _if_value {
*/
xbstart [bB]{quote}
xbstop {quote}
xbinside [^']
*
xbcat {quote}{
space}*\n{space}*
{quote}
xbinside [^']
+
xbcat {quote}{
whitespace_with_newline}
{quote}
/* Hexadecimal number
*/
xhstart [xX]{quote}
xhstop {quote}
xhinside [^']
*
xhcat {quote}{
space}*\n{space}*
{quote}
xhinside [^']
+
xhcat {quote}{
whitespace_with_newline}
{quote}
/* C version of hex number
*/
...
...
@@ -131,9 +128,9 @@ quote '
xqstart {quote}
xqstop {quote}
xqdouble {quote}{quote}
xqinside [^\\']
*
xqinside [^\\']
+
xqliteral [\\](.|\n)
xqcat {quote}{
space}*\n{space}*
{quote}
xqcat {quote}{
whitespace_with_newline}
{quote}
/* Delimited quote
* Allows embedded spaces and other special characters into identifiers.
...
...
@@ -141,7 +138,7 @@ xqcat {quote}{space}*\n{space}*{quote}
dquote \"
xdstart {dquote}
xdstop {dquote}
xdinside [^"]
*
xdinside [^"]
+
/* special stuff for C strings */
xdcqq \\\\
...
...
@@ -149,14 +146,25 @@ xdcqdq \\\"
xdcother [^"]
xdcinside ({xdcqq}|{xdcqdq}|{xdcother})
/* Comments
/* C
-Style C
omments
* Ignored by the scanner and parser.
* The "extended comment" syntax closely resembles allowable operator syntax.
* The tricky part here is to get lex to recognize a string starting with
* slash-star as a comment, when interpreting it as an operator would produce
* a longer match --- remember lex will prefer a longer match! So, we have
* to provide a special rule for xcline (a complete comment that could
* otherwise look like an operator), as well as append {op_and_self}* to
* xcstart so that it matches at least as much as {operator} would.
* Then the tie-breaker (first matching rule of same length) wins.
* There is still a problem if someone writes, eg, slash-star-star-slash-plus.
* It'll be taken as an xcstart, rather than xcline and an operator as one
* could wish. I don't see any way around that given lex's behavior;
* that someone will just have to write a space after the comment.
*/
xcline [\/][\*].*[\*][\/]{line_end}+
xcstart [\/][\*]{op_and_self}*
xcstop {op_and_self}*[\*][\/]{space_or_nl}*
xcinside [^*]*
xcstar [^/]
xcline \/\*{op_and_self}*\*\/
xcstart \/\*{op_and_self}*
xcstop \*+\/
xcinside ([^*]+)|(\*+[^/])
digit [0-9]
letter [\200-\377_A-Za-z]
...
...
@@ -181,12 +189,44 @@ real ((({digit}*\.{digit}+)|({digit}+\.{digit}*)|({digit}+))([Ee][-+]?{digit}+
param \${integer}
comment ("--"|"//").*
/*
* In order to make the world safe for Windows and Mac clients as well as
* Unix ones, we accept either \n or \r as a newline. A DOS-style \r\n
* sequence will be seen as two successive newlines, but that doesn't cause
* any problems. SQL92-style comments, which start with -- and extend to the
* next newline, are treated as equivalent to a single whitespace character.
*
* NOTE a fine point: if there is no newline following --, we will absorb
* everything to the end of the input as a comment. This is correct. Older
* versions of Postgres failed to recognize -- as a comment if the input
* did not end with a newline.
*
* XXX perhaps \f (formfeed) should be treated as a newline as well?
*/
ccomment "//".*\n
space [ \t\r\f]
space_or_nl [ \t\r\f\n]
line_end {space}*\n
line_end {space}*\n
horiz_space [ \t\f]
newline [\n\r]
non_newline [^\n\r]
comment (("--"|"//"){non_newline}*)
whitespace ({space}|{comment})
/*
* SQL92 requires at least one newline in the whitespace separating
* string literals that are to be concatenated. Silly, but who are we
* to argue? Note that {whitespace_with_newline} should not have * after
* it, whereas {whitespace} should generally have a * after it...
*/
horiz_whitespace ({horiz_space}|{comment})
whitespace_with_newline ({horiz_whitespace}*{newline}{whitespace}*)
other .
/* some stuff needed for ecpg */
...
...
@@ -217,14 +257,16 @@ cppline {space}*#(.*\\{line_end})*.*
* of escaped-quote "\'".
* Other embedded escaped characters are matched explicitly and the leading
* backslash is dropped from the string. - thomas 1997-09-24
* Note that xcline must appear before xcstart, which must appear before
* operator, as explained above! Also whitespace (comment) must appear
* before operator.
*/
%%
<SQL>{
comment}
{ /* ignore */ }
<SQL>{
whitespace}
{ /* ignore */ }
{xcline} { ECHO; }
<xc>{xcstar} { ECHO; }
{xcstart} {
before_comment = YYSTATE;
ECHO;
...
...
@@ -254,7 +296,7 @@ cppline {space}*#(.*\\{line_end})*.*
addlit(yytext, yyleng);
}
<xh>{xhcat} |
<xb>{xbcat} {
<xb>{xbcat} {
/* ignore */
}
<SQL>{xhstart} {
...
...
@@ -286,7 +328,7 @@ cppline {space}*#(.*\\{line_end})*.*
<xq>{xqliteral} {
addlit(yytext, yyleng);
}
<xq>{xqcat} {
<xq>{xqcat} {
/* ignore */
}
<SQL>{xdstart} {
...
...
@@ -331,43 +373,28 @@ cppline {space}*#(.*\\{line_end})*.*
return Op;
}
<SQL>{param} {
yylval.ival = ato
i
((char*)&yytext[1]);
yylval.ival = ato
l
((char*)&yytext[1]);
return PARAM;
}
<C,SQL>{integer} {
char* endptr;
errno = 0;
yylval.ival = strtol((char *)yytext,&endptr,10);
yylval.ival = strtol((char *)yytext,
&endptr,10);
if (*endptr != '\0' || errno == ERANGE)
{
errno = 0;
yylval.str = mm_strdup((char*)yytext);
return
S
CONST;
return
F
CONST;
}
return ICONST;
}
{decimal} {
char* endptr;
if (strlen((char *)yytext) <= 17)
{
errno = 0;
yylval.dval = strtod((char *)yytext,&endptr);
if (*endptr != '\0' || errno == ERANGE)
mmerror(ET_ERROR, "Bad float8 input");
return FCONST;
}
yylval.str = mm_strdup((char*)yytext);
return
S
CONST;
return
F
CONST;
}
<C,SQL>{real} {
char* endptr;
errno = 0;
yylval.dval = strtod((char *)yytext,&endptr);
if (*endptr != '\0' || errno == ERANGE)
mmerror(ET_ERROR, "Bad float input");
yylval.str = mm_strdup((char*)yytext);
return FCONST;
}
<SQL>:{identifier}(("->"|\.){identifier})* {
...
...
@@ -433,7 +460,6 @@ cppline {space}*#(.*\\{line_end})*.*
}
}
}
<SQL>{space_or_nl} { /* ignore */ }
<SQL>{other} { return yytext[0]; }
<C>{exec_sql} { BEGIN SQL; return SQL_START; }
<C>{ccomment} { /* ignore */ }
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
991b9740
This diff is collapsed.
Click to expand it.
src/interfaces/ecpg/preproc/type.c
View file @
991b9740
...
...
@@ -163,7 +163,7 @@ get_type(enum ECPGttype typ)
return
(
"ECPGt_NO_INDICATOR"
);
break
;
case
ECPGt_char_variable
:
/* string that should not be
* quoted */
* quoted */
return
(
"ECPGt_char_variable"
);
break
;
default:
...
...
@@ -198,12 +198,13 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, l
void
ECPGdump_a_type
(
FILE
*
o
,
const
char
*
name
,
struct
ECPGtype
*
typ
,
const
char
*
ind_name
,
struct
ECPGtype
*
ind_typ
,
const
char
*
prefix
,
const
char
*
ind_prefix
)
{
#if 0
if (ind_typ == NULL)
{
ind_typ = &ecpg_no_indicator;
ind_name = "no_indicator";
}
#endif
switch
(
typ
->
typ
)
{
case
ECPGt_array
:
...
...
@@ -248,7 +249,8 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in
break
;
default:
ECPGdump_a_simple
(
o
,
name
,
typ
->
typ
,
typ
->
size
,
-
1
,
NULL
,
prefix
);
ECPGdump_a_simple
(
o
,
ind_name
,
ind_typ
->
typ
,
ind_typ
->
size
,
-
1
,
NULL
,
ind_prefix
);
if
(
ind_typ
!=
NULL
)
ECPGdump_a_simple
(
o
,
ind_name
,
ind_typ
->
typ
,
ind_typ
->
size
,
-
1
,
NULL
,
ind_prefix
);
break
;
}
}
...
...
@@ -399,3 +401,60 @@ ECPGfree_type(struct ECPGtype * typ)
}
free
(
typ
);
}
const
char
*
get_dtype
(
enum
ECPGdtype
typ
)
{
switch
(
typ
)
{
case
ECPGd_count
:
return
(
"ECPGd_countr"
);
break
;
case
ECPGd_data
:
return
(
"ECPGd_data"
);
break
;
case
ECPGd_di_code
:
return
(
"ECPGd_di_code"
);
break
;
case
ECPGd_di_precision
:
return
(
"ECPGd_di_precision"
);
break
;
case
ECPGd_indicator
:
return
(
"ECPGd_indicator"
);
break
;
case
ECPGd_key_member
:
return
(
"ECPGd_key_member"
);
break
;
case
ECPGd_length
:
return
(
"ECPGd_length"
);
break
;
case
ECPGd_name
:
return
(
"ECPGd_name"
);
break
;
case
ECPGd_nullable
:
return
(
"ECPGd_nullable"
);
break
;
case
ECPGd_octet
:
return
(
"ECPGd_octet"
);
break
;
case
ECPGd_precision
:
return
(
"ECPGd_precision"
);
break
;
case
ECPGd_ret_length
:
return
(
"ECPGd_ret_length"
);
case
ECPGd_ret_octet
:
return
(
"ECPGd_ret_octet"
);
break
;
case
ECPGd_scale
:
return
(
"ECPGd_scale"
);
break
;
case
ECPGd_type
:
return
(
"ECPGd_type"
);
break
;
default:
sprintf
(
errortext
,
"illegal descriptor item %d
\n
"
,
typ
);
yyerror
(
errortext
);
}
return
NULL
;
}
src/interfaces/ecpg/preproc/type.h
View file @
991b9740
...
...
@@ -148,9 +148,9 @@ struct descriptor
struct
assignment
{
char
*
variable
;
char
*
value
;
struct
assignment
*
next
;
char
*
variable
;
enum
ECPGdtype
value
;
struct
assignment
*
next
;
};
enum
errortype
{
ET_WARN
,
ET_ERROR
,
ET_FATAL
};
...
...
src/interfaces/ecpg/preproc/variable.c
View file @
991b9740
...
...
@@ -222,8 +222,9 @@ dump_variables(struct arguments * list, int mode)
/* Then the current element and its indicator */
ECPGdump_a_type
(
yyout
,
list
->
variable
->
name
,
list
->
variable
->
type
,
(
list
->
indicator
->
type
->
typ
!=
ECPGt_NO_INDICATOR
)
?
list
->
indicator
->
name
:
NULL
,
(
list
->
indicator
->
type
->
typ
!=
ECPGt_NO_INDICATOR
)
?
list
->
indicator
->
type
:
NULL
,
NULL
,
NULL
);
/* (list->indicator->type->typ != ECPGt_NO_INDICATOR) ? list->indicator->name : NULL,
(list->indicator->type->typ != ECPGt_NO_INDICATOR) ? list->indicator->type : NULL, NULL, NULL);*/
list
->
indicator
->
name
,
list
->
indicator
->
type
,
NULL
,
NULL
);
/* Then release the list element. */
if
(
mode
!=
0
)
...
...
src/interfaces/ecpg/test/dyntest.pgc
View file @
991b9740
...
...
@@ -2,7 +2,7 @@
*
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
*
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.
2 2000/02/17 19:48:58
meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.
3 2000/02/22 19:57:12
meskes Exp $
*/
#include <stdio.h>
...
...
@@ -30,6 +30,10 @@ int main(int argc,char **argv)
char QUERY[1024];
exec sql end declare section;
int done=0;
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
snprintf(QUERY,sizeof QUERY,"select * from %s",argc>1?argv[1]:"pg_tables");
...
...
@@ -123,5 +127,9 @@ int main(int argc,char **argv)
exec sql close MYCURS;
exec sql deallocate descriptor MYDESC;
if (dbgs != NULL)
fclose(dbgs);
return 0;
}
src/interfaces/ecpg/test/test2.pgc
View file @
991b9740
...
...
@@ -47,8 +47,8 @@ exec sql end declare section;
strcpy(msg, "insert");
exec sql insert into meskes(name, married, children) values ('Petra', '19900404', 3);
exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 3
3
, '19900404', 3);
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103,
8
);
exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 3
4
, '19900404', 3);
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103,
9
);
exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 6);
exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 2);
...
...
src/interfaces/ecpg/test/test3.pgc
View file @
991b9740
...
...
@@ -39,8 +39,8 @@ exec sql end declare section;
strcpy(msg, "insert");
exec sql insert into meskes(name, married, children) values (:wifesname, '19900404', 3);
exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 3
3
, '19900404', 3);
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103,
8
);
exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 3
4
, '19900404', 3);
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103,
9
);
exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 6);
exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 2);
...
...
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