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

Commit639a0f1

Browse files
committed
Merge branch 'rel_future_beta' ofhttps://github.com/postgrespro/pg_pathman into rel_future_beta
2 parentsd13e38f +1192aea commit639a0f1

File tree

3 files changed

+72
-5
lines changed

3 files changed

+72
-5
lines changed

‎expected/pathman_expressions.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ SELECT COUNT(*) FROM test_exprs.hash_rel;
1616
5
1717
(1 row)
1818

19+
\set VERBOSITY default
20+
SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value2))', 4);
21+
ERROR: partitioning expression parse error
22+
DETAIL: syntax error at or near ")"
23+
QUERY: SELECT public.add_to_pathman_config(parent_relid, expression)
24+
CONTEXT: PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 9 at PERFORM
25+
SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value3', 4);
26+
ERROR: partitioning expression analyze error
27+
DETAIL: column "value3" does not exist
28+
HINT: Perhaps you meant to reference the column "hash_rel.value" or the column "hash_rel.value2".
29+
QUERY: SELECT public.add_to_pathman_config(parent_relid, expression)
30+
CONTEXT: PL/pgSQL function create_hash_partitions(regclass,text,integer,boolean,text[],text[]) line 9 at PERFORM
31+
\set VERBOSITY terse
1932
SELECT create_hash_partitions('test_exprs.hash_rel', 'value * value2', 4);
2033
create_hash_partitions
2134
------------------------

‎sql/pathman_expressions.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ INSERT INTO test_exprs.hash_rel (value, value2)
1515
SELECT val, val*2FROM generate_series(1,5) val;
1616

1717
SELECTCOUNT(*)FROMtest_exprs.hash_rel;
18+
\set VERBOSITY default
19+
SELECT create_hash_partitions('test_exprs.hash_rel','value * value2))',4);
20+
SELECT create_hash_partitions('test_exprs.hash_rel','value * value3',4);
21+
22+
\set VERBOSITY terse
1823
SELECT create_hash_partitions('test_exprs.hash_rel','value * value2',4);
1924
SELECTCOUNT(*)FROM ONLYtest_exprs.hash_rel;
2025
SELECTCOUNT(*)FROMtest_exprs.hash_rel;

‎src/relation_info.c

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,9 @@ parse_partitioning_expression(const Oid relid,
565565
char**query_string_out,/* ret value #1 */
566566
Node**parsetree_out)/* ret value #2 */
567567
{
568-
SelectStmt*select_stmt;
569-
List*parsetree_list;
568+
SelectStmt*select_stmt;
569+
List*parsetree_list;
570+
MemoryContextold_mcxt;
570571

571572
constchar*sql="SELECT (%s) FROM ONLY %s.%s";
572573
char*relname=get_rel_name(relid),
@@ -575,7 +576,31 @@ parse_partitioning_expression(const Oid relid,
575576
quote_identifier(nspname),
576577
quote_identifier(relname));
577578

578-
parsetree_list=raw_parser(query_string);
579+
old_mcxt=CurrentMemoryContext;
580+
581+
PG_TRY();
582+
{
583+
parsetree_list=raw_parser(query_string);
584+
}
585+
PG_CATCH();
586+
{
587+
ErrorData*error;
588+
589+
/* Switch to the original context & copy edata */
590+
MemoryContextSwitchTo(old_mcxt);
591+
error=CopyErrorData();
592+
FlushErrorState();
593+
594+
error->detail=error->message;
595+
error->message="partitioning expression parse error";
596+
error->sqlerrcode=ERRCODE_INVALID_PARAMETER_VALUE;
597+
error->cursorpos=0;
598+
error->internalpos=0;
599+
600+
ReThrowError(error);
601+
}
602+
PG_END_TRY();
603+
579604
if (list_length(parsetree_list)!=1)
580605
elog(ERROR,"expression \"%s\" produced more than one query",exp_cstr);
581606

@@ -660,8 +685,32 @@ cook_partitioning_expression(const Oid relid,
660685
*/
661686
old_mcxt=MemoryContextSwitchTo(parse_mcxt);
662687

663-
/* This will fail with elog in case of wrong expression */
664-
querytree_list=pg_analyze_and_rewrite(parsetree,query_string,NULL,0);
688+
PG_TRY();
689+
{
690+
/* This will fail with elog in case of wrong expression */
691+
querytree_list=pg_analyze_and_rewrite(parsetree,query_string,NULL,0);
692+
}
693+
PG_CATCH();
694+
{
695+
ErrorData*error;
696+
697+
/* Switch to the original context & copy edata */
698+
MemoryContextSwitchTo(old_mcxt);
699+
error=CopyErrorData();
700+
FlushErrorState();
701+
702+
error->detail=error->message;
703+
error->message="partitioning expression analyze error";
704+
error->sqlerrcode=ERRCODE_INVALID_PARAMETER_VALUE;
705+
error->cursorpos=0;
706+
error->internalpos=0;
707+
708+
/* Enable pathman hooks */
709+
pathman_hooks_enabled= true;
710+
ReThrowError(error);
711+
}
712+
PG_END_TRY();
713+
665714
if (list_length(querytree_list)!=1)
666715
elog(ERROR,"partitioning expression produced more than 1 query");
667716

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp