aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2009-01-28 18:32:55 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2009-01-28 18:32:55 +0000
commite40c166d6ec87b71500c8034fd2ce3d1ec3d2c26 (patch)
treefadbd87eab07aad21d886f69afeb794460a15d13
parent20632d57f1b3476668e1bf6a4667b9533949d9f4 (diff)
downloadpostgresql-e40c166d6ec87b71500c8034fd2ce3d1ec3d2c26.tar.gz
postgresql-e40c166d6ec87b71500c8034fd2ce3d1ec3d2c26.zip
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.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/contrib/tsearch2/tsearch2.c b/contrib/tsearch2/tsearch2.c
index 9dc5eb3bdbf..c0ba00eafe7 100644
--- a/contrib/tsearch2/tsearch2.c
+++ b/contrib/tsearch2/tsearch2.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.5 2008/01/01 19:45:45 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.5.2.1 2009/01/28 18:32:55 teodor Exp $
*
*-------------------------------------------------------------------------
*/
@@ -372,8 +372,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 */
@@ -393,10 +395,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;
}