From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch> |
Cc: | pgsql-general(at)postgresql(dot)org, Joe Conway <mail(at)joeconway(dot)com> |
Subject: | Re: Crosstab Problems |
Date: | 2007-10-18 15:47:37 |
Message-ID: | 24199.1192722457@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-patches |
Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch> writes:
> Here is a SQL dump for the table. One can just neglect the JOIN with
> the countries table (which just replaces the country id with the
> country name):
> http://geodata.grid.unep.ch/download/sql_agri_area.sql.zip
> But when re-doing the query now without the JOIN, it works (almost):
OK, after poking at it, it seems that crosstab() isn't prepared for
null rowids. I can reproduce the crash without any data:
contrib_regression=# select * from crosstab(
'SELECT null::text as name, 10 as year, 42 as value', 3)
as ct(name text, year int, value int);
server closed the connection unexpectedly
Backtrace looks like
#0 0xc008774c in ?? () from /usr/lib/libc.1
#1 0x3eb0bc in MemoryContextStrdup (context=0x40167048, string=0x0)
at mcxt.c:662
#2 0xc0a5f2e4 in crosstab (fcinfo=0x7b03b858) at tablefunc.c:539
#3 0x239e24 in ExecMakeTableFunctionResult (funcexpr=0x401615e8,
econtext=0x401611f0, expectedDesc=0x401613a0, returnDesc=0x7b03b7d8)
at execQual.c:1566
#4 0x24d264 in FunctionNext (node=0x40161160) at nodeFunctionscan.c:68
#5 0x23ed8c in ExecScan (node=0x40161160,
accessMtd=0x400170b2 <DINFINITY+3218>) at execScan.c:68
#6 0x24d2c4 in ExecFunctionScan (node=0x40167048) at nodeFunctionscan.c:109
so it's trying to pstrdup a null result from SPI_getvalue.
Obviously it shouldn't crash, but I'm not sure what it *should* do in
this case. Joe?
In the meantime, it appears that you want to not use a LEFT JOIN here,
or else maybe COALESCE(c.name, '') so that a null isn't returned to
crosstab.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Lizhe.Xu | 2007-10-18 15:49:40 | Problem of installation on Mac |
Previous Message | brian | 2007-10-18 15:38:19 | Re: running postgres |
From | Date | Subject | |
---|---|---|---|
Next Message | Florian G. Pflug | 2007-10-18 16:03:56 | Re: Why copy_relation_data only use wal whenWALarchivingis enabled |
Previous Message | Stefan Schwarzer | 2007-10-18 15:17:22 | Re: Crosstab Problems |