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
32a4c300
Commit
32a4c300
authored
Nov 14, 2001
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Christof's patches.
parent
ebb93323
Changes
16
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
281 additions
and
200 deletions
+281
-200
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+4
-0
src/interfaces/ecpg/README.dynSQL
src/interfaces/ecpg/README.dynSQL
+2
-12
src/interfaces/ecpg/include/ecpglib.h
src/interfaces/ecpg/include/ecpglib.h
+2
-0
src/interfaces/ecpg/lib/connect.c
src/interfaces/ecpg/lib/connect.c
+13
-13
src/interfaces/ecpg/lib/data.c
src/interfaces/ecpg/lib/data.c
+3
-3
src/interfaces/ecpg/lib/descriptor.c
src/interfaces/ecpg/lib/descriptor.c
+98
-80
src/interfaces/ecpg/lib/error.c
src/interfaces/ecpg/lib/error.c
+2
-2
src/interfaces/ecpg/lib/execute.c
src/interfaces/ecpg/lib/execute.c
+109
-61
src/interfaces/ecpg/lib/extern.h
src/interfaces/ecpg/lib/extern.h
+25
-7
src/interfaces/ecpg/lib/memory.c
src/interfaces/ecpg/lib/memory.c
+3
-3
src/interfaces/ecpg/lib/misc.c
src/interfaces/ecpg/lib/misc.c
+8
-8
src/interfaces/ecpg/lib/pg_type.h
src/interfaces/ecpg/lib/pg_type.h
+3
-2
src/interfaces/ecpg/lib/prepare.c
src/interfaces/ecpg/lib/prepare.c
+5
-5
src/interfaces/ecpg/test/Makefile
src/interfaces/ecpg/test/Makefile
+2
-2
src/interfaces/ecpg/test/dyntest.pgc
src/interfaces/ecpg/test/dyntest.pgc
+1
-1
src/interfaces/ecpg/test/dyntest2.pgc
src/interfaces/ecpg/test/dyntest2.pgc
+1
-1
No files found.
src/interfaces/ecpg/ChangeLog
View file @
32a4c300
...
...
@@ -1146,5 +1146,9 @@ Sun Oct 21 14:19:42 CEST 2001
Fri Nov 2 16:16:25 CET 2001
- Synced preproc.y with gram.y.
Wed Nov 14 11:50:27 CET 2001
- Added several patches by Christof Petig <christof.petig@wtal.de>.
- Set ecpg version to 2.9.0.
- Set library version to 3.3.0.
src/interfaces/ecpg/README.dynSQL
View file @
32a4c300
descriptor statements have the following shortcomings
- up to now the only reasonable statement is
FETCH ... INTO SQL DESCRIPTOR <name>
no input variables allowed!
- input descriptors (USING DESCRIPTOR <name>) are not supported
Reason: to fully support dynamic SQL the frontend/backend communication
should change to recognize input parameters.
Since this is not likely to happen in the near future and you
can cover the same functionality with the existing infrastructure
I'll leave the work to someone else.
- string buffer overflow does not always generate warnings
(beware: terminating 0 may be missing because strncpy is used)
:var=data sets sqlwarn accordingly (but not indicator)
- char variables pointing to NULL are not allocated on demand
- string truncation does not show up in indicator
(using s[n]printf), I'll leave the work to someone else.
src/interfaces/ecpg/include/ecpglib.h
View file @
32a4c300
...
...
@@ -67,6 +67,8 @@ void ECPGraise(int line, int code, const char *str);
bool
ECPGget_desc_header
(
int
,
char
*
,
int
*
);
bool
ECPGget_desc
(
int
,
char
*
,
int
,...);
/* dynamic result allocation */
void
ECPGfree_auto_mem
(
void
);
#ifdef __cplusplus
}
...
...
src/interfaces/ecpg/lib/connect.c
View file @
32a4c300
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.1
4 2001/10/31 04:49:44 momjian
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.1
5 2001/11/14 11:11:49 meskes
Exp $ */
#include "postgres_fe.h"
...
...
@@ -12,7 +12,7 @@ static struct connection *all_connections = NULL,
*
actual_connection
=
NULL
;
struct
connection
*
get_connection
(
const
char
*
connection_name
)
ECPG
get_connection
(
const
char
*
connection_name
)
{
struct
connection
*
con
=
all_connections
;
...
...
@@ -63,10 +63,10 @@ ecpg_finish(struct connection * act)
bool
ECPGsetcommit
(
int
lineno
,
const
char
*
mode
,
const
char
*
connection_name
)
{
struct
connection
*
con
=
get_connection
(
connection_name
);
struct
connection
*
con
=
ECPG
get_connection
(
connection_name
);
PGresult
*
results
;
if
(
!
ecpg_
init
(
con
,
connection_name
,
lineno
))
if
(
!
ECPG
init
(
con
,
connection_name
,
lineno
))
return
(
false
);
ECPGlog
(
"ECPGsetcommit line %d action = %s connection = %s
\n
"
,
lineno
,
mode
,
con
->
name
);
...
...
@@ -106,9 +106,9 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
bool
ECPGsetconn
(
int
lineno
,
const
char
*
connection_name
)
{
struct
connection
*
con
=
get_connection
(
connection_name
);
struct
connection
*
con
=
ECPG
get_connection
(
connection_name
);
if
(
!
ecpg_
init
(
con
,
connection_name
,
lineno
))
if
(
!
ECPG
init
(
con
,
connection_name
,
lineno
))
return
(
false
);
actual_connection
=
con
;
...
...
@@ -269,9 +269,9 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
*
realname
=
NULL
,
*
options
=
NULL
;
init_sqlca
();
ECPG
init_sqlca
();
if
((
this
=
(
struct
connection
*
)
ecpg_
alloc
(
sizeof
(
struct
connection
),
lineno
))
==
NULL
)
if
((
this
=
(
struct
connection
*
)
ECPG
alloc
(
sizeof
(
struct
connection
),
lineno
))
==
NULL
)
return
false
;
if
(
dbname
==
NULL
&&
connection_name
==
NULL
)
...
...
@@ -393,9 +393,9 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
/* add connection to our list */
if
(
connection_name
!=
NULL
)
this
->
name
=
ecpg_
strdup
(
connection_name
,
lineno
);
this
->
name
=
ECPG
strdup
(
connection_name
,
lineno
);
else
this
->
name
=
ecpg_
strdup
(
realname
,
lineno
);
this
->
name
=
ECPG
strdup
(
realname
,
lineno
);
this
->
cache_head
=
NULL
;
...
...
@@ -465,7 +465,7 @@ ECPGdisconnect(int lineno, const char *connection_name)
if
(
strcmp
(
connection_name
,
"ALL"
)
==
0
)
{
init_sqlca
();
ECPG
init_sqlca
();
for
(
con
=
all_connections
;
con
;)
{
struct
connection
*
f
=
con
;
...
...
@@ -476,9 +476,9 @@ ECPGdisconnect(int lineno, const char *connection_name)
}
else
{
con
=
get_connection
(
connection_name
);
con
=
ECPG
get_connection
(
connection_name
);
if
(
!
ecpg_
init
(
con
,
connection_name
,
lineno
))
if
(
!
ECPG
init
(
con
,
connection_name
,
lineno
))
return
(
false
);
else
ecpg_finish
(
con
);
...
...
src/interfaces/ecpg/lib/data.c
View file @
32a4c300
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.1
8 2001/11/05 17:46:37 momjian
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.1
9 2001/11/14 11:11:49 meskes
Exp $ */
#include "postgres_fe.h"
...
...
@@ -12,14 +12,14 @@
#include "sqlca.h"
bool
get_data
(
const
PGresult
*
results
,
int
act_tuple
,
int
act_field
,
int
lineno
,
ECPG
get_data
(
const
PGresult
*
results
,
int
act_tuple
,
int
act_field
,
int
lineno
,
enum
ECPGttype
type
,
enum
ECPGttype
ind_type
,
void
*
var
,
void
*
ind
,
long
varcharsize
,
long
offset
,
bool
isarray
)
{
char
*
pval
=
(
char
*
)
PQgetvalue
(
results
,
act_tuple
,
act_field
);
ECPGlog
(
"get_data line %d: RESULT: %s
\n
"
,
lineno
,
pval
?
pval
:
""
);
ECPGlog
(
"
ECPG
get_data line %d: RESULT: %s
\n
"
,
lineno
,
pval
?
pval
:
""
);
/* pval is a pointer to the value */
/* let's check is it really is an array if it should be one */
...
...
src/interfaces/ecpg/lib/descriptor.c
View file @
32a4c300
/* dynamic SQL support routines
*
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.1
8 2001/11/05 17:46:37 momjian
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.1
9 2001/11/14 11:11:49 meskes
Exp $
*/
#include "postgres_fe.h"
#include "pg_type.h"
#include "ecpgtype.h"
#include "ecpglib.h"
...
...
@@ -30,14 +31,16 @@ ECPGDynamicType_DDT(Oid type)
{
switch
(
type
)
{
case
1082
:
return
SQL3_DDT_DATE
;
/* date */
case
1083
:
return
SQL3_DDT_TIME
;
/* time */
case
1184
:
return
SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE
;
/* datetime */
case
1296
:
return
SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE
;
/* timestamp */
case
DATEOID
:
return
SQL3_DDT_DATE
;
case
TIMEOID
:
return
SQL3_DDT_TIME
;
case
TIMESTAMPOID
:
return
SQL3_DDT_TIMESTAMP
;
case
TIMESTAMPTZOID
:
return
SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE
;
case
TIMETZOID
:
return
SQL3_DDT_TIME_WITH_TIME_ZONE
;
default:
return
SQL3_DDT_ILLEGAL
;
}
...
...
@@ -139,10 +142,9 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
va_list
args
;
PGresult
*
ECPGresult
=
ECPGresultByDescriptor
(
lineno
,
desc_name
);
enum
ECPGdtype
type
;
bool
Indicator_seen
=
false
,
Data_seen
=
false
;
int
ntuples
,
act_tuple
;
struct
variable
data_var
;
va_start
(
args
,
index
);
if
(
!
ECPGresult
)
...
...
@@ -166,6 +168,10 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
type
=
va_arg
(
args
,
enum
ECPGdtype
);
memset
(
&
data_var
,
0
,
sizeof
data_var
);
data_var
.
type
=
ECPGt_EORT
;
data_var
.
ind_type
=
ECPGt_NO_INDICATOR
;
while
(
type
!=
ECPGd_EODT
)
{
char
type_str
[
20
];
...
...
@@ -184,26 +190,27 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
switch
(
type
)
{
case
(
ECPGd_indicator
):
data_var
.
ind_type
=
vartype
;
data_var
.
ind_pointer
=
var
;
data_var
.
ind_varcharsize
=
varcharsize
;
data_var
.
ind_arrsize
=
arrsize
;
data_var
.
ind_offset
=
offset
;
if
(
data_var
.
ind_arrsize
==
0
||
data_var
.
ind_varcharsize
==
0
)
data_var
.
ind_value
=
*
((
void
**
)
(
data_var
.
ind_pointer
));
else
data_var
.
ind_value
=
data_var
.
ind_pointer
;
break
;
/*
* this is like ECPGexecute missing : allocate arrays,
* perhaps this should go into a common function !!
*/
if
(
ntuples
>
arrsize
)
{
ECPGlog
(
"ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d
\n
"
,
lineno
,
ntuples
,
arrsize
);
ECPGraise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
NULL
);
return
false
;
}
Indicator_seen
=
true
;
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
{
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
-
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
)))
return
(
false
);
var
=
(
char
*
)
var
+
offset
;
ECPGlog
(
"ECPGget_desc: INDICATOR[%d] = %d
\n
"
,
act_tuple
,
-
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
));
}
case
ECPGd_data
:
data_var
.
type
=
vartype
;
data_var
.
pointer
=
var
;
data_var
.
varcharsize
=
varcharsize
;
data_var
.
arrsize
=
arrsize
;
data_var
.
offset
=
offset
;
if
(
data_var
.
arrsize
==
0
||
data_var
.
varcharsize
==
0
)
data_var
.
value
=
*
((
void
**
)
(
data_var
.
pointer
));
else
data_var
.
value
=
data_var
.
pointer
;
break
;
case
ECPGd_name
:
...
...
@@ -239,29 +246,6 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog
(
"ECPGget_desc: PRECISION = %d
\n
"
,
PQfmod
(
ECPGresult
,
index
)
>>
16
);
break
;
case
ECPGd_ret_length
:
case
ECPGd_ret_octet
:
/*
* this is like ECPGexecute missing : allocate arrays,
* perhaps this should go into a common function !!
*/
if
(
ntuples
>
arrsize
)
{
ECPGlog
(
"ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d
\n
"
,
lineno
,
ntuples
,
arrsize
);
ECPGraise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
NULL
);
return
false
;
}
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
{
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
)))
return
(
false
);
var
=
(
char
*
)
var
+
offset
;
ECPGlog
(
"ECPGget_desc: RETURNED[%d] = %d
\n
"
,
act_tuple
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
));
}
break
;
case
ECPGd_octet
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQfsize
(
ECPGresult
,
index
)))
return
(
false
);
...
...
@@ -289,36 +273,43 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ECPGlog
(
"ECPGget_desc: TYPE = %d
\n
"
,
ECPGDynamicType_DDT
(
PQftype
(
ECPGresult
,
index
)));
break
;
case
ECPGd_data
:
case
ECPGd_cardinality
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQntuples
(
ECPGresult
)))
return
(
false
);
ECPGlog
(
"ECPGget_desc: CARDINALITY = %d
\n
"
,
PQntuples
(
ECPGresult
));
break
;
case
ECPGd_ret_length
:
case
ECPGd_ret_octet
:
/*
* this is like ECPGexecute missing : allocate arrays,
* perhaps this should go into a common function !!
* this is like ECPGstore_result
*/
if
(
ntuples
>
arrsize
)
if
(
arrsize
>
0
&&
ntuples
>
arrsize
)
{
ECPGlog
(
"ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d
\n
"
,
lineno
,
ntuples
,
arrsize
);
ECPGraise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
NULL
);
return
false
;
}
Data_seen
=
true
;
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
/* allocate storage if needed */
if
(
arrsize
==
0
&&
var
!=
NULL
&&
*
(
void
**
)
var
==
NULL
)
{
if
(
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
))
continue
;
/* do not touch data on null value */
if
(
!
get_data
(
ECPGresult
,
act_tuple
,
index
,
lineno
,
vartype
,
ECPGt_NO_INDICATOR
,
var
,
NULL
,
varcharsize
,
offset
,
false
))
return
(
false
);
void
*
mem
=
(
void
*
)
ECPGalloc
(
offset
*
ntuples
,
lineno
);
*
(
void
**
)
var
=
mem
;
ECPGadd_mem
(
mem
,
lineno
);
var
=
mem
;
}
break
;
case
ECPGd_cardinality
:
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQntuples
(
ECPGresult
)))
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
{
if
(
!
get_int_item
(
lineno
,
var
,
vartype
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
)))
return
(
false
);
ECPGlog
(
"ECPGget_desc: CARDINALITY = %d
\n
"
,
PQntuples
(
ECPGresult
));
var
=
(
char
*
)
var
+
offset
;
ECPGlog
(
"ECPGget_desc: RETURNED[%d] = %d
\n
"
,
act_tuple
,
PQgetlength
(
ECPGresult
,
act_tuple
,
index
));
}
break
;
default:
...
...
@@ -330,15 +321,42 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
type
=
va_arg
(
args
,
enum
ECPGdtype
);
}
if
(
Data_seen
&&
!
Indicator_seen
)
if
(
data_var
.
type
!=
ECPGt_EORT
)
{
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
struct
statement
stmt
;
memset
(
&
stmt
,
0
,
sizeof
stmt
);
stmt
.
lineno
=
lineno
;
/* desparate try to guess something sensible */
stmt
.
connection
=
ECPGget_connection
(
NULL
);
ECPGstore_result
(
ECPGresult
,
index
,
&
stmt
,
&
data_var
);
}
else
if
(
data_var
.
ind_type
!=
ECPGt_NO_INDICATOR
)
{
if
(
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
))
/*
* this is like ECPGstore_result
* but since we don't have a data variable at hand, we can't call it
*/
if
(
data_var
.
ind_arrsize
>
0
&&
ntuples
>
data_var
.
ind_arrsize
)
{
ECPGraise
(
lineno
,
ECPG_MISSING_INDICATOR
,
NULL
);
return
(
false
);
ECPGlog
(
"ECPGget_desc line %d: Incorrect number of matches (indicator): %d don't fit into array of %d
\n
"
,
lineno
,
ntuples
,
data_var
.
ind_arrsize
);
ECPGraise
(
lineno
,
ECPG_TOO_MANY_MATCHES
,
NULL
);
return
false
;
}
/* allocate storage if needed */
if
(
data_var
.
ind_arrsize
==
0
&&
data_var
.
ind_pointer
!=
NULL
&&
data_var
.
ind_value
==
NULL
)
{
void
*
mem
=
(
void
*
)
ECPGalloc
(
data_var
.
ind_offset
*
ntuples
,
lineno
);
*
(
void
**
)
data_var
.
ind_pointer
=
mem
;
ECPGadd_mem
(
mem
,
lineno
);
data_var
.
ind_value
=
mem
;
}
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
{
if
(
!
get_int_item
(
lineno
,
data_var
.
ind_value
,
data_var
.
ind_type
,
-
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
)))
return
(
false
);
data_var
.
ind_value
=
(
char
*
)
data_var
.
ind_value
+
data_var
.
ind_offset
;
ECPGlog
(
"ECPGget_desc: INDICATOR[%d] = %d
\n
"
,
act_tuple
,
-
PQgetisnull
(
ECPGresult
,
act_tuple
,
index
));
}
}
...
...
@@ -369,10 +387,10 @@ ECPGdeallocate_desc(int line, const char *name)
bool
ECPGallocate_desc
(
int
line
,
const
char
*
name
)
{
struct
descriptor
*
new
=
(
struct
descriptor
*
)
ecpg_
alloc
(
sizeof
(
struct
descriptor
),
line
);
struct
descriptor
*
new
=
(
struct
descriptor
*
)
ECPG
alloc
(
sizeof
(
struct
descriptor
),
line
);
new
->
next
=
all_descriptors
;
new
->
name
=
ecpg_
alloc
(
strlen
(
name
)
+
1
,
line
);
new
->
name
=
ECPG
alloc
(
strlen
(
name
)
+
1
,
line
);
new
->
result
=
PQmakeEmptyPGresult
(
NULL
,
0
);
strcpy
(
new
->
name
,
name
);
all_descriptors
=
new
;
...
...
src/interfaces/ecpg/lib/error.c
View file @
32a4c300
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.1
2 2001/10/18 20:32:58 momjian
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.1
3 2001/11/14 11:11:49 meskes
Exp $ */
#include "postgres_fe.h"
...
...
@@ -154,7 +154,7 @@ ECPGraise(int line, int code, const char *str)
ECPGlog
(
"raising sqlcode %d in line %d, '%s'.
\n
"
,
code
,
line
,
sqlca
.
sqlerrm
.
sqlerrmc
);
/* free all memory we have allocated for the user */
free_auto_mem
();
ECPG
free_auto_mem
();
}
/* print out an error message */
...
...
src/interfaces/ecpg/lib/execute.c
View file @
32a4c300
This diff is collapsed.
Click to expand it.
src/interfaces/ecpg/lib/extern.h
View file @
32a4c300
...
...
@@ -3,14 +3,15 @@
/* Here are some methods used by the lib. */
/* Returns a pointer to a string containing a simple type name. */
void
free_auto_mem
(
void
);
bool
get_data
(
const
PGresult
*
,
int
,
int
,
int
,
enum
ECPGttype
type
,
void
ECPGadd_mem
(
void
*
ptr
,
int
lineno
);
bool
ECPGget_data
(
const
PGresult
*
,
int
,
int
,
int
,
enum
ECPGttype
type
,
enum
ECPGttype
,
void
*
,
void
*
,
long
,
long
,
bool
);
struct
connection
*
get_connection
(
const
char
*
);
void
init_sqlca
(
void
);
char
*
ecpg_
alloc
(
long
,
int
);
bool
ecpg_
init
(
const
struct
connection
*
,
const
char
*
,
const
int
);
char
*
ecpg_
strdup
(
const
char
*
,
int
);
struct
connection
*
ECPG
get_connection
(
const
char
*
);
void
ECPG
init_sqlca
(
void
);
char
*
ECPG
alloc
(
long
,
int
);
bool
ECPG
init
(
const
struct
connection
*
,
const
char
*
,
const
int
);
char
*
ECPG
strdup
(
const
char
*
,
int
);
const
char
*
ECPGtype_name
(
enum
ECPGttype
);
unsigned
int
ECPGDynamicType
(
Oid
);
...
...
@@ -62,6 +63,23 @@ struct descriptor
struct
descriptor
*
next
;
};
struct
variable
{
enum
ECPGttype
type
;
void
*
value
;
void
*
pointer
;
long
varcharsize
;
long
arrsize
;
long
offset
;
enum
ECPGttype
ind_type
;
void
*
ind_value
;
void
*
ind_pointer
;
long
ind_varcharsize
;
long
ind_arrsize
;
long
ind_offset
;
struct
variable
*
next
;
};
PGresult
**
ECPGdescriptor_lvalue
(
int
line
,
const
char
*
descriptor
);
...
...
src/interfaces/ecpg/lib/memory.c
View file @
32a4c300
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.
6 2001/10/05 17:37:07
meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.
7 2001/11/14 11:11:49
meskes Exp $ */
#include "postgres_fe.h"
...
...
@@ -8,7 +8,7 @@
#include "extern.h"
char
*
ecpg_
alloc
(
long
size
,
int
lineno
)
ECPG
alloc
(
long
size
,
int
lineno
)
{
char
*
new
=
(
char
*
)
calloc
(
1L
,
size
);
...
...
@@ -23,7 +23,7 @@ ecpg_alloc(long size, int lineno)
}
char
*
ecpg_
strdup
(
const
char
*
string
,
int
lineno
)
ECPG
strdup
(
const
char
*
string
,
int
lineno
)
{
char
*
new
=
strdup
(
string
);
...
...
src/interfaces/ecpg/lib/misc.c
View file @
32a4c300
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.
9 2001/10/30 05:38:56 momjian
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.
10 2001/11/14 11:11:49 meskes
Exp $ */
#include "postgres_fe.h"
...
...
@@ -40,15 +40,15 @@ static int simple_debug = 0;
static
FILE
*
debugstream
=
NULL
;
void
init_sqlca
(
void
)
ECPG
init_sqlca
(
void
)
{
memcpy
((
char
*
)
&
sqlca
,
(
char
*
)
&
sqlca_init
,
sizeof
(
sqlca
));
}
bool
ecpg_
init
(
const
struct
connection
*
con
,
const
char
*
connection_name
,
const
int
lineno
)
ECPG
init
(
const
struct
connection
*
con
,
const
char
*
connection_name
,
const
int
lineno
)
{
init_sqlca
();
ECPG
init_sqlca
();
if
(
con
==
NULL
)
{
ECPGraise
(
lineno
,
ECPG_NO_CONN
,
connection_name
?
connection_name
:
"NULL"
);
...
...
@@ -61,9 +61,9 @@ ecpg_init(const struct connection * con, const char *connection_name, const int
bool
ECPGstatus
(
int
lineno
,
const
char
*
connection_name
)
{
struct
connection
*
con
=
get_connection
(
connection_name
);
struct
connection
*
con
=
ECPG
get_connection
(
connection_name
);
if
(
!
ecpg_
init
(
con
,
connection_name
,
lineno
))
if
(
!
ECPG
init
(
con
,
connection_name
,
lineno
))
return
(
false
);
/* are we connected? */
...
...
@@ -80,9 +80,9 @@ bool
ECPGtrans
(
int
lineno
,
const
char
*
connection_name
,
const
char
*
transaction
)
{
PGresult
*
res
;
struct
connection
*
con
=
get_connection
(
connection_name
);
struct
connection
*
con
=
ECPG
get_connection
(
connection_name
);
if
(
!
ecpg_
init
(
con
,
connection_name
,
lineno
))
if
(
!
ECPG
init
(
con
,
connection_name
,
lineno
))
return
(
false
);
ECPGlog
(
"ECPGtrans line %d action = %s connection = %s
\n
"
,
lineno
,
transaction
,
con
->
name
);
...
...
src/interfaces/ecpg/lib/pg_type.h
View file @
32a4c300
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_type.h,v 1.
5 2001/11/05 17:46:37 momjian
Exp $
* $Id: pg_type.h,v 1.
6 2001/11/14 11:11:49 meskes
Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
...
...
@@ -62,7 +62,8 @@
#define VARCHAROID 1043
#define DATEOID 1082
#define TIMEOID 1083
#define TIMESTAMPOID 1184
#define TIMESTAMPOID 1114
#define TIMESTAMPTZOID 1184
#define INTERVALOID 1186
#define TIMETZOID 1266
#define ZPBITOID 1560
...
...
src/interfaces/ecpg/lib/prepare.c
View file @
32a4c300
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/prepare.c,v 1.1
0 2001/11/05 17:46:37 momjian
Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/prepare.c,v 1.1
1 2001/11/14 11:11:49 meskes
Exp $ */
#include "postgres_fe.h"
...
...
@@ -69,11 +69,11 @@ ECPGprepare(int lineno, char *name, char *variable)
return
false
;
}
this
=
(
struct
prepared_statement
*
)
ecpg_
alloc
(
sizeof
(
struct
prepared_statement
),
lineno
);
this
=
(
struct
prepared_statement
*
)
ECPG
alloc
(
sizeof
(
struct
prepared_statement
),
lineno
);
if
(
!
this
)
return
false
;
stmt
=
(
struct
statement
*
)
ecpg_
alloc
(
sizeof
(
struct
statement
),
lineno
);
stmt
=
(
struct
statement
*
)
ECPG
alloc
(
sizeof
(
struct
statement
),
lineno
);
if
(
!
stmt
)
{
free
(
this
);
...
...
@@ -83,14 +83,14 @@ ECPGprepare(int lineno, char *name, char *variable)
/* create statement */
stmt
->
lineno
=
lineno
;
stmt
->
connection
=
NULL
;
stmt
->
command
=
ecpg_
strdup
(
variable
,
lineno
);
stmt
->
command
=
ECPG
strdup
(
variable
,
lineno
);
stmt
->
inlist
=
stmt
->
outlist
=
NULL
;
/* if we have C variables in our statment replace them with '?' */
replace_variables
(
stmt
->
command
);
/* add prepared statement to our list */
this
->
name
=
ecpg_
strdup
(
name
,
lineno
);
this
->
name
=
ECPG
strdup
(
name
,
lineno
);
this
->
stmt
=
stmt
;
if
(
prep_stmts
==
NULL
)
...
...
src/interfaces/ecpg/test/Makefile
View file @
32a4c300
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.3
1 2001/08/11 10:52:09 petere
Exp $
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.3
2 2001/11/14 11:11:49 meskes
Exp $
subdir
=
src/interfaces/ecpg/test
top_builddir
=
../../../..
...
...
@@ -8,7 +8,7 @@ override CPPFLAGS := -I$(srcdir)/../include $(CPPFLAGS)
ECPG
=
../preproc/ecpg
-I
$(srcdir)
/../include
TESTS
=
test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init
TESTS
=
test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init
testdynalloc
all
:
$(TESTS)
...
...
src/interfaces/ecpg/test/dyntest.pgc
View file @
32a4c300
...
...
@@ -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.
8 2001/08/11 10:52:09 petere
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.
9 2001/11/14 11:11:49 meskes
Exp $
*/
#include <stdio.h>
...
...
src/interfaces/ecpg/test/dyntest2.pgc
View file @
32a4c300
...
...
@@ -2,7 +2,7 @@
*
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
*
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest2.pgc,v 1.
2 2001/08/11 10:52:09 petere
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest2.pgc,v 1.
3 2001/11/14 11:11:49 meskes
Exp $
*/
#include <stdio.h>
...
...
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