pgindent run for release 9.3

This is the first run of the Perl-based pgindent script.  Also update
pgindent instructions.
This commit is contained in:
Bruce Momjian 2013-05-29 16:58:43 -04:00
parent 07ab261ef3
commit 9af4159fce
367 changed files with 4222 additions and 3829 deletions

View File

@ -97,7 +97,6 @@ gbt_bit_xfrm(bytea *leaf)
static GBT_VARKEY *
gbt_bit_l2n(GBT_VARKEY *leaf)
{
GBT_VARKEY *out = leaf;
GBT_VARKEY_R r = gbt_var_key_readable(leaf);
bytea *o;

View File

@ -121,7 +121,6 @@ gbt_text_compress(PG_FUNCTION_ARGS)
Datum
gbt_bpchar_compress(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GISTENTRY *retval;

View File

@ -382,7 +382,6 @@ gbt_ts_union(PG_FUNCTION_ARGS)
Datum
gbt_ts_penalty(PG_FUNCTION_ARGS)
{
tsKEY *origentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
tsKEY *newentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2);

View File

@ -137,7 +137,6 @@ gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_nin
bool
gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo)
{
GBT_NUMKEY_R b1,
b2;
@ -159,7 +158,6 @@ gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo
void
gbt_num_bin_union(Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo)
{
GBT_NUMKEY_R rd;
rd.lower = &e[0];

View File

@ -56,7 +56,6 @@ gbt_var_decompress(PG_FUNCTION_ARGS)
GBT_VARKEY_R
gbt_var_key_readable(const GBT_VARKEY *k)
{
GBT_VARKEY_R r;
r.lower = (bytea *) &(((char *) k)[VARHDRSZ]);
@ -270,7 +269,6 @@ gbt_var_bin_union(Datum *u, GBT_VARKEY *e, Oid collation,
GISTENTRY *
gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)
{
GISTENTRY *retval;
if (entry->leafkey)
@ -299,7 +297,6 @@ GBT_VARKEY *
gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation,
const gbtree_vinfo *tinfo)
{
int i = 0,
numranges = entryvec->n;
GBT_VARKEY *cur;

View File

@ -1984,9 +1984,9 @@ dblink_fdw_validator(PG_FUNCTION_ARGS)
if (!is_valid_dblink_option(options, def->defname, context))
{
/*
* Unknown option, or invalid option for the context specified,
* so complain about it. Provide a hint with list of valid
* options for the context.
* Unknown option, or invalid option for the context specified, so
* complain about it. Provide a hint with list of valid options
* for the context.
*/
StringInfoData buf;
const PQconninfoOption *opt;

View File

@ -299,8 +299,8 @@ main(int argc, char **argv)
dryrun = true;
break;
case 'x':
additional_ext = strdup(optarg); /* Extension to remove from
* xlogfile names */
additional_ext = strdup(optarg); /* Extension to remove
* from xlogfile names */
break;
default:
fprintf(stderr, "Try \"%s --help\" for more information.\n", progname);

View File

@ -110,8 +110,11 @@ test_timing(int32 duration)
uint64 total_time;
int64 time_elapsed = 0;
uint64 loop_count = 0;
uint64 prev, cur;
instr_time start_time, end_time, temp;
uint64 prev,
cur;
instr_time start_time,
end_time,
temp;
total_time = duration > 0 ? duration * 1000000 : 0;
@ -120,7 +123,8 @@ test_timing(int32 duration)
while (time_elapsed < total_time)
{
int32 diff, bits = 0;
int32 diff,
bits = 0;
prev = cur;
INSTR_TIME_SET_CURRENT(temp);
@ -163,7 +167,8 @@ test_timing(int32 duration)
static void
output(uint64 loop_count)
{
int64 max_bit = 31, i;
int64 max_bit = 31,
i;
/* find highest bit value */
while (max_bit > 0 && histogram[max_bit] == 0)

View File

@ -347,8 +347,8 @@ get_wildcard_part(const char *str, int lenstr,
else
{
/*
* Back up endword to the escape character when stopping at
* an escaped char, so that subsequent get_wildcard_part will
* Back up endword to the escape character when stopping at an
* escaped char, so that subsequent get_wildcard_part will
* restart from the escape character. We assume here that
* escape chars are single-byte.
*/

View File

@ -46,11 +46,9 @@ fix_path_separator(char *path)
*c = '\\';
return result;
#else
return path;
#endif
}
@ -164,9 +162,9 @@ check_new_cluster(void)
"Old and new cluster install users have different values for pg_authid.oid.\n");
/*
* We only allow the install user in the new cluster because other
* defined users might match users defined in the old cluster and
* generate an error during pg_dump restore.
* We only allow the install user in the new cluster because other defined
* users might match users defined in the old cluster and generate an
* error during pg_dump restore.
*/
if (new_cluster.role_count != 1)
pg_log(PG_FATAL, "Only the install user can be defined in the new cluster.\n");
@ -366,9 +364,9 @@ set_locale_and_encoding(ClusterInfo *cluster)
if (GET_MAJOR_VERSION(cluster->major_version) < 902)
{
/*
* Pre-9.2 did not canonicalize the supplied locale names
* to match what the system returns, while 9.2+ does, so
* convert pre-9.2 to match.
* Pre-9.2 did not canonicalize the supplied locale names to match
* what the system returns, while 9.2+ does, so convert pre-9.2 to
* match.
*/
ctrl->lc_collate = get_canonical_locale_name(LC_COLLATE,
pg_strdup(PQgetvalue(res, 0, i_datcollate)));
@ -598,8 +596,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
/*
* Some users (oddly) create tablespaces inside the cluster data
* directory. We can't create a proper old cluster delete script
* in that case.
* directory. We can't create a proper old cluster delete script in that
* case.
*/
strlcpy(old_cluster_pgdata, old_cluster.pgdata, MAXPGPATH);
canonicalize_path(old_cluster_pgdata);

View File

@ -472,10 +472,10 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pg_free(lc_messages);
/*
* Before 9.3, pg_resetxlog reported the xlogid and segno of the first
* log file after reset as separate lines. Starting with 9.3, it reports
* the WAL file name. If the old cluster is older than 9.3, we construct
* the WAL file name from the xlogid and segno.
* Before 9.3, pg_resetxlog reported the xlogid and segno of the first log
* file after reset as separate lines. Starting with 9.3, it reports the
* WAL file name. If the old cluster is older than 9.3, we construct the
* WAL file name from the xlogid and segno.
*/
if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
{
@ -621,7 +621,10 @@ check_control_data(ControlData *oldctrl,
"options.\n");
}
/* We might eventually allow upgrades from checksum to no-checksum clusters. */
/*
* We might eventually allow upgrades from checksum to no-checksum
* clusters.
*/
if (oldctrl->data_checksum_version != newctrl->data_checksum_version)
{
pg_log(PG_FATAL,

View File

@ -44,6 +44,7 @@ exec_prog(const char *log_file, const char *opt_log_file,
{
int result;
int written;
#define MAXCMDLEN (2 * MAXPGPATH)
char cmd[MAXCMDLEN];
mode_t old_umask = 0;
@ -68,14 +69,14 @@ exec_prog(const char *log_file, const char *opt_log_file,
#ifdef WIN32
{
/*
* "pg_ctl -w stop" might have reported that the server has
* stopped because the postmaster.pid file has been removed,
* but "pg_ctl -w start" might still be in the process of
* closing and might still be holding its stdout and -l log
* file descriptors open. Therefore, try to open the log
* file a few more times.
* "pg_ctl -w stop" might have reported that the server has stopped
* because the postmaster.pid file has been removed, but "pg_ctl -w
* start" might still be in the process of closing and might still be
* holding its stdout and -l log file descriptors open. Therefore,
* try to open the log file a few more times.
*/
int iter;
for (iter = 0; iter < 4 && log == NULL; iter++)
{
sleep(1);
@ -122,10 +123,11 @@ exec_prog(const char *log_file, const char *opt_log_file,
}
#ifndef WIN32
/*
* We can't do this on Windows because it will keep the "pg_ctl start"
* output filename open until the server stops, so we do the \n\n above
* on that platform. We use a unique filename for "pg_ctl start" that is
* output filename open until the server stops, so we do the \n\n above on
* that platform. We use a unique filename for "pg_ctl start" that is
* never reused while the server is running, so it works fine. We could
* log these commands to a third file, but that just adds complexity.
*/
@ -178,7 +180,6 @@ pid_lock_file_exists(const char *datadir)
void
verify_directories(void)
{
#ifndef WIN32
if (access(".", R_OK | W_OK | X_OK) != 0)
#else

View File

@ -127,7 +127,6 @@ linkAndUpdateFile(pageCnvCtx *pageConverter,
static int
copy_file(const char *srcfile, const char *dstfile, bool force)
{
#define COPY_BUF_SIZE (50 * BLCKSZ)
int src_fd;

View File

@ -60,10 +60,9 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
* table names change during ALTER TABLE ALTER COLUMN SET TYPE. In >=
* 9.0, TOAST relation names always use heap table oids, hence we
* cannot check relation names when upgrading from pre-9.0. Clusters
* upgraded to 9.0 will get matching TOAST names.
* If index names don't match primary key constraint names, this will
* fail because pg_dump dumps constraint names and pg_upgrade checks
* index names.
* upgraded to 9.0 will get matching TOAST names. If index names don't
* match primary key constraint names, this will fail because pg_dump
* dumps constraint names and pg_upgrade checks index names.
*/
if (strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
((GET_MAJOR_VERSION(old_cluster.major_version) >= 900 ||
@ -79,7 +78,10 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
num_maps++;
}
/* Do this check after the loop so hopefully we will produce a clearer error above */
/*
* Do this check after the loop so hopefully we will produce a clearer
* error above
*/
if (old_db->rel_arr.nrels != new_db->rel_arr.nrels)
pg_log(PG_FATAL, "old and new databases \"%s\" have a different number of relations\n",
old_db->db_name);
@ -285,8 +287,11 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
"LEFT OUTER JOIN pg_catalog.pg_index i "
" ON c.oid = i.indexrelid "
"WHERE relkind IN ('r', 'm', 'i'%s) AND "
/* pg_dump only dumps valid indexes; testing indisready is
* necessary in 9.2, and harmless in earlier/later versions. */
/*
* pg_dump only dumps valid indexes; testing indisready is necessary in
* 9.2, and harmless in earlier/later versions.
*/
" i.indisvalid IS DISTINCT FROM false AND "
" i.indisready IS DISTINCT FROM false AND "
/* exclude possible orphaned temp tables */

View File

@ -314,8 +314,8 @@ check_required_directory(char **dirpath, char **configpath,
}
/*
* Trim off any trailing path separators because we construct paths
* by appending to this path.
* Trim off any trailing path separators because we construct paths by
* appending to this path.
*/
#ifndef WIN32
if ((*dirpath)[strlen(*dirpath) - 1] == '/')
@ -398,10 +398,10 @@ void
get_sock_dir(ClusterInfo *cluster, bool live_check)
{
#ifdef HAVE_UNIX_SOCKETS
/*
* sockdir and port were added to postmaster.pid in PG 9.1.
* Pre-9.1 cannot process pg_ctl -w for sockets in non-default
* locations.
* sockdir and port were added to postmaster.pid in PG 9.1. Pre-9.1 cannot
* process pg_ctl -w for sockets in non-default locations.
*/
if (GET_MAJOR_VERSION(cluster->major_version) >= 901)
{
@ -415,11 +415,13 @@ get_sock_dir(ClusterInfo *cluster, bool live_check)
else
{
/*
* If we are doing a live check, we will use the old cluster's Unix
* domain socket directory so we can connect to the live server.
* If we are doing a live check, we will use the old cluster's
* Unix domain socket directory so we can connect to the live
* server.
*/
unsigned short orig_port = cluster->port;
char filename[MAXPGPATH], line[MAXPGPATH];
char filename[MAXPGPATH],
line[MAXPGPATH];
FILE *fp;
int lineno;
@ -454,9 +456,12 @@ get_sock_dir(ClusterInfo *cluster, bool live_check)
}
}
else
/* Can't get sockdir and pg_ctl -w can't use a non-default, use default */
cluster->sockdir = NULL;
/*
* Can't get sockdir and pg_ctl -w can't use a non-default, use
* default
*/
cluster->sockdir = NULL;
#else /* !HAVE_UNIX_SOCKETS */
cluster->sockdir = NULL;
#endif

View File

@ -59,9 +59,9 @@ setupPageConverter(void)
if (newPageVersion != oldPageVersion)
{
/*
* The clusters use differing page layouts, see if we can find a plugin
* that knows how to convert from the old page layout to the new page
* layout.
* The clusters use differing page layouts, see if we can find a
* plugin that knows how to convert from the old page layout to the
* new page layout.
*/
if ((converter = loadConverterPlugin(newPageVersion, oldPageVersion)) == NULL)
@ -161,6 +161,4 @@ loadConverterPlugin(uint16 newPageVersion, uint16 oldPageVersion)
}
}
#endif

View File

@ -30,13 +30,15 @@ static int parallel_jobs;
*/
HANDLE *thread_handles;
typedef struct {
typedef struct
{
char log_file[MAXPGPATH];
char opt_log_file[MAXPGPATH];
char cmd[MAX_STRING];
} exec_thread_arg;
typedef struct {
typedef struct
{
DbInfoArr *old_db_arr;
DbInfoArr *new_db_arr;
char old_pgdata[MAXPGPATH];
@ -52,7 +54,6 @@ void **cur_thread_args;
DWORD win32_exec_prog(exec_thread_arg *args);
DWORD win32_transfer_all_new_dbs(transfer_thread_arg *args);
#endif
/*
@ -67,6 +68,7 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
{
va_list args;
char cmd[MAX_STRING];
#ifndef WIN32
pid_t child;
#else
@ -119,8 +121,8 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
/*
* For safety and performance, we keep the args allocated during
* the entire life of the process, and we don't free the args
* in a thread different from the one that allocated it.
* the entire life of the process, and we don't free the args in a
* thread different from the one that allocated it.
*/
for (i = 0; i < user_opts.jobs; i++)
exec_thread_args[i] = pg_malloc(sizeof(exec_thread_arg));
@ -167,7 +169,8 @@ win32_exec_prog(exec_thread_arg *args)
* This has the same API as transfer_all_new_dbs, except it does parallel execution
* by transfering multiple tablespaces in parallel
*/
void parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
void
parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
char *old_pgdata, char *new_pgdata,
char *old_tablespace)
{
@ -224,8 +227,8 @@ void parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
/*
* For safety and performance, we keep the args allocated during
* the entire life of the process, and we don't free the args
* in a thread different from the one that allocated it.
* the entire life of the process, and we don't free the args in a
* thread different from the one that allocated it.
*/
for (i = 0; i < user_opts.jobs; i++)
transfer_thread_args[i] = pg_malloc(sizeof(transfer_thread_arg));
@ -293,7 +296,6 @@ reap_child(bool wait_for_child)
if (WEXITSTATUS(work_status) != 0)
pg_log(PG_FATAL, "child worker exited abnormally: %s\n", strerror(errno));
#else
/* wait for one to finish */
thread_num = WaitForMultipleObjects(parallel_jobs, thread_handles,
@ -321,10 +323,10 @@ reap_child(bool wait_for_child)
thread_handles[thread_num] = thread_handles[parallel_jobs - 1];
/*
* We must swap the arg struct pointers because the thread we
* just moved is active, and we must make sure it is not
* reused by the next created thread. Instead, the new thread
* will use the arg struct of the thread that just died.
* We must swap the arg struct pointers because the thread we just
* moved is active, and we must make sure it is not reused by the next
* created thread. Instead, the new thread will use the arg struct of
* the thread that just died.
*/
tmp_args = cur_thread_args[thread_num];
cur_thread_args[thread_num] = cur_thread_args[parallel_jobs - 1];

View File

@ -193,13 +193,12 @@ setup(char *argv0, bool *live_check)
if (pid_lock_file_exists(old_cluster.pgdata))
{
/*
* If we have a postmaster.pid file, try to start the server. If
* it starts, the pid file was stale, so stop the server. If it
* doesn't start, assume the server is running. If the pid file
* is left over from a server crash, this also allows any committed
* transactions stored in the WAL to be replayed so they are not
* lost, because WAL files are not transfered from old to new
* servers.
* If we have a postmaster.pid file, try to start the server. If it
* starts, the pid file was stale, so stop the server. If it doesn't
* start, assume the server is running. If the pid file is left over
* from a server crash, this also allows any committed transactions
* stored in the WAL to be replayed so they are not lost, because WAL
* files are not transfered from old to new servers.
*/
if (start_postmaster(&old_cluster, false))
stop_postmaster(false);
@ -313,8 +312,8 @@ create_new_objects(void)
/*
* Technically, we only need to install these support functions in new
* databases that also exist in the old cluster, but for completeness
* we process all new databases.
* databases that also exist in the old cluster, but for completeness we
* process all new databases.
*/
for (dbnum = 0; dbnum < new_cluster.dbarr.ndbs; dbnum++)
{
@ -330,7 +329,8 @@ create_new_objects(void)
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
{
char sql_file_name[MAXPGPATH], log_file_name[MAXPGPATH];
char sql_file_name[MAXPGPATH],
log_file_name[MAXPGPATH];
DbInfo *old_db = &old_cluster.dbarr.dbs[dbnum];
pg_log(PG_STATUS, "%s", old_db->db_name);
@ -418,6 +418,7 @@ copy_clog_xlog_xid(void)
copy_subdir_files("pg_multixact/offsets");
copy_subdir_files("pg_multixact/members");
prep_status("Setting next multixact ID and offset for new cluster");
/*
* we preserve all files and contents, so we must preserve both "next"
* counters here and the oldest multi present on system.
@ -434,6 +435,7 @@ copy_clog_xlog_xid(void)
else if (new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
{
prep_status("Setting oldest multixact ID on new cluster");
/*
* We don't preserve files in this case, but it's important that the
* oldest multi is set to the latest value used by the old system, so
@ -549,7 +551,6 @@ set_frozenxids(void)
static void
cleanup(void)
{
fclose(log_opts.internal);
/* Remove dump and log files? */
@ -567,7 +568,8 @@ cleanup(void)
if (old_cluster.dbarr.dbs)
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
{
char sql_file_name[MAXPGPATH], log_file_name[MAXPGPATH];
char sql_file_name[MAXPGPATH],
log_file_name[MAXPGPATH];
DbInfo *old_db = &old_cluster.dbarr.dbs[dbnum];
snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);

View File

@ -477,11 +477,11 @@ void old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
char *old_8_3_create_sequence_script(ClusterInfo *cluster);
/* parallel.c */
void parallel_exec_prog(const char *log_file, const char *opt_log_file,
void
parallel_exec_prog(const char *log_file, const char *opt_log_file,
const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
void parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
char *old_pgdata, char *new_pgdata,
char *old_tablespace);
bool reap_child(bool wait_for_child);

View File

@ -35,11 +35,11 @@ transfer_all_new_tablespaces(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
/*
* Transfering files by tablespace is tricky because a single database
* can use multiple tablespaces. For non-parallel mode, we just pass a
* NULL tablespace path, which matches all tablespaces. In parallel mode,
* we pass the default tablespace and all user-created tablespaces
* and let those operations happen in parallel.
* Transfering files by tablespace is tricky because a single database can
* use multiple tablespaces. For non-parallel mode, we just pass a NULL
* tablespace path, which matches all tablespaces. In parallel mode, we
* pass the default tablespace and all user-created tablespaces and let
* those operations happen in parallel.
*/
if (user_opts.jobs <= 1)
parallel_transfer_all_new_dbs(old_db_arr, new_db_arr, old_pgdata,
@ -219,11 +219,9 @@ transfer_relfile(pageCnvCtx *pageConverter, FileNameMap *map,
char extent_suffix[65];
/*
* Now copy/link any related segments as well. Remember, PG breaks
* large files into 1GB segments, the first segment has no extension,
* subsequent segments are named relfilenode.1, relfilenode.2,
* relfilenode.3.
* copied.
* Now copy/link any related segments as well. Remember, PG breaks large
* files into 1GB segments, the first segment has no extension, subsequent
* segments are named relfilenode.1, relfilenode.2, relfilenode.3. copied.
*/
for (segno = 0;; segno++)
{
@ -286,4 +284,3 @@ transfer_relfile(pageCnvCtx *pageConverter, FileNameMap *map,
return;
}

View File

@ -89,6 +89,7 @@ static bool
verify_directory(const char *directory)
{
DIR *dir = opendir(directory);
if (dir == NULL)
return false;
closedir(dir);
@ -672,9 +673,9 @@ main(int argc, char **argv)
(uint32) private.startptr);
/*
* Display a message that we're skipping data if `from` wasn't a pointer to
* the start of a record and also wasn't a pointer to the beginning of a
* segment (e.g. we were used in file mode).
* Display a message that we're skipping data if `from` wasn't a pointer
* to the start of a record and also wasn't a pointer to the beginning of
* a segment (e.g. we were used in file mode).
*/
if (first_record != private.startptr && (private.startptr % XLogSegSize) != 0)
printf("first record is after %X/%X, at %X/%X, skipping over %u bytes\n",

View File

@ -33,4 +33,3 @@
const RmgrDescData RmgrDescTable[RM_MAX_ID + 1] = {
#include "access/rmgrlist.h"
};

View File

@ -162,7 +162,8 @@ char *index_tablespace = NULL;
bool use_log; /* log transaction latencies to a file */
bool use_quiet; /* quiet logging onto stderr */
int agg_interval; /* log aggregates instead of individual transactions */
int agg_interval; /* log aggregates instead of individual
* transactions */
bool is_connect; /* establish connection for each transaction */
bool is_latencies; /* report per-command latencies */
int main_pid; /* main process id used in log filename */
@ -265,7 +266,8 @@ typedef struct
int cnt; /* number of transactions */
double min_duration; /* min/max durations */
double max_duration;
double sum; /* sum(duration), sum(duration^2) - for estimates */
double sum; /* sum(duration), sum(duration^2) - for
* estimates */
double sum2;
} AggVals;
@ -874,7 +876,8 @@ clientDone(CState *st, bool ok)
}
static
void agg_vals_init(AggVals * aggs, instr_time start)
void
agg_vals_init(AggVals *aggs, instr_time start)
{
/* basic counters */
aggs->cnt = 0; /* number of transactions */
@ -964,8 +967,10 @@ top:
/* should we aggregate the results or not? */
if (agg_interval > 0)
{
/* are we still in the same interval? if yes, accumulate the
* values (print them otherwise) */
/*
* are we still in the same interval? if yes, accumulate
* the values (print them otherwise)
*/
if (agg->start_time + agg_interval >= INSTR_TIME_GET_DOUBLE(now))
{
agg->cnt += 1;
@ -981,12 +986,18 @@ top:
}
else
{
/* Loop until we reach the interval of the current transaction (and
* print all the empty intervals in between). */
/*
* Loop until we reach the interval of the current
* transaction (and print all the empty intervals in
* between).
*/
while (agg->start_time + agg_interval < INSTR_TIME_GET_DOUBLE(now))
{
/* This is a non-Windows branch (thanks to the ifdef in usage), so
* we don't need to handle this in a special way (see below). */
/*
* This is a non-Windows branch (thanks to the
* ifdef in usage), so we don't need to handle
* this in a special way (see below).
*/
fprintf(logfile, "%ld %d %.0f %.0f %.0f %.0f\n",
agg->start_time, agg->cnt, agg->sum, agg->sum2,
agg->min_duration, agg->max_duration);
@ -1002,7 +1013,10 @@ top:
agg->sum2 = 0;
}
/* and now update the reset values (include the current) */
/*
* and now update the reset values (include the
* current)
*/
agg->cnt = 1;
agg->min_duration = usec;
agg->max_duration = usec;
@ -1014,12 +1028,20 @@ top:
{
/* no, print raw transactions */
#ifndef WIN32
/* This is more than we really ought to know about instr_time */
/*
* This is more than we really ought to know about
* instr_time
*/
fprintf(logfile, "%d %d %.0f %d %ld %ld\n",
st->id, st->cnt, usec, st->use_file,
(long) now.tv_sec, (long) now.tv_usec);
#else
/* On Windows, instr_time doesn't provide a timestamp anyway */
/*
* On Windows, instr_time doesn't provide a timestamp
* anyway
*/
fprintf(logfile, "%d %d %.0f %d 0 0\n",
st->id, st->cnt, usec, st->use_file);
#endif
@ -1234,11 +1256,11 @@ top:
}
/*
* getrand() needs to be able to subtract max from min and add
* one to the result without overflowing. Since we know max > min,
* we can detect overflow just by checking for a negative result.
* But we must check both that the subtraction doesn't overflow,
* and that adding one to the result doesn't overflow either.
* getrand() needs to be able to subtract max from min and add one
* to the result without overflowing. Since we know max > min, we
* can detect overflow just by checking for a negative result. But
* we must check both that the subtraction doesn't overflow, and
* that adding one to the result doesn't overflow either.
*/
if (max - min < 0 || (max - min) + 1 < 0)
{
@ -1418,7 +1440,6 @@ disconnect_all(CState *state, int length)
static void
init(bool is_no_vacuum)
{
/* The scale factor at/beyond which 32bit integers are incapable of storing
* 64bit values.
*
@ -1488,8 +1509,10 @@ init(bool is_no_vacuum)
int64 k;
/* used to track elapsed time and estimate of the remaining time */
instr_time start, diff;
double elapsed_sec, remaining_sec;
instr_time start,
diff;
double elapsed_sec,
remaining_sec;
int log_interval = 1;
if ((con = doConnect()) == NULL)
@ -1573,8 +1596,10 @@ init(bool is_no_vacuum)
exit(1);
}
/* If we want to stick with the original logging, print a message each
* 100k inserted rows. */
/*
* If we want to stick with the original logging, print a message each
* 100k inserted rows.
*/
if ((!use_quiet) && (j % 100000 == 0))
{
INSTR_TIME_SET_CURRENT(diff);
@ -1598,7 +1623,8 @@ init(bool is_no_vacuum)
remaining_sec = (scale * naccounts - j) * elapsed_sec / j;
/* have we reached the next interval (or end)? */
if ((j == scale * naccounts) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS)) {
if ((j == scale * naccounts) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS))
{
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
j, (int64) naccounts * scale,
@ -2393,17 +2419,20 @@ main(int argc, char **argv)
exit(1);
}
if (agg_interval > 0 && (! use_log)) {
if (agg_interval > 0 && (!use_log))
{
fprintf(stderr, "log aggregation is allowed only when actually logging transactions\n");
exit(1);
}
if ((duration > 0) && (agg_interval > duration)) {
if ((duration > 0) && (agg_interval > duration))
{
fprintf(stderr, "number of seconds for aggregation (%d) must not be higher that test duration (%d)\n", agg_interval, duration);
exit(1);
}
if ((duration > 0) && (agg_interval > 0) && (duration % agg_interval != 0)) {
if ((duration > 0) && (agg_interval > 0) && (duration % agg_interval != 0))
{
fprintf(stderr, "duration (%d) must be a multiple of aggregation interval (%d)\n", duration, agg_interval);
exit(1);
}

View File

@ -117,14 +117,11 @@ mp_result mp_int_mul_value(mp_int a, int value, mp_int c);
mp_result mp_int_mul_pow2(mp_int a, int p2, mp_int c);
mp_result mp_int_sqr(mp_int a, mp_int c); /* c = a * a */
mp_result
mp_int_div(mp_int a, mp_int b, /* q = a / b */
mp_result mp_int_div(mp_int a, mp_int b, /* q = a / b */
mp_int q, mp_int r); /* r = a % b */
mp_result
mp_int_div_value(mp_int a, int value, /* q = a / value */
mp_result mp_int_div_value(mp_int a, int value, /* q = a / value */
mp_int q, int *r); /* r = a % value */
mp_result
mp_int_div_pow2(mp_int a, int p2, /* q = a / 2^p2 */
mp_result mp_int_div_pow2(mp_int a, int p2, /* q = a / 2^p2 */
mp_int q, mp_int r); /* r = q % 2^p2 */
mp_result mp_int_mod(mp_int a, mp_int m, mp_int c); /* c = a % m */
@ -143,17 +140,13 @@ int mp_int_divisible_value(mp_int a, int v);
/* Returns k >= 0 such that z = 2^k, if one exists; otherwise < 0 */
int mp_int_is_pow2(mp_int z);
mp_result
mp_int_exptmod(mp_int a, mp_int b, mp_int m,
mp_result mp_int_exptmod(mp_int a, mp_int b, mp_int m,
mp_int c); /* c = a^b (mod m) */
mp_result
mp_int_exptmod_evalue(mp_int a, int value,
mp_result mp_int_exptmod_evalue(mp_int a, int value,
mp_int m, mp_int c); /* c = a^v (mod m) */
mp_result
mp_int_exptmod_bvalue(int value, mp_int b,
mp_result mp_int_exptmod_bvalue(int value, mp_int b,
mp_int m, mp_int c); /* c = v^b (mod m) */
mp_result
mp_int_exptmod_known(mp_int a, mp_int b,
mp_result mp_int_exptmod_known(mp_int a, mp_int b,
mp_int m, mp_int mu,
mp_int c); /* c = a^b (mod m) */
mp_result mp_int_redux_const(mp_int m, mp_int c);
@ -162,8 +155,7 @@ mp_result mp_int_invmod(mp_int a, mp_int m, mp_int c); /* c = 1/a (mod m) */
mp_result mp_int_gcd(mp_int a, mp_int b, mp_int c); /* c = gcd(a, b) */
mp_result
mp_int_egcd(mp_int a, mp_int b, mp_int c, /* c = gcd(a, b) */
mp_result mp_int_egcd(mp_int a, mp_int b, mp_int c, /* c = gcd(a, b) */
mp_int x, mp_int y); /* c = ax + by */
mp_result mp_int_sqrt(mp_int a, mp_int c); /* c = floor(sqrt(q)) */

View File

@ -265,8 +265,7 @@ int pgp_s2k_read(PullFilter *src, PGP_S2K *s2k);
int pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int klen);
typedef struct PGP_CFB PGP_CFB;
int
pgp_cfb_create(PGP_CFB **ctx_p, int algo,
int pgp_cfb_create(PGP_CFB **ctx_p, int algo,
const uint8 *key, int key_len, int recync, uint8 *iv);
void pgp_cfb_free(PGP_CFB *ctx);
int pgp_cfb_encrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst);

View File

@ -280,8 +280,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
result = HeapTupleGetDatum(tuple);
/*
* no need to pfree what we allocated; it's on a short-lived memory
* context anyway
* no need to pfree what we allocated; it's on a short-lived
* memory context anyway
*/
SRF_RETURN_NEXT(funcctx, result);

View File

@ -211,9 +211,9 @@ sepgsql_object_access(ObjectAccessType access,
/*
* A case when we don't want to apply permission
* check is that relation is internally altered
* without user's intention. E.g, no need to
* check on toast table/index to be renamed at
* end of the table rewrites.
* without user's intention. E.g, no need to check
* on toast table/index to be renamed at end of
* the table rewrites.
*/
if (is_internal)
break;
@ -241,8 +241,8 @@ sepgsql_object_access(ObjectAccessType access,
ObjectAccessNamespaceSearch *ns_arg = arg;
/*
* If stacked extension already decided not to allow users
* to search this schema, we just stick with that decision.
* If stacked extension already decided not to allow users to
* search this schema, we just stick with that decision.
*/
if (!ns_arg->result)
break;

View File

@ -351,9 +351,8 @@ sepgsql_fmgr_hook(FmgrHookEventType event,
*
* Also, db_procedure:entrypoint permission should be checked
* whether this procedure can perform as an entrypoint of the
* trusted procedure, or not.
* Note that db_procedure:execute permission shall be checked
* individually.
* trusted procedure, or not. Note that db_procedure:execute
* permission shall be checked individually.
*/
if (stack->new_label)
{

View File

@ -81,6 +81,7 @@ sepgsql_schema_post_create(Oid namespaceId)
tcontext,
SEPG_CLASS_DB_SCHEMA,
nsp_name);
/*
* check db_schema:{create}
*/

View File

@ -237,11 +237,11 @@ worker_spi_main(void *main_arg)
* start time is always up to date.
*
* The SPI_connect() call lets us run queries through the SPI manager,
* and the PushActiveSnapshot() call creates an "active" snapshot which
* is necessary for queries to have MVCC data to work on.
* and the PushActiveSnapshot() call creates an "active" snapshot
* which is necessary for queries to have MVCC data to work on.
*
* The pgstat_report_activity() call makes our activity visible through
* the pgstat views.
* The pgstat_report_activity() call makes our activity visible
* through the pgstat views.
*/
SetCurrentStatementStartTimestamp();
StartTransactionCommand();

View File

@ -173,7 +173,6 @@ void
ginFindParents(GinBtree btree, GinBtreeStack *stack,
BlockNumber rootBlkno)
{
Page page;
Buffer buffer;
BlockNumber blkno,

View File

@ -364,8 +364,9 @@ gistScanPage(IndexScanDesc scan, GISTSearchItem *pageItem, double *myDistances,
item->blkno = ItemPointerGetBlockNumber(&it->t_tid);
/*
* LSN of current page is lsn of parent page for child. We only
* have a shared lock, so we need to get the LSN atomically.
* LSN of current page is lsn of parent page for child. We
* only have a shared lock, so we need to get the LSN
* atomically.
*/
item->data.parentlsn = BufferGetLSNAtomic(buffer);
}

View File

@ -810,8 +810,8 @@ gistGetFakeLSN(Relation rel)
if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
{
/*
* Temporary relations are only accessible in our session, so a
* simple backend-local counter will do.
* Temporary relations are only accessible in our session, so a simple
* backend-local counter will do.
*/
return counter++;
}

View File

@ -123,6 +123,7 @@ static const struct
MultiXactStatus lockstatus;
MultiXactStatus updstatus;
}
tupleLockExtraInfo[MaxLockTupleMode + 1] =
{
{ /* LockTupleKeyShare */
@ -146,6 +147,7 @@ tupleLockExtraInfo[MaxLockTupleMode + 1] =
MultiXactStatusUpdate
}
};
/* Get the LOCKMODE for a given MultiXactStatus */
#define LOCKMODE_from_mxstatus(status) \
(tupleLockExtraInfo[TUPLOCK_from_mxstatus((status))].hwlock)
@ -365,10 +367,10 @@ heapgetpage(HeapScanDesc scan, BlockNumber page)
* page. That's how index-only scans work fine in hot standby. A crucial
* difference between index-only scans and heap scans is that the
* index-only scan completely relies on the visibility map where as heap
* scan looks at the page-level PD_ALL_VISIBLE flag. We are not sure if the
* page-level flag can be trusted in the same way, because it might get
* propagated somehow without being explicitly WAL-logged, e.g. via a full
* page write. Until we can prove that beyond doubt, let's check each
* scan looks at the page-level PD_ALL_VISIBLE flag. We are not sure if
* the page-level flag can be trusted in the same way, because it might
* get propagated somehow without being explicitly WAL-logged, e.g. via a
* full page write. Until we can prove that beyond doubt, let's check each
* tuple for visibility the hard way.
*/
all_visible = PageIsAllVisible(dp) && !snapshot->takenDuringRecovery;
@ -2730,13 +2732,12 @@ l1:
}
/*
* If this is the first possibly-multixact-able operation in the
* current transaction, set my per-backend OldestMemberMXactId setting.
* We can be certain that the transaction will never become a member of
* any older MultiXactIds than that. (We have to do this even if we
* end up just using our own TransactionId below, since some other
* backend could incorporate our XID into a MultiXact immediately
* afterwards.)
* If this is the first possibly-multixact-able operation in the current
* transaction, set my per-backend OldestMemberMXactId setting. We can be
* certain that the transaction will never become a member of any older
* MultiXactIds than that. (We have to do this even if we end up just
* using our own TransactionId below, since some other backend could
* incorporate our XID into a MultiXact immediately afterwards.)
*/
MultiXactIdSetOldestMember();
@ -3006,13 +3007,13 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
/*
* If we're not updating any "key" column, we can grab a weaker lock type.
* This allows for more concurrency when we are running simultaneously with
* foreign key checks.
* This allows for more concurrency when we are running simultaneously
* with foreign key checks.
*
* Note that if a column gets detoasted while executing the update, but the
* value ends up being the same, this test will fail and we will use the
* stronger lock. This is acceptable; the important case to optimize is
* updates that don't manipulate key columns, not those that
* Note that if a column gets detoasted while executing the update, but
* the value ends up being the same, this test will fail and we will use
* the stronger lock. This is acceptable; the important case to optimize
* is updates that don't manipulate key columns, not those that
* serendipitiously arrive at the same key values.
*/
HeapSatisfiesHOTandKeyUpdate(relation, hot_attrs, key_attrs,
@ -3026,12 +3027,12 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
/*
* If this is the first possibly-multixact-able operation in the
* current transaction, set my per-backend OldestMemberMXactId setting.
* We can be certain that the transaction will never become a member of
* any older MultiXactIds than that. (We have to do this even if we
* end up just using our own TransactionId below, since some other
* backend could incorporate our XID into a MultiXact immediately
* afterwards.)
* current transaction, set my per-backend OldestMemberMXactId
* setting. We can be certain that the transaction will never become a
* member of any older MultiXactIds than that. (We have to do this
* even if we end up just using our own TransactionId below, since
* some other backend could incorporate our XID into a MultiXact
* immediately afterwards.)
*/
MultiXactIdSetOldestMember();
}
@ -3073,13 +3074,14 @@ l2:
/*
* XXX note that we don't consider the "no wait" case here. This
* isn't a problem currently because no caller uses that case, but it
* should be fixed if such a caller is introduced. It wasn't a problem
* previously because this code would always wait, but now that some
* tuple locks do not conflict with one of the lock modes we use, it is
* possible that this case is interesting to handle specially.
* should be fixed if such a caller is introduced. It wasn't a
* problem previously because this code would always wait, but now
* that some tuple locks do not conflict with one of the lock modes we
* use, it is possible that this case is interesting to handle
* specially.
*
* This may cause failures with third-party code that calls heap_update
* directly.
* This may cause failures with third-party code that calls
* heap_update directly.
*/
/* must copy state data before unlocking buffer */
@ -3109,10 +3111,10 @@ l2:
* gone (or even not sleep at all in some cases); we need to preserve
* it as locker, unless it is gone completely.
*
* If it's not a multi, we need to check for sleeping conditions before
* actually going to sleep. If the update doesn't conflict with the
* locks, we just continue without sleeping (but making sure it is
* preserved).
* If it's not a multi, we need to check for sleeping conditions
* before actually going to sleep. If the update doesn't conflict
* with the locks, we just continue without sleeping (but making sure
* it is preserved).
*/
if (infomask & HEAP_XMAX_IS_MULTI)
{
@ -3138,15 +3140,15 @@ l2:
* Note that the multixact may not be done by now. It could have
* surviving members; our own xact or other subxacts of this
* backend, and also any other concurrent transaction that locked
* the tuple with KeyShare if we only got TupleLockUpdate. If this
* is the case, we have to be careful to mark the updated tuple
* with the surviving members in Xmax.
* the tuple with KeyShare if we only got TupleLockUpdate. If
* this is the case, we have to be careful to mark the updated
* tuple with the surviving members in Xmax.
*
* Note that there could have been another update in the MultiXact.
* In that case, we need to check whether it committed or aborted.
* If it aborted we are safe to update it again; otherwise there is
* an update conflict, and we have to return HeapTupleUpdated
* below.
* Note that there could have been another update in the
* MultiXact. In that case, we need to check whether it committed
* or aborted. If it aborted we are safe to update it again;
* otherwise there is an update conflict, and we have to return
* HeapTupleUpdated below.
*
* In the LockTupleExclusive case, we still need to preserve the
* surviving members: those would include the tuple locks we had
@ -3167,17 +3169,17 @@ l2:
else
{
/*
* If it's just a key-share locker, and we're not changing the
* key columns, we don't need to wait for it to end; but we
* need to preserve it as locker.
* If it's just a key-share locker, and we're not changing the key
* columns, we don't need to wait for it to end; but we need to
* preserve it as locker.
*/
if (HEAP_XMAX_IS_KEYSHR_LOCKED(infomask) && key_intact)
{
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
/*
* recheck the locker; if someone else changed the tuple while we
* weren't looking, start over.
* recheck the locker; if someone else changed the tuple while
* we weren't looking, start over.
*/
if ((oldtup.t_data->t_infomask & HEAP_XMAX_IS_MULTI) ||
!TransactionIdEquals(HeapTupleHeaderGetRawXmax(oldtup.t_data),
@ -3194,9 +3196,9 @@ l2:
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
/*
* xwait is done, but if xwait had just locked the tuple then some
* other xact could update this tuple before we get to this point.
* Check for xmax change, and start over if so.
* xwait is done, but if xwait had just locked the tuple then
* some other xact could update this tuple before we get to
* this point. Check for xmax change, and start over if so.
*/
if ((oldtup.t_data->t_infomask & HEAP_XMAX_IS_MULTI) ||
!TransactionIdEquals(HeapTupleHeaderGetRawXmax(oldtup.t_data),
@ -3247,8 +3249,8 @@ l2:
* visible while we were busy locking the buffer, or during some
* subsequent window during which we had it unlocked, we'll have to unlock
* and re-lock, to avoid holding the buffer lock across an I/O. That's a
* bit unfortunate, especially since we'll now have to recheck whether
* the tuple has been locked or updated under us, but hopefully it won't
* bit unfortunate, especially since we'll now have to recheck whether the
* tuple has been locked or updated under us, but hopefully it won't
* happen very often.
*/
if (vmbuffer == InvalidBuffer && PageIsAllVisible(page))
@ -3656,9 +3658,9 @@ heap_tuple_attr_equals(TupleDesc tupdesc, int attrnum,
/*
* Extract the corresponding values. XXX this is pretty inefficient if
* there are many indexed columns. Should HeapSatisfiesHOTandKeyUpdate do a
* single heap_deform_tuple call on each tuple, instead? But that doesn't
* work for system columns ...
* there are many indexed columns. Should HeapSatisfiesHOTandKeyUpdate do
* a single heap_deform_tuple call on each tuple, instead? But that
* doesn't work for system columns ...
*/
value1 = heap_getattr(tup1, attrnum, tupdesc, &isnull1);
value2 = heap_getattr(tup2, attrnum, tupdesc, &isnull2);
@ -3944,11 +3946,11 @@ l3:
LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
/*
* If any subtransaction of the current top transaction already holds a
* lock as strong or stronger than what we're requesting, we
* If any subtransaction of the current top transaction already holds
* a lock as strong or stronger than what we're requesting, we
* effectively hold the desired lock already. We *must* succeed
* without trying to take the tuple lock, else we will deadlock against
* anyone wanting to acquire a stronger lock.
* without trying to take the tuple lock, else we will deadlock
* against anyone wanting to acquire a stronger lock.
*/
if (infomask & HEAP_XMAX_IS_MULTI)
{
@ -3957,9 +3959,9 @@ l3:
MultiXactMember *members;
/*
* We don't need to allow old multixacts here; if that had been the
* case, HeapTupleSatisfiesUpdate would have returned MayBeUpdated
* and we wouldn't be here.
* We don't need to allow old multixacts here; if that had been
* the case, HeapTupleSatisfiesUpdate would have returned
* MayBeUpdated and we wouldn't be here.
*/
nmembers = GetMultiXactIdMembers(xwait, &members, false);
@ -4023,20 +4025,20 @@ l3:
* continue if the key hasn't been modified.
*
* However, if there are updates, we need to walk the update chain
* to mark future versions of the row as locked, too. That way, if
* somebody deletes that future version, we're protected against
* the key going away. This locking of future versions could block
* momentarily, if a concurrent transaction is deleting a key; or
* it could return a value to the effect that the transaction
* deleting the key has already committed. So we do this before
* re-locking the buffer; otherwise this would be prone to
* deadlocks.
* to mark future versions of the row as locked, too. That way,
* if somebody deletes that future version, we're protected
* against the key going away. This locking of future versions
* could block momentarily, if a concurrent transaction is
* deleting a key; or it could return a value to the effect that
* the transaction deleting the key has already committed. So we
* do this before re-locking the buffer; otherwise this would be
* prone to deadlocks.
*
* Note that the TID we're locking was grabbed before we unlocked
* the buffer. For it to change while we're not looking, the other
* properties we're testing for below after re-locking the buffer
* would also change, in which case we would restart this loop
* above.
* the buffer. For it to change while we're not looking, the
* other properties we're testing for below after re-locking the
* buffer would also change, in which case we would restart this
* loop above.
*/
if (!(infomask2 & HEAP_KEYS_UPDATED))
{
@ -4045,8 +4047,8 @@ l3:
updated = !HEAP_XMAX_IS_LOCKED_ONLY(infomask);
/*
* If there are updates, follow the update chain; bail out
* if that cannot be done.
* If there are updates, follow the update chain; bail out if
* that cannot be done.
*/
if (follow_updates && updated)
{
@ -4069,8 +4071,9 @@ l3:
/*
* Make sure it's still an appropriate lock, else start over.
* Also, if it wasn't updated before we released the lock, but
* is updated now, we start over too; the reason is that we now
* need to follow the update chain to lock the new versions.
* is updated now, we start over too; the reason is that we
* now need to follow the update chain to lock the new
* versions.
*/
if (!HeapTupleHeaderIsOnlyLocked(tuple->t_data) &&
((tuple->t_data->t_infomask2 & HEAP_KEYS_UPDATED) ||
@ -4114,8 +4117,8 @@ l3:
{
/*
* If we're requesting NoKeyExclusive, we might also be able to
* avoid sleeping; just ensure that there's no other lock type than
* KeyShare. Note that this is a bit more involved than just
* avoid sleeping; just ensure that there's no other lock type
* than KeyShare. Note that this is a bit more involved than just
* checking hint bits -- we need to expand the multixact to figure
* out lock modes for each one (unless there was only one such
* locker).
@ -4126,8 +4129,8 @@ l3:
MultiXactMember *members;
/*
* We don't need to allow old multixacts here; if that had been
* the case, HeapTupleSatisfiesUpdate would have returned
* We don't need to allow old multixacts here; if that had
* been the case, HeapTupleSatisfiesUpdate would have returned
* MayBeUpdated and we wouldn't be here.
*/
nmembers = GetMultiXactIdMembers(xwait, &members, false);
@ -4135,8 +4138,8 @@ l3:
if (nmembers <= 0)
{
/*
* No need to keep the previous xmax here. This is unlikely
* to happen.
* No need to keep the previous xmax here. This is
* unlikely to happen.
*/
require_sleep = false;
}
@ -4355,8 +4358,8 @@ failed:
* for cases where it is a plain TransactionId.
*
* Note in particular that this covers the case where we already hold
* exclusive lock on the tuple and the caller only wants key share or share
* lock. It would certainly not do to give up the exclusive lock.
* exclusive lock on the tuple and the caller only wants key share or
* share lock. It would certainly not do to give up the exclusive lock.
*/
if (!(old_infomask & (HEAP_XMAX_INVALID |
HEAP_XMAX_COMMITTED |
@ -4379,13 +4382,12 @@ failed:
}
/*
* If this is the first possibly-multixact-able operation in the
* current transaction, set my per-backend OldestMemberMXactId setting.
* We can be certain that the transaction will never become a member of
* any older MultiXactIds than that. (We have to do this even if we
* end up just using our own TransactionId below, since some other
* backend could incorporate our XID into a MultiXact immediately
* afterwards.)
* If this is the first possibly-multixact-able operation in the current
* transaction, set my per-backend OldestMemberMXactId setting. We can be
* certain that the transaction will never become a member of any older
* MultiXactIds than that. (We have to do this even if we end up just
* using our own TransactionId below, since some other backend could
* incorporate our XID into a MultiXact immediately afterwards.)
*/
MultiXactIdSetOldestMember();
@ -4422,8 +4424,8 @@ failed:
* Make sure there is no forward chain link in t_ctid. Note that in the
* cases where the tuple has been updated, we must not overwrite t_ctid,
* because it was set by the updater. Moreover, if the tuple has been
* updated, we need to follow the update chain to lock the new versions
* of the tuple as well.
* updated, we need to follow the update chain to lock the new versions of
* the tuple as well.
*/
if (HEAP_XMAX_IS_LOCKED_ONLY(new_infomask))
tuple->t_data->t_ctid = *tid;
@ -4565,8 +4567,8 @@ l5:
MultiXactStatus new_status;
/*
* Currently we don't allow XMAX_COMMITTED to be set for multis,
* so cross-check.
* Currently we don't allow XMAX_COMMITTED to be set for multis, so
* cross-check.
*/
Assert(!(old_infomask & HEAP_XMAX_COMMITTED));
@ -4587,10 +4589,11 @@ l5:
/*
* If the XMAX is already a MultiXactId, then we need to expand it to
* include add_to_xmax; but if all the members were lockers and are all
* gone, we can do away with the IS_MULTI bit and just set add_to_xmax
* as the only locker/updater. If all lockers are gone and we have an
* updater that aborted, we can also do without a multi.
* include add_to_xmax; but if all the members were lockers and are
* all gone, we can do away with the IS_MULTI bit and just set
* add_to_xmax as the only locker/updater. If all lockers are gone
* and we have an updater that aborted, we can also do without a
* multi.
*
* The cost of doing GetMultiXactIdMembers would be paid by
* MultiXactIdExpand if we weren't to do this, so this check is not
@ -4633,6 +4636,7 @@ l5:
status = MultiXactStatusNoKeyUpdate;
new_status = get_mxact_status_for_lock(mode, is_update);
/*
* since it's not running, it's obviously impossible for the old
* updater to be identical to the current one, so we need not check
@ -4737,6 +4741,7 @@ l5:
status = MultiXactStatusNoKeyUpdate;
new_status = get_mxact_status_for_lock(mode, is_update);
/*
* since it's not running, it's obviously impossible for the old
* updater to be identical to the current one, so we need not check
@ -4802,11 +4807,12 @@ l4:
xmax = HeapTupleHeaderGetRawXmax(mytup.t_data);
/*
* If this tuple is updated and the key has been modified (or deleted),
* what we do depends on the status of the updating transaction: if
* it's live, we sleep until it finishes; if it has committed, we have
* to fail (i.e. return HeapTupleUpdated); if it aborted, we ignore it.
* For updates that didn't touch the key, we can just plough ahead.
* If this tuple is updated and the key has been modified (or
* deleted), what we do depends on the status of the updating
* transaction: if it's live, we sleep until it finishes; if it has
* committed, we have to fail (i.e. return HeapTupleUpdated); if it
* aborted, we ignore it. For updates that didn't touch the key, we
* can just plough ahead.
*/
if (!(old_infomask & HEAP_XMAX_INVALID) &&
(mytup.t_data->t_infomask2 & HEAP_KEYS_UPDATED))
@ -4932,12 +4938,12 @@ heap_lock_updated_tuple(Relation rel, HeapTuple tuple, ItemPointer ctid,
{
/*
* If this is the first possibly-multixact-able operation in the
* current transaction, set my per-backend OldestMemberMXactId setting.
* We can be certain that the transaction will never become a member of
* any older MultiXactIds than that. (We have to do this even if we
* end up just using our own TransactionId below, since some other
* backend could incorporate our XID into a MultiXact immediately
* afterwards.)
* current transaction, set my per-backend OldestMemberMXactId
* setting. We can be certain that the transaction will never become a
* member of any older MultiXactIds than that. (We have to do this
* even if we end up just using our own TransactionId below, since
* some other backend could incorporate our XID into a MultiXact
* immediately afterwards.)
*/
MultiXactIdSetOldestMember();
@ -5117,9 +5123,9 @@ heap_freeze_tuple(HeapTupleHeader tuple, TransactionId cutoff_xid,
HeapTupleHeaderSetXmax(tuple, InvalidTransactionId);
/*
* The tuple might be marked either XMAX_INVALID or XMAX_COMMITTED
* + LOCKED. Normalize to INVALID just to be sure no one gets
* confused. Also get rid of the HEAP_KEYS_UPDATED bit.
* The tuple might be marked either XMAX_INVALID or XMAX_COMMITTED +
* LOCKED. Normalize to INVALID just to be sure no one gets confused.
* Also get rid of the HEAP_KEYS_UPDATED bit.
*/
tuple->t_infomask &= ~HEAP_XMAX_BITS;
tuple->t_infomask |= HEAP_XMAX_INVALID;
@ -5257,8 +5263,8 @@ MultiXactIdGetUpdateXid(TransactionId xmax, uint16 t_infomask)
Assert(t_infomask & HEAP_XMAX_IS_MULTI);
/*
* Since we know the LOCK_ONLY bit is not set, this cannot be a
* multi from pre-pg_upgrade.
* Since we know the LOCK_ONLY bit is not set, this cannot be a multi from
* pre-pg_upgrade.
*/
nmembers = GetMultiXactIdMembers(xmax, &members, false);
@ -5284,6 +5290,7 @@ MultiXactIdGetUpdateXid(TransactionId xmax, uint16 t_infomask)
members[i].status == MultiXactStatusUpdate);
update_xact = members[i].xid;
#ifndef USE_ASSERT_CHECKING
/*
* in an assert-enabled build, walk the whole array to ensure
* there's no other updater.

View File

@ -532,8 +532,8 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, TransactionId latestRemovedX
START_CRIT_SECTION();
/*
* We don't do MarkBufferDirty here because we're about to initialise
* the page, and nobody else can see it yet.
* We don't do MarkBufferDirty here because we're about to initialise the
* page, and nobody else can see it yet.
*/
/* XLOG stuff */
@ -552,8 +552,8 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, TransactionId latestRemovedX
XLogInsert(RM_BTREE_ID, XLOG_BTREE_REUSE_PAGE, rdata);
/*
* We don't do PageSetLSN here because we're about to initialise
* the page, so no need.
* We don't do PageSetLSN here because we're about to initialise the
* page, so no need.
*/
}

View File

@ -608,8 +608,8 @@ btree_xlog_delete_get_latestRemovedXid(xl_btree_delete *xlrec)
* In what follows, we have to examine the previous state of the index
* page, as well as the heap page(s) it points to. This is only valid if
* WAL replay has reached a consistent database state; which means that
* the preceding check is not just an optimization, but is *necessary*.
* We won't have let in any user sessions before we reach consistency.
* the preceding check is not just an optimization, but is *necessary*. We
* won't have let in any user sessions before we reach consistency.
*/
if (!reachedConsistency)
elog(PANIC, "btree_xlog_delete_get_latestRemovedXid: cannot operate with inconsistent data");
@ -701,10 +701,10 @@ btree_xlog_delete_get_latestRemovedXid(xl_btree_delete *xlrec)
/*
* XXX If all heap tuples were LP_DEAD then we will be returning
* InvalidTransactionId here, causing conflict for all HS
* transactions. That should happen very rarely (reasoning please?). Also
* note that caller can't tell the difference between this case and the
* fast path exit above. May need to change that in future.
* InvalidTransactionId here, causing conflict for all HS transactions.
* That should happen very rarely (reasoning please?). Also note that
* caller can't tell the difference between this case and the fast path
* exit above. May need to change that in future.
*/
return latestRemovedXid;
}

View File

@ -85,6 +85,7 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
else if (info == XLOG_HINT)
{
BkpBlock *bkp = (BkpBlock *) rec;
appendStringInfo(buf, "page hint: %s block %u",
relpathperm(bkp->node, bkp->fork),
bkp->block);

View File

@ -177,8 +177,8 @@ typedef struct MultiXactStateData
MultiXactId lastTruncationPoint;
/*
* oldest multixact that is still on disk. Anything older than this should
* not be consulted.
* oldest multixact that is still on disk. Anything older than this
* should not be consulted.
*/
MultiXactId oldestMultiXactId;
Oid oldestMultiXactDB;
@ -387,9 +387,9 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status)
multi, xid, mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the
* only caller of this function does a check that the multixact is
* no longer running.
* Note: we don't allow for old multis here. The reason is that the only
* caller of this function does a check that the multixact is no longer
* running.
*/
nmembers = GetMultiXactIdMembers(multi, &members, false);
@ -430,14 +430,14 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status)
}
/*
* Determine which of the members of the MultiXactId are still of interest.
* This is any running transaction, and also any transaction that grabbed
* something stronger than just a lock and was committed. (An update that
* aborted is of no interest here.)
* Determine which of the members of the MultiXactId are still of
* interest. This is any running transaction, and also any transaction
* that grabbed something stronger than just a lock and was committed.
* (An update that aborted is of no interest here.)
*
* (Removing dead members is just an optimization, but a useful one.
* Note we have the same race condition here as above: j could be 0 at the
* end of the loop.)
* (Removing dead members is just an optimization, but a useful one. Note
* we have the same race condition here as above: j could be 0 at the end
* of the loop.)
*/
newMembers = (MultiXactMember *)
palloc(sizeof(MultiXactMember) * (nmembers + 1));
@ -722,9 +722,9 @@ CreateMultiXactId(int nmembers, MultiXactMember *members)
/*
* XXX Note: there's a lot of padding space in MultiXactMember. We could
* find a more compact representation of this Xlog record -- perhaps all the
* status flags in one XLogRecData, then all the xids in another one? Not
* clear that it's worth the trouble though.
* find a more compact representation of this Xlog record -- perhaps all
* the status flags in one XLogRecData, then all the xids in another one?
* Not clear that it's worth the trouble though.
*/
rdata[0].data = (char *) (&xlrec);
rdata[0].len = SizeOfMultiXactCreate;
@ -995,10 +995,10 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
*
* We don't care about MultiXactId wraparound here; it will be handled by
* the next iteration. But note that nextMXact may be InvalidMultiXactId
* or the first value on a segment-beginning page after this routine exits,
* so anyone else looking at the variable must be prepared to deal with
* either case. Similarly, nextOffset may be zero, but we won't use that
* as the actual start offset of the next multixact.
* or the first value on a segment-beginning page after this routine
* exits, so anyone else looking at the variable must be prepared to deal
* with either case. Similarly, nextOffset may be zero, but we won't use
* that as the actual start offset of the next multixact.
*/
(MultiXactState->nextMXact)++;
@ -1066,9 +1066,9 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
*
* An ID older than MultiXactState->oldestMultiXactId cannot possibly be
* useful; it should have already been frozen by vacuum. We've truncated
* the on-disk structures anyway. Returning the wrong values could lead to
* an incorrect visibility result. However, to support pg_upgrade we need
* to allow an empty set to be returned regardless, if the caller is
* the on-disk structures anyway. Returning the wrong values could lead
* to an incorrect visibility result. However, to support pg_upgrade we
* need to allow an empty set to be returned regardless, if the caller is
* willing to accept it; the caller is expected to check that it's an
* allowed condition (such as ensuring that the infomask bits set on the
* tuple are consistent with the pg_upgrade scenario). If the caller is
@ -1076,8 +1076,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
* raise an error.
*
* Conversely, an ID >= nextMXact shouldn't ever be seen here; if it is
* seen, it implies undetected ID wraparound has occurred. This raises
* a hard error.
* seen, it implies undetected ID wraparound has occurred. This raises a
* hard error.
*
* Shared lock is enough here since we aren't modifying any global state.
* Acquire it just long enough to grab the current counter values. We may
@ -1911,11 +1911,11 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
multiStopLimit -= FirstMultiXactId;
/*
* We'll start complaining loudly when we get within 10M multis of the stop
* point. This is kind of arbitrary, but if you let your gas gauge get
* down to 1% of full, would you be looking for the next gas station? We
* need to be fairly liberal about this number because there are lots of
* scenarios where most transactions are done by automatic clients that
* We'll start complaining loudly when we get within 10M multis of the
* stop point. This is kind of arbitrary, but if you let your gas gauge
* get down to 1% of full, would you be looking for the next gas station?
* We need to be fairly liberal about this number because there are lots
* of scenarios where most transactions are done by automatic clients that
* won't pay attention to warnings. (No, we're not gonna make this
* configurable. If you know enough to configure it, you know enough to
* not get in this kind of trouble in the first place.)
@ -1925,8 +1925,8 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid)
multiWarnLimit -= FirstMultiXactId;
/*
* We'll start trying to force autovacuums when oldest_datminmxid gets
* to be more than 200 million transactions old.
* We'll start trying to force autovacuums when oldest_datminmxid gets to
* be more than 200 million transactions old.
*/
multiVacLimit = oldest_datminmxid + 200000000;
if (multiVacLimit < FirstMultiXactId)
@ -2207,9 +2207,9 @@ TruncateMultiXact(MultiXactId oldestMXact)
/*
* Note we can't just plow ahead with the truncation; it's possible that
* there are no segments to truncate, which is a problem because we are
* going to attempt to read the offsets page to determine where to truncate
* the members SLRU. So we first scan the directory to determine the
* earliest offsets page number that we can read without error.
* going to attempt to read the offsets page to determine where to
* truncate the members SLRU. So we first scan the directory to determine
* the earliest offsets page number that we can read without error.
*/
trunc.earliestExistingPage = -1;
SlruScanDirectory(MultiXactOffsetCtl, SlruScanDirCbFindEarliest, &trunc);
@ -2220,9 +2220,9 @@ TruncateMultiXact(MultiXactId oldestMXact)
return;
/*
* First, compute the safe truncation point for MultiXactMember.
* This is the starting offset of the multixact we were passed
* as MultiXactOffset cutoff.
* First, compute the safe truncation point for MultiXactMember. This is
* the starting offset of the multixact we were passed as MultiXactOffset
* cutoff.
*/
{
int pageno;

View File

@ -179,8 +179,8 @@ readTimeLineHistory(TimeLineID targetTLI)
errhint("Timeline IDs must be less than child timeline's ID.")));
/*
* Create one more entry for the "tip" of the timeline, which has no
* entry in the history file.
* Create one more entry for the "tip" of the timeline, which has no entry
* in the history file.
*/
entry = (TimeLineHistoryEntry *) palloc(sizeof(TimeLineHistoryEntry));
entry->tli = targetTLI;
@ -553,6 +553,7 @@ tliOfPointInHistory(XLogRecPtr ptr, List *history)
foreach(cell, history)
{
TimeLineHistoryEntry *tle = (TimeLineHistoryEntry *) lfirst(cell);
if ((XLogRecPtrIsInvalid(tle->begin) || tle->begin <= ptr) &&
(XLogRecPtrIsInvalid(tle->end) || ptr < tle->end))
{

View File

@ -1024,8 +1024,8 @@ RecordTransactionCommit(void)
*
* It's safe to change the delayChkpt flag of our own backend without
* holding the ProcArrayLock, since we're the only one modifying it.
* This makes checkpoint's determination of which xacts are delayChkpt a
* bit fuzzy, but it doesn't matter.
* This makes checkpoint's determination of which xacts are delayChkpt
* a bit fuzzy, but it doesn't matter.
*/
START_CRIT_SECTION();
MyPgXact->delayChkpt = true;
@ -4683,12 +4683,11 @@ xact_redo_commit_internal(TransactionId xid, XLogRecPtr lsn,
* from the template database, and then commit the transaction. If we
* crash after all the files have been copied but before the commit, you
* have files in the data directory without an entry in pg_database. To
* minimize the window
* for that, we use ForceSyncCommit() to rush the commit record to disk as
* quick as possible. We have the same window during recovery, and forcing
* an XLogFlush() (which updates minRecoveryPoint during recovery) helps
* to reduce that problem window, for any user that requested
* ForceSyncCommit().
* minimize the window for that, we use ForceSyncCommit() to rush the
* commit record to disk as quick as possible. We have the same window
* during recovery, and forcing an XLogFlush() (which updates
* minRecoveryPoint during recovery) helps to reduce that problem window,
* for any user that requested ForceSyncCommit().
*/
if (XactCompletionForceSyncCommit(xinfo))
XLogFlush(lsn);

View File

@ -403,7 +403,8 @@ typedef struct XLogCtlData
uint32 ckptXidEpoch; /* nextXID & epoch of latest checkpoint */
TransactionId ckptXid;
XLogRecPtr asyncXactLSN; /* LSN of newest async commit/abort */
XLogSegNo lastRemovedSegNo; /* latest removed/recycled XLOG segment */
XLogSegNo lastRemovedSegNo; /* latest removed/recycled XLOG
* segment */
/* Fake LSN counter, for unlogged relations. Protected by ulsn_lck */
XLogRecPtr unloggedLSN;
@ -1251,10 +1252,10 @@ XLogCheckBuffer(XLogRecData *rdata, bool holdsExclusiveLock,
page = BufferGetPage(rdata->buffer);
/*
* We assume page LSN is first data on *every* page that can be passed
* to XLogInsert, whether it has the standard page layout or not. We
* don't need to take the buffer header lock for PageGetLSN if we hold
* an exclusive lock on the page and/or the relation.
* We assume page LSN is first data on *every* page that can be passed to
* XLogInsert, whether it has the standard page layout or not. We don't
* need to take the buffer header lock for PageGetLSN if we hold an
* exclusive lock on the page and/or the relation.
*/
if (holdsExclusiveLock)
*lsn = PageGetLSN(page);
@ -1979,8 +1980,8 @@ XLogFlush(XLogRecPtr record)
/*
* Sleep before flush! By adding a delay here, we may give further
* backends the opportunity to join the backlog of group commit
* followers; this can significantly improve transaction throughput, at
* the risk of increasing transaction latency.
* followers; this can significantly improve transaction throughput,
* at the risk of increasing transaction latency.
*
* We do not sleep if enableFsync is not turned on, nor if there are
* fewer than CommitSiblings other backends with active transactions.
@ -3215,8 +3216,8 @@ RestoreBackupBlockContents(XLogRecPtr lsn, BkpBlock bkpb, char *blk,
}
/*
* The checksum value on this page is currently invalid. We don't
* need to reset it here since it will be set before being written.
* The checksum value on this page is currently invalid. We don't need to
* reset it here since it will be set before being written.
*/
PageSetLSN(page, lsn);
@ -3272,16 +3273,17 @@ ReadRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr, int emode,
}
/*
* We only end up here without a message when XLogPageRead() failed
* - in that case we already logged something.
* In StandbyMode that only happens if we have been triggered, so
* we shouldn't loop anymore in that case.
* We only end up here without a message when XLogPageRead()
* failed - in that case we already logged something. In
* StandbyMode that only happens if we have been triggered, so we
* shouldn't loop anymore in that case.
*/
if (errormsg)
ereport(emode_for_corrupt_record(emode,
RecPtr ? RecPtr : EndRecPtr),
(errmsg_internal("%s", errormsg) /* already translated */ ));
}
/*
* Check page TLI is one of the expected values.
*/
@ -3314,10 +3316,10 @@ ReadRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr, int emode,
lastSourceFailed = true;
/*
* If archive recovery was requested, but we were still doing crash
* recovery, switch to archive recovery and retry using the offline
* archive. We have now replayed all the valid WAL in pg_xlog, so
* we are presumably now consistent.
* If archive recovery was requested, but we were still doing
* crash recovery, switch to archive recovery and retry using the
* offline archive. We have now replayed all the valid WAL in
* pg_xlog, so we are presumably now consistent.
*
* We require that there's at least some valid WAL present in
* pg_xlog, however (!fetch_ckpt). We could recover using the WAL
@ -3401,8 +3403,8 @@ rescanLatestTimeLine(void)
newExpectedTLEs = readTimeLineHistory(newtarget);
/*
* If the current timeline is not part of the history of the new
* timeline, we cannot proceed to it.
* If the current timeline is not part of the history of the new timeline,
* we cannot proceed to it.
*/
found = false;
foreach(cell, newExpectedTLEs)
@ -4998,8 +5000,8 @@ StartupXLOG(void)
&backupFromStandby))
{
/*
* Archive recovery was requested, and thanks to the backup label file,
* we know how far we need to replay to reach consistency. Enter
* Archive recovery was requested, and thanks to the backup label
* file, we know how far we need to replay to reach consistency. Enter
* archive recovery directly.
*/
InArchiveRecovery = true;
@ -5049,8 +5051,8 @@ StartupXLOG(void)
/*
* It's possible that archive recovery was requested, but we don't
* know how far we need to replay the WAL before we reach consistency.
* This can happen for example if a base backup is taken from a running
* server using an atomic filesystem snapshot, without calling
* This can happen for example if a base backup is taken from a
* running server using an atomic filesystem snapshot, without calling
* pg_start/stop_backup. Or if you just kill a running master server
* and put it into archive recovery by creating a recovery.conf file.
*
@ -5058,8 +5060,8 @@ StartupXLOG(void)
* replaying all the WAL present in pg_xlog, and only enter archive
* recovery after that.
*
* But usually we already know how far we need to replay the WAL (up to
* minRecoveryPoint, up to backupEndPoint, or until we see an
* But usually we already know how far we need to replay the WAL (up
* to minRecoveryPoint, up to backupEndPoint, or until we see an
* end-of-backup record), and we can enter archive recovery directly.
*/
if (ArchiveRecoveryRequested &&
@ -5119,15 +5121,16 @@ StartupXLOG(void)
* timeline in the history of the requested timeline, we cannot proceed:
* the backup is not part of the history of the requested timeline.
*/
Assert(expectedTLEs); /* was initialized by reading checkpoint record */
Assert(expectedTLEs); /* was initialized by reading checkpoint
* record */
if (tliOfPointInHistory(checkPointLoc, expectedTLEs) !=
checkPoint.ThisTimeLineID)
{
XLogRecPtr switchpoint;
/*
* tliSwitchPoint will throw an error if the checkpoint's timeline
* is not in expectedTLEs at all.
* tliSwitchPoint will throw an error if the checkpoint's timeline is
* not in expectedTLEs at all.
*/
switchpoint = tliSwitchPoint(ControlFile->checkPointCopy.ThisTimeLineID, expectedTLEs, NULL);
ereport(FATAL,
@ -5206,16 +5209,16 @@ StartupXLOG(void)
ThisTimeLineID = checkPoint.ThisTimeLineID;
/*
* Copy any missing timeline history files between 'now' and the
* recovery target timeline from archive to pg_xlog. While we don't need
* those files ourselves - the history file of the recovery target
* timeline covers all the previous timelines in the history too - a
* cascading standby server might be interested in them. Or, if you
* archive the WAL from this server to a different archive than the
* master, it'd be good for all the history files to get archived there
* after failover, so that you can use one of the old timelines as a
* PITR target. Timeline history files are small, so it's better to copy
* them unnecessarily than not copy them and regret later.
* Copy any missing timeline history files between 'now' and the recovery
* target timeline from archive to pg_xlog. While we don't need those
* files ourselves - the history file of the recovery target timeline
* covers all the previous timelines in the history too - a cascading
* standby server might be interested in them. Or, if you archive the WAL
* from this server to a different archive than the master, it'd be good
* for all the history files to get archived there after failover, so that
* you can use one of the old timelines as a PITR target. Timeline history
* files are small, so it's better to copy them unnecessarily than not
* copy them and regret later.
*/
restoreTimeLineHistoryFiles(ThisTimeLineID, recoveryTargetTLI);
@ -5517,6 +5520,7 @@ StartupXLOG(void)
do
{
bool switchedTLI = false;
#ifdef WAL_DEBUG
if (XLOG_DEBUG ||
(rmid == RM_XACT_ID && trace_recovery_messages <= DEBUG2) ||
@ -5598,13 +5602,13 @@ StartupXLOG(void)
}
/*
* Before replaying this record, check if this record
* causes the current timeline to change. The record is
* already considered to be part of the new timeline,
* so we update ThisTimeLineID before replaying it.
* That's important so that replayEndTLI, which is
* recorded as the minimum recovery point's TLI if
* recovery stops after this record, is set correctly.
* Before replaying this record, check if this record causes
* the current timeline to change. The record is already
* considered to be part of the new timeline, so we update
* ThisTimeLineID before replaying it. That's important so
* that replayEndTLI, which is recorded as the minimum
* recovery point's TLI if recovery stops after this record,
* is set correctly.
*/
if (record->xl_rmid == RM_XLOG_ID)
{
@ -5952,8 +5956,9 @@ StartupXLOG(void)
* allows some extra error checking in xlog_redo.
*
* In fast promotion, only create a lightweight end-of-recovery record
* instead of a full checkpoint. A checkpoint is requested later, after
* we're fully out of recovery mode and already accepting queries.
* instead of a full checkpoint. A checkpoint is requested later,
* after we're fully out of recovery mode and already accepting
* queries.
*/
if (bgwriterLaunched)
{
@ -5972,14 +5977,15 @@ StartupXLOG(void)
fast_promoted = true;
/*
* Insert a special WAL record to mark the end of recovery,
* since we aren't doing a checkpoint. That means that the
* checkpointer process may likely be in the middle of a
* time-smoothed restartpoint and could continue to be for
* minutes after this. That sounds strange, but the effect
* is roughly the same and it would be stranger to try to
* come out of the restartpoint and then checkpoint.
* We request a checkpoint later anyway, just for safety.
* Insert a special WAL record to mark the end of
* recovery, since we aren't doing a checkpoint. That
* means that the checkpointer process may likely be in
* the middle of a time-smoothed restartpoint and could
* continue to be for minutes after this. That sounds
* strange, but the effect is roughly the same and it
* would be stranger to try to come out of the
* restartpoint and then checkpoint. We request a
* checkpoint later anyway, just for safety.
*/
CreateEndOfRecoveryRecord();
}
@ -6092,8 +6098,8 @@ StartupXLOG(void)
}
/*
* If there were cascading standby servers connected to us, nudge any
* wal sender processes to notice that we've been promoted.
* If there were cascading standby servers connected to us, nudge any wal
* sender processes to notice that we've been promoted.
*/
WalSndWakeup();
@ -6151,9 +6157,9 @@ CheckRecoveryConsistency(void)
}
/*
* Have we passed our safe starting point? Note that minRecoveryPoint
* is known to be incorrectly set if ControlFile->backupEndRequired,
* until the XLOG_BACKUP_RECORD arrives to advise us of the correct
* Have we passed our safe starting point? Note that minRecoveryPoint is
* known to be incorrectly set if ControlFile->backupEndRequired, until
* the XLOG_BACKUP_RECORD arrives to advise us of the correct
* minRecoveryPoint. All we know prior to that is that we're not
* consistent yet.
*/
@ -6946,8 +6952,8 @@ CreateCheckPoint(int flags)
TRACE_POSTGRESQL_CHECKPOINT_START(flags);
/*
* In some cases there are groups of actions that must all occur on
* one side or the other of a checkpoint record. Before flushing the
* In some cases there are groups of actions that must all occur on one
* side or the other of a checkpoint record. Before flushing the
* checkpoint record we must explicitly wait for any backend currently
* performing those groups of actions.
*
@ -7211,8 +7217,8 @@ CreateEndOfRecoveryRecord(void)
XLogFlush(recptr);
/*
* Update the control file so that crash recovery can follow
* the timeline changes to this point.
* Update the control file so that crash recovery can follow the timeline
* changes to this point.
*/
LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
ControlFile->time = (pg_time_t) xlrec.end_time;
@ -7458,7 +7464,8 @@ CreateRestartPoint(int flags)
XLogRecPtr endptr;
/*
* Get the current end of xlog replayed or received, whichever is later.
* Get the current end of xlog replayed or received, whichever is
* later.
*/
receivePtr = GetWalRcvWriteRecPtr(NULL, NULL);
replayPtr = GetXLogReplayRecPtr(NULL);
@ -7468,8 +7475,8 @@ CreateRestartPoint(int flags)
_logSegNo--;
/*
* Update ThisTimeLineID to the timeline we're currently replaying,
* so that we install any recycled segments on that timeline.
* Update ThisTimeLineID to the timeline we're currently replaying, so
* that we install any recycled segments on that timeline.
*
* There is no guarantee that the WAL segments will be useful on the
* current timeline; if recovery proceeds to a new timeline right
@ -7480,8 +7487,8 @@ CreateRestartPoint(int flags)
* It's possible or perhaps even likely that we finish recovery while
* a restartpoint is in progress. That means we may get to this point
* some minutes afterwards. Setting ThisTimeLineID at that time would
* actually set it backwards, so we don't want that to persist; if
* we do reset it here, make sure to reset it back afterwards. This
* actually set it backwards, so we don't want that to persist; if we
* do reset it here, make sure to reset it back afterwards. This
* doesn't look very clean or principled, but its the best of about
* five different ways of handling this edge case.
*/
@ -7693,8 +7700,8 @@ XLogSaveBufferForHint(Buffer buffer)
GetRedoRecPtr();
/*
* Setup phony rdata element for use within XLogCheckBuffer only.
* We reuse and reset rdata for any actual WAL record insert.
* Setup phony rdata element for use within XLogCheckBuffer only. We reuse
* and reset rdata for any actual WAL record insert.
*/
rdata[0].buffer = buffer;
rdata[0].buffer_std = true;
@ -7861,10 +7868,10 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI)
ereport(PANIC,
(errmsg("unexpected prev timeline ID %u (current timeline ID %u) in checkpoint record",
prevTLI, ThisTimeLineID)));
/*
* The new timeline better be in the list of timelines we expect
* to see, according to the timeline history. It should also not
* decrease.
* The new timeline better be in the list of timelines we expect to see,
* according to the timeline history. It should also not decrease.
*/
if (newTLI < ThisTimeLineID || !tliInHistory(newTLI, expectedTLEs))
ereport(PANIC,
@ -7872,14 +7879,13 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI)
newTLI, ThisTimeLineID)));
/*
* If we have not yet reached min recovery point, and we're about
* to switch to a timeline greater than the timeline of the min
* recovery point: trouble. After switching to the new timeline,
* we could not possibly visit the min recovery point on the
* correct timeline anymore. This can happen if there is a newer
* timeline in the archive that branched before the timeline the
* min recovery point is on, and you attempt to do PITR to the
* new timeline.
* If we have not yet reached min recovery point, and we're about to
* switch to a timeline greater than the timeline of the min recovery
* point: trouble. After switching to the new timeline, we could not
* possibly visit the min recovery point on the correct timeline anymore.
* This can happen if there is a newer timeline in the archive that
* branched before the timeline the min recovery point is on, and you
* attempt to do PITR to the new timeline.
*/
if (!XLogRecPtrIsInvalid(minRecoveryPoint) &&
lsn < minRecoveryPoint &&
@ -8105,17 +8111,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
BkpBlock bkpb;
/*
* Hint bit records contain a backup block stored "inline" in the normal
* data since the locking when writing hint records isn't sufficient to
* use the normal backup block mechanism, which assumes exclusive lock
* on the buffer supplied.
* Hint bit records contain a backup block stored "inline" in the
* normal data since the locking when writing hint records isn't
* sufficient to use the normal backup block mechanism, which assumes
* exclusive lock on the buffer supplied.
*
* Since the only change in these backup block are hint bits, there are
* no recovery conflicts generated.
* Since the only change in these backup block are hint bits, there
* are no recovery conflicts generated.
*
* This also means there is no corresponding API call for this,
* so an smgr implementation has no need to implement anything.
* Which means nothing is needed in md.c etc
* This also means there is no corresponding API call for this, so an
* smgr implementation has no need to implement anything. Which means
* nothing is needed in md.c etc
*/
data = XLogRecGetData(record);
memcpy(&bkpb, data, sizeof(BkpBlock));
@ -8379,6 +8385,7 @@ char *
XLogFileNameP(TimeLineID tli, XLogSegNo segno)
{
char *result = palloc(MAXFNAMELEN);
XLogFileName(result, tli, segno);
return result;
}
@ -9571,11 +9578,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
break;
case XLOG_FROM_PG_XLOG:
/*
* Check to see if the trigger file exists. Note that we do
* this only after failure, so when you create the trigger
* file, we still finish replaying as much as we can from
* archive and pg_xlog before failover.
* Check to see if the trigger file exists. Note that we
* do this only after failure, so when you create the
* trigger file, we still finish replaying as much as we
* can from archive and pg_xlog before failover.
*/
if (StandbyMode && CheckForStandbyTrigger())
{
@ -9584,15 +9592,15 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
}
/*
* Not in standby mode, and we've now tried the archive and
* pg_xlog.
* Not in standby mode, and we've now tried the archive
* and pg_xlog.
*/
if (!StandbyMode)
return false;
/*
* If primary_conninfo is set, launch walreceiver to try to
* stream the missing WAL.
* If primary_conninfo is set, launch walreceiver to try
* to stream the missing WAL.
*
* If fetching_ckpt is TRUE, RecPtr points to the initial
* checkpoint location. In that case, we use RedoStartLSN
@ -9624,28 +9632,32 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
RequestXLogStreaming(tli, ptr, PrimaryConnInfo);
receivedUpto = 0;
}
/*
* Move to XLOG_FROM_STREAM state in either case. We'll get
* immediate failure if we didn't launch walreceiver, and
* move on to the next state.
* Move to XLOG_FROM_STREAM state in either case. We'll
* get immediate failure if we didn't launch walreceiver,
* and move on to the next state.
*/
currentSource = XLOG_FROM_STREAM;
break;
case XLOG_FROM_STREAM:
/*
* Failure while streaming. Most likely, we got here because
* streaming replication was terminated, or promotion was
* triggered. But we also get here if we find an invalid
* record in the WAL streamed from master, in which case
* something is seriously wrong. There's little chance that
* the problem will just go away, but PANIC is not good for
* availability either, especially in hot standby mode. So,
* we treat that the same as disconnection, and retry from
* archive/pg_xlog again. The WAL in the archive should be
* identical to what was streamed, so it's unlikely that it
* helps, but one can hope...
* Failure while streaming. Most likely, we got here
* because streaming replication was terminated, or
* promotion was triggered. But we also get here if we
* find an invalid record in the WAL streamed from master,
* in which case something is seriously wrong. There's
* little chance that the problem will just go away, but
* PANIC is not good for availability either, especially
* in hot standby mode. So, we treat that the same as
* disconnection, and retry from archive/pg_xlog again.
* The WAL in the archive should be identical to what was
* streamed, so it's unlikely that it helps, but one can
* hope...
*/
/*
* Before we leave XLOG_FROM_STREAM state, make sure that
* walreceiver is not active, so that it won't overwrite
@ -9668,11 +9680,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
}
/*
* XLOG_FROM_STREAM is the last state in our state machine,
* so we've exhausted all the options for obtaining the
* requested WAL. We're going to loop back and retry from
* the archive, but if it hasn't been long since last
* attempt, sleep 5 seconds to avoid busy-waiting.
* XLOG_FROM_STREAM is the last state in our state
* machine, so we've exhausted all the options for
* obtaining the requested WAL. We're going to loop back
* and retry from the archive, but if it hasn't been long
* since last attempt, sleep 5 seconds to avoid
* busy-waiting.
*/
now = (pg_time_t) time(NULL);
if ((now - last_fail_time) < 5)
@ -9691,9 +9704,9 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
else if (currentSource == XLOG_FROM_PG_XLOG)
{
/*
* We just successfully read a file in pg_xlog. We prefer files
* in the archive over ones in pg_xlog, so try the next file
* again from the archive first.
* We just successfully read a file in pg_xlog. We prefer files in
* the archive over ones in pg_xlog, so try the next file again
* from the archive first.
*/
if (InArchiveRecovery)
currentSource = XLOG_FROM_ARCHIVE;
@ -9754,13 +9767,14 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
/*
* Walreceiver is active, so see if new data has arrived.
*
* We only advance XLogReceiptTime when we obtain fresh WAL
* from walreceiver and observe that we had already processed
* everything before the most recent "chunk" that it flushed to
* disk. In steady state where we are keeping up with the
* incoming data, XLogReceiptTime will be updated on each cycle.
* When we are behind, XLogReceiptTime will not advance, so the
* grace time allotted to conflicting queries will decrease.
* We only advance XLogReceiptTime when we obtain fresh
* WAL from walreceiver and observe that we had already
* processed everything before the most recent "chunk"
* that it flushed to disk. In steady state where we are
* keeping up with the incoming data, XLogReceiptTime will
* be updated on each cycle. When we are behind,
* XLogReceiptTime will not advance, so the grace time
* allotted to conflicting queries will decrease.
*/
if (RecPtr < receivedUpto)
havedata = true;
@ -9784,12 +9798,13 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
if (havedata)
{
/*
* Great, streamed far enough. Open the file if it's not
* open already. Also read the timeline history file if
* we haven't initialized timeline history yet; it should
* be streamed over and present in pg_xlog by now. Use
* XLOG_FROM_STREAM so that source info is set correctly
* and XLogReceiptTime isn't changed.
* Great, streamed far enough. Open the file if it's
* not open already. Also read the timeline history
* file if we haven't initialized timeline history
* yet; it should be streamed over and present in
* pg_xlog by now. Use XLOG_FROM_STREAM so that
* source info is set correctly and XLogReceiptTime
* isn't changed.
*/
if (readFile < 0)
{
@ -9818,20 +9833,21 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
{
/*
* Note that we don't "return false" immediately here.
* After being triggered, we still want to replay all the
* WAL that was already streamed. It's in pg_xlog now, so
* we just treat this as a failure, and the state machine
* will move on to replay the streamed WAL from pg_xlog,
* and then recheck the trigger and exit replay.
* After being triggered, we still want to replay all
* the WAL that was already streamed. It's in pg_xlog
* now, so we just treat this as a failure, and the
* state machine will move on to replay the streamed
* WAL from pg_xlog, and then recheck the trigger and
* exit replay.
*/
lastSourceFailed = true;
break;
}
/*
* Wait for more WAL to arrive. Time out after 5 seconds, like
* when polling the archive, to react to a trigger file
* promptly.
* Wait for more WAL to arrive. Time out after 5 seconds,
* like when polling the archive, to react to a trigger
* file promptly.
*/
WaitLatch(&XLogCtl->recoveryWakeupLatch,
WL_LATCH_SET | WL_TIMEOUT,
@ -9903,11 +9919,10 @@ CheckForStandbyTrigger(void)
if (IsPromoteTriggered())
{
/*
* In 9.1 and 9.2 the postmaster unlinked the promote file
* inside the signal handler. We now leave the file in place
* and let the Startup process do the unlink. This allows
* Startup to know whether we're doing fast or normal
* promotion. Fast promotion takes precedence.
* In 9.1 and 9.2 the postmaster unlinked the promote file inside the
* signal handler. We now leave the file in place and let the Startup
* process do the unlink. This allows Startup to know whether we're
* doing fast or normal promotion. Fast promotion takes precedence.
*/
if (stat(FAST_PROMOTE_SIGNAL_FILE, &stat_buf) == 0)
{

View File

@ -87,9 +87,9 @@ RestoreArchivedFile(char *path, const char *xlogfname,
* of log segments that weren't yet transferred to the archive.
*
* Notice that we don't actually overwrite any files when we copy back
* from archive because the restore_command may inadvertently
* restore inappropriate xlogs, or they may be corrupt, so we may wish to
* fallback to the segments remaining in current XLOGDIR later. The
* from archive because the restore_command may inadvertently restore
* inappropriate xlogs, or they may be corrupt, so we may wish to fallback
* to the segments remaining in current XLOGDIR later. The
* copy-from-archive filename is always the same, ensuring that we don't
* run out of disk space on long recoveries.
*/
@ -434,18 +434,19 @@ KeepFileRestoredFromArchive(char *path, char *xlogfname)
if (stat(xlogfpath, &statbuf) == 0)
{
char oldpath[MAXPGPATH];
#ifdef WIN32
static unsigned int deletedcounter = 1;
/*
* On Windows, if another process (e.g a walsender process) holds
* the file open in FILE_SHARE_DELETE mode, unlink will succeed,
* but the file will still show up in directory listing until the
* last handle is closed, and we cannot rename the new file in its
* place until that. To avoid that problem, rename the old file to
* a temporary name first. Use a counter to create a unique
* filename, because the same file might be restored from the
* archive multiple times, and a walsender could still be holding
* onto an old deleted version of it.
* On Windows, if another process (e.g a walsender process) holds the
* file open in FILE_SHARE_DELETE mode, unlink will succeed, but the
* file will still show up in directory listing until the last handle
* is closed, and we cannot rename the new file in its place until
* that. To avoid that problem, rename the old file to a temporary
* name first. Use a counter to create a unique filename, because the
* same file might be restored from the archive multiple times, and a
* walsender could still be holding onto an old deleted version of it.
*/
snprintf(oldpath, MAXPGPATH, "%s.deleted%u",
xlogfpath, deletedcounter++);
@ -474,17 +475,17 @@ KeepFileRestoredFromArchive(char *path, char *xlogfname)
path, xlogfpath)));
/*
* Create .done file forcibly to prevent the restored segment from
* being archived again later.
* Create .done file forcibly to prevent the restored segment from being
* archived again later.
*/
XLogArchiveForceDone(xlogfname);
/*
* If the existing file was replaced, since walsenders might have it
* open, request them to reload a currently-open segment. This is only
* required for WAL segments, walsenders don't hold other files open, but
* there's no harm in doing this too often, and we don't know what kind
* of a file we're dealing with here.
* If the existing file was replaced, since walsenders might have it open,
* request them to reload a currently-open segment. This is only required
* for WAL segments, walsenders don't hold other files open, but there's
* no harm in doing this too often, and we don't know what kind of a file
* we're dealing with here.
*/
if (reload)
WalSndRqstFileReload();

View File

@ -221,9 +221,9 @@ XLogReadRecord(XLogReaderState *state, XLogRecPtr RecPtr, char **errormsg)
targetRecOff = RecPtr % XLOG_BLCKSZ;
/*
* Read the page containing the record into state->readBuf. Request
* enough byte to cover the whole record header, or at least the part of
* it that fits on the same page.
* Read the page containing the record into state->readBuf. Request enough
* byte to cover the whole record header, or at least the part of it that
* fits on the same page.
*/
readOff = ReadPageInternal(state,
targetPagePtr,

View File

@ -870,6 +870,7 @@ AddNewRelationTuple(Relation pg_class_desc,
* that will do.
*/
new_rel_reltup->relfrozenxid = RecentXmin;
/*
* Similarly, initialize the minimum Multixact to the first value that
* could possibly be stored in tuples in the table. Running
@ -1915,10 +1916,10 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
/*
* Post creation hook for attribute defaults.
*
* XXX. ALTER TABLE ALTER COLUMN SET/DROP DEFAULT is implemented
* with a couple of deletion/creation of the attribute's default entry,
* so the callee should check existence of an older version of this
* entry if it needs to distinguish.
* XXX. ALTER TABLE ALTER COLUMN SET/DROP DEFAULT is implemented with a
* couple of deletion/creation of the attribute's default entry, so the
* callee should check existence of an older version of this entry if it
* needs to distinguish.
*/
InvokeObjectPostCreateHookArg(AttrDefaultRelationId,
RelationGetRelid(rel), attnum, is_internal);

View File

@ -293,6 +293,7 @@ RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode,
Oid namespaceId;
namespaceId = LookupExplicitNamespace(relation->schemaname, missing_ok);
/*
* For missing_ok, allow a non-existant schema name to
* return InvalidOid.

View File

@ -94,10 +94,11 @@ typedef struct
AttrNumber attnum_owner; /* attnum of owner field */
AttrNumber attnum_acl; /* attnum of acl field */
AclObjectKind acl_kind; /* ACL_KIND_* of this object type */
bool is_nsp_name_unique; /* can the nsp/name combination (or name
* alone, if there's no namespace) be
* considered an unique identifier for an
* object of this class? */
bool is_nsp_name_unique; /* can the nsp/name combination (or
* name alone, if there's no
* namespace) be considered an unique
* identifier for an object of this
* class? */
} ObjectPropertyType;
static ObjectPropertyType ObjectProperty[] =
@ -2359,8 +2360,8 @@ pg_identify_object(PG_FUNCTION_ARGS)
}
/*
* We only return the object name if it can be used (together
* with the schema name, if any) as an unique identifier.
* We only return the object name if it can be used (together with
* the schema name, if any) as an unique identifier.
*/
if (get_object_namensp_unique(address.classId))
{

View File

@ -92,11 +92,11 @@ validOperatorName(const char *name)
return false;
/*
* For SQL standard compatibility, '+' and '-' cannot be the last char of a
* multi-char operator unless the operator contains chars that are not in
* SQL operators. The idea is to lex '=-' as two operators, but not to
* forbid operator names like '?-' that could not be sequences of standard SQL
* operators.
* For SQL standard compatibility, '+' and '-' cannot be the last char of
* a multi-char operator unless the operator contains chars that are not
* in SQL operators. The idea is to lex '=-' as two operators, but not to
* forbid operator names like '?-' that could not be sequences of standard
* SQL operators.
*/
if (len > 1 &&
(name[len - 1] == '+' ||

View File

@ -505,13 +505,12 @@ smgr_redo(XLogRecPtr lsn, XLogRecord *record)
smgrcreate(reln, MAIN_FORKNUM, true);
/*
* Before we perform the truncation, update minimum recovery point
* to cover this WAL record. Once the relation is truncated, there's
* no going back. The buffer manager enforces the WAL-first rule
* for normal updates to relation files, so that the minimum recovery
* point is always updated before the corresponding change in the
* data file is flushed to disk. We have to do the same manually
* here.
* Before we perform the truncation, update minimum recovery point to
* cover this WAL record. Once the relation is truncated, there's no
* going back. The buffer manager enforces the WAL-first rule for
* normal updates to relation files, so that the minimum recovery
* point is always updated before the corresponding change in the data
* file is flushed to disk. We have to do the same manually here.
*
* Doing this before the truncation means that if the truncation fails
* for some reason, you cannot start up the system even after restart,

View File

@ -501,9 +501,9 @@ CopySendEndOfRow(CopyState cstate)
ClosePipeToProgram(cstate);
/*
* If ClosePipeToProgram() didn't throw an error,
* the program terminated normally, but closed the
* pipe first. Restore errno, and throw an error.
* If ClosePipeToProgram() didn't throw an error, the
* program terminated normally, but closed the pipe
* first. Restore errno, and throw an error.
*/
errno = EPIPE;
}
@ -1022,9 +1022,9 @@ ProcessCopyOptions(CopyState cstate,
else if (strcmp(defel->defname, "convert_selectively") == 0)
{
/*
* Undocumented, not-accessible-from-SQL option: convert only
* the named columns to binary form, storing the rest as NULLs.
* It's allowed for the column list to be NIL.
* Undocumented, not-accessible-from-SQL option: convert only the
* named columns to binary form, storing the rest as NULLs. It's
* allowed for the column list to be NIL.
*/
if (cstate->convert_selectively)
ereport(ERROR,
@ -1929,8 +1929,8 @@ CopyFromErrorCallback(void *arg)
* Error is relevant to a particular line.
*
* If line_buf still contains the correct line, and it's already
* transcoded, print it. If it's still in a foreign encoding,
* it's quite likely that the error is precisely a failure to do
* transcoded, print it. If it's still in a foreign encoding, it's
* quite likely that the error is precisely a failure to do
* encoding conversion (ie, bad data). We dare not try to convert
* it, and at present there's no way to regurgitate it without
* conversion. So we have to punt and just report the line number.
@ -2096,13 +2096,12 @@ CopyFrom(CopyState cstate)
}
/*
* Optimize if new relfilenode was created in this subxact or
* one of its committed children and we won't see those rows later
* as part of an earlier scan or command. This ensures that if this
* subtransaction aborts then the frozen rows won't be visible
* after xact cleanup. Note that the stronger test of exactly
* which subtransaction created it is crucial for correctness
* of this optimisation.
* Optimize if new relfilenode was created in this subxact or one of its
* committed children and we won't see those rows later as part of an
* earlier scan or command. This ensures that if this subtransaction
* aborts then the frozen rows won't be visible after xact cleanup. Note
* that the stronger test of exactly which subtransaction created it is
* crucial for correctness of this optimisation.
*/
if (cstate->freeze)
{

View File

@ -1882,8 +1882,11 @@ static int
errdetail_busy_db(int notherbackends, int npreparedxacts)
{
if (notherbackends > 0 && npreparedxacts > 0)
/* We don't deal with singular versus plural here, since gettext
* doesn't support multiple plurals in one string. */
/*
* We don't deal with singular versus plural here, since gettext
* doesn't support multiple plurals in one string.
*/
errdetail("There are %d other session(s) and %d prepared transaction(s) using the database.",
notherbackends, npreparedxacts);
else if (notherbackends > 0)

View File

@ -302,7 +302,8 @@ insert_event_trigger_tuple(char *trigname, char *eventname, Oid evtOwner,
HeapTuple tuple;
Datum values[Natts_pg_trigger];
bool nulls[Natts_pg_trigger];
ObjectAddress myself, referenced;
ObjectAddress myself,
referenced;
/* Open pg_event_trigger. */
tgrel = heap_open(EventTriggerRelationId, RowExclusiveLock);
@ -646,11 +647,11 @@ EventTriggerCommonSetup(Node *parsetree,
tag = CreateCommandTag(parsetree);
/*
* Filter list of event triggers by command tag, and copy them into
* our memory context. Once we start running the command trigers, or
* indeed once we do anything at all that touches the catalogs, an
* invalidation might leave cachelist pointing at garbage, so we must
* do this before we can do much else.
* Filter list of event triggers by command tag, and copy them into our
* memory context. Once we start running the command trigers, or indeed
* once we do anything at all that touches the catalogs, an invalidation
* might leave cachelist pointing at garbage, so we must do this before we
* can do much else.
*/
foreach(lc, cachelist)
{
@ -716,8 +717,8 @@ EventTriggerDDLCommandStart(Node *parsetree)
list_free(runlist);
/*
* Make sure anything the event triggers did will be visible to
* the main command.
* Make sure anything the event triggers did will be visible to the main
* command.
*/
CommandCounterIncrement();
}
@ -745,8 +746,8 @@ EventTriggerDDLCommandEnd(Node *parsetree)
return;
/*
* Make sure anything the main command did will be visible to the
* event triggers.
* Make sure anything the main command did will be visible to the event
* triggers.
*/
CommandCounterIncrement();
@ -774,10 +775,11 @@ EventTriggerSQLDrop(Node *parsetree)
return;
/*
* Use current state to determine whether this event fires at all. If there
* are no triggers for the sql_drop event, then we don't have anything to do
* here. Note that dropped object collection is disabled if this is the case,
* so even if we were to try to run, the list would be empty.
* Use current state to determine whether this event fires at all. If
* there are no triggers for the sql_drop event, then we don't have
* anything to do here. Note that dropped object collection is disabled
* if this is the case, so even if we were to try to run, the list would
* be empty.
*/
if (!currentEventTriggerState ||
slist_is_empty(&currentEventTriggerState->SQLDropList))
@ -786,24 +788,25 @@ EventTriggerSQLDrop(Node *parsetree)
runlist = EventTriggerCommonSetup(parsetree,
EVT_SQLDrop, "sql_drop",
&trigdata);
/*
* Nothing to do if run list is empty. Note this shouldn't happen, because
* if there are no sql_drop events, then objects-to-drop wouldn't have been
* collected in the first place and we would have quitted above.
* Nothing to do if run list is empty. Note this shouldn't happen,
* because if there are no sql_drop events, then objects-to-drop wouldn't
* have been collected in the first place and we would have quitted above.
*/
if (runlist == NIL)
return;
/*
* Make sure anything the main command did will be visible to the
* event triggers.
* Make sure anything the main command did will be visible to the event
* triggers.
*/
CommandCounterIncrement();
/*
* Make sure pg_event_trigger_dropped_objects only works when running these
* triggers. Use PG_TRY to ensure in_sql_drop is reset even when one
* trigger fails. (This is perhaps not necessary, as the currentState
* Make sure pg_event_trigger_dropped_objects only works when running
* these triggers. Use PG_TRY to ensure in_sql_drop is reset even when
* one trigger fails. (This is perhaps not necessary, as the currentState
* variable will be removed shortly by our caller, but it seems better to
* play safe.)
*/
@ -841,8 +844,8 @@ EventTriggerInvoke(List *fn_oid_list, EventTriggerData *trigdata)
check_stack_depth();
/*
* Let's evaluate event triggers in their own memory context, so
* that any leaks get cleaned up promptly.
* Let's evaluate event triggers in their own memory context, so that any
* leaks get cleaned up promptly.
*/
context = AllocSetContextCreate(CurrentMemoryContext,
"event trigger context",
@ -860,10 +863,10 @@ EventTriggerInvoke(List *fn_oid_list, EventTriggerData *trigdata)
PgStat_FunctionCallUsage fcusage;
/*
* We want each event trigger to be able to see the results of
* the previous event trigger's action. Caller is responsible
* for any command-counter increment that is needed between the
* event trigger and anything else in the transaction.
* We want each event trigger to be able to see the results of the
* previous event trigger's action. Caller is responsible for any
* command-counter increment that is needed between the event trigger
* and anything else in the transaction.
*/
if (first)
first = false;
@ -987,6 +990,7 @@ EventTriggerSupportsObjectClass(ObjectClass objclass)
return true;
case MAX_OCLASS:
/*
* This shouldn't ever happen, but we keep the case to avoid a
* compiler warning without a "default" clause in the switch.
@ -1112,8 +1116,9 @@ EventTriggerSQLDropAddObject(ObjectAddress *object)
/*
* Obtain schema names from the object's catalog tuple, if one exists;
* this lets us skip objects in temp schemas. We trust that ObjectProperty
* contains all object classes that can be schema-qualified.
* this lets us skip objects in temp schemas. We trust that
* ObjectProperty contains all object classes that can be
* schema-qualified.
*/
if (is_objectclass_supported(object->classId))
{

View File

@ -415,8 +415,8 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
instrument_option |= INSTRUMENT_BUFFERS;
/*
* We always collect timing for the entire statement, even when
* node-level timing is off, so we don't look at es->timing here.
* We always collect timing for the entire statement, even when node-level
* timing is off, so we don't look at es->timing here.
*/
INSTR_TIME_SET_CURRENT(starttime);

View File

@ -698,8 +698,8 @@ nextval_internal(Oid relid)
/*
* We must mark the buffer dirty before doing XLogInsert(); see notes in
* SyncOneBuffer(). However, we don't apply the desired changes just yet.
* This looks like a violation of the buffer update protocol, but it is
* in fact safe because we hold exclusive lock on the buffer. Any other
* This looks like a violation of the buffer update protocol, but it is in
* fact safe because we hold exclusive lock on the buffer. Any other
* process, including a checkpoint, that tries to examine the buffer
* contents will block until we release the lock, and then will see the
* final state that we install below.
@ -1226,8 +1226,8 @@ init_params(List *options, bool isInit,
}
/*
* We must reset log_cnt when isInit or when changing any parameters
* that would affect future nextval allocations.
* We must reset log_cnt when isInit or when changing any parameters that
* would affect future nextval allocations.
*/
if (isInit)
new->log_cnt = 0;

View File

@ -1675,9 +1675,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
&found_whole_row);
/*
* For the moment we have to reject whole-row variables.
* We could convert them, if we knew the new table's rowtype
* OID, but that hasn't been assigned yet.
* For the moment we have to reject whole-row variables. We
* could convert them, if we knew the new table's rowtype OID,
* but that hasn't been assigned yet.
*/
if (found_whole_row)
ereport(ERROR,
@ -3294,7 +3294,8 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
ATExecAddConstraint(wqueue, tab, rel, (Constraint *) cmd->def,
true, false, lockmode);
break;
case AT_ReAddConstraint: /* Re-add pre-existing check constraint */
case AT_ReAddConstraint: /* Re-add pre-existing check
* constraint */
ATExecAddConstraint(wqueue, tab, rel, (Constraint *) cmd->def,
false, true, lockmode);
break;
@ -9564,9 +9565,9 @@ ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
RelationGetRelid(parent_rel));
/*
* Post alter hook of this inherits. Since object_access_hook doesn't
* take multiple object identifiers, we relay oid of parent relation
* using auxiliary_id argument.
* Post alter hook of this inherits. Since object_access_hook doesn't take
* multiple object identifiers, we relay oid of parent relation using
* auxiliary_id argument.
*/
InvokeObjectPostAlterHookArg(InheritsRelationId,
RelationGetRelid(rel), 0,
@ -10247,6 +10248,7 @@ PreCommit_on_commit_actions(void)
/* Do nothing (there shouldn't be such entries, actually) */
break;
case ONCOMMIT_DELETE_ROWS:
/*
* If this transaction hasn't accessed any temporary
* relations, we can skip truncating ON COMMIT DELETE ROWS

View File

@ -1266,6 +1266,7 @@ renametrig(RenameStmt *stmt)
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
tgoid = HeapTupleGetOid(tuple);
/*
* Update pg_trigger tuple with new tgname.
*/
@ -2619,6 +2620,7 @@ ltrmark:;
switch (test)
{
case HeapTupleSelfUpdated:
/*
* The target tuple was already updated or deleted by the
* current command, or by a later command in the current

View File

@ -924,8 +924,8 @@ DefineDomain(CreateDomainStmt *stmt)
/*
* Check constraints are handled after domain creation, as
* they require the Oid of the domain; at this point we can
* only check that they're not marked NO INHERIT, because
* that would be bogus.
* only check that they're not marked NO INHERIT, because that
* would be bogus.
*/
if (constr->is_no_inherit)
ereport(ERROR,
@ -1192,14 +1192,14 @@ AlterEnum(AlterEnumStmt *stmt, bool isTopLevel)
* Ordinarily we disallow adding values within transaction blocks, because
* we can't cope with enum OID values getting into indexes and then having
* their defining pg_enum entries go away. However, it's okay if the enum
* type was created in the current transaction, since then there can be
* no such indexes that wouldn't themselves go away on rollback. (We
* support this case because pg_dump --binary-upgrade needs it.) We test
* this by seeing if the pg_type row has xmin == current XID and is not
* HEAP_UPDATED. If it is HEAP_UPDATED, we can't be sure whether the
* type was created or only modified in this xact. So we are disallowing
* some cases that could theoretically be safe; but fortunately pg_dump
* only needs the simplest case.
* type was created in the current transaction, since then there can be no
* such indexes that wouldn't themselves go away on rollback. (We support
* this case because pg_dump --binary-upgrade needs it.) We test this by
* seeing if the pg_type row has xmin == current XID and is not
* HEAP_UPDATED. If it is HEAP_UPDATED, we can't be sure whether the type
* was created or only modified in this xact. So we are disallowing some
* cases that could theoretically be safe; but fortunately pg_dump only
* needs the simplest case.
*/
if (HeapTupleHeaderGetXmin(tup->t_data) == GetCurrentTransactionId() &&
!(tup->t_data->t_infomask & HEAP_UPDATED))

View File

@ -327,10 +327,10 @@ get_rel_oids(Oid relid, const RangeVar *vacrel)
* Since we don't take a lock here, the relation might be gone, or the
* RangeVar might no longer refer to the OID we look up here. In the
* former case, VACUUM will do nothing; in the latter case, it will
* process the OID we looked up here, rather than the new one.
* Neither is ideal, but there's little practical alternative, since
* we're going to commit this transaction and begin a new one between
* now and then.
* process the OID we looked up here, rather than the new one. Neither
* is ideal, but there's little practical alternative, since we're
* going to commit this transaction and begin a new one between now
* and then.
*/
relid = RangeVarGetRelid(vacrel, NoLock, false);
@ -723,8 +723,8 @@ vac_update_datfrozenxid(void)
newFrozenXid = GetOldestXmin(true, true);
/*
* Similarly, initialize the MultiXact "min" with the value that would
* be used on pg_class for new tables. See AddNewRelationTuple().
* Similarly, initialize the MultiXact "min" with the value that would be
* used on pg_class for new tables. See AddNewRelationTuple().
*/
newFrozenMulti = GetOldestMultiXactId();
@ -900,8 +900,8 @@ vac_truncate_clog(TransactionId frozenXID, MultiXactId frozenMulti)
/*
* Update the wrap limit for GetNewTransactionId and creation of new
* MultiXactIds. Note: these functions will also signal the postmaster for
* an(other) autovac cycle if needed. XXX should we avoid possibly
* MultiXactIds. Note: these functions will also signal the postmaster
* for an(other) autovac cycle if needed. XXX should we avoid possibly
* signalling twice?
*/
SetTransactionIdLimit(frozenXID, oldestxid_datoid);

View File

@ -903,11 +903,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
* so that we get back in sync.
*
* NB: If the heap page is all-visible but the VM bit is not set,
* we don't need to dirty the heap page. However, if checksums are
* enabled, we do need to make sure that the heap page is dirtied
* before passing it to visibilitymap_set(), because it may be
* logged. Given that this situation should only happen in rare
* cases after a crash, it is not worth optimizing.
* we don't need to dirty the heap page. However, if checksums
* are enabled, we do need to make sure that the heap page is
* dirtied before passing it to visibilitymap_set(), because it
* may be logged. Given that this situation should only happen in
* rare cases after a crash, it is not worth optimizing.
*/
PageSetAllVisible(page);
MarkBufferDirty(buf);
@ -1146,8 +1146,8 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
MarkBufferDirty(buffer);
/*
* Now that we have removed the dead tuples from the page, once again check
* if the page has become all-visible.
* Now that we have removed the dead tuples from the page, once again
* check if the page has become all-visible.
*/
if (!visibilitymap_test(onerel, blkno, vmbuffer) &&
heap_page_is_all_visible(buffer, &visibility_cutoff_xid))
@ -1669,8 +1669,7 @@ heap_page_is_all_visible(Buffer buf, TransactionId *visibility_cutoff_xid)
/*
* This is a stripped down version of the line pointer scan in
* lazy_scan_heap(). So if you change anything here, also check that
* code.
* lazy_scan_heap(). So if you change anything here, also check that code.
*/
maxoff = PageGetMaxOffsetNumber(page);
for (offnum = FirstOffsetNumber;
@ -1689,8 +1688,8 @@ heap_page_is_all_visible(Buffer buf, TransactionId *visibility_cutoff_xid)
ItemPointerSet(&(tuple.t_self), BufferGetBlockNumber(buf), offnum);
/*
* Dead line pointers can have index pointers pointing to them. So they
* can't be treated as visible
* Dead line pointers can have index pointers pointing to them. So
* they can't be treated as visible
*/
if (ItemIdIsDead(itemid))
{
@ -1716,8 +1715,8 @@ heap_page_is_all_visible(Buffer buf, TransactionId *visibility_cutoff_xid)
}
/*
* The inserter definitely committed. But is it old
* enough that everyone sees it as committed?
* The inserter definitely committed. But is it old enough
* that everyone sees it as committed?
*/
xmin = HeapTupleHeaderGetXmin(tuple.t_data);
if (!TransactionIdPrecedes(xmin, OldestXmin))

View File

@ -959,12 +959,13 @@ CheckValidResultRel(Relation resultRel, CmdType operation)
RelationGetRelationName(resultRel))));
break;
case RELKIND_VIEW:
/*
* Okay only if there's a suitable INSTEAD OF trigger. Messages
* here should match rewriteHandler.c's rewriteTargetView, except
* that we omit errdetail because we haven't got the information
* handy (and given that we really shouldn't get here anyway,
* it's not worth great exertion to get).
* handy (and given that we really shouldn't get here anyway, it's
* not worth great exertion to get).
*/
switch (operation)
{
@ -1391,7 +1392,8 @@ ExecEndPlan(PlanState *planstate, EState *estate)
}
/*
* close any relations selected FOR [KEY] UPDATE/SHARE, again keeping locks
* close any relations selected FOR [KEY] UPDATE/SHARE, again keeping
* locks
*/
foreach(l, estate->es_rowMarks)
{
@ -1546,9 +1548,9 @@ ExecRelCheck(ResultRelInfo *resultRelInfo,
qual = resultRelInfo->ri_ConstraintExprs[i];
/*
* NOTE: SQL specifies that a NULL result from a constraint
* expression is not to be treated as a failure. Therefore, tell
* ExecQual to return TRUE for NULL.
* NOTE: SQL specifies that a NULL result from a constraint expression
* is not to be treated as a failure. Therefore, tell ExecQual to
* return TRUE for NULL.
*/
if (!ExecQual(qual, econtext, true))
return check[i].ccname;
@ -1901,13 +1903,13 @@ EvalPlanQualFetch(EState *estate, Relation relation, int lockmode,
/*
* If tuple was inserted by our own transaction, we have to check
* cmin against es_output_cid: cmin >= current CID means our
* command cannot see the tuple, so we should ignore it.
* Otherwise heap_lock_tuple() will throw an error, and so would
* any later attempt to update or delete the tuple. (We need not
* check cmax because HeapTupleSatisfiesDirty will consider a
* tuple deleted by our transaction dead, regardless of cmax.)
* Wee just checked that priorXmax == xmin, so we can test that
* variable instead of doing HeapTupleHeaderGetXmin again.
* command cannot see the tuple, so we should ignore it. Otherwise
* heap_lock_tuple() will throw an error, and so would any later
* attempt to update or delete the tuple. (We need not check cmax
* because HeapTupleSatisfiesDirty will consider a tuple deleted
* by our transaction dead, regardless of cmax.) Wee just checked
* that priorXmax == xmin, so we can test that variable instead of
* doing HeapTupleHeaderGetXmin again.
*/
if (TransactionIdIsCurrentTransactionId(priorXmax) &&
HeapTupleHeaderGetCmin(tuple.t_data) >= estate->es_output_cid)
@ -1929,6 +1931,7 @@ EvalPlanQualFetch(EState *estate, Relation relation, int lockmode,
switch (test)
{
case HeapTupleSelfUpdated:
/*
* The target tuple was already updated or deleted by the
* current command, or by a later command in the current

View File

@ -139,6 +139,7 @@ lnext:
switch (test)
{
case HeapTupleSelfUpdated:
/*
* The target tuple was already updated or deleted by the
* current command, or by a later command in the current

View File

@ -397,13 +397,14 @@ ldelete:;
switch (result)
{
case HeapTupleSelfUpdated:
/*
* The target tuple was already updated or deleted by the
* current command, or by a later command in the current
* transaction. The former case is possible in a join DELETE
* where multiple tuples join to the same target tuple.
* This is somewhat questionable, but Postgres has always
* allowed it: we just ignore additional deletion attempts.
* where multiple tuples join to the same target tuple. This
* is somewhat questionable, but Postgres has always allowed
* it: we just ignore additional deletion attempts.
*
* The latter case arises if the tuple is modified by a
* command in a BEFORE trigger, or perhaps by a command in a
@ -417,9 +418,9 @@ ldelete:;
* to business rules; so throwing an error is the only safe
* course.
*
* If a trigger actually intends this type of interaction,
* it can re-execute the DELETE and then return NULL to
* cancel the outer delete.
* If a trigger actually intends this type of interaction, it
* can re-execute the DELETE and then return NULL to cancel
* the outer delete.
*/
if (hufd.cmax != estate->es_output_cid)
ereport(ERROR,
@ -678,14 +679,15 @@ lreplace:;
switch (result)
{
case HeapTupleSelfUpdated:
/*
* The target tuple was already updated or deleted by the
* current command, or by a later command in the current
* transaction. The former case is possible in a join UPDATE
* where multiple tuples join to the same target tuple.
* This is pretty questionable, but Postgres has always
* allowed it: we just execute the first update action and
* ignore additional update attempts.
* where multiple tuples join to the same target tuple. This
* is pretty questionable, but Postgres has always allowed it:
* we just execute the first update action and ignore
* additional update attempts.
*
* The latter case arises if the tuple is modified by a
* command in a BEFORE trigger, or perhaps by a command in a
@ -697,9 +699,9 @@ lreplace:;
* previous ones. So throwing an error is the only safe
* course.
*
* If a trigger actually intends this type of interaction,
* it can re-execute the UPDATE (assuming it can figure out
* how) and then return NULL to cancel the outer update.
* If a trigger actually intends this type of interaction, it
* can re-execute the UPDATE (assuming it can figure out how)
* and then return NULL to cancel the outer update.
*/
if (hufd.cmax != estate->es_output_cid)
ereport(ERROR,

View File

@ -47,7 +47,6 @@ int
cx(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring,
int num_gene, City *city_table)
{
int i,
start_pos,
curr_pos;

View File

@ -46,7 +46,6 @@ void
px(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene,
City *city_table)
{
int num_positions;
int i,
pos,

View File

@ -2083,9 +2083,9 @@ generate_implied_equalities_for_column(PlannerInfo *root,
continue;
/*
* Scan members, looking for a match to the target column. Note
* that child EC members are considered, but only when they belong to
* the target relation. (Unlike regular members, the same expression
* Scan members, looking for a match to the target column. Note that
* child EC members are considered, but only when they belong to the
* target relation. (Unlike regular members, the same expression
* could be a child member of more than one EC. Therefore, it's
* potentially order-dependent which EC a child relation's target
* column gets matched to. This is annoying but it only happens in

View File

@ -2630,8 +2630,8 @@ check_partial_indexes(PlannerInfo *root, RelOptInfo *rel)
return;
/*
* Construct a list of clauses that we can assume true for the purpose
* of proving the index(es) usable. Restriction clauses for the rel are
* Construct a list of clauses that we can assume true for the purpose of
* proving the index(es) usable. Restriction clauses for the rel are
* always usable, and so are any join clauses that are "movable to" this
* rel. Also, we can consider any EC-derivable join clauses (which must
* be "movable to" this rel, by definition).
@ -2653,8 +2653,8 @@ check_partial_indexes(PlannerInfo *root, RelOptInfo *rel)
/*
* Add on any equivalence-derivable join clauses. Computing the correct
* relid sets for generate_join_implied_equalities is slightly tricky
* because the rel could be a child rel rather than a true baserel, and
* in that case we must remove its parent's relid from all_baserels.
* because the rel could be a child rel rather than a true baserel, and in
* that case we must remove its parent's relid from all_baserels.
*/
if (rel->reloptkind == RELOPT_OTHER_MEMBER_REL)
{

View File

@ -861,11 +861,11 @@ make_outerjoininfo(PlannerInfo *root,
Assert(jointype != JOIN_RIGHT);
/*
* Presently the executor cannot support FOR [KEY] UPDATE/SHARE marking of rels
* appearing on the nullable side of an outer join. (It's somewhat unclear
* what that would mean, anyway: what should we mark when a result row is
* generated from no element of the nullable relation?) So, complain if
* any nullable rel is FOR [KEY] UPDATE/SHARE.
* Presently the executor cannot support FOR [KEY] UPDATE/SHARE marking of
* rels appearing on the nullable side of an outer join. (It's somewhat
* unclear what that would mean, anyway: what should we mark when a result
* row is generated from no element of the nullable relation?) So,
* complain if any nullable rel is FOR [KEY] UPDATE/SHARE.
*
* You might be wondering why this test isn't made far upstream in the
* parser. It's because the parser hasn't got enough info --- consider

View File

@ -260,8 +260,8 @@ optimize_minmax_aggregates(PlannerInfo *root, List *tlist,
* We have to replace Aggrefs with Params in equivalence classes too, else
* ORDER BY or DISTINCT on an optimized aggregate will fail. We don't
* need to process child eclass members though, since they aren't of
* interest anymore --- and replace_aggs_with_params_mutator isn't able
* to handle Aggrefs containing translated child Vars, anyway.
* interest anymore --- and replace_aggs_with_params_mutator isn't able to
* handle Aggrefs containing translated child Vars, anyway.
*
* Note: at some point it might become necessary to mutate other data
* structures too, such as the query's sortClause or distinctClause. Right

View File

@ -571,9 +571,9 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
returningLists = NIL;
/*
* If there was a FOR [KEY] UPDATE/SHARE clause, the LockRows node will
* have dealt with fetching non-locked marked rows, else we need
* to have ModifyTable do that.
* If there was a FOR [KEY] UPDATE/SHARE clause, the LockRows node
* will have dealt with fetching non-locked marked rows, else we
* need to have ModifyTable do that.
*/
if (parse->rowMarks)
rowMarks = NIL;
@ -964,8 +964,8 @@ inheritance_planner(PlannerInfo *root)
root->simple_rel_array = save_rel_array;
/*
* If there was a FOR [KEY] UPDATE/SHARE clause, the LockRows node will have
* dealt with fetching non-locked marked rows, else we need to have
* If there was a FOR [KEY] UPDATE/SHARE clause, the LockRows node will
* have dealt with fetching non-locked marked rows, else we need to have
* ModifyTable do that.
*/
if (parse->rowMarks)
@ -1075,8 +1075,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
tlist);
/*
* Can't handle FOR [KEY] UPDATE/SHARE here (parser should have checked
* already, but let's make sure).
* Can't handle FOR [KEY] UPDATE/SHARE here (parser should have
* checked already, but let's make sure).
*/
if (parse->rowMarks)
ereport(ERROR,
@ -1741,9 +1741,9 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
}
/*
* If there is a FOR [KEY] UPDATE/SHARE clause, add the LockRows node. (Note: we
* intentionally test parse->rowMarks not root->rowMarks here. If there
* are only non-locking rowmarks, they should be handled by the
* If there is a FOR [KEY] UPDATE/SHARE clause, add the LockRows node.
* (Note: we intentionally test parse->rowMarks not root->rowMarks here.
* If there are only non-locking rowmarks, they should be handled by the
* ModifyTable node instead.)
*/
if (parse->rowMarks)
@ -1927,9 +1927,9 @@ preprocess_rowmarks(PlannerInfo *root)
if (parse->rowMarks)
{
/*
* We've got trouble if FOR [KEY] UPDATE/SHARE appears inside grouping,
* since grouping renders a reference to individual tuple CTIDs
* invalid. This is also checked at parse time, but that's
* We've got trouble if FOR [KEY] UPDATE/SHARE appears inside
* grouping, since grouping renders a reference to individual tuple
* CTIDs invalid. This is also checked at parse time, but that's
* insufficient because of rule substitution, query pullup, etc.
*/
CheckSelectLocking(parse);
@ -1937,7 +1937,8 @@ preprocess_rowmarks(PlannerInfo *root)
else
{
/*
* We only need rowmarks for UPDATE, DELETE, or FOR [KEY] UPDATE/SHARE.
* We only need rowmarks for UPDATE, DELETE, or FOR [KEY]
* UPDATE/SHARE.
*/
if (parse->commandType != CMD_UPDATE &&
parse->commandType != CMD_DELETE)

View File

@ -1288,9 +1288,9 @@ is_simple_subquery(Query *subquery, RangeTblEntry *rte,
return false;
/*
* Don't pull up if the RTE represents a security-barrier view; we couldn't
* prevent information leakage once the RTE's Vars are scattered about in
* the upper query.
* Don't pull up if the RTE represents a security-barrier view; we
* couldn't prevent information leakage once the RTE's Vars are scattered
* about in the upper query.
*/
if (rte->security_barrier)
return false;

View File

@ -282,6 +282,7 @@ set_cheapest(RelOptInfo *parent_rel)
/* old path is less-parameterized, keep it */
break;
case BMS_DIFFERENT:
/*
* This means that neither path has the least possible
* parameterization for the rel. We'll sit on the old
@ -328,8 +329,8 @@ set_cheapest(RelOptInfo *parent_rel)
parameterized_paths = lcons(cheapest_total_path, parameterized_paths);
/*
* If there is no unparameterized path, use the best parameterized path
* as cheapest_total_path (but not as cheapest_startup_path).
* If there is no unparameterized path, use the best parameterized path as
* cheapest_total_path (but not as cheapest_startup_path).
*/
if (cheapest_total_path == NULL)
cheapest_total_path = best_param_path;

View File

@ -2167,10 +2167,10 @@ transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
errmsg("materialized views may not be defined using bound parameters")));
/*
* For now, we disallow unlogged materialized views, because it
* seems like a bad idea for them to just go to empty after a crash.
* (If we could mark them as unpopulated, that would be better, but
* that requires catalog changes which crash recovery can't presently
* For now, we disallow unlogged materialized views, because it seems
* like a bad idea for them to just go to empty after a crash. (If we
* could mark them as unpopulated, that would be better, but that
* requires catalog changes which crash recovery can't presently
* handle.)
*/
if (stmt->into->rel->relpersistence == RELPERSISTENCE_UNLOGGED)
@ -2394,8 +2394,8 @@ applyLockingClause(Query *qry, Index rtindex,
{
/*
* If the same RTE is specified for more than one locking strength,
* treat is as the strongest. (Reasonable, since you can't take both a
* shared and exclusive lock at the same time; it'll end up being
* treat is as the strongest. (Reasonable, since you can't take both
* a shared and exclusive lock at the same time; it'll end up being
* exclusive anyway.)
*
* We also consider that NOWAIT wins if it's specified both ways. This

View File

@ -52,6 +52,7 @@ line: while (<GRAM>)
if (!($kcat))
{
# Is this the beginning of a keyword list?
foreach $k (keys %keyword_categories)
{
@ -81,6 +82,7 @@ line: while (<GRAM>)
}
elsif ($arr[$fieldIndexer] eq '/*')
{
# start of a multiline comment
$comment = 1;
next;
@ -92,6 +94,7 @@ line: while (<GRAM>)
if ($arr[$fieldIndexer] eq ';')
{
# end of keyword list
$kcat = '';
next;
@ -116,6 +119,7 @@ foreach $kcat (keys %keyword_categories)
foreach $kword (@{ $keywords{$kcat} })
{
# Some keyword have a _P suffix. Remove it for the comparison.
$bare_kword = $kword;
$bare_kword =~ s/_P$//;
@ -206,6 +210,7 @@ kwlist_line: while (<KWLIST>)
}
else
{
# Remove it from the hash, so that we can
# complain at the end if there's keywords left
# that were not found in kwlist.h

View File

@ -715,8 +715,8 @@ transformFromClauseItem(ParseState *pstate, Node *n,
/*
* Make the left-side RTEs available for LATERAL access within the
* right side, by temporarily adding them to the pstate's namespace
* list. Per SQL:2008, if the join type is not INNER or LEFT then
* the left-side names must still be exposed, but it's an error to
* list. Per SQL:2008, if the join type is not INNER or LEFT then the
* left-side names must still be exposed, but it's an error to
* reference them. (Stupid design, but that's what it says.) Hence,
* we always push them into the namespace, but mark them as not
* lateral_ok if the jointype is wrong.

View File

@ -1411,9 +1411,9 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
return result;
/*
* Check to see if the sublink is in an invalid place within the query.
* We allow sublinks everywhere in SELECT/INSERT/UPDATE/DELETE, but
* generally not in utility statements.
* Check to see if the sublink is in an invalid place within the query. We
* allow sublinks everywhere in SELECT/INSERT/UPDATE/DELETE, but generally
* not in utility statements.
*/
err = NULL;
switch (pstate->p_expr_kind)

View File

@ -556,6 +556,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
errmsg("constraints are not supported on foreign tables"),
parser_errposition(cxt->pstate,
constraint->location)));
/*
* Fill in the current attribute's name and throw it into the
* list of FK constraints to be processed later.
@ -1405,8 +1406,8 @@ transformIndexConstraints(CreateStmtContext *cxt)
/*
* Scan the index list and remove any redundant index specifications. This
* can happen if, for instance, the user writes UNIQUE PRIMARY KEY. A
* strict reading of SQL would suggest raising an error instead, but
* that strikes me as too anal-retentive. - tgl 2001-02-14
* strict reading of SQL would suggest raising an error instead, but that
* strikes me as too anal-retentive. - tgl 2001-02-14
*
* XXX in ALTER TABLE case, it'd be nice to look for duplicate
* pre-existing indexes, too.

View File

@ -384,10 +384,10 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
* settings.
*
* However, we disable this logic in the EXEC_BACKEND case, and fall back
* to the old method of allocating the entire segment using System V shared
* memory, because there's no way to attach an mmap'd segment to a process
* after exec(). Since EXEC_BACKEND is intended only for developer use,
* this shouldn't be a big problem.
* to the old method of allocating the entire segment using System V
* shared memory, because there's no way to attach an mmap'd segment to a
* process after exec(). Since EXEC_BACKEND is intended only for
* developer use, this shouldn't be a big problem.
*/
#ifndef EXEC_BACKEND
{
@ -406,9 +406,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
/*
* We assume that no one will attempt to run PostgreSQL 9.3 or later
* on systems that are ancient enough that anonymous shared memory is
* not supported, such as pre-2.4 versions of Linux. If that turns out
* to be false, we might need to add a run-time test here and do this
* only if the running kernel supports it.
* not supported, such as pre-2.4 versions of Linux. If that turns
* out to be false, we might need to add a run-time test here and do
* this only if the running kernel supports it.
*/
AnonymousShmem = mmap(NULL, size, PROT_READ | PROT_WRITE, PG_MMAP_FLAGS,
-1, 0);
@ -519,9 +519,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
/*
* If AnonymousShmem is NULL here, then we're not using anonymous shared
* memory, and should return a pointer to the System V shared memory block.
* Otherwise, the System V shared memory block is only a shim, and we must
* return a pointer to the real block.
* memory, and should return a pointer to the System V shared memory
* block. Otherwise, the System V shared memory block is only a shim, and
* we must return a pointer to the real block.
*/
if (AnonymousShmem == NULL)
return hdr;

View File

@ -949,8 +949,8 @@ rebuild_database_list(Oid newdb)
PgStat_StatDBEntry *entry;
/*
* skip databases with no stat entries -- in particular, this gets
* rid of dropped databases
* skip databases with no stat entries -- in particular, this gets rid
* of dropped databases
*/
entry = pgstat_fetch_stat_dbentry(avdb->adl_datid);
if (entry == NULL)

View File

@ -930,8 +930,8 @@ CheckpointerShmemInit(void)
{
/*
* First time through, so initialize. Note that we zero the whole
* requests array; this is so that CompactCheckpointerRequestQueue
* can assume that any pad bytes in the request structs are zeroes.
* requests array; this is so that CompactCheckpointerRequestQueue can
* assume that any pad bytes in the request structs are zeroes.
*/
MemSet(CheckpointerShmem, 0, size);
SpinLockInit(&CheckpointerShmem->ckpt_lck);

View File

@ -102,9 +102,9 @@ fork_process(void)
/*
* Older Linux kernels have oom_adj not oom_score_adj. This works
* similarly except with a different scale of adjustment values.
* If it's necessary to build Postgres to work with either API,
* you can define both LINUX_OOM_SCORE_ADJ and LINUX_OOM_ADJ.
* similarly except with a different scale of adjustment values. If
* it's necessary to build Postgres to work with either API, you can
* define both LINUX_OOM_SCORE_ADJ and LINUX_OOM_ADJ.
*/
#ifdef LINUX_OOM_ADJ
{

View File

@ -4401,9 +4401,9 @@ pgstat_recv_inquiry(PgStat_MsgInquiry *msg, int len)
* request's cutoff time, update it; otherwise there's nothing to do.
*
* Note that if a request is found, we return early and skip the below
* check for clock skew. This is okay, since the only way for a DB request
* to be present in the list is that we have been here since the last write
* round.
* check for clock skew. This is okay, since the only way for a DB
* request to be present in the list is that we have been here since the
* last write round.
*/
slist_foreach(iter, &last_statrequests)
{

View File

@ -207,8 +207,10 @@ BackgroundWorker *MyBgworkerEntry = NULL;
/* The socket number we are listening for connections on */
int PostPortNumber;
/* The directory names for Unix socket(s) */
char *Unix_socket_directories;
/* The TCP listen address(es) */
char *ListenAddresses;
@ -1212,8 +1214,8 @@ PostmasterMain(int argc, char *argv[])
/*
* We can start up without the IDENT file, although it means that you
* cannot log in using any of the authentication methods that need a
* user name mapping. load_ident() already logged the details of
* error to the log.
* user name mapping. load_ident() already logged the details of error
* to the log.
*/
}
@ -5214,11 +5216,11 @@ RegisterBackgroundWorker(BackgroundWorker *worker)
}
/*
* Enforce maximum number of workers. Note this is overly restrictive:
* we could allow more non-shmem-connected workers, because these don't
* count towards the MAX_BACKENDS limit elsewhere. This doesn't really
* matter for practical purposes; several million processes would need to
* run on a single server.
* Enforce maximum number of workers. Note this is overly restrictive: we
* could allow more non-shmem-connected workers, because these don't count
* towards the MAX_BACKENDS limit elsewhere. This doesn't really matter
* for practical purposes; several million processes would need to run on
* a single server.
*/
if (++numworkers > maxworkers)
{

View File

@ -583,8 +583,8 @@ SysLogger_Start(void)
/*
* The initial logfile is created right in the postmaster, to verify that
* the Log_directory is writable. We save the reference time so that
* the syslogger child process can recompute this file name.
* the Log_directory is writable. We save the reference time so that the
* syslogger child process can recompute this file name.
*
* It might look a bit strange to re-do this during a syslogger restart,
* but we must do so since the postmaster closed syslogFile after the

View File

@ -79,8 +79,8 @@ pg_regprefix(regex_t *re,
/*
* Since a correct NFA should never contain any exit-free loops, it should
* not be possible for our traversal to return to a previously visited
* NFA state. Hence we need at most nstates chrs in the output string.
* not be possible for our traversal to return to a previously visited NFA
* state. Hence we need at most nstates chrs in the output string.
*/
*string = (chr *) MALLOC(cnfa->nstates * sizeof(chr));
if (*string == NULL)
@ -122,8 +122,8 @@ findprefix(struct cnfa * cnfa,
/*
* The "pre" state must have only BOS/BOL outarcs, else pattern isn't
* anchored left. If we have both BOS and BOL, they must go to the
* same next state.
* anchored left. If we have both BOS and BOL, they must go to the same
* next state.
*/
st = cnfa->pre;
nextst = -1;

View File

@ -249,8 +249,8 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
* I'd rather not worry about timelines here, so scan pg_xlog and
* include all WAL files in the range between 'startptr' and 'endptr',
* regardless of the timeline the file is stamped with. If there are
* some spurious WAL files belonging to timelines that don't belong
* in this server's history, they will be included too. Normally there
* some spurious WAL files belonging to timelines that don't belong in
* this server's history, they will be included too. Normally there
* shouldn't be such files, but if there are, there's little harm in
* including them.
*/
@ -290,9 +290,9 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
CheckXLogRemoved(startsegno, ThisTimeLineID);
/*
* Put the WAL filenames into an array, and sort. We send the files
* in order from oldest to newest, to reduce the chance that a file
* is recycled before we get a chance to send it over.
* Put the WAL filenames into an array, and sort. We send the files in
* order from oldest to newest, to reduce the chance that a file is
* recycled before we get a chance to send it over.
*/
nWalFiles = list_length(walFileList);
walFiles = palloc(nWalFiles * sizeof(char *));
@ -311,6 +311,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
if (segno != startsegno)
{
char startfname[MAXFNAMELEN];
XLogFileName(startfname, ThisTimeLineID, startsegno);
ereport(ERROR,
(errmsg("could not find WAL file \"%s\"", startfname)));
@ -324,6 +325,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
if (!(nextsegno == segno || currsegno == segno))
{
char nextfname[MAXFNAMELEN];
XLogFileName(nextfname, ThisTimeLineID, nextsegno);
ereport(ERROR,
(errmsg("could not find WAL file \"%s\"", nextfname)));
@ -332,6 +334,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
if (segno != endsegno)
{
char endfname[MAXFNAMELEN];
XLogFileName(endfname, ThisTimeLineID, endsegno);
ereport(ERROR,
(errmsg("could not find WAL file \"%s\"", endfname)));
@ -415,6 +418,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
foreach(lc, historyFileList)
{
char *fname = lfirst(lc);
snprintf(pathbuf, MAXPGPATH, XLOGDIR "/%s", fname);
if (lstat(pathbuf, &statbuf) != 0)
@ -657,6 +661,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
pq_sendstring(&buf, "tli");
pq_sendint(&buf, 0, 4); /* table oid */
pq_sendint(&buf, 0, 2); /* attnum */
/*
* int8 may seem like a surprising data type for this, but in thory int4
* would not be wide enough for this, as TimeLineID is unsigned.
@ -747,7 +752,8 @@ sendTablespace(char *path, bool sizeonly)
TABLESPACE_VERSION_DIRECTORY);
/*
* Store a directory entry in the tar file so we get the permissions right.
* Store a directory entry in the tar file so we get the permissions
* right.
*/
if (lstat(pathbuf, &statbuf) != 0)
{

View File

@ -214,7 +214,8 @@ libpqrcv_endstreaming(TimeLineID *next_tli)
/*
* After COPY is finished, we should receive a result set indicating the
* next timeline's ID, or just CommandComplete if the server was shut down.
* next timeline's ID, or just CommandComplete if the server was shut
* down.
*
* If we had not yet received CopyDone from the backend, PGRES_COPY_IN
* would also be possible. However, at the moment this function is only

View File

@ -332,12 +332,13 @@ WalReceiverMain(void)
/*
* Get any missing history files. We do this always, even when we're
* not interested in that timeline, so that if we're promoted to become
* the master later on, we don't select the same timeline that was
* already used in the current master. This isn't bullet-proof - you'll
* need some external software to manage your cluster if you need to
* ensure that a unique timeline id is chosen in every case, but let's
* avoid the confusion of timeline id collisions where we can.
* not interested in that timeline, so that if we're promoted to
* become the master later on, we don't select the same timeline that
* was already used in the current master. This isn't bullet-proof -
* you'll need some external software to manage your cluster if you
* need to ensure that a unique timeline id is chosen in every case,
* but let's avoid the confusion of timeline id collisions where we
* can.
*/
WalRcvFetchTimeLineHistoryFiles(startpointTLI, primaryTLI);
@ -387,7 +388,8 @@ WalReceiverMain(void)
/*
* Emergency bailout if postmaster has died. This is to avoid
* the necessity for manual cleanup of all postmaster children.
* the necessity for manual cleanup of all postmaster
* children.
*/
if (!PostmasterIsAlive())
exit(1);
@ -422,7 +424,10 @@ WalReceiverMain(void)
{
if (len > 0)
{
/* Something was received from master, so reset timeout */
/*
* Something was received from master, so reset
* timeout
*/
last_recv_timestamp = GetCurrentTimestamp();
ping_sent = false;
XLogWalRcvProcessMsg(buf[0], &buf[1], len - 1);
@ -457,10 +462,11 @@ WalReceiverMain(void)
/*
* We didn't receive anything new. If we haven't heard
* anything from the server for more than
* wal_receiver_timeout / 2, ping the server. Also, if it's
* been longer than wal_receiver_status_interval since the
* last update we sent, send a status update to the master
* anyway, to report any progress in applying WAL.
* wal_receiver_timeout / 2, ping the server. Also, if
* it's been longer than wal_receiver_status_interval
* since the last update we sent, send a status update to
* the master anyway, to report any progress in applying
* WAL.
*/
bool requestReply = false;
@ -482,8 +488,8 @@ WalReceiverMain(void)
(errmsg("terminating walreceiver due to timeout")));
/*
* We didn't receive anything new, for half of receiver
* replication timeout. Ping the server.
* We didn't receive anything new, for half of
* receiver replication timeout. Ping the server.
*/
if (!ping_sent)
{
@ -511,9 +517,9 @@ WalReceiverMain(void)
DisableWalRcvImmediateExit();
/*
* If the server had switched to a new timeline that we didn't know
* about when we began streaming, fetch its timeline history file
* now.
* If the server had switched to a new timeline that we didn't
* know about when we began streaming, fetch its timeline history
* file now.
*/
WalRcvFetchTimeLineHistoryFiles(startpointTLI, primaryTLI);
}
@ -614,8 +620,8 @@ WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI)
if (walrcv->walRcvState == WALRCV_STOPPING)
{
/*
* We should've received SIGTERM if the startup process wants
* us to die, but might as well check it here too.
* We should've received SIGTERM if the startup process wants us
* to die, but might as well check it here too.
*/
SpinLockRelease(&walrcv->mutex);
exit(1);
@ -664,8 +670,9 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last)
DisableWalRcvImmediateExit();
/*
* Check that the filename on the master matches what we calculated
* ourselves. This is just a sanity check, it should always match.
* Check that the filename on the master matches what we
* calculated ourselves. This is just a sanity check, it should
* always match.
*/
TLHistoryFileName(expectedfname, tli);
if (strcmp(fname, expectedfname) != 0)
@ -890,8 +897,8 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
XLogFileNameP(recvFileTLI, recvSegNo))));
/*
* Create .done file forcibly to prevent the streamed segment from
* being archived later.
* Create .done file forcibly to prevent the streamed segment
* from being archived later.
*/
XLogFileName(xlogfname, recvFileTLI, recvSegNo);
XLogArchiveForceDone(xlogfname);

View File

@ -96,6 +96,7 @@ bool am_cascading_walsender = false; /* Am I cascading WAL to
int max_wal_senders = 0; /* the maximum number of concurrent walsenders */
int wal_sender_timeout = 60 * 1000; /* maximum time to send one
* WAL data message */
/*
* State for WalSndWakeupRequest
*/
@ -138,6 +139,7 @@ static StringInfoData tmpbuf;
* Timestamp of the last receipt of the reply from the standby.
*/
static TimestampTz last_reply_timestamp;
/* Have we sent a heartbeat message asking for reply, since last reply? */
static bool ping_sent = false;
@ -322,8 +324,8 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
off_t bytesleft;
/*
* Reply with a result set with one row, and two columns. The first col
* is the name of the history file, 2nd is the contents.
* Reply with a result set with one row, and two columns. The first col is
* the name of the history file, 2nd is the contents.
*/
TLHistoryFileName(histfname, cmd->timeline);
@ -420,8 +422,8 @@ StartReplication(StartReplicationCmd *cmd)
/*
* Select the timeline. If it was given explicitly by the client, use
* that. Otherwise use the timeline of the last replayed record, which
* is kept in ThisTimeLineID.
* that. Otherwise use the timeline of the last replayed record, which is
* kept in ThisTimeLineID.
*/
if (am_cascading_walsender)
{
@ -448,8 +450,8 @@ StartReplication(StartReplicationCmd *cmd)
sendTimeLineIsHistoric = true;
/*
* Check that the timeline the client requested for exists, and the
* requested start location is on that timeline.
* Check that the timeline the client requested for exists, and
* the requested start location is on that timeline.
*/
timeLineHistory = readTimeLineHistory(ThisTimeLineID);
switchpoint = tliSwitchPoint(cmd->timeline, timeLineHistory,
@ -461,14 +463,14 @@ StartReplication(StartReplicationCmd *cmd)
* requested startpoint is on that timeline in our history.
*
* This is quite loose on purpose. We only check that we didn't
* fork off the requested timeline before the switchpoint. We don't
* check that we switched *to* it before the requested starting
* point. This is because the client can legitimately request to
* start replication from the beginning of the WAL segment that
* contains switchpoint, but on the new timeline, so that it
* doesn't end up with a partial segment. If you ask for a too old
* starting point, you'll get an error later when we fail to find
* the requested WAL segment in pg_xlog.
* fork off the requested timeline before the switchpoint. We
* don't check that we switched *to* it before the requested
* starting point. This is because the client can legitimately
* request to start replication from the beginning of the WAL
* segment that contains switchpoint, but on the new timeline, so
* that it doesn't end up with a partial segment. If you ask for a
* too old starting point, you'll get an error later when we fail
* to find the requested WAL segment in pg_xlog.
*
* XXX: we could be more strict here and only allow a startpoint
* that's older than the switchpoint, if it it's still in the same
@ -503,12 +505,13 @@ StartReplication(StartReplicationCmd *cmd)
if (!sendTimeLineIsHistoric || cmd->startpoint < sendTimeLineValidUpto)
{
/*
* When we first start replication the standby will be behind the primary.
* For some applications, for example, synchronous replication, it is
* important to have a clear state for this initial catchup mode, so we
* can trigger actions when we change streaming state later. We may stay
* in this state for a long time, which is exactly why we want to be able
* to monitor whether or not we are still here.
* When we first start replication the standby will be behind the
* primary. For some applications, for example, synchronous
* replication, it is important to have a clear state for this initial
* catchup mode, so we can trigger actions when we change streaming
* state later. We may stay in this state for a long time, which is
* exactly why we want to be able to monitor whether or not we are
* still here.
*/
WalSndSetState(WALSNDSTATE_CATCHUP);
@ -582,6 +585,7 @@ StartReplication(StartReplicationCmd *cmd)
pq_sendstring(&buf, "next_tli");
pq_sendint(&buf, 0, 4); /* table oid */
pq_sendint(&buf, 0, 2); /* attnum */
/*
* int8 may seem like a surprising data type for this, but in theory
* int4 would not be wide enough for this, as TimeLineID is unsigned.
@ -932,11 +936,11 @@ ProcessStandbyHSFeedbackMessage(void)
* cleanup conflicts on the standby server.
*
* There is a small window for a race condition here: although we just
* checked that feedbackXmin precedes nextXid, the nextXid could have gotten
* advanced between our fetching it and applying the xmin below, perhaps
* far enough to make feedbackXmin wrap around. In that case the xmin we
* set here would be "in the future" and have no effect. No point in
* worrying about this since it's too late to save the desired data
* checked that feedbackXmin precedes nextXid, the nextXid could have
* gotten advanced between our fetching it and applying the xmin below,
* perhaps far enough to make feedbackXmin wrap around. In that case the
* xmin we set here would be "in the future" and have no effect. No point
* in worrying about this since it's too late to save the desired data
* anyway. Assuming that the standby sends us an increasing sequence of
* xmins, this could only happen during the first reply cycle, else our
* own xmin would prevent nextXid from advancing so far.
@ -969,8 +973,8 @@ WalSndLoop(void)
ping_sent = false;
/*
* Loop until we reach the end of this timeline or the client requests
* to stop streaming.
* Loop until we reach the end of this timeline or the client requests to
* stop streaming.
*/
for (;;)
{
@ -1082,8 +1086,8 @@ WalSndLoop(void)
{
/*
* If half of wal_sender_timeout has lapsed without receiving
* any reply from standby, send a keep-alive message to standby
* requesting an immediate reply.
* any reply from standby, send a keep-alive message to
* standby requesting an immediate reply.
*/
timeout = TimestampTzPlusMilliseconds(last_reply_timestamp,
wal_sender_timeout / 2);
@ -1133,6 +1137,7 @@ WalSndLoop(void)
return;
send_failure:
/*
* Get here on send failure. Clean up and exit.
*
@ -1431,16 +1436,16 @@ XLogSend(bool *caughtup)
/*
* Streaming the latest timeline on a standby.
*
* Attempt to send all WAL that has already been replayed, so that
* we know it's valid. If we're receiving WAL through streaming
* Attempt to send all WAL that has already been replayed, so that we
* know it's valid. If we're receiving WAL through streaming
* replication, it's also OK to send any WAL that has been received
* but not replayed.
*
* The timeline we're recovering from can change, or we can be
* promoted. In either case, the current timeline becomes historic.
* We need to detect that so that we don't try to stream past the
* point where we switched to another timeline. We check for promotion
* or timeline switch after calculating FlushPtr, to avoid a race
* promoted. In either case, the current timeline becomes historic. We
* need to detect that so that we don't try to stream past the point
* where we switched to another timeline. We check for promotion or
* timeline switch after calculating FlushPtr, to avoid a race
* condition: if the timeline becomes historic just after we checked
* that it was still current, it's still be OK to stream it up to the
* FlushPtr that was calculated before it became historic.
@ -1509,13 +1514,14 @@ XLogSend(bool *caughtup)
* forked to the next timeline, stop streaming.
*
* Note: We might already have sent WAL > sendTimeLineValidUpto. The
* startup process will normally replay all WAL that has been received from
* the master, before promoting, but if the WAL streaming is terminated at
* a WAL page boundary, the valid portion of the timeline might end in the
* middle of a WAL record. We might've already sent the first half of that
* partial WAL record to the cascading standby, so that sentPtr >
* sendTimeLineValidUpto. That's OK; the cascading standby can't replay the
* partial WAL record either, so it can still follow our timeline switch.
* startup process will normally replay all WAL that has been received
* from the master, before promoting, but if the WAL streaming is
* terminated at a WAL page boundary, the valid portion of the timeline
* might end in the middle of a WAL record. We might've already sent the
* first half of that partial WAL record to the cascading standby, so that
* sentPtr > sendTimeLineValidUpto. That's OK; the cascading standby can't
* replay the partial WAL record either, so it can still follow our
* timeline switch.
*/
if (sendTimeLineIsHistoric && sendTimeLineValidUpto <= sentPtr)
{
@ -1651,8 +1657,8 @@ GetStandbyFlushRecPtr(void)
/*
* We can safely send what's already been replayed. Also, if walreceiver
* is streaming WAL from the same timeline, we can send anything that
* it has streamed, but hasn't been replayed yet.
* is streaming WAL from the same timeline, we can send anything that it
* has streamed, but hasn't been replayed yet.
*/
receivePtr = GetWalRcvWriteRecPtr(NULL, &receiveTLI);

View File

@ -541,9 +541,9 @@ DefineQueryRewrite(char *rulename,
DeleteSystemAttributeTuples(event_relid);
/*
* Drop the toast table if any. (This won't take care of updating
* the toast fields in the relation's own pg_class entry; we handle
* that below.)
* Drop the toast table if any. (This won't take care of updating the
* toast fields in the relation's own pg_class entry; we handle that
* below.)
*/
if (OidIsValid(toastrelid))
{

View File

@ -131,9 +131,9 @@ AcquireRewriteLocks(Query *parsetree, bool forUpdatePushedDown)
*
* If the relation is the query's result relation, then we
* need RowExclusiveLock. Otherwise, check to see if the
* relation is accessed FOR [KEY] UPDATE/SHARE or not. We can't
* just grab AccessShareLock because then the executor would
* be trying to upgrade the lock, leading to possible
* relation is accessed FOR [KEY] UPDATE/SHARE or not. We
* can't just grab AccessShareLock because then the executor
* would be trying to upgrade the lock, leading to possible
* deadlocks.
*/
if (rt_index == parsetree->resultRelation)
@ -1375,8 +1375,8 @@ ApplyRetrieveRule(Query *parsetree,
}
/*
* If FOR [KEY] UPDATE/SHARE of view, be sure we get right initial lock on the
* relations it references.
* If FOR [KEY] UPDATE/SHARE of view, be sure we get right initial lock on
* the relations it references.
*/
rc = get_parse_rowmark(parsetree, rt_index);
forUpdatePushedDown |= (rc != NULL);
@ -1423,9 +1423,9 @@ ApplyRetrieveRule(Query *parsetree,
rte->modifiedCols = NULL;
/*
* If FOR [KEY] UPDATE/SHARE of view, mark all the contained tables as implicit
* FOR [KEY] UPDATE/SHARE, the same as the parser would have done if the view's
* subquery had been written out explicitly.
* If FOR [KEY] UPDATE/SHARE of view, mark all the contained tables as
* implicit FOR [KEY] UPDATE/SHARE, the same as the parser would have done
* if the view's subquery had been written out explicitly.
*
* Note: we don't consider forUpdatePushedDown here; such marks will be
* made by recursing from the upper level in markQueryForLocking.
@ -2089,9 +2089,9 @@ relation_is_updatable(Oid reloid, int req_events)
/*
* If the relation doesn't exist, say "false" rather than throwing an
* error. This is helpful since scanning an information_schema view
* under MVCC rules can result in referencing rels that were just
* deleted according to a SnapshotNow probe.
* error. This is helpful since scanning an information_schema view under
* MVCC rules can result in referencing rels that were just deleted
* according to a SnapshotNow probe.
*/
if (rel == NULL)
return false;
@ -2680,10 +2680,10 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
parsetree = rewriteTargetView(parsetree, rt_entry_relation);
/*
* At this point product_queries contains any DO ALSO rule actions.
* Add the rewritten query before or after those. This must match
* the handling the original query would have gotten below, if
* we allowed it to be included again.
* At this point product_queries contains any DO ALSO rule
* actions. Add the rewritten query before or after those. This
* must match the handling the original query would have gotten
* below, if we allowed it to be included again.
*/
if (parsetree->commandType == CMD_INSERT)
product_queries = lcons(parsetree, product_queries);

View File

@ -1406,6 +1406,7 @@ ReplaceVarsFromTargetList_callback(Var *var,
return (Node *) var;
case REPLACEVARS_SUBSTITUTE_NULL:
/*
* If Var is of domain type, we should add a CoerceToDomain
* node, in case there is a NOT NULL domain constraint.

View File

@ -1220,7 +1220,8 @@ BufferSync(int flags)
/*
* Unless this is a shutdown checkpoint, we write only permanent, dirty
* buffers. But at shutdown or end of recovery, we write all dirty buffers.
* buffers. But at shutdown or end of recovery, we write all dirty
* buffers.
*/
if (!((flags & CHECKPOINT_IS_SHUTDOWN) || (flags & CHECKPOINT_END_OF_RECOVERY)))
mask |= BM_PERMANENT;
@ -1964,14 +1965,14 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln)
* However, this rule does not apply to unlogged relations, which will be
* lost after a crash anyway. Most unlogged relation pages do not bear
* LSNs since we never emit WAL records for them, and therefore flushing
* up through the buffer LSN would be useless, but harmless. However, GiST
* indexes use LSNs internally to track page-splits, and therefore unlogged
* GiST pages bear "fake" LSNs generated by GetFakeLSNForUnloggedRel. It
* is unlikely but possible that the fake LSN counter could advance past
* the WAL insertion point; and if it did happen, attempting to flush WAL
* through that location would fail, with disastrous system-wide
* consequences. To make sure that can't happen, skip the flush if the
* buffer isn't permanent.
* up through the buffer LSN would be useless, but harmless. However,
* GiST indexes use LSNs internally to track page-splits, and therefore
* unlogged GiST pages bear "fake" LSNs generated by
* GetFakeLSNForUnloggedRel. It is unlikely but possible that the fake
* LSN counter could advance past the WAL insertion point; and if it did
* happen, attempting to flush WAL through that location would fail, with
* disastrous system-wide consequences. To make sure that can't happen,
* skip the flush if the buffer isn't permanent.
*/
if (buf->flags & BM_PERMANENT)
XLogFlush(recptr);
@ -2204,8 +2205,8 @@ DropRelFileNodesAllBuffers(RelFileNodeBackend *rnodes, int nnodes)
}
/*
* If there are no non-local relations, then we're done. Release the memory
* and return.
* If there are no non-local relations, then we're done. Release the
* memory and return.
*/
if (n == 0)
{
@ -2215,8 +2216,8 @@ DropRelFileNodesAllBuffers(RelFileNodeBackend *rnodes, int nnodes)
/*
* For low number of relations to drop just use a simple walk through, to
* save the bsearch overhead. The threshold to use is rather a guess than a
* exactly determined value, as it depends on many factors (CPU and RAM
* save the bsearch overhead. The threshold to use is rather a guess than
* a exactly determined value, as it depends on many factors (CPU and RAM
* speeds, amount of shared buffers etc.).
*/
use_bsearch = n > DROP_RELS_BSEARCH_THRESHOLD;
@ -2605,13 +2606,13 @@ MarkBufferDirtyHint(Buffer buffer)
/*
* This routine might get called many times on the same page, if we are
* making the first scan after commit of an xact that added/deleted many
* tuples. So, be as quick as we can if the buffer is already dirty. We do
* this by not acquiring spinlock if it looks like the status bits are
* tuples. So, be as quick as we can if the buffer is already dirty. We
* do this by not acquiring spinlock if it looks like the status bits are
* already set. Since we make this test unlocked, there's a chance we
* might fail to notice that the flags have just been cleared, and failed
* to reset them, due to memory-ordering issues. But since this function
* is only intended to be used in cases where failing to write out the data
* would be harmless anyway, it doesn't really matter.
* is only intended to be used in cases where failing to write out the
* data would be harmless anyway, it doesn't really matter.
*/
if ((bufHdr->flags & (BM_DIRTY | BM_JUST_DIRTIED)) !=
(BM_DIRTY | BM_JUST_DIRTIED))
@ -2622,21 +2623,20 @@ MarkBufferDirtyHint(Buffer buffer)
/*
* If checksums are enabled, and the buffer is permanent, then a full
* page image may be required even for some hint bit updates to protect
* against torn pages. This full page image is only necessary if the
* hint bit update is the first change to the page since the last
* checkpoint.
* page image may be required even for some hint bit updates to
* protect against torn pages. This full page image is only necessary
* if the hint bit update is the first change to the page since the
* last checkpoint.
*
* We don't check full_page_writes here because that logic is
* included when we call XLogInsert() since the value changes
* dynamically.
* We don't check full_page_writes here because that logic is included
* when we call XLogInsert() since the value changes dynamically.
*/
if (DataChecksumsEnabled() && (bufHdr->flags & BM_PERMANENT))
{
/*
* If we're in recovery we cannot dirty a page because of a hint.
* We can set the hint, just not dirty the page as a result so
* the hint is lost when we evict the page or shutdown.
* We can set the hint, just not dirty the page as a result so the
* hint is lost when we evict the page or shutdown.
*
* See src/backend/storage/page/README for longer discussion.
*/
@ -2646,21 +2646,21 @@ MarkBufferDirtyHint(Buffer buffer)
/*
* If the block is already dirty because we either made a change
* or set a hint already, then we don't need to write a full page
* image. Note that aggressive cleaning of blocks
* dirtied by hint bit setting would increase the call rate.
* Bulk setting of hint bits would reduce the call rate...
* image. Note that aggressive cleaning of blocks dirtied by hint
* bit setting would increase the call rate. Bulk setting of hint
* bits would reduce the call rate...
*
* We must issue the WAL record before we mark the buffer dirty.
* Otherwise we might write the page before we write the WAL.
* That causes a race condition, since a checkpoint might occur
* between writing the WAL record and marking the buffer dirty.
* We solve that with a kluge, but one that is already in use
* during transaction commit to prevent race conditions.
* Basically, we simply prevent the checkpoint WAL record from
* being written until we have marked the buffer dirty. We don't
* start the checkpoint flush until we have marked dirty, so our
* checkpoint must flush the change to disk successfully or the
* checkpoint never gets written, so crash recovery will fix.
* Otherwise we might write the page before we write the WAL. That
* causes a race condition, since a checkpoint might occur between
* writing the WAL record and marking the buffer dirty. We solve
* that with a kluge, but one that is already in use during
* transaction commit to prevent race conditions. Basically, we
* simply prevent the checkpoint WAL record from being written
* until we have marked the buffer dirty. We don't start the
* checkpoint flush until we have marked dirty, so our checkpoint
* must flush the change to disk successfully or the checkpoint
* never gets written, so crash recovery will fix.
*
* It's possible we may enter here without an xid, so it is
* essential that CreateCheckpoint waits for virtual transactions
@ -2677,13 +2677,13 @@ MarkBufferDirtyHint(Buffer buffer)
dirtied = true; /* Means "will be dirtied by this action" */
/*
* Set the page LSN if we wrote a backup block. We aren't
* supposed to set this when only holding a share lock but
* as long as we serialise it somehow we're OK. We choose to
* set LSN while holding the buffer header lock, which causes
* any reader of an LSN who holds only a share lock to also
* obtain a buffer header lock before using PageGetLSN(),
* which is enforced in BufferGetLSNAtomic().
* Set the page LSN if we wrote a backup block. We aren't supposed
* to set this when only holding a share lock but as long as we
* serialise it somehow we're OK. We choose to set LSN while
* holding the buffer header lock, which causes any reader of an
* LSN who holds only a share lock to also obtain a buffer header
* lock before using PageGetLSN(), which is enforced in
* BufferGetLSNAtomic().
*
* If checksums are enabled, you might think we should reset the
* checksum here. That will happen when the page is written

View File

@ -1429,11 +1429,11 @@ GetSnapshotData(Snapshot snapshot)
* depending upon when the snapshot was taken, or change normal
* snapshot processing so it matches.
*
* Note: It is possible for recovery to end before we finish taking the
* snapshot, and for newly assigned transaction ids to be added to the
* ProcArray. xmax cannot change while we hold ProcArrayLock, so those
* newly added transaction ids would be filtered away, so we need not
* be concerned about them.
* Note: It is possible for recovery to end before we finish taking
* the snapshot, and for newly assigned transaction ids to be added to
* the ProcArray. xmax cannot change while we hold ProcArrayLock, so
* those newly added transaction ids would be filtered away, so we
* need not be concerned about them.
*/
subcount = KnownAssignedXidsGetAndSetXmin(snapshot->subxip, &xmin,
xmax);
@ -1688,8 +1688,8 @@ GetRunningTransactionData(void)
/*
* Top-level XID of a transaction is always less than any of
* its subxids, so we don't need to check if any of the subxids
* are smaller than oldestRunningXid
* its subxids, so we don't need to check if any of the
* subxids are smaller than oldestRunningXid
*/
}
}

View File

@ -443,10 +443,10 @@ ResolveRecoveryConflictWithBufferPin(void)
ProcWaitForSignal();
/*
* Clear any timeout requests established above. We assume here that
* the Startup process doesn't have any other timeouts than what this
* function uses. If that stops being true, we could cancel the
* timeouts individually, but that'd be slower.
* Clear any timeout requests established above. We assume here that the
* Startup process doesn't have any other timeouts than what this function
* uses. If that stops being true, we could cancel the timeouts
* individually, but that'd be slower.
*/
disable_all_timeouts(false);
}

View File

@ -2333,8 +2333,8 @@ LockReassignOwner(LOCALLOCK *locallock, ResourceOwner parent)
int ip = -1;
/*
* Scan to see if there are any locks belonging to current owner or
* its parent
* Scan to see if there are any locks belonging to current owner or its
* parent
*/
lockOwners = locallock->lockOwners;
for (i = locallock->numLockOwners - 1; i >= 0; i--)
@ -2690,9 +2690,9 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
LWLockAcquire(proc->backendLock, LW_SHARED);
/*
* If the target backend isn't referencing the same database as the
* lock, then we needn't examine the individual relation IDs at
* all; none of them can be relevant.
* If the target backend isn't referencing the same database as
* the lock, then we needn't examine the individual relation IDs
* at all; none of them can be relevant.
*
* See FastPathTransferLocks() for discussion of why we do this
* test after acquiring the lock.
@ -3165,8 +3165,8 @@ PostPrepare_Locks(TransactionId xid)
* our procLink chain and put it into the new proc's chain, too.
*
* Note: the updated proclock hash key will still belong to the
* same hash partition, cf proclock_hash(). So the partition
* lock we already hold is sufficient for this.
* same hash partition, cf proclock_hash(). So the partition lock
* we already hold is sufficient for this.
*/
SHMQueueDelete(&proclock->procLink);
@ -3177,9 +3177,9 @@ PostPrepare_Locks(TransactionId xid)
proclocktag.myProc = newproc;
/*
* Update the proclock. We should not find any existing entry
* for the same hash key, since there can be only one entry for
* any given lock with my own proc.
* Update the proclock. We should not find any existing entry for
* the same hash key, since there can be only one entry for any
* given lock with my own proc.
*/
if (!hash_update_hash_key(LockMethodProcLockHash,
(void *) proclock,

View File

@ -1575,8 +1575,8 @@ GetSerializableTransactionSnapshot(Snapshot snapshot)
/*
* Can't use serializable mode while recovery is still active, as it is,
* for example, on a hot standby. We could get here despite the check
* in check_XactIsoLevel() if default_transaction_isolation is set to
* for example, on a hot standby. We could get here despite the check in
* check_XactIsoLevel() if default_transaction_isolation is set to
* serializable, so phrase the hint accordingly.
*/
if (RecoveryInProgress())

View File

@ -186,8 +186,8 @@ InitProcGlobal(void)
* five separate consumers: (1) normal backends, (2) autovacuum workers
* and the autovacuum launcher, (3) background workers, (4) auxiliary
* processes, and (5) prepared transactions. Each PGPROC structure is
* dedicated to exactly one of these purposes, and they do not move between
* groups.
* dedicated to exactly one of these purposes, and they do not move
* between groups.
*/
procs = (PGPROC *) ShmemAlloc(TotalProcs * sizeof(PGPROC));
ProcGlobal->allProcs = procs;

View File

@ -101,10 +101,10 @@ PageIsVerified(Page page, BlockNumber blkno)
}
/*
* The following checks don't prove the header is correct,
* only that it looks sane enough to allow into the buffer pool.
* Later usage of the block can still reveal problems,
* which is why we offer the checksum option.
* The following checks don't prove the header is correct, only that
* it looks sane enough to allow into the buffer pool. Later usage of
* the block can still reveal problems, which is why we offer the
* checksum option.
*/
if ((p->pd_flags & ~PD_VALID_FLAG_BITS) == 0 &&
p->pd_lower <= p->pd_upper &&
@ -905,10 +905,10 @@ PageSetChecksumCopy(Page page, BlockNumber blkno)
/*
* We make a copy iff we need to calculate a checksum because other
* backends may set hint bits on this page while we write, which
* would mean the checksum differs from the page contents. It doesn't
* matter if we include or exclude hints during the copy, as long
* as we write a valid page and associated checksum.
* backends may set hint bits on this page while we write, which would
* mean the checksum differs from the page contents. It doesn't matter if
* we include or exclude hints during the copy, as long as we write a
* valid page and associated checksum.
*/
memcpy((char *) pageCopy, (char *) page, BLCKSZ);
PageSetChecksumInplace(pageCopy, blkno);
@ -931,6 +931,7 @@ PageSetChecksumInplace(Page page, BlockNumber blkno)
if (DataChecksumsEnabled())
{
PageHeader p = (PageHeader) page;
p->pd_checksum = PageCalcChecksum16(page, blkno);
}
@ -958,9 +959,8 @@ PageCalcChecksum16(Page page, BlockNumber blkno)
/*
* Save pd_checksum and set it to zero, so that the checksum calculation
* isn't affected by the checksum stored on the page. We do this to
* allow optimization of the checksum calculation on the whole block
* in one go.
* isn't affected by the checksum stored on the page. We do this to allow
* optimization of the checksum calculation on the whole block in one go.
*/
save_checksum = phdr->pd_checksum;
phdr->pd_checksum = 0;

View File

@ -134,7 +134,8 @@ checksum_block(char *data, uint32 size)
uint32 sums[N_SUMS];
uint32 (*dataArr)[N_SUMS] = (uint32 (*)[N_SUMS]) data;
uint32 result = 0;
int i, j;
int i,
j;
/* ensure that the size is compatible with the algorithm */
Assert((size % (sizeof(uint32) * N_SUMS)) == 0);

View File

@ -443,8 +443,8 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
return;
/*
* create an array which contains all relations to be dropped, and
* close each relation's forks at the smgr level while at it
* create an array which contains all relations to be dropped, and close
* each relation's forks at the smgr level while at it
*/
rnodes = palloc(sizeof(RelFileNodeBackend) * nrels);
for (i = 0; i < nrels; i++)
@ -466,8 +466,8 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
DropRelFileNodesAllBuffers(rnodes, nrels);
/*
* It'd be nice to tell the stats collector to forget them immediately, too.
* But we can't because we don't know the OIDs.
* It'd be nice to tell the stats collector to forget them immediately,
* too. But we can't because we don't know the OIDs.
*/
/*
@ -475,8 +475,8 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
* dangling smgr references they may have for these rels. We should do
* this before starting the actual unlinking, in case we fail partway
* through that step. Note that the sinval messages will eventually come
* back to this backend, too, and thereby provide a backstop that we closed
* our own smgr rel.
* back to this backend, too, and thereby provide a backstop that we
* closed our own smgr rel.
*/
for (i = 0; i < nrels; i++)
CacheInvalidateSmgr(rnodes[i]);
@ -492,6 +492,7 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
for (i = 0; i < nrels; i++)
{
int which = rels[i]->smgr_which;
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
(*(smgrsw[which].smgr_unlink)) (rnodes[i], forknum, isRedo);
}

View File

@ -388,8 +388,8 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
/*
* If element type is pass-by-reference, we must copy it into
* palloc'd space, so that we can release the array below.
* (We do this so that the space needed for element values is
* palloc'd space, so that we can release the array below. (We
* do this so that the space needed for element values is
* limited by the size of the hashtable; if we kept all the
* array values around, it could be much more.)
*/

Some files were not shown because too many files have changed in this diff Show More