MCPcopy Create free account
hub / github.com/apache/cloudberry / test_predtest

Function test_predtest

src/test/modules/test_predtest/test_predtest.c:32–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30PG_FUNCTION_INFO_V1(test_predtest);
31
32Datum
33test_predtest(PG_FUNCTION_ARGS)
34{
35 text *txt = PG_GETARG_TEXT_PP(0);
36 char *query_string = text_to_cstring(txt);
37 SPIPlanPtr spiplan;
38 int spirc;
39 TupleDesc tupdesc;
40 bool s_i_holds,
41 w_i_holds,
42 s_r_holds,
43 w_r_holds;
44 CachedPlan *cplan;
45 PlannedStmt *stmt;
46 Plan *plan;
47 Expr *clause1;
48 Expr *clause2;
49 bool strong_implied_by,
50 weak_implied_by,
51 strong_refuted_by,
52 weak_refuted_by;
53 Datum values[8];
54 bool nulls[8];
55 int i;
56
57 /* We use SPI to parse, plan, and execute the test query */
58 if (SPI_connect() != SPI_OK_CONNECT)
59 elog(ERROR, "SPI_connect failed");
60
61 /*
62 * First, plan and execute the query, and inspect the results. To the
63 * extent that the query fully exercises the two expressions, this
64 * provides an experimental indication of whether implication or
65 * refutation holds.
66 */
67 spiplan = SPI_prepare(query_string, 0, NULL);
68 if (spiplan == NULL)
69 elog(ERROR, "SPI_prepare failed for \"%s\"", query_string);
70
71 spirc = SPI_execute_plan(spiplan, NULL, NULL, true, 0);
72 if (spirc != SPI_OK_SELECT)
73 elog(ERROR, "failed to execute \"%s\"", query_string);
74 tupdesc = SPI_tuptable->tupdesc;
75 if (tupdesc->natts != 2 ||
76 TupleDescAttr(tupdesc, 0)->atttypid != BOOLOID ||
77 TupleDescAttr(tupdesc, 1)->atttypid != BOOLOID)
78 elog(ERROR, "query must yield two boolean columns");
79
80 s_i_holds = w_i_holds = s_r_holds = w_r_holds = true;
81 for (i = 0; i < SPI_processed; i++)
82 {
83 HeapTuple tup = SPI_tuptable->vals[i];
84 Datum dat;
85 bool isnull;
86 char c1,
87 c2;
88
89 /* Extract column values in a 3-way representation */

Callers

nothing calls this directly

Calls 15

text_to_cstringFunction · 0.85
SPI_connectFunction · 0.85
SPI_prepareFunction · 0.85
SPI_execute_planFunction · 0.85
SPI_getbinvalFunction · 0.85
DatumGetBoolFunction · 0.85
SPI_plan_get_cached_planFunction · 0.85
list_lengthFunction · 0.85
make_ands_implicitFunction · 0.85
predicate_implied_byFunction · 0.85
predicate_refuted_byFunction · 0.85
SPI_finishFunction · 0.85

Tested by

no test coverage detected