Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-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


pgsql-hackers by date

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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group