summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeodor Sigaev2009-01-28 18:31:32 +0000
committerTeodor Sigaev2009-01-28 18:31:32 +0000
commit2fc6e706138ff4794e383655d9ce46aaf49772d3 (patch)
tree339ebaecaa99c41c65dc3579c56c2c75121e1755
parent19e0014129b54ec3d0da187c836699d0cead74a2 (diff)
Fix bug with multiple evaluation of tsearch2 compatibility trigger, trigger
data should be restored. Backpatch only for 8.3 because previous versions haven't such layer.
-rw-r--r--contrib/tsearch2/tsearch2.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/contrib/tsearch2/tsearch2.c b/contrib/tsearch2/tsearch2.c
index 4e127264eb..db59331ab7 100644
--- a/contrib/tsearch2/tsearch2.c
+++ b/contrib/tsearch2/tsearch2.c
@@ -367,8 +367,10 @@ tsa_tsearch2(PG_FUNCTION_ARGS)
{
TriggerData *trigdata;
Trigger *trigger;
- char **tgargs;
+ char **tgargs,
+ **tgargs_old;
int i;
+ Datum res;
/* Check call context */
if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */
@@ -388,10 +390,20 @@ tsa_tsearch2(PG_FUNCTION_ARGS)
tgargs[1] = pstrdup(GetConfigOptionByName("default_text_search_config",
NULL));
+ tgargs_old = trigger->tgargs;
trigger->tgargs = tgargs;
trigger->tgnargs++;
- return tsvector_update_trigger_byid(fcinfo);
+ res = tsvector_update_trigger_byid(fcinfo);
+
+ /* restore old trigger data */
+ trigger->tgargs = tgargs_old;
+ trigger->tgnargs--;
+
+ pfree(tgargs[1]);
+ pfree(tgargs);
+
+ return res;
}