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

Commit3a05cfa

Browse files
committed
fix ExtractConst() for PostgreSQL 10
1 parent4c166c1 commit3a05cfa

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

‎src/pg_pathman.c‎

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,22 @@ IsConstValue(Node *node, const WalkerContext *context)
144144
staticConst*
145145
ExtractConst(Node*node,constWalkerContext*context)
146146
{
147-
ExprState*estate;
147+
ExprState*estate;
148+
ExprContext*econtext=context->econtext;
148149

149-
Datumvalue;
150-
boolisnull;
150+
Datumvalue;
151+
boolisnull;
151152

152-
Oidtypid,
153-
collid;
154-
inttypmod;
153+
Oidtypid,
154+
collid;
155+
inttypmod;
155156

156157
/* Fast path for Consts */
157158
if (IsA(node,Const))
158159
return (Const*)node;
159160

160-
/* Evaluate expression */
161-
estate=ExecInitExpr((Expr*)node,NULL);
162-
value=ExecEvalExprCompat(estate,context->econtext,&isnull,
163-
mult_result_handler);
161+
/* Just a paranoid check */
162+
Assert(IsConstValue(node,context));
164163

165164
switch (nodeTag(node))
166165
{
@@ -171,6 +170,9 @@ ExtractConst(Node *node, const WalkerContext *context)
171170
typid=param->paramtype;
172171
typmod=param->paramtypmod;
173172
collid=param->paramcollid;
173+
174+
/* It must be provided */
175+
Assert(WcxtHasExprContext(context));
174176
}
175177
break;
176178

@@ -179,15 +181,33 @@ ExtractConst(Node *node, const WalkerContext *context)
179181
RowExpr*row= (RowExpr*)node;
180182

181183
typid=row->row_typeid;
182-
typmod=-1;
184+
typmod=-1;
183185
collid=InvalidOid;
186+
187+
#ifPG_VERSION_NUM >=100000
188+
/* If there's no context - create it! */
189+
if (!WcxtHasExprContext(context))
190+
econtext=CreateStandaloneExprContext();
191+
#endif
184192
}
185193
break;
186194

187195
default:
188-
elog(ERROR,"error in function "CppAsString(ExtractConst));;
196+
elog(ERROR,"error in function "CppAsString(ExtractConst));
189197
}
190198

199+
/* Evaluate expression */
200+
estate=ExecInitExpr((Expr*)node,NULL);
201+
value=ExecEvalExprCompat(estate,econtext,&isnull,
202+
mult_result_handler);
203+
204+
#ifPG_VERSION_NUM >=100000
205+
/* Free temp econtext if needed */
206+
if (econtext&& !WcxtHasExprContext(context))
207+
FreeExprContext(econtext, true);
208+
#endif
209+
210+
/* Finally return Const */
191211
returnmakeConst(typid,typmod,collid,get_typlen(typid),
192212
value,isnull,get_typbyval(typid));
193213
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp