Re: Number of parameters in a sql function

Started by Tom Lanealmost 27 years ago4 messages
#1Tom Lane
tgl@sss.pgh.pa.us

"Stan Ng" <stan@squaresoft.com> writes:

I'm running into a limit problem with CREATE FUNCTION. Whenever I exceed
the limit on parameters, somewhere around 12 for me, psql bombs on me
with the "pqReadData() -- backend closed the channel unexpectedly" error
message. Is there any way to increase the parameter limit for
functions?

It shouldn't be letting you get that high; the system limit is 8
parameters for a function. (It looks to me like parse_func.c should
be, but is failing to, verify that the length of the parameter lists
it is passed are within bounds --- or else gram.y itself should complain
if the list is overlength.)

Increasing the limit would be rather a major project I suspect.
A quick look around the sources found a lot of dependencies, some
being symbolic constants (not all the same one :-() and some being
hard coded "8"s. Ick. Also, you would certainly be facing an initdb
and database reload, because the number of argument-type columns in
pg_proc would have to increase.

It'd be good to clean this up and replace pg_proc's fixed-size
proargtypes column with a variable-size "array of oid" column.
Any volunteers?

regards, tom lane

#2Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Tom Lane (#1)
Re: [HACKERS] Re: Number of parameters in a sql function

Looks like this was fixed, because we now generate an error:

test=> create function klasd (int, int, int, int, int, int, int, int,
int) returns int as 'asdf' language 'c';
ERROR: Procedures cannot take more than 8 arguments

"Stan Ng" <stan@squaresoft.com> writes:

I'm running into a limit problem with CREATE FUNCTION. Whenever I exceed
the limit on parameters, somewhere around 12 for me, psql bombs on me
with the "pqReadData() -- backend closed the channel unexpectedly" error
message. Is there any way to increase the parameter limit for
functions?

It shouldn't be letting you get that high; the system limit is 8
parameters for a function. (It looks to me like parse_func.c should
be, but is failing to, verify that the length of the parameter lists
it is passed are within bounds --- or else gram.y itself should complain
if the list is overlength.)

Increasing the limit would be rather a major project I suspect.
A quick look around the sources found a lot of dependencies, some
being symbolic constants (not all the same one :-() and some being
hard coded "8"s. Ick. Also, you would certainly be facing an initdb
and database reload, because the number of argument-type columns in
pg_proc would have to increase.

It'd be good to clean this up and replace pg_proc's fixed-size
proargtypes column with a variable-size "array of oid" column.
Any volunteers?

regards, tom lane

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: [HACKERS] Re: Number of parameters in a sql function

Bruce Momjian <maillist@candle.pha.pa.us> writes:

Looks like this was fixed, because we now generate an error:
test=> create function klasd (int, int, int, int, int, int, int, int,
int) returns int as 'asdf' language 'c';
ERROR: Procedures cannot take more than 8 arguments

I'm not sure if this is a sufficient defense or not --- IIRC, there were
places in the parser that stuffed info into size-8 arrays without any
nearby check that no more than 8 items would be forthcoming. Offhand
the obvious try doesn't crash it:

regression=> select foo(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18);
ERROR: No such function 'foo' with the specified attributes

but I am hoping to go back and look more carefully.

regards, tom lane

#4ZEUGSWETTER Andreas IZ5
Andreas.Zeugswetter@telecom.at
In reply to: Tom Lane (#3)
Re: [HACKERS] Re: Number of parameters in a sql function

Offhand the obvious try doesn't crash it:

regression=> select foo(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18);
ERROR: No such function 'foo' with the specified attributes

SQL functions do allow more than 8 parameters.

Andreas