pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
BUG #11304: UNION query with NULL values fails 4+ messages / 4 participants [nested] [flat]
* BUG #11304: UNION query with NULL values fails @ 2014-08-28 21:37 m.woehling@barthauer.de 0 siblings, 1 reply; 4+ messages in thread From: m.woehling@barthauer.de @ 2014-08-28 21:37 UTC (permalink / raw) To: pgsql-bugs The following bug has been logged on the website: Bug reference: 11304 Logged by: Markus Woehling Email address: m.woehling@barthauer.de PostgreSQL version: 9.3.5 Operating system: Windows Server 2008 Description: I want to "warm up" the bug reports "BUG #1453" [http://permalink.gmane.org/gmane.comp.db.postgresql.bugs/7383] and "BUG #5974" [http://www.postgresql.org/message-id/201104122018.p3CKIlWR042915@wwwmaster.postgresql.org]. I need to build UNION queries with NULL values dynamically like in this sample: select null union all select null union all select 1; This could be workaround: select null union all (select null union all select 1); But this workaround fails in this case: select 1 union all (select null union all select null); Because I don't know the "real" data type of the NULL values, I can't specify the type like in this sample: select 1 union all (select null::int union all select null::int); I know that MSSQL, Oracle, MySQL, DB2 and Firebird don't have this problem. So I'd really like to see this working in PostgreSQL as well. Currently this problem hinders me from using PostgreSQL as DBMS in our products. Markus -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #11304: UNION query with NULL values fails @ 2014-08-29 14:35 Mike Porter <mike@udel.edu> parent: m.woehling@barthauer.de 0 siblings, 1 reply; 4+ messages in thread From: Mike Porter @ 2014-08-29 14:35 UTC (permalink / raw) To: m.woehling@barthauer.de; +Cc: pgsql-bugs On Thu, 28 Aug 2014, m.woehling@barthauer.de wrote: > The following bug has been logged on the website: > > Bug reference: 11304 > Logged by: Markus Woehling > Email address: m.woehling@barthauer.de > PostgreSQL version: 9.3.5 > Operating system: Windows Server 2008 > Description: > select c1 :: integer from (select null as c1 union all select null as c1 union all select 1 :: text as c1) x; c1 ---- 1 (3 rows) select c1 :: integer +1 from (select null as c1 union all select null as c1 union all select 1 :: text as c1) x; ?column? ---------- 2 (3 rows) (I hate NULL. Just felt like I needed to say that.) The above example was run on a 9.2.3 server. > I want to "warm up" the bug reports "BUG #1453" > [http://permalink.gmane.org/gmane.comp.db.postgresql.bugs/7383] and "BUG > #5974" > [http://www.postgresql.org/message-id/201104122018.p3CKIlWR042915@wwwmaster.postgresql.org]. > > I need to build UNION queries with NULL values dynamically like in this > sample: > select null union all select null union all select 1; > > This could be workaround: > select null union all (select null union all select 1); > > But this workaround fails in this case: > select 1 union all (select null union all select null); > > Because I don't know the "real" data type of the NULL values, I can't > specify the type like in this sample: > select 1 union all (select null::int union all select null::int); > > I know that MSSQL, Oracle, MySQL, DB2 and Firebird don't have this problem. > So I'd really like to see this working in PostgreSQL as well. > Currently this problem hinders me from using PostgreSQL as DBMS in our > products. > > Markus > > > -- > Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-bugs > - Mike Porter PGP Fingerprint: F4 AE E1 9F 67 F7 DA EA 2F D2 37 F3 99 ED D1 C2 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #11304: UNION query with NULL values fails @ 2014-08-29 15:16 David G Johnston <david.g.johnston@gmail.com> parent: Mike Porter <mike@udel.edu> 0 siblings, 1 reply; 4+ messages in thread From: David G Johnston @ 2014-08-29 15:16 UTC (permalink / raw) To: pgsql-bugs Mike Porter wrote > On Thu, 28 Aug 2014, > m.woehling@ > wrote: > >> The following bug has been logged on the website: >> >> Bug reference: 11304 >> Logged by: Markus Woehling >> Email address: > m.woehling@ >> PostgreSQL version: 9.3.5 >> Operating system: Windows Server 2008 >> Description: >> > > select c1 :: integer from (select null as c1 union all select null as c1 > union all select 1 :: text as c1) x; > c1 > ---- > > > 1 > (3 rows) > > select c1 :: integer +1 from (select null as c1 union all select null as > c1 union all select 1 :: text as c1) x; > ?column? > ---------- > > > 2 > (3 rows) > > > (I hate NULL. Just felt like I needed to say that.) > > The above example was run on a 9.2.3 server. Do you have a conclusion/observation to make? NULL + NOT-NULL => NULL Furthermore, since null is valid input for any type, explicit casting between types, if such a cast exists, will always succeed and will always result in null. I agree there is potential for compatibility improvement here but I don't see where your observation fits in. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-11304-UNION-query-with-NULL-values-fails-tp5816830p58169... Sent from the PostgreSQL - bugs mailing list archive at Nabble.com. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #11304: UNION query with NULL values fails @ 2014-09-01 09:38 Wöhling, Markus <M.Woehling@Barthauer.de> parent: David G Johnston <david.g.johnston@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Wöhling, Markus @ 2014-09-01 09:38 UTC (permalink / raw) To: pgsql-bugs I want to clarify what's my problem with the "untyped" NULL values. I have to build SQL queries dynamically. Basically it's something like merging different queries (or query parts) into a bigger query. I don't know the data types of the "source" columns und I have to add NULL columns to the resulting query. This combination is causing the trouble, and for me there's no way to work around this issue in another way. Hope that helps. Markus -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2014-09-01 09:38 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2014-08-28 21:37 BUG #11304: UNION query with NULL values fails m.woehling@barthauer.de 2014-08-29 14:35 ` Mike Porter <mike@udel.edu> 2014-08-29 15:16 ` David G Johnston <david.g.johnston@gmail.com> 2014-09-01 09:38 ` Wöhling, Markus <M.Woehling@Barthauer.de>
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