DB2 BOOLEAN type, EXISTS predicate and nullability strange behavior I'm using DB2 LUW v11.1.4.5,
It seems that EXISTS predicate, when FALSE returns NULL (is it documented ?)
In the following query on X is null is true, all the rest acts like FALSE is a synonym for NULL, but the metadata say all the columns are not nullable
(see dbfiddle)
with boolstmt as
(
  select  'exists' stmt,
    exists(select 1 from sysibm.sysdummy1 where ibmreqd = 'N') as x
  from sysibm.sysdummy1
 )
select
 stmt,
 x,
 x is null &quot;x is null&quot;,
 not x &quot;NOT x&quot;,
 x = FALSE &quot;x = FALSE&quot;,
 smallint(x) &quot;smallint(x)&quot;,
 char(x) &quot;char(x)&quot;
from boolstmt

now with the following query every column is nullable, it shows that x really is NULL with EXISTS
with boolstmt as
(
  select  'exists' stmt,
    exists(select 1 from sysibm.sysdummy1 where ibmreqd = 'N') as x
  from sysibm.sysdummy1
  union all
  select  'count' stmt,
    (select count(*) from sysibm.sysdummy1 where ibmreqd = 'N') &gt; 0 as x
  from sysibm.sysdummy1
 )
select
 stmt,
 x,
 x is null &quot;x is null&quot;,
 not x &quot;NOT x&quot;,
 x = FALSE &quot;x = FALSE&quot;,
 smallint(x) &quot;smallint(x)&quot;,
 char(x) &quot;char(x)&quot;
from boolstmt

My question is : did someone know about it, it seems to me that's a problem on the server but do you know if it may come from the JDBC driver (using 4.27.25) ? Is the problem still there using later versions ?
An interesting question with the answer that is not so interesting: in this trivial example your EXISTS is optimized away, so an attempt to reference this predicate evaluation result is undefined. If you run db2exfmt (or another tool that can retrieve the &quot;optimized&quot; version of the statement), you will see that this is what gets executed in the end:
SELECT 'exists' AS &quot;STMT&quot;,
   $INTERNAL_FUNC$() AS &quot;X&quot;,
   $INTERNAL_FUNC$() AS &quot;x is null&quot;,
   $INTERNAL_FUNC$() AS &quot;NOT x&quot;,
   $INTERNAL_FUNC$() AS &quot;x = FALSE&quot;,
   SMALLINT($INTERNAL_FUNC$()) AS &quot;smallint(x)&quot;,
   CHAR($INTERNAL_FUNC$()) AS &quot;char(x)&quot;,
   $INTERNAL_FUNC$() AS &quot;Y&quot;,
   $INTERNAL_FUNC$() AS &quot;y is null&quot;,
   $INTERNAL_FUNC$() AS &quot;NOT y&quot;,
   $INTERNAL_FUNC$() AS &quot;y = FALSE&quot;,
   SMALLINT($INTERNAL_FUNC$()) AS &quot;smallint(y)&quot;,
   CHAR($INTERNAL_FUNC$()) AS &quot;char(y)&quot; 
FROM (SELECT NULL 
FROM (VALUES ) AS Q1 
WHERE ('Y' = 'N')) AS Q2

This is likely Working As Designed™, because predicates, of which EXISTS is one, are not meant to be used in place of expressions. Db2 tries to do its best to turn predicate evaluation outcomes into values, but the optimizer has an upper hand.
Things work as you expect when you use expressions and predicates where they respectively belong:
with boolstmt as
(
  select  'exists' stmt,
    case when exists(select 1 from sysibm.sysdummy1 where ibmreqd = 'N') then true else false end as x
  from sysibm.sysdummy1
 )