*** empty log message ***
This commit is contained in:
parent
9a4344e73e
commit
29e2916827
@ -555,6 +555,10 @@ Mon Apr 12 17:56:14 CEST 1999
|
||||
- Fixed ECPG variable handling.
|
||||
- Make no_auto_trans be accessible via SET command.
|
||||
- Do not eat comments so line numbering should be correct.
|
||||
|
||||
Wed Apr 14 17:59:06 CEST 1999
|
||||
|
||||
- Added simple calculations for array bounds.
|
||||
- Set library version to 3.0.0
|
||||
- Set ecpg version to 2.6.0
|
||||
|
||||
|
@ -45,8 +45,6 @@ extern "C"
|
||||
struct cursor *next;
|
||||
};
|
||||
|
||||
extern int no_auto_trans;
|
||||
|
||||
/* define this for simplicity as well as compatibility */
|
||||
|
||||
#define SQLCODE sqlca.sqlcode
|
||||
|
@ -55,7 +55,7 @@ static struct connection
|
||||
char *name;
|
||||
PGconn *connection;
|
||||
bool committed;
|
||||
int no_auto_trans;
|
||||
int autocommit;
|
||||
struct connection *next;
|
||||
} *all_connections = NULL, *actual_connection = NULL;
|
||||
|
||||
@ -660,7 +660,7 @@ ECPGexecute(struct statement * stmt)
|
||||
|
||||
/* Now the request is built. */
|
||||
|
||||
if (stmt->connection->committed && !stmt->connection->no_auto_trans)
|
||||
if (stmt->connection->committed && !stmt->connection->autocommit)
|
||||
{
|
||||
if ((results = PQexec(stmt->connection->connection, "begin transaction")) == NULL)
|
||||
{
|
||||
@ -1164,7 +1164,7 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
|
||||
|
||||
if (con)
|
||||
{
|
||||
if (con->no_auto_trans == true && strncmp(mode, "ON", strlen("ON")) == 0)
|
||||
if (con->autocommit == true && strncmp(mode, "OFF", strlen("OFF")) == 0)
|
||||
{
|
||||
if (con->committed)
|
||||
{
|
||||
@ -1176,9 +1176,9 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
|
||||
PQclear(results);
|
||||
con->committed = false;
|
||||
}
|
||||
con->no_auto_trans = false;
|
||||
con->autocommit = false;
|
||||
}
|
||||
else if (con->no_auto_trans == false && strncmp(mode, "OFF", strlen("OFF")) == 0)
|
||||
else if (con->autocommit == false && strncmp(mode, "ON", strlen("ON")) == 0)
|
||||
{
|
||||
if (!con->committed)
|
||||
{
|
||||
@ -1190,7 +1190,7 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
|
||||
PQclear(results);
|
||||
con->committed = true;
|
||||
}
|
||||
con->no_auto_trans = true;
|
||||
con->autocommit = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1220,7 +1220,7 @@ ECPGsetconn(int lineno, const char *connection_name)
|
||||
}
|
||||
|
||||
bool
|
||||
ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd, const char *connection_name, int no_auto_trans)
|
||||
ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd, const char *connection_name, int autocommit)
|
||||
{
|
||||
struct connection *this = (struct connection *) ecpg_alloc(sizeof(struct connection), lineno);
|
||||
|
||||
@ -1258,7 +1258,7 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd
|
||||
}
|
||||
|
||||
this->committed = true;
|
||||
this->no_auto_trans = no_auto_trans;
|
||||
this->autocommit = autocommit;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ extern char *optarg;
|
||||
#include "extern.h"
|
||||
|
||||
struct _include_path *include_paths;
|
||||
int no_auto_trans = 0;
|
||||
int autocommit = 0;
|
||||
struct cursor *cur = NULL;
|
||||
struct typedefs *types = NULL;
|
||||
|
||||
@ -76,7 +76,7 @@ main(int argc, char *const argv[])
|
||||
add_include_path(optarg);
|
||||
break;
|
||||
case 't':
|
||||
no_auto_trans = 1;
|
||||
autocommit = 1;
|
||||
break;
|
||||
case 'v':
|
||||
fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
|
||||
|
@ -21,6 +21,7 @@
|
||||
static ScanKeyword ScanKeywords[] = {
|
||||
/* name value */
|
||||
{"at", SQL_AT},
|
||||
{"autocommit", SQL_AUTOCOMMIT},
|
||||
{"bool", SQL_BOOL},
|
||||
{"break", SQL_BREAK},
|
||||
{"call", SQL_CALL},
|
||||
@ -39,6 +40,7 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"indicator", SQL_INDICATOR},
|
||||
{"int", SQL_INT},
|
||||
{"long", SQL_LONG},
|
||||
{"off", SQL_OFF},
|
||||
{"open", SQL_OPEN},
|
||||
{"prepare", SQL_PREPARE},
|
||||
{"reference", SQL_REFERENCE},
|
||||
|
@ -5,7 +5,7 @@
|
||||
/* variables */
|
||||
|
||||
extern int braces_open,
|
||||
no_auto_trans, struct_level;
|
||||
autocommit, struct_level;
|
||||
extern char *yytext, errortext[128];
|
||||
extern int yylineno,
|
||||
yyleng;
|
||||
|
@ -654,12 +654,12 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
|
||||
}
|
||||
|
||||
/* special embedded SQL token */
|
||||
%token SQL_AT SQL_BOOL SQL_BREAK
|
||||
%token SQL_AT SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK
|
||||
%token SQL_CALL SQL_CONNECT SQL_CONNECTION SQL_CONTINUE
|
||||
%token SQL_DEALLOCATE SQL_DISCONNECT SQL_ENUM
|
||||
%token SQL_FOUND SQL_FREE SQL_GO SQL_GOTO
|
||||
%token SQL_IDENTIFIED SQL_IMMEDIATE SQL_INDICATOR SQL_INT SQL_LONG
|
||||
%token SQL_OPEN SQL_PREPARE SQL_RELEASE SQL_REFERENCE
|
||||
%token SQL_OFF SQL_OPEN SQL_PREPARE SQL_RELEASE SQL_REFERENCE
|
||||
%token SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQLERROR SQL_SQLPRINT
|
||||
%token SQL_SQLWARNING SQL_START SQL_STOP SQL_STRUCT SQL_UNSIGNED
|
||||
%token SQL_VAR SQL_WHENEVER
|
||||
@ -831,7 +831,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
|
||||
%type <str> ECPGFree ECPGDeclare ECPGVar sql_variable_declarations
|
||||
%type <str> sql_declaration sql_variable_list sql_variable opt_at
|
||||
%type <str> struct_type s_struct declaration variable_declarations
|
||||
%type <str> s_struct s_union union_type
|
||||
%type <str> s_struct s_union union_type ECPGSetAutocommit on_off
|
||||
|
||||
%type <type_enum> simple_type varchar_type
|
||||
|
||||
@ -842,6 +842,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
|
||||
%type <index> opt_array_bounds nest_array_bounds opt_type_array_bounds
|
||||
%type <index> nest_type_array_bounds
|
||||
|
||||
%type <ival> Iresult
|
||||
%%
|
||||
prog: statements;
|
||||
|
||||
@ -913,7 +914,7 @@ stmt: AddAttrStmt { output_statement($1, 0); }
|
||||
if (connection)
|
||||
yyerror("no at option for connect statement.\n");
|
||||
|
||||
fprintf(yyout, "ECPGconnect(__LINE__, %s, %d);", $1, no_auto_trans);
|
||||
fprintf(yyout, "ECPGconnect(__LINE__, %s, %d);", $1, autocommit);
|
||||
whenever_action(0);
|
||||
free($1);
|
||||
}
|
||||
@ -981,6 +982,11 @@ stmt: AddAttrStmt { output_statement($1, 0); }
|
||||
free($1);
|
||||
}
|
||||
| ECPGRelease { /* output already done */ }
|
||||
| ECPGSetAutocommit {
|
||||
fprintf(yyout, "ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
|
||||
whenever_action(0);
|
||||
free($1);
|
||||
}
|
||||
| ECPGSetConnection {
|
||||
if (connection)
|
||||
yyerror("no at option for set connection statement.\n");
|
||||
@ -3170,11 +3176,14 @@ opt_array_bounds: '[' ']' nest_array_bounds
|
||||
$$.index2 = $3.index1;
|
||||
$$.str = cat2_str(make1_str("[]"), $3.str);
|
||||
}
|
||||
| '[' Iconst ']' nest_array_bounds
|
||||
| '[' Iresult ']' nest_array_bounds
|
||||
{
|
||||
$$.index1 = atol($2);
|
||||
char *txt = mm_alloc(20L);
|
||||
|
||||
sprintf (txt, "%d", $2);
|
||||
$$.index1 = $2;
|
||||
$$.index2 = $4.index1;
|
||||
$$.str = cat4_str(make1_str("["), $2, make1_str("]"), $4.str);
|
||||
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
|
||||
}
|
||||
| /* EMPTY */
|
||||
{
|
||||
@ -3190,11 +3199,14 @@ nest_array_bounds: '[' ']' nest_array_bounds
|
||||
$$.index2 = $3.index1;
|
||||
$$.str = cat2_str(make1_str("[]"), $3.str);
|
||||
}
|
||||
| '[' Iconst ']' nest_array_bounds
|
||||
| '[' Iresult ']' nest_array_bounds
|
||||
{
|
||||
$$.index1 = atol($2);
|
||||
char *txt = mm_alloc(20L);
|
||||
|
||||
sprintf (txt, "%d", $2);
|
||||
$$.index1 = $2;
|
||||
$$.index2 = $4.index1;
|
||||
$$.str = cat4_str(make1_str("["), $2, make1_str("]"), $4.str);
|
||||
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
|
||||
}
|
||||
| /* EMPTY */
|
||||
{
|
||||
@ -3204,6 +3216,16 @@ nest_array_bounds: '[' ']' nest_array_bounds
|
||||
}
|
||||
;
|
||||
|
||||
Iresult: Iconst { $$ = atol($1); }
|
||||
| '(' Iresult ')' { $$ = $2; }
|
||||
| Iresult '+' Iresult { $$ = $1 + $3};
|
||||
| Iresult '-' Iresult { $$ = $1 - $3};
|
||||
| Iresult '*' Iresult { $$ = $1 * $3};
|
||||
| Iresult '/' Iresult { $$ = $1 / $3};
|
||||
| Iresult '%' Iresult { $$ = $1 % $3};
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Type syntax
|
||||
@ -3239,6 +3261,7 @@ Generic: generic
|
||||
generic: ident { $$ = $1; }
|
||||
| TYPE_P { $$ = make1_str("type"); }
|
||||
| SQL_AT { $$ = make1_str("at"); }
|
||||
| SQL_AUTOCOMMIT { $$ = make1_str("autocommit"); }
|
||||
| SQL_BOOL { $$ = make1_str("bool"); }
|
||||
| SQL_BREAK { $$ = make1_str("break"); }
|
||||
| SQL_CALL { $$ = make1_str("call"); }
|
||||
@ -3255,6 +3278,7 @@ generic: ident { $$ = $1; }
|
||||
| SQL_INDICATOR { $$ = make1_str("indicator"); }
|
||||
| SQL_INT { $$ = make1_str("int"); }
|
||||
| SQL_LONG { $$ = make1_str("long"); }
|
||||
| SQL_OFF { $$ = make1_str("off"); }
|
||||
| SQL_OPEN { $$ = make1_str("open"); }
|
||||
| SQL_PREPARE { $$ = make1_str("prepare"); }
|
||||
| SQL_RELEASE { $$ = make1_str("release"); }
|
||||
@ -4475,7 +4499,6 @@ ColId: ident { $$ = $1; }
|
||||
| SQL_BREAK { $$ = make1_str("break"); }
|
||||
| SQL_CALL { $$ = make1_str("call"); }
|
||||
| SQL_CONNECT { $$ = make1_str("connect"); }
|
||||
| SQL_CONNECTION { $$ = make1_str("connection"); }
|
||||
| SQL_CONTINUE { $$ = make1_str("continue"); }
|
||||
| SQL_DEALLOCATE { $$ = make1_str("deallocate"); }
|
||||
| SQL_DISCONNECT { $$ = make1_str("disconnect"); }
|
||||
@ -4487,6 +4510,7 @@ ColId: ident { $$ = $1; }
|
||||
| SQL_INDICATOR { $$ = make1_str("indicator"); }
|
||||
| SQL_INT { $$ = make1_str("int"); }
|
||||
| SQL_LONG { $$ = make1_str("long"); }
|
||||
| SQL_OFF { $$ = make1_str("off"); }
|
||||
| SQL_OPEN { $$ = make1_str("open"); }
|
||||
| SQL_PREPARE { $$ = make1_str("prepare"); }
|
||||
| SQL_RELEASE { $$ = make1_str("release"); }
|
||||
@ -5138,13 +5162,27 @@ ECPGRelease: TransactionStmt SQL_RELEASE
|
||||
free($1);
|
||||
}
|
||||
|
||||
/*
|
||||
* set/reset the automatic transaction mode, this needs a differnet handling
|
||||
* as the other set commands
|
||||
*/
|
||||
ECPGSetAutocommit: SET SQL_AUTOCOMMIT to_equal on_off
|
||||
{
|
||||
$$ = $4;
|
||||
}
|
||||
|
||||
on_off: ON { $$ = make1_str("on"); }
|
||||
| SQL_OFF { $$ = make1_str("off"); }
|
||||
|
||||
to_equal: TO | "=";
|
||||
|
||||
/*
|
||||
* set the actual connection, this needs a differnet handling as the other
|
||||
* set commands
|
||||
*/
|
||||
ECPGSetConnection: SET SQL_CONNECTION connection_object
|
||||
ECPGSetConnection: SET SQL_CONNECTION to_equal connection_object
|
||||
{
|
||||
$$ = $3;
|
||||
$$ = $4;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5204,17 +5242,23 @@ opt_type_array_bounds: '[' ']' nest_type_array_bounds
|
||||
$$.index2 = $3.index1;
|
||||
$$.str = cat2_str(make1_str("[]"), $3.str);
|
||||
}
|
||||
| '[' Iconst ']' nest_type_array_bounds
|
||||
| '[' Iresult ']' nest_type_array_bounds
|
||||
{
|
||||
$$.index1 = atol($2);
|
||||
char *txt = mm_alloc(20L);
|
||||
|
||||
sprintf (txt, "%d", $2);
|
||||
$$.index1 = $2;
|
||||
$$.index2 = $4.index1;
|
||||
$$.str = cat4_str(make1_str("["), $2, make1_str("]"), $4.str);
|
||||
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
|
||||
}
|
||||
| '(' Iconst ')' nest_type_array_bounds
|
||||
| '(' Iresult ')' nest_type_array_bounds
|
||||
{
|
||||
$$.index1 = atol($2);
|
||||
char *txt = mm_alloc(20L);
|
||||
|
||||
sprintf (txt, "%d", $2);
|
||||
$$.index1 = $2;
|
||||
$$.index2 = $4.index1;
|
||||
$$.str = cat4_str(make1_str("["), $2, make1_str("]"), $4.str);
|
||||
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
|
||||
}
|
||||
| /* EMPTY */
|
||||
{
|
||||
@ -5236,17 +5280,23 @@ nest_type_array_bounds: '[' ']' nest_type_array_bounds
|
||||
$$.index2 = $3.index1;
|
||||
$$.str = cat2_str(make1_str("[]"), $3.str);
|
||||
}
|
||||
| '[' Iconst ']' nest_type_array_bounds
|
||||
| '[' Iresult ']' nest_type_array_bounds
|
||||
{
|
||||
$$.index1 = atol($2);
|
||||
char *txt = mm_alloc(20L);
|
||||
|
||||
sprintf (txt, "%d", $2);
|
||||
$$.index1 = $2;
|
||||
$$.index2 = $4.index1;
|
||||
$$.str = cat4_str(make1_str("["), $2, make1_str("]"), $4.str);
|
||||
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
|
||||
}
|
||||
| '(' Iconst ')' nest_type_array_bounds
|
||||
| '(' Iresult ')' nest_type_array_bounds
|
||||
{
|
||||
$$.index1 = atol($2);
|
||||
char *txt = mm_alloc(20L);
|
||||
|
||||
sprintf (txt, "%d", $2);
|
||||
$$.index1 = $2;
|
||||
$$.index2 = $4.index1;
|
||||
$$.str = cat4_str(make1_str("["), $2, make1_str("]"), $4.str);
|
||||
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
|
||||
}
|
||||
| /* EMPTY */
|
||||
{
|
||||
@ -5954,6 +6004,10 @@ c_anything: IDENT { $$ = $1; }
|
||||
| Iconst { $$ = $1; }
|
||||
| Fconst { $$ = $1; }
|
||||
| '*' { $$ = make1_str("*"); }
|
||||
| '+' { $$ = make1_str("+"); }
|
||||
| '-' { $$ = make1_str("-"); }
|
||||
| '/' { $$ = make1_str("/"); }
|
||||
| '%' { $$ = make1_str("%"); }
|
||||
| S_AUTO { $$ = make1_str("auto"); }
|
||||
| S_BOOL { $$ = make1_str("bool"); }
|
||||
| S_CHAR { $$ = make1_str("char"); }
|
||||
|
@ -2,6 +2,7 @@ exec sql whenever sqlerror sqlprint;
|
||||
|
||||
exec sql include sqlca;
|
||||
|
||||
/* comment */
|
||||
exec sql define AMOUNT 4;
|
||||
|
||||
exec sql type intarray is int[AMOUNT];
|
||||
@ -42,7 +43,7 @@ exec sql end declare section;
|
||||
exec sql commit;
|
||||
|
||||
strcpy(msg, "set connection");
|
||||
exec sql set connection main;
|
||||
exec sql set connection to main;
|
||||
|
||||
strcpy(msg, "execute insert 1");
|
||||
sprintf(command, "insert into test(name, amount, letter) values ('db: mm', 1, 'f')");
|
||||
@ -69,7 +70,9 @@ exec sql end declare section;
|
||||
|
||||
strcpy(msg, "commit");
|
||||
exec sql commit;
|
||||
exec sql at pm commit;
|
||||
|
||||
/* Stop automatic transactioning for connection pm. */
|
||||
exec sql at pm set autocommit to off;
|
||||
|
||||
strcpy(msg, "select");
|
||||
exec sql select name, amount, letter into :name, :amount, :letter from test;
|
||||
|
Loading…
x
Reference in New Issue
Block a user