Is TG_NARGS/TG_ARGV just legacy, or what?

Lists: pgsql-hackers
From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Is TG_NARGS/TG_ARGV just legacy, or what?
Date: 2006-03-04 22:44:04
Message-ID: 200603041444.04650.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Folks,

I was just building something and noticing the peculiar structure we've
given to arguments to trigger procedures. Instead of declaring them
normally, we pass them through the variables TG_NARGS and TG_ARGV[]. This
is inconsistent with the entire rest of Postgres, as well as making it
hard to validate passed constants (e.g. if you pass the wrong number of
arguments, you won't know it until execution time).

Is there some sound technical reason not to use the standard argument
declaration, or is this just something we've overlooked fixing?

--
--Josh

Josh Berkus
Aglio Database Solutions
San Francisco


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is TG_NARGS/TG_ARGV just legacy, or what?
Date: 2006-03-04 23:47:27
Message-ID: 200603041547.28145.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew,

> It does have the advantage that you can call a single trigger function
> with variable argument types/numbers. "Fixing" it would involve an
> unknown amount of legacy breakage.

Yes ... I don't see a good way to maintain legacy compatibility.

Triggers seem like the least useful place to have variable-argument
functions, though. And it is inconsistent with how we use functions
everywhere else, as well as in violation of the SQL03 standard on CREATE
FUNCTION (don't know what the standard says about triggers, though).

--
--Josh

Josh Berkus
Aglio Database Solutions
San Francisco


From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <josh(at)agliodbs(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Is TG_NARGS/TG_ARGV just legacy, or what?
Date: 2006-03-04 23:59:59
Message-ID: 4862.24.211.165.134.1141516799.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus said:
> Folks,
>
> I was just building something and noticing the peculiar structure we've
> given to arguments to trigger procedures. Instead of declaring them
> normally, we pass them through the variables TG_NARGS and TG_ARGV[].
> This is inconsistent with the entire rest of Postgres, as well as
> making it hard to validate passed constants (e.g. if you pass the
> wrong number of arguments, you won't know it until execution time).
>
> Is there some sound technical reason not to use the standard argument
> declaration, or is this just something we've overlooked fixing?
>

I'm not sure it's broken ... just different.

It does have the advantage that you can call a single trigger function with
variable argument types/numbers. "Fixing" it would involve an unknown amount
of legacy breakage.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: josh(at)agliodbs(dot)com
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is TG_NARGS/TG_ARGV just legacy, or what?
Date: 2006-03-05 01:48:29
Message-ID: 28798.1141523309@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> Triggers seem like the least useful place to have variable-argument
> functions, though. And it is inconsistent with how we use functions
> everywhere else, as well as in violation of the SQL03 standard on CREATE
> FUNCTION (don't know what the standard says about triggers, though).

On what basis do you assert that?

Triggers necessarily have arguments that aren't in the explicit argument
list, namely the state data about the new/old row and so on. It
wouldn't be productive to try to force all that stuff to be passed as
explicit arguments (and if we did try, we'd make it harder to add more
trigger arguments in future). The ARGV thing for stuff passed from the
CREATE TRIGGER command is certainly on the crufty side, but it's not
inconsistent with how we pass all the other data to a trigger. I don't
see an argument for changing this that justifies the compatibility
problems we'd create.

regards, tom lane