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

Commit662d12a

Browse files
committed
Avoid crash in eval_const_expressions if a Param's type changes.
Since commit6719b23 it's been possible for the values of plpgsqlrecord field variables to be exposed to the planner as Params.(Before that, plpgsql never supplied values for such variables duringplanning, so that the problematic code wasn't reached.) Other placesthat touch potentially-type-mutable Params either cope gracefully ordo runtime-test-and-ereport checks that the type is what they expect.But eval_const_expressions() just had an Assert, meaning that it eitherfailed the assertion or risked crashes due to using an incompatiblevalue.In this case, rather than throwing an ereport immediately, we can justnot perform a const-substitution in case of a mismatch. This seemsimportant for the same reason that the Param fetch was speculative:we might not actually reach this part of the expression at runtime.Test case will follow in a separate commit.Patch by me, pursuant to bug report from Andrew Gierth.Back-patch to v11 where the previous commit appeared.Discussion:https://postgr.es/m/87wotkfju1.fsf@news-spur.riddles.org.uk
1 parent3acc4ac commit662d12a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎src/backend/optimizer/util/clauses.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,14 @@ eval_const_expressions_mutator(Node *node,
25672567
else
25682568
prm=&paramLI->params[param->paramid-1];
25692569

2570-
if (OidIsValid(prm->ptype))
2570+
/*
2571+
* We don't just check OidIsValid, but insist that the
2572+
* fetched type match the Param, just in case the hook did
2573+
* something unexpected. No need to throw an error here
2574+
* though; leave that for runtime.
2575+
*/
2576+
if (OidIsValid(prm->ptype)&&
2577+
prm->ptype==param->paramtype)
25712578
{
25722579
/* OK to substitute parameter value? */
25732580
if (context->estimate||
@@ -2583,7 +2590,6 @@ eval_const_expressions_mutator(Node *node,
25832590
booltypByVal;
25842591
Datumpval;
25852592

2586-
Assert(prm->ptype==param->paramtype);
25872593
get_typlenbyval(param->paramtype,
25882594
&typLen,&typByVal);
25892595
if (prm->isnull||typByVal)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp