summaryrefslogtreecommitdiff
path: root/statement.c
diff options
context:
space:
mode:
authorHeikki Linnakangas2013-04-18 20:03:11 +0000
committerHeikki Linnakangas2013-04-18 20:03:11 +0000
commit9be21e28393d490cdf07e7e8a494112a88ed5df5 (patch)
treef8f75f9f20532b79136fb7619d48a9925abc3aec /statement.c
parent1bf0f3d78c1789fd2c2275c92fa7330bff72c027 (diff)
Avoid multiple evaluation in some macros.
There was at least one real bug caused by the multiple evaluation of 2nd argument to SC_set_result(). SC_pre_execute() passed QR_Constructor() call as the 2nd argument, so we ended up creating extra result sets that were leaked.
Diffstat (limited to 'statement.c')
-rw-r--r--statement.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/statement.c b/statement.c
index 0c40967..7c0878e 100644
--- a/statement.c
+++ b/statement.c
@@ -522,6 +522,41 @@ SC_Destructor(StatementClass *self)
return TRUE;
}
+void
+SC_init_Result(StatementClass *self)
+{
+ self->result = self->curres = NULL;
+ self->curr_param_result = 0;
+ mylog("SC_init_Result(%x)", self);
+}
+
+void
+SC_set_Result(StatementClass *self, QResultClass *res)
+{
+ if (res != self->result)
+ {
+ mylog("SC_set_Result(%x, %x)", self, res);
+ QR_Destructor(self->result);
+ self->result = self->curres = res;
+ if (NULL != res)
+ self->curr_param_result = 1;
+ }
+}
+
+void
+SC_forget_unnamed(StatementClass *self)
+{
+ if (PREPARED_TEMPORARILY == self->prepared)
+ {
+ SC_set_prepared(self, ONCE_DESCRIBED);
+ if (FALSE && !SC_IsExecuting(self))
+ {
+ QResultClass *res = SC_get_Curres(self);
+ if (NULL != res && !res->dataFilled && !QR_is_fetching_tuples(res))
+ SC_set_Result(self, NULL);
+ }
+ }
+}
/*
* Free parameters and free the memory from the