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

Commitf00f0d1

Browse files
committed
Fix expression parser
1 parenta0f38b5 commitf00f0d1

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

‎src/include/partition_creation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ typedef struct
8888
PartExpressionInfo*get_part_expression_info(Oidrelid,
8989
constchar*expr_string,boolcheck_hash_func,boolmake_plan);
9090

91-
Node*get_raw_expression(Oidrelid,constchar*expr,char**query_string_out);
91+
Node*get_raw_expression(Oidrelid,constchar*expr,char**query_string_out,
92+
Node**parsetree);
9293

9394
/* Partitioning callback type */
9495
typedefenum

‎src/partition_creation.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ create_single_partition_internal(Oid parent_relid,
697697

698698
*expr_type=DatumGetObjectId(config_values[Anum_pathman_config_atttype-1]);
699699
expr_string=TextDatumGetCString(config_values[Anum_pathman_config_expression-1]);
700-
*expr=get_raw_expression(parent_relid,expr_string,NULL);
700+
*expr=get_raw_expression(parent_relid,expr_string,NULL,NULL);
701701
pfree(expr_string);
702702
}
703703

@@ -1686,7 +1686,8 @@ text_to_regprocedure(text *proc_signature)
16861686

16871687
/* Wraps expression by SELECT query and returns parsed tree */
16881688
Node*
1689-
get_raw_expression(Oidrelid,constchar*expr,char**query_string_out)
1689+
get_raw_expression(Oidrelid,constchar*expr,char**query_string_out,
1690+
Node**parsetree)
16901691
{
16911692
Node*result;
16921693
SelectStmt*select_stmt;
@@ -1705,7 +1706,14 @@ get_raw_expression(Oid relid, const char *expr, char **query_string_out)
17051706
{
17061707
*query_string_out=query_string;
17071708
}
1709+
17081710
select_stmt= (SelectStmt*)lfirst(list_head(parsetree_list));
1711+
1712+
if (parsetree)
1713+
{
1714+
*parsetree= (Node*)select_stmt;
1715+
}
1716+
17091717
target= (ResTarget*)lfirst(list_head(select_stmt->targetList));
17101718
result= (Node*)target->val;
17111719
returnresult;
@@ -1719,7 +1727,8 @@ PartExpressionInfo *
17191727
get_part_expression_info(Oidrelid,constchar*expr_string,
17201728
boolcheck_hash_func,boolmake_plan)
17211729
{
1722-
Node*expr_node;
1730+
Node*expr_node,
1731+
*parsetree;
17231732
Query*query;
17241733
char*query_string,*out_string;
17251734
PartExpressionInfo*expr_info;
@@ -1730,15 +1739,16 @@ get_part_expression_info(Oid relid, const char *expr_string,
17301739
expr_info=palloc(sizeof(PartExpressionInfo));
17311740

17321741
/* Keep raw expression */
1733-
expr_info->raw_expr=get_raw_expression(relid,expr_string,&query_string);
1742+
expr_info->raw_expr=get_raw_expression(relid,expr_string,
1743+
&query_string,&parsetree);
17341744
expr_info->expr_datum= (Datum)0;
17351745

17361746
/* We don't need pathman activity initialization for this relation yet */
17371747
pathman_hooks_enabled= false;
17381748

17391749
/* This will fail with elog in case of wrong expression
17401750
*with more or less understable text */
1741-
querytree_list=pg_analyze_and_rewrite(expr_info->raw_expr,
1751+
querytree_list=pg_analyze_and_rewrite(parsetree,
17421752
query_string,NULL,0);
17431753
query= (Query*)lfirst(list_head(querytree_list));
17441754

‎src/pl_range_funcs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ build_range_condition(PG_FUNCTION_ARGS)
378378
MakeBoundInf(PLUS_INFINITY) :
379379
MakeBound(PG_GETARG_DATUM(3));
380380

381-
expr=get_raw_expression(relid,expression,NULL);
381+
expr=get_raw_expression(relid,expression,NULL,NULL);
382382
con=build_range_check_constraint(relid,
383383
expr,
384384
&min,&max,
@@ -835,7 +835,7 @@ modify_range_constraint(Oid child_relid,
835835
drop_check_constraint(child_relid);
836836

837837
/* Parse expression */
838-
expr=get_raw_expression(child_relid,attname,NULL);
838+
expr=get_raw_expression(child_relid,attname,NULL,NULL);
839839

840840
/* Build a new one */
841841
constraint=build_range_check_constraint(child_relid,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp