postgresql/src/backend
Tom Lane 5fe0ab4201 Fix failure to remove non-first segments of temporary tables.
Commit 4ab5dae94 broke mdunlinkfork's logic for removing additional
segments of a multi-gigabyte table, because it neglected to advance
"segno" after unlinking the first segment, in the code path where it
chooses to unlink that one immediately.  Then the main remove loop
gets ENOENT at segment zero and figures it's done, so we never remove
whatever additional segments might exist.

The main problem here is with large temporary tables, but WAL replay
of a drop of a large regular table would also fail to remove extra
segments.  The third case where this path is taken is for non-main
forks; but I doubt it matters for those since they probably never
exceed 1GB.

The simplest fix is just to increment segno after that unlink().
(Probably this logic could do with a more thorough rethink, but not
with mere hours to go before 15.1 wraps.)

While here, also fix an incautious assumption that
register_forget_request cannot change errno.  I don't think that
that has any really bad consequences, as we'd end up trying to unlink
the zero'th segment either way, but it greatly complicates reasoning
about what could happen here.  Also make a couple of other cosmetic
fixes.

Per bug #17679 from Balazs Szilfai.  Back-patch into v15, as the
faulty patch was.

Discussion: https://postgr.es/m/17679-1095d04450cf6a6e@postgresql.org
2022-11-07 11:36:45 -05:00
..
access Fix ordering issue with WAL operations in GIN fast insert path 2022-10-26 09:41:13 +09:00
backup Message style improvements 2022-09-24 18:38:35 -04:00
bootstrap Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
catalog Avoid crash after function syntax error in a replication worker. 2022-11-03 12:01:57 -04:00
commands Fix CREATE DATABASE so we can pg_upgrade DBs with OIDs above 2^31. 2022-11-04 10:39:52 -04:00
executor Fix copy-and-pasteo in comment. 2022-11-02 18:15:01 +09:00
foreign Rename SetSingleFuncCall() to InitMaterializedSRF() 2022-10-18 10:22:40 +09:00
jit Track LLVM 15 changes. 2022-10-19 22:18:54 +13:00
lib Fix lock assertions in dshash.c. 2022-07-11 16:01:22 +12:00
libpq Remove misguided SSL key file ownership check in libpq. 2022-05-26 14:14:05 -04:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:32 +09:00
nodes Fix pg_stat_statements for MERGE 2022-09-27 10:44:42 +02:00
optimizer Update some comments that should've covered MERGE 2022-10-24 12:52:43 +02:00
parser Fix CREATE DATABASE so we can pg_upgrade DBs with OIDs above 2^31. 2022-11-04 10:39:52 -04:00
partitioning Small cleanup of create_list_bounds() 2022-07-13 17:01:39 +12:00
po Translation updates 2022-11-07 14:04:05 +01:00
port Ensure that the argument of shmdt(2) is declared "void *". 2022-02-15 17:17:28 -05:00
postmaster Rework shutdown callback of archiver modules 2022-10-19 14:07:01 +09:00
regex Defend against stack overrun in a few more places. 2022-08-24 13:02:19 -04:00
replication Defend against unsupported partition relkind in logical replication worker. 2022-11-02 12:29:39 -04:00
rewrite Reject non-ON-SELECT rules that are named "_RETURN". 2022-10-17 12:14:39 -04:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Partially undo commit 94da73281. 2022-08-05 15:57:46 -04:00
storage Fix failure to remove non-first segments of temporary tables. 2022-11-07 11:36:45 -05:00
tcop Force immediate commit after CREATE DATABASE etc in extended protocol. 2022-07-26 13:07:03 -04:00
tsearch Defend against stack overrun in a few more places. 2022-08-24 13:02:19 -04:00
utils Fix planner failure with extended statistics on partitioned tables. 2022-11-01 14:34:44 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Move basebackup code to new directory src/backend/backup 2022-08-10 14:03:09 -04:00
nls.mk Translation updates 2022-11-07 14:04:05 +01:00