Thread: A maybe-bug?
Hi all! I tried this: tmp1=# CREATE DOMAIN real as numeric; CREATE DOMAIN tmp1=# CREATE TABLE t1 ( r real ); CREATE TABLE tmp1=# CREATE TABLE t2 ( r "real" ); CREATE TABLE tmp1=# INSERT INTO t1 VALUES ( 0.000000000000000000000000000001 ); INSERT 0 1 tmp1=# INSERT INTO t1 VALUES ( 0.00000000000000000000000000000000000000000000001 ); ERROR: value out of range: underflow tmp1=# INSERT INTO t2 VALUES ( 0.000000000000000000000000000001 ); INSERT 0 1 tmp1=# INSERT INTO t2 VALUES ( 0.00000000000000000000000000000000000000000000001 ); INSERT 0 1 tmp1=# It looks like to me this is a bug and also the documentation seems to confirm: "The domain name must be unique among the types and domains existing in its schema." Any idea? -- Vincenzo Romano NotOrAnd Information Technologies NON QVIETIS MARIBVS NAVTA PERITVS
Vincenzo Romano <vincenzo.romano@notorand.it> writes: > I tried this: > tmp1=# CREATE DOMAIN real as numeric; > [ and got confused between this domain and the built-in "real" ] > It looks like to me this is a bug and also the documentation seems to confirm: > "The domain name must be unique among the types and domains existing > in its schema." No bug. The REAL keyword is treated as an alias for pg_catalog.float4, but even if it weren't an alias, it would exist in schema pg_catalog. Thus there is not a name conflict with your domain, which (I suppose) was created in the "public" schema. regards, tom lane
Tom Lane wrote: > Vincenzo Romano <vincenzo.romano@notorand.it> writes: > >> I tried this: >> tmp1=# CREATE DOMAIN real as numeric; >> [ and got confused between this domain and the built-in "real" ] >> > > >> It looks like to me this is a bug and also the documentation seems to confirm: >> "The domain name must be unique among the types and domains existing >> in its schema." >> > > No bug. The REAL keyword is treated as an alias for pg_catalog.float4, > but even if it weren't an alias, it would exist in schema pg_catalog. > Thus there is not a name conflict with your domain, which (I suppose) > was created in the "public" schema. > > regards, tom lane > > Really, I can't see how quoting an identifier should change the behaviour or resolved type. In the non-quoted version it uses the pg_catalog.float4 and in the quoted version it uses the domain. This doesn't seem right at all. I would have expected it would reject both t1 and t2 inserts on the basic real and "real" both map to pg_catalog.float4. The documentation indicates that pg_catalog is always searched first. If it is, the domain from public should always use the pg_catalog version. Russell
Russell Smith <mr-russ@pws.com.au> writes: > Really, I can't see how quoting an identifier should change the > behaviour or resolved type. REAL is not an identifier. It's a keyword. In fact, it's a reserved word according to SQL99. So if we were going to do anything about this, it would be to reject the OP's CREATE DOMAIN command as invalid syntax. regards, tom lane