1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +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:
Tom Lane
2022-05-12 15:17:30 -04:00
parent 93909599cd
commit 23e7b38bfe
287 changed files with 5193 additions and 3549 deletions

View File

@ -1402,17 +1402,17 @@ check_tuple_attribute(HeapCheckContext *ctx)
cmid = TOAST_COMPRESS_METHOD(&toast_pointer);
switch (cmid)
{
/* List of all valid compression method IDs */
/* List of all valid compression method IDs */
case TOAST_PGLZ_COMPRESSION_ID:
case TOAST_LZ4_COMPRESSION_ID:
valid = true;
break;
/* Recognized but invalid compression method ID */
/* Recognized but invalid compression method ID */
case TOAST_INVALID_COMPRESSION_ID:
break;
/* Intentionally no default here */
/* Intentionally no default here */
}
if (!valid)
report_corruption(ctx,

View File

@ -37,13 +37,13 @@ typedef struct bbsink_shell
FILE *pipe;
} bbsink_shell;
void _PG_init(void);
void _PG_init(void);
static void *shell_check_detail(char *target, char *target_detail);
static bbsink *shell_get_sink(bbsink *next_sink, void *detail_arg);
static void bbsink_shell_begin_archive(bbsink *sink,
const char *archive_name);
const char *archive_name);
static void bbsink_shell_archive_contents(bbsink *sink, size_t len);
static void bbsink_shell_end_archive(bbsink *sink);
static void bbsink_shell_begin_manifest(bbsink *sink);
@ -101,7 +101,7 @@ shell_check_detail(char *target, char *target_detail)
{
if (shell_required_role[0] != '\0')
{
Oid roleid;
Oid roleid;
StartTransactionCommand();
roleid = get_role_oid(shell_required_role, true);
@ -125,8 +125,8 @@ static bbsink *
shell_get_sink(bbsink *next_sink, void *detail_arg)
{
bbsink_shell *sink;
bool has_detail_escape = false;
char *c;
bool has_detail_escape = false;
char *c;
/*
* Set up the bbsink.
@ -171,15 +171,15 @@ shell_get_sink(bbsink *next_sink, void *detail_arg)
/*
* Since we're passing the string provided by the user to popen(), it will
* be interpreted by the shell, which is a potential security
* vulnerability, since the user invoking this module is not necessarily
* a superuser. To stay out of trouble, we must disallow any shell
* vulnerability, since the user invoking this module is not necessarily a
* superuser. To stay out of trouble, we must disallow any shell
* metacharacters here; to be conservative and keep things simple, we
* allow only alphanumerics.
*/
if (sink->target_detail != NULL)
{
char *d;
bool scary = false;
char *d;
bool scary = false;
for (d = sink->target_detail; *d != '\0'; ++d)
{
@ -210,7 +210,7 @@ static char *
shell_construct_command(char *base_command, const char *filename,
char *target_detail)
{
StringInfoData buf;
StringInfoData buf;
char *c;
initStringInfo(&buf);
@ -271,7 +271,7 @@ shell_construct_command(char *base_command, const char *filename,
static void
shell_finish_command(bbsink_shell *sink)
{
int pclose_rc;
int pclose_rc;
/* There should be a command running. */
Assert(sink->current_command != NULL);
@ -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
* anyway, but we may get a more meaningful error message by
* doing this. If not, we'll fall through to the generic error
* below.
* anyway, but we may get a more meaningful error message by doing
* this. If not, we'll fall through to the generic error below.
*/
shell_finish_command(sink);
errno = EPIPE;

View File

@ -20,11 +20,12 @@ my $node = PostgreSQL::Test::Cluster->new('primary');
# 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.
$node->init('allows_streaming' => 1,
'auth_extra' => [ '--create-role', 'backupuser' ]);
$node->init(
'allows_streaming' => 1,
'auth_extra' => [ '--create-role', 'backupuser' ]);
$node->append_conf('postgresql.conf',
"shared_preload_libraries = 'basebackup_to_shell'");
"shared_preload_libraries = 'basebackup_to_shell'");
$node->start;
$node->safe_psql('postgres', 'CREATE USER backupuser REPLICATION');
$node->safe_psql('postgres', 'CREATE ROLE trustworthy');
@ -41,61 +42,61 @@ my @pg_basebackup_cmd = (@pg_basebackup_defs, '-U', 'backupuser', '-Xfetch');
# Can't use this module without setting basebackup_to_shell.command.
$node->command_fails_like(
[ @pg_basebackup_cmd, '--target', 'shell' ],
[ @pg_basebackup_cmd, '--target', 'shell' ],
qr/shell command for backup is not configured/,
'fails if basebackup_to_shell.command is not set');
# 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;
$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 =
$PostgreSQL::Test::Utils::windows_os
? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
: qq{$gzip --fast > "$escaped_backup_path/%f.gz"};
$PostgreSQL::Test::Utils::windows_os
? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
: qq{$gzip --fast > "$escaped_backup_path/%f.gz"};
$node->append_conf('postgresql.conf',
"basebackup_to_shell.command='$shell_command'");
"basebackup_to_shell.command='$shell_command'");
$node->reload();
# Should work now.
$node->command_ok(
[ @pg_basebackup_cmd, '--target', 'shell' ],
[ @pg_basebackup_cmd, '--target', 'shell' ],
'backup with no detail: pg_basebackup');
verify_backup('', $backup_path, "backup with no detail");
# Should fail with a detail.
$node->command_fails_like(
[ @pg_basebackup_cmd, '--target', 'shell:foo' ],
[ @pg_basebackup_cmd, '--target', 'shell:foo' ],
qr/a target detail is not permitted because the configured command does not include %d/,
'fails if detail provided without %d');
# Reconfigure to restrict access and require a detail.
$shell_command =
$PostgreSQL::Test::Utils::windows_os
? qq{$gzip --fast > "$escaped_backup_path\\\\%d.%f.gz"}
: qq{$gzip --fast > "$escaped_backup_path/%d.%f.gz"};
$PostgreSQL::Test::Utils::windows_os
? qq{$gzip --fast > "$escaped_backup_path\\\\%d.%f.gz"}
: qq{$gzip --fast > "$escaped_backup_path/%d.%f.gz"};
$node->append_conf('postgresql.conf',
"basebackup_to_shell.command='$shell_command'");
"basebackup_to_shell.command='$shell_command'");
$node->append_conf('postgresql.conf',
"basebackup_to_shell.required_role='trustworthy'");
"basebackup_to_shell.required_role='trustworthy'");
$node->reload();
# Should fail due to lack of permission.
$node->command_fails_like(
[ @pg_basebackup_cmd, '--target', 'shell' ],
[ @pg_basebackup_cmd, '--target', 'shell' ],
qr/permission denied to use basebackup_to_shell/,
'fails if required_role not granted');
# Should fail due to lack of a detail.
$node->safe_psql('postgres', 'GRANT trustworthy TO backupuser');
$node->command_fails_like(
[ @pg_basebackup_cmd, '--target', 'shell' ],
[ @pg_basebackup_cmd, '--target', 'shell' ],
qr/a target detail is required because the configured command includes %d/,
'fails if %d is present and detail not given');
# Should work.
$node->command_ok(
[ @pg_basebackup_cmd, '--target', 'shell:bar' ],
$node->command_ok([ @pg_basebackup_cmd, '--target', 'shell:bar' ],
'backup with detail: pg_basebackup');
verify_backup('bar.', $backup_path, "backup with detail");
@ -105,30 +106,34 @@ sub verify_backup
{
my ($prefix, $backup_dir, $test_name) = @_;
ok(-f "$backup_dir/${prefix}backup_manifest.gz",
"$test_name: backup_manifest.gz was created");
ok(-f "$backup_dir/${prefix}base.tar.gz",
"$test_name: base.tar.gz was created");
ok( -f "$backup_dir/${prefix}backup_manifest.gz",
"$test_name: backup_manifest.gz was created");
ok( -f "$backup_dir/${prefix}base.tar.gz",
"$test_name: base.tar.gz was created");
SKIP: {
SKIP:
{
my $tar = $ENV{TAR};
skip "no tar program available", 1 if (!defined $tar || $tar eq '');
# Decompress.
system_or_bail($gzip, '-d',
$backup_dir . '/' . $prefix . 'backup_manifest.gz');
$backup_dir . '/' . $prefix . 'backup_manifest.gz');
system_or_bail($gzip, '-d',
$backup_dir . '/' . $prefix . 'base.tar.gz');
$backup_dir . '/' . $prefix . 'base.tar.gz');
# Untar.
my $extract_path = PostgreSQL::Test::Utils::tempdir;
system_or_bail($tar, 'xf', $backup_dir . '/' . $prefix . 'base.tar',
'-C', $extract_path);
'-C', $extract_path);
# Verify.
$node->command_ok([ 'pg_verifybackup', '-n',
'-m', "${backup_dir}/${prefix}backup_manifest",
'-e', $extract_path ],
"$test_name: backup verifies ok");
$node->command_ok(
[
'pg_verifybackup', '-n',
'-m', "${backup_dir}/${prefix}backup_manifest",
'-e', $extract_path
],
"$test_name: backup verifies ok");
}
}

View File

@ -40,8 +40,8 @@
PG_MODULE_MAGIC;
void _PG_init(void);
void _PG_archive_module_init(ArchiveModuleCallbacks *cb);
void _PG_init(void);
void _PG_archive_module_init(ArchiveModuleCallbacks *cb);
static char *archive_directory = NULL;
static MemoryContext basic_archive_context;
@ -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.
* Our check_configured callback also checks for this and prevents archiving
* from proceeding if it is still empty.
* Our check_configured callback also checks for this and prevents
* archiving from proceeding if it is still empty.
*/
if (*newval == NULL || *newval[0] == '\0')
return true;
@ -119,7 +119,7 @@ check_archive_directory(char **newval, void **extra, GucSource source)
}
/*
* Do a basic sanity check that the specified archive directory exists. It
* Do a basic sanity check that the specified archive directory exists. It
* could be removed at some point in the future, so we still need to be
* prepared for it not to exist in the actual archiving logic.
*/
@ -155,18 +155,19 @@ basic_archive_file(const char *file, const char *path)
MemoryContext oldcontext;
/*
* We run basic_archive_file_internal() in our own memory context so that we
* can easily reset it during error recovery (thus avoiding memory leaks).
* We run basic_archive_file_internal() in our own memory context so that
* we can easily reset it during error recovery (thus avoiding memory
* leaks).
*/
oldcontext = MemoryContextSwitchTo(basic_archive_context);
/*
* Since the archiver operates at the bottom of the exception stack, ERRORs
* turn into FATALs and cause the archiver process to restart. However,
* using ereport(ERROR, ...) when there are problems is easy to code and
* maintain. Therefore, we create our own exception handler to catch ERRORs
* and return false instead of restarting the archiver whenever there is a
* failure.
* Since the archiver operates at the bottom of the exception stack,
* ERRORs turn into FATALs and cause the archiver process to restart.
* However, using ereport(ERROR, ...) when there are problems is easy to
* code and maintain. Therefore, we create our own exception handler to
* catch ERRORs and return false instead of restarting the archiver
* whenever there is a failure.
*/
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);
/*
* First, check if the file has already been archived. If it already exists
* and has the same contents as the file we're trying to archive, we can
* return success (after ensuring the file is persisted to disk). This
* scenario is possible if the server crashed after archiving the file but
* before renaming its .ready file to .done.
* First, check if the file has already been archived. If it already
* exists and has the same contents as the file we're trying to archive,
* we can return success (after ensuring the file is persisted to disk).
* This scenario is possible if the server crashed after archiving the
* file but before renaming its .ready file to .done.
*
* If the archive file already exists but has different contents, something
* might be wrong, so we just fail.
* If the archive file already exists but has different contents,
* something might be wrong, so we just fail.
*/
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);
/*
* Copy the file to its temporary destination. Note that this will fail if
* temp already exists.
* Copy the file to its temporary destination. Note that this will fail
* if temp already exists.
*/
copy_file(unconstify(char *, path), temp);
@ -318,9 +319,9 @@ compare_files(const char *file1, const char *file2)
for (;;)
{
int nbytes = 0;
int buf1_len = 0;
int buf2_len = 0;
int nbytes = 0;
int buf1_len = 0;
int buf2_len = 0;
while (buf1_len < CMP_BUF_SIZE)
{

View File

@ -53,8 +53,8 @@ gbt_boollt(const void *a, const void *b, FmgrInfo *flinfo)
static int
gbt_boolkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
{
boolKEY *ia = (boolKEY *) (((const Nsrt *) a)->t);
boolKEY *ib = (boolKEY *) (((const Nsrt *) b)->t);
boolKEY *ia = (boolKEY *) (((const Nsrt *) a)->t);
boolKEY *ib = (boolKEY *) (((const Nsrt *) b)->t);
if (ia->lower == ib->lower)
{

View File

@ -99,7 +99,7 @@ hstore_to_plpython(PG_FUNCTION_ARGS)
PyObject *key;
key = PLyUnicode_FromStringAndSize(HSTORE_KEY(entries, base, i),
HSTORE_KEYLEN(entries, i));
HSTORE_KEYLEN(entries, i));
if (HSTORE_VALISNULL(entries, i))
PyDict_SetItem(dict, key, Py_None);
else
@ -107,7 +107,7 @@ hstore_to_plpython(PG_FUNCTION_ARGS)
PyObject *value;
value = PLyUnicode_FromStringAndSize(HSTORE_VAL(entries, base, i),
HSTORE_VALLEN(entries, i));
HSTORE_VALLEN(entries, i));
PyDict_SetItem(dict, key, value);
Py_XDECREF(value);
}

View File

@ -63,12 +63,12 @@ brin_page_type(PG_FUNCTION_ARGS)
/* verify the special space has the expected size */
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(BrinSpecialSpace)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "BRIN"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(BrinSpecialSpace)),
(int) PageGetSpecialSize(page))));
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "BRIN"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(BrinSpecialSpace)),
(int) PageGetSpecialSize(page))));
switch (BrinPageType(page))
{
@ -103,12 +103,12 @@ verify_brin_page(bytea *raw_page, uint16 type, const char *strtype)
/* verify the special space has the expected size */
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(BrinSpecialSpace)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "BRIN"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(BrinSpecialSpace)),
(int) PageGetSpecialSize(page))));
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "BRIN"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(BrinSpecialSpace)),
(int) PageGetSpecialSize(page))));
/* verify the special space says this page is what we want */
if (BrinPageType(page) != type)

View File

@ -60,21 +60,21 @@ gist_page_opaque_info(PG_FUNCTION_ARGS)
/* verify the special space has the expected size */
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(GISTPageOpaqueData)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(GISTPageOpaqueData)),
(int) PageGetSpecialSize(page))));
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(GISTPageOpaqueData)),
(int) PageGetSpecialSize(page))));
opaq = GistPageGetOpaque(page);
if (opaq->gist_page_id != GIST_PAGE_ID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected %08x, got %08x.",
GIST_PAGE_ID,
opaq->gist_page_id)));
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected %08x, got %08x.",
GIST_PAGE_ID,
opaq->gist_page_id)));
/* Build a tuple descriptor for our result type */
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
@ -138,21 +138,21 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
/* verify the special space has the expected size */
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(GISTPageOpaqueData)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(GISTPageOpaqueData)),
(int) PageGetSpecialSize(page))));
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(GISTPageOpaqueData)),
(int) PageGetSpecialSize(page))));
opaq = GistPageGetOpaque(page);
if (opaq->gist_page_id != GIST_PAGE_ID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected %08x, got %08x.",
GIST_PAGE_ID,
opaq->gist_page_id)));
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected %08x, got %08x.",
GIST_PAGE_ID,
opaq->gist_page_id)));
/* Avoid bogus PageGetMaxOffsetNumber() call with deleted pages */
if (GistPageIsDeleted(page))

View File

@ -1533,7 +1533,10 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
HASH_SEQ_STATUS hash_seq;
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);
/* hash table must exist already */

View File

@ -47,7 +47,7 @@ static XLogRecPtr ValidateInputLSNs(bool till_end_of_wal,
XLogRecPtr start_lsn, XLogRecPtr end_lsn);
static void GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
XLogRecPtr end_lsn);
static void GetXLogSummaryStats(XLogStats * stats, ReturnSetInfo *rsinfo,
static void GetXLogSummaryStats(XLogStats *stats, ReturnSetInfo *rsinfo,
Datum *values, bool *nulls, uint32 ncols,
bool stats_per_record);
static void FillXLogStatsRow(const char *name, uint64 n, uint64 total_count,
@ -102,7 +102,7 @@ InitXLogReaderState(XLogRecPtr lsn, XLogRecPtr *first_record)
LSN_FORMAT_ARGS(lsn))));
private_data = (ReadLocalXLogPageNoWaitPrivate *)
palloc0(sizeof(ReadLocalXLogPageNoWaitPrivate));
palloc0(sizeof(ReadLocalXLogPageNoWaitPrivate));
xlogreader = XLogReaderAllocate(wal_segment_size, NULL,
XL_ROUTINE(.page_read = &read_local_xlog_page_no_wait,
@ -143,7 +143,7 @@ static XLogRecord *
ReadNextXLogRecord(XLogReaderState *xlogreader, XLogRecPtr first_record)
{
XLogRecord *record;
char *errormsg;
char *errormsg;
record = XLogReadRecord(xlogreader, &errormsg);
@ -153,7 +153,7 @@ ReadNextXLogRecord(XLogReaderState *xlogreader, XLogRecPtr first_record)
/* return NULL, if end of WAL is reached */
private_data = (ReadLocalXLogPageNoWaitPrivate *)
xlogreader->private_data;
xlogreader->private_data;
if (private_data->end_of_wal)
return NULL;
@ -181,12 +181,12 @@ GetWALRecordInfo(XLogReaderState *record, XLogRecPtr lsn,
Datum *values, bool *nulls, uint32 ncols)
{
const char *id;
RmgrData desc;
uint32 fpi_len = 0;
RmgrData desc;
uint32 fpi_len = 0;
StringInfoData rec_desc;
StringInfoData rec_blk_ref;
uint32 main_data_len;
int i = 0;
uint32 main_data_len;
int i = 0;
desc = GetRmgr(XLogRecGetRmid(record));
id = desc.rm_identify(XLogRecGetInfo(record));
@ -228,9 +228,9 @@ Datum
pg_get_wal_record_info(PG_FUNCTION_ARGS)
{
#define PG_GET_WAL_RECORD_INFO_COLS 11
Datum result;
Datum values[PG_GET_WAL_RECORD_INFO_COLS];
bool nulls[PG_GET_WAL_RECORD_INFO_COLS];
Datum result;
Datum values[PG_GET_WAL_RECORD_INFO_COLS];
bool nulls[PG_GET_WAL_RECORD_INFO_COLS];
XLogRecPtr lsn;
XLogRecPtr curr_lsn;
XLogRecPtr first_record;
@ -334,8 +334,8 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
XLogRecPtr first_record;
XLogReaderState *xlogreader;
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
Datum values[PG_GET_WAL_RECORDS_INFO_COLS];
bool nulls[PG_GET_WAL_RECORDS_INFO_COLS];
Datum values[PG_GET_WAL_RECORDS_INFO_COLS];
bool nulls[PG_GET_WAL_RECORDS_INFO_COLS];
SetSingleFuncCall(fcinfo, 0);
@ -418,11 +418,11 @@ FillXLogStatsRow(const char *name,
uint64 tot_len, uint64 total_len,
Datum *values, bool *nulls, uint32 ncols)
{
double n_pct,
rec_len_pct,
fpi_len_pct,
tot_len_pct;
int i = 0;
double n_pct,
rec_len_pct,
fpi_len_pct,
tot_len_pct;
int i = 0;
n_pct = 0;
if (total_count != 0)
@ -461,11 +461,11 @@ GetXLogSummaryStats(XLogStats *stats, ReturnSetInfo *rsinfo,
Datum *values, bool *nulls, uint32 ncols,
bool stats_per_record)
{
uint64 total_count = 0;
uint64 total_rec_len = 0;
uint64 total_fpi_len = 0;
uint64 total_len = 0;
int ri;
uint64 total_count = 0;
uint64 total_rec_len = 0;
uint64 total_fpi_len = 0;
uint64 total_len = 0;
int ri;
/*
* Each row shows its percentages of the total, so make a first pass to
@ -488,7 +488,7 @@ GetXLogSummaryStats(XLogStats *stats, ReturnSetInfo *rsinfo,
uint64 rec_len;
uint64 fpi_len;
uint64 tot_len;
RmgrData desc;
RmgrData desc;
if (!RmgrIdIsValid(ri))
continue;
@ -500,7 +500,7 @@ GetXLogSummaryStats(XLogStats *stats, ReturnSetInfo *rsinfo,
if (stats_per_record)
{
int rj;
int rj;
for (rj = 0; rj < MAX_XLINFO_TYPES; rj++)
{
@ -556,10 +556,10 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
#define PG_GET_WAL_STATS_COLS 9
XLogRecPtr first_record;
XLogReaderState *xlogreader;
XLogStats stats;
XLogStats stats;
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
Datum values[PG_GET_WAL_STATS_COLS];
bool nulls[PG_GET_WAL_STATS_COLS];
Datum values[PG_GET_WAL_STATS_COLS];
bool nulls[PG_GET_WAL_STATS_COLS];
SetSingleFuncCall(fcinfo, 0);
@ -599,7 +599,7 @@ pg_get_wal_stats(PG_FUNCTION_ARGS)
{
XLogRecPtr start_lsn;
XLogRecPtr end_lsn;
bool stats_per_record;
bool stats_per_record;
start_lsn = PG_GETARG_LSN(0);
end_lsn = PG_GETARG_LSN(1);
@ -623,7 +623,7 @@ pg_get_wal_stats_till_end_of_wal(PG_FUNCTION_ARGS)
{
XLogRecPtr start_lsn;
XLogRecPtr end_lsn = InvalidXLogRecPtr;
bool stats_per_record;
bool stats_per_record;
start_lsn = PG_GETARG_LSN(0);
stats_per_record = PG_GETARG_BOOL(1);

View File

@ -373,7 +373,8 @@ gen_ossl_decrypt(PX_Cipher *c, int padding, const uint8 *data, unsigned dlen,
uint8 *res, unsigned *rlen)
{
OSSLCipher *od = c->ptr;
int outlen, outlen2;
int outlen,
outlen2;
if (!od->init)
{
@ -402,7 +403,8 @@ gen_ossl_encrypt(PX_Cipher *c, int padding, const uint8 *data, unsigned dlen,
uint8 *res, unsigned *rlen)
{
OSSLCipher *od = c->ptr;
int outlen, outlen2;
int outlen,
outlen2;
if (!od->init)
{

View File

@ -255,46 +255,46 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
if (RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind) ||
rel->rd_rel->relkind == RELKIND_SEQUENCE)
{
return pgstat_heap(rel, fcinfo);
return pgstat_heap(rel, fcinfo);
}
else if (rel->rd_rel->relkind == RELKIND_INDEX)
{
switch (rel->rd_rel->relam)
{
case BTREE_AM_OID:
return pgstat_index(rel, BTREE_METAPAGE + 1,
pgstat_btree_page, fcinfo);
case HASH_AM_OID:
return pgstat_index(rel, HASH_METAPAGE + 1,
pgstat_hash_page, fcinfo);
case GIST_AM_OID:
return pgstat_index(rel, GIST_ROOT_BLKNO + 1,
pgstat_gist_page, fcinfo);
case GIN_AM_OID:
err = "gin index";
break;
case SPGIST_AM_OID:
err = "spgist index";
break;
case BRIN_AM_OID:
err = "brin index";
break;
default:
err = "unknown index";
break;
}
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("index \"%s\" (%s) is not supported",
RelationGetRelationName(rel), err)));
switch (rel->rd_rel->relam)
{
case BTREE_AM_OID:
return pgstat_index(rel, BTREE_METAPAGE + 1,
pgstat_btree_page, fcinfo);
case HASH_AM_OID:
return pgstat_index(rel, HASH_METAPAGE + 1,
pgstat_hash_page, fcinfo);
case GIST_AM_OID:
return pgstat_index(rel, GIST_ROOT_BLKNO + 1,
pgstat_gist_page, fcinfo);
case GIN_AM_OID:
err = "gin index";
break;
case SPGIST_AM_OID:
err = "spgist index";
break;
case BRIN_AM_OID:
err = "brin index";
break;
default:
err = "unknown index";
break;
}
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("index \"%s\" (%s) is not supported",
RelationGetRelationName(rel), err)));
}
else
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot get tuple-level statistics for relation \"%s\"",
RelationGetRelationName(rel)),
errdetail_relkind_not_supported(rel->rd_rel->relkind)));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot get tuple-level statistics for relation \"%s\"",
RelationGetRelationName(rel)),
errdetail_relkind_not_supported(rel->rd_rel->relkind)));
}
return 0; /* should not happen */

View File

@ -654,10 +654,10 @@ do_sql_command_end(PGconn *conn, const char *sql, bool consume_input)
PGresult *res;
/*
* If requested, consume whatever data is available from the socket.
* (Note that if all data is available, this allows pgfdw_get_result to
* call PQgetResult without forcing the overhead of WaitLatchOrSocket,
* which would be large compared to the overhead of PQconsumeInput.)
* If requested, consume whatever data is available from the socket. (Note
* that if all data is available, this allows pgfdw_get_result to call
* PQgetResult without forcing the overhead of WaitLatchOrSocket, which
* would be large compared to the overhead of PQconsumeInput.)
*/
if (consume_input && !PQconsumeInput(conn))
pgfdw_report_error(ERROR, NULL, conn, false, sql);
@ -1560,6 +1560,7 @@ pgfdw_finish_pre_commit_cleanup(List *pending_entries)
entry = (ConnCacheEntry *) lfirst(lc);
Assert(entry->changing_xact_state);
/*
* We might already have received the result on the socket, so pass
* 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);
Assert(entry->changing_xact_state);
/*
* We might already have received the result on the socket, so pass
* consume_input=true to try to consume it first

View File

@ -1243,9 +1243,9 @@ postgresGetForeignPlan(PlannerInfo *root,
if (best_path->fdw_private)
{
has_final_sort = boolVal(list_nth(best_path->fdw_private,
FdwPathPrivateHasFinalSort));
FdwPathPrivateHasFinalSort));
has_limit = boolVal(list_nth(best_path->fdw_private,
FdwPathPrivateHasLimit));
FdwPathPrivateHasLimit));
}
if (IS_SIMPLE_REL(foreignrel))
@ -1926,7 +1926,7 @@ postgresBeginForeignModify(ModifyTableState *mtstate,
values_end_len = intVal(list_nth(fdw_private,
FdwModifyPrivateLen));
has_returning = boolVal(list_nth(fdw_private,
FdwModifyPrivateHasReturning));
FdwModifyPrivateHasReturning));
retrieved_attrs = (List *) list_nth(fdw_private,
FdwModifyPrivateRetrievedAttrs);
@ -2686,11 +2686,11 @@ postgresBeginDirectModify(ForeignScanState *node, int eflags)
dmstate->query = strVal(list_nth(fsplan->fdw_private,
FdwDirectModifyPrivateUpdateSql));
dmstate->has_returning = boolVal(list_nth(fsplan->fdw_private,
FdwDirectModifyPrivateHasReturning));
FdwDirectModifyPrivateHasReturning));
dmstate->retrieved_attrs = (List *) list_nth(fsplan->fdw_private,
FdwDirectModifyPrivateRetrievedAttrs);
dmstate->set_processed = boolVal(list_nth(fsplan->fdw_private,
FdwDirectModifyPrivateSetProcessed));
FdwDirectModifyPrivateSetProcessed));
/* Create context for per-tuple temp workspace. */
dmstate->temp_cxt = AllocSetContextCreate(estate->es_query_cxt,

View File

@ -300,8 +300,8 @@ pg_decode_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
txn->output_plugin_private = txndata;
/*
* If asked to skip empty transactions, we'll emit BEGIN at the point where
* the first operation is received for this transaction.
* If asked to skip empty transactions, we'll emit BEGIN at the point
* where the first operation is received for this transaction.
*/
if (data->skip_empty_xacts)
return;
@ -360,8 +360,8 @@ pg_decode_begin_prepare_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
txn->output_plugin_private = txndata;
/*
* If asked to skip empty transactions, we'll emit BEGIN at the point where
* the first operation is received for this transaction.
* If asked to skip empty transactions, we'll emit BEGIN at the point
* where the first operation is received for this transaction.
*/
if (data->skip_empty_xacts)
return;