IITDBGroup / gprom

GProM is a middleware that adds support for provenance to database backends.
http://www.cs.iit.edu/%7edbgroup/research/gprom.php
Apache License 2.0
8 stars 5 forks source link

Lack of parentheses in serialization of set operations #64

Open lordpretzel opened 3 years ago

lordpretzel commented 3 years ago

GProM is not adding parentheses were needed to encode the evaluation order of set operations

For example (R - S) u (T - U) is serialized as

SELECT * FROM R EXCEPT SELECT * FROM S UNION ALL SELECT * FROM T EXCEPT SELECT * FROM U

which is the same as

((((SELECT * FROM R) EXCEPT SELECT * FROM S) UNION ALL SELECT * FROM T) EXCEPT SELECT * FROM U)

but the correct translation is:

((SELECT * FROM R EXCEPT SELECT * FROM S) UNION ALL (SELECT * FROM T EXCEPT SELECT * FROM U))
lordpretzel commented 3 years ago

Commit ceec54bbb0e438e4fb0ad95f726294785252e6a1 resolved this bug for postgres. Check for other backends (SQLite chokes on parenthesis for set operations, will need a workaround there potentially.