mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Teach \d+ to show partitioning constraints.
The fact that we didn't have this in the first place is likely why
the problem fixed by f8bffe9e6d
escaped detection.
Patch by Amit Langote, reviewed and slightly adjusted by me.
Discussion: http://postgr.es/m/CA+TgmoYWnV2GMnYLG-Czsix-E1WGAbo4D+0tx7t9NdfYBDMFsA@mail.gmail.com
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
#include "access/sysattr.h"
|
||||
#include "catalog/dependency.h"
|
||||
#include "catalog/indexing.h"
|
||||
#include "catalog/partition.h"
|
||||
#include "catalog/pg_aggregate.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "catalog/pg_authid.h"
|
||||
@ -1728,6 +1729,37 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
|
||||
return buf.data;
|
||||
}
|
||||
|
||||
/*
|
||||
* pg_get_partition_constraintdef
|
||||
*
|
||||
* Returns partition constraint expression as a string for the input relation
|
||||
*/
|
||||
Datum
|
||||
pg_get_partition_constraintdef(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid relationId = PG_GETARG_OID(0);
|
||||
Expr *constr_expr;
|
||||
int prettyFlags;
|
||||
List *context;
|
||||
char *consrc;
|
||||
|
||||
constr_expr = get_partition_qual_relid(relationId);
|
||||
|
||||
/* Quick exit if not a partition */
|
||||
if (constr_expr == NULL)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
/*
|
||||
* Deparse and return the constraint expression.
|
||||
*/
|
||||
prettyFlags = PRETTYFLAG_INDENT;
|
||||
context = deparse_context_for(get_relation_name(relationId), relationId);
|
||||
consrc = deparse_expression_pretty((Node *) constr_expr, context, false,
|
||||
false, prettyFlags, 0);
|
||||
|
||||
PG_RETURN_TEXT_P(string_to_text(consrc));
|
||||
}
|
||||
|
||||
/*
|
||||
* pg_get_constraintdef
|
||||
*
|
||||
|
Reference in New Issue
Block a user