Queries with multiple USINGs crash backend - Mailing list pgsql-bugs

From Chris Pascoe
Subject Queries with multiple USINGs crash backend
Date
Msg-id Pine.LNX.4.21.0006272321340.14802-100000@celab21.pc.elec.uq.edu.au
Whole thread Raw
Responses Re: Queries with multiple USINGs crash backend  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Hello,

The following SQL demonstrates a crash in the backend.  It occurs in both
the current Debian Linux 7.0.2 package, and in a separately compiled
version of the same.

--8<--

CREATE TABLE A
(
    A    INT4,
    B    INT4,
    C    INT4
);

CREATE TABLE B
(
    A    INT4,
    B    INT4,
    C    INT4
);

CREATE TABLE C
(
    A    INT4,
    B    INT4,
    C    INT4
);

/* The inserts are optional, but demonstrate that the first two queries
 * produce correct results. */
INSERT INTO A VALUES (1,2,3);
INSERT INTO A VALUES (1,2,5);
INSERT INTO B VALUES (1,2,3);
INSERT INTO B VALUES (1,2,5);
INSERT INTO B VALUES (1,2,6);
INSERT INTO C VALUES (1,2,4);

/* This runs OK */
SELECT * FROM A,B,C WHERE A.A = B.A AND A.B = B.B AND A.C = B.C
    AND B.A = C.A AND B.B = C.B;

/* As does this */
SELECT * FROM A JOIN B ON (A.A = B.A AND A.B = B.B AND A.C = B.C)
    JOIN C ON (B.A = C.A AND B.B = C.B);

/*
 * This makes the backend close the channel unexpectedly (die),
 * but should be equivalent to the example using ON.
 */
SELECT * FROM A JOIN B USING (A,B,C) JOIN C USING (A,B);

--8<--

Regards,
Chris

pgsql-bugs by date:

Previous
From: Stephen van Egmond
Date:
Subject: Bug report: selects rope in tables they shouldn't
Next
From: Darcy Buskermolen
Date:
Subject: joins on the same table with aggregates