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

Commit8a1d813

Browse files
author
Alexander Kuzmenkov
committed
Make get_partition_cooked_key work for tables with no partitions.
1 parent50c078b commit8a1d813

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

‎src/pl_funcs.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,33 @@ get_partition_key_type_pl(PG_FUNCTION_ARGS)
142142
}
143143

144144
/*
145-
* Return partition key type.
145+
* Returncookedpartition key.
146146
*/
147147
Datum
148148
get_partition_cooked_key_pl(PG_FUNCTION_ARGS)
149149
{
150-
Oidrelid=PG_GETARG_OID(0);
151-
PartRelationInfo*prel;
152-
Datumres;
150+
/* Values extracted from PATHMAN_CONFIG */
151+
Datumvalues[Natts_pathman_config];
152+
boolisnull[Natts_pathman_config];
153+
154+
Oidrelid=PG_GETARG_OID(0);
155+
char*expr_cstr;
156+
Node*expr;
157+
char*cooked_cstr;
158+
159+
/* Check that table is registered in PATHMAN_CONFIG */
160+
if (!pathman_config_contains_relation(relid,values,isnull,NULL,NULL))
161+
elog(ERROR,"table \"%s\" is not partitioned",
162+
get_rel_name_or_relid(relid));
153163

154-
prel=get_pathman_relation_info(relid);
155-
shout_if_prel_is_invalid(relid,prel,PT_ANY);
164+
expr_cstr=TextDatumGetCString(values[Anum_pathman_config_expr-1]);
165+
expr=cook_partitioning_expression(relid,expr_cstr,NULL);
166+
cooked_cstr=nodeToString(expr);
156167

157-
res=CStringGetTextDatum(nodeToString(prel->expr));
158-
close_pathman_relation_info(prel);
168+
pfree(expr_cstr);
169+
pfree(expr);
159170

160-
PG_RETURN_TEXT_P(res);
171+
PG_RETURN_TEXT_P(CStringGetTextDatum(cooked_cstr));
161172
}
162173

163174
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp