473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Bug in functions returning setof where table has dropped column?


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
1 1475
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Steven An | last post by:
Howdy, I need to write an update query with multiple aggregate functions. Here is an example: UPDATE t SET t.a = ( select avg(f.q) from dbo.foo f where f.p = t.y ), t.b = ( select sum(f.q)...
1
by: BARTKO, Zoltan | last post by:
Ladies and Gentlemen, Please, enlighten me, if you can, in the following matter: I made a type: create type my_type as ( a integer, b integer );
2
by: Chris Travers | last post by:
Hi all; I suspect I know what the answer here is, but I thought I would ask anyway. How transparent are SQL language functions from the planner's perspective? For example if I create a table:...
4
by: Bill Moran | last post by:
I'm having a little trouble understanding how to do something. I assume I'm just missing it in the documentation, so a pointer to relevent docs would be as welcome as a direct answer. I have a...
2
by: Gellert, Andre | last post by:
Hello, I have following problem: A user "xy" shouldn't have any rights to a table, but needs data from the content of the table. My idea was to setup a PL/PGSQL procedure to fetch the data...
5
by: Robert Fitzpatrick | last post by:
Can someone point me to some more information or perhaps show an example of returning a recordset from a plpgsql function. I'd like to send an argument or arguments to the function, do some queries...
2
by: Vladimir M | last post by:
Hi I am writing a function with PL/pgSQL, which returns result of some complex query with several tables. In manual i found such example: CREATE OR REPLACE FUNCTION Test() RETURNS SETOF...
0
by: lazybee26 | last post by:
Hello – I’m trying to findout a better solution to this approach. Currently if I have to return columns from multiple tables, I have to define my own TYPE and then return SETOF that type in...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.