Debian Codegraph @

src/test/modules/test_predtest/README

raw
1 test_predtest is a module for checking the correctness of the optimizer's
2 predicate-proof logic, in src/backend/optimizer/util/predtest.c.
3
4 The module provides a function that allows direct application of
5 predtest.c's exposed functions, predicate_implied_by() and
6 predicate_refuted_by(), to arbitrary boolean expressions, with direct
7 inspection of the results. This could be done indirectly by checking
8 planner results, but it can be difficult to construct end-to-end test
9 cases that prove that the expected results were obtained.
10
11 In general, the use of this function is like
12 select * from test_predtest('query string')
13 where the query string must be a SELECT returning two boolean
14 columns, for example
15
16 select * from test_predtest($$
17 select x, not x
18 from (values (false), (true), (null)) as v(x)
19 $$);
20
21 The function parses and plans the given query, and then applies the
22 predtest.c code to the two boolean expressions in the SELECT list, to see
23 if the first expression can be proven or refuted by the second. It also
24 executes the query, and checks the resulting rows to see whether any
25 claimed implication or refutation relationship actually holds. If the
26 query is designed to exercise the expressions on a full set of possible
27 input values, as in the example above, then this provides a mechanical
28 cross-check as to whether the proof code has given a correct answer.