pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix assorted bugs in pg_get_partition_constraintdef(). 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix assorted bugs in pg_get_partition_constraintdef(). @ 2018-09-27 22:15 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2018-09-27 22:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/aaf10f32a308bc5f53772c773edf3f345f59bb74 Modified Files -------------- src/backend/utils/cache/lsyscache.c | 24 +++++++++++++++++ src/backend/utils/cache/partcache.c | 48 ++++++++++++++++++++-------------- src/include/utils/lsyscache.h | 1 + src/test/regress/expected/indexing.out | 19 ++++++++++++++ src/test/regress/sql/indexing.sql | 2 ++ 5 files changed, 75 insertions(+), 19 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix assorted bugs in pg_get_partition_constraintdef(). @ 2018-09-27 22:15 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2018-09-27 22:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/49507dec46010cc781a4b4575b6c2ff5088b13d3 Modified Files -------------- src/backend/utils/cache/lsyscache.c | 24 +++++++++++++++++ src/backend/utils/cache/partcache.c | 48 ++++++++++++++++++++-------------- src/include/utils/lsyscache.h | 1 + src/test/regress/expected/indexing.out | 19 ++++++++++++++ src/test/regress/sql/indexing.sql | 2 ++ 5 files changed, 75 insertions(+), 19 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix assorted bugs in pg_get_partition_constraintdef(). @ 2018-09-27 22:15 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2018-09-27 22:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/dff3f06dc95e3c8dd6debbec3282556fbcb3f9ee Modified Files -------------- src/backend/catalog/partition.c | 32 +++++++++++++++++++++----------- src/backend/utils/cache/lsyscache.c | 24 ++++++++++++++++++++++++ src/include/utils/lsyscache.h | 1 + 3 files changed, 46 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2018-09-27 22:15 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-09-27 22:15 pgsql: Fix assorted bugs in pg_get_partition_constraintdef(). Tom Lane <tgl@sss.pgh.pa.us> 2018-09-27 22:15 pgsql: Fix assorted bugs in pg_get_partition_constraintdef(). Tom Lane <tgl@sss.pgh.pa.us> 2018-09-27 22:15 pgsql: Fix assorted bugs in pg_get_partition_constraintdef(). Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox