Re: [HACKERS] "op must return bool to be used with subquery"?

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] "op must return bool to be used with subquery"?
Date: 1999-05-10 05:05:48
Message-ID: 199905100505.BAA24024@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Given
> create table t1 (name text, value float8);
>
> this fails:
> SELECT name, value FROM t1 as touter WHERE
> (value/(SELECT AVG(value) FROM t1 WHERE name = touter.name)) > 0.75;
> ERROR: parser: '/' must return 'bool' to be used with subquery

Aren't you really saying WHERE col / (subselect). That doesn't return
bool, so the message seems correct.

We don't allow subselects in target lists, or inside expressions.

>
> The code in parse_expr.c that produces this message claims to be
> enforcing that "sub-selects can only be used in WHERE clauses".
> Either the comment is inaccurate or the test is too restrictive.
> If the test is correct then I think the error message is unhelpful.
> Anybody understand this code well enough to know what's really going on?
>
> regards, tom lane
>
>

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Mount 1999-05-10 07:15:45 RE: [HACKERS] Re: SIGBUS in AllocSetAlloc & jdbc
Previous Message Bruce Momjian 1999-05-10 05:03:22 Re: [HACKERS] Parser bug: alias is a "non-group column"?