postgresql/src/include
Alvaro Herrera 8aba932251
Fix relcache inconsistency hazard in partition detach
During queries coming from ri_triggers.c, we need to omit partitions
that are marked pending detach -- otherwise, the RI query is tricked
into allowing a row into the referencing table whose corresponding row
is in the detached partition.  Which is bogus: once the detach operation
completes, the row becomes an orphan.

However, the code was not doing that in repeatable-read transactions,
because relcache kept a copy of the partition descriptor that included
the partition, and used it in the RI query.  This commit changes the
partdesc cache code to only keep descriptors that aren't dependent on
a snapshot (namely: those where no detached partition exist, and those
where detached partitions are included).  When a partdesc-without-
detached-partitions is requested, we create one afresh each time; also,
those partdescs are stored in PortalContext instead of
CacheMemoryContext.

find_inheritance_children gets a new output *detached_exist boolean,
which indicates whether any partition marked pending-detach is found.
Its "include_detached" input flag is changed to "omit_detached", because
that name captures desired the semantics more naturally.
CreatePartitionDirectory() and RelationGetPartitionDesc() arguments are
identically renamed.

This was noticed because a buildfarm member that runs with relcache
clobbering, which would not keep the improperly cached partdesc, broke
one test, which led us to realize that the expected output of that test
was bogus.  This commit also corrects that expected output.

Author: Amit Langote <amitlangote09@gmail.com>
Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/3269784.1617215412@sss.pgh.pa.us
2021-04-22 15:13:25 -04:00
..
access Fix under-parenthesized XLogRecHasBlockRef() macro. 2021-04-20 17:01:49 -04:00
bootstrap Update copyright for 2021 2021-01-02 13:06:25 -05:00
catalog Fix relcache inconsistency hazard in partition detach 2021-04-22 15:13:25 -04:00
commands Allow TRUNCATE command to truncate foreign tables. 2021-04-08 20:56:08 +09:00
common Refactor HMAC implementations 2021-04-03 17:30:49 +09:00
datatype Update copyright for 2021 2021-01-02 13:06:25 -05:00
executor Undo decision to allow pg_proc.prosrc to be NULL. 2021-04-15 17:17:20 -04:00
fe_utils psql: Refine lexing of BEGIN...END blocks in CREATE FUNCTION statements 2021-04-16 12:20:23 +02:00
foreign Allow TRUNCATE command to truncate foreign tables. 2021-04-08 20:56:08 +09:00
jit Update copyright for 2021 2021-01-02 13:06:25 -05:00
lib Fix typos and grammar in documentation and code comments 2021-04-09 13:53:07 +09:00
libpq Refactor hba_authname 2021-04-07 14:24:47 +02:00
mb Do COPY FROM encoding conversion/verification in larger chunks. 2021-04-01 12:23:40 +03:00
nodes Speedup ScalarArrayOpExpr evaluation 2021-04-08 23:51:22 +12:00
optimizer Rename find_em_expr_usable_for_sorting_rel. 2021-04-20 11:37:36 -04:00
parser SQL-standard function body 2021-04-07 21:47:55 +02:00
partitioning Fix relcache inconsistency hazard in partition detach 2021-04-22 15:13:25 -04:00
port Add missing pthread_barrier_t. 2021-03-10 17:44:04 +13:00
portability Fix another portability bug in recent pgbench commit. 2021-03-10 23:20:41 +13:00
postmaster Remove temporary files after backend crash 2021-03-18 17:38:28 +01:00
regex Improve memory management in regex compiler. 2021-02-26 13:52:10 -05:00
replication Add information of total data processed to replication slot stats. 2021-04-16 07:34:43 +05:30
rewrite Rework planning and execution of UPDATE and DELETE. 2021-03-31 11:52:37 -04:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Extended statistics on expressions 2021-03-27 00:01:11 +01:00
storage Provide ReadRecentBuffer() to re-pin buffers by ID. 2021-04-08 17:50:25 +12:00
tcop SQL-standard function body 2021-04-07 21:47:55 +02:00
tsearch Don't leak compiled regex(es) when an ispell cache entry is dropped. 2021-03-18 22:22:47 -04:00
utils adjust query id feature to use pg_stat_activity.query_id 2021-04-20 12:22:26 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Work around issues in MinGW-64's setjmp/longjmp support. 2021-03-15 12:34:17 -04:00
fmgr.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
funcapi.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
getaddrinfo.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
getopt_long.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
Makefile Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
miscadmin.h Add function to log the memory contexts of specified backend process. 2021-04-06 13:44:15 +09:00
pg_config.h.in Refactor HMAC implementations 2021-04-03 17:30:49 +09:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix concurrency issues with WAL segment recycling on Windows 2021-03-22 14:02:26 +09:00
pg_getopt.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_trace.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pgstat.h Fix test case added by commit f5fc2f5b23. 2021-04-19 09:02:47 +05:30
pgtar.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pgtime.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
port.h Move bsearch_arg to src/port 2021-03-23 00:11:22 +01:00
postgres.h Mostly-cosmetic adjustments of TOAST-related macros. 2021-03-22 13:43:10 -04:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
rusagestub.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
windowapi.h Update copyright for 2021 2021-01-02 13:06:25 -05:00