@@ -142,22 +142,33 @@ get_partition_key_type_pl(PG_FUNCTION_ARGS)
142142}
143143
144144/*
145- * Return partition key type .
145+ * Returncooked partition key.
146146 */
147147Datum
148148get_partition_cooked_key_pl (PG_FUNCTION_ARGS )
149149{
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 ));
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/*