Skip to content

Commit f0212ce

Browse files
author
Michael Meskes
committed
- Synced preproc.y with gram.y.
- Synced pgc.l with scan.l. - Synced keyword.c. - Include the remaining patches by Christof Petig <christof.petig@wtal.de>.
1 parent 3baf740 commit f0212ce

24 files changed

+223
-356
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,10 +1084,17 @@ Wed Jun 13 14:39:12 CEST 2001
10841084

10851085
- Synced preproc.y with gram.y.
10861086
- Applied bug fix by John Summerfield.
1087-
- Set ecpg version to 2.9.0.
1088-
- Set library version to 3.3.0.
10891087

10901088
Son Aug 19 11:04:39 CEST 2001
10911089

10921090
- Synced preproc.y with gram.y.
10931091
- Include some patches by Christof Petig <christof.petig@wtal.de>.
1092+
1093+
Wed Sep 19 15:57:49 CEST 2001
1094+
1095+
- Synced preproc.y with gram.y.
1096+
- Synced pgc.l with scan.l.
1097+
- Synced keyword.c.
1098+
- Include the remaining patches by Christof Petig <christof.petig@wtal.de>.
1099+
- Set ecpg version to 2.9.0.
1100+
- Set library version to 3.3.0.

src/interfaces/ecpg/include/ecpgtype.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ extern "C"
4646
ECPGt_EOIT, /* End of insert types. */
4747
ECPGt_EORT, /* End of result types. */
4848
ECPGt_NO_INDICATOR, /* no indicator */
49-
ECPGt_long_long, ECPGt_unsigned_long_long
49+
ECPGt_long_long, ECPGt_unsigned_long_long,
50+
ECPGt_descriptor /* sql descriptor, no C variable */
5051
};
5152

5253
/* descriptor items */
@@ -71,7 +72,7 @@ extern "C"
7172
ECPGd_EODT /* End of descriptor types. */
7273
};
7374

74-
#define IS_SIMPLE_TYPE(type) (((type) >= ECPGt_char && (type) <= ECPGt_varchar2) || (type)>=ECPGt_long_long)
75+
#define IS_SIMPLE_TYPE(type) (((type) >= ECPGt_char && (type) <= ECPGt_varchar2) || ((type)>=ECPGt_long_long && (type) <= ECPGt_unsigned_long_long))
7576

7677
#ifdef __cplusplus
7778
}

src/interfaces/ecpg/include/sql3types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
44
*
5-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.4 2000/04/12 17:17:01 momjian Exp $
5+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.5 2001/09/19 14:09:32 meskes Exp $
66
*/
77

88
/* chapter 13.1 table 2: Codes used for SQL data types in Dynamic SQL */

src/interfaces/ecpg/lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile,v 1.12 2001/05/11 01:46:33 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile,v 1.13 2001/09/19 14:09:32 meskes Exp $
88
#
99
#-------------------------------------------------------------------------
1010

src/interfaces/ecpg/lib/connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.11 2001/08/24 14:07:49 petere Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.12 2001/09/19 14:09:32 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

src/interfaces/ecpg/lib/data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.14 2001/08/24 14:07:49 petere Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.15 2001/09/19 14:09:32 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

src/interfaces/ecpg/lib/descriptor.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.15 2001/08/24 14:07:49 petere Exp $ */
1+
/* dynamic SQL support routines
2+
*
3+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.16 2001/09/19 14:09:32 meskes Exp $
4+
*/
25

36
#include "postgres_fe.h"
47

@@ -8,27 +11,15 @@
811
#include "extern.h"
912
#include "sql3types.h"
1013

11-
struct descriptor
12-
{
13-
char *name;
14-
PGresult *result;
15-
struct descriptor *next;
16-
} *all_descriptors = NULL;
14+
struct descriptor *all_descriptors = NULL;
1715

16+
/* old internal convenience function that might go away later */
1817
static PGresult
1918
*
2019
ECPGresultByDescriptor(int line, const char *name)
2120
{
22-
struct descriptor *i;
23-
24-
for (i = all_descriptors; i != NULL; i = i->next)
25-
{
26-
if (!strcmp(name, i->name))
27-
return i->result;
28-
}
29-
30-
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, name);
31-
21+
PGresult **resultpp = ECPGdescriptor_lvalue ( line, name );
22+
if (resultpp) return *resultpp;
3223
return NULL;
3324
}
3425

@@ -373,3 +364,18 @@ ECPGallocate_desc(int line, const char *name)
373364
all_descriptors = new;
374365
return true;
375366
}
367+
368+
PGresult **
369+
ECPGdescriptor_lvalue(int line, const char *descriptor)
370+
{
371+
struct descriptor *i;
372+
373+
for (i = all_descriptors; i != NULL; i = i->next)
374+
{
375+
if (!strcmp(descriptor, i->name))
376+
return &i->result;
377+
}
378+
379+
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, (char *) descriptor);
380+
return NULL;
381+
}

src/interfaces/ecpg/lib/error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.9 2001/08/24 14:07:49 petere Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.10 2001/09/19 14:09:32 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

src/interfaces/ecpg/lib/execute.c

Lines changed: 20 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.22 2001/08/24 14:07:49 petere Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.23 2001/09/19 14:09:32 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -817,6 +817,7 @@ ECPGexecute(struct statement * stmt)
817817
* it should go into a separate function
818818
*/
819819
{
820+
bool clear_result = TRUE;
820821
var = stmt->outlist;
821822
switch (PQresultStatus(results))
822823
{
@@ -840,7 +841,19 @@ ECPGexecute(struct statement * stmt)
840841
break;
841842
}
842843

843-
for (act_field = 0; act_field < nfields && status; act_field++)
844+
if (var != NULL && var->type==ECPGt_descriptor)
845+
{ PGresult **resultpp = ECPGdescriptor_lvalue(stmt->lineno, (const char*)var->pointer);
846+
if (resultpp == NULL) status = false;
847+
else
848+
{ if (*resultpp)
849+
PQclear(*resultpp);
850+
*resultpp=results;
851+
clear_result = FALSE;
852+
ECPGlog("ECPGexecute putting result into descriptor '%s'\n", (const char*)var->pointer);
853+
}
854+
var = var->next;
855+
}
856+
else for (act_field = 0; act_field < nfields && status; act_field++)
844857
{
845858
if (var == NULL)
846859
{
@@ -972,7 +985,7 @@ ECPGexecute(struct statement * stmt)
972985
status = false;
973986
break;
974987
}
975-
PQclear(results);
988+
if (clear_result) PQclear(results);
976989
}
977990

978991
/* check for asynchronous returns */
@@ -1032,186 +1045,12 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
10321045
return (status);
10331046
}
10341047

1035-
/* dynamic SQL support routines
1036-
*
1037-
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
1038-
*
1039-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.22 2001/08/24 14:07:49 petere Exp $
1040-
*/
1041-
1042-
PGconn *ECPG_internal_get_connection(char *name);
1043-
1044-
extern struct descriptor
1045-
{
1046-
char *name;
1047-
PGresult *result;
1048-
struct descriptor *next;
1049-
} *all_descriptors;
1050-
1051-
/* like ECPGexecute */
1052-
static bool
1053-
execute_descriptor(int lineno, const char *query
1054-
,struct connection * con, PGresult **resultptr)
1055-
{
1056-
bool status = false;
1057-
PGresult *results;
1058-
PGnotify *notify;
1059-
1060-
/* Now the request is built. */
1061-
1062-
if (con->committed && !con->autocommit)
1063-
{
1064-
if ((results = PQexec(con->connection, "begin transaction")) == NULL)
1065-
{
1066-
ECPGraise(lineno, ECPG_TRANS, NULL);
1067-
return false;
1068-
}
1069-
PQclear(results);
1070-
con->committed = false;
1071-
}
1072-
1073-
ECPGlog("execute_descriptor line %d: QUERY: %s on connection %s\n", lineno, query, con->name);
1074-
results = PQexec(con->connection, query);
1075-
1076-
if (results == NULL)
1077-
{
1078-
ECPGlog("ECPGexecute line %d: error: %s", lineno,
1079-
PQerrorMessage(con->connection));
1080-
ECPGraise(lineno, ECPG_PGSQL, PQerrorMessage(con->connection));
1081-
}
1082-
else
1083-
{
1084-
*resultptr = results;
1085-
switch (PQresultStatus(results))
1086-
{
1087-
int ntuples;
1088-
1089-
case PGRES_TUPLES_OK:
1090-
status = true;
1091-
sqlca.sqlerrd[2] = ntuples = PQntuples(results);
1092-
if (ntuples < 1)
1093-
{
1094-
ECPGlog("execute_descriptor line %d: Incorrect number of matches: %d\n",
1095-
lineno, ntuples);
1096-
ECPGraise(lineno, ECPG_NOT_FOUND, NULL);
1097-
status = false;
1098-
break;
1099-
}
1100-
break;
1101-
#if 1 /* strictly these are not needed (yet) */
1102-
case PGRES_EMPTY_QUERY:
1103-
/* do nothing */
1104-
ECPGraise(lineno, ECPG_EMPTY, NULL);
1105-
break;
1106-
case PGRES_COMMAND_OK:
1107-
status = true;
1108-
sqlca.sqlerrd[1] = PQoidValue(results);
1109-
sqlca.sqlerrd[2] = atol(PQcmdTuples(results));
1110-
ECPGlog("ECPGexecute line %d Ok: %s\n", lineno, PQcmdStatus(results));
1111-
break;
1112-
case PGRES_COPY_OUT:
1113-
ECPGlog("ECPGexecute line %d: Got PGRES_COPY_OUT ... tossing.\n", lineno);
1114-
PQendcopy(con->connection);
1115-
break;
1116-
case PGRES_COPY_IN:
1117-
ECPGlog("ECPGexecute line %d: Got PGRES_COPY_IN ... tossing.\n", lineno);
1118-
PQendcopy(con->connection);
1119-
break;
1120-
#else
1121-
case PGRES_EMPTY_QUERY:
1122-
case PGRES_COMMAND_OK:
1123-
case PGRES_COPY_OUT:
1124-
case PGRES_COPY_IN:
1125-
break;
1126-
#endif
1127-
case PGRES_NONFATAL_ERROR:
1128-
case PGRES_FATAL_ERROR:
1129-
case PGRES_BAD_RESPONSE:
1130-
ECPGlog("ECPGexecute line %d: Error: %s",
1131-
lineno, PQerrorMessage(con->connection));
1132-
ECPGraise(lineno, ECPG_PGSQL, PQerrorMessage(con->connection));
1133-
status = false;
1134-
break;
1135-
default:
1136-
ECPGlog("ECPGexecute line %d: Got something else, postgres error.\n",
1137-
lineno);
1138-
ECPGraise(lineno, ECPG_PGSQL, PQerrorMessage(con->connection));
1139-
status = false;
1140-
break;
1141-
}
1142-
}
1143-
1144-
/* check for asynchronous returns */
1145-
notify = PQnotifies(con->connection);
1146-
if (notify)
1147-
{
1148-
ECPGlog("ECPGexecute line %d: ASYNC NOTIFY of '%s' from backend pid '%d' received\n",
1149-
lineno, notify->relname, notify->be_pid);
1150-
free(notify);
1151-
}
1152-
return status;
1153-
}
1154-
1155-
/* like ECPGdo */
1156-
static bool
1157-
do_descriptor2(int lineno, const char *connection_name,
1158-
PGresult **resultptr, const char *query)
1159-
{
1160-
struct connection *con = get_connection(connection_name);
1161-
bool status = true;
1162-
char *locale = setlocale(LC_NUMERIC, NULL);
1163-
1164-
/* Make sure we do NOT honor the locale for numeric input/output */
1165-
/* since the database wants teh standard decimal point */
1166-
setlocale(LC_NUMERIC, "C");
1167-
1168-
if (!ecpg_init(con, connection_name, lineno))
1169-
{
1170-
setlocale(LC_NUMERIC, locale);
1171-
return (false);
1172-
}
1173-
1174-
/* are we connected? */
1175-
if (con == NULL || con->connection == NULL)
1176-
{
1177-
ECPGlog("do_descriptor2: not connected to %s\n", con->name);
1178-
ECPGraise(lineno, ECPG_NOT_CONN, NULL);
1179-
setlocale(LC_NUMERIC, locale);
1180-
return false;
1181-
}
1182-
1183-
status = execute_descriptor(lineno, query, con, resultptr);
1184-
1185-
/* and reset locale value so our application is not affected */
1186-
setlocale(LC_NUMERIC, locale);
1187-
return (status);
1188-
}
1189-
1048+
/* old descriptor interface */
11901049
bool
11911050
ECPGdo_descriptor(int line, const char *connection,
11921051
const char *descriptor, const char *query)
11931052
{
1194-
struct descriptor *i;
1195-
1196-
for (i = all_descriptors; i != NULL; i = i->next)
1197-
{
1198-
if (!strcmp(descriptor, i->name))
1199-
{
1200-
bool status;
1201-
1202-
/* free previous result */
1203-
if (i->result)
1204-
PQclear(i->result);
1205-
i->result = NULL;
1206-
1207-
status = do_descriptor2(line, connection, &i->result, query);
1208-
1209-
if (!i->result)
1210-
PQmakeEmptyPGresult(NULL, 0);
1211-
return (status);
1212-
}
1213-
}
1214-
1215-
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, (char *) descriptor);
1216-
return false;
1053+
return ECPGdo(line, connection, (char *)query, ECPGt_EOIT,
1054+
ECPGt_descriptor, descriptor, 0L, 0L, 0L,
1055+
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
12171056
}

src/interfaces/ecpg/lib/extern.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,14 @@ struct connection
5252
struct ECPGtype_information_cache *cache_head;
5353
struct connection *next;
5454
};
55+
56+
/* structure to store descriptors */
57+
struct descriptor
58+
{
59+
char *name;
60+
PGresult *result;
61+
struct descriptor *next;
62+
};
63+
64+
PGresult **
65+
ECPGdescriptor_lvalue(int line, const char *descriptor);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy