| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | pgsql-hackers(at)postgreSQL(dot)org |
| Subject: | Problem in contrib/tablefunc's crosstab() |
| Date: | 2008-11-30 23:55:27 |
| Message-ID: | 13839.1228089327@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
While fooling with the recent contrib problem
http://archives.postgresql.org/pgsql-committers/2008-11/msg00346.php
I noticed another way that tablefunc.c is being cavalier about the
state when it returns control: the crosstab() function returns with
an internal SPI call still active! This is relatively harmless in
the case where it's being called by MakeTableFunctionResult; but you
can expose an error in other cases, for instance running two of 'em
in parallel:
contrib_regression=# SELECT crosstab3(
'select rowid, attribute, value
from ct
where attribute = ''att2'' or attribute = ''att3''
order by 1,2'),
crosstab3(
'select rowid, attribute, value
from ct
where attribute = ''att2'' or attribute = ''att3''
order by 1,2');
ERROR: crosstab: SPI_connect returned -1
The right way to fix this IMHO is to change the function to be called
only once and accumulate its results into a tuplestore. That'll be
marginally more efficient, too.
Think I'll go fix this while I'm watching the football game ...
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2008-12-01 02:17:16 | Re: Comments to Synchronous replication patch v3 |
| Previous Message | Tom Lane | 2008-11-30 23:07:09 | Re: pgsql: Remove inappropriate memory context switch in |