postgresql/src/include
Tom Lane aaf10f32a3 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
2018-09-27 18:15:17 -04:00
..
access Add support for nearest-neighbor (KNN) searches to SP-GiST 2018-09-19 01:54:10 +03:00
bootstrap
catalog Remove fmgr.h inclusion from partition.h 2018-09-25 17:52:07 -03:00
commands Collect JIT instrumentation from workers. 2018-09-25 13:12:44 -07:00
common Install a check for mis-linking of src/port and src/common functions. 2018-09-09 12:23:23 -04:00
datatype
executor Split ExecStoreTuple into ExecStoreHeapTuple and ExecStoreBufferHeapTuple. 2018-09-25 16:27:48 -07:00
fe_utils Add semicolons to end of internally run queries 2018-08-30 19:23:22 +02:00
foreign
jit Collect JIT instrumentation from workers. 2018-09-25 13:12:44 -07:00
lib Code review for simplehash.h. 2018-08-28 12:32:22 +12:00
libpq Remove duplicate function declarations. 2018-08-14 14:25:14 -04:00
mb
nodes Collect JIT instrumentation from workers. 2018-09-25 13:12:44 -07:00
optimizer Don't allow LIMIT/OFFSET clause within sub-selects to be pushed to workers. 2018-09-14 09:36:30 +05:30
parser Fix INSERT ON CONFLICT UPDATE through a view that isn't just SELECT *. 2018-08-04 19:38:58 -04:00
partitioning Fix run-time partition pruning for appends with multiple source rels. 2018-08-01 19:42:52 -04:00
port Convert elog.c's useful_strerror() into a globally-used strerror wrapper. 2018-09-26 11:06:42 -04:00
portability
postmaster Implement "pg_ctl logrotate" command 2018-09-01 19:46:49 +03:00
regex
replication Fix memory leak in TRUNCATE decoding 2018-09-03 02:10:24 +02:00
rewrite
snowball Sync our Snowball stemmer dictionaries with current upstream. 2018-09-24 17:29:38 -04:00
statistics
storage Fix longstanding recursion hazard in sinval message processing. 2018-09-07 18:04:54 -04:00
tcop
tsearch
utils Fix assorted bugs in pg_get_partition_constraintdef(). 2018-09-27 18:15:17 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Always use our own versions of *printf(). 2018-09-26 13:13:57 -04:00
fmgr.h
funcapi.h Clean up in the wake of TupleDescGetSlot() removal / 10763358c3. 2018-09-27 11:38:11 -07:00
getaddrinfo.h
getopt_long.h
Makefile Refactor dlopen() support 2018-09-06 11:33:04 +02:00
miscadmin.h Switch flags tracking pending interrupts to sig_atomic_t 2018-09-27 07:47:20 +09:00
pg_config_ext.h.in
pg_config_ext.h.win32
pg_config_manual.h Add a debugging option to stress-test outfuncs.c and readfuncs.c. 2018-09-18 17:11:54 -04:00
pg_config.h.in Try another way to detect the result type of strerror_r(). 2018-09-26 18:23:13 -04:00
pg_config.h.win32 Try another way to detect the result type of strerror_r(). 2018-09-26 18:23:13 -04:00
pg_getopt.h
pg_trace.h
pgstat.h
pgtar.h
pgtime.h
port.h Clean up *printf macros to avoid conflict with format archetypes. 2018-09-26 17:35:01 -04:00
postgres_ext.h
postgres_fe.h
postgres.h
rusagestub.h
windowapi.h