提交 6f66fd8c 编写于 作者: M Michael Meskes

*** empty log message ***

上级 60bb92af
...@@ -472,7 +472,7 @@ Mon Feb 22 19:47:45 CET 1999 ...@@ -472,7 +472,7 @@ Mon Feb 22 19:47:45 CET 1999
- Added 'at <db_connection>' option to all commands it is apllicable - Added 'at <db_connection>' option to all commands it is apllicable
to. Due to changing the API of some libecpg functions this to. Due to changing the API of some libecpg functions this
requires me to increase the major version number. requires me to increase the major version number of libecpg.
- Synced pgc.l with scan.l. - Synced pgc.l with scan.l.
- Added support for unions. - Added support for unions.
...@@ -498,5 +498,9 @@ Thu Mar 4 19:49:28 CET 1999 ...@@ -498,5 +498,9 @@ Thu Mar 4 19:49:28 CET 1999
- Switched memory allocation to calloc() to make sure memory is - Switched memory allocation to calloc() to make sure memory is
cleared. cleared.
- Fixed varchar auto-allocating. - Fixed varchar auto-allocating.
Sat Mar 6 14:06:07 CET 1999
- Replaced placeholder ';;' by '?' since this is what standard says.
- Set library version to 3.0.0 - Set library version to 3.0.0
- Set ecpg version to 3.0.0 - Set ecpg version to 2.6.0
...@@ -129,7 +129,7 @@ register_error(long code, char *fmt,...) ...@@ -129,7 +129,7 @@ register_error(long code, char *fmt,...)
static struct connection * static struct connection *
get_connection(const char *connection_name) get_connection(const char *connection_name)
{ {
struct connection *con = all_connections;; struct connection *con = all_connections;
if (connection_name == NULL || strcmp(connection_name, "CURRENT") == 0) if (connection_name == NULL || strcmp(connection_name, "CURRENT") == 0)
return actual_connection; return actual_connection;
...@@ -377,11 +377,11 @@ next_insert(char *text) ...@@ -377,11 +377,11 @@ next_insert(char *text)
char *ptr = text; char *ptr = text;
bool string = false; bool string = false;
for (; ptr[1] != '\0' && (ptr[0] != ';' || ptr[1] != ';' || string); ptr++) for (; *ptr != '\0' && (*ptr != '?' || string); ptr++)
if (ptr[0] == '\'') if (*ptr == '\'')
string = string ? false : true; string = string ? false : true;
return (ptr[1] == '\0') ? NULL : ptr; return (*ptr == '\0') ? NULL : ptr;
} }
static bool static bool
...@@ -604,7 +604,7 @@ ECPGexecute(struct statement * stmt) ...@@ -604,7 +604,7 @@ ECPGexecute(struct statement * stmt)
strcat(newcopy, strcat(newcopy,
copiedquery copiedquery
+ (p - newcopy) + (p - newcopy)
+ sizeof(";;") - 1 /* don't count the '\0' */); + sizeof("?") - 1 /* don't count the '\0' */);
} }
/* /*
...@@ -675,7 +675,7 @@ ECPGexecute(struct statement * stmt) ...@@ -675,7 +675,7 @@ ECPGexecute(struct statement * stmt)
{ {
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n", ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
stmt->lineno, ntuples); stmt->lineno, ntuples);
register_error(ECPG_NOT_FOUND, "Data not found line %d.", stmt->lineno); register_error(ECPG_NOT_FOUND, "No data found line %d.", stmt->lineno);
status = false; status = false;
break; break;
} }
...@@ -1266,8 +1266,8 @@ replace_variables(char *text) ...@@ -1266,8 +1266,8 @@ replace_variables(char *text)
if (!string && *ptr == ':') if (!string && *ptr == ':')
{ {
ptr[0] = ptr[1] = ';'; *ptr = '?';
for (ptr += 2; *ptr && isvarchar(*ptr); ptr++) for (++ptr; *ptr && isvarchar(*ptr); ptr++)
*ptr = ' '; *ptr = ' ';
} }
} }
...@@ -1307,7 +1307,7 @@ ECPGprepare(int lineno, char *name, char *variable) ...@@ -1307,7 +1307,7 @@ ECPGprepare(int lineno, char *name, char *variable)
stmt->command = ecpg_strdup(variable, lineno); stmt->command = ecpg_strdup(variable, lineno);
stmt->inlist = stmt->outlist = NULL; stmt->inlist = stmt->outlist = NULL;
/* if we have C variables in our statment replace them with ';;' */ /* if we have C variables in our statment replace them with '?' */
replace_variables(stmt->command); replace_variables(stmt->command);
/* add prepared statement to our list */ /* add prepared statement to our list */
......
SRCDIR= ../../.. SRCDIR= ../../..
include $(SRCDIR)/Makefile.global include $(SRCDIR)/Makefile.global
MAJOR_VERSION=3 MAJOR_VERSION=2
MINOR_VERSION=0 MINOR_VERSION=6
PATCHLEVEL=0 PATCHLEVEL=0
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \ CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
......
...@@ -1097,7 +1097,7 @@ user_group_clause: IN GROUP user_group_list { $$ = cat2_str(make1_str("in group ...@@ -1097,7 +1097,7 @@ user_group_clause: IN GROUP user_group_list { $$ = cat2_str(make1_str("in group
| /*EMPTY*/ { $$ = make1_str(""); } | /*EMPTY*/ { $$ = make1_str(""); }
; ;
user_valid_clause: VALID UNTIL Sconst { $$ = cat2_str(make1_str("valid until"), $3);; } user_valid_clause: VALID UNTIL Sconst { $$ = cat2_str(make1_str("valid until"), $3); }
| /*EMPTY*/ { $$ = make1_str(""); } | /*EMPTY*/ { $$ = make1_str(""); }
; ;
...@@ -2221,7 +2221,7 @@ set_opt: SETOF { $$ = make1_str("setof"); } ...@@ -2221,7 +2221,7 @@ set_opt: SETOF { $$ = make1_str("setof"); }
RemoveStmt: DROP remove_type name RemoveStmt: DROP remove_type name
{ {
$$ = cat3_str(make1_str("drop"), $2, $3);; $$ = cat3_str(make1_str("drop"), $2, $3);
} }
; ;
...@@ -2931,7 +2931,7 @@ opt_select_limit: LIMIT select_limit_value ',' select_offset_value ...@@ -2931,7 +2931,7 @@ opt_select_limit: LIMIT select_limit_value ',' select_offset_value
| LIMIT select_limit_value OFFSET select_offset_value | LIMIT select_limit_value OFFSET select_offset_value
{ $$ = cat4_str(make1_str("limit"), $2, make1_str("offset"), $4); } { $$ = cat4_str(make1_str("limit"), $2, make1_str("offset"), $4); }
| LIMIT select_limit_value | LIMIT select_limit_value
{ $$ = cat2_str(make1_str("limit"), $2);; } { $$ = cat2_str(make1_str("limit"), $2); }
| OFFSET select_offset_value LIMIT select_limit_value | OFFSET select_offset_value LIMIT select_limit_value
{ $$ = cat4_str(make1_str("offset"), $2, make1_str("limit"), $4); } { $$ = cat4_str(make1_str("offset"), $2, make1_str("limit"), $4); }
| OFFSET select_offset_value | OFFSET select_offset_value
...@@ -3835,7 +3835,7 @@ a_expr: attr opt_indirection ...@@ -3835,7 +3835,7 @@ a_expr: attr opt_indirection
| case_expr | case_expr
{ $$ = $1; } { $$ = $1; }
| cinputvariable | cinputvariable
{ $$ = make1_str(";;"); } { $$ = make1_str("?"); }
; ;
/* Restricted expressions /* Restricted expressions
...@@ -3982,7 +3982,7 @@ extract_list: extract_arg FROM a_expr ...@@ -3982,7 +3982,7 @@ extract_list: extract_arg FROM a_expr
| /* EMPTY */ | /* EMPTY */
{ $$ = make1_str(""); } { $$ = make1_str(""); }
| cinputvariable | cinputvariable
{ $$ = make1_str(";;"); } { $$ = make1_str("?"); }
; ;
extract_arg: datetime { $$ = $1; } extract_arg: datetime { $$ = $1; }
...@@ -4734,7 +4734,7 @@ ECPGCursorStmt: DECLARE name opt_cursor CURSOR FOR ident cursor_clause ...@@ -4734,7 +4734,7 @@ ECPGCursorStmt: DECLARE name opt_cursor CURSOR FOR ident cursor_clause
this->next = cur; this->next = cur;
this->name = $2; this->name = $2;
this->connection = connection; this->connection = connection;
this->command = cat5_str(make1_str("declare"), mm_strdup($2), $3, make1_str("cursor for ;;"), $7); this->command = cat5_str(make1_str("declare"), mm_strdup($2), $3, make1_str("cursor for ?"), $7);
this->argsresult = NULL; this->argsresult = NULL;
thisquery->type = &ecpg_query; thisquery->type = &ecpg_query;
...@@ -5037,7 +5037,7 @@ ECPGExecute : EXECUTE SQL_IMMEDIATE execstring ...@@ -5037,7 +5037,7 @@ ECPGExecute : EXECUTE SQL_IMMEDIATE execstring
add_variable(&argsinsert, thisquery, &no_indicator); add_variable(&argsinsert, thisquery, &no_indicator);
$$ = make1_str(";;"); $$ = make1_str("?");
} }
| EXECUTE ident | EXECUTE ident
{ {
...@@ -5052,7 +5052,7 @@ ECPGExecute : EXECUTE SQL_IMMEDIATE execstring ...@@ -5052,7 +5052,7 @@ ECPGExecute : EXECUTE SQL_IMMEDIATE execstring
add_variable(&argsinsert, thisquery, &no_indicator); add_variable(&argsinsert, thisquery, &no_indicator);
} opt_using } opt_using
{ {
$$ = make1_str(";;"); $$ = make1_str("?");
} }
execstring: char_variable | execstring: char_variable |
...@@ -5860,7 +5860,7 @@ cinputvariable : cvariable indicator { ...@@ -5860,7 +5860,7 @@ cinputvariable : cvariable indicator {
civariableonly : cvariable { civariableonly : cvariable {
add_variable(&argsinsert, find_variable($1), &no_indicator); add_variable(&argsinsert, find_variable($1), &no_indicator);
$$ = make1_str(";;"); $$ = make1_str("?");
} }
cvariable: CVARIABLE { $$ = $1; } cvariable: CVARIABLE { $$ = $1; }
......
...@@ -63,7 +63,7 @@ exec sql end declare section; ...@@ -63,7 +63,7 @@ exec sql end declare section;
printf("Inserted %d tuples via execute immediate\n", sqlca.sqlerrd[2]); printf("Inserted %d tuples via execute immediate\n", sqlca.sqlerrd[2]);
strcpy(msg, "execute insert 4"); strcpy(msg, "execute insert 4");
sprintf(command, "insert into test(name, amount, letter) select name, amount+;;, letter from test"); sprintf(command, "insert into test(name, amount, letter) select name, amount+?, letter from test");
exec sql prepare I from :command; exec sql prepare I from :command;
exec sql at pm execute I using :increment; exec sql at pm execute I using :increment;
......
#include <stdio.h>
exec sql include header_test;
exec sql type str is varchar[10];
int
main ()
{
typedef struct { long born; short age; } birthinfo;
exec sql type birthinfo is struct { long born; short age; };
exec sql begin declare section;
struct personal_struct { str name;
birthinfo birth;
} personal;
struct personal_indicator { int ind_name;
birthinfo ind_birth;
} ind_personal;
int *ind_married = NULL;
int children;
int ind_children;
str *married = NULL;
char *testname="Petra";
char *query="select name, born, age, married, children from meskes where name = :var1";
exec sql end declare section;
exec sql declare cur cursor for
select name, born, age, married, children from meskes;
char msg[128], command[128];
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
strcpy(msg, "connect");
exec sql connect to unix:postgresql://localhost:5432/mm;
strcpy(msg, "create");
exec sql create table meskes(name char(8), born integer, age smallint, married date, children integer);
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, 33, '19900404', 3);
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103, 8);
exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 5);
exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 1);
strcpy(msg, "commit");
exec sql commit;
strcpy(msg, "open");
exec sql open cur;
exec sql whenever not found do break;
while (1) {
strcpy(msg, "fetch");
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %10.10s", married->arr);
if (ind_children >= 0)
printf(", children = %d", children);
putchar('\n');
free(married);
married = NULL;
}
strcpy(msg, "close");
exec sql close cur;
/* and now the same query with prepare */
exec sql prepare MM from :query;
exec sql declare prep cursor for MM;
strcpy(msg, "open");
exec sql open prep using :testname;
exec sql whenever not found do break;
while (1) {
strcpy(msg, "fetch");
exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %10.10s", married->arr);
if (ind_children >= 0)
printf(", children = %d", children);
putchar('\n');
}
free(married);
strcpy(msg, "close");
exec sql close prep;
strcpy(msg, "drop");
exec sql drop table meskes;
strcpy(msg, "commit");
exec sql commit;
strcpy(msg, "disconnect");
exec sql disconnect;
if (dbgs != NULL)
fclose(dbgs);
return (0);
}
#include <stdio.h>
exec sql include header_test;
exec sql type str is varchar[10];
int
main ()
{
typedef struct { long born; short age; } birthinfo;
exec sql type birthinfo is struct { long born; short age; };
exec sql begin declare section;
struct personal_struct { str name;
birthinfo birth;
} personal;
struct personal_indicator { int ind_name;
birthinfo ind_birth;
} ind_personal;
int *ind_married = NULL;
int children;
int ind_children;
str *married = NULL;
char *testname="Petra";
char *query="select name, born, age, married, children from meskes where name = :var1";
exec sql end declare section;
exec sql declare cur cursor for
select name, born, age, married, children from meskes;
char msg[128], command[128];
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
strcpy(msg, "connect");
exec sql connect to unix:postgresql://localhost:5432/mm;
strcpy(msg, "create");
exec sql create table meskes(name char(8), born integer, age smallint, married date, children integer);
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, 33, '19900404', 3);
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103, 8);
exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 5);
exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 1);
strcpy(msg, "commit");
exec sql commit;
strcpy(msg, "open");
exec sql open cur;
exec sql whenever not found do break;
while (1) {
strcpy(msg, "fetch");
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %10.10s", married->arr);
if (ind_children >= 0)
printf(", children = %d", children);
putchar('\n');
free(married);
married = NULL;
}
strcpy(msg, "close");
exec sql close cur;
/* and now the same query with prepare */
exec sql prepare MM from :query;
exec sql declare prep cursor for MM;
strcpy(msg, "open");
exec sql open prep using :testname;
exec sql whenever not found do break;
while (1) {
strcpy(msg, "fetch");
exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %10.10s", married->arr);
if (ind_children >= 0)
printf(", children = %d", children);
putchar('\n');
}
free(married);
strcpy(msg, "close");
exec sql close prep;
strcpy(msg, "drop");
exec sql drop table meskes;
strcpy(msg, "commit");
exec sql commit;
strcpy(msg, "disconnect");
exec sql disconnect;
if (dbgs != NULL)
fclose(dbgs);
return (0);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册