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

Q: unexpected result from SRF in SQL

From: Ian Barwick <barwick(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Q: unexpected result from SRF in SQL
Date: 2002-05-26 06:28:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Using a recent build (22.5) from CVS, if I create a set returning
function in SQL like this:

func_test=# CREATE TABLE foo (id INT, txt1 TEXT, txt2 TEXT);
func_test=# INSERT INTO foo VALUES(1, 'Hello','World');
INSERT 24819 1
func_test=# CREATE OR REPLACE FUNCTION bar(int)
func_test-# RETURNS SETOF foo
func_test-# AS 'SELECT * FROM foo WHERE id = $1'
func_test-# LANGUAGE 'sql';

I can do this (expected result):

func_test=# SELECT txt1, txt2 FROM bar(1);
 txt1  | txt2  
 Hello | World
(1 row)

but also this:

func_test=# select bar(1);
(1 row)

What is this number? It often varies from query to query.
Possibly an error-in-disguise because of something to do
with the calling context?

Just curious ;-)

Ian Barwick


pgsql-hackers by date

Next:From: Neil ConwayDate: 2002-05-26 06:32:01
Subject: COPY and views
Previous:From: Joe ConwayDate: 2002-05-26 06:24:21
Subject: sample SRF: SHOW ALL equiv C function returning setof composite

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