From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com> |
Cc: | Andrzej Kosmala <ak(at)webproject(dot)pl>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: "ERROR: Query-specified return tuple and actual function |
Date: | 2003-01-14 02:31:19 |
Message-ID: | 12135.1042511479@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Joe Conway <mail(at)joeconway(dot)com> writes:
> Without this change, any table that has had a column dropped would not
> be able to be used as a function's return type at all.
Yup, that was the idea ;-)
> start with table test, attributes (a,b,c)
> drop attribute b from test
> tupledesc_mismatch checks that function's output is (a,c)
> if function actually outputs (a,c), no problem
But there *is* a problem: tuples conforming to test's tupledescriptor
must actually still have three columns. If the function only outputs
two columns, it won't work.
You might possibly be able to make it work by restructuring the tuple to
have a null column in the middle, but I'm not sure about all the
consequences.
In the meantime, tupledesc_mismatch *is correct as it stands* --- if the
test it embodies is not satisfied, you will get core dumps. What you
would need to do if you do not like the present behavior is to be
willing to restructure the function's result tuple.
I believe that there are comparable problems in the other direction:
it's possible that the tuple actually returned by the function might
contain attisdropped columns that you'd need to ignore to make it match
up to the expected result type. I'm not quite sure about how to put
together mapping logic that handles all these cases, but it could
probably be done.
However, all this is just the tip of the iceberg. Suppose I have
defined a view
CREATE VIEW v AS SELECT a, b, c FROM myfunction()
where myfunction returns a rowtype containing a,b,c. What happens if
someone drops column b from the table defining the rowtype?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Adam Buraczewski | 2003-01-14 10:33:11 | Re: "ERROR: Query-specified return tuple and actual function |
Previous Message | Joe Conway | 2003-01-14 02:13:01 | Re: "ERROR: Query-specified return tuple and actual function |