X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CF4B6529C7 for ; Sat, 20 Aug 2005 12:52:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84889-02 for ; Sat, 20 Aug 2005 15:52:05 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9B82552EB9 for ; Sat, 20 Aug 2005 12:52:00 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7KFpwj9024395; Sat, 20 Aug 2005 11:51:58 -0400 (EDT) To: Moritz Bayer Cc: pgsql-sql@postgresql.org Subject: Re: Problem with self-made plpgsql-function / casting In-reply-to: References: Comments: In-reply-to Moritz Bayer message dated "Sat, 20 Aug 2005 16:54:22 +0200" Date: Sat, 20 Aug 2005 11:51:58 -0400 Message-ID: <24394.1124553118@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/176 X-Sequence-Number: 22404 Moritz Bayer writes: > ERROR: function public.fc_editlanguage(integer, "unknown", "unknown", > integer) does not exist > > CREATE OR REPLACE FUNCTION "public"."fc_editlanguage" (id bigint, name > varchar, kuerzel varchar, active smallint) RETURNS smallint AS The short answer to this is to avoid declaring function arguments as "smallint". When you call this as, say, select fc_editlanguage(42, 'foo', 'bar', 1); the "42" and the "1" are initially typed as integer constants. There's an implicit up-cast from integer to bigint, so the parser has no problem matching the 42 to a bigint parameter, but the down-cast from integer to smallint is not implicit. With the function as written you'd have to cast to smallint explicitly: select fc_editlanguage(42, 'foo', 'bar', 1::smallint); This is enough of a notational pain in the neck that it's easier just to declare the argument as integer. regards, tom lane