GitHub user leskin-in opened a pull request: https://github.com/apache/incubator-hawq/pull/1369
HAWQ-1617. Incorrect processing of boolean operators in pushdown When accessing external tables, the pushdown feature sometimes works incorrect. Consider the following query: ``` SELECT * FROM table_ex WHERE bool1=false AND id1=60003; ``` When this query is executed, an error "stack is not empty ..." happens. Turns out that such query is transformed into a list of three items that represents the constraints: `BoolExpr`, `Var` and `OpExpr` (this is equal to a query `WHERE NOT(bool1 = true) AND (id1 = 60003)`). Note that the list does not contain (implicit) AND operators. Then, the list is processed by a [piece of code in pxffilters.c](https://github.com/apache/incubator-hawq/blob/master/src/backend/access/external/pxffilters.c#L1259), where there is a check of presence of `BoolExpr`. If expression items of this kind are detected, no implicit AND operators are added. In the case described, one 'BoolExpr' element is present, and no implicit AND operators are added. This leads to the error mentioned above. This commit changes the signatures of `enrich_trivial_expression()` and `pxf_free_expression_items_list()` from [pxffilters.c](https://github.com/apache/incubator-hawq/blob/master/src/backend/access/external/pxffilters.c) in order to fix the bug: * A number of impicit AND operators to be added is now passed to `add_extra_and_expression_items()` * `add_extra_and_expression_items()` now requires the pointer to pointer to `Node` object to store the pointer to an expression item for the implicit AND that it creates (before, it was stored in the expression item itself; however, due to the presence of other logical operators, we cannot rely on this mechanism) * `pxf_free_expression_items_list()` simplifies, due to the changes in the way how the pointer to `Node` object is stored The current mechanism of implicit AND expressions addition works well only while the OR operators are not supported (or not present in a query). When the OR operators appear, the implicit ANDs must be added in different parts of a query, not only to the end, as done now. You can merge this pull request into a Git repository by running: $ git pull https://github.com/arenadata/incubator-hawq HAWQ-1617 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-hawq/pull/1369.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1369 ---- ---- ---