return (true);
}
+static void
+free_variable(struct variable *var)
+{
+ struct variable *var_next;
+
+ if( var == (struct variable *)NULL )
+ return;
+ var_next = var->next;
+ free(var);
+
+ while(var_next)
+ {
+ var = var_next;
+ var_next = var->next;
+ free(var);
+ }
+}
+
+static void
+free_statement(struct statement *stmt)
+{
+ if( stmt == (struct statement *)NULL )
+ return;
+ free_variable(stmt->inlist);
+ free_variable(stmt->outlist);
+ free(stmt);
+}
+
static char *
next_insert(char *text)
{
status = false;
}
- PQclear(results);
break;
case PGRES_EMPTY_QUERY:
/* do nothing */
status = false;
break;
}
+ PQclear(results);
}
/* check for asynchronous returns */
va_list args;
struct statement *stmt;
struct connection *con = get_connection(connection_name);
+ bool status;
if (con == NULL)
{
- register_error(ECPG_NO_CONN, "No such connection %s in line %d.", connection_name, lineno);
+ register_error(ECPG_NO_CONN, "No such connection %s in line %d.", connection_name ? connection_name : "NULL", lineno);
return (false);
}
return false;
}
- return (ECPGexecute(stmt));
+ status = ECPGexecute(stmt);
+ free_statement(stmt);
+ return (status);
}
bool
if (con == NULL)
{
- register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name, lineno);
+ register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name ? connection_name : "NULL", lineno);
return (false);
}
if (con == NULL)
{
- register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name, lineno);
+ register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name ? connection_name : "NULL", lineno);
return (false);
}
return true;
}
+bool
+ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
+{
+ struct connection *con = get_connection(connection_name);
+ PGresult *results;
+
+ if (con)
+ {
+ if (con->no_auto_trans == true && strncmp(mode, "ON", strlen("ON")) == 0)
+ {
+ if (con->committed)
+ {
+ if ((results = PQexec(con->connection, "begin transaction")) == NULL)
+ {
+ register_error(ECPG_TRANS, "Error in transaction processing line %d.", lineno);
+ return false;
+ }
+ PQclear(results);
+ con->committed = false;
+ }
+ con->no_auto_trans = false;
+ }
+ else if (con->no_auto_trans == false && strncmp(mode, "OFF", strlen("OFF")) == 0)
+ {
+ if (!con->committed)
+ {
+ if ((results = PQexec(con->connection, "commit")) == NULL)
+ {
+ register_error(ECPG_TRANS, "Error in transaction processing line %d.", lineno);
+ return false;
+ }
+ PQclear(results);
+ con->committed = true;
+ }
+ con->no_auto_trans = true;
+ }
+ }
+ else
+ {
+ register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name ? connection_name : "NULL", lineno);
+ return false;
+ }
+
+ return true;
+}
+
bool
ECPGsetconn(int lineno, const char *connection_name)
{
}
else
{
- register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name, lineno);
+ register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name ? connection_name : "NULL", lineno);
return false;
}
}
if (con == NULL)
{
- ECPGlog("disconnect: not connected to connection %s\n", connection_name);
- register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name, lineno);
+ ECPGlog("disconnect: not connected to connection %s\n", connection_name ? connection_name : "NULL");
+ register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name ? connection_name : "NULL", lineno);
return false;
}
else
%%
<SQL>{comment} { /* ignore */ }
-{xcline} { /* ignore */ }
+{xcline} { ECHO; }
-<xc>{xcstar} { /* ignore */ }
+<xc>{xcstar} { ECHO; }
{xcstart} {
before_comment = YYSTATE;
+ ECHO;
BEGIN(xc);
}
-<xc>{xcstop} { BEGIN(before_comment); }
+<xc>{xcstop} { ECHO; BEGIN(before_comment); }
-<xc>{xcinside} { /* ignore */ }
+<xc>{xcinside} { ECHO; }
<SQL>{xbstart} {
BEGIN(xb);
}
}
}
-<SQL>{integer}/{space}*-{number} {
+<C,SQL>{integer}/{space}*-{number} {
char* endptr;
BEGIN(xm);
}
return ICONST;
}
-<SQL>{real}/{space}*-{number} {
+<C,SQL>{real}/{space}*-{number} {
char* endptr;
BEGIN(xm);
yyerror("ERROR: Bad float8 input");
return FCONST;
}
-<SQL>{integer} {
+<C,SQL>{integer} {
char* endptr;
errno = 0;
}
return ICONST;
}
-<SQL>{real} {
+<C,SQL>{real} {
char* endptr;
errno = 0;
yyerror("ERROR: Bad float input");
return FCONST;
}
-<C>{integer}/{space}*-{number} {
- char* endptr;
-
- BEGIN(xm);
- errno = 0;
- yylval.ival = strtol((char *)yytext,&endptr,10);
- if (*endptr != '\0' || errno == ERANGE)
- {
- errno = 0;
- yylval.dval = strtod(((char *)yytext),&endptr);
- if (*endptr != '\0' || errno == ERANGE)
- yyerror("ERROR: Bad integer input");
- yyerror("WARNING: Integer input is out of range; promoted to float");
- return FCONST;
- }
- return ICONST;
- }
-<C>{integer} {
- char* endptr;
-
- errno = 0;
- yylval.ival = strtol((char *)yytext,&endptr,10);
- if (*endptr != '\0' || errno == ERANGE)
- {
- errno = 0;
- yylval.dval = strtod(((char *)yytext),&endptr);
- if (*endptr != '\0' || errno == ERANGE)
- yyerror("ERROR: Bad integer input");
- yyerror("WARNING: Integer input is out of range; promoted to float");
- return FCONST;
- }
- return ICONST;
- }
<SQL>:{identifier}(("->"|\.){identifier})* {
yylval.str = mm_strdup((char*)yytext+1);
return(CVARIABLE);