Bug or misunderstanding w/domains in 7.3devel?

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: "Pgsql-Hackers(at)Postgresql(dot) Org" <pgsql-hackers(at)postgresql(dot)org>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Bug or misunderstanding w/domains in 7.3devel?
Date: 2002-04-18 13:18:59
Message-ID: AHEDLOKJMIPAGOHCCBCDKEMMCAAA.joel@joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Using latest CVS sources with Linux 2.4 i586:

Comparing using domains versus traditional explicit field types.
Here's the control test:

test=# create table t1 (f varchar(5) not null);
CREATE
test=# insert into t1 values ('2');
INSERT 16626 1
test=# select * from t1 where f='2';
f
---
2
(1 row)

If I create a VARCHAR domain, everything works as expected.

test=# create domain typ varchar(5) not null;
CREATE DOMAIN
test=# create table t2 (f typ);
CREATE
test=# insert into t2 values ('2');
INSERT 16627 1
test=# select * from t2 where f='2';
f
---
2
(1 row)

Here's a control test for the same thing, except with CHAR:

test=# create table t1 (f char(5) not null);
CREATE
test=# insert into t1 values ('2');
INSERT 16639 1
test=# select * from t1 where f='2';
f
-------
2
(1 row)

However, if I create a CHAR domain, I'm unable to query the value from the
table:

test=# create domain typ char(5) not null;
CREATE DOMAIN
test=# create table t2 (f typ);
CREATE
test=# insert into t2 values ('2');
INSERT 16640 1
test=# select * from t2 where f='2';
f
---
(0 rows)

Even if I coerce the value to the correct domain:

test=# select * from t2 where f='2'::typ;
f
---
(0 rows)

However, this works:

test=# select * from t2 where f='2'::char;
f
-------
2
(1 row)

Is this a bug? Is this correct behavior? Am I misunderstanding this?

Thanks!

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2002-04-18 13:54:25 Bug #635: PostgreSQL ODBC Driver BUG
Previous Message Peter Koll 2002-04-18 12:23:01 libpgtcl

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-04-18 13:30:13 Re: unknownin/out patch (was [HACKERS] PQescapeBytea is not
Previous Message Alexandre Dulaunoy 2002-04-18 12:36:49 Re: new food for the contrib/ directory