summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/preproc')
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.c3
-rw-r--r--src/interfaces/ecpg/preproc/extern.h1
-rw-r--r--src/interfaces/ecpg/preproc/preproc.y12
-rw-r--r--src/interfaces/ecpg/preproc/variable.c22
4 files changed, 27 insertions, 11 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index ceb06fb744..31bc48752f 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -177,8 +177,7 @@ main(int argc, char *const argv[])
for (ptr = cur; ptr != NULL;)
{
struct cursor *this = ptr;
- struct arguments *l1,
- *l2;
+ struct arguments *l1, *l2;
free(ptr->command);
free(ptr->connection);
diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h
index f79c3b43a0..41b3f9d972 100644
--- a/src/interfaces/ecpg/preproc/extern.h
+++ b/src/interfaces/ecpg/preproc/extern.h
@@ -59,6 +59,7 @@ extern void add_descriptor(char *,char *);
extern void drop_descriptor(char *,char *);
extern struct descriptor *lookup_descriptor(char *,char *);
extern void add_variable(struct arguments ** , struct variable * , struct variable *);
+extern void append_variable(struct arguments ** , struct variable * , struct variable *);
extern void dump_variables(struct arguments *, int);
extern struct typedefs *get_typedef(char *);
extern void adjust_array(enum ECPGttype, int *, int *, int, int, bool);
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index e21a67b080..78dad88c4f 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -525,15 +525,13 @@ stmt: AlterTableStmt { output_statement($1, 0, NULL, connection); }
}
/* merge variables given in prepare statement with those given here */
- for (p = argsinsert; p && p->next; p = p->next);
- if (p)
- p->next = ptr->argsinsert;
- else
- argsinsert = ptr->argsinsert;
+ for (p = ptr->argsinsert; p; p = p->next)
+ append_variable(&argsinsert, p->variable, p->indicator);
- argsresult = ptr->argsresult;
+ for (p = ptr->argsresult; p; p = p->next)
+ add_variable(&argsresult, p->variable, p->indicator);
- output_statement(ptr->command, 0, NULL, ptr->connection);
+ output_statement(mm_strdup(ptr->command), 0, NULL, ptr->connection ? mm_strdup(ptr->connection) : NULL);
}
| ECPGPrepare {
if (connection)
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c
index 98cf32576d..3de45350b1 100644
--- a/src/interfaces/ecpg/preproc/variable.c
+++ b/src/interfaces/ecpg/preproc/variable.c
@@ -189,17 +189,35 @@ reset_variables(void)
argsresult = NULL;
}
-/* Add a variable to a request. */
+/* Insert a new variable into our request list. */
void
add_variable(struct arguments ** list, struct variable * var, struct variable * ind)
{
- struct arguments * p = (struct arguments *)mm_alloc(sizeof(struct arguments));
+ struct arguments *p = (struct arguments *)mm_alloc(sizeof(struct arguments));
+
p->variable = var;
p->indicator = ind;
p->next = *list;
*list = p;
}
+/* Append a new variable to our request list. */
+void
+append_variable(struct arguments ** list, struct variable * var, struct variable * ind)
+{
+ struct arguments *p, *new = (struct arguments *)mm_alloc(sizeof(struct arguments));
+
+ for (p = *list; p && p->next; p = p->next);
+
+ new->variable = var;
+ new->indicator = ind;
+ new->next = NULL;
+
+ if (p)
+ p->next = new;
+ else
+ *list = new;
+}
/* Dump out a list of all the variable on this list.
This is a recursive function that works from the end of the list and