Skip to content

Commit 3ca7edd

Browse files
committed
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.
1 parent 61fd2c5 commit 3ca7edd

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

contrib/tsearch2/tsearch2.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.8 2009/01/01 17:23:32 momjian Exp $
10+
* $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.9 2009/01/28 18:31:32 teodor Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -367,8 +367,10 @@ tsa_tsearch2(PG_FUNCTION_ARGS)
367367
{
368368
TriggerData *trigdata;
369369
Trigger *trigger;
370-
char **tgargs;
370+
char **tgargs,
371+
**tgargs_old;
371372
int i;
373+
Datum res;
372374

373375
/* Check call context */
374376
if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */
@@ -388,10 +390,20 @@ tsa_tsearch2(PG_FUNCTION_ARGS)
388390

389391
tgargs[1] = pstrdup(GetConfigOptionByName("default_text_search_config",
390392
NULL));
393+
tgargs_old = trigger->tgargs;
391394
trigger->tgargs = tgargs;
392395
trigger->tgnargs++;
393396

394-
return tsvector_update_trigger_byid(fcinfo);
397+
res = tsvector_update_trigger_byid(fcinfo);
398+
399+
/* restore old trigger data */
400+
trigger->tgargs = tgargs_old;
401+
trigger->tgnargs--;
402+
403+
pfree(tgargs[1]);
404+
pfree(tgargs);
405+
406+
return res;
395407
}
396408

397409

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy