Re: Pl/Pgsql triger procedure calls with parameters - Mailing list pgsql-general

From Tom Lane
Subject Re: Pl/Pgsql triger procedure calls with parameters
Date
Msg-id 16117.1006818599@sss.pgh.pa.us
Whole thread Raw
In response to Pl/Pgsql triger procedure calls with parameters  (David A Dickson <davidd@saraswati.wcg.mcgill.ca>)
List pgsql-general
David A Dickson <davidd@saraswati.wcg.mcgill.ca> writes:
> I am trying to make a call to a function that takes three text parameters
> as input from a trigger. The function is supposed to check if
> SELECT * FROM $3 WHERE new.$1 = $3.$2
> has more than 0 rows.

While this may seem neat and clean, I think you'd be a lot better off
writing multiple trigger functions that have the table and field names
wired into them.  If you insist on parameterizing like this, you will
have to run the queries via EXECUTE in plpgsql, which means you will get
no query plan caching, which is a performance hit you probably do not
want to take in a trigger function.

            regards, tom lane

pgsql-general by date:

Previous
From: "news.postgresql.org"
Date:
Subject: check constriaint for BLOB
Next
From: "Gurupartap Davis"
Date:
Subject: Re: Optimize for insertions?