Received: from www.actarg.com (root@[209.180.91.25]) by hub.org (8.9.3/8.9.3) with ESMTP id NAA57338 for ; Fri, 3 Mar 2000 13:17:08 -0500 (EST) (envelope-from kyle@actarg.com) Received: from actarg.com (root@tao.actarg.com [192.168.2.1]) by www.actarg.com (8.8.7/8.8.7) with ESMTP id LAA18837 for ; Fri, 3 Mar 2000 11:17:07 -0700 Received: from actarg.com (kyle@chi.actarg.com [192.168.2.16]) by actarg.com (8.8.7/8.8.7) with ESMTP id LAA14441 for ; Fri, 3 Mar 2000 11:15:05 -0700 Sender: kyle@actarg.com Message-ID: <38C0022D.B30A7536@actarg.com> Date: Fri, 03 Mar 2000 11:19:25 -0700 From: Kyle Bateman Organization: Action Target Inc X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.0.36 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: 7.0beta bug (or feature)? Content-Type: multipart/mixed; boundary="------------B7490E62AD05C125402120CC" This is a multi-part message in MIME format. --------------B7490E62AD05C125402120CC Content-Type: multipart/alternative; boundary="------------28E2999B4D849EA85018441E" --------------28E2999B4D849EA85018441E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This function would load OK in 6.5 but doesn't work in 7.0beta1: The problem is in the very last function definition where date_week is defined with a date argument. It simply calls the date_week function that has a text argument, but apparently, the parser does not recognize the fact that a cast is present and tries to look for an existing function date_week(date) instead of date_week(text). It looks like either there is a problem in the parser with casting, or there is a new way of doing things I should adapt to. Anyone know which it is? Here is the error message: ERROR: No such function 'date_week' with the specified attributes Here is the SQL to recreate the problem: -- Define PLPSQL Language ******************************** drop function plpgsql_call_handler (); CREATE FUNCTION plpgsql_call_handler () RETURNS OPAQUE AS '/usr/local/pgsql/lib/plpgsql.so' LANGUAGE 'C'; -- This creates the plpgsql language drop PROCEDURAL LANGUAGE 'plpgsql'; CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'; -- Define PLTCL Language ********************************* drop function pltcl_call_handler (); CREATE FUNCTION pltcl_call_handler () RETURNS OPAQUE AS '/usr/local/pgsql/lib/pltcl.so' LANGUAGE 'C'; -- This creates the plpgsql language drop PROCEDURAL LANGUAGE 'pltcl'; CREATE TRUSTED PROCEDURAL LANGUAGE 'pltcl' HANDLER pltcl_call_handler LANCOMPILER 'PL/TCL'; -- Convert date in 1999-01-15 format to the month of the year (1999,35) -- calling sequence: date_week(ISO_date) drop function date_week(text); create function date_week(text) returns text as ' set spl [split $1 {-/. }] set year [lindex $spl 0] set month [string trimleft [lindex $spl 1] 0] set day [lindex $spl 2] if {$month > 0 && $month <= 31} { set secs [clock scan "$month/$day/$year"] } else { set secs [clock scan "$month $day, $year"] } set week [clock format $secs -format "%U"] if {$week == 0} { return "[expr $year - 1]-52" } return "$year-$week" ' LANGUAGE 'pltcl'; drop function date_week(date); create function date_week(date) returns text as ' select date_week($1::text); ' LANGUAGE 'sql'; --------------28E2999B4D849EA85018441E Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit This function would load OK in 6.5 but doesn't work in 7.0beta1:

The problem is in the very last function definition  where date_week is defined with a date argument.  It simply calls the date_week function that has a text argument, but apparently, the parser does not recognize the fact that a cast is present and tries to look for an existing function date_week(date) instead of date_week(text).

It looks like either there is a problem in the parser with casting, or there is a new way of doing things I should adapt to.  Anyone know which it is?

Here is the error message:
ERROR:  No such function 'date_week' with the specified attributes
 

Here is the SQL to recreate the problem:

-- Define PLPSQL Language ********************************
drop function plpgsql_call_handler ();
CREATE FUNCTION plpgsql_call_handler () RETURNS OPAQUE AS
        '/usr/local/pgsql/lib/plpgsql.so' LANGUAGE 'C';

-- This creates the plpgsql language
drop PROCEDURAL LANGUAGE 'plpgsql';
CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql'
        HANDLER plpgsql_call_handler
        LANCOMPILER 'PL/pgSQL';

-- Define PLTCL Language *********************************
drop function pltcl_call_handler ();
CREATE FUNCTION pltcl_call_handler () RETURNS OPAQUE AS
        '/usr/local/pgsql/lib/pltcl.so' LANGUAGE 'C';

-- This creates the plpgsql language
drop PROCEDURAL LANGUAGE 'pltcl';
CREATE TRUSTED PROCEDURAL LANGUAGE 'pltcl'
        HANDLER pltcl_call_handler
        LANCOMPILER 'PL/TCL';

-- Convert date in 1999-01-15 format to the month of the year (1999,35)
-- calling sequence: date_week(ISO_date)
drop function date_week(text);
create function date_week(text) returns text as '
        set spl [split $1 {-/. }]
        set year [lindex $spl 0]
        set month [string trimleft [lindex $spl 1] 0]
        set day [lindex $spl 2]
        if {$month > 0 && $month <= 31} {
            set secs [clock scan "$month/$day/$year"]
        } else {
            set secs [clock scan "$month $day, $year"]
        }
        set week [clock format $secs -format "%U"]
        if {$week == 0} {
            return "[expr $year - 1]-52"
        }
        return "$year-$week"
        ' LANGUAGE 'pltcl';

drop function date_week(date);
create function date_week(date) returns text as '
        select date_week($1::text);
        ' LANGUAGE 'sql';
 
 
  --------------28E2999B4D849EA85018441E-- --------------B7490E62AD05C125402120CC Content-Type: text/x-vcard; charset=us-ascii; name="kyle.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Kyle Bateman Content-Disposition: attachment; filename="kyle.vcf" begin:vcard n:Bateman;Kyle tel;fax:801-377-8096 tel;work:801-377-8033x101 x-mozilla-html:FALSE url:www.actiontarget.com org:Action Target Inc adr:;;PO Box 636;Provo;UT;84603;US version:2.1 email;internet:kyle@actiontarget.com title:President x-mozilla-cpt:;-15520 fn:Kyle Bateman end:vcard --------------B7490E62AD05C125402120CC--