postgresql/src/backend/commands
Robert Haas 9c08aea6a3 Add new block-by-block strategy for CREATE DATABASE.
Because this strategy logs changes on a block-by-block basis, it
avoids the need to checkpoint before and after the operation.
However, because it logs each changed block individually, it might
generate a lot of extra write-ahead logging if the template database
is large. Therefore, the older strategy remains available via a new
STRATEGY parameter to CREATE DATABASE, and a corresponding --strategy
option to createdb.

Somewhat controversially, this patch assembles the list of relations
to be copied to the new database by reading the pg_class relation of
the template database. Cross-database access like this isn't normally
possible, but it can be made to work here because there can't be any
connections to the database being copied, nor can it contain any
in-doubt transactions. Even so, we have to use lower-level interfaces
than normal, since the table scan and relcache interfaces will not
work for a database to which we're not connected. The advantage of
this approach is that we do not need to rely on the filesystem to
determine what ought to be copied, but instead on PostgreSQL's own
knowledge of the database structure. This avoids, for example,
copying stray files that happen to be located in the source database
directory.

Dilip Kumar, with a fairly large number of cosmetic changes by me.
Reviewed and tested by Ashutosh Sharma, Andres Freund, John Naylor,
Greg Nancarrow, Neha Sharma. Additional feedback from Bruce Momjian,
Heikki Linnakangas, Julien Rouhaud, Adam Brusselback, Kyotaro
Horiguchi, Tomas Vondra, Andrew Dunstan, Álvaro Herrera, and others.

Discussion: http://postgr.es/m/CA+TgmoYtcdxBjLh31DLxUXHxFVMPGzrU5_T=CYCvRyFHywSBUQ@mail.gmail.com
2022-03-29 11:48:36 -04:00
..
Makefile Move parallel vacuum code to vacuumparallel.c. 2021-12-23 11:42:52 +05:30
aggregatecmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
alter.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
amcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
analyze.c Add VACUUM instrumentation for scanned pages, relfrozenxid. 2022-02-11 16:48:40 -08:00
async.c Reduce more the number of calls to GetMaxBackends() 2022-02-10 10:27:29 +09:00
cluster.c Consolidate VACUUM xid cutoff logic. 2022-02-11 18:26:15 -08:00
collationcmds.c Add option to use ICU as global locale provider 2022-03-17 11:13:16 +01:00
comment.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
constraint.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
conversioncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copy.c Use has_privs_for_roles for predefined role checks 2022-03-28 15:10:04 -04:00
copyfrom.c Remove workarounds for avoiding [U]INT64_FORMAT in translatable strings. 2022-03-21 11:11:55 -04:00
copyfromparse.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copyto.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00
createas.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dbcommands.c Add new block-by-block strategy for CREATE DATABASE. 2022-03-29 11:48:36 -04:00
define.c Add Boolean node 2022-01-17 10:38:23 +01:00
discard.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dropcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
event_trigger.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
explain.c Add support for MERGE SQL command 2022-03-28 16:47:48 +02:00
extension.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
foreigncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
functioncmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
indexcmds.c Fix comment in CheckIndexCompatible(). 2022-02-18 12:19:10 +09:00
lockcmds.c Add support for security invoker views. 2022-03-22 10:28:10 +00:00
matview.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
opclasscmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
operatorcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
policy.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
portalcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
prepare.c Add pg_analyze_and_rewrite_varparams() 2022-03-07 08:13:30 +01:00
proclang.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
publicationcmds.c Allow specifying column lists for logical replication 2022-03-26 01:01:27 +01:00
schemacmds.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00
seclabel.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
sequence.c Add decoding of sequences to built-in replication 2022-03-24 18:49:27 +01:00
statscmds.c Check syscache result in AlterStatistics 2022-01-23 03:16:31 +01:00
subscriptioncmds.c Add decoding of sequences to built-in replication 2022-03-24 18:49:27 +01:00
tablecmds.c Add new block-by-block strategy for CREATE DATABASE. 2022-03-29 11:48:36 -04:00
tablespace.c Revert "Fix replay of create database records on standby" 2022-03-29 15:36:21 +02:00
trigger.c Add support for MERGE SQL command 2022-03-28 16:47:48 +02:00
tsearchcmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
typecmds.c Add missing TYPEALIGN macros 2022-02-16 19:33:28 +07:00
user.c Remove the ability of a role to administer itself. 2022-03-28 13:38:13 -04:00
vacuum.c Avoid VACUUM reltuples distortion. 2022-02-16 17:15:50 -08:00
vacuumparallel.c Unify VACUUM VERBOSE and autovacuum logging. 2022-01-14 16:50:34 -08:00
variable.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
view.c Parse/analyze function renaming 2022-03-04 14:50:22 +01:00