By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,710 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,710 IT Pros & Developers. It's quick & easy.

Bug in functions returning setof where table has dropped column?

P: n/a

I really cannot tell if this is a bug or I am just doing something
stupid.

I create a table called wibble:

CREATE TABLE wibble (a integer, b integer);

I insert some data:

INSERT INTO wibble VALUES (1,1);

I decide that actually I want column b to be a BIGINT, so I do:

ALTER TABLE wibble ADD COLUMN c BIGINT;
UPDATE wibble SET c = b;
ALTER TABLE wibble DROP COLUMN b;
ALTER TABLE wibble RENAME c TO b;

I have written a function which shows fairly simply my problem.

CREATE FUNCTION foobar() RETURNS SETOF wibble AS
'SELECT * FROM wibble' LANGUAGE SQL;

Doing 'select * from foobar();' gives me the error:

ERROR: query-specified return row and actual function return row do not
match

I have tested it on other tables where I have not messed around with
any columns like this and it does not occur for them.

I am using postgresql 7.4.1 on Debian sid/unstable (i386).

I would love to know what I have done wrong here, if this is not a bug.

Thanks in advance,

Stephen Quinney
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Stephen Quinney <st*************@computing-services.oxford.ac.uk> writes:
I have written a function which shows fairly simply my problem. CREATE FUNCTION foobar() RETURNS SETOF wibble AS
'SELECT * FROM wibble' LANGUAGE SQL; Doing 'select * from foobar();' gives me the error: ERROR: query-specified return row and actual function return row do not
match


Yeah, there are various bits of the system that are still not fully
comfortable with dropped columns, and that's one of them. Not sure
how hard it would be to fix this particular problem.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.