Re: Smallint - Integer Casting Problems in Plpgsql

Lists: pgsql-general
From: Denis Gasparin <denis(at)edistar(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Smallint - Integer Casting Problems in Plpgsql functions
Date: 2004-03-17 15:54:19
Message-ID: 405874AB.9020701@edistar.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi, i'm upgrading our database from postgresql 7.2.3 to 7.4.2.
The import went fine but i have some casting problems with plpgsql
functions.

I've create a test function with this code:

create function test(varchar,smallint,integer) returns integer as '
declare
a alias for $1;
b alias for $2;
c alias for $3;
begin
raise notice ''test'';
return 1;
end;
' language 'plpgsql';

The command:
select test('aaa',1,1);
gives me the following error:
ERROR: function test("unknown", integer, integer) does not exist
HINT: No function matches the given name and argument types. You may
need to add explicit type casts.

Obviously, with the command:
select test('aaa',1::smallint,1);

the result is 1.

Thank you in advance for your help,

--
Doct. Eng. Denis Gasparin: denis(at)edistar(dot)com
---------------------------
Programmer & System Administrator - Edistar srl


From: Richard Huxton <dev(at)archonet(dot)com>
To: Denis Gasparin <denis(at)edistar(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Smallint - Integer Casting Problems in Plpgsql functions
Date: 2004-03-17 17:26:01
Message-ID: 200403171726.01377.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wednesday 17 March 2004 15:54, Denis Gasparin wrote:
> Hi, i'm upgrading our database from postgresql 7.2.3 to 7.4.2.
> The import went fine but i have some casting problems with plpgsql
> functions.
>
> I've create a test function with this code:
>
> create function test(varchar,smallint,integer) returns integer as '

> select test('aaa',1,1);
> gives me the following error:
> ERROR: function test("unknown", integer, integer) does not exist

Easiest solution is to just define the function as accepting integer rather
than smallint.
I believe the typeing will be smarter in 7.5 but don't know if it will affect
this situation.

--
Richard Huxton
Archonet Ltd


From: Denis Gasparin <denis(at)edistar(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Smallint - Integer Casting Problems in Plpgsql functions
Date: 2004-03-18 07:52:24
Message-ID: 40595538.3040703@edistar.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi Richard.
Thank you for your reply. I rewrote the store procedure to accept
integer instead of smallint.

What i don't understand is why the casting is working in 7.2.3. What
has been changed from that?

Thank you,

--
Doct. Eng. Denis Gasparin: denis(at)edistar(dot)com
---------------------------
Programmer & System Administrator - Edistar srl

Richard Huxton wrote:

>On Wednesday 17 March 2004 15:54, Denis Gasparin wrote:
>
>
>>Hi, i'm upgrading our database from postgresql 7.2.3 to 7.4.2.
>>The import went fine but i have some casting problems with plpgsql
>>functions.
>>
>>I've create a test function with this code:
>>
>>create function test(varchar,smallint,integer) returns integer as '
>>
>>
>
>
>
>>select test('aaa',1,1);
>>gives me the following error:
>>ERROR: function test("unknown", integer, integer) does not exist
>>
>>
>
>Easiest solution is to just define the function as accepting integer rather
>than smallint.
>I believe the typeing will be smarter in 7.5 but don't know if it will affect
>this situation.
>
>
>


From: Richard Huxton <dev(at)archonet(dot)com>
To: Denis Gasparin <denis(at)edistar(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Smallint - Integer Casting Problems in Plpgsql functions
Date: 2004-03-18 09:15:54
Message-ID: 200403180915.54761.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thursday 18 March 2004 07:52, Denis Gasparin wrote:
> Hi Richard.
> Thank you for your reply. I rewrote the store procedure to accept
> integer instead of smallint.
>
> What i don't understand is why the casting is working in 7.2.3. What
> has been changed from that?

The type system was tightened up. It's been made smarter for 7.5, but I'm not
sure it deals with this.

--
Richard Huxton
Archonet Ltd


From: Denis Gasparin <denis(at)edistar(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Smallint - Integer Casting Problems in Plpgsql functions
Date: 2004-03-18 10:12:20
Message-ID: 40597604.7090904@edistar.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


>The type system was tightened up. It's been made smarter for 7.5, but I'm not
>sure it deals with this.
>
>
>
I suspected it was so. I hope that in 7.5 the problem will be solved
because i think it is more a bug than a feature and many people will be
asking for it...

I hope Tom Lane and the others Postgresql developers will be reading this.

Thank you,

--
Doct. Eng. Denis Gasparin: denis(at)edistar(dot)com
---------------------------
Programmer & System Administrator - Edistar srl


From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: Denis Gasparin <denis(at)edistar(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Smallint - Integer Casting Problems in Plpgsql functions
Date: 2004-03-18 15:54:23
Message-ID: 20040318155423.22532.qmail@web20812.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

--- Denis Gasparin <denis(at)edistar(dot)com> wrote:
>
> >The type system was tightened up. It's been made
> smarter for 7.5, but I'm not
> >sure it deals with this.
> >
> >
> >
> I suspected it was so. I hope that in 7.5 the
> problem will be solved
> because i think it is more a bug than a feature and
> many people will be
> asking for it...
>
> I hope Tom Lane and the others Postgresql developers
> will be reading this.

If you search the mailing list archives you will find
plenty of discussions on this issue, some quite
recent. If you still have issues or questions to
raise after reading those discussions, then you will
certainly not be wasting the developers' time by
posting them.

>
> Thank you,
>
> --
> Doct. Eng. Denis Gasparin: denis(at)edistar(dot)com
> ---------------------------
> Programmer & System Administrator - Edistar srl
>
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please
> send an appropriate
> subscribe-nomail command to
> majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list
cleanly

__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com


From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
Cc: Denis Gasparin <denis(at)edistar(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Smallint - Integer Casting Problems in Plpgsql
Date: 2004-03-23 19:34:37
Message-ID: 1080070477.11890.420.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, 2004-03-18 at 10:54, Jeff Eckermann wrote:
> --- Denis Gasparin <denis(at)edistar(dot)com> wrote:
> >
> > >The type system was tightened up. It's been made
> > smarter for 7.5, but I'm not
> > >sure it deals with this.
> > >
> > I suspected it was so. I hope that in 7.5 the
> > problem will be solved
> > because i think it is more a bug than a feature and
> > many people will be
> > asking for it...
> >
> > I hope Tom Lane and the others Postgresql developers
> > will be reading this.
>
> If you search the mailing list archives you will find
> plenty of discussions on this issue, some quite
> recent. If you still have issues or questions to
> raise after reading those discussions, then you will
> certainly not be wasting the developers' time by
> posting them.
>

I'll add that on the 7.5 install I tested this on (which admittedly is a
bit old), it was still "busted", so if you want to see this changed
you'll need to be a squeaky wheel.

Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL