Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd8062ea

Browse files
committed
Tighten test_predtest's input checks, and improve error messages.
test_predtest() neglected to consider the possibility thatSPI_plan_get_cached_plan would return NULL. This led to a coredump if the input (incorrectly) contains more than one SQLcommand.While here, let's expend more than zero effort on the errormessage for this case and nearby ones.Per (half of) bug #18483 from Alexander Kozhemyakin.Back-patch to all supported branches, not because this isvery significant (it's merely test scaffolding) but to makeour world a bit safer for fuzz testing.Discussion:https://postgr.es/m/18483-30bfff42de238000@postgresql.org
1 parent7c4ac65 commitd8062ea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/test/modules/test_predtest/test_predtest.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ test_predtest(PG_FUNCTION_ARGS)
7474
if (tupdesc->natts!=2||
7575
TupleDescAttr(tupdesc,0)->atttypid!=BOOLOID||
7676
TupleDescAttr(tupdesc,1)->atttypid!=BOOLOID)
77-
elog(ERROR,"query must yield two boolean columns");
77+
elog(ERROR,"test_predtestquery must yield two boolean columns");
7878

7979
s_i_holds=w_i_holds=s_r_holds=w_r_holds= true;
8080
for (i=0;i<SPI_processed;i++)
@@ -124,11 +124,11 @@ test_predtest(PG_FUNCTION_ARGS)
124124
*/
125125
cplan=SPI_plan_get_cached_plan(spiplan);
126126

127-
if (list_length(cplan->stmt_list)!=1)
128-
elog(ERROR,"failed to decipher query plan");
127+
if (cplan==NULL||list_length(cplan->stmt_list)!=1)
128+
elog(ERROR,"test_predtest query string must contain exactly one query");
129129
stmt=linitial_node(PlannedStmt,cplan->stmt_list);
130130
if (stmt->commandType!=CMD_SELECT)
131-
elog(ERROR,"failed to decipher query plan");
131+
elog(ERROR,"test_predtest query must be a SELECT");
132132
plan=stmt->planTree;
133133
Assert(list_length(plan->targetlist) >=2);
134134
clause1=castNode(TargetEntry,linitial(plan->targetlist))->expr;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp