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

Commitba578fe

Browse files
committed
light refactoring (get rid of const Node *varnode)
1 parent8cf2371 commitba578fe

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

‎src/pg_pathman.c

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,17 @@ static WrapperNode *handle_boolexpr(const BoolExpr *expr, WalkerContext *context
5656
staticWrapperNode*handle_arrexpr(constScalarArrayOpExpr*expr,WalkerContext*context);
5757
staticWrapperNode*handle_opexpr(constOpExpr*expr,WalkerContext*context);
5858

59-
staticvoidhandle_binary_opexpr(WalkerContext*context,
60-
WrapperNode*result,
61-
constNode*varnode,
62-
constConst*c);
59+
staticvoidhandle_binary_opexpr(constConst*c,WalkerContext*context,
60+
WrapperNode*result);
6361

6462
staticvoidhandle_binary_opexpr_param(constPartRelationInfo*prel,
65-
WrapperNode*result,
66-
constNode*varnode);
63+
WrapperNode*result);
6764

68-
staticboolpull_var_param(constWalkerContext*context,
69-
constOpExpr*expr,
70-
Node**var_ptr,
71-
Node**param_ptr);
65+
staticboolis_key_op_param(constOpExpr*expr,
66+
constWalkerContext*context,
67+
Node**param_ptr);
7268

73-
staticConst*extract_const(WalkerContext*wcxt,Param*param);
69+
staticConst*extract_const(Param*param,WalkerContext*wcxt);
7470

7571

7672
/* Copied from PostgreSQL (allpaths.c) */
@@ -93,13 +89,13 @@ static void generate_mergeappend_paths(PlannerInfo *root,
9389

9490

9591
/* We can transform Param into Const provided that 'econtext' is available */
96-
#defineIsConstValue(wcxt,node) \
92+
#defineIsConstValue(node,wcxt) \
9793
( IsA((node), Const) || (WcxtHasExprContext(wcxt) ? IsA((node), Param) : false) )
9894

99-
#defineExtractConst(wcxt,node) \
95+
#defineExtractConst(node,wcxt) \
10096
( \
10197
IsA((node), Param) ? \
102-
extract_const((wcxt), (Param *) (node)) : \
98+
extract_const((Param *) (node), (wcxt)) : \
10399
((Const *) (node)) \
104100
)
105101

@@ -994,25 +990,26 @@ static WrapperNode *
994990
handle_opexpr(constOpExpr*expr,WalkerContext*context)
995991
{
996992
WrapperNode*result= (WrapperNode*)palloc0(sizeof(WrapperNode));
997-
Node*var,*param;
993+
Node*param;
998994
constPartRelationInfo*prel=context->prel;
999995

1000996
result->orig= (constNode*)expr;
1001997
result->args=NIL;
1002998

1003999
if (list_length(expr->args)==2)
10041000
{
1005-
if (pull_var_param(context,expr,&var,&param))
1001+
/* Is it KEY OP PARAM or PARAM OP KEY? */
1002+
if (is_key_op_param(expr,context,&param))
10061003
{
1007-
if (IsConstValue(context,param))
1004+
if (IsConstValue(param,context))
10081005
{
1009-
handle_binary_opexpr(context,result,var,
1010-
ExtractConst(context,param));
1006+
handle_binary_opexpr(ExtractConst(param,context),context,result);
10111007
returnresult;
10121008
}
1009+
/* TODO: estimate selectivity for param if it's Var */
10131010
elseif (IsA(param,Param)||IsA(param,Var))
10141011
{
1015-
handle_binary_opexpr_param(prel,result,var);
1012+
handle_binary_opexpr_param(prel,result);
10161013
returnresult;
10171014
}
10181015
}
@@ -1024,10 +1021,10 @@ handle_opexpr(const OpExpr *expr, WalkerContext *context)
10241021
}
10251022

10261023
/* Binary operator handler */
1027-
/* FIXME: varnode */
10281024
staticvoid
1029-
handle_binary_opexpr(WalkerContext*context,WrapperNode*result,
1030-
constNode*varnode,constConst*c)
1025+
handle_binary_opexpr(constConst*c,
1026+
WalkerContext*context,
1027+
WrapperNode*result)
10311028
{
10321029
intstrategy;
10331030
TypeCacheEntry*tce;
@@ -1112,10 +1109,9 @@ handle_binary_opexpr(WalkerContext *context, WrapperNode *result,
11121109
}
11131110

11141111
/* Estimate selectivity of parametrized quals */
1115-
/* FIXME: varnode */
11161112
staticvoid
11171113
handle_binary_opexpr_param(constPartRelationInfo*prel,
1118-
WrapperNode*result,constNode*varnode)
1114+
WrapperNode*result)
11191115
{
11201116
constOpExpr*expr= (constOpExpr*)result->orig;
11211117
TypeCacheEntry*tce;
@@ -1131,30 +1127,27 @@ handle_binary_opexpr_param(const PartRelationInfo *prel,
11311127

11321128

11331129
/*
1134-
* Checks if expression is a KEY OP PARAM or PARAM OP KEY, where KEY is
1135-
*partition expression and PARAM is whatever.
1130+
* Checks if expression is a KEY OP PARAM or PARAM OP KEY, where
1131+
*KEY is partitioning expression and PARAM is whatever.
11361132
*
11371133
* NOTE: returns false if partition key is not in expression.
11381134
*/
11391135
staticbool
1140-
pull_var_param(constWalkerContext*context,
1141-
constOpExpr*expr,
1142-
Node**var_ptr,
1143-
Node**param_ptr)
1136+
is_key_op_param(constOpExpr*expr,
1137+
constWalkerContext*context,
1138+
Node**param_ptr)/* ret value #1 */
11441139
{
11451140
Node*left=linitial(expr->args),
11461141
*right=lsecond(expr->args);
11471142

11481143
if (match_expr_to_operand(context->prel_expr,left))
11491144
{
1150-
*var_ptr=left;
11511145
*param_ptr=right;
11521146
return true;
11531147
}
11541148

11551149
if (match_expr_to_operand(context->prel_expr,right))
11561150
{
1157-
*var_ptr=right;
11581151
*param_ptr=left;
11591152
return true;
11601153
}
@@ -1164,7 +1157,7 @@ pull_var_param(const WalkerContext *context,
11641157

11651158
/* Extract (evaluate) Const from Param node */
11661159
staticConst*
1167-
extract_const(WalkerContext*wcxt,Param*param)
1160+
extract_const(Param*param,WalkerContext*wcxt)
11681161
{
11691162
ExprState*estate=ExecInitExpr((Expr*)param,NULL);
11701163
boolisnull;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp