mirror of
https://github.com/postgres/postgres.git
synced 2025-04-20 00:42:27 +03:00
Pre-beta mechanical code beautification.
Run pgindent, pgperltidy, and reformat-dat-files. I manually fixed a couple of comments that pgindent uglified.
This commit is contained in:
parent
93909599cd
commit
23e7b38bfe
@ -22,7 +22,6 @@ diag("Time::HiRes::VERSION: $Time::HiRes::VERSION");
|
|||||||
|
|
||||||
# Check that if prove is using msys perl it is for an msys target
|
# Check that if prove is using msys perl it is for an msys target
|
||||||
ok( ($ENV{__CONFIG_HOST_OS__} || "") eq 'msys',
|
ok( ($ENV{__CONFIG_HOST_OS__} || "") eq 'msys',
|
||||||
"Msys perl used for correct target")
|
"Msys perl used for correct target") if $Config{osname} eq 'msys';
|
||||||
if $Config{osname} eq 'msys';
|
|
||||||
ok(1);
|
ok(1);
|
||||||
done_testing();
|
done_testing();
|
||||||
|
@ -171,8 +171,8 @@ shell_get_sink(bbsink *next_sink, void *detail_arg)
|
|||||||
/*
|
/*
|
||||||
* Since we're passing the string provided by the user to popen(), it will
|
* Since we're passing the string provided by the user to popen(), it will
|
||||||
* be interpreted by the shell, which is a potential security
|
* be interpreted by the shell, which is a potential security
|
||||||
* vulnerability, since the user invoking this module is not necessarily
|
* vulnerability, since the user invoking this module is not necessarily a
|
||||||
* a superuser. To stay out of trouble, we must disallow any shell
|
* superuser. To stay out of trouble, we must disallow any shell
|
||||||
* metacharacters here; to be conservative and keep things simple, we
|
* metacharacters here; to be conservative and keep things simple, we
|
||||||
* allow only alphanumerics.
|
* allow only alphanumerics.
|
||||||
*/
|
*/
|
||||||
@ -335,9 +335,8 @@ shell_send_data(bbsink_shell *sink, size_t len)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The error we're about to throw would shut down the command
|
* The error we're about to throw would shut down the command
|
||||||
* anyway, but we may get a more meaningful error message by
|
* anyway, but we may get a more meaningful error message by doing
|
||||||
* doing this. If not, we'll fall through to the generic error
|
* this. If not, we'll fall through to the generic error below.
|
||||||
* below.
|
|
||||||
*/
|
*/
|
||||||
shell_finish_command(sink);
|
shell_finish_command(sink);
|
||||||
errno = EPIPE;
|
errno = EPIPE;
|
||||||
|
@ -20,7 +20,8 @@ my $node = PostgreSQL::Test::Cluster->new('primary');
|
|||||||
|
|
||||||
# Make sure pg_hba.conf is set up to allow connections from backupuser.
|
# Make sure pg_hba.conf is set up to allow connections from backupuser.
|
||||||
# This is only needed on Windows machines that don't use UNIX sockets.
|
# This is only needed on Windows machines that don't use UNIX sockets.
|
||||||
$node->init('allows_streaming' => 1,
|
$node->init(
|
||||||
|
'allows_streaming' => 1,
|
||||||
'auth_extra' => [ '--create-role', 'backupuser' ]);
|
'auth_extra' => [ '--create-role', 'backupuser' ]);
|
||||||
|
|
||||||
$node->append_conf('postgresql.conf',
|
$node->append_conf('postgresql.conf',
|
||||||
@ -48,7 +49,8 @@ $node->command_fails_like(
|
|||||||
# Configure basebackup_to_shell.command and reload the configuation file.
|
# Configure basebackup_to_shell.command and reload the configuation file.
|
||||||
my $backup_path = PostgreSQL::Test::Utils::tempdir;
|
my $backup_path = PostgreSQL::Test::Utils::tempdir;
|
||||||
my $escaped_backup_path = $backup_path;
|
my $escaped_backup_path = $backup_path;
|
||||||
$escaped_backup_path =~ s{\\}{\\\\}g if ($PostgreSQL::Test::Utils::windows_os);
|
$escaped_backup_path =~ s{\\}{\\\\}g
|
||||||
|
if ($PostgreSQL::Test::Utils::windows_os);
|
||||||
my $shell_command =
|
my $shell_command =
|
||||||
$PostgreSQL::Test::Utils::windows_os
|
$PostgreSQL::Test::Utils::windows_os
|
||||||
? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
|
? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
|
||||||
@ -94,8 +96,7 @@ $node->command_fails_like(
|
|||||||
'fails if %d is present and detail not given');
|
'fails if %d is present and detail not given');
|
||||||
|
|
||||||
# Should work.
|
# Should work.
|
||||||
$node->command_ok(
|
$node->command_ok([ @pg_basebackup_cmd, '--target', 'shell:bar' ],
|
||||||
[ @pg_basebackup_cmd, '--target', 'shell:bar' ],
|
|
||||||
'backup with detail: pg_basebackup');
|
'backup with detail: pg_basebackup');
|
||||||
verify_backup('bar.', $backup_path, "backup with detail");
|
verify_backup('bar.', $backup_path, "backup with detail");
|
||||||
|
|
||||||
@ -110,7 +111,8 @@ sub verify_backup
|
|||||||
ok( -f "$backup_dir/${prefix}base.tar.gz",
|
ok( -f "$backup_dir/${prefix}base.tar.gz",
|
||||||
"$test_name: base.tar.gz was created");
|
"$test_name: base.tar.gz was created");
|
||||||
|
|
||||||
SKIP: {
|
SKIP:
|
||||||
|
{
|
||||||
my $tar = $ENV{TAR};
|
my $tar = $ENV{TAR};
|
||||||
skip "no tar program available", 1 if (!defined $tar || $tar eq '');
|
skip "no tar program available", 1 if (!defined $tar || $tar eq '');
|
||||||
|
|
||||||
@ -126,9 +128,12 @@ sub verify_backup
|
|||||||
'-C', $extract_path);
|
'-C', $extract_path);
|
||||||
|
|
||||||
# Verify.
|
# Verify.
|
||||||
$node->command_ok([ 'pg_verifybackup', '-n',
|
$node->command_ok(
|
||||||
|
[
|
||||||
|
'pg_verifybackup', '-n',
|
||||||
'-m', "${backup_dir}/${prefix}backup_manifest",
|
'-m', "${backup_dir}/${prefix}backup_manifest",
|
||||||
'-e', $extract_path ],
|
'-e', $extract_path
|
||||||
|
],
|
||||||
"$test_name: backup verifies ok");
|
"$test_name: backup verifies ok");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,8 @@ check_archive_directory(char **newval, void **extra, GucSource source)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The default value is an empty string, so we have to accept that value.
|
* The default value is an empty string, so we have to accept that value.
|
||||||
* Our check_configured callback also checks for this and prevents archiving
|
* Our check_configured callback also checks for this and prevents
|
||||||
* from proceeding if it is still empty.
|
* archiving from proceeding if it is still empty.
|
||||||
*/
|
*/
|
||||||
if (*newval == NULL || *newval[0] == '\0')
|
if (*newval == NULL || *newval[0] == '\0')
|
||||||
return true;
|
return true;
|
||||||
@ -155,18 +155,19 @@ basic_archive_file(const char *file, const char *path)
|
|||||||
MemoryContext oldcontext;
|
MemoryContext oldcontext;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We run basic_archive_file_internal() in our own memory context so that we
|
* We run basic_archive_file_internal() in our own memory context so that
|
||||||
* can easily reset it during error recovery (thus avoiding memory leaks).
|
* we can easily reset it during error recovery (thus avoiding memory
|
||||||
|
* leaks).
|
||||||
*/
|
*/
|
||||||
oldcontext = MemoryContextSwitchTo(basic_archive_context);
|
oldcontext = MemoryContextSwitchTo(basic_archive_context);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since the archiver operates at the bottom of the exception stack, ERRORs
|
* Since the archiver operates at the bottom of the exception stack,
|
||||||
* turn into FATALs and cause the archiver process to restart. However,
|
* ERRORs turn into FATALs and cause the archiver process to restart.
|
||||||
* using ereport(ERROR, ...) when there are problems is easy to code and
|
* However, using ereport(ERROR, ...) when there are problems is easy to
|
||||||
* maintain. Therefore, we create our own exception handler to catch ERRORs
|
* code and maintain. Therefore, we create our own exception handler to
|
||||||
* and return false instead of restarting the archiver whenever there is a
|
* catch ERRORs and return false instead of restarting the archiver
|
||||||
* failure.
|
* whenever there is a failure.
|
||||||
*/
|
*/
|
||||||
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
|
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
|
||||||
{
|
{
|
||||||
@ -228,14 +229,14 @@ basic_archive_file_internal(const char *file, const char *path)
|
|||||||
snprintf(destination, MAXPGPATH, "%s/%s", archive_directory, file);
|
snprintf(destination, MAXPGPATH, "%s/%s", archive_directory, file);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First, check if the file has already been archived. If it already exists
|
* First, check if the file has already been archived. If it already
|
||||||
* and has the same contents as the file we're trying to archive, we can
|
* exists and has the same contents as the file we're trying to archive,
|
||||||
* return success (after ensuring the file is persisted to disk). This
|
* we can return success (after ensuring the file is persisted to disk).
|
||||||
* scenario is possible if the server crashed after archiving the file but
|
* This scenario is possible if the server crashed after archiving the
|
||||||
* before renaming its .ready file to .done.
|
* file but before renaming its .ready file to .done.
|
||||||
*
|
*
|
||||||
* If the archive file already exists but has different contents, something
|
* If the archive file already exists but has different contents,
|
||||||
* might be wrong, so we just fail.
|
* something might be wrong, so we just fail.
|
||||||
*/
|
*/
|
||||||
if (stat(destination, &st) == 0)
|
if (stat(destination, &st) == 0)
|
||||||
{
|
{
|
||||||
@ -274,8 +275,8 @@ basic_archive_file_internal(const char *file, const char *path)
|
|||||||
archive_directory, "archtemp", file, MyProcPid, epoch);
|
archive_directory, "archtemp", file, MyProcPid, epoch);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy the file to its temporary destination. Note that this will fail if
|
* Copy the file to its temporary destination. Note that this will fail
|
||||||
* temp already exists.
|
* if temp already exists.
|
||||||
*/
|
*/
|
||||||
copy_file(unconstify(char *, path), temp);
|
copy_file(unconstify(char *, path), temp);
|
||||||
|
|
||||||
|
@ -1533,7 +1533,10 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
|
|||||||
HASH_SEQ_STATUS hash_seq;
|
HASH_SEQ_STATUS hash_seq;
|
||||||
pgssEntry *entry;
|
pgssEntry *entry;
|
||||||
|
|
||||||
/* Superusers or roles with the privileges of pg_read_all_stats members are allowed */
|
/*
|
||||||
|
* Superusers or roles with the privileges of pg_read_all_stats members
|
||||||
|
* are allowed
|
||||||
|
*/
|
||||||
is_allowed_role = has_privs_of_role(userid, ROLE_PG_READ_ALL_STATS);
|
is_allowed_role = has_privs_of_role(userid, ROLE_PG_READ_ALL_STATS);
|
||||||
|
|
||||||
/* hash table must exist already */
|
/* hash table must exist already */
|
||||||
|
@ -373,7 +373,8 @@ gen_ossl_decrypt(PX_Cipher *c, int padding, const uint8 *data, unsigned dlen,
|
|||||||
uint8 *res, unsigned *rlen)
|
uint8 *res, unsigned *rlen)
|
||||||
{
|
{
|
||||||
OSSLCipher *od = c->ptr;
|
OSSLCipher *od = c->ptr;
|
||||||
int outlen, outlen2;
|
int outlen,
|
||||||
|
outlen2;
|
||||||
|
|
||||||
if (!od->init)
|
if (!od->init)
|
||||||
{
|
{
|
||||||
@ -402,7 +403,8 @@ gen_ossl_encrypt(PX_Cipher *c, int padding, const uint8 *data, unsigned dlen,
|
|||||||
uint8 *res, unsigned *rlen)
|
uint8 *res, unsigned *rlen)
|
||||||
{
|
{
|
||||||
OSSLCipher *od = c->ptr;
|
OSSLCipher *od = c->ptr;
|
||||||
int outlen, outlen2;
|
int outlen,
|
||||||
|
outlen2;
|
||||||
|
|
||||||
if (!od->init)
|
if (!od->init)
|
||||||
{
|
{
|
||||||
|
@ -654,10 +654,10 @@ do_sql_command_end(PGconn *conn, const char *sql, bool consume_input)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If requested, consume whatever data is available from the socket.
|
* If requested, consume whatever data is available from the socket. (Note
|
||||||
* (Note that if all data is available, this allows pgfdw_get_result to
|
* that if all data is available, this allows pgfdw_get_result to call
|
||||||
* call PQgetResult without forcing the overhead of WaitLatchOrSocket,
|
* PQgetResult without forcing the overhead of WaitLatchOrSocket, which
|
||||||
* which would be large compared to the overhead of PQconsumeInput.)
|
* would be large compared to the overhead of PQconsumeInput.)
|
||||||
*/
|
*/
|
||||||
if (consume_input && !PQconsumeInput(conn))
|
if (consume_input && !PQconsumeInput(conn))
|
||||||
pgfdw_report_error(ERROR, NULL, conn, false, sql);
|
pgfdw_report_error(ERROR, NULL, conn, false, sql);
|
||||||
@ -1560,6 +1560,7 @@ pgfdw_finish_pre_commit_cleanup(List *pending_entries)
|
|||||||
entry = (ConnCacheEntry *) lfirst(lc);
|
entry = (ConnCacheEntry *) lfirst(lc);
|
||||||
|
|
||||||
Assert(entry->changing_xact_state);
|
Assert(entry->changing_xact_state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We might already have received the result on the socket, so pass
|
* We might already have received the result on the socket, so pass
|
||||||
* consume_input=true to try to consume it first
|
* consume_input=true to try to consume it first
|
||||||
@ -1634,6 +1635,7 @@ pgfdw_finish_pre_subcommit_cleanup(List *pending_entries, int curlevel)
|
|||||||
entry = (ConnCacheEntry *) lfirst(lc);
|
entry = (ConnCacheEntry *) lfirst(lc);
|
||||||
|
|
||||||
Assert(entry->changing_xact_state);
|
Assert(entry->changing_xact_state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We might already have received the result on the socket, so pass
|
* We might already have received the result on the socket, so pass
|
||||||
* consume_input=true to try to consume it first
|
* consume_input=true to try to consume it first
|
||||||
|
@ -300,8 +300,8 @@ pg_decode_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
|
|||||||
txn->output_plugin_private = txndata;
|
txn->output_plugin_private = txndata;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If asked to skip empty transactions, we'll emit BEGIN at the point where
|
* If asked to skip empty transactions, we'll emit BEGIN at the point
|
||||||
* the first operation is received for this transaction.
|
* where the first operation is received for this transaction.
|
||||||
*/
|
*/
|
||||||
if (data->skip_empty_xacts)
|
if (data->skip_empty_xacts)
|
||||||
return;
|
return;
|
||||||
@ -360,8 +360,8 @@ pg_decode_begin_prepare_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
|
|||||||
txn->output_plugin_private = txndata;
|
txn->output_plugin_private = txndata;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If asked to skip empty transactions, we'll emit BEGIN at the point where
|
* If asked to skip empty transactions, we'll emit BEGIN at the point
|
||||||
* the first operation is received for this transaction.
|
* where the first operation is received for this transaction.
|
||||||
*/
|
*/
|
||||||
if (data->skip_empty_xacts)
|
if (data->skip_empty_xacts)
|
||||||
return;
|
return;
|
||||||
|
@ -663,9 +663,9 @@ init_toast_snapshot(Snapshot toast_snapshot)
|
|||||||
/*
|
/*
|
||||||
* Catalog snapshots can be returned by GetOldestSnapshot() even if not
|
* Catalog snapshots can be returned by GetOldestSnapshot() even if not
|
||||||
* registered or active. That easily hides bugs around not having a
|
* registered or active. That easily hides bugs around not having a
|
||||||
* snapshot set up - most of the time there is a valid catalog
|
* snapshot set up - most of the time there is a valid catalog snapshot.
|
||||||
* snapshot. So additionally insist that the current snapshot is
|
* So additionally insist that the current snapshot is registered or
|
||||||
* registered or active.
|
* active.
|
||||||
*/
|
*/
|
||||||
Assert(HaveRegisteredOrActiveSnapshot());
|
Assert(HaveRegisteredOrActiveSnapshot());
|
||||||
|
|
||||||
|
@ -68,9 +68,9 @@ typedef struct
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Tuple visibility is only computed once for each tuple, for correctness
|
* Tuple visibility is only computed once for each tuple, for correctness
|
||||||
* and efficiency reasons; see comment in heap_page_prune() for
|
* and efficiency reasons; see comment in heap_page_prune() for details.
|
||||||
* details. This is of type int8[,] instead of HTSV_Result[], so we can use
|
* This is of type int8[], instead of HTSV_Result[], so we can use -1 to
|
||||||
* -1 to indicate no visibility has been computed, e.g. for LP_DEAD items.
|
* indicate no visibility has been computed, e.g. for LP_DEAD items.
|
||||||
*
|
*
|
||||||
* Same indexing as ->marked.
|
* Same indexing as ->marked.
|
||||||
*/
|
*/
|
||||||
|
@ -2232,12 +2232,12 @@ lazy_vacuum(LVRelState *vacrel)
|
|||||||
* dead_items space is not CPU cache resident.
|
* dead_items space is not CPU cache resident.
|
||||||
*
|
*
|
||||||
* We don't take any special steps to remember the LP_DEAD items (such
|
* We don't take any special steps to remember the LP_DEAD items (such
|
||||||
* as counting them in our final update to the stats system) when
|
* as counting them in our final update to the stats system) when the
|
||||||
* the optimization is applied. Though the accounting used in
|
* optimization is applied. Though the accounting used in analyze.c's
|
||||||
* analyze.c's acquire_sample_rows() will recognize the same LP_DEAD
|
* acquire_sample_rows() will recognize the same LP_DEAD items as dead
|
||||||
* items as dead rows in its own stats report, that's okay.
|
* rows in its own stats report, that's okay. The discrepancy should
|
||||||
* The discrepancy should be negligible. If this optimization is ever
|
* be negligible. If this optimization is ever expanded to cover more
|
||||||
* expanded to cover more cases then this may need to be reconsidered.
|
* cases then this may need to be reconsidered.
|
||||||
*/
|
*/
|
||||||
threshold = (double) vacrel->rel_pages * BYPASS_THRESHOLD_PAGES;
|
threshold = (double) vacrel->rel_pages * BYPASS_THRESHOLD_PAGES;
|
||||||
bypass = (vacrel->lpdead_item_pages < threshold &&
|
bypass = (vacrel->lpdead_item_pages < threshold &&
|
||||||
|
@ -411,8 +411,8 @@ xact_desc_prepare(StringInfo buf, uint8 info, xl_xact_prepare *xlrec, RepOriginI
|
|||||||
parsed.tsId, xlrec->initfileinval);
|
parsed.tsId, xlrec->initfileinval);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the replication origin has been set in this record in the
|
* Check if the replication origin has been set in this record in the same
|
||||||
* same way as PrepareRedoAdd().
|
* way as PrepareRedoAdd().
|
||||||
*/
|
*/
|
||||||
if (origin_id != InvalidRepOriginId)
|
if (origin_id != InvalidRepOriginId)
|
||||||
appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s",
|
appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s",
|
||||||
|
@ -435,10 +435,10 @@ typedef struct XLogCtlInsert
|
|||||||
bool fullPageWrites;
|
bool fullPageWrites;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* runningBackups is a counter indicating the number of backups currently in
|
* runningBackups is a counter indicating the number of backups currently
|
||||||
* progress. forcePageWrites is set to true when runningBackups is non-zero.
|
* in progress. forcePageWrites is set to true when runningBackups is
|
||||||
* lastBackupStart is the latest checkpoint redo location used as a starting
|
* non-zero. lastBackupStart is the latest checkpoint redo location used
|
||||||
* point for an online backup.
|
* as a starting point for an online backup.
|
||||||
*/
|
*/
|
||||||
int runningBackups;
|
int runningBackups;
|
||||||
XLogRecPtr lastBackupStart;
|
XLogRecPtr lastBackupStart;
|
||||||
@ -5307,14 +5307,14 @@ StartupXLOG(void)
|
|||||||
* When recovering from a backup (we are in recovery, and archive recovery
|
* When recovering from a backup (we are in recovery, and archive recovery
|
||||||
* was requested), complain if we did not roll forward far enough to reach
|
* was requested), complain if we did not roll forward far enough to reach
|
||||||
* the point where the database is consistent. For regular online
|
* the point where the database is consistent. For regular online
|
||||||
* backup-from-primary, that means reaching the end-of-backup WAL record (at
|
* backup-from-primary, that means reaching the end-of-backup WAL record
|
||||||
* which point we reset backupStartPoint to be Invalid), for
|
* (at which point we reset backupStartPoint to be Invalid), for
|
||||||
* backup-from-replica (which can't inject records into the WAL stream),
|
* backup-from-replica (which can't inject records into the WAL stream),
|
||||||
* that point is when we reach the minRecoveryPoint in pg_control (which
|
* that point is when we reach the minRecoveryPoint in pg_control (which
|
||||||
* we purposfully copy last when backing up from a replica). For pg_rewind
|
* we purposefully copy last when backing up from a replica). For
|
||||||
* (which creates a backup_label with a method of "pg_rewind") or
|
* pg_rewind (which creates a backup_label with a method of "pg_rewind")
|
||||||
* snapshot-style backups (which don't), backupEndRequired will be set to
|
* or snapshot-style backups (which don't), backupEndRequired will be set
|
||||||
* false.
|
* to false.
|
||||||
*
|
*
|
||||||
* Note: it is indeed okay to look at the local variable
|
* Note: it is indeed okay to look at the local variable
|
||||||
* LocalMinRecoveryPoint here, even though ControlFile->minRecoveryPoint
|
* LocalMinRecoveryPoint here, even though ControlFile->minRecoveryPoint
|
||||||
@ -5328,8 +5328,8 @@ StartupXLOG(void)
|
|||||||
/*
|
/*
|
||||||
* Ran off end of WAL before reaching end-of-backup WAL record, or
|
* Ran off end of WAL before reaching end-of-backup WAL record, or
|
||||||
* minRecoveryPoint. That's a bad sign, indicating that you tried to
|
* minRecoveryPoint. That's a bad sign, indicating that you tried to
|
||||||
* recover from an online backup but never called pg_backup_stop(),
|
* recover from an online backup but never called pg_backup_stop(), or
|
||||||
* or you didn't archive all the WAL needed.
|
* you didn't archive all the WAL needed.
|
||||||
*/
|
*/
|
||||||
if (ArchiveRecoveryRequested || ControlFile->backupEndRequired)
|
if (ArchiveRecoveryRequested || ControlFile->backupEndRequired)
|
||||||
{
|
{
|
||||||
@ -8481,8 +8481,8 @@ do_pg_backup_stop(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
|
|||||||
WALInsertLockAcquireExclusive();
|
WALInsertLockAcquireExclusive();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It is expected that each do_pg_backup_start() call is matched by exactly
|
* It is expected that each do_pg_backup_start() call is matched by
|
||||||
* one do_pg_backup_stop() call.
|
* exactly one do_pg_backup_stop() call.
|
||||||
*/
|
*/
|
||||||
Assert(XLogCtl->Insert.runningBackups > 0);
|
Assert(XLogCtl->Insert.runningBackups > 0);
|
||||||
XLogCtl->Insert.runningBackups--;
|
XLogCtl->Insert.runningBackups--;
|
||||||
|
@ -497,15 +497,15 @@ XLogArchiveNotify(const char *xlog)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Timeline history files are given the highest archival priority to
|
* Timeline history files are given the highest archival priority to lower
|
||||||
* lower the chance that a promoted standby will choose a timeline that
|
* the chance that a promoted standby will choose a timeline that is
|
||||||
* is already in use. However, the archiver ordinarily tries to gather
|
* already in use. However, the archiver ordinarily tries to gather
|
||||||
* multiple files to archive from each scan of the archive_status
|
* multiple files to archive from each scan of the archive_status
|
||||||
* directory, which means that newly created timeline history files
|
* directory, which means that newly created timeline history files could
|
||||||
* could be left unarchived for a while. To ensure that the archiver
|
* be left unarchived for a while. To ensure that the archiver picks up
|
||||||
* picks up timeline history files as soon as possible, we force the
|
* timeline history files as soon as possible, we force the archiver to
|
||||||
* archiver to scan the archive_status directory the next time it looks
|
* scan the archive_status directory the next time it looks for a file to
|
||||||
* for a file to archive.
|
* archive.
|
||||||
*/
|
*/
|
||||||
if (IsTLHistoryFileName(xlog))
|
if (IsTLHistoryFileName(xlog))
|
||||||
PgArchForceDirScan();
|
PgArchForceDirScan();
|
||||||
|
@ -74,8 +74,8 @@ pg_backup_start(PG_FUNCTION_ARGS)
|
|||||||
errmsg("a backup is already in progress in this session")));
|
errmsg("a backup is already in progress in this session")));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Label file and tablespace map file need to be long-lived, since
|
* Label file and tablespace map file need to be long-lived, since they
|
||||||
* they are read in pg_backup_stop.
|
* are read in pg_backup_stop.
|
||||||
*/
|
*/
|
||||||
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
|
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
|
||||||
label_file = makeStringInfo();
|
label_file = makeStringInfo();
|
||||||
@ -127,8 +127,8 @@ pg_backup_stop(PG_FUNCTION_ARGS)
|
|||||||
errhint("Did you call pg_backup_start()?")));
|
errhint("Did you call pg_backup_start()?")));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stop the backup. Return a copy of the backup label and tablespace map so
|
* Stop the backup. Return a copy of the backup label and tablespace map
|
||||||
* they can be written to disk by the caller.
|
* so they can be written to disk by the caller.
|
||||||
*/
|
*/
|
||||||
stoppoint = do_pg_backup_stop(label_file->data, waitforarchive, NULL);
|
stoppoint = do_pg_backup_stop(label_file->data, waitforarchive, NULL);
|
||||||
|
|
||||||
|
@ -1205,9 +1205,9 @@ read_backup_label(XLogRecPtr *checkPointLoc, TimeLineID *backupLabelTLI,
|
|||||||
* method was used) or if this label came from somewhere else (the only
|
* method was used) or if this label came from somewhere else (the only
|
||||||
* other option today being from pg_rewind). If this was a streamed
|
* other option today being from pg_rewind). If this was a streamed
|
||||||
* backup then we know that we need to play through until we get to the
|
* backup then we know that we need to play through until we get to the
|
||||||
* end of the WAL which was generated during the backup (at which point
|
* end of the WAL which was generated during the backup (at which point we
|
||||||
* we will have reached consistency and backupEndRequired will be reset
|
* will have reached consistency and backupEndRequired will be reset to be
|
||||||
* to be false).
|
* false).
|
||||||
*/
|
*/
|
||||||
if (fscanf(lfp, "BACKUP METHOD: %19s\n", backuptype) == 1)
|
if (fscanf(lfp, "BACKUP METHOD: %19s\n", backuptype) == 1)
|
||||||
{
|
{
|
||||||
@ -2055,10 +2055,9 @@ CheckRecoveryConsistency(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Have we passed our safe starting point? Note that minRecoveryPoint is
|
* Have we passed our safe starting point? Note that minRecoveryPoint is
|
||||||
* known to be incorrectly set if recovering from a backup, until
|
* known to be incorrectly set if recovering from a backup, until the
|
||||||
* the XLOG_BACKUP_END arrives to advise us of the correct
|
* XLOG_BACKUP_END arrives to advise us of the correct minRecoveryPoint.
|
||||||
* minRecoveryPoint. All we know prior to that is that we're not
|
* All we know prior to that is that we're not consistent yet.
|
||||||
* consistent yet.
|
|
||||||
*/
|
*/
|
||||||
if (!reachedConsistency && !backupEndRequired &&
|
if (!reachedConsistency && !backupEndRequired &&
|
||||||
minRecoveryPoint <= lastReplayedEndRecPtr)
|
minRecoveryPoint <= lastReplayedEndRecPtr)
|
||||||
|
@ -80,8 +80,7 @@ typedef struct xl_invalid_page
|
|||||||
|
|
||||||
static HTAB *invalid_page_tab = NULL;
|
static HTAB *invalid_page_tab = NULL;
|
||||||
|
|
||||||
static int
|
static int read_local_xlog_page_guts(XLogReaderState *state, XLogRecPtr targetPagePtr,
|
||||||
read_local_xlog_page_guts(XLogReaderState *state, XLogRecPtr targetPagePtr,
|
|
||||||
int reqLen, XLogRecPtr targetRecPtr,
|
int reqLen, XLogRecPtr targetRecPtr,
|
||||||
char *cur_page, bool wait_for_wal);
|
char *cur_page, bool wait_for_wal);
|
||||||
|
|
||||||
@ -940,8 +939,8 @@ read_local_xlog_page_guts(XLogReaderState *state, XLogRecPtr targetPagePtr,
|
|||||||
* archive in the timeline will get renamed to .partial by
|
* archive in the timeline will get renamed to .partial by
|
||||||
* StartupXLOG().
|
* StartupXLOG().
|
||||||
*
|
*
|
||||||
* If that happens after our caller determined the TLI but before
|
* If that happens after our caller determined the TLI but before we
|
||||||
* we actually read the xlog page, we might still try to read from the
|
* actually read the xlog page, we might still try to read from the
|
||||||
* old (now renamed) segment and fail. There's not much we can do
|
* old (now renamed) segment and fail. There's not much we can do
|
||||||
* about this, but it can only happen when we're a leaf of a cascading
|
* about this, but it can only happen when we're a leaf of a cascading
|
||||||
* standby whose primary gets promoted while we're decoding, so a
|
* standby whose primary gets promoted while we're decoding, so a
|
||||||
|
@ -96,7 +96,9 @@ sub ParseHeader
|
|||||||
push @{ $catalog{toasting} },
|
push @{ $catalog{toasting} },
|
||||||
{ parent_table => $1, toast_oid => $2, toast_index_oid => $3 };
|
{ parent_table => $1, toast_oid => $2, toast_index_oid => $3 };
|
||||||
}
|
}
|
||||||
elsif (/^DECLARE_TOAST_WITH_MACRO\(\s*(\w+),\s*(\d+),\s*(\d+),\s*(\w+),\s*(\w+)\)/)
|
elsif (
|
||||||
|
/^DECLARE_TOAST_WITH_MACRO\(\s*(\w+),\s*(\d+),\s*(\d+),\s*(\w+),\s*(\w+)\)/
|
||||||
|
)
|
||||||
{
|
{
|
||||||
push @{ $catalog{toasting} },
|
push @{ $catalog{toasting} },
|
||||||
{
|
{
|
||||||
@ -108,7 +110,8 @@ sub ParseHeader
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
elsif (
|
elsif (
|
||||||
/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*(\w+),\s*(\d+),\s*(\w+),\s*(.+)\)/)
|
/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*(\w+),\s*(\d+),\s*(\w+),\s*(.+)\)/
|
||||||
|
)
|
||||||
{
|
{
|
||||||
push @{ $catalog{indexing} },
|
push @{ $catalog{indexing} },
|
||||||
{
|
{
|
||||||
|
@ -1265,8 +1265,8 @@ heap_create_with_catalog(const char *relname,
|
|||||||
* remove the disk file again.)
|
* remove the disk file again.)
|
||||||
*
|
*
|
||||||
* NB: Note that passing create_storage = true is correct even for binary
|
* NB: Note that passing create_storage = true is correct even for binary
|
||||||
* upgrade. The storage we create here will be replaced later, but we need
|
* upgrade. The storage we create here will be replaced later, but we
|
||||||
* to have something on disk in the meanwhile.
|
* need to have something on disk in the meanwhile.
|
||||||
*/
|
*/
|
||||||
new_rel_desc = heap_create(relname,
|
new_rel_desc = heap_create(relname,
|
||||||
relnamespace,
|
relnamespace,
|
||||||
@ -3219,9 +3219,8 @@ restart:
|
|||||||
/*
|
/*
|
||||||
* If this constraint has a parent constraint which we have not seen
|
* If this constraint has a parent constraint which we have not seen
|
||||||
* yet, keep track of it for the second loop, below. Tracking parent
|
* yet, keep track of it for the second loop, below. Tracking parent
|
||||||
* constraints allows us to climb up to the top-level constraint
|
* constraints allows us to climb up to the top-level constraint and
|
||||||
* and look for all possible relations referencing the partitioned
|
* look for all possible relations referencing the partitioned table.
|
||||||
* table.
|
|
||||||
*/
|
*/
|
||||||
if (OidIsValid(con->conparentid) &&
|
if (OidIsValid(con->conparentid) &&
|
||||||
!list_member_oid(parent_cons, con->conparentid))
|
!list_member_oid(parent_cons, con->conparentid))
|
||||||
|
@ -928,9 +928,9 @@ index_create(Relation heapRelation,
|
|||||||
binary_upgrade_next_index_pg_class_relfilenode = InvalidOid;
|
binary_upgrade_next_index_pg_class_relfilenode = InvalidOid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that we want create_storage = true for binary upgrade.
|
* Note that we want create_storage = true for binary upgrade. The
|
||||||
* The storage we create here will be replaced later, but we need
|
* storage we create here will be replaced later, but we need to
|
||||||
* to have something on disk in the meanwhile.
|
* have something on disk in the meanwhile.
|
||||||
*/
|
*/
|
||||||
Assert(create_storage);
|
Assert(create_storage);
|
||||||
}
|
}
|
||||||
|
@ -378,9 +378,9 @@ publication_add_relation(Oid pubid, PublicationRelInfo *pri,
|
|||||||
check_publication_add_relation(targetrel);
|
check_publication_add_relation(targetrel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Translate column names to attnums and make sure the column list contains
|
* Translate column names to attnums and make sure the column list
|
||||||
* only allowed elements (no system or generated columns etc.). Also build
|
* contains only allowed elements (no system or generated columns etc.).
|
||||||
* an array of attnums, for storing in the catalog.
|
* Also build an array of attnums, for storing in the catalog.
|
||||||
*/
|
*/
|
||||||
publication_translate_columns(pri->relation, pri->columns,
|
publication_translate_columns(pri->relation, pri->columns,
|
||||||
&natts, &attarray);
|
&natts, &attarray);
|
||||||
@ -558,8 +558,8 @@ pub_collist_to_bitmapset(Bitmapset *columns, Datum pubcols, MemoryContext mcxt)
|
|||||||
MemoryContext oldcxt = NULL;
|
MemoryContext oldcxt = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If an existing bitmap was provided, use it. Otherwise just use NULL
|
* If an existing bitmap was provided, use it. Otherwise just use NULL and
|
||||||
* and build a new bitmap.
|
* build a new bitmap.
|
||||||
*/
|
*/
|
||||||
if (columns)
|
if (columns)
|
||||||
result = columns;
|
result = columns;
|
||||||
|
@ -340,13 +340,13 @@ RelationTruncate(Relation rel, BlockNumber nblocks)
|
|||||||
* is in progress.
|
* is in progress.
|
||||||
*
|
*
|
||||||
* The truncation operation might drop buffers that the checkpoint
|
* The truncation operation might drop buffers that the checkpoint
|
||||||
* otherwise would have flushed. If it does, then it's essential that
|
* otherwise would have flushed. If it does, then it's essential that the
|
||||||
* the files actually get truncated on disk before the checkpoint record
|
* files actually get truncated on disk before the checkpoint record is
|
||||||
* is written. Otherwise, if reply begins from that checkpoint, the
|
* written. Otherwise, if reply begins from that checkpoint, the
|
||||||
* to-be-truncated blocks might still exist on disk but have older
|
* to-be-truncated blocks might still exist on disk but have older
|
||||||
* contents than expected, which can cause replay to fail. It's OK for
|
* contents than expected, which can cause replay to fail. It's OK for the
|
||||||
* the blocks to not exist on disk at all, but not for them to have the
|
* blocks to not exist on disk at all, but not for them to have the wrong
|
||||||
* wrong contents.
|
* contents.
|
||||||
*/
|
*/
|
||||||
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_COMPLETE) == 0);
|
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_COMPLETE) == 0);
|
||||||
MyProc->delayChkptFlags |= DELAY_CHKPT_COMPLETE;
|
MyProc->delayChkptFlags |= DELAY_CHKPT_COMPLETE;
|
||||||
|
@ -680,10 +680,10 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now report ANALYZE to the cumulative stats system. For regular tables, we do
|
* Now report ANALYZE to the cumulative stats system. For regular tables,
|
||||||
* it only if not doing inherited stats. For partitioned tables, we only
|
* we do it only if not doing inherited stats. For partitioned tables, we
|
||||||
* do it for inherited stats. (We're never called for not-inherited stats
|
* only do it for inherited stats. (We're never called for not-inherited
|
||||||
* on partitioned tables anyway.)
|
* stats on partitioned tables anyway.)
|
||||||
*
|
*
|
||||||
* Reset the changes_since_analyze counter only if we analyzed all
|
* Reset the changes_since_analyze counter only if we analyzed all
|
||||||
* columns; otherwise, there is still work for auto-analyze to do.
|
* columns; otherwise, there is still work for auto-analyze to do.
|
||||||
|
@ -246,8 +246,9 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Nondeterministic collations are currently only supported with ICU
|
* Nondeterministic collations are currently only supported with ICU
|
||||||
* because that's the only case where it can actually make a difference.
|
* because that's the only case where it can actually make a
|
||||||
* So we can save writing the code for the other providers.
|
* difference. So we can save writing the code for the other
|
||||||
|
* providers.
|
||||||
*/
|
*/
|
||||||
if (!collisdeterministic && collprovider != COLLPROVIDER_ICU)
|
if (!collisdeterministic && collprovider != COLLPROVIDER_ICU)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
@ -800,7 +800,8 @@ NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields)
|
|||||||
errmsg("column name mismatch in header line field %d: got null value (\"%s\"), expected \"%s\"",
|
errmsg("column name mismatch in header line field %d: got null value (\"%s\"), expected \"%s\"",
|
||||||
fldnum, cstate->opts.null_print, NameStr(attr->attname))));
|
fldnum, cstate->opts.null_print, NameStr(attr->attname))));
|
||||||
|
|
||||||
if (namestrcmp(&attr->attname, colName) != 0) {
|
if (namestrcmp(&attr->attname, colName) != 0)
|
||||||
|
{
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
|
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
|
||||||
errmsg("column name mismatch in header line field %d: got \"%s\", expected \"%s\"",
|
errmsg("column name mismatch in header line field %d: got \"%s\", expected \"%s\"",
|
||||||
|
@ -201,9 +201,9 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
|
|||||||
*
|
*
|
||||||
* We typically do not read relation data into shared_buffers without
|
* We typically do not read relation data into shared_buffers without
|
||||||
* holding a relation lock. It's unclear what could go wrong if we
|
* holding a relation lock. It's unclear what could go wrong if we
|
||||||
* skipped it in this case, because nobody can be modifying either
|
* skipped it in this case, because nobody can be modifying either the
|
||||||
* the source or destination database at this point, and we have locks
|
* source or destination database at this point, and we have locks on
|
||||||
* on both databases, too, but let's take the conservative route.
|
* both databases, too, but let's take the conservative route.
|
||||||
*/
|
*/
|
||||||
dstrelid.relId = srcrelid.relId = relinfo->reloid;
|
dstrelid.relId = srcrelid.relId = relinfo->reloid;
|
||||||
LockRelationId(&srcrelid, AccessShareLock);
|
LockRelationId(&srcrelid, AccessShareLock);
|
||||||
@ -274,9 +274,9 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* We can't use a real relcache entry for a relation in some other
|
* We can't use a real relcache entry for a relation in some other
|
||||||
* database, but since we're only going to access the fields related
|
* database, but since we're only going to access the fields related to
|
||||||
* to physical storage, a fake one is good enough. If we didn't do this
|
* physical storage, a fake one is good enough. If we didn't do this and
|
||||||
* and used the smgr layer directly, we would have to worry about
|
* used the smgr layer directly, we would have to worry about
|
||||||
* invalidations.
|
* invalidations.
|
||||||
*/
|
*/
|
||||||
rel = CreateFakeRelcacheEntry(rnode);
|
rel = CreateFakeRelcacheEntry(rnode);
|
||||||
@ -368,10 +368,10 @@ ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
|
|||||||
CreateDBRelInfo *relinfo;
|
CreateDBRelInfo *relinfo;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ScanSourceDatabasePgClassTuple is in charge of constructing
|
* ScanSourceDatabasePgClassTuple is in charge of constructing a
|
||||||
* a CreateDBRelInfo object for this tuple, but can also decide
|
* CreateDBRelInfo object for this tuple, but can also decide that
|
||||||
* that this tuple isn't something we need to copy. If we do need
|
* this tuple isn't something we need to copy. If we do need to
|
||||||
* to copy the relation, add it to the list.
|
* copy the relation, add it to the list.
|
||||||
*/
|
*/
|
||||||
relinfo = ScanSourceDatabasePgClassTuple(&tuple, tbid, dbid,
|
relinfo = ScanSourceDatabasePgClassTuple(&tuple, tbid, dbid,
|
||||||
srcpath);
|
srcpath);
|
||||||
@ -406,11 +406,11 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
|
|||||||
*
|
*
|
||||||
* Shared objects don't need to be copied, because they are shared.
|
* Shared objects don't need to be copied, because they are shared.
|
||||||
* Objects without storage can't be copied, because there's nothing to
|
* Objects without storage can't be copied, because there's nothing to
|
||||||
* copy. Temporary relations don't need to be copied either, because
|
* copy. Temporary relations don't need to be copied either, because they
|
||||||
* they are inaccessible outside of the session that created them,
|
* are inaccessible outside of the session that created them, which must
|
||||||
* which must be gone already, and couldn't connect to a different database
|
* be gone already, and couldn't connect to a different database if it
|
||||||
* if it still existed. autovacuum will eventually remove the pg_class
|
* still existed. autovacuum will eventually remove the pg_class entries
|
||||||
* entries as well.
|
* as well.
|
||||||
*/
|
*/
|
||||||
if (classForm->reltablespace == GLOBALTABLESPACE_OID ||
|
if (classForm->reltablespace == GLOBALTABLESPACE_OID ||
|
||||||
!RELKIND_HAS_STORAGE(classForm->relkind) ||
|
!RELKIND_HAS_STORAGE(classForm->relkind) ||
|
||||||
@ -824,10 +824,10 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
|||||||
/*
|
/*
|
||||||
* We don't normally permit new databases to be created with
|
* We don't normally permit new databases to be created with
|
||||||
* system-assigned OIDs. pg_upgrade tries to preserve database
|
* system-assigned OIDs. pg_upgrade tries to preserve database
|
||||||
* OIDs, so we can't allow any database to be created with an
|
* OIDs, so we can't allow any database to be created with an OID
|
||||||
* OID that might be in use in a freshly-initialized cluster
|
* that might be in use in a freshly-initialized cluster created
|
||||||
* created by some future version. We assume all such OIDs will
|
* by some future version. We assume all such OIDs will be from
|
||||||
* be from the system-managed OID range.
|
* the system-managed OID range.
|
||||||
*
|
*
|
||||||
* As an exception, however, we permit any OID to be assigned when
|
* As an exception, however, we permit any OID to be assigned when
|
||||||
* allow_system_table_mods=on (so that initdb can assign system
|
* allow_system_table_mods=on (so that initdb can assign system
|
||||||
@ -1348,15 +1348,15 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
|||||||
InvokeObjectPostCreateHook(DatabaseRelationId, dboid, 0);
|
InvokeObjectPostCreateHook(DatabaseRelationId, dboid, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we're going to be reading data for the to-be-created database
|
* If we're going to be reading data for the to-be-created database into
|
||||||
* into shared_buffers, take a lock on it. Nobody should know that this
|
* shared_buffers, take a lock on it. Nobody should know that this
|
||||||
* database exists yet, but it's good to maintain the invariant that a
|
* database exists yet, but it's good to maintain the invariant that a
|
||||||
* lock an AccessExclusiveLock on the database is sufficient to drop all
|
* lock an AccessExclusiveLock on the database is sufficient to drop all
|
||||||
* of its buffers without worrying about more being read later.
|
* of its buffers without worrying about more being read later.
|
||||||
*
|
*
|
||||||
* Note that we need to do this before entering the PG_ENSURE_ERROR_CLEANUP
|
* Note that we need to do this before entering the
|
||||||
* block below, because createdb_failure_callback expects this lock to
|
* PG_ENSURE_ERROR_CLEANUP block below, because createdb_failure_callback
|
||||||
* be held already.
|
* expects this lock to be held already.
|
||||||
*/
|
*/
|
||||||
if (dbstrategy == CREATEDB_WAL_LOG)
|
if (dbstrategy == CREATEDB_WAL_LOG)
|
||||||
LockSharedObject(DatabaseRelationId, dboid, 0, AccessShareLock);
|
LockSharedObject(DatabaseRelationId, dboid, 0, AccessShareLock);
|
||||||
|
@ -332,8 +332,8 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
|
|||||||
/*
|
/*
|
||||||
* Inform cumulative stats system about our activity: basically, we
|
* Inform cumulative stats system about our activity: basically, we
|
||||||
* truncated the matview and inserted some new data. (The concurrent
|
* truncated the matview and inserted some new data. (The concurrent
|
||||||
* code path above doesn't need to worry about this because the inserts
|
* code path above doesn't need to worry about this because the
|
||||||
* and deletes it issues get counted by lower-level code.)
|
* inserts and deletes it issues get counted by lower-level code.)
|
||||||
*/
|
*/
|
||||||
pgstat_count_truncate(matviewRel);
|
pgstat_count_truncate(matviewRel);
|
||||||
if (!stmt->skipData)
|
if (!stmt->skipData)
|
||||||
|
@ -384,8 +384,8 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* For a partition, if pubviaroot is true, find the topmost ancestor that
|
* For a partition, if pubviaroot is true, find the topmost ancestor that
|
||||||
* is published via this publication as we need to use its column list
|
* is published via this publication as we need to use its column list for
|
||||||
* for the changes.
|
* the changes.
|
||||||
*
|
*
|
||||||
* Note that even though the column list used is for an ancestor, the
|
* Note that even though the column list used is for an ancestor, the
|
||||||
* REPLICA IDENTITY used will be for the actual child table.
|
* REPLICA IDENTITY used will be for the actual child table.
|
||||||
@ -429,8 +429,9 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
|
|||||||
/*
|
/*
|
||||||
* Attnums in the bitmap returned by RelationGetIndexAttrBitmap are
|
* Attnums in the bitmap returned by RelationGetIndexAttrBitmap are
|
||||||
* offset (to handle system columns the usual way), while column list
|
* offset (to handle system columns the usual way), while column list
|
||||||
* does not use offset, so we can't do bms_is_subset(). Instead, we have
|
* does not use offset, so we can't do bms_is_subset(). Instead, we
|
||||||
* to loop over the idattrs and check all of them are in the list.
|
* have to loop over the idattrs and check all of them are in the
|
||||||
|
* list.
|
||||||
*/
|
*/
|
||||||
x = -1;
|
x = -1;
|
||||||
while ((x = bms_next_member(idattrs, x)) >= 0)
|
while ((x = bms_next_member(idattrs, x)) >= 0)
|
||||||
@ -440,9 +441,9 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
|
|||||||
/*
|
/*
|
||||||
* If pubviaroot is true, we are validating the column list of the
|
* If pubviaroot is true, we are validating the column list of the
|
||||||
* parent table, but the bitmap contains the replica identity
|
* parent table, but the bitmap contains the replica identity
|
||||||
* information of the child table. The parent/child attnums may not
|
* information of the child table. The parent/child attnums may
|
||||||
* match, so translate them to the parent - get the attname from
|
* not match, so translate them to the parent - get the attname
|
||||||
* the child, and look it up in the parent.
|
* from the child, and look it up in the parent.
|
||||||
*/
|
*/
|
||||||
if (pubviaroot)
|
if (pubviaroot)
|
||||||
{
|
{
|
||||||
@ -1217,8 +1218,8 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
|
|||||||
newrelid = RelationGetRelid(newpubrel->relation);
|
newrelid = RelationGetRelid(newpubrel->relation);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the new publication has column list, transform it to
|
* If the new publication has column list, transform it to a
|
||||||
* a bitmap too.
|
* bitmap too.
|
||||||
*/
|
*/
|
||||||
if (newpubrel->columns)
|
if (newpubrel->columns)
|
||||||
{
|
{
|
||||||
|
@ -297,6 +297,7 @@ CreateStatistics(CreateStatsStmt *stmt)
|
|||||||
while ((k = bms_next_member(attnums, k)) >= 0)
|
while ((k = bms_next_member(attnums, k)) >= 0)
|
||||||
{
|
{
|
||||||
AttrNumber attnum = k + FirstLowInvalidHeapAttributeNumber;
|
AttrNumber attnum = k + FirstLowInvalidHeapAttributeNumber;
|
||||||
|
|
||||||
if (attnum <= 0)
|
if (attnum <= 0)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
@ -511,9 +512,9 @@ CreateStatistics(CreateStatsStmt *stmt)
|
|||||||
relation_close(statrel, RowExclusiveLock);
|
relation_close(statrel, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We used to create the pg_statistic_ext_data tuple too, but it's not clear
|
* We used to create the pg_statistic_ext_data tuple too, but it's not
|
||||||
* what value should the stxdinherit flag have (it depends on whether the rel
|
* clear what value should the stxdinherit flag have (it depends on
|
||||||
* is partitioned, contains data, etc.)
|
* whether the rel is partitioned, contains data, etc.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
InvokeObjectPostCreateHook(StatisticExtRelationId, statoid, 0);
|
InvokeObjectPostCreateHook(StatisticExtRelationId, statoid, 0);
|
||||||
|
@ -1578,13 +1578,13 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
|
|||||||
PG_END_TRY();
|
PG_END_TRY();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tell the cumulative stats system that the subscription is getting dropped.
|
* Tell the cumulative stats system that the subscription is getting
|
||||||
* We can safely report dropping the subscription statistics here if the
|
* dropped. We can safely report dropping the subscription statistics here
|
||||||
* subscription is associated with a replication slot since we cannot run
|
* if the subscription is associated with a replication slot since we
|
||||||
* DROP SUBSCRIPTION inside a transaction block. Subscription statistics
|
* cannot run DROP SUBSCRIPTION inside a transaction block. Subscription
|
||||||
* will be removed later by (auto)vacuum either if it's not associated
|
* statistics will be removed later by (auto)vacuum either if it's not
|
||||||
* with a replication slot or if the message for dropping the subscription
|
* associated with a replication slot or if the message for dropping the
|
||||||
* gets lost.
|
* subscription gets lost.
|
||||||
*/
|
*/
|
||||||
if (slotname)
|
if (slotname)
|
||||||
pgstat_drop_subscription(subid);
|
pgstat_drop_subscription(subid);
|
||||||
|
@ -9463,6 +9463,7 @@ validateFkOnDeleteSetColumns(int numfks, const int16 *fkattnums,
|
|||||||
if (!seen)
|
if (!seen)
|
||||||
{
|
{
|
||||||
char *col = strVal(list_nth(fksetcols, i));
|
char *col = strVal(list_nth(fksetcols, i));
|
||||||
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||||
errmsg("column \"%s\" referenced in ON DELETE SET action must be part of foreign key", col)));
|
errmsg("column \"%s\" referenced in ON DELETE SET action must be part of foreign key", col)));
|
||||||
@ -15890,6 +15891,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
|
|||||||
CatalogTupleUpdate(pg_index, &pg_index_tuple->t_self, pg_index_tuple);
|
CatalogTupleUpdate(pg_index, &pg_index_tuple->t_self, pg_index_tuple);
|
||||||
InvokeObjectPostAlterHookArg(IndexRelationId, thisIndexOid, 0,
|
InvokeObjectPostAlterHookArg(IndexRelationId, thisIndexOid, 0,
|
||||||
InvalidOid, is_internal);
|
InvalidOid, is_internal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Invalidate the relcache for the table, so that after we commit
|
* Invalidate the relcache for the table, so that after we commit
|
||||||
* all sessions will refresh the table's replica identity index
|
* all sessions will refresh the table's replica identity index
|
||||||
@ -17931,8 +17933,8 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd,
|
|||||||
/*
|
/*
|
||||||
* If the partition we just attached is partitioned itself, invalidate
|
* If the partition we just attached is partitioned itself, invalidate
|
||||||
* relcache for all descendent partitions too to ensure that their
|
* relcache for all descendent partitions too to ensure that their
|
||||||
* rd_partcheck expression trees are rebuilt; partitions already locked
|
* rd_partcheck expression trees are rebuilt; partitions already locked at
|
||||||
* at the beginning of this function.
|
* the beginning of this function.
|
||||||
*/
|
*/
|
||||||
if (attachrel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
if (attachrel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||||
{
|
{
|
||||||
@ -18652,9 +18654,9 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
|
|||||||
/*
|
/*
|
||||||
* If the partition we just detached is partitioned itself, invalidate
|
* If the partition we just detached is partitioned itself, invalidate
|
||||||
* relcache for all descendent partitions too to ensure that their
|
* relcache for all descendent partitions too to ensure that their
|
||||||
* rd_partcheck expression trees are rebuilt; must lock partitions
|
* rd_partcheck expression trees are rebuilt; must lock partitions before
|
||||||
* before doing so, using the same lockmode as what partRel has been
|
* doing so, using the same lockmode as what partRel has been locked with
|
||||||
* locked with by the caller.
|
* by the caller.
|
||||||
*/
|
*/
|
||||||
if (partRel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
if (partRel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||||
{
|
{
|
||||||
|
@ -3978,8 +3978,8 @@ ExecEvalJsonIsPredicate(ExprState *state, ExprEvalStep *op)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do full parsing pass only for uniqueness check or for
|
* Do full parsing pass only for uniqueness check or for JSON text
|
||||||
* JSON text validation.
|
* validation.
|
||||||
*/
|
*/
|
||||||
if (res && (pred->unique_keys || exprtype == TEXTOID))
|
if (res && (pred->unique_keys || exprtype == TEXTOID))
|
||||||
res = json_validate(json, pred->unique_keys, false);
|
res = json_validate(json, pred->unique_keys, false);
|
||||||
@ -4751,8 +4751,7 @@ ExecPrepareJsonItemCoercion(JsonbValue *item,
|
|||||||
|
|
||||||
case jbvString:
|
case jbvString:
|
||||||
coercion = &coercions->string;
|
coercion = &coercions->string;
|
||||||
res = PointerGetDatum(
|
res = PointerGetDatum(cstring_to_text_with_len(item->val.string.val,
|
||||||
cstring_to_text_with_len(item->val.string.val,
|
|
||||||
item->val.string.len));
|
item->val.string.len));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4826,8 +4825,8 @@ ExecEvalJsonExprSubtrans(JsonFunc func, ExprEvalStep *op,
|
|||||||
return func(op, econtext, res, resnull, p, error);
|
return func(op, econtext, res, resnull, p, error);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We should catch exceptions of category ERRCODE_DATA_EXCEPTION
|
* We should catch exceptions of category ERRCODE_DATA_EXCEPTION and
|
||||||
* and execute the corresponding ON ERROR behavior then.
|
* execute the corresponding ON ERROR behavior then.
|
||||||
*/
|
*/
|
||||||
oldcontext = CurrentMemoryContext;
|
oldcontext = CurrentMemoryContext;
|
||||||
oldowner = CurrentResourceOwner;
|
oldowner = CurrentResourceOwner;
|
||||||
@ -4864,7 +4863,8 @@ ExecEvalJsonExprSubtrans(JsonFunc func, ExprEvalStep *op,
|
|||||||
|
|
||||||
ecategory = ERRCODE_TO_CATEGORY(edata->sqlerrcode);
|
ecategory = ERRCODE_TO_CATEGORY(edata->sqlerrcode);
|
||||||
|
|
||||||
if (ecategory != ERRCODE_DATA_EXCEPTION && /* jsonpath and other data errors */
|
if (ecategory != ERRCODE_DATA_EXCEPTION && /* jsonpath and other data
|
||||||
|
* errors */
|
||||||
ecategory != ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION) /* domain errors */
|
ecategory != ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION) /* domain errors */
|
||||||
ReThrowError(edata);
|
ReThrowError(edata);
|
||||||
|
|
||||||
@ -4949,15 +4949,17 @@ ExecEvalJsonExpr(ExprEvalStep *op, ExprContext *econtext,
|
|||||||
*error = true;
|
*error = true;
|
||||||
return (Datum) 0;
|
return (Datum) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Coercion via I/O means here that the cast to the target
|
* Coercion via I/O means here that the cast to the target
|
||||||
* type simply does not exist.
|
* type simply does not exist.
|
||||||
*/
|
*/
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX Standard says about a separate error code
|
* XXX Standard says about a separate error code
|
||||||
* ERRCODE_SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE
|
* ERRCODE_SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE but
|
||||||
* but does not define its number.
|
* does not define its number.
|
||||||
*/
|
*/
|
||||||
(errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
|
(errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
|
||||||
errmsg("SQL/JSON item cannot be cast to target type")));
|
errmsg("SQL/JSON item cannot be cast to target type")));
|
||||||
@ -5018,6 +5020,7 @@ ExecEvalJsonExpr(ExprEvalStep *op, ExprContext *econtext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (jexpr->on_empty->btype == JSON_BEHAVIOR_DEFAULT)
|
if (jexpr->on_empty->btype == JSON_BEHAVIOR_DEFAULT)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Execute DEFAULT expression as a coercion expression, because
|
* Execute DEFAULT expression as a coercion expression, because
|
||||||
* its result is already coerced to the target type.
|
* its result is already coerced to the target type.
|
||||||
|
@ -575,6 +575,7 @@ ExecReScanIndexScan(IndexScanState *node)
|
|||||||
if (node->iss_ReorderQueue)
|
if (node->iss_ReorderQueue)
|
||||||
{
|
{
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
while (!pairingheap_is_empty(node->iss_ReorderQueue))
|
while (!pairingheap_is_empty(node->iss_ReorderQueue))
|
||||||
{
|
{
|
||||||
tuple = reorderqueue_pop(node);
|
tuple = reorderqueue_pop(node);
|
||||||
|
@ -890,8 +890,8 @@ llvm_shutdown(int code, Datum arg)
|
|||||||
* has occurred in the middle of LLVM code. It is not safe to call back
|
* has occurred in the middle of LLVM code. It is not safe to call back
|
||||||
* into LLVM (which is why a FATAL error was thrown).
|
* into LLVM (which is why a FATAL error was thrown).
|
||||||
*
|
*
|
||||||
* We do need to shutdown LLVM in other shutdown cases, otherwise
|
* We do need to shutdown LLVM in other shutdown cases, otherwise e.g.
|
||||||
* e.g. profiling data won't be written out.
|
* profiling data won't be written out.
|
||||||
*/
|
*/
|
||||||
if (llvm_in_fatal_on_oom())
|
if (llvm_in_fatal_on_oom())
|
||||||
{
|
{
|
||||||
|
@ -634,9 +634,9 @@ dshash_seq_next(dshash_seq_status *status)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Not yet holding any partition locks. Need to determine the size of the
|
* Not yet holding any partition locks. Need to determine the size of the
|
||||||
* hash table, it could have been resized since we were looking
|
* hash table, it could have been resized since we were looking last.
|
||||||
* last. Since we iterate in partition order, we can start by
|
* Since we iterate in partition order, we can start by unconditionally
|
||||||
* unconditionally lock partition 0.
|
* lock partition 0.
|
||||||
*
|
*
|
||||||
* Once we hold the lock, no resizing can happen until the scan ends. So
|
* Once we hold the lock, no resizing can happen until the scan ends. So
|
||||||
* we don't need to repeatedly call ensure_valid_bucket_pointers().
|
* we don't need to repeatedly call ensure_valid_bucket_pointers().
|
||||||
|
@ -2802,8 +2802,7 @@ static bool
|
|||||||
_equalA_Const(const A_Const *a, const A_Const *b)
|
_equalA_Const(const A_Const *a, const A_Const *b)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Hack for in-line val field. Also val is not valid is isnull is
|
* Hack for in-line val field. Also val is not valid is isnull is true.
|
||||||
* true.
|
|
||||||
*/
|
*/
|
||||||
if (!a->isnull && !b->isnull &&
|
if (!a->isnull && !b->isnull &&
|
||||||
!equal(&a->val, &b->val))
|
!equal(&a->val, &b->val))
|
||||||
|
@ -1239,7 +1239,8 @@ exprSetCollation(Node *expr, Oid collation)
|
|||||||
if (ctor->coercion)
|
if (ctor->coercion)
|
||||||
exprSetCollation((Node *) ctor->coercion, collation);
|
exprSetCollation((Node *) ctor->coercion, collation);
|
||||||
else
|
else
|
||||||
Assert(!OidIsValid(collation)); /* result is always a json[b] type */
|
Assert(!OidIsValid(collation)); /* result is always a
|
||||||
|
* json[b] type */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case T_JsonIsPredicate:
|
case T_JsonIsPredicate:
|
||||||
|
@ -3613,8 +3613,8 @@ static void
|
|||||||
_outFloat(StringInfo str, const Float *node)
|
_outFloat(StringInfo str, const Float *node)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We assume the value is a valid numeric literal and so does not
|
* We assume the value is a valid numeric literal and so does not need
|
||||||
* need quoting.
|
* quoting.
|
||||||
*/
|
*/
|
||||||
appendStringInfoString(str, node->fval);
|
appendStringInfoString(str, node->fval);
|
||||||
}
|
}
|
||||||
@ -3629,8 +3629,8 @@ static void
|
|||||||
_outString(StringInfo str, const String *node)
|
_outString(StringInfo str, const String *node)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We use outToken to provide escaping of the string's content,
|
* We use outToken to provide escaping of the string's content, but we
|
||||||
* but we don't want it to do anything with an empty string.
|
* don't want it to do anything with an empty string.
|
||||||
*/
|
*/
|
||||||
appendStringInfoChar(str, '"');
|
appendStringInfoChar(str, '"');
|
||||||
if (node->sval[0] != '\0')
|
if (node->sval[0] != '\0')
|
||||||
|
@ -1777,10 +1777,11 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When building a fractional path, determine a cheapest fractional
|
* When building a fractional path, determine a cheapest
|
||||||
* path for each child relation too. Looking at startup and total
|
* fractional path for each child relation too. Looking at startup
|
||||||
* costs is not enough, because the cheapest fractional path may be
|
* and total costs is not enough, because the cheapest fractional
|
||||||
* dominated by two separate paths (one for startup, one for total).
|
* path may be dominated by two separate paths (one for startup,
|
||||||
|
* one for total).
|
||||||
*
|
*
|
||||||
* When needed (building fractional path), determine the cheapest
|
* When needed (building fractional path), determine the cheapest
|
||||||
* fractional path too.
|
* fractional path too.
|
||||||
@ -1796,8 +1797,8 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
|
|||||||
path_fraction);
|
path_fraction);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we found no path with matching pathkeys, use the cheapest
|
* If we found no path with matching pathkeys, use the
|
||||||
* total path instead.
|
* cheapest total path instead.
|
||||||
*
|
*
|
||||||
* XXX We might consider partially sorted paths too (with an
|
* XXX We might consider partially sorted paths too (with an
|
||||||
* incremental sort on top). But we'd have to build all the
|
* incremental sort on top). But we'd have to build all the
|
||||||
|
@ -1832,17 +1832,17 @@ get_width_cost_multiplier(PlannerInfo *root, Expr *expr)
|
|||||||
* Values are passed as Datum type, so comparisons can't be cheaper than
|
* Values are passed as Datum type, so comparisons can't be cheaper than
|
||||||
* comparing a Datum value.
|
* comparing a Datum value.
|
||||||
*
|
*
|
||||||
* FIXME I find this reasoning questionable. We may pass int2, and comparing
|
* FIXME I find this reasoning questionable. We may pass int2, and
|
||||||
* it is probably a bit cheaper than comparing a bigint.
|
* comparing it is probably a bit cheaper than comparing a bigint.
|
||||||
*/
|
*/
|
||||||
if (width <= sizeof(Datum))
|
if (width <= sizeof(Datum))
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We consider the cost of a comparison not to be directly proportional to
|
* We consider the cost of a comparison not to be directly proportional to
|
||||||
* width of the argument, because widths of the arguments could be slightly
|
* width of the argument, because widths of the arguments could be
|
||||||
* different (we only know the average width for the whole column). So we
|
* slightly different (we only know the average width for the whole
|
||||||
* use log16(width) as an estimate.
|
* column). So we use log16(width) as an estimate.
|
||||||
*/
|
*/
|
||||||
return 1.0 + 0.125 * LOG2(width / sizeof(Datum));
|
return 1.0 + 0.125 * LOG2(width / sizeof(Datum));
|
||||||
}
|
}
|
||||||
@ -1915,10 +1915,10 @@ compute_cpu_sort_cost(PlannerInfo *root, List *pathkeys, int nPresortedKeys,
|
|||||||
if (list_length(pathkeys) == 0)
|
if (list_length(pathkeys) == 0)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If we'll use a bounded heap-sort keeping just K tuples in memory, for
|
* If we'll use a bounded heap-sort keeping just K tuples in memory,
|
||||||
* a total number of tuple comparisons of N log2 K; but the constant
|
* for a total number of tuple comparisons of N log2 K; but the
|
||||||
* factor is a bit higher than for quicksort. Tweak it so that the cost
|
* constant factor is a bit higher than for quicksort. Tweak it so
|
||||||
* curve is continuous at the crossover point.
|
* that the cost curve is continuous at the crossover point.
|
||||||
*/
|
*/
|
||||||
output_tuples = (heapSort) ? 2.0 * output_tuples : tuples;
|
output_tuples = (heapSort) ? 2.0 * output_tuples : tuples;
|
||||||
per_tuple_cost += 2.0 * cpu_operator_cost * LOG2(output_tuples);
|
per_tuple_cost += 2.0 * cpu_operator_cost * LOG2(output_tuples);
|
||||||
@ -1930,9 +1930,9 @@ compute_cpu_sort_cost(PlannerInfo *root, List *pathkeys, int nPresortedKeys,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Computing total cost of sorting takes into account:
|
* Computing total cost of sorting takes into account the per-column
|
||||||
* - per column comparison function cost
|
* comparison function cost. We try to compute the needed number of
|
||||||
* - we try to compute needed number of comparison per column
|
* comparisons per column.
|
||||||
*/
|
*/
|
||||||
foreach(lc, pathkeys)
|
foreach(lc, pathkeys)
|
||||||
{
|
{
|
||||||
@ -1985,10 +1985,10 @@ compute_cpu_sort_cost(PlannerInfo *root, List *pathkeys, int nPresortedKeys,
|
|||||||
pathkeyExprs = lappend(pathkeyExprs, em->em_expr);
|
pathkeyExprs = lappend(pathkeyExprs, em->em_expr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to calculate the number of comparisons for this column, which
|
* We need to calculate the number of comparisons for this column,
|
||||||
* requires knowing the group size. So we estimate the number of groups
|
* which requires knowing the group size. So we estimate the number of
|
||||||
* by calling estimate_num_groups_incremental(), which estimates the
|
* groups by calling estimate_num_groups_incremental(), which
|
||||||
* group size for "new" pathkeys.
|
* estimates the group size for "new" pathkeys.
|
||||||
*
|
*
|
||||||
* Note: estimate_num_groups_incremental does not handle fake Vars, so
|
* Note: estimate_num_groups_incremental does not handle fake Vars, so
|
||||||
* use a default estimate otherwise.
|
* use a default estimate otherwise.
|
||||||
@ -1999,26 +1999,30 @@ compute_cpu_sort_cost(PlannerInfo *root, List *pathkeys, int nPresortedKeys,
|
|||||||
&cache_varinfos,
|
&cache_varinfos,
|
||||||
list_length(pathkeyExprs) - 1);
|
list_length(pathkeyExprs) - 1);
|
||||||
else if (tuples > 4.0)
|
else if (tuples > 4.0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use geometric mean as estimation if there are no stats.
|
* Use geometric mean as estimation if there are no stats.
|
||||||
*
|
*
|
||||||
* We don't use DEFAULT_NUM_DISTINCT here, because that’s used for
|
* We don't use DEFAULT_NUM_DISTINCT here, because that's used for
|
||||||
* a single column, but here we’re dealing with multiple columns.
|
* a single column, but here we're dealing with multiple columns.
|
||||||
*/
|
*/
|
||||||
nGroups = ceil(2.0 + sqrt(tuples) * (i + 1) / list_length(pathkeys));
|
nGroups = ceil(2.0 + sqrt(tuples) * (i + 1) / list_length(pathkeys));
|
||||||
else
|
else
|
||||||
nGroups = tuples;
|
nGroups = tuples;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Presorted keys are not considered in the cost above, but we still do
|
* Presorted keys are not considered in the cost above, but we still
|
||||||
* have to compare them in the qsort comparator. So make sure to factor
|
* do have to compare them in the qsort comparator. So make sure to
|
||||||
* in the cost in that case.
|
* factor in the cost in that case.
|
||||||
*/
|
*/
|
||||||
if (i >= nPresortedKeys)
|
if (i >= nPresortedKeys)
|
||||||
{
|
{
|
||||||
if (heapSort)
|
if (heapSort)
|
||||||
{
|
{
|
||||||
/* have to keep at least one group, and a multiple of group size */
|
/*
|
||||||
|
* have to keep at least one group, and a multiple of group
|
||||||
|
* size
|
||||||
|
*/
|
||||||
correctedNGroups = ceil(output_tuples / tuplesPerPrevGroup);
|
correctedNGroups = ceil(output_tuples / tuplesPerPrevGroup);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2033,19 +2037,20 @@ compute_cpu_sort_cost(PlannerInfo *root, List *pathkeys, int nPresortedKeys,
|
|||||||
i++;
|
i++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Uniform distributions with all groups being of the same size are the
|
* Uniform distributions with all groups being of the same size are
|
||||||
* best case, with nice smooth behavior. Real-world distributions tend
|
* the best case, with nice smooth behavior. Real-world distributions
|
||||||
* not to be uniform, though, and we don’t have any reliable easy-to-use
|
* tend not to be uniform, though, and we don't have any reliable
|
||||||
* information. As a basic defense against skewed distributions, we use
|
* easy-to-use information. As a basic defense against skewed
|
||||||
* a 1.5 factor to make the expected group a bit larger, but we need to
|
* distributions, we use a 1.5 factor to make the expected group a bit
|
||||||
* be careful not to make the group larger than in the preceding step.
|
* larger, but we need to be careful not to make the group larger than
|
||||||
|
* in the preceding step.
|
||||||
*/
|
*/
|
||||||
tuplesPerPrevGroup = Min(tuplesPerPrevGroup,
|
tuplesPerPrevGroup = Min(tuplesPerPrevGroup,
|
||||||
ceil(1.5 * tuplesPerPrevGroup / nGroups));
|
ceil(1.5 * tuplesPerPrevGroup / nGroups));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Once we get single-row group, it means tuples in the group are unique
|
* Once we get single-row group, it means tuples in the group are
|
||||||
* and we can skip all remaining columns.
|
* unique and we can skip all remaining columns.
|
||||||
*/
|
*/
|
||||||
if (tuplesPerPrevGroup <= 1.0)
|
if (tuplesPerPrevGroup <= 1.0)
|
||||||
break;
|
break;
|
||||||
@ -2057,15 +2062,15 @@ compute_cpu_sort_cost(PlannerInfo *root, List *pathkeys, int nPresortedKeys,
|
|||||||
per_tuple_cost *= cpu_operator_cost;
|
per_tuple_cost *= cpu_operator_cost;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Accordingly to "Introduction to algorithms", Thomas H. Cormen, Charles E.
|
* Accordingly to "Introduction to algorithms", Thomas H. Cormen, Charles
|
||||||
* Leiserson, Ronald L. Rivest, ISBN 0-07-013143-0, quicksort estimation
|
* E. Leiserson, Ronald L. Rivest, ISBN 0-07-013143-0, quicksort
|
||||||
* formula has additional term proportional to number of tuples (See Chapter
|
* estimation formula has additional term proportional to number of tuples
|
||||||
* 8.2 and Theorem 4.1). That affects cases with a low number of tuples,
|
* (see Chapter 8.2 and Theorem 4.1). That affects cases with a low number
|
||||||
* approximately less than 1e4. We could implement it as an additional
|
* of tuples, approximately less than 1e4. We could implement it as an
|
||||||
* multiplier under the logarithm, but we use a bit more complex formula
|
* additional multiplier under the logarithm, but we use a bit more
|
||||||
* which takes into account the number of unique tuples and it’s not clear
|
* complex formula which takes into account the number of unique tuples
|
||||||
* how to combine the multiplier with the number of groups. Estimate it as
|
* and it's not clear how to combine the multiplier with the number of
|
||||||
* 10 in cpu_operator_cost unit.
|
* groups. Estimate it as 10 cpu_operator_cost units.
|
||||||
*/
|
*/
|
||||||
per_tuple_cost += 10 * cpu_operator_cost;
|
per_tuple_cost += 10 * cpu_operator_cost;
|
||||||
|
|
||||||
|
@ -685,9 +685,9 @@ get_eclass_for_sort_expr(PlannerInfo *root,
|
|||||||
/*
|
/*
|
||||||
* Match!
|
* Match!
|
||||||
*
|
*
|
||||||
* Copy the sortref if it wasn't set yet. That may happen if the
|
* Copy the sortref if it wasn't set yet. That may happen if
|
||||||
* ec was constructed from WHERE clause, i.e. it doesn't have a
|
* the ec was constructed from WHERE clause, i.e. it doesn't
|
||||||
* target reference at all.
|
* have a target reference at all.
|
||||||
*/
|
*/
|
||||||
if (cur_ec->ec_sortref == 0 && sortref > 0)
|
if (cur_ec->ec_sortref == 0 && sortref > 0)
|
||||||
cur_ec->ec_sortref = sortref;
|
cur_ec->ec_sortref = sortref;
|
||||||
|
@ -365,9 +365,9 @@ group_keys_reorder_by_pathkeys(List *pathkeys, List **group_pathkeys,
|
|||||||
* there's a matching GROUP BY key. If we find one, we append it to the
|
* there's a matching GROUP BY key. If we find one, we append it to the
|
||||||
* list, and do the same for the clauses.
|
* list, and do the same for the clauses.
|
||||||
*
|
*
|
||||||
* Once we find the first pathkey without a matching GROUP BY key, the rest
|
* Once we find the first pathkey without a matching GROUP BY key, the
|
||||||
* of the pathkeys are useless and can't be used to evaluate the grouping,
|
* rest of the pathkeys are useless and can't be used to evaluate the
|
||||||
* so we abort the loop and ignore the remaining pathkeys.
|
* grouping, so we abort the loop and ignore the remaining pathkeys.
|
||||||
*
|
*
|
||||||
* XXX Pathkeys are built in a way to allow simply comparing pointers.
|
* XXX Pathkeys are built in a way to allow simply comparing pointers.
|
||||||
*/
|
*/
|
||||||
@ -403,7 +403,8 @@ group_keys_reorder_by_pathkeys(List *pathkeys, List **group_pathkeys,
|
|||||||
/*
|
/*
|
||||||
* Used to generate all permutations of a pathkey list.
|
* Used to generate all permutations of a pathkey list.
|
||||||
*/
|
*/
|
||||||
typedef struct PathkeyMutatorState {
|
typedef struct PathkeyMutatorState
|
||||||
|
{
|
||||||
List *elemsList;
|
List *elemsList;
|
||||||
ListCell **elemCells;
|
ListCell **elemCells;
|
||||||
void **elems;
|
void **elems;
|
||||||
@ -471,7 +472,10 @@ PathkeyMutatorSwap(int *a, int i, int j)
|
|||||||
static bool
|
static bool
|
||||||
PathkeyMutatorNextSet(int *a, int n)
|
PathkeyMutatorNextSet(int *a, int n)
|
||||||
{
|
{
|
||||||
int j, k, l, r;
|
int j,
|
||||||
|
k,
|
||||||
|
l,
|
||||||
|
r;
|
||||||
|
|
||||||
j = n - 2;
|
j = n - 2;
|
||||||
|
|
||||||
@ -597,19 +601,20 @@ get_cheapest_group_keys_order(PlannerInfo *root, double nrows,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We could exhaustively cost all possible orderings of the pathkeys, but for
|
* We could exhaustively cost all possible orderings of the pathkeys, but
|
||||||
* a large number of pathkeys it might be prohibitively expensive. So we try
|
* for a large number of pathkeys it might be prohibitively expensive. So
|
||||||
* to apply simple cheap heuristics first - we sort the pathkeys by sort cost
|
* we try to apply simple cheap heuristics first - we sort the pathkeys by
|
||||||
* (as if the pathkey was sorted independently) and then check only the four
|
* sort cost (as if the pathkey was sorted independently) and then check
|
||||||
* cheapest pathkeys. The remaining pathkeys are kept ordered by cost.
|
* only the four cheapest pathkeys. The remaining pathkeys are kept
|
||||||
|
* ordered by cost.
|
||||||
*
|
*
|
||||||
* XXX This is a very simple heuristics, but likely to work fine for most
|
* XXX This is a very simple heuristics, but likely to work fine for most
|
||||||
* cases (because the number of GROUP BY clauses tends to be lower than 4).
|
* cases (because the number of GROUP BY clauses tends to be lower than
|
||||||
* But it ignores how the number of distinct values in each pathkey affects
|
* 4). But it ignores how the number of distinct values in each pathkey
|
||||||
* the following steps. It might be better to use "more expensive" pathkey
|
* affects the following steps. It might be better to use "more expensive"
|
||||||
* first if it has many distinct values, because it then limits the number
|
* pathkey first if it has many distinct values, because it then limits
|
||||||
* of comparisons for the remaining pathkeys. But evaluating that is likely
|
* the number of comparisons for the remaining pathkeys. But evaluating
|
||||||
* quite the expensive.
|
* that is likely quite the expensive.
|
||||||
*/
|
*/
|
||||||
nFreeKeys = list_length(*group_pathkeys) - n_preordered;
|
nFreeKeys = list_length(*group_pathkeys) - n_preordered;
|
||||||
nToPermute = 4;
|
nToPermute = 4;
|
||||||
@ -658,22 +663,23 @@ get_cheapest_group_keys_order(PlannerInfo *root, double nrows,
|
|||||||
Assert(list_length(new_group_pathkeys) == list_length(*group_pathkeys));
|
Assert(list_length(new_group_pathkeys) == list_length(*group_pathkeys));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate pathkey lists with permutations of the first nToPermute pathkeys.
|
* Generate pathkey lists with permutations of the first nToPermute
|
||||||
|
* pathkeys.
|
||||||
*
|
*
|
||||||
* XXX We simply calculate sort cost for each individual pathkey list, but
|
* XXX We simply calculate sort cost for each individual pathkey list, but
|
||||||
* there's room for two dynamic programming optimizations here. Firstly, we
|
* there's room for two dynamic programming optimizations here. Firstly,
|
||||||
* may pass the current "best" cost to cost_sort_estimate so that it can
|
* we may pass the current "best" cost to cost_sort_estimate so that it
|
||||||
* "abort" if the estimated pathkeys list exceeds it. Secondly, it could pass
|
* can "abort" if the estimated pathkeys list exceeds it. Secondly, it
|
||||||
* the return information about the position when it exceeded the cost, and
|
* could pass the return information about the position when it exceeded
|
||||||
* we could skip all permutations with the same prefix.
|
* the cost, and we could skip all permutations with the same prefix.
|
||||||
*
|
*
|
||||||
* Imagine we've already found ordering with cost C1, and we're evaluating
|
* Imagine we've already found ordering with cost C1, and we're evaluating
|
||||||
* another ordering - cost_sort_estimate() calculates cost by adding the
|
* another ordering - cost_sort_estimate() calculates cost by adding the
|
||||||
* pathkeys one by one (more or less), and the cost only grows. If at any
|
* pathkeys one by one (more or less), and the cost only grows. If at any
|
||||||
* point it exceeds C1, it can't possibly be "better" so we can discard it.
|
* point it exceeds C1, it can't possibly be "better" so we can discard
|
||||||
* But we also know that we can discard all ordering with the same prefix,
|
* it. But we also know that we can discard all ordering with the same
|
||||||
* because if we're estimating (a,b,c,d) and we exceed C1 at (a,b) then the
|
* prefix, because if we're estimating (a,b,c,d) and we exceed C1 at (a,b)
|
||||||
* same thing will happen for any ordering with this prefix.
|
* then the same thing will happen for any ordering with this prefix.
|
||||||
*/
|
*/
|
||||||
PathkeyMutatorInit(&mstate, new_group_pathkeys, n_preordered, n_preordered + nToPermute);
|
PathkeyMutatorInit(&mstate, new_group_pathkeys, n_preordered, n_preordered + nToPermute);
|
||||||
|
|
||||||
@ -756,9 +762,9 @@ get_useful_group_keys_orderings(PlannerInfo *root, double nrows,
|
|||||||
infos = lappend(infos, info);
|
infos = lappend(infos, info);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Should we try generating alternative orderings of the group keys? If not,
|
* Should we try generating alternative orderings of the group keys? If
|
||||||
* we produce only the order specified in the query, i.e. the optimization
|
* not, we produce only the order specified in the query, i.e. the
|
||||||
* is effectively disabled.
|
* optimization is effectively disabled.
|
||||||
*/
|
*/
|
||||||
if (!enable_group_by_reordering)
|
if (!enable_group_by_reordering)
|
||||||
return infos;
|
return infos;
|
||||||
@ -782,8 +788,9 @@ get_useful_group_keys_orderings(PlannerInfo *root, double nrows,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the path is sorted in some way, try reordering the group keys to match
|
* If the path is sorted in some way, try reordering the group keys to
|
||||||
* as much of the ordering as possible - we get this sort for free (mostly).
|
* match as much of the ordering as possible - we get this sort for free
|
||||||
|
* (mostly).
|
||||||
*
|
*
|
||||||
* We must not do this when there are no grouping sets, because those use
|
* We must not do this when there are no grouping sets, because those use
|
||||||
* more complex logic to decide the ordering.
|
* more complex logic to decide the ordering.
|
||||||
|
@ -1162,8 +1162,8 @@ mark_async_capable_plan(Plan *plan, Path *path)
|
|||||||
case T_ProjectionPath:
|
case T_ProjectionPath:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the generated plan node includes a Result node for
|
* If the generated plan node includes a Result node for the
|
||||||
* the projection, we can't execute it asynchronously.
|
* projection, we can't execute it asynchronously.
|
||||||
*/
|
*/
|
||||||
if (IsA(plan, Result))
|
if (IsA(plan, Result))
|
||||||
return false;
|
return false;
|
||||||
|
@ -6283,8 +6283,8 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
|
|||||||
else if (parse->hasAggs)
|
else if (parse->hasAggs)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We have aggregation, possibly with plain GROUP BY. Make
|
* We have aggregation, possibly with plain GROUP BY.
|
||||||
* an AggPath.
|
* Make an AggPath.
|
||||||
*/
|
*/
|
||||||
add_path(grouped_rel, (Path *)
|
add_path(grouped_rel, (Path *)
|
||||||
create_agg_path(root,
|
create_agg_path(root,
|
||||||
@ -6301,8 +6301,8 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
|
|||||||
else if (group_clauses)
|
else if (group_clauses)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We have GROUP BY without aggregation or grouping sets.
|
* We have GROUP BY without aggregation or grouping
|
||||||
* Make a GroupPath.
|
* sets. Make a GroupPath.
|
||||||
*/
|
*/
|
||||||
add_path(grouped_rel, (Path *)
|
add_path(grouped_rel, (Path *)
|
||||||
create_group_path(root,
|
create_group_path(root,
|
||||||
@ -6321,8 +6321,8 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we may consider incremental sort on this path, but only
|
* Now we may consider incremental sort on this path, but only
|
||||||
* when the path is not already sorted and when incremental sort
|
* when the path is not already sorted and when incremental
|
||||||
* is enabled.
|
* sort is enabled.
|
||||||
*/
|
*/
|
||||||
if (is_sorted || !enable_incremental_sort)
|
if (is_sorted || !enable_incremental_sort)
|
||||||
continue;
|
continue;
|
||||||
@ -6335,8 +6335,9 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We should have already excluded pathkeys of length 1 because
|
* We should have already excluded pathkeys of length 1
|
||||||
* then presorted_keys > 0 would imply is_sorted was true.
|
* because then presorted_keys > 0 would imply is_sorted was
|
||||||
|
* true.
|
||||||
*/
|
*/
|
||||||
Assert(list_length(root->group_pathkeys) != 1);
|
Assert(list_length(root->group_pathkeys) != 1);
|
||||||
|
|
||||||
@ -6357,8 +6358,8 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
|
|||||||
else if (parse->hasAggs)
|
else if (parse->hasAggs)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We have aggregation, possibly with plain GROUP BY. Make an
|
* We have aggregation, possibly with plain GROUP BY. Make
|
||||||
* AggPath.
|
* an AggPath.
|
||||||
*/
|
*/
|
||||||
add_path(grouped_rel, (Path *)
|
add_path(grouped_rel, (Path *)
|
||||||
create_agg_path(root,
|
create_agg_path(root,
|
||||||
@ -6375,8 +6376,8 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
|
|||||||
else if (parse->groupClause)
|
else if (parse->groupClause)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We have GROUP BY without aggregation or grouping sets. Make
|
* We have GROUP BY without aggregation or grouping sets.
|
||||||
* a GroupPath.
|
* Make a GroupPath.
|
||||||
*/
|
*/
|
||||||
add_path(grouped_rel, (Path *)
|
add_path(grouped_rel, (Path *)
|
||||||
create_group_path(root,
|
create_group_path(root,
|
||||||
@ -6435,8 +6436,8 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
|
|||||||
&presorted_keys);
|
&presorted_keys);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert a Sort node, if required. But there's no point in
|
* Insert a Sort node, if required. But there's no point
|
||||||
* sorting anything but the cheapest path.
|
* in sorting anything but the cheapest path.
|
||||||
*/
|
*/
|
||||||
if (!is_sorted)
|
if (!is_sorted)
|
||||||
{
|
{
|
||||||
@ -6471,24 +6472,30 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
|
|||||||
dNumGroups));
|
dNumGroups));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we may consider incremental sort on this path, but only
|
* Now we may consider incremental sort on this path, but
|
||||||
* when the path is not already sorted and when incremental
|
* only when the path is not already sorted and when
|
||||||
* sort is enabled.
|
* incremental sort is enabled.
|
||||||
*/
|
*/
|
||||||
if (is_sorted || !enable_incremental_sort)
|
if (is_sorted || !enable_incremental_sort)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Restore the input path (we might have added Sort on top). */
|
/*
|
||||||
|
* Restore the input path (we might have added Sort on
|
||||||
|
* top).
|
||||||
|
*/
|
||||||
path = path_original;
|
path = path_original;
|
||||||
|
|
||||||
/* no shared prefix, not point in building incremental sort */
|
/*
|
||||||
|
* no shared prefix, not point in building incremental
|
||||||
|
* sort
|
||||||
|
*/
|
||||||
if (presorted_keys == 0)
|
if (presorted_keys == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We should have already excluded pathkeys of length 1
|
* We should have already excluded pathkeys of length 1
|
||||||
* because then presorted_keys > 0 would imply is_sorted was
|
* because then presorted_keys > 0 would imply is_sorted
|
||||||
* true.
|
* was true.
|
||||||
*/
|
*/
|
||||||
Assert(list_length(root->group_pathkeys) != 1);
|
Assert(list_length(root->group_pathkeys) != 1);
|
||||||
|
|
||||||
@ -6924,8 +6931,8 @@ create_partial_grouping_paths(PlannerInfo *root,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we may consider incremental sort on this path, but only
|
* Now we may consider incremental sort on this path, but only
|
||||||
* when the path is not already sorted and when incremental sort
|
* when the path is not already sorted and when incremental
|
||||||
* is enabled.
|
* sort is enabled.
|
||||||
*/
|
*/
|
||||||
if (is_sorted || !enable_incremental_sort)
|
if (is_sorted || !enable_incremental_sort)
|
||||||
continue;
|
continue;
|
||||||
@ -6938,8 +6945,9 @@ create_partial_grouping_paths(PlannerInfo *root,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We should have already excluded pathkeys of length 1 because
|
* We should have already excluded pathkeys of length 1
|
||||||
* then presorted_keys > 0 would imply is_sorted was true.
|
* because then presorted_keys > 0 would imply is_sorted was
|
||||||
|
* true.
|
||||||
*/
|
*/
|
||||||
Assert(list_length(root->group_pathkeys) != 1);
|
Assert(list_length(root->group_pathkeys) != 1);
|
||||||
|
|
||||||
|
@ -974,8 +974,8 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
|||||||
else if (rel->rd_rel->relkind == RELKIND_INDEX)
|
else if (rel->rd_rel->relkind == RELKIND_INDEX)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* XXX: It'd probably be good to move this into a callback,
|
* XXX: It'd probably be good to move this into a callback, individual
|
||||||
* individual index types e.g. know if they have a metapage.
|
* index types e.g. know if they have a metapage.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* it has storage, ok to call the smgr */
|
/* it has storage, ok to call the smgr */
|
||||||
@ -997,10 +997,10 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
|||||||
relallvisible = (BlockNumber) rel->rd_rel->relallvisible;
|
relallvisible = (BlockNumber) rel->rd_rel->relallvisible;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Discount the metapage while estimating the number of tuples.
|
* Discount the metapage while estimating the number of tuples. This
|
||||||
* This is a kluge because it assumes more than it ought to about
|
* is a kluge because it assumes more than it ought to about index
|
||||||
* index structure. Currently it's OK for btree, hash, and GIN
|
* structure. Currently it's OK for btree, hash, and GIN indexes but
|
||||||
* indexes but suspect for GiST indexes.
|
* suspect for GiST indexes.
|
||||||
*/
|
*/
|
||||||
if (relpages > 0)
|
if (relpages > 0)
|
||||||
{
|
{
|
||||||
@ -1015,18 +1015,18 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If we have no data because the relation was never vacuumed,
|
* If we have no data because the relation was never vacuumed,
|
||||||
* estimate tuple width from attribute datatypes. We assume
|
* estimate tuple width from attribute datatypes. We assume here
|
||||||
* here that the pages are completely full, which is OK for
|
* that the pages are completely full, which is OK for tables
|
||||||
* tables (since they've presumably not been VACUUMed yet) but
|
* (since they've presumably not been VACUUMed yet) but is
|
||||||
* is probably an overestimate for indexes. Fortunately
|
* probably an overestimate for indexes. Fortunately
|
||||||
* get_relation_info() can clamp the overestimate to the
|
* get_relation_info() can clamp the overestimate to the parent
|
||||||
* parent table's size.
|
* table's size.
|
||||||
*
|
*
|
||||||
* Note: this code intentionally disregards alignment
|
* Note: this code intentionally disregards alignment
|
||||||
* considerations, because (a) that would be gilding the lily
|
* considerations, because (a) that would be gilding the lily
|
||||||
* considering how crude the estimate is, and (b) it creates
|
* considering how crude the estimate is, and (b) it creates
|
||||||
* platform dependencies in the default plans which are kind
|
* platform dependencies in the default plans which are kind of a
|
||||||
* of a headache for regression testing.
|
* headache for regression testing.
|
||||||
*
|
*
|
||||||
* XXX: Should this logic be more index specific?
|
* XXX: Should this logic be more index specific?
|
||||||
*/
|
*/
|
||||||
@ -1041,10 +1041,10 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
|||||||
*tuples = rint(density * (double) curpages);
|
*tuples = rint(density * (double) curpages);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use relallvisible as-is, rather than scaling it up like we
|
* We use relallvisible as-is, rather than scaling it up like we do
|
||||||
* do for the pages and tuples counts, on the theory that any
|
* for the pages and tuples counts, on the theory that any pages added
|
||||||
* pages added since the last VACUUM are most likely not marked
|
* since the last VACUUM are most likely not marked all-visible. But
|
||||||
* all-visible. But costsize.c wants it converted to a fraction.
|
* costsize.c wants it converted to a fraction.
|
||||||
*/
|
*/
|
||||||
if (relallvisible == 0 || curpages <= 0)
|
if (relallvisible == 0 || curpages <= 0)
|
||||||
*allvisfrac = 0;
|
*allvisfrac = 0;
|
||||||
@ -1057,9 +1057,9 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Just use whatever's in pg_class. This covers foreign tables,
|
* Just use whatever's in pg_class. This covers foreign tables,
|
||||||
* sequences, and also relkinds without storage (shouldn't get
|
* sequences, and also relkinds without storage (shouldn't get here?);
|
||||||
* here?); see initializations in AddNewRelationTuple(). Note
|
* see initializations in AddNewRelationTuple(). Note that FDW must
|
||||||
* that FDW must cope if reltuples is -1!
|
* cope if reltuples is -1!
|
||||||
*/
|
*/
|
||||||
*pages = rel->rd_rel->relpages;
|
*pages = rel->rd_rel->relpages;
|
||||||
*tuples = rel->rd_rel->reltuples;
|
*tuples = rel->rd_rel->reltuples;
|
||||||
|
@ -2231,7 +2231,10 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
|
|||||||
setup_parser_errposition_callback(&pcbstate, pstate,
|
setup_parser_errposition_callback(&pcbstate, pstate,
|
||||||
bestlocation);
|
bestlocation);
|
||||||
|
|
||||||
/* If it's a recursive union, we need to require hashing support. */
|
/*
|
||||||
|
* If it's a recursive union, we need to require hashing
|
||||||
|
* support.
|
||||||
|
*/
|
||||||
op->groupClauses = lappend(op->groupClauses,
|
op->groupClauses = lappend(op->groupClauses,
|
||||||
makeSortGroupClauseForSetOp(rescoltype, recursive));
|
makeSortGroupClauseForSetOp(rescoltype, recursive));
|
||||||
|
|
||||||
|
@ -692,8 +692,11 @@ assign_collations_walker(Node *node, assign_collations_context *context)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case T_JsonExpr:
|
case T_JsonExpr:
|
||||||
/* Context item and PASSING arguments are already
|
|
||||||
* marked with collations in parse_expr.c. */
|
/*
|
||||||
|
* Context item and PASSING arguments are already
|
||||||
|
* marked with collations in parse_expr.c.
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
@ -3583,6 +3583,7 @@ coerceJsonFuncExpr(ParseState *pstate, Node *expr,
|
|||||||
list_make2(texpr, enc),
|
list_make2(texpr, enc),
|
||||||
InvalidOid, InvalidOid,
|
InvalidOid, InvalidOid,
|
||||||
COERCE_EXPLICIT_CALL);
|
COERCE_EXPLICIT_CALL);
|
||||||
|
|
||||||
fexpr->location = location;
|
fexpr->location = location;
|
||||||
|
|
||||||
return (Node *) fexpr;
|
return (Node *) fexpr;
|
||||||
@ -3863,8 +3864,7 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
|
|||||||
aggfnname = "pg_catalog.jsonb_object_agg_unique_strict"; /* F_JSONB_OBJECT_AGG_UNIQUE_STRICT */
|
aggfnname = "pg_catalog.jsonb_object_agg_unique_strict"; /* F_JSONB_OBJECT_AGG_UNIQUE_STRICT */
|
||||||
else
|
else
|
||||||
aggfnname = "pg_catalog.jsonb_object_agg_strict"; /* F_JSONB_OBJECT_AGG_STRICT */
|
aggfnname = "pg_catalog.jsonb_object_agg_strict"; /* F_JSONB_OBJECT_AGG_STRICT */
|
||||||
else
|
else if (agg->unique)
|
||||||
if (agg->unique)
|
|
||||||
aggfnname = "pg_catalog.jsonb_object_agg_unique"; /* F_JSONB_OBJECT_AGG_UNIQUE */
|
aggfnname = "pg_catalog.jsonb_object_agg_unique"; /* F_JSONB_OBJECT_AGG_UNIQUE */
|
||||||
else
|
else
|
||||||
aggfnname = "pg_catalog.jsonb_object_agg"; /* F_JSONB_OBJECT_AGG */
|
aggfnname = "pg_catalog.jsonb_object_agg"; /* F_JSONB_OBJECT_AGG */
|
||||||
@ -3878,8 +3878,7 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
|
|||||||
aggfnname = "pg_catalog.json_object_agg_unique_strict"; /* F_JSON_OBJECT_AGG_UNIQUE_STRICT */
|
aggfnname = "pg_catalog.json_object_agg_unique_strict"; /* F_JSON_OBJECT_AGG_UNIQUE_STRICT */
|
||||||
else
|
else
|
||||||
aggfnname = "pg_catalog.json_object_agg_strict"; /* F_JSON_OBJECT_AGG_STRICT */
|
aggfnname = "pg_catalog.json_object_agg_strict"; /* F_JSON_OBJECT_AGG_STRICT */
|
||||||
else
|
else if (agg->unique)
|
||||||
if (agg->unique)
|
|
||||||
aggfnname = "pg_catalog.json_object_agg_unique"; /* F_JSON_OBJECT_AGG_UNIQUE */
|
aggfnname = "pg_catalog.json_object_agg_unique"; /* F_JSON_OBJECT_AGG_UNIQUE */
|
||||||
else
|
else
|
||||||
aggfnname = "pg_catalog.json_object_agg"; /* F_JSON_OBJECT_AGG */
|
aggfnname = "pg_catalog.json_object_agg"; /* F_JSON_OBJECT_AGG */
|
||||||
|
@ -369,10 +369,10 @@ transformJsonTableChildPlan(JsonTableContext *cxt, JsonTablePlan *plan,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Node *node1 =
|
Node *node1 = transformJsonTableChildPlan(cxt, plan->plan1,
|
||||||
transformJsonTableChildPlan(cxt, plan->plan1, columns);
|
columns);
|
||||||
Node *node2 =
|
Node *node2 = transformJsonTableChildPlan(cxt, plan->plan2,
|
||||||
transformJsonTableChildPlan(cxt, plan->plan2, columns);
|
columns);
|
||||||
|
|
||||||
return makeJsonTableSiblingJoin(plan->join_type == JSTPJ_CROSS,
|
return makeJsonTableSiblingJoin(plan->join_type == JSTPJ_CROSS,
|
||||||
node1, node2);
|
node1, node2);
|
||||||
@ -451,9 +451,8 @@ appendJsonTableColumns(JsonTableContext *cxt, List *columns)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the type and typmod for the new column. FOR
|
* Determine the type and typmod for the new column. FOR ORDINALITY
|
||||||
* ORDINALITY columns are INTEGER by standard; the others are
|
* columns are INTEGER by standard; the others are user-specified.
|
||||||
* user-specified.
|
|
||||||
*/
|
*/
|
||||||
switch (rawc->coltype)
|
switch (rawc->coltype)
|
||||||
{
|
{
|
||||||
@ -662,7 +661,8 @@ transformJsonTable(ParseState *pstate, JsonTable *jt)
|
|||||||
|
|
||||||
registerAllJsonTableColumns(&cxt, jt->columns);
|
registerAllJsonTableColumns(&cxt, jt->columns);
|
||||||
|
|
||||||
#if 0 /* XXX it' unclear from the standard whether root path name is mandatory or not */
|
#if 0 /* XXX it' unclear from the standard whether
|
||||||
|
* root path name is mandatory or not */
|
||||||
if (plan && plan->plan_type != JSTP_DEFAULT && !rootPathName)
|
if (plan && plan->plan_type != JSTP_DEFAULT && !rootPathName)
|
||||||
{
|
{
|
||||||
/* Assign root path name and create corresponding plan node */
|
/* Assign root path name and create corresponding plan node */
|
||||||
|
@ -393,8 +393,9 @@ make_const(ParseState *pstate, A_Const *aconst)
|
|||||||
if (errno == 0 && *endptr == '\0')
|
if (errno == 0 && *endptr == '\0')
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* It might actually fit in int32. Probably only INT_MIN can
|
* It might actually fit in int32. Probably only INT_MIN
|
||||||
* occur, but we'll code the test generally just to be sure.
|
* can occur, but we'll code the test generally just to be
|
||||||
|
* sure.
|
||||||
*/
|
*/
|
||||||
int32 val32 = (int32) val64;
|
int32 val32 = (int32) val64;
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ RelationGetPartitionDesc(Relation rel, bool omit_detached)
|
|||||||
* cached descriptor too. We determine that based on the pg_inherits.xmin
|
* cached descriptor too. We determine that based on the pg_inherits.xmin
|
||||||
* that was saved alongside that descriptor: if the xmin that was not in
|
* that was saved alongside that descriptor: if the xmin that was not in
|
||||||
* progress for that active snapshot is also not in progress for the
|
* progress for that active snapshot is also not in progress for the
|
||||||
* current active snapshot, then we can use it. Otherwise build one
|
* current active snapshot, then we can use it. Otherwise build one from
|
||||||
* from scratch.
|
* scratch.
|
||||||
*/
|
*/
|
||||||
if (omit_detached &&
|
if (omit_detached &&
|
||||||
rel->rd_partdesc_nodetached &&
|
rel->rd_partdesc_nodetached &&
|
||||||
|
@ -984,7 +984,8 @@ rebuild_database_list(Oid newdb)
|
|||||||
hctl.keysize = sizeof(Oid);
|
hctl.keysize = sizeof(Oid);
|
||||||
hctl.entrysize = sizeof(avl_dbase);
|
hctl.entrysize = sizeof(avl_dbase);
|
||||||
hctl.hcxt = tmpcxt;
|
hctl.hcxt = tmpcxt;
|
||||||
dbhash = hash_create("autovacuum db hash", 20, &hctl, /* magic number here FIXME */
|
dbhash = hash_create("autovacuum db hash", 20, &hctl, /* magic number here
|
||||||
|
* FIXME */
|
||||||
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
||||||
|
|
||||||
/* start by inserting the new database */
|
/* start by inserting the new database */
|
||||||
@ -1683,12 +1684,12 @@ AutoVacWorkerMain(int argc, char *argv[])
|
|||||||
char dbname[NAMEDATALEN];
|
char dbname[NAMEDATALEN];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report autovac startup to the cumulative stats system. We deliberately do
|
* Report autovac startup to the cumulative stats system. We
|
||||||
* this before InitPostgres, so that the last_autovac_time will get
|
* deliberately do this before InitPostgres, so that the
|
||||||
* updated even if the connection attempt fails. This is to prevent
|
* last_autovac_time will get updated even if the connection attempt
|
||||||
* autovac from getting "stuck" repeatedly selecting an unopenable
|
* fails. This is to prevent autovac from getting "stuck" repeatedly
|
||||||
* database, rather than making any progress on stuff it can connect
|
* selecting an unopenable database, rather than making any progress
|
||||||
* to.
|
* on stuff it can connect to.
|
||||||
*/
|
*/
|
||||||
pgstat_report_autovac(dbid);
|
pgstat_report_autovac(dbid);
|
||||||
|
|
||||||
|
@ -826,9 +826,9 @@ StartBackgroundWorker(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a per-backend PGPROC struct in shared memory, except in the
|
* Create a per-backend PGPROC struct in shared memory, except in the
|
||||||
* EXEC_BACKEND case where this was done in SubPostmasterMain. We must
|
* EXEC_BACKEND case where this was done in SubPostmasterMain. We must do
|
||||||
* do this before we can use LWLocks (and in the EXEC_BACKEND case we
|
* this before we can use LWLocks (and in the EXEC_BACKEND case we already
|
||||||
* already had to do some stuff with LWLocks).
|
* had to do some stuff with LWLocks).
|
||||||
*/
|
*/
|
||||||
#ifndef EXEC_BACKEND
|
#ifndef EXEC_BACKEND
|
||||||
InitProcess();
|
InitProcess();
|
||||||
|
@ -81,8 +81,7 @@ typedef struct PgArchData
|
|||||||
int pgprocno; /* pgprocno of archiver process */
|
int pgprocno; /* pgprocno of archiver process */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Forces a directory scan in pgarch_readyXlog(). Protected by
|
* Forces a directory scan in pgarch_readyXlog(). Protected by arch_lck.
|
||||||
* arch_lck.
|
|
||||||
*/
|
*/
|
||||||
bool force_dir_scan;
|
bool force_dir_scan;
|
||||||
|
|
||||||
@ -579,9 +578,9 @@ pgarch_readyXlog(char *xlog)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* If we still have stored file names from the previous directory scan,
|
* If we still have stored file names from the previous directory scan,
|
||||||
* try to return one of those. We check to make sure the status file
|
* try to return one of those. We check to make sure the status file is
|
||||||
* is still present, as the archive_command for a previous file may
|
* still present, as the archive_command for a previous file may have
|
||||||
* have already marked it done.
|
* already marked it done.
|
||||||
*/
|
*/
|
||||||
while (arch_files->arch_files_size > 0)
|
while (arch_files->arch_files_size > 0)
|
||||||
{
|
{
|
||||||
@ -655,8 +654,8 @@ pgarch_readyXlog(char *xlog)
|
|||||||
CStringGetDatum(basename), NULL) > 0)
|
CStringGetDatum(basename), NULL) > 0)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Remove the lowest priority file and add the current one to
|
* Remove the lowest priority file and add the current one to the
|
||||||
* the heap.
|
* heap.
|
||||||
*/
|
*/
|
||||||
arch_file = DatumGetCString(binaryheap_remove_first(arch_files->arch_heap));
|
arch_file = DatumGetCString(binaryheap_remove_first(arch_files->arch_heap));
|
||||||
strcpy(arch_file, basename);
|
strcpy(arch_file, basename);
|
||||||
@ -677,8 +676,8 @@ pgarch_readyXlog(char *xlog)
|
|||||||
binaryheap_build(arch_files->arch_heap);
|
binaryheap_build(arch_files->arch_heap);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill arch_files array with the files to archive in ascending order
|
* Fill arch_files array with the files to archive in ascending order of
|
||||||
* of priority.
|
* priority.
|
||||||
*/
|
*/
|
||||||
arch_files->arch_files_size = arch_files->arch_heap->bh_size;
|
arch_files->arch_files_size = arch_files->arch_heap->bh_size;
|
||||||
for (int i = 0; i < arch_files->arch_files_size; i++)
|
for (int i = 0; i < arch_files->arch_files_size; i++)
|
||||||
@ -793,8 +792,8 @@ HandlePgArchInterrupts(void)
|
|||||||
if (archiveLibChanged)
|
if (archiveLibChanged)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Call the currently loaded archive module's shutdown callback, if
|
* Call the currently loaded archive module's shutdown callback,
|
||||||
* one is defined.
|
* if one is defined.
|
||||||
*/
|
*/
|
||||||
call_archive_module_shutdown_callback(0, 0);
|
call_archive_module_shutdown_callback(0, 0);
|
||||||
|
|
||||||
@ -803,8 +802,8 @@ HandlePgArchInterrupts(void)
|
|||||||
* load the new one, but there is presently no mechanism for
|
* load the new one, but there is presently no mechanism for
|
||||||
* unloading a library (see the comment above
|
* unloading a library (see the comment above
|
||||||
* internal_load_library()). To deal with this, we simply restart
|
* internal_load_library()). To deal with this, we simply restart
|
||||||
* the archiver. The new archive module will be loaded when the new
|
* the archiver. The new archive module will be loaded when the
|
||||||
* archiver process starts up.
|
* new archiver process starts up.
|
||||||
*/
|
*/
|
||||||
ereport(LOG,
|
ereport(LOG,
|
||||||
(errmsg("restarting archiver process because value of "
|
(errmsg("restarting archiver process because value of "
|
||||||
@ -828,9 +827,8 @@ LoadArchiveLibrary(void)
|
|||||||
memset(&ArchiveContext, 0, sizeof(ArchiveModuleCallbacks));
|
memset(&ArchiveContext, 0, sizeof(ArchiveModuleCallbacks));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If shell archiving is enabled, use our special initialization
|
* If shell archiving is enabled, use our special initialization function.
|
||||||
* function. Otherwise, load the library and call its
|
* Otherwise, load the library and call its _PG_archive_module_init().
|
||||||
* _PG_archive_module_init().
|
|
||||||
*/
|
*/
|
||||||
if (XLogArchiveLibrary[0] == '\0')
|
if (XLogArchiveLibrary[0] == '\0')
|
||||||
archive_init = shell_archive_init;
|
archive_init = shell_archive_init;
|
||||||
|
@ -2859,8 +2859,8 @@ pmdie(SIGNAL_ARGS)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* If we reached normal running, we go straight to waiting for
|
* If we reached normal running, we go straight to waiting for
|
||||||
* client backends to exit. If already in PM_STOP_BACKENDS or
|
* client backends to exit. If already in PM_STOP_BACKENDS or a
|
||||||
* a later state, do not change it.
|
* later state, do not change it.
|
||||||
*/
|
*/
|
||||||
if (pmState == PM_RUN || pmState == PM_HOT_STANDBY)
|
if (pmState == PM_RUN || pmState == PM_HOT_STANDBY)
|
||||||
connsAllowed = false;
|
connsAllowed = false;
|
||||||
|
@ -297,9 +297,9 @@ HandleWalWriterInterrupts(void)
|
|||||||
/*
|
/*
|
||||||
* Force reporting remaining WAL statistics at process exit.
|
* Force reporting remaining WAL statistics at process exit.
|
||||||
*
|
*
|
||||||
* Since pgstat_report_wal is invoked with 'force' is false in main loop
|
* Since pgstat_report_wal is invoked with 'force' is false in main
|
||||||
* to avoid overloading the cumulative stats system, there may exist
|
* loop to avoid overloading the cumulative stats system, there may
|
||||||
* unreported stats counters for the WAL writer.
|
* exist unreported stats counters for the WAL writer.
|
||||||
*/
|
*/
|
||||||
pgstat_report_wal(true);
|
pgstat_report_wal(true);
|
||||||
|
|
||||||
|
@ -234,8 +234,8 @@ pg_set_regex_collation(Oid collation)
|
|||||||
if (!OidIsValid(collation))
|
if (!OidIsValid(collation))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This typically means that the parser could not resolve a
|
* This typically means that the parser could not resolve a conflict
|
||||||
* conflict of implicit collations, so report it that way.
|
* of implicit collations, so report it that way.
|
||||||
*/
|
*/
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
||||||
@ -253,9 +253,9 @@ pg_set_regex_collation(Oid collation)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* NB: pg_newlocale_from_collation will fail if not HAVE_LOCALE_T;
|
* NB: pg_newlocale_from_collation will fail if not HAVE_LOCALE_T; the
|
||||||
* the case of pg_regex_locale != 0 but not HAVE_LOCALE_T does not
|
* case of pg_regex_locale != 0 but not HAVE_LOCALE_T does not have to
|
||||||
* have to be considered below.
|
* be considered below.
|
||||||
*/
|
*/
|
||||||
pg_regex_locale = pg_newlocale_from_collation(collation);
|
pg_regex_locale = pg_newlocale_from_collation(collation);
|
||||||
|
|
||||||
|
@ -131,11 +131,11 @@ bbsink_copystream_begin_backup(bbsink *sink)
|
|||||||
* data by means of CopyData messages where the payload portion of each
|
* data by means of CopyData messages where the payload portion of each
|
||||||
* message begins with a type byte. However, basebackup.c expects the
|
* message begins with a type byte. However, basebackup.c expects the
|
||||||
* buffer to be aligned, so we can't just allocate one extra byte for the
|
* buffer to be aligned, so we can't just allocate one extra byte for the
|
||||||
* type byte. Instead, allocate enough extra bytes that the portion of
|
* type byte. Instead, allocate enough extra bytes that the portion of the
|
||||||
* the buffer we reveal to our callers can be aligned, while leaving room
|
* buffer we reveal to our callers can be aligned, while leaving room to
|
||||||
* to slip the type byte in just beforehand. That will allow us to ship
|
* slip the type byte in just beforehand. That will allow us to ship the
|
||||||
* the data with a single call to pq_putmessage and without needing any
|
* data with a single call to pq_putmessage and without needing any extra
|
||||||
* extra copying.
|
* copying.
|
||||||
*/
|
*/
|
||||||
buf = palloc(mysink->base.bbs_buffer_length + MAXIMUM_ALIGNOF);
|
buf = palloc(mysink->base.bbs_buffer_length + MAXIMUM_ALIGNOF);
|
||||||
mysink->msgbuffer = buf + (MAXIMUM_ALIGNOF - 1);
|
mysink->msgbuffer = buf + (MAXIMUM_ALIGNOF - 1);
|
||||||
|
@ -129,10 +129,10 @@ bbsink_gzip_begin_archive(bbsink *sink, const char *archive_name)
|
|||||||
zs->avail_out = sink->bbs_next->bbs_buffer_length;
|
zs->avail_out = sink->bbs_next->bbs_buffer_length;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to use deflateInit2() rather than deflateInit() here so that
|
* We need to use deflateInit2() rather than deflateInit() here so that we
|
||||||
* we can request a gzip header rather than a zlib header. Otherwise, we
|
* can request a gzip header rather than a zlib header. Otherwise, we want
|
||||||
* want to supply the same values that would have been used by default
|
* to supply the same values that would have been used by default if we
|
||||||
* if we had just called deflateInit().
|
* had just called deflateInit().
|
||||||
*
|
*
|
||||||
* Per the documentation for deflateInit2, the third argument must be
|
* Per the documentation for deflateInit2, the third argument must be
|
||||||
* Z_DEFLATED; the fourth argument is the number of "window bits", by
|
* Z_DEFLATED; the fourth argument is the number of "window bits", by
|
||||||
@ -147,9 +147,8 @@ bbsink_gzip_begin_archive(bbsink *sink, const char *archive_name)
|
|||||||
errmsg("could not initialize compression library"));
|
errmsg("could not initialize compression library"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add ".gz" to the archive name. Note that the pg_basebackup -z
|
* Add ".gz" to the archive name. Note that the pg_basebackup -z produces
|
||||||
* produces archives named ".tar.gz" rather than ".tgz", so we match
|
* archives named ".tar.gz" rather than ".tgz", so we match that here.
|
||||||
* that here.
|
|
||||||
*/
|
*/
|
||||||
gz_archive_name = psprintf("%s.gz", archive_name);
|
gz_archive_name = psprintf("%s.gz", archive_name);
|
||||||
Assert(sink->bbs_next != NULL);
|
Assert(sink->bbs_next != NULL);
|
||||||
@ -248,8 +247,8 @@ bbsink_gzip_end_archive(bbsink *sink)
|
|||||||
mysink->base.bbs_next->bbs_buffer_length - mysink->bytes_written;
|
mysink->base.bbs_next->bbs_buffer_length - mysink->bytes_written;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As bbsink_gzip_archive_contents, but pass Z_FINISH since there
|
* As bbsink_gzip_archive_contents, but pass Z_FINISH since there is
|
||||||
* is no more input.
|
* no more input.
|
||||||
*/
|
*/
|
||||||
res = deflate(zs, Z_FINISH);
|
res = deflate(zs, Z_FINISH);
|
||||||
if (res == Z_STREAM_ERROR)
|
if (res == Z_STREAM_ERROR)
|
||||||
@ -260,8 +259,8 @@ bbsink_gzip_end_archive(bbsink *sink)
|
|||||||
mysink->base.bbs_next->bbs_buffer_length - zs->avail_out;
|
mysink->base.bbs_next->bbs_buffer_length - zs->avail_out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apparently we had no data in the output buffer and deflate()
|
* Apparently we had no data in the output buffer and deflate() was
|
||||||
* was not able to add any. We must be done.
|
* not able to add any. We must be done.
|
||||||
*/
|
*/
|
||||||
if (mysink->bytes_written == 0)
|
if (mysink->bytes_written == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -77,10 +77,11 @@ bbsink_server_new(bbsink *next, char *pathname)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* It's not a good idea to store your backups in the same directory that
|
* It's not a good idea to store your backups in the same directory that
|
||||||
* you're backing up. If we allowed a relative path here, that could easily
|
* you're backing up. If we allowed a relative path here, that could
|
||||||
* happen accidentally, so we don't. The user could still accomplish the
|
* easily happen accidentally, so we don't. The user could still
|
||||||
* same thing by including the absolute path to $PGDATA in the pathname,
|
* accomplish the same thing by including the absolute path to $PGDATA in
|
||||||
* but that's likely an intentional bad decision rather than an accident.
|
* the pathname, but that's likely an intentional bad decision rather than
|
||||||
|
* an accident.
|
||||||
*/
|
*/
|
||||||
if (!is_absolute_path(pathname))
|
if (!is_absolute_path(pathname))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -90,9 +91,10 @@ bbsink_server_new(bbsink *next, char *pathname)
|
|||||||
switch (pg_check_dir(pathname))
|
switch (pg_check_dir(pathname))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Does not exist, so create it using the same permissions we'd use
|
* Does not exist, so create it using the same permissions we'd
|
||||||
* for a new subdirectory of the data directory itself.
|
* use for a new subdirectory of the data directory itself.
|
||||||
*/
|
*/
|
||||||
if (MakePGDirectory(pathname) < 0)
|
if (MakePGDirectory(pathname) < 0)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
@ -80,9 +80,9 @@ BaseBackupAddTarget(char *name,
|
|||||||
/*
|
/*
|
||||||
* We found one, so update it.
|
* We found one, so update it.
|
||||||
*
|
*
|
||||||
* It is probably not a great idea to call BaseBackupAddTarget
|
* It is probably not a great idea to call BaseBackupAddTarget for
|
||||||
* for the same name multiple times, but if it happens, this
|
* the same name multiple times, but if it happens, this seems
|
||||||
* seems like the sanest behavior.
|
* like the sanest behavior.
|
||||||
*/
|
*/
|
||||||
ttype->check_detail = check_detail;
|
ttype->check_detail = check_detail;
|
||||||
ttype->get_sink = get_sink;
|
ttype->get_sink = get_sink;
|
||||||
@ -91,9 +91,9 @@ BaseBackupAddTarget(char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use TopMemoryContext for allocations here to make sure that the
|
* We use TopMemoryContext for allocations here to make sure that the data
|
||||||
* data we need doesn't vanish under us; that's also why we copy the
|
* we need doesn't vanish under us; that's also why we copy the target
|
||||||
* target name into a newly-allocated chunk of memory.
|
* name into a newly-allocated chunk of memory.
|
||||||
*/
|
*/
|
||||||
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
|
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
|
||||||
ttype = palloc(sizeof(BaseBackupTargetType));
|
ttype = palloc(sizeof(BaseBackupTargetType));
|
||||||
|
@ -108,9 +108,9 @@ bbsink_zstd_begin_backup(bbsink *sink)
|
|||||||
if ((compress->options & PG_COMPRESSION_OPTION_WORKERS) != 0)
|
if ((compress->options & PG_COMPRESSION_OPTION_WORKERS) != 0)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* On older versions of libzstd, this option does not exist, and trying
|
* On older versions of libzstd, this option does not exist, and
|
||||||
* to set it will fail. Similarly for newer versions if they are
|
* trying to set it will fail. Similarly for newer versions if they
|
||||||
* compiled without threading support.
|
* are compiled without threading support.
|
||||||
*/
|
*/
|
||||||
ret = ZSTD_CCtx_setParameter(mysink->cctx, ZSTD_c_nbWorkers,
|
ret = ZSTD_CCtx_setParameter(mysink->cctx, ZSTD_c_nbWorkers,
|
||||||
compress->workers);
|
compress->workers);
|
||||||
|
@ -344,9 +344,9 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't allow to invoke more sync workers once we have reached the sync
|
* We don't allow to invoke more sync workers once we have reached the
|
||||||
* worker limit per subscription. So, just return silently as we might get
|
* sync worker limit per subscription. So, just return silently as we
|
||||||
* here because of an otherwise harmless race condition.
|
* might get here because of an otherwise harmless race condition.
|
||||||
*/
|
*/
|
||||||
if (OidIsValid(relid) && nsyncworkers >= max_sync_workers_per_subscription)
|
if (OidIsValid(relid) && nsyncworkers >= max_sync_workers_per_subscription)
|
||||||
{
|
{
|
||||||
|
@ -646,8 +646,8 @@ ReorderBufferTXNByXid(ReorderBuffer *rb, TransactionId xid, bool create,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the cache wasn't hit or it yielded a "does-not-exist" and we want
|
* If the cache wasn't hit or it yielded a "does-not-exist" and we want to
|
||||||
* to create an entry.
|
* create an entry.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* search the lookup table */
|
/* search the lookup table */
|
||||||
|
@ -786,11 +786,11 @@ fetch_remote_table_info(char *nspname, char *relname,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch info about column lists for the relation (from all the
|
* Fetch info about column lists for the relation (from all the
|
||||||
* publications). We unnest the int2vector values, because that
|
* publications). We unnest the int2vector values, because that makes
|
||||||
* makes it easier to combine lists by simply adding the attnums
|
* it easier to combine lists by simply adding the attnums to a new
|
||||||
* to a new bitmap (without having to parse the int2vector data).
|
* bitmap (without having to parse the int2vector data). This
|
||||||
* This preserves NULL values, so that if one of the publications
|
* preserves NULL values, so that if one of the publications has no
|
||||||
* has no column list, we'll know that.
|
* column list, we'll know that.
|
||||||
*/
|
*/
|
||||||
resetStringInfo(&cmd);
|
resetStringInfo(&cmd);
|
||||||
appendStringInfo(&cmd,
|
appendStringInfo(&cmd,
|
||||||
@ -816,10 +816,10 @@ fetch_remote_table_info(char *nspname, char *relname,
|
|||||||
nspname, relname, pubres->err)));
|
nspname, relname, pubres->err)));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Merge the column lists (from different publications) by creating
|
* Merge the column lists (from different publications) by creating a
|
||||||
* a single bitmap with all the attnums. If we find a NULL value,
|
* single bitmap with all the attnums. If we find a NULL value, that
|
||||||
* that means one of the publications has no column list for the
|
* means one of the publications has no column list for the table
|
||||||
* table we're syncing.
|
* we're syncing.
|
||||||
*/
|
*/
|
||||||
slot = MakeSingleTupleTableSlot(pubres->tupledesc, &TTSOpsMinimalTuple);
|
slot = MakeSingleTupleTableSlot(pubres->tupledesc, &TTSOpsMinimalTuple);
|
||||||
while (tuplestore_gettupleslot(pubres->tuplestore, true, false, slot))
|
while (tuplestore_gettupleslot(pubres->tuplestore, true, false, slot))
|
||||||
@ -1056,8 +1056,8 @@ copy_table(Relation rel)
|
|||||||
quote_qualified_identifier(lrel.nspname, lrel.relname));
|
quote_qualified_identifier(lrel.nspname, lrel.relname));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX Do we need to list the columns in all cases? Maybe we're replicating
|
* XXX Do we need to list the columns in all cases? Maybe we're
|
||||||
* all columns?
|
* replicating all columns?
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < lrel.natts; i++)
|
for (int i = 0; i < lrel.natts; i++)
|
||||||
{
|
{
|
||||||
@ -1321,10 +1321,10 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* COPY FROM does not honor RLS policies. That is not a problem for
|
* COPY FROM does not honor RLS policies. That is not a problem for
|
||||||
* subscriptions owned by roles with BYPASSRLS privilege (or superuser, who
|
* subscriptions owned by roles with BYPASSRLS privilege (or superuser,
|
||||||
* has it implicitly), but other roles should not be able to circumvent
|
* who has it implicitly), but other roles should not be able to
|
||||||
* RLS. Disallow logical replication into RLS enabled relations for such
|
* circumvent RLS. Disallow logical replication into RLS enabled
|
||||||
* roles.
|
* relations for such roles.
|
||||||
*/
|
*/
|
||||||
if (check_enable_rls(RelationGetRelid(rel), InvalidOid, false) == RLS_ENABLED)
|
if (check_enable_rls(RelationGetRelid(rel), InvalidOid, false) == RLS_ENABLED)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
@ -174,8 +174,8 @@ typedef struct RelationSyncEntry
|
|||||||
Bitmapset *columns;
|
Bitmapset *columns;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private context to store additional data for this entry - state for
|
* Private context to store additional data for this entry - state for the
|
||||||
* the row filter expressions, column list, etc.
|
* row filter expressions, column list, etc.
|
||||||
*/
|
*/
|
||||||
MemoryContext entry_cxt;
|
MemoryContext entry_cxt;
|
||||||
} RelationSyncEntry;
|
} RelationSyncEntry;
|
||||||
@ -206,8 +206,7 @@ typedef struct RelationSyncEntry
|
|||||||
*/
|
*/
|
||||||
typedef struct PGOutputTxnData
|
typedef struct PGOutputTxnData
|
||||||
{
|
{
|
||||||
bool sent_begin_txn; /* flag indicating whether BEGIN has
|
bool sent_begin_txn; /* flag indicating whether BEGIN has been sent */
|
||||||
* been sent */
|
|
||||||
} PGOutputTxnData;
|
} PGOutputTxnData;
|
||||||
|
|
||||||
/* Map used to remember which relation schemas we sent. */
|
/* Map used to remember which relation schemas we sent. */
|
||||||
@ -987,7 +986,8 @@ pgoutput_column_list_init(PGOutputData *data, List *publications,
|
|||||||
*
|
*
|
||||||
* All the given publication-table mappings must be checked.
|
* All the given publication-table mappings must be checked.
|
||||||
*
|
*
|
||||||
* Multiple publications might have multiple column lists for this relation.
|
* Multiple publications might have multiple column lists for this
|
||||||
|
* relation.
|
||||||
*
|
*
|
||||||
* FOR ALL TABLES and FOR ALL TABLES IN SCHEMA implies "don't use column
|
* FOR ALL TABLES and FOR ALL TABLES IN SCHEMA implies "don't use column
|
||||||
* list" so it takes precedence.
|
* list" so it takes precedence.
|
||||||
@ -1005,8 +1005,9 @@ pgoutput_column_list_init(PGOutputData *data, List *publications,
|
|||||||
bool pub_no_list = true;
|
bool pub_no_list = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the publication is FOR ALL TABLES then it is treated the same as if
|
* If the publication is FOR ALL TABLES then it is treated the same as
|
||||||
* there are no column lists (even if other publications have a list).
|
* if there are no column lists (even if other publications have a
|
||||||
|
* list).
|
||||||
*/
|
*/
|
||||||
if (!pub->alltables)
|
if (!pub->alltables)
|
||||||
{
|
{
|
||||||
@ -1014,8 +1015,8 @@ pgoutput_column_list_init(PGOutputData *data, List *publications,
|
|||||||
* Check for the presence of a column list in this publication.
|
* Check for the presence of a column list in this publication.
|
||||||
*
|
*
|
||||||
* Note: If we find no pg_publication_rel row, it's a publication
|
* Note: If we find no pg_publication_rel row, it's a publication
|
||||||
* defined for a whole schema, so it can't have a column list, just
|
* defined for a whole schema, so it can't have a column list,
|
||||||
* like a FOR ALL TABLES publication.
|
* just like a FOR ALL TABLES publication.
|
||||||
*/
|
*/
|
||||||
cftuple = SearchSysCache2(PUBLICATIONRELMAP,
|
cftuple = SearchSysCache2(PUBLICATIONRELMAP,
|
||||||
ObjectIdGetDatum(entry->publish_as_relid),
|
ObjectIdGetDatum(entry->publish_as_relid),
|
||||||
@ -1221,9 +1222,9 @@ pgoutput_row_filter(Relation relation, TupleTableSlot *old_slot,
|
|||||||
* For updates, we can have only a new tuple when none of the replica
|
* For updates, we can have only a new tuple when none of the replica
|
||||||
* identity columns changed and none of those columns have external data
|
* identity columns changed and none of those columns have external data
|
||||||
* but we still need to evaluate the row filter for the new tuple as the
|
* but we still need to evaluate the row filter for the new tuple as the
|
||||||
* existing values of those columns might not match the filter. Also, users
|
* existing values of those columns might not match the filter. Also,
|
||||||
* can use constant expressions in the row filter, so we anyway need to
|
* users can use constant expressions in the row filter, so we anyway need
|
||||||
* evaluate it for the new tuple.
|
* to evaluate it for the new tuple.
|
||||||
*
|
*
|
||||||
* For deletes, we only have the old tuple.
|
* For deletes, we only have the old tuple.
|
||||||
*/
|
*/
|
||||||
@ -1674,8 +1675,7 @@ pgoutput_message(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
|||||||
xid = txn->xid;
|
xid = txn->xid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output BEGIN if we haven't yet. Avoid for non-transactional
|
* Output BEGIN if we haven't yet. Avoid for non-transactional messages.
|
||||||
* messages.
|
|
||||||
*/
|
*/
|
||||||
if (transactional)
|
if (transactional)
|
||||||
{
|
{
|
||||||
@ -2079,15 +2079,15 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Under what relid should we publish changes in this publication?
|
* Under what relid should we publish changes in this publication?
|
||||||
* We'll use the top-most relid across all publications. Also track
|
* We'll use the top-most relid across all publications. Also
|
||||||
* the ancestor level for this publication.
|
* track the ancestor level for this publication.
|
||||||
*/
|
*/
|
||||||
Oid pub_relid = relid;
|
Oid pub_relid = relid;
|
||||||
int ancestor_level = 0;
|
int ancestor_level = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a FOR ALL TABLES publication, pick the partition root
|
* If this is a FOR ALL TABLES publication, pick the partition
|
||||||
* and set the ancestor level accordingly.
|
* root and set the ancestor level accordingly.
|
||||||
*/
|
*/
|
||||||
if (pub->alltables)
|
if (pub->alltables)
|
||||||
{
|
{
|
||||||
@ -2156,18 +2156,18 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* We want to publish the changes as the top-most ancestor
|
* We want to publish the changes as the top-most ancestor
|
||||||
* across all publications. So we need to check if the
|
* across all publications. So we need to check if the already
|
||||||
* already calculated level is higher than the new one. If
|
* calculated level is higher than the new one. If yes, we can
|
||||||
* yes, we can ignore the new value (as it's a child).
|
* ignore the new value (as it's a child). Otherwise the new
|
||||||
* Otherwise the new value is an ancestor, so we keep it.
|
* value is an ancestor, so we keep it.
|
||||||
*/
|
*/
|
||||||
if (publish_ancestor_level > ancestor_level)
|
if (publish_ancestor_level > ancestor_level)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we found an ancestor higher up in the tree, discard
|
* If we found an ancestor higher up in the tree, discard the
|
||||||
* the list of publications through which we replicate it,
|
* list of publications through which we replicate it, and use
|
||||||
* and use the new ancestor.
|
* the new ancestor.
|
||||||
*/
|
*/
|
||||||
if (publish_ancestor_level < ancestor_level)
|
if (publish_ancestor_level < ancestor_level)
|
||||||
{
|
{
|
||||||
|
@ -504,8 +504,8 @@ retry:
|
|||||||
MyReplicationSlot = s;
|
MyReplicationSlot = s;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The call to pgstat_acquire_replslot() protects against stats for
|
* The call to pgstat_acquire_replslot() protects against stats for a
|
||||||
* a different slot, from before a restart or such, being present during
|
* different slot, from before a restart or such, being present during
|
||||||
* pgstat_report_replslot().
|
* pgstat_report_replslot().
|
||||||
*/
|
*/
|
||||||
if (SlotIsLogical(s))
|
if (SlotIsLogical(s))
|
||||||
|
@ -1406,9 +1406,9 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
|
|||||||
if (!has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
|
if (!has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Only superusers and roles with privileges of pg_read_all_stats
|
* Only superusers and roles with privileges of pg_read_all_stats can
|
||||||
* can see details. Other users only get the pid value to know whether
|
* see details. Other users only get the pid value to know whether it
|
||||||
* it is a WAL receiver, but no details.
|
* is a WAL receiver, but no details.
|
||||||
*/
|
*/
|
||||||
MemSet(&nulls[1], true, sizeof(bool) * (tupdesc->natts - 1));
|
MemSet(&nulls[1], true, sizeof(bool) * (tupdesc->natts - 1));
|
||||||
}
|
}
|
||||||
|
@ -1505,9 +1505,9 @@ WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId
|
|||||||
* When skipping empty transactions in synchronous replication, we send a
|
* When skipping empty transactions in synchronous replication, we send a
|
||||||
* keepalive message to avoid delaying such transactions.
|
* keepalive message to avoid delaying such transactions.
|
||||||
*
|
*
|
||||||
* It is okay to check sync_standbys_defined flag without lock here as
|
* It is okay to check sync_standbys_defined flag without lock here as in
|
||||||
* in the worst case we will just send an extra keepalive message when it
|
* the worst case we will just send an extra keepalive message when it is
|
||||||
* is really not required.
|
* really not required.
|
||||||
*/
|
*/
|
||||||
if (skipped_xact &&
|
if (skipped_xact &&
|
||||||
SyncRepRequested() &&
|
SyncRepRequested() &&
|
||||||
|
@ -673,9 +673,8 @@ ReadRecentBuffer(RelFileNode rnode, ForkNumber forkNum, BlockNumber blockNum,
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* It's now safe to pin the buffer. We can't pin first and ask
|
* It's now safe to pin the buffer. We can't pin first and ask
|
||||||
* questions later, because it might confuse code paths
|
* questions later, because it might confuse code paths like
|
||||||
* like InvalidateBuffer() if we pinned a random non-matching
|
* InvalidateBuffer() if we pinned a random non-matching buffer.
|
||||||
* buffer.
|
|
||||||
*/
|
*/
|
||||||
if (have_private_ref)
|
if (have_private_ref)
|
||||||
PinBuffer(bufHdr, NULL); /* bump pin count */
|
PinBuffer(bufHdr, NULL); /* bump pin count */
|
||||||
@ -2945,10 +2944,10 @@ RelationGetNumberOfBlocksInFork(Relation relation, ForkNumber forkNum)
|
|||||||
if (RELKIND_HAS_TABLE_AM(relation->rd_rel->relkind))
|
if (RELKIND_HAS_TABLE_AM(relation->rd_rel->relkind))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Not every table AM uses BLCKSZ wide fixed size blocks.
|
* Not every table AM uses BLCKSZ wide fixed size blocks. Therefore
|
||||||
* Therefore tableam returns the size in bytes - but for the
|
* tableam returns the size in bytes - but for the purpose of this
|
||||||
* purpose of this routine, we want the number of blocks.
|
* routine, we want the number of blocks. Therefore divide, rounding
|
||||||
* Therefore divide, rounding up.
|
* up.
|
||||||
*/
|
*/
|
||||||
uint64 szbytes;
|
uint64 szbytes;
|
||||||
|
|
||||||
@ -3707,9 +3706,9 @@ RelationCopyStorageUsingBuffer(Relation src, Relation dst, ForkNumber forkNum,
|
|||||||
BufferAccessStrategy bstrategy_dst;
|
BufferAccessStrategy bstrategy_dst;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In general, we want to write WAL whenever wal_level > 'minimal', but
|
* In general, we want to write WAL whenever wal_level > 'minimal', but we
|
||||||
* we can skip it when copying any fork of an unlogged relation other
|
* can skip it when copying any fork of an unlogged relation other than
|
||||||
* than the init fork.
|
* the init fork.
|
||||||
*/
|
*/
|
||||||
use_wal = XLogIsNeeded() && (permanent || forkNum == INIT_FORKNUM);
|
use_wal = XLogIsNeeded() && (permanent || forkNum == INIT_FORKNUM);
|
||||||
|
|
||||||
@ -3789,9 +3788,9 @@ CreateAndCopyRelationData(RelFileNode src_rnode, RelFileNode dst_rnode,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* We can't use a real relcache entry for a relation in some other
|
* We can't use a real relcache entry for a relation in some other
|
||||||
* database, but since we're only going to access the fields related
|
* database, but since we're only going to access the fields related to
|
||||||
* to physical storage, a fake one is good enough. If we didn't do this
|
* physical storage, a fake one is good enough. If we didn't do this and
|
||||||
* and used the smgr layer directly, we would have to worry about
|
* used the smgr layer directly, we would have to worry about
|
||||||
* invalidations.
|
* invalidations.
|
||||||
*/
|
*/
|
||||||
src_rel = CreateFakeRelcacheEntry(src_rnode);
|
src_rel = CreateFakeRelcacheEntry(src_rnode);
|
||||||
|
@ -1172,8 +1172,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
|
|||||||
*
|
*
|
||||||
* We have to sort them logically, because in KnownAssignedXidsAdd we
|
* We have to sort them logically, because in KnownAssignedXidsAdd we
|
||||||
* call TransactionIdFollowsOrEquals and so on. But we know these XIDs
|
* call TransactionIdFollowsOrEquals and so on. But we know these XIDs
|
||||||
* come from RUNNING_XACTS, which means there are only normal XIDs from
|
* come from RUNNING_XACTS, which means there are only normal XIDs
|
||||||
* the same epoch, so this is safe.
|
* from the same epoch, so this is safe.
|
||||||
*/
|
*/
|
||||||
qsort(xids, nxids, sizeof(TransactionId), xidLogicalComparator);
|
qsort(xids, nxids, sizeof(TransactionId), xidLogicalComparator);
|
||||||
|
|
||||||
|
@ -534,9 +534,9 @@ shm_mq_sendv(shm_mq_handle *mqh, shm_mq_iovec *iov, int iovcnt, bool nowait,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the caller has requested force flush or we have written more than 1/4
|
* If the caller has requested force flush or we have written more than
|
||||||
* of the ring size, mark it as written in shared memory and notify the
|
* 1/4 of the ring size, mark it as written in shared memory and notify
|
||||||
* receiver.
|
* the receiver.
|
||||||
*/
|
*/
|
||||||
if (force_flush || mqh->mqh_send_pending > (mq->mq_ring_size >> 2))
|
if (force_flush || mqh->mqh_send_pending > (mq->mq_ring_size >> 2))
|
||||||
{
|
{
|
||||||
|
@ -208,10 +208,11 @@ SInvalShmemSize(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* In Hot Standby mode, the startup process requests a procState array
|
* In Hot Standby mode, the startup process requests a procState array
|
||||||
* slot using InitRecoveryTransactionEnvironment(). Even though MaxBackends
|
* slot using InitRecoveryTransactionEnvironment(). Even though
|
||||||
* doesn't account for the startup process, it is guaranteed to get a
|
* MaxBackends doesn't account for the startup process, it is guaranteed
|
||||||
* free slot. This is because the autovacuum launcher and worker processes,
|
* to get a free slot. This is because the autovacuum launcher and worker
|
||||||
* which are included in MaxBackends, are not started in Hot Standby mode.
|
* processes, which are included in MaxBackends, are not started in Hot
|
||||||
|
* Standby mode.
|
||||||
*/
|
*/
|
||||||
size = add_size(size, mul_size(sizeof(ProcState), MaxBackends));
|
size = add_size(size, mul_size(sizeof(ProcState), MaxBackends));
|
||||||
|
|
||||||
|
@ -4377,11 +4377,12 @@ PostgresMain(const char *dbname, const char *username)
|
|||||||
* Note: this includes fflush()'ing the last of the prior output.
|
* Note: this includes fflush()'ing the last of the prior output.
|
||||||
*
|
*
|
||||||
* This is also a good time to flush out collected statistics to the
|
* This is also a good time to flush out collected statistics to the
|
||||||
* cumulative stats system, and to update the PS stats display. We avoid doing
|
* cumulative stats system, and to update the PS stats display. We
|
||||||
* those every time through the message loop because it'd slow down
|
* avoid doing those every time through the message loop because it'd
|
||||||
* processing of batched messages, and because we don't want to report
|
* slow down processing of batched messages, and because we don't want
|
||||||
* uncommitted updates (that confuses autovacuum). The notification
|
* to report uncommitted updates (that confuses autovacuum). The
|
||||||
* processor wants a call too, if we are not in a transaction block.
|
* notification processor wants a call too, if we are not in a
|
||||||
|
* transaction block.
|
||||||
*
|
*
|
||||||
* Also, if an idle timeout is enabled, start the timer for that.
|
* Also, if an idle timeout is enabled, start the timer for that.
|
||||||
*/
|
*/
|
||||||
@ -4470,8 +4471,9 @@ PostgresMain(const char *dbname, const char *username)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* (4) turn off the idle-in-transaction, idle-session and
|
* (4) turn off the idle-in-transaction, idle-session and
|
||||||
* idle-stats-update timeouts if active. We do this before step (5) so
|
* idle-stats-update timeouts if active. We do this before step (5)
|
||||||
* that any last-moment timeout is certain to be detected in step (5).
|
* so that any last-moment timeout is certain to be detected in step
|
||||||
|
* (5).
|
||||||
*
|
*
|
||||||
* At most one of these timeouts will be active, so there's no need to
|
* At most one of these timeouts will be active, so there's no need to
|
||||||
* worry about combining the timeout.c calls into one.
|
* worry about combining the timeout.c calls into one.
|
||||||
|
@ -3996,7 +3996,8 @@ hash_array(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Make fake type cache entry structure. Note that we can't just
|
* Make fake type cache entry structure. Note that we can't just
|
||||||
* modify typentry, since that points directly into the type cache.
|
* modify typentry, since that points directly into the type
|
||||||
|
* cache.
|
||||||
*/
|
*/
|
||||||
record_typentry = palloc0(sizeof(*record_typentry));
|
record_typentry = palloc0(sizeof(*record_typentry));
|
||||||
record_typentry->type_id = element_type;
|
record_typentry->type_id = element_type;
|
||||||
|
@ -112,8 +112,8 @@ calculate_database_size(Oid dbOid)
|
|||||||
AclResult aclresult;
|
AclResult aclresult;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* User must have connect privilege for target database or have privileges of
|
* User must have connect privilege for target database or have privileges
|
||||||
* pg_read_all_stats
|
* of pg_read_all_stats
|
||||||
*/
|
*/
|
||||||
aclresult = pg_database_aclcheck(dbOid, GetUserId(), ACL_CONNECT);
|
aclresult = pg_database_aclcheck(dbOid, GetUserId(), ACL_CONNECT);
|
||||||
if (aclresult != ACLCHECK_OK &&
|
if (aclresult != ACLCHECK_OK &&
|
||||||
@ -196,9 +196,9 @@ calculate_tablespace_size(Oid tblspcOid)
|
|||||||
AclResult aclresult;
|
AclResult aclresult;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* User must have privileges of pg_read_all_stats or have CREATE privilege for
|
* User must have privileges of pg_read_all_stats or have CREATE privilege
|
||||||
* target tablespace, either explicitly granted or implicitly because it
|
* for target tablespace, either explicitly granted or implicitly because
|
||||||
* is default for current database.
|
* it is default for current database.
|
||||||
*/
|
*/
|
||||||
if (tblspcOid != MyDatabaseTableSpace &&
|
if (tblspcOid != MyDatabaseTableSpace &&
|
||||||
!has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
|
!has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
|
||||||
|
@ -1675,8 +1675,8 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
|
|||||||
if (!OidIsValid(collid))
|
if (!OidIsValid(collid))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This typically means that the parser could not resolve a
|
* This typically means that the parser could not resolve a conflict
|
||||||
* conflict of implicit collations, so report it that way.
|
* of implicit collations, so report it that way.
|
||||||
*/
|
*/
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
||||||
@ -1797,8 +1797,8 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
|
|||||||
if (!OidIsValid(collid))
|
if (!OidIsValid(collid))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This typically means that the parser could not resolve a
|
* This typically means that the parser could not resolve a conflict
|
||||||
* conflict of implicit collations, so report it that way.
|
* of implicit collations, so report it that way.
|
||||||
*/
|
*/
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
||||||
@ -1920,8 +1920,8 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
|
|||||||
if (!OidIsValid(collid))
|
if (!OidIsValid(collid))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This typically means that the parser could not resolve a
|
* This typically means that the parser could not resolve a conflict
|
||||||
* conflict of implicit collations, so report it that way.
|
* of implicit collations, so report it that way.
|
||||||
*/
|
*/
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
||||||
|
@ -1011,6 +1011,7 @@ json_unique_builder_get_skipped_keys(JsonUniqueBuilderState *cxt)
|
|||||||
if (!out->data)
|
if (!out->data)
|
||||||
{
|
{
|
||||||
MemoryContext oldcxt = MemoryContextSwitchTo(cxt->mcxt);
|
MemoryContext oldcxt = MemoryContextSwitchTo(cxt->mcxt);
|
||||||
|
|
||||||
initStringInfo(out);
|
initStringInfo(out);
|
||||||
MemoryContextSwitchTo(oldcxt);
|
MemoryContextSwitchTo(oldcxt);
|
||||||
}
|
}
|
||||||
@ -1116,8 +1117,8 @@ json_object_agg_transfn_worker(FunctionCallInfo fcinfo,
|
|||||||
out = state->str;
|
out = state->str;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Append comma delimiter only if we have already outputted some fields
|
* Append comma delimiter only if we have already outputted some
|
||||||
* after the initial string "{ ".
|
* fields after the initial string "{ ".
|
||||||
*/
|
*/
|
||||||
if (out->len > 2)
|
if (out->len > 2)
|
||||||
appendStringInfoString(out, ", ");
|
appendStringInfoString(out, ", ");
|
||||||
@ -1327,6 +1328,7 @@ json_build_object(PG_FUNCTION_ARGS)
|
|||||||
Datum *args;
|
Datum *args;
|
||||||
bool *nulls;
|
bool *nulls;
|
||||||
Oid *types;
|
Oid *types;
|
||||||
|
|
||||||
/* build argument values to build the object */
|
/* build argument values to build the object */
|
||||||
int nargs = extract_variadic_args(fcinfo, 0, true,
|
int nargs = extract_variadic_args(fcinfo, 0, true,
|
||||||
&args, &types, &nulls);
|
&args, &types, &nulls);
|
||||||
@ -1382,6 +1384,7 @@ json_build_array(PG_FUNCTION_ARGS)
|
|||||||
Datum *args;
|
Datum *args;
|
||||||
bool *nulls;
|
bool *nulls;
|
||||||
Oid *types;
|
Oid *types;
|
||||||
|
|
||||||
/* build argument values to build the object */
|
/* build argument values to build the object */
|
||||||
int nargs = extract_variadic_args(fcinfo, 0, true,
|
int nargs = extract_variadic_args(fcinfo, 0, true,
|
||||||
&args, &types, &nulls);
|
&args, &types, &nulls);
|
||||||
|
@ -1240,6 +1240,7 @@ jsonb_build_object(PG_FUNCTION_ARGS)
|
|||||||
Datum *args;
|
Datum *args;
|
||||||
bool *nulls;
|
bool *nulls;
|
||||||
Oid *types;
|
Oid *types;
|
||||||
|
|
||||||
/* build argument values to build the object */
|
/* build argument values to build the object */
|
||||||
int nargs = extract_variadic_args(fcinfo, 0, true,
|
int nargs = extract_variadic_args(fcinfo, 0, true,
|
||||||
&args, &types, &nulls);
|
&args, &types, &nulls);
|
||||||
@ -1299,6 +1300,7 @@ jsonb_build_array(PG_FUNCTION_ARGS)
|
|||||||
Datum *args;
|
Datum *args;
|
||||||
bool *nulls;
|
bool *nulls;
|
||||||
Oid *types;
|
Oid *types;
|
||||||
|
|
||||||
/* build argument values to build the object */
|
/* build argument values to build the object */
|
||||||
int nargs = extract_variadic_args(fcinfo, 0, true,
|
int nargs = extract_variadic_args(fcinfo, 0, true,
|
||||||
&args, &types, &nulls);
|
&args, &types, &nulls);
|
||||||
|
@ -1959,7 +1959,8 @@ uniqueifyJsonbObject(JsonbValue *object, bool unique_keys, bool skip_nulls)
|
|||||||
|
|
||||||
if (hasNonUniq || skip_nulls)
|
if (hasNonUniq || skip_nulls)
|
||||||
{
|
{
|
||||||
JsonbPair *ptr, *res;
|
JsonbPair *ptr,
|
||||||
|
*res;
|
||||||
|
|
||||||
while (skip_nulls && object->val.object.nPairs > 0 &&
|
while (skip_nulls && object->val.object.nPairs > 0 &&
|
||||||
object->val.object.pairs->value.type == jbvNull)
|
object->val.object.pairs->value.type == jbvNull)
|
||||||
|
@ -3157,7 +3157,8 @@ json_populate_type(Datum json_val, Oid json_type, Oid typid, int32 typmod,
|
|||||||
|
|
||||||
jsv.val.json.str = VARDATA_ANY(json);
|
jsv.val.json.str = VARDATA_ANY(json);
|
||||||
jsv.val.json.len = VARSIZE_ANY_EXHDR(json);
|
jsv.val.json.len = VARSIZE_ANY_EXHDR(json);
|
||||||
jsv.val.json.type = JSON_TOKEN_INVALID; /* not used in populate_composite() */
|
jsv.val.json.type = JSON_TOKEN_INVALID; /* not used in
|
||||||
|
* populate_composite() */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -181,8 +181,8 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation)
|
|||||||
if (!OidIsValid(collation))
|
if (!OidIsValid(collation))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This typically means that the parser could not resolve a
|
* This typically means that the parser could not resolve a conflict
|
||||||
* conflict of implicit collations, so report it that way.
|
* of implicit collations, so report it that way.
|
||||||
*/
|
*/
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
(errcode(ERRCODE_INDETERMINATE_COLLATION),
|
||||||
|
@ -1439,7 +1439,8 @@ multirange_agg_transfn(PG_FUNCTION_ARGS)
|
|||||||
if (range_count == 0)
|
if (range_count == 0)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Add an empty range so we get an empty result (not a null result).
|
* Add an empty range so we get an empty result (not a null
|
||||||
|
* result).
|
||||||
*/
|
*/
|
||||||
accumArrayResult(state,
|
accumArrayResult(state,
|
||||||
RangeTypePGetDatum(make_empty_range(rngtypcache)),
|
RangeTypePGetDatum(make_empty_range(rngtypcache)),
|
||||||
|
@ -8541,10 +8541,10 @@ div_var(const NumericVar *var1, const NumericVar *var2, NumericVar *result,
|
|||||||
* The full multiple-place algorithm is taken from Knuth volume 2,
|
* The full multiple-place algorithm is taken from Knuth volume 2,
|
||||||
* Algorithm 4.3.1D.
|
* Algorithm 4.3.1D.
|
||||||
*
|
*
|
||||||
* We need the first divisor digit to be >= NBASE/2. If it isn't,
|
* We need the first divisor digit to be >= NBASE/2. If it isn't, make it
|
||||||
* make it so by scaling up both the divisor and dividend by the
|
* so by scaling up both the divisor and dividend by the factor "d". (The
|
||||||
* factor "d". (The reason for allocating dividend[0] above is to
|
* reason for allocating dividend[0] above is to leave room for possible
|
||||||
* leave room for possible carry here.)
|
* carry here.)
|
||||||
*/
|
*/
|
||||||
if (divisor[1] < HALF_NBASE)
|
if (divisor[1] < HALF_NBASE)
|
||||||
{
|
{
|
||||||
@ -8576,8 +8576,8 @@ div_var(const NumericVar *var1, const NumericVar *var2, NumericVar *result,
|
|||||||
/*
|
/*
|
||||||
* Begin the main loop. Each iteration of this loop produces the j'th
|
* Begin the main loop. Each iteration of this loop produces the j'th
|
||||||
* quotient digit by dividing dividend[j .. j + var2ndigits] by the
|
* quotient digit by dividing dividend[j .. j + var2ndigits] by the
|
||||||
* divisor; this is essentially the same as the common manual
|
* divisor; this is essentially the same as the common manual procedure
|
||||||
* procedure for long division.
|
* for long division.
|
||||||
*/
|
*/
|
||||||
for (j = 0; j < res_ndigits; j++)
|
for (j = 0; j < res_ndigits; j++)
|
||||||
{
|
{
|
||||||
@ -8586,10 +8586,9 @@ div_var(const NumericVar *var1, const NumericVar *var2, NumericVar *result,
|
|||||||
int qhat;
|
int qhat;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If next2digits are 0, then quotient digit must be 0 and there's
|
* If next2digits are 0, then quotient digit must be 0 and there's no
|
||||||
* no need to adjust the working dividend. It's worth testing
|
* need to adjust the working dividend. It's worth testing here to
|
||||||
* here to fall out ASAP when processing trailing zeroes in a
|
* fall out ASAP when processing trailing zeroes in a dividend.
|
||||||
* dividend.
|
|
||||||
*/
|
*/
|
||||||
if (next2digits == 0)
|
if (next2digits == 0)
|
||||||
{
|
{
|
||||||
@ -8603,10 +8602,10 @@ div_var(const NumericVar *var1, const NumericVar *var2, NumericVar *result,
|
|||||||
qhat = next2digits / divisor1;
|
qhat = next2digits / divisor1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adjust quotient digit if it's too large. Knuth proves that
|
* Adjust quotient digit if it's too large. Knuth proves that after
|
||||||
* after this step, the quotient digit will be either correct or
|
* this step, the quotient digit will be either correct or just one
|
||||||
* just one too large. (Note: it's OK to use dividend[j+2] here
|
* too large. (Note: it's OK to use dividend[j+2] here because we
|
||||||
* because we know the divisor length is at least 2.)
|
* know the divisor length is at least 2.)
|
||||||
*/
|
*/
|
||||||
while (divisor2 * qhat >
|
while (divisor2 * qhat >
|
||||||
(next2digits - qhat * divisor1) * NBASE + dividend[j + 2])
|
(next2digits - qhat * divisor1) * NBASE + dividend[j + 2])
|
||||||
@ -8620,10 +8619,10 @@ div_var(const NumericVar *var1, const NumericVar *var2, NumericVar *result,
|
|||||||
/*
|
/*
|
||||||
* Multiply the divisor by qhat, and subtract that from the
|
* Multiply the divisor by qhat, and subtract that from the
|
||||||
* working dividend. The multiplication and subtraction are
|
* working dividend. The multiplication and subtraction are
|
||||||
* folded together here, noting that qhat <= NBASE (since it
|
* folded together here, noting that qhat <= NBASE (since it might
|
||||||
* might be one too large), and so the intermediate result
|
* be one too large), and so the intermediate result "tmp_result"
|
||||||
* "tmp_result" is in the range [-NBASE^2, NBASE - 1], and
|
* is in the range [-NBASE^2, NBASE - 1], and "borrow" is in the
|
||||||
* "borrow" is in the range [0, NBASE].
|
* range [0, NBASE].
|
||||||
*/
|
*/
|
||||||
borrow = 0;
|
borrow = 0;
|
||||||
for (i = var2ndigits; i >= 0; i--)
|
for (i = var2ndigits; i >= 0; i--)
|
||||||
@ -8636,12 +8635,12 @@ div_var(const NumericVar *var1, const NumericVar *var2, NumericVar *result,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we got a borrow out of the top dividend digit, then
|
* If we got a borrow out of the top dividend digit, then indeed
|
||||||
* indeed qhat was one too large. Fix it, and add back the
|
* qhat was one too large. Fix it, and add back the divisor to
|
||||||
* divisor to correct the working dividend. (Knuth proves
|
* correct the working dividend. (Knuth proves that this will
|
||||||
* that this will occur only about 3/NBASE of the time; hence,
|
* occur only about 3/NBASE of the time; hence, it's a good idea
|
||||||
* it's a good idea to test this code with small NBASE to be
|
* to test this code with small NBASE to be sure this section gets
|
||||||
* sure this section gets exercised.)
|
* exercised.)
|
||||||
*/
|
*/
|
||||||
if (borrow)
|
if (borrow)
|
||||||
{
|
{
|
||||||
|
@ -608,8 +608,8 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* Non-empty range A contains non-empty range B if lower
|
* Non-empty range A contains non-empty range B if lower
|
||||||
* bound of A is lower or equal to lower bound of range B
|
* bound of A is lower or equal to lower bound of range B
|
||||||
* and upper bound of range A is greater than or equal to upper
|
* and upper bound of range A is greater than or equal to
|
||||||
* bound of range A.
|
* upper bound of range A.
|
||||||
*
|
*
|
||||||
* All non-empty ranges contain an empty range.
|
* All non-empty ranges contain an empty range.
|
||||||
*/
|
*/
|
||||||
|
@ -113,8 +113,10 @@ typedef struct RI_ConstraintInfo
|
|||||||
Oid fk_relid; /* referencing relation */
|
Oid fk_relid; /* referencing relation */
|
||||||
char confupdtype; /* foreign key's ON UPDATE action */
|
char confupdtype; /* foreign key's ON UPDATE action */
|
||||||
char confdeltype; /* foreign key's ON DELETE action */
|
char confdeltype; /* foreign key's ON DELETE action */
|
||||||
int ndelsetcols; /* number of columns referenced in ON DELETE SET clause */
|
int ndelsetcols; /* number of columns referenced in ON DELETE
|
||||||
int16 confdelsetcols[RI_MAX_NUMKEYS]; /* attnums of cols to set on delete */
|
* SET clause */
|
||||||
|
int16 confdelsetcols[RI_MAX_NUMKEYS]; /* attnums of cols to set on
|
||||||
|
* delete */
|
||||||
char confmatchtype; /* foreign key's match type */
|
char confmatchtype; /* foreign key's match type */
|
||||||
int nkeys; /* number of key columns */
|
int nkeys; /* number of key columns */
|
||||||
int16 pk_attnums[RI_MAX_NUMKEYS]; /* attnums of referenced cols */
|
int16 pk_attnums[RI_MAX_NUMKEYS]; /* attnums of referenced cols */
|
||||||
@ -1059,7 +1061,8 @@ ri_set(TriggerData *trigdata, bool is_set_null, int tgkind)
|
|||||||
/*
|
/*
|
||||||
* Fetch or prepare a saved plan for the trigger.
|
* Fetch or prepare a saved plan for the trigger.
|
||||||
*/
|
*/
|
||||||
switch (tgkind) {
|
switch (tgkind)
|
||||||
|
{
|
||||||
case RI_TRIGTYPE_UPDATE:
|
case RI_TRIGTYPE_UPDATE:
|
||||||
queryno = is_set_null
|
queryno = is_set_null
|
||||||
? RI_PLAN_SETNULL_ONUPDATE
|
? RI_PLAN_SETNULL_ONUPDATE
|
||||||
@ -1089,22 +1092,26 @@ ri_set(TriggerData *trigdata, bool is_set_null, int tgkind)
|
|||||||
int num_cols_to_set;
|
int num_cols_to_set;
|
||||||
const int16 *set_cols;
|
const int16 *set_cols;
|
||||||
|
|
||||||
switch (tgkind) {
|
switch (tgkind)
|
||||||
|
{
|
||||||
case RI_TRIGTYPE_UPDATE:
|
case RI_TRIGTYPE_UPDATE:
|
||||||
num_cols_to_set = riinfo->nkeys;
|
num_cols_to_set = riinfo->nkeys;
|
||||||
set_cols = riinfo->fk_attnums;
|
set_cols = riinfo->fk_attnums;
|
||||||
break;
|
break;
|
||||||
case RI_TRIGTYPE_DELETE:
|
case RI_TRIGTYPE_DELETE:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If confdelsetcols are present, then we only update
|
* If confdelsetcols are present, then we only update the
|
||||||
* the columns specified in that array, otherwise we
|
* columns specified in that array, otherwise we update all
|
||||||
* update all the referencing columns.
|
* the referencing columns.
|
||||||
*/
|
*/
|
||||||
if (riinfo->ndelsetcols != 0) {
|
if (riinfo->ndelsetcols != 0)
|
||||||
|
{
|
||||||
num_cols_to_set = riinfo->ndelsetcols;
|
num_cols_to_set = riinfo->ndelsetcols;
|
||||||
set_cols = riinfo->confdelsetcols;
|
set_cols = riinfo->confdelsetcols;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
num_cols_to_set = riinfo->nkeys;
|
num_cols_to_set = riinfo->nkeys;
|
||||||
set_cols = riinfo->fk_attnums;
|
set_cols = riinfo->fk_attnums;
|
||||||
}
|
}
|
||||||
|
@ -2331,7 +2331,10 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
|
|||||||
if (string)
|
if (string)
|
||||||
appendStringInfo(&buf, " ON DELETE %s", string);
|
appendStringInfo(&buf, " ON DELETE %s", string);
|
||||||
|
|
||||||
/* Add columns specified to SET NULL or SET DEFAULT if provided. */
|
/*
|
||||||
|
* Add columns specified to SET NULL or SET DEFAULT if
|
||||||
|
* provided.
|
||||||
|
*/
|
||||||
val = SysCacheGetAttr(CONSTROID, tup,
|
val = SysCacheGetAttr(CONSTROID, tup,
|
||||||
Anum_pg_constraint_confdelsetcols, &isnull);
|
Anum_pg_constraint_confdelsetcols, &isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
@ -9778,7 +9781,8 @@ get_rule_expr(Node *node, deparse_context *context,
|
|||||||
|
|
||||||
if (jexpr->passing_values)
|
if (jexpr->passing_values)
|
||||||
{
|
{
|
||||||
ListCell *lc1, *lc2;
|
ListCell *lc1,
|
||||||
|
*lc2;
|
||||||
bool needcomma = false;
|
bool needcomma = false;
|
||||||
|
|
||||||
appendStringInfoString(buf, " PASSING ");
|
appendStringInfoString(buf, " PASSING ");
|
||||||
@ -10251,7 +10255,8 @@ get_agg_expr_helper(Aggref *aggref, deparse_context *context,
|
|||||||
if (is_json_objectagg)
|
if (is_json_objectagg)
|
||||||
{
|
{
|
||||||
if (i > 2)
|
if (i > 2)
|
||||||
break; /* skip ABSENT ON NULL and WITH UNIQUE args */
|
break; /* skip ABSENT ON NULL and WITH UNIQUE
|
||||||
|
* args */
|
||||||
|
|
||||||
appendStringInfoString(buf, " : ");
|
appendStringInfoString(buf, " : ");
|
||||||
}
|
}
|
||||||
@ -11348,7 +11353,8 @@ get_json_table(TableFunc *tf, deparse_context *context, bool showimplicit)
|
|||||||
|
|
||||||
if (jexpr->passing_values)
|
if (jexpr->passing_values)
|
||||||
{
|
{
|
||||||
ListCell *lc1, *lc2;
|
ListCell *lc1,
|
||||||
|
*lc2;
|
||||||
bool needcomma = false;
|
bool needcomma = false;
|
||||||
|
|
||||||
appendStringInfoChar(buf, ' ');
|
appendStringInfoChar(buf, ' ');
|
||||||
|
@ -2194,6 +2194,7 @@ timestamp_sortsupport(PG_FUNCTION_ARGS)
|
|||||||
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
|
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
|
||||||
|
|
||||||
#if SIZEOF_DATUM >= 8
|
#if SIZEOF_DATUM >= 8
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this build has pass-by-value timestamps, then we can use a standard
|
* If this build has pass-by-value timestamps, then we can use a standard
|
||||||
* comparator function.
|
* comparator function.
|
||||||
|
@ -377,8 +377,8 @@ uuid_abbrev_convert(Datum original, SortSupport ssup)
|
|||||||
*
|
*
|
||||||
* This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer
|
* This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer
|
||||||
* 3-way comparator) works correctly on all platforms. If we didn't do
|
* 3-way comparator) works correctly on all platforms. If we didn't do
|
||||||
* this, the comparator would have to call memcmp() with a pair of pointers
|
* this, the comparator would have to call memcmp() with a pair of
|
||||||
* to the first byte of each abbreviated key, which is slower.
|
* pointers to the first byte of each abbreviated key, which is slower.
|
||||||
*/
|
*/
|
||||||
res = DatumBigEndianToNative(res);
|
res = DatumBigEndianToNative(res);
|
||||||
|
|
||||||
|
@ -2674,8 +2674,8 @@ done:
|
|||||||
*
|
*
|
||||||
* This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer
|
* This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer
|
||||||
* 3-way comparator) works correctly on all platforms. If we didn't do
|
* 3-way comparator) works correctly on all platforms. If we didn't do
|
||||||
* this, the comparator would have to call memcmp() with a pair of pointers
|
* this, the comparator would have to call memcmp() with a pair of
|
||||||
* to the first byte of each abbreviated key, which is slower.
|
* pointers to the first byte of each abbreviated key, which is slower.
|
||||||
*/
|
*/
|
||||||
res = DatumBigEndianToNative(res);
|
res = DatumBigEndianToNative(res);
|
||||||
|
|
||||||
|
15
src/backend/utils/cache/relcache.c
vendored
15
src/backend/utils/cache/relcache.c
vendored
@ -5258,9 +5258,9 @@ restart:
|
|||||||
pull_varattnos(indexExpressions, 1, &hotblockingattrs);
|
pull_varattnos(indexExpressions, 1, &hotblockingattrs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Collect all attributes in the index predicate, too. We have to ignore
|
* Collect all attributes in the index predicate, too. We have to
|
||||||
* amhotblocking flag, because the row might become indexable, in which
|
* ignore amhotblocking flag, because the row might become indexable,
|
||||||
* case we have to add it to the index.
|
* in which case we have to add it to the index.
|
||||||
*/
|
*/
|
||||||
pull_varattnos(indexPredicate, 1, &hotblockingattrs);
|
pull_varattnos(indexPredicate, 1, &hotblockingattrs);
|
||||||
|
|
||||||
@ -5308,9 +5308,8 @@ restart:
|
|||||||
/*
|
/*
|
||||||
* Now save copies of the bitmaps in the relcache entry. We intentionally
|
* Now save copies of the bitmaps in the relcache entry. We intentionally
|
||||||
* set rd_attrsvalid last, because that's what signals validity of the
|
* set rd_attrsvalid last, because that's what signals validity of the
|
||||||
* values; if we run out of memory before making that copy, we won't
|
* values; if we run out of memory before making that copy, we won't leave
|
||||||
* leave the relcache entry looking like the other ones are valid but
|
* the relcache entry looking like the other ones are valid but empty.
|
||||||
* empty.
|
|
||||||
*/
|
*/
|
||||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||||
relation->rd_keyattr = bms_copy(uindexattrs);
|
relation->rd_keyattr = bms_copy(uindexattrs);
|
||||||
@ -5636,8 +5635,8 @@ RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc)
|
|||||||
pubdesc->pubactions.pubtruncate |= pubform->pubtruncate;
|
pubdesc->pubactions.pubtruncate |= pubform->pubtruncate;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if all columns referenced in the filter expression are part of
|
* Check if all columns referenced in the filter expression are part
|
||||||
* the REPLICA IDENTITY index or not.
|
* of the REPLICA IDENTITY index or not.
|
||||||
*
|
*
|
||||||
* If the publication is FOR ALL TABLES then it means the table has no
|
* If the publication is FOR ALL TABLES then it means the table has no
|
||||||
* row filters and we can skip the validation.
|
* row filters and we can skip the validation.
|
||||||
|
14
src/backend/utils/cache/relmapper.c
vendored
14
src/backend/utils/cache/relmapper.c
vendored
@ -302,8 +302,8 @@ RelationMapCopy(Oid dbid, Oid tsid, char *srcdbpath, char *dstdbpath)
|
|||||||
* RelationMappingLock.
|
* RelationMappingLock.
|
||||||
*
|
*
|
||||||
* There's no point in trying to preserve files here. The new database
|
* There's no point in trying to preserve files here. The new database
|
||||||
* isn't usable yet anyway, and won't ever be if we can't install a
|
* isn't usable yet anyway, and won't ever be if we can't install a relmap
|
||||||
* relmap file.
|
* file.
|
||||||
*/
|
*/
|
||||||
write_relmap_file(&map, true, false, false, dbid, tsid, dstdbpath);
|
write_relmap_file(&map, true, false, false, dbid, tsid, dstdbpath);
|
||||||
}
|
}
|
||||||
@ -1089,11 +1089,11 @@ relmap_redo(XLogReaderState *record)
|
|||||||
* There shouldn't be anyone else updating relmaps during WAL replay,
|
* There shouldn't be anyone else updating relmaps during WAL replay,
|
||||||
* but grab the lock to interlock against load_relmap_file().
|
* but grab the lock to interlock against load_relmap_file().
|
||||||
*
|
*
|
||||||
* Note that we use the same WAL record for updating the relmap of
|
* Note that we use the same WAL record for updating the relmap of an
|
||||||
* an existing database as we do for creating a new database. In
|
* existing database as we do for creating a new database. In the
|
||||||
* the latter case, taking the relmap log and sending sinval messages
|
* latter case, taking the relmap log and sending sinval messages is
|
||||||
* is unnecessary, but harmless. If we wanted to avoid it, we could
|
* unnecessary, but harmless. If we wanted to avoid it, we could add a
|
||||||
* add a flag to the WAL record to indicate which operation is being
|
* flag to the WAL record to indicate which operation is being
|
||||||
* performed.
|
* performed.
|
||||||
*/
|
*/
|
||||||
LWLockAcquire(RelationMappingLock, LW_EXCLUSIVE);
|
LWLockAcquire(RelationMappingLock, LW_EXCLUSIVE);
|
||||||
|
@ -429,6 +429,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
|
|||||||
iculocale = NULL;
|
iculocale = NULL;
|
||||||
|
|
||||||
default_locale.provider = dbform->datlocprovider;
|
default_locale.provider = dbform->datlocprovider;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default locale is currently always deterministic. Nondeterministic
|
* Default locale is currently always deterministic. Nondeterministic
|
||||||
* locales currently don't support pattern matching, which would break a
|
* locales currently don't support pattern matching, which would break a
|
||||||
@ -604,8 +605,8 @@ BaseInit(void)
|
|||||||
InitTemporaryFileAccess();
|
InitTemporaryFileAccess();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize local buffers for WAL record construction, in case we
|
* Initialize local buffers for WAL record construction, in case we ever
|
||||||
* ever try to insert XLOG.
|
* try to insert XLOG.
|
||||||
*/
|
*/
|
||||||
InitXLogInsert();
|
InitXLogInsert();
|
||||||
|
|
||||||
@ -693,10 +694,10 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is either a bootstrap process or a standalone backend, start
|
* If this is either a bootstrap process or a standalone backend, start up
|
||||||
* up the XLOG machinery, and register to have it closed down at exit.
|
* the XLOG machinery, and register to have it closed down at exit. In
|
||||||
* In other cases, the startup process is responsible for starting up
|
* other cases, the startup process is responsible for starting up the
|
||||||
* the XLOG machinery, and the checkpointer for closing it down.
|
* XLOG machinery, and the checkpointer for closing it down.
|
||||||
*/
|
*/
|
||||||
if (!IsUnderPostmaster)
|
if (!IsUnderPostmaster)
|
||||||
{
|
{
|
||||||
@ -1242,6 +1243,7 @@ ShutdownPostgres(int code, Datum arg)
|
|||||||
#ifdef USE_ASSERT_CHECKING
|
#ifdef USE_ASSERT_CHECKING
|
||||||
{
|
{
|
||||||
int held_lwlocks = LWLockHeldCount();
|
int held_lwlocks = LWLockHeldCount();
|
||||||
|
|
||||||
if (held_lwlocks)
|
if (held_lwlocks)
|
||||||
elog(WARNING, "holding %d lwlocks at the end of ShutdownPostgres()",
|
elog(WARNING, "holding %d lwlocks at the end of ShutdownPostgres()",
|
||||||
held_lwlocks);
|
held_lwlocks);
|
||||||
|
@ -706,8 +706,8 @@ qsort_tuple_unsigned_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
|
|||||||
return compare;
|
return compare;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No need to waste effort calling the tiebreak function when there are
|
* No need to waste effort calling the tiebreak function when there are no
|
||||||
* no other keys to sort on.
|
* other keys to sort on.
|
||||||
*/
|
*/
|
||||||
if (state->onlyKey != NULL)
|
if (state->onlyKey != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@ -730,8 +730,8 @@ qsort_tuple_signed_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
|
|||||||
return compare;
|
return compare;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No need to waste effort calling the tiebreak function when there are
|
* No need to waste effort calling the tiebreak function when there are no
|
||||||
* no other keys to sort on.
|
* other keys to sort on.
|
||||||
*/
|
*/
|
||||||
if (state->onlyKey != NULL)
|
if (state->onlyKey != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@ -754,8 +754,8 @@ qsort_tuple_int32_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
|
|||||||
return compare;
|
return compare;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No need to waste effort calling the tiebreak function when there are
|
* No need to waste effort calling the tiebreak function when there are no
|
||||||
* no other keys to sort on.
|
* other keys to sort on.
|
||||||
*/
|
*/
|
||||||
if (state->onlyKey != NULL)
|
if (state->onlyKey != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1808,8 +1808,8 @@ make_template0(FILE *cmdfd)
|
|||||||
* the new cluster should be the result of a fresh initdb.)
|
* the new cluster should be the result of a fresh initdb.)
|
||||||
*
|
*
|
||||||
* We use "STRATEGY = file_copy" here because checkpoints during initdb
|
* We use "STRATEGY = file_copy" here because checkpoints during initdb
|
||||||
* are cheap. "STRATEGY = wal_log" would generate more WAL, which would
|
* are cheap. "STRATEGY = wal_log" would generate more WAL, which would be
|
||||||
* be a little bit slower and make the new cluster a little bit bigger.
|
* a little bit slower and make the new cluster a little bit bigger.
|
||||||
*/
|
*/
|
||||||
static const char *const template0_setup[] = {
|
static const char *const template0_setup[] = {
|
||||||
"CREATE DATABASE template0 IS_TEMPLATE = true ALLOW_CONNECTIONS = false"
|
"CREATE DATABASE template0 IS_TEMPLATE = true ALLOW_CONNECTIONS = false"
|
||||||
|
@ -97,27 +97,45 @@ SKIP:
|
|||||||
|
|
||||||
if ($ENV{with_icu} eq 'yes')
|
if ($ENV{with_icu} eq 'yes')
|
||||||
{
|
{
|
||||||
command_fails_like(['initdb', '--no-sync', '--locale-provider=icu', "$tempdir/data2"],
|
command_fails_like(
|
||||||
|
[ 'initdb', '--no-sync', '--locale-provider=icu', "$tempdir/data2" ],
|
||||||
qr/initdb: error: ICU locale must be specified/,
|
qr/initdb: error: ICU locale must be specified/,
|
||||||
'locale provider ICU requires --icu-locale');
|
'locale provider ICU requires --icu-locale');
|
||||||
|
|
||||||
command_ok(['initdb', '--no-sync', '--locale-provider=icu', '--icu-locale=en', "$tempdir/data3"],
|
command_ok(
|
||||||
|
[
|
||||||
|
'initdb', '--no-sync',
|
||||||
|
'--locale-provider=icu', '--icu-locale=en',
|
||||||
|
"$tempdir/data3"
|
||||||
|
],
|
||||||
'option --icu-locale');
|
'option --icu-locale');
|
||||||
|
|
||||||
command_fails_like(['initdb', '--no-sync', '--locale-provider=icu', '--icu-locale=@colNumeric=lower', "$tempdir/dataX"],
|
command_fails_like(
|
||||||
|
[
|
||||||
|
'initdb', '--no-sync',
|
||||||
|
'--locale-provider=icu', '--icu-locale=@colNumeric=lower',
|
||||||
|
"$tempdir/dataX"
|
||||||
|
],
|
||||||
qr/FATAL: could not open collator for locale/,
|
qr/FATAL: could not open collator for locale/,
|
||||||
'fails for invalid ICU locale');
|
'fails for invalid ICU locale');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
command_fails(['initdb', '--no-sync', '--locale-provider=icu', "$tempdir/data2"],
|
command_fails(
|
||||||
|
[ 'initdb', '--no-sync', '--locale-provider=icu', "$tempdir/data2" ],
|
||||||
'locale provider ICU fails since no ICU support');
|
'locale provider ICU fails since no ICU support');
|
||||||
}
|
}
|
||||||
|
|
||||||
command_fails(['initdb', '--no-sync', '--locale-provider=xyz', "$tempdir/dataX"],
|
command_fails(
|
||||||
|
[ 'initdb', '--no-sync', '--locale-provider=xyz', "$tempdir/dataX" ],
|
||||||
'fails for invalid locale provider');
|
'fails for invalid locale provider');
|
||||||
|
|
||||||
command_fails(['initdb', '--no-sync', '--locale-provider=libc', '--icu-locale=en', "$tempdir/dataX"],
|
command_fails(
|
||||||
|
[
|
||||||
|
'initdb', '--no-sync',
|
||||||
|
'--locale-provider=libc', '--icu-locale=en',
|
||||||
|
"$tempdir/dataX"
|
||||||
|
],
|
||||||
'fails for invalid option combination');
|
'fails for invalid option combination');
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
@ -1081,10 +1081,10 @@ verify_btree_slot_handler(PGresult *res, PGconn *conn, void *context)
|
|||||||
/*
|
/*
|
||||||
* We expect the btree checking functions to return one void row
|
* We expect the btree checking functions to return one void row
|
||||||
* each, or zero rows if the check was skipped due to the object
|
* each, or zero rows if the check was skipped due to the object
|
||||||
* being in the wrong state to be checked, so we should output some
|
* being in the wrong state to be checked, so we should output
|
||||||
* sort of warning if we get anything more, not because it
|
* some sort of warning if we get anything more, not because it
|
||||||
* indicates corruption, but because it suggests a mismatch between
|
* indicates corruption, but because it suggests a mismatch
|
||||||
* amcheck and pg_amcheck versions.
|
* between amcheck and pg_amcheck versions.
|
||||||
*
|
*
|
||||||
* In conjunction with --progress, anything written to stderr at
|
* In conjunction with --progress, anything written to stderr at
|
||||||
* this time would present strangely to the user without an extra
|
* this time would present strangely to the user without an extra
|
||||||
|
@ -155,8 +155,7 @@ $node->command_checks_all(
|
|||||||
[
|
[
|
||||||
qr/pg_amcheck: error: improper qualified name \(too many dotted names\): localhost\.postgres/
|
qr/pg_amcheck: error: improper qualified name \(too many dotted names\): localhost\.postgres/
|
||||||
],
|
],
|
||||||
'multipart database patterns are rejected'
|
'multipart database patterns are rejected');
|
||||||
);
|
|
||||||
|
|
||||||
# Check that a three-part schema name is rejected
|
# Check that a three-part schema name is rejected
|
||||||
$node->command_checks_all(
|
$node->command_checks_all(
|
||||||
@ -166,8 +165,7 @@ $node->command_checks_all(
|
|||||||
[
|
[
|
||||||
qr/pg_amcheck: error: improper qualified name \(too many dotted names\): localhost\.postgres\.pg_catalog/
|
qr/pg_amcheck: error: improper qualified name \(too many dotted names\): localhost\.postgres\.pg_catalog/
|
||||||
],
|
],
|
||||||
'three part schema patterns are rejected'
|
'three part schema patterns are rejected');
|
||||||
);
|
|
||||||
|
|
||||||
# Check that a four-part table name is rejected
|
# Check that a four-part table name is rejected
|
||||||
$node->command_checks_all(
|
$node->command_checks_all(
|
||||||
@ -177,39 +175,44 @@ $node->command_checks_all(
|
|||||||
[
|
[
|
||||||
qr/pg_amcheck: error: improper relation name \(too many dotted names\): localhost\.postgres\.pg_catalog\.pg_class/
|
qr/pg_amcheck: error: improper relation name \(too many dotted names\): localhost\.postgres\.pg_catalog\.pg_class/
|
||||||
],
|
],
|
||||||
'four part table patterns are rejected'
|
'four part table patterns are rejected');
|
||||||
);
|
|
||||||
|
|
||||||
# Check that too many dotted names still draws an error under --no-strict-names
|
# Check that too many dotted names still draws an error under --no-strict-names
|
||||||
# That flag means that it is ok for the object to be missing, not that it is ok
|
# That flag means that it is ok for the object to be missing, not that it is ok
|
||||||
# for the object name to be ungrammatical
|
# for the object name to be ungrammatical
|
||||||
$node->command_checks_all(
|
$node->command_checks_all(
|
||||||
[ 'pg_amcheck', '--no-strict-names', '-t', 'this.is.a.really.long.dotted.string' ],
|
[
|
||||||
|
'pg_amcheck', '--no-strict-names',
|
||||||
|
'-t', 'this.is.a.really.long.dotted.string'
|
||||||
|
],
|
||||||
2,
|
2,
|
||||||
[qr/^$/],
|
[qr/^$/],
|
||||||
[
|
[
|
||||||
qr/pg_amcheck: error: improper relation name \(too many dotted names\): this\.is\.a\.really\.long\.dotted\.string/
|
qr/pg_amcheck: error: improper relation name \(too many dotted names\): this\.is\.a\.really\.long\.dotted\.string/
|
||||||
],
|
],
|
||||||
'ungrammatical table names still draw errors under --no-strict-names'
|
'ungrammatical table names still draw errors under --no-strict-names');
|
||||||
);
|
|
||||||
$node->command_checks_all(
|
$node->command_checks_all(
|
||||||
[ 'pg_amcheck', '--no-strict-names', '-s', 'postgres.long.dotted.string' ],
|
[
|
||||||
|
'pg_amcheck', '--no-strict-names', '-s',
|
||||||
|
'postgres.long.dotted.string'
|
||||||
|
],
|
||||||
2,
|
2,
|
||||||
[qr/^$/],
|
[qr/^$/],
|
||||||
[
|
[
|
||||||
qr/pg_amcheck: error: improper qualified name \(too many dotted names\): postgres\.long\.dotted\.string/
|
qr/pg_amcheck: error: improper qualified name \(too many dotted names\): postgres\.long\.dotted\.string/
|
||||||
],
|
],
|
||||||
'ungrammatical schema names still draw errors under --no-strict-names'
|
'ungrammatical schema names still draw errors under --no-strict-names');
|
||||||
);
|
|
||||||
$node->command_checks_all(
|
$node->command_checks_all(
|
||||||
[ 'pg_amcheck', '--no-strict-names', '-d', 'postgres.long.dotted.string' ],
|
[
|
||||||
|
'pg_amcheck', '--no-strict-names', '-d',
|
||||||
|
'postgres.long.dotted.string'
|
||||||
|
],
|
||||||
2,
|
2,
|
||||||
[qr/^$/],
|
[qr/^$/],
|
||||||
[
|
[
|
||||||
qr/pg_amcheck: error: improper qualified name \(too many dotted names\): postgres\.long\.dotted\.string/
|
qr/pg_amcheck: error: improper qualified name \(too many dotted names\): postgres\.long\.dotted\.string/
|
||||||
],
|
],
|
||||||
'ungrammatical database names still draw errors under --no-strict-names'
|
'ungrammatical database names still draw errors under --no-strict-names');
|
||||||
);
|
|
||||||
|
|
||||||
# Likewise for exclusion patterns
|
# Likewise for exclusion patterns
|
||||||
$node->command_checks_all(
|
$node->command_checks_all(
|
||||||
|
@ -33,8 +33,7 @@ $node->safe_psql(
|
|||||||
));
|
));
|
||||||
|
|
||||||
# We have not yet broken the index, so we should get no corruption
|
# We have not yet broken the index, so we should get no corruption
|
||||||
$node->command_like(
|
$node->command_like([ 'pg_amcheck', '-p', $node->port, 'postgres' ],
|
||||||
[ 'pg_amcheck', '-p', $node->port, 'postgres' ],
|
|
||||||
qr/^$/,
|
qr/^$/,
|
||||||
'pg_amcheck all schemas, tables and indexes reports no corruption');
|
'pg_amcheck all schemas, tables and indexes reports no corruption');
|
||||||
|
|
||||||
|
@ -288,8 +288,9 @@ bbstreamer_gzip_decompressor_content(bbstreamer *streamer,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This call decompresses data starting at zs->next_in and updates
|
* This call decompresses data starting at zs->next_in and updates
|
||||||
* zs->next_in * and zs->avail_in. It generates output data starting at
|
* zs->next_in * and zs->avail_in. It generates output data starting
|
||||||
* zs->next_out and updates zs->next_out and zs->avail_out accordingly.
|
* at zs->next_out and updates zs->next_out and zs->avail_out
|
||||||
|
* accordingly.
|
||||||
*/
|
*/
|
||||||
res = inflate(zs, Z_NO_FLUSH);
|
res = inflate(zs, Z_NO_FLUSH);
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user