#include <sqlca.h>
/* variables visible to the programs */
-int no_auto_trans;
-
static struct sqlca sqlca_init =
{
{'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '},
{
char *name;
PGconn *connection;
- int committed;
+ bool committed;
+ int no_auto_trans;
struct connection *next;
} *all_connections = NULL, *actual_connection = NULL;
/* Now the request is built. */
- if (stmt->connection->committed && !no_auto_trans)
+ if (stmt->connection->committed && !stmt->connection->no_auto_trans)
{
if ((results = PQexec(stmt->connection->connection, "begin transaction")) == NULL)
{
}
bool
-ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd, const char *connection_name)
+ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd, const char *connection_name, int no_auto_trans)
{
struct connection *this = (struct connection *) ecpg_alloc(sizeof(struct connection), lineno);
}
this->committed = true;
+ this->no_auto_trans = no_auto_trans;
return true;
}
*/
char * input_filename = NULL;
-static void
+void
output_line_number()
{
if (input_filename)
- fprintf(yyout, "\n#line %d \"%s\"\n", yylineno, input_filename);
+ fprintf(yyout, "\n#line %d \"%s\"\n", yylineno + 1, input_filename);
+}
+
+static void
+output_simple_statement(char *cmd)
+{
+ fputs(cmd, yyout);
+ output_line_number();
+ free(cmd);
}
/*
| RevokeStmt { output_statement($1, 0); }
| OptimizableStmt {
if (strncmp($1, "/* " , sizeof("/* ")-1) == 0)
- {
- fputs($1, yyout);
- free($1);
- }
+ output_simple_statement($1);
else
output_statement($1, 1);
}
if (connection)
yyerror("no at option for connect statement.\n");
- fprintf(yyout, "no_auto_trans = %d;\n", no_auto_trans);
- fprintf(yyout, "ECPGconnect(__LINE__, %s);", $1);
+ fprintf(yyout, "ECPGconnect(__LINE__, %s, %d);", $1, no_auto_trans);
whenever_action(0);
free($1);
}
| ECPGCursorStmt {
- fputs($1, yyout);
- free($1);
+ output_simple_statement($1);
}
| ECPGDeallocate {
if (connection)
free($1);
}
| ECPGDeclare {
- fputs($1, yyout);
- free($1);
+ output_simple_statement($1);
}
| ECPGDisconnect {
if (connection)
if (connection)
yyerror("no at option for typedef statement.\n");
- fputs($1, yyout);
- free($1);
+ output_simple_statement($1);
}
| ECPGVar {
if (connection)
yyerror("no at option for var statement.\n");
- fputs($1, yyout);
- free($1);
+ output_simple_statement($1);
}
| ECPGWhenever {
if (connection)
yyerror("no at option for whenever statement.\n");
- fputs($1, yyout);
- output_line_number();
- free($1);
+ output_simple_statement($1);
}
;
}
| '-' a_expr %prec UMINUS
{ $$ = cat2_str(make1_str("-"), $2); }
+ | '%' a_expr
+ { $$ = cat2_str(make1_str("%"), $2); }
+ | a_expr '%'
+ { $$ = cat2_str($1, make1_str("%")); }
| a_expr '+' a_expr
{ $$ = cat3_str($1, make1_str("+"), $3); }
| a_expr '-' a_expr
{
$$ = make1_str("user");
}
-
| EXISTS '(' SubSelect ')'
{
$$ = make3_str(make1_str("exists("), $3, make1_str(")"));
}
| '-' b_expr %prec UMINUS
{ $$ = cat2_str(make1_str("-"), $2); }
+ | '%' b_expr
+ { $$ = cat2_str(make1_str("%"), $2); }
+ | b_expr '%'
+ { $$ = cat2_str($1, make1_str("%")); }
| b_expr '+' b_expr
{ $$ = cat3_str($1, make1_str("+"), $3); }
| b_expr '-' b_expr
{
$$ = make2_str($1, make1_str(",NULL"));
}
- | user_name '/' ColId
+ | user_name '/' user_name
{
$$ = make3_str($1, make1_str(","), $3);
}
}
| '-' ecpg_expr %prec UMINUS
{ $$ = cat2_str(make1_str("-"), $2); }
+ | '%' ecpg_expr
+ { $$ = cat2_str(make1_str("%"), $2); }
+ | a_expr '%'
+ { $$ = cat2_str($1, make1_str("%")); }
| a_expr '+' ecpg_expr
{ $$ = cat3_str($1, make1_str("+"), $3); }
| a_expr '-' ecpg_expr
{ $$ = cat3_str($1, make1_str("<"), $3); }
| a_expr '>' ecpg_expr
{ $$ = cat3_str($1, make1_str(">"), $3); }
+ | a_expr '=' NULL_P
+ { $$ = cat2_str($1, make1_str("= NULL")); }
+ | NULL_P '=' a_expr
+ { $$ = cat2_str(make1_str("= NULL"), $3); }
| a_expr '=' ecpg_expr
{ $$ = cat3_str($1, make1_str("="), $3); }
/* | ':' ecpg_expr
{
$$ = make1_str("current_user");
}
+ | USER
+ {
+ $$ = make1_str("user");
+ }
| EXISTS '(' SubSelect ')'
{
$$ = make3_str(make1_str("exists("), $3, make1_str(")"));
}
| a_expr IN '(' in_expr ')'
{
- $$ = make4_str($1, make1_str("in ("), $4, make1_str(")"));
+ $$ = make4_str($1, make1_str(" in ("), $4, make1_str(")"));
}
| a_expr NOT IN '(' not_in_expr ')'
{
- $$ = make4_str($1, make1_str("not in ("), $5, make1_str(")"));
+ $$ = make4_str($1, make1_str(" not in ("), $5, make1_str(")"));
}
| a_expr Op '(' SubSelect ')'
{
}
| a_expr Op ALL '(' SubSelect ')'
{
- $$ = make3_str($1, $2, make3_str(make1_str("all ("), $5, make1_str(")")));
+ $$ = cat3_str($1, $2, make3_str(make1_str("all ("), $5, make1_str(")")));
}
| a_expr '+' ALL '(' SubSelect ')'
{
{ $$ = cat3_str($1, make1_str("or"), $3); }
| NOT ecpg_expr
{ $$ = cat2_str(make1_str("not"), $2); }
+ | case_expr
+ { $$ = $1; }
| civariableonly
{ $$ = $1; }
;