@@ -142,22 +142,33 @@ get_partition_key_type_pl(PG_FUNCTION_ARGS)
142
142
}
143
143
144
144
/*
145
- * Return partition key type .
145
+ * Return cooked partition key.
146
146
*/
147
147
Datum
148
148
get_partition_cooked_key_pl (PG_FUNCTION_ARGS )
149
149
{
150
- Oid relid = PG_GETARG_OID (0 );
151
- PartRelationInfo * prel ;
152
- Datum res ;
150
+ /* Values extracted from PATHMAN_CONFIG */
151
+ Datum values [Natts_pathman_config ];
152
+ bool isnull [Natts_pathman_config ];
153
+
154
+ Oid relid = 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 ));
153
163
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 );
156
167
157
- res = CStringGetTextDatum ( nodeToString ( prel -> expr ) );
158
- close_pathman_relation_info ( prel );
168
+ pfree ( expr_cstr );
169
+ pfree ( expr );
159
170
160
- PG_RETURN_TEXT_P (res );
171
+ PG_RETURN_TEXT_P (CStringGetTextDatum ( cooked_cstr ) );
161
172
}
162
173
163
174
/*
0 commit comments