"internal error" triggered by EXISTS() - Mailing list pgsql-hackers

From Tom Lane
Subject "internal error" triggered by EXISTS()
Date
Msg-id 17025.900451896@sss.pgh.pa.us
Whole thread Raw
Responses Re: [HACKERS] "internal error" triggered by EXISTS()
Re: [HACKERS] "internal error" triggered by EXISTS()
List pgsql-hackers
I tried the following to find out whether a table has any records
with field1 < X (for a constant X):

tgl=> SELECT EXISTS(SELECT * FROM table WHERE field1 < X);
ERROR:  internal error: do not know how to transform targetlist

Is this a bug?  (I'm using development sources from yesterday.)

Am I using EXISTS() incorrectly?  The examples I've been able to find
only show it as a part of a WHERE clause.

If it did work, would it be any faster than a table scan?  The code
I was hoping to replace is like this:
    SELECT COUNT(field1) WHERE field1 < X;
    // test whether result > 0
Since aggregates aren't optimized very well, this ends up reading
much or all of the table, even if there is an index for field1.
I was hoping EXISTS() might be smarter...

            regards, tom lane

pgsql-hackers by date:

Previous
From: Mike Embry
Date:
Subject: SEQUENCES and COPY FROM
Next
From: dg@illustra.com (David Gould)
Date:
Subject: Re: [HACKERS] "internal error" triggered by EXISTS()