postgresql/src/include/utils
Tom Lane 49507dec46 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:06 -04:00
..
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
acl.h Replace AclObjectKind with ObjectType 2018-01-19 14:01:15 -05:00
aclchk_internal.h Replace GrantObjectType with ObjectType 2018-01-19 14:01:14 -05:00
array.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
arrayaccess.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
ascii.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
attoptcache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
backend_random.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
builtins.h Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY. 2018-03-19 18:50:05 -04:00
bytea.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
cash.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catcache.h Save a few bytes by removing useless last argument to SearchCatCacheList. 2018-01-29 15:13:17 -05:00
combocid.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
date.h Fix compiler warnings due to commit cc4feded 2018-01-17 03:33:02 -05:00
datetime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
datum.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
dsa.h Use size_t consistently in dsa.{ch}. 2018-09-22 00:41:49 +12:00
dynahash.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
dynamic_loader.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
elog.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
evtcache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
expandeddatum.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
expandedrecord.h Detoast plpgsql variables if they might live across a transaction boundary. 2018-05-16 14:56:52 -04:00
fmgrtab.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
formatting.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
freepage.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
geo_decls.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
guc.h Teach SHOW ALL to honor pg_read_all_settings membership 2018-06-08 16:19:05 -04:00
guc_tables.h Split out documentation of SSL parameters into their own section 2018-01-23 07:11:38 -05:00
hashutils.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
help_config.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
hsearch.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
index_selfuncs.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
inet.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
int8.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
inval.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
json.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
jsonapi.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
jsonb.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
logtape.h Fix some sloppiness in the new BufFileSize() and BufFileAppend() functions. 2018-05-02 17:23:13 +03:00
lsyscache.h Fix assorted bugs in pg_get_partition_constraintdef(). 2018-09-27 18:15:06 -04:00
memdebug.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
memutils.h Rename MemoryContextCopySetIdentifier() for clarity 2018-04-06 12:37:54 -04:00
nabstime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
numeric.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
palloc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
partcache.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
pg_crc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_locale.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_lsn.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_rusage.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pidfile.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
plancache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
portal.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
ps_status.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
queryenvironment.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rangetypes.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
regproc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rel.h Fix misc typos, mostly in comments. 2018-07-18 16:17:42 +03:00
relcache.h Allow HOT updates for some expression indexes 2018-03-27 19:57:02 +01:00
relfilenodemap.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
relmapper.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
relptr.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
reltrigger.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
resowner.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
resowner_private.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
rls.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
ruleutils.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sampling.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
selfuncs.h Add prefix operator for TEXT type. 2018-04-03 19:46:45 +03:00
sharedtuplestore.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
snapmgr.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
snapshot.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sortsupport.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
spccache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
syscache.h Save a few bytes by removing useless last argument to SearchCatCacheList. 2018-01-29 15:13:17 -05:00
timeout.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
timestamp.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
tqual.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
tuplesort.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
tuplestore.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
typcache.h Make plpgsql use its DTYPE_REC code paths for composite-type variables. 2018-02-13 18:52:21 -05:00
tzparser.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
uuid.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
varbit.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
varlena.h Further fixes for quoted-list GUC values in pg_dump and ruleutils.c. 2018-07-31 13:00:08 -04:00
xml.h Update copyright for 2018 2018-01-02 23:30:12 -05:00