weird cast behavior in "IN (values)" clause - Mailing list pgsql-hackers

From Alvaro Herrera
Subject weird cast behavior in "IN (values)" clause
Date
Msg-id 1309918036-sup-4092@alvh.no-ip.org
Whole thread Raw
Responses Re: weird cast behavior in "IN (values)" clause
List pgsql-hackers
I just came across this:

alvherre=# select * from pg_class where oid::regclass in ('foo');
ERROR:  invalid input syntax for type oid: "foo"
LÍNEA 1: select * from pg_class where oid::regclass in ('foo');
^
alvherre=# select * from pg_class where oid::regclass in ('foo', 'foo');relname | relnamespace | reltype | reloftype |
relowner| relam | relfilenode | reltablespace | relpages | reltuples | reltoastrelid | reltoastidxid | relhasindex |
relisshared| relpersistence | relkind | relnatts | relchecks | relhasoids | relhaspkey | relhasrules | relhastriggers |
relhassubclass| relfrozenxid | relacl | reloptions 
 

---------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-------------+----------------+---------+----------+-----------+------------+------------+-------------+----------------+----------------+--------------+--------+------------foo
   |         2200 |   16448 |         0 |       10 |     0 |       16446 |             0 |        0 |         0 |
     0 |             0 | t           | f           | p              | r       |        1 |         0 | f          | t
      | f           | f              | f              |          720 |        | 
 
(1 fila)


Not sure what to make of it.

(The reason I put the regclass cast in the oid instead of the other way
around is that I was trying a bunch of other tables, so it was 
oid::regclass IN ('foo', 'bar', 'baz')
which is a lot easier to type than attaching a regclass cast to each
literal).

I am not sure why it would be valid to list two literals in the values
but not one.

-- 
Álvaro Herrera <alvherre@alvh.no-ip.org>


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Potential NULL dereference found in typecmds.c
Next
From: Tom Lane
Date:
Subject: Re: weird cast behavior in "IN (values)" clause