Q: unexpected result from SRF in SQL - Mailing list pgsql-hackers

From Ian Barwick
Subject Q: unexpected result from SRF in SQL
Date
Msg-id 200205260828.12643.barwick@gmx.net
Whole thread Raw
List 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);
CREATE TABLE
func_test=# INSERT INTO foo VALUES(1, 'Hello','World');
INSERT 24819 1
func_test=#
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';
CREATE FUNCTION

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);   bar
-----------139059784
(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:

Previous
From: Joe Conway
Date:
Subject: sample SRF: SHOW ALL equiv C function returning setof composite
Next
From: Neil Conway
Date:
Subject: COPY and views