jOOQ / jOOQ

jOOQ is the best way to write SQL in Java
https://www.jooq.org
Other
6.16k stars 1.21k forks source link

Add support for native BOOLEAN types in Db2 #10063

Open lukaseder opened 4 years ago

lukaseder commented 4 years ago

It appears that Db2 has introduced support for standard SQL BOOLEAN types: https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r0055394.html

With all the goodies: https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r_predicate_boolean.html

We'll support that as well from jOOQ 3.14 onwards. This change affects:


This is a backwards incompatible change with the following effects:

lukaseder commented 4 years ago

It seems to have been added in 9.7: https://www.ibm.com/support/knowledgecenter/en/SSEPGG_9.7.0/com.ibm.db2.luw.sql.ref.doc/doc/r0055394.html

We started integration testing Db2 a long time ago, before 9.7, where this was not available yet. Just didn't notice the improvement.

lukaseder commented 4 years ago

Db2 does not correctly implement 3VL:

SELECT a, b, a OR b AS v
FROM 
  (VALUES(NULL),(TRUE),(FALSE)) t(a),
  (VALUES(NULL),(TRUE),(FALSE)) u(b);

To yield:

A|B|V|
-|-|-|
 | | |
1| |1|
0| | |
 |1|1|
1|1|1|
0|1|1|
 |0|0|
1|0|1|
0|0|0|

As can be seen, there's a bug in how the OR predicate is evaluated. This can be seen here:

SELECT NULL OR FALSE, FALSE OR NULL FROM SYSIBM.dual; 

Yielding:

1|2|
-|-|
0| |

Supporting the BOOLEAN type means that we might produce very subtle regressions in this area. Not sure if we should...

lukaseder commented 4 years ago

These bugs completely break the [ NOT ] LIKE ANY predicate, making it unusable. There might be other, more subtle regressions currently not covered by the integration tests. We cannot risk this.