aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/lsyscache.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-09-27 18:15:06 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-09-27 18:15:17 -0400
commitaaf10f32a308bc5f53772c773edf3f345f59bb74 (patch)
tree87b71d038df8d0ea9fde924d8992758804320551 /src/include/utils/lsyscache.h
parent4ec90f53f10141867d8b86f58d72990a13ff267b (diff)
downloadpostgresql-aaf10f32a308bc5f53772c773edf3f345f59bb74.tar.gz
postgresql-aaf10f32a308bc5f53772c773edf3f345f59bb74.zip
Fix assorted bugs in pg_get_partition_constraintdef().
It failed if passed a nonexistent relation OID, or one that was a non-heap relation, because of blindly applying heap_open to a user-supplied OID. This is not OK behavior for a SQL-exposed function; we have a project policy that we should return NULL in such cases. Moreover, since pg_get_partition_constraintdef ought now to work on indexes, restricting it to heaps is flat wrong anyway. The underlying function generate_partition_qual() wasn't on board with indexes having partition quals either, nor for that matter with rels having relispartition set but yet null relpartbound. (One wonders whether the person who wrote the function comment blocks claiming that these functions allow a missing relpartbound had ever tested it.) Fix by testing relispartition before opening the rel, and by using relation_open not heap_open. (If any other relkinds ever grow the ability to have relispartition set, the code will work with them automatically.) Also, don't reject null relpartbound in generate_partition_qual. Back-patch to v11, and all but the null-relpartbound change to v10. (It's not really necessary to change generate_partition_qual at all in v10, but I thought s/heap_open/relation_open/ would be a good idea anyway just to keep the code in sync with later branches.) Per report from Justin Pryzby. Discussion: https://postgr.es/m/20180927200020.GJ776@telsasoft.com
Diffstat (limited to 'src/include/utils/lsyscache.h')
-rw-r--r--src/include/utils/lsyscache.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
index e0eea2a0dc5..8c57de77c06 100644
--- a/src/include/utils/lsyscache.h
+++ b/src/include/utils/lsyscache.h
@@ -128,6 +128,7 @@ extern char *get_rel_name(Oid relid);
extern Oid get_rel_namespace(Oid relid);
extern Oid get_rel_type_id(Oid relid);
extern char get_rel_relkind(Oid relid);
+extern bool get_rel_relispartition(Oid relid);
extern Oid get_rel_tablespace(Oid relid);
extern char get_rel_persistence(Oid relid);
extern Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes);