CREATE TABLE "bug_table" (
"id" BIGINT NOT NULL,
test VARCHAR,
CONSTRAINT "test_table_pkey" PRIMARY KEY("id")
) WITHOUT OIDS;
INSERT INTO bug_table (id,test) VALUES (1,'test');
select * from bug_table;
CREATE OR REPLACE FUNCTION buggy_procedure() RETURNS TABLE (id INT8,
test VARCHAR)
AS $$
BEGIN
-- @todo hide password
RETURN QUERY
SELECT id ,test
FROM bug_table
;
END;
$$
LANGUAGE plpgsql STRICT SECURITY DEFINER;
SELECT * FROM buggy_procedure();
---------------------------
it returns 1 but empty row. What is wrong with this?
Regards
Michal Szymanski
http://blog.szymanskich.net
Don't use column names in your functions that are the same as variable
or parameter names of the function. This is working basically as if
you'd written "SELECT null,null", because the output parameters are
still null when the RETURN QUERY is executed.
regards, tom lane
--
Sent via pgsql-general mailing list (pgsql-...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
use qualified names instead
RETURN QUERY
SELECT b.id, b.test
FROM bug_table b;
regards
Pavel Stehule
Thank you, now it works. Using RETURNS TABLE will resolve my other
problem related to the bug/functionality of Postgres -
http://groups.google.pl/group/pgsql.bugs/browse_thread/thread/0647bde500c1b782?hl=pl#