summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2009-12-16 10:15:07 +0000
committerMichael Meskes <meskes@postgresql.org>2009-12-16 10:15:07 +0000
commitd19669e5f90b7dd860f47a399329c5f921908bcf (patch)
treeba8fca9e2ced888503664896bb427e20d95b734a /src/interfaces/ecpg/preproc
parentdd4cd55c15886c46378dc27f44f59a6de8c4d45b (diff)
Fixed auto-prepare to not try preparing statements that are not preparable. Bug
found and solved by Boszormenyi Zoltan <zb@cybertec.at>, some small adjustments by me.
Diffstat (limited to 'src/interfaces/ecpg/preproc')
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.addons9
-rw-r--r--src/interfaces/ecpg/preproc/output.c20
2 files changed, 19 insertions, 10 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.addons b/src/interfaces/ecpg/preproc/ecpg.addons
index 3899fabf515..ec7645dad53 100644
--- a/src/interfaces/ecpg/preproc/ecpg.addons
+++ b/src/interfaces/ecpg/preproc/ecpg.addons
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.11 2009/11/27 16:07:22 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.12 2009/12/16 10:15:06 meskes Exp $ */
ECPG: stmtClosePortalStmt block
{
if (INFORMIX_MODE)
@@ -26,13 +26,14 @@ ECPG: stmtDeallocateStmt block
}
ECPG: stmtDeclareCursorStmt block
{ output_simple_statement($1); }
-ECPG: stmtDeleteStmt block
ECPG: stmtDiscardStmt block
ECPG: stmtFetchStmt block
+ { output_statement($1, 1, ECPGst_normal); }
+ECPG: stmtDeleteStmt block
ECPG: stmtInsertStmt block
ECPG: stmtSelectStmt block
ECPG: stmtUpdateStmt block
- { output_statement($1, 1, ECPGst_normal); }
+ { output_statement($1, 1, ECPGst_prepnormal); }
ECPG: stmtExecuteStmt block
{ output_statement($1, 1, ECPGst_execute); }
ECPG: stmtPrepareStmt block
@@ -133,7 +134,7 @@ ECPG: stmtViewStmt rule
if ((ptr = add_additional_variables($1, true)) != NULL)
{
connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
- output_statement(mm_strdup(ptr->command), 0, 0);
+ output_statement(mm_strdup(ptr->command), 0, ECPGst_normal);
ptr->opened = true;
}
}
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 09486c66d00..94cefdb2d2c 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.25 2009/06/11 14:49:13 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.26 2009/12/16 10:15:06 meskes Exp $ */
#include "postgres_fe.h"
@@ -105,14 +105,24 @@ hashline_number(void)
return EMPTY;
}
+static char *ecpg_statement_type_name[] = {
+ "ECPGst_normal",
+ "ECPGst_execute",
+ "ECPGst_exec_immediate",
+ "ECPGst_prepnormal"
+};
+
void
output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
{
-
fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
- if (st == ECPGst_normal)
+ if (st == ECPGst_execute || st == ECPGst_exec_immediate)
+ {
+ fprintf(yyout, "%s, %s, ", ecpg_statement_type_name[st], stmt);
+ }
+ else
{
- if (auto_prepare)
+ if (st == ECPGst_prepnormal && auto_prepare)
fputs("ECPGst_prepnormal, \"", yyout);
else
fputs("ECPGst_normal, \"", yyout);
@@ -120,8 +130,6 @@ output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
output_escaped_str(stmt, false);
fputs("\", ", yyout);
}
- else
- fprintf(yyout, "%d, %s, ", st, stmt);
/* dump variables to C file */
dump_variables(argsinsert, 1);