77 *
88 *
99 * IDENTIFICATION
10- * $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.8 2009/01/01 17:23 :32momjian Exp $
10+ * $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.9 2009/01/28 18:31 :32teodor Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -367,8 +367,10 @@ tsa_tsearch2(PG_FUNCTION_ARGS)
367367{
368368TriggerData * trigdata ;
369369Trigger * trigger ;
370- char * * tgargs ;
370+ char * * tgargs ,
371+ * * tgargs_old ;
371372int i ;
373+ Datum res ;
372374
373375/* Check call context */
374376if (!CALLED_AS_TRIGGER (fcinfo ))/* internal error */
@@ -388,10 +390,20 @@ tsa_tsearch2(PG_FUNCTION_ARGS)
388390
389391tgargs [1 ]= pstrdup (GetConfigOptionByName ("default_text_search_config" ,
390392NULL ));
393+ tgargs_old = trigger -> tgargs ;
391394trigger -> tgargs = tgargs ;
392395trigger -> 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