pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feeddata type of projected item in a union not correct
4+ messages / 3 participants
[nested] [flat]
* data type of projected item in a union not correct
@ 2012-09-24 23:43 the6campbells <the6campbells@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: the6campbells @ 2012-09-24 23:43 UTC (permalink / raw)
To: pgsql-jdbc
Database 9.0.4
Driver PostgreSQL 9.1 JDBC4 (build 902)
The following projection is not described with the expected type+precision
as one would expect from ISO-SQL
Is this a known Postgres bug, quirk or ....
t1.c1 char(32)
t2.c1 varchar(32)
select t1.c1 returns precision of 32
select t2.c1 returned precision of 32
t1.c1
union
t2.c1
t2.c1
union
t1.c1
returns precision 2147483647
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: data type of projected item in a union not correct
@ 2012-09-25 00:29 David Johnston <polobo@yahoo.com>
parent: the6campbells <the6campbells@gmail.com>
1 sibling, 1 reply; 4+ messages in thread
From: David Johnston @ 2012-09-25 00:29 UTC (permalink / raw)
To: the6campbells <the6campbells@gmail.com>; +Cc: pgsql-jdbc
On Sep 24, 2012, at 19:43, the6campbells <the6campbells@gmail.com> wrote:
> Database 9.0.4
> Driver PostgreSQL 9.1 JDBC4 (build 902)
>
>
> The following projection is not described with the expected type+precision as one would expect from ISO-SQL
>
> Is this a known Postgres bug, quirk or ....
>
> t1.c1 char(32)
> t2.c1 varchar(32)
>
> select t1.c1 returns precision of 32
> select t2.c1 returned precision of 32
>
>
> t1.c1
> union
> t2.c1
>
> t2.c1
> union
> t1.c1
>
> returns precision 2147483647
>
>
From the description here
http://www.postgresql.org/docs/9.2/interactive/typeconv-union-case.html
I infer that since the two types are not the same they are both converted to the preferred base type "text" which while it should have an undefined precision instead is reported to have an arbitrary large precision.
What result do you feel it should report and for what reason?
David J.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: data type of projected item in a union not correct
@ 2012-09-25 01:26 the6campbells <the6campbells@gmail.com>
parent: David Johnston <polobo@yahoo.com>
0 siblings, 0 replies; 4+ messages in thread
From: the6campbells @ 2012-09-25 01:26 UTC (permalink / raw)
To: David Johnston <polobo@yahoo.com>; +Cc: pgsql-jdbc
per the ISO-SQL 20xx specification and many vendors vrchar(32)
On Mon, Sep 24, 2012 at 8:29 PM, David Johnston <polobo@yahoo.com> wrote:
> On Sep 24, 2012, at 19:43, the6campbells <the6campbells@gmail.com> wrote:
>
> > Database 9.0.4
> > Driver PostgreSQL 9.1 JDBC4 (build 902)
> >
> >
> > The following projection is not described with the expected
> type+precision as one would expect from ISO-SQL
> >
> > Is this a known Postgres bug, quirk or ....
> >
> > t1.c1 char(32)
> > t2.c1 varchar(32)
> >
> > select t1.c1 returns precision of 32
> > select t2.c1 returned precision of 32
> >
> >
> > t1.c1
> > union
> > t2.c1
> >
> > t2.c1
> > union
> > t1.c1
> >
> > returns precision 2147483647
> >
> >
>
> From the description here
>
> http://www.postgresql.org/docs/9.2/interactive/typeconv-union-case.html
>
> I infer that since the two types are not the same they are both converted
> to the preferred base type "text" which while it should have an undefined
> precision instead is reported to have an arbitrary large precision.
>
> What result do you feel it should report and for what reason?
>
> David J.
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: data type of projected item in a union not correct
@ 2012-09-25 03:31 Kris Jurka <books@ejurka.com>
parent: the6campbells <the6campbells@gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Kris Jurka @ 2012-09-25 03:31 UTC (permalink / raw)
To: the6campbells <the6campbells@gmail.com>; +Cc: pgsql-jdbc
On Mon, 24 Sep 2012, the6campbells wrote:
> The following projection is not described with the expected type+precision
> as one would expect from ISO-SQL
>
> Is this a known Postgres bug, quirk or ....
This is a serverside problem. Try the same test in psql or similar.
jurka=# create table t as select 'a'::varchar(32) as c1,
'b'::varchar(32) as c2 union select 'c'::char(32),
'd'::varchar(32);
SELECT 2
jurka=# \d t
Table "public.t"
Column | Type | Modifiers
--------+-----------------------+-----------
c1 | character varying |
c2 | character varying(32) |
As you can see the c1 column has had the length information dropped.
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2012-09-25 03:31 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-09-24 23:43 data type of projected item in a union not correct the6campbells <the6campbells@gmail.com>
2012-09-25 00:29 ` David Johnston <polobo@yahoo.com>
2012-09-25 01:26 ` the6campbells <the6campbells@gmail.com>
2012-09-25 03:31 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox