BUG #1011: Explain analyze "query" cause segv - Mailing list pgsql-bugs

From PostgreSQL Bugs List
Subject BUG #1011: Explain analyze "query" cause segv
Date
Msg-id 20031216220723.4FBD2CF882A@www.postgresql.com
Whole thread Raw
Responses Re: BUG #1011: Explain analyze "query" cause segv  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      1011
Logged by:          Pawel Rutkowski
Email address:      sor@rsc.pl
PostgreSQL version: 7.4
Operating system:   FreeBSD rsc.pl 4.9-STABLE FreeBSD 4.9-STABLE #22: Tue Dec  2 20:31:00 CET 2003
Description:        Explain analyze "query" cause segv
Details:

I've notice problem with some explain analyze queries.
First explain works great but running same explain once again cause Segmentation Fault.

I've test it on two machines (Celeron 1.7GHz 1GB RAM, 2xPIII 1.1GHz 512MB RAM) with same result.

There is test case (notice there is ltree column):
(its also avaiable at: http://www.manifest.pl/case.sql)

CREATE TABLE p (
    id serial NOT NULL,
    kat ltree NOT NULL,
    name text,
    id_pricelist integer,
    manufactur character varying(50),
    weight character varying(20),
    price double precision,
    stock text,
    id_pricelist_int integer,
    manufactur_code character varying(50) NOT NULL
);

COPY p (id, kat, name, id_pricelist, manufactur, weight, price, stock, id_pricelist_int, manufactur_code) FROM stdin;
1364380  root.tillbeh___ouml____r.h___ouml____gtalare Speaker Soundwave 3000P 5.1 20W SUB 5W Center 4x5W Satelite RMS
15TRUST    498   13 15 12951 
1364353  root.tillbeh___ouml____r.h___ouml____gtalare Speaker Soundwave 350P 2x2W RMS 350W PMPO Retail   15 TRUST
130  4  16 13026 
1364354  root.tillbeh___ouml____r.h___ouml____gtalare Speaker SoundWave 450P 2x3W RMS 450W PMPO Retail   15 TRUST
166  9  16 13028 
1364352  root.tillbeh___ouml____r.h___ouml____gtalare Speaker SoundWave 200P 2x2W RMS Retail    15 TRUST    137   8  16
12558
1366057  root.tillbeh___ouml____r.h___ouml____gtalare Trust Speakers SoundWave 100p 16 TRUST    68 2003-12-17  16 12605
1364378  root.tillbeh___ouml____r.h___ouml____gtalare Speaker SoundWave 1000P Retail   15 TRUST    177   19 15 12616
1364379  root.tillbeh___ouml____r.h___ouml____gtalare Speaker SoundWave 2000P 5.1 Retail  15 TRUST    353   2  15 12618
1367533  root.tillbeh___ouml____r.h___ouml____gtalare Hvgtalare i trd, 300W PMPO, aktiv   18 MEGAPART    80 918   18
SP-100
1367534  root.tillbeh___ouml____r.h___ouml____gtalare Hvgtalare i trd, 300W PMPO, aktiv, svart  18 MEGAPART    80 0  18
SP-101
1367535  root.tillbeh___ouml____r.h___ouml____gtalare Subwooferpaket i trd, 800W PMPO, 20W RMS  18 MEGAPART    200
211  18 SP-300 
\.
EXPLAIN ANALYZE select a.manufactur from p a where kat ~ 'root.tillbeh___ouml____r.h___ouml____gtalare.*' group by
manufacturorder by lower(manufactur); 
EXPLAIN ANALYZE select a.manufactur from p a where kat ~ 'root.tillbeh___ouml____r.h___ouml____gtalare.*' group by
manufacturorder by lower(manufactur); 


and here is backtrace from gdb:
(also avaiable at http://www.manifest.pl/bt.txt)
#0  0x81ca0ef in AllocSetAlloc (context=0x83ae120, size=38) at aset.c:546
546                     if (chunk->size >= size)
(gdb) bt
#0  0x81ca0ef in AllocSetAlloc (context=0x83ae120, size=38) at aset.c:546
#1  0x81ca931 in MemoryContextAlloc (context=0x83ae120, size=38) at mcxt.c:485
#2  0x81a331e in textout (fcinfo=0xbfbfea84) at varlena.c:285
#3  0x81c16ba in FunctionCall3 (flinfo=0x8411528, arg1=138125792, arg2=0, arg3=4294967295) at fmgr.c:1016
#4  0x8081c59 in printtup (tuple=0x83ba1b0, typeinfo=0x8389c18, self=0x83b1778) at printtup.c:337
#5  0x8165e27 in RunFromStore (portal=0x83b5018, direction=ForwardScanDirection, count=0, dest=0x83b1778) at
pquery.c:695
#6  0x8165c51 in PortalRunSelect (portal=0x83b5018, forward=1, count=2147483647, dest=0x83b1778) at pquery.c:573
#7  0x8165b66 in PortalRun (portal=0x83b5018, count=2147483647, dest=0x83b1778, altdest=0x83b1778,
completionTag=0xbfbfecd4"") 
    at pquery.c:467
#8  0x8162c7b in exec_simple_query (
    query_string=0x83b1018 "EXPLAIN ANALYZE select a.manufactur from p a where kat ~
'root.tillbeh___ouml____r.h___ouml____gtalare.*'group by manufactur order by lower(manufactur);") at postgres.c:873 
#9  0x816501f in PostgresMain (argc=4, argv=0x8335488, username=0x8335458 "rsctest") at postgres.c:2868
#10 0x8144a0d in BackendFork (port=0x8332600) at postmaster.c:2558
#11 0x814422b in BackendStartup (port=0x8332600) at postmaster.c:2201
#12 0x8142b13 in ServerLoop () at postmaster.c:1113
#13 0x8142597 in PostmasterMain (argc=1, argv=0x8322040) at postmaster.c:891
#14 0x8118fd3 in main (argc=1, argv=0xbfbffc94) at main.c:214

Regards
Pawel

pgsql-bugs by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: pg_dump of table including check rule fails to restore
Next
From: Tom Lane
Date:
Subject: Re: BUG #1010: format_type errors oin formatting type interval.