Skip site navigation (1) Skip section navigation (2)

Re: Correcting Error message

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Piyush Newe <piyush(dot)newe(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us
Subject: Re: Correcting Error message
Date: 2010-02-27 00:12:51
Message-ID: BBC897F8-FC06-464A-9D56-ACA977283D86@seespotcode.net (view raw or flat)
Thread:
Lists: pgsql-hackers
On Feb 26, 2010, at 3:30 , Piyush Newe wrote:

> Hi,
>
> Consider following testcase,
>
> CREATE TABLE footable(id int4, name varchar2(10));
>
> CREATE FUNCTION foofunc(a footable, b integer DEFAULT 10)
>  RETURNS integer AS $$ SELECT 123; $$ LANGUAGE SQL;
>
> CREATE FUNCTION foofunc(a footable, b numeric DEFAULT 10)
>  RETURNS integer AS $$ SELECT 123; $$ LANGUAGE SQL;
>
> SELECT (footable.*).foofunc FROM footable;
> ERROR:  column footable.foofunc does not exist
> LINE 1: SELECT (footable.*).foofunc FROM footable;
>               ^

Is that calling syntax correct?  I'd think it should be:

SELECT foofunc(footable.*, 10) FROM footable;

Note there are two arguments to foofunc (in either version)

test=# SELECT version();
                                                                version
--------------------------------------------------------------------------------------------------------------------------------------
  PostgreSQL 8.4.2 on i386-apple-darwin9.8.0, compiled by GCC i686- 
apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493), 32-bit
(1 row)

test=# CREATE TABLE footable(id int4, name varchar(10));
CREATE TABLE
test=# INSERT INTO footable (id, name) VALUES (1, 'foo'), (2, 'bar');
INSERT 0 2
test=# CREATE FUNCTION foofunc(a footable, b integer DEFAULT 10)
postgres-#  RETURNS integer AS $$ SELECT 123; $$ LANGUAGE SQL;
CREATE FUNCTION
test=# CREATE FUNCTION foofunc(a footable, b numeric DEFAULT 10)
postgres-#  RETURNS integer AS $$ SELECT 456; $$ LANGUAGE SQL;
CREATE FUNCTION
test=# SELECT name, foofunc(footable.*, 10) FROM footable;
  name | foofunc
------+---------
  foo  |     123
  bar  |     123
(2 rows)

test=# SELECT name, foofunc(footable.*, 10.0) FROM footable;
  name | foofunc
------+---------
  foo  |     456
  bar  |     456
(2 rows)

In any event, I couldn't get your example to work on Postgres 8.4  
regardless due to the varchar2 type. Which version of Postgres are you  
using?

test=# CREATE TABLE footable(id int4, name varchar2(10));
ERROR:  type "varchar2" does not exist



Michael Glaesemann
grzm seespotcode net




In response to

Responses

pgsql-hackers by date

Next:From: Josh BerkusDate: 2010-02-27 00:21:11
Subject: Re: Re: Hot Standby query cancellation and Streaming Replication integration
Previous:From: Greg SmithDate: 2010-02-27 00:11:36
Subject: Re: Hot Standby query cancellation and Streaming Replication integration

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group