Thread: Domain Implicit Casting Trouble

Domain Implicit Casting Trouble

From
"Dave Hartwig"
Date:
I came across the following problem when migrating from 7.3.4 to 7.4b4.
Query #4 does not fail under version 7.3.4.  But it does under version
7.4b4.   It seems that in some situations the implicit cast fails.  It
would not be a problem if I had the opportunity to manually cast these
queries.  But I don't.  I am using a client package (Hibernate) which
generates statements automatically based on an O/R mapping.=20=20

CREATE DOMAIN foo_varchardomain AS varchar(10);

CREATE DOMAIN foo_intdomain AS int4;

CREATE TABLE foo_table (i foo_intdomain, c foo_varchardomain);

INSERT INTO foo_table VALUES (1, 'x');

SELECT * FROM foo_table WHERE i =3D '1'::text;

SELECT * FROM foo_table WHERE i::int4 =3D '1'; -- query #1 ok

SELECT * FROM foo_table WHERE i =3D 1;         -- query #2 ok

SELECT * FROM foo_table WHERE c =3D 'x';       -- query #3 ok

SELECT * FROM foo_table WHERE i =3D '1';       -- query #4 ERROR
ERROR:  operator is not unique: foo_intdomain =3D "unknown"
HINT:  Could not choose a best candidate operator. You may need to add
explicit type casts.

TIA
David

Re: Domain Implicit Casting Trouble

From
Tom Lane
Date:
"Dave Hartwig" <daveh@Routescape.com> writes:
> I came across the following problem when migrating from 7.3.4 to 7.4b4.
> Query #4 does not fail under version 7.3.4.  But it does under version
> 7.4b4.   It seems that in some situations the implicit cast fails.

Fixed in CVS tip.  Thanks for the report.

            regards, tom lane