Using a snapshot from two days ago on a i586-pc-linux-gnu using
linux-elf template:

test=> create table test (t1 integer);
CREATE
test=> create function myfunc (integer) returns integer
test-> as 'select $1' language 'sql';
ERROR:  ProcedureCreate: arg type 'integer' is not defined
test=> create function myfunc(int4) returns int4
test-> as 'select $1' language 'sql';
CREATE

I can use the integer type in tables, but not in functions.  Is this a
bug?

Ewan Mellor.

Thu, 05 Feb 1998 17:00:15 +0000
Ewan Mellor <em@nexus.co.uk>
create function bug?

I noticed that too, but since I don't use 'integer' in tables, I
figured postgres didn't have the "integer" type (which probably should
have struck me as odd).  It might be one of these silly grammer
rewrites, in which case (if there isn't central type/function parsing
code it seems like more trouble than it's worth, I mean why not just
have the extra type/functions in the catalogs?  or have aliases somehow?)

I'm sure you can work around it ;)

On Thu, 5 February 1998, at 17:00:15, Ewan Mellor wrote:

> Using a snapshot from two days ago on a i586-pc-linux-gnu using
> linux-elf template:
> 
> test=> create table test (t1 integer);
> CREATE
> test=> create function myfunc (integer) returns integer
> test-> as 'select $1' language 'sql';
> ERROR:  ProcedureCreate: arg type 'integer' is not defined
> test=> create function myfunc(int4) returns int4
> test-> as 'select $1' language 'sql';
> CREATE
> 
> I can use the integer type in tables, but not in functions.  Is this a
> bug?
> 
> Ewan Mellor.

Thu, 5 Feb 1998 11:05:19 -0800
Brett McCormick <brett@work.chicken.org>
Re: [HACKERS] create function bug?

After going over the grammer and function code, there's a little bit
of weirdness I see.  I don't know the correct terminology, but the
grammer for typname is a little odd.  in the first case (i.e. txname)
it does some type translating itself (flort => float8, decimal =>
integer, numeric => integer) before calling xlateSqlType, which does
the same thing, but with the following types: (int/integer => int4,
smalling => int2, real => float8, interval => timespan)

in the second case (SETOF txname), none of this pre-xlateSqlType
translating is done.

is it safe to assume someone put this code in the wrong place (not in
xlateSqlType so it would apply to all types)?  is the grammar the best
place for this "type aliasing"?  would it be safe to modify the create
function grammer to call xlateSqlType (so long as opaque does not get
aliased to anything? ;)

--brett

> On Thu, 5 February 1998, at 17:00:15, Ewan Mellor wrote:
> 
> > Using a snapshot from two days ago on a i586-pc-linux-gnu using
> > linux-elf template:
> > 
> > test=> create table test (t1 integer);
> > CREATE
> > test=> create function myfunc (integer) returns integer
> > test-> as 'select $1' language 'sql';
> > ERROR:  ProcedureCreate: arg type 'integer' is not defined
> > test=> create function myfunc(int4) returns int4
> > test-> as 'select $1' language 'sql';
> > CREATE
> > 
> > I can use the integer type in tables, but not in functions.  Is this a
> > bug?
> > 
> > Ewan Mellor.

Thu, 5 Feb 1998 13:14:30 -0800
Brett McCormick <brett@work.chicken.org>
Re: [HACKERS] create function bug?

On Thu, 5 Feb 1998, Ewan Mellor wrote:

> test=> create function myfunc (integer) returns integer
> test-> as 'select $1' language 'sql';

  On most PLs that I used, you need to specify a variable name for the
param, after all, how are you going to refer to it?

  Try:

create function myfunc (myint integer) returns integer
as 'select $1' language 'sql';


Tom


Thu, 5 Feb 1998 13:48:10 -0800 (PST)
Tom <tom@sdf.com>
Re: [HACKERS] create function bug?
> is it safe to assume someone put this code in the wrong place (not in
> xlateSqlType so it would apply to all types)?  is the grammar the best
> place for this "type aliasing"?  would it be safe to modify the create
> function grammer to call xlateSqlType (so long as opaque does not get
> aliased to anything? ;)
> > > Using a snapshot from two days ago on a i586-pc-linux-gnu using
> > > linux-elf template: <snip>
> > > I can use the integer type in tables, but not in functions.  Is this a
> > > bug?

This behavior must have been in the code for a long time. Anyway, I'll fix it
for v6.3 (I have some other similar fixes for function names ready to commit
and I'll do both at the same time).

"integer" is translated into "int4" in the parser, to avoid having to
replicate the declarations for the support code. Specify the actual type name
and your declaration will work now.

                                                - Tom


Fri, 06 Feb 1998 02:53:37 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] create function bug?