Initial pgindent and pgperltidy run for v14.

Also "make reformat-dat-files".

The only change worthy of note is that pgindent messed up the formatting
of launcher.c's struct LogicalRepWorkerId, which led me to notice that
that struct wasn't used at all anymore, so I just took it out.
This commit is contained in:
Tom Lane 2021-05-12 13:14:10 -04:00
parent e6ccd1ce16
commit def5b065ff
230 changed files with 2408 additions and 2125 deletions

View File

@ -51,8 +51,7 @@ detects_heap_corruption(
# #
fresh_test_table('test'); fresh_test_table('test');
$node->safe_psql('postgres', q(VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test)); $node->safe_psql('postgres', q(VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test));
detects_no_corruption( detects_no_corruption("verify_heapam('test')",
"verify_heapam('test')",
"all-frozen not corrupted table"); "all-frozen not corrupted table");
corrupt_first_page('test'); corrupt_first_page('test');
detects_heap_corruption("verify_heapam('test')", detects_heap_corruption("verify_heapam('test')",

View File

@ -839,13 +839,16 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false; return false;
case XID_COMMITTED: case XID_COMMITTED:
/* /*
* The tuple is dead, because the xvac transaction moved * The tuple is dead, because the xvac transaction moved
* it off and committed. It's checkable, but also prunable. * it off and committed. It's checkable, but also
* prunable.
*/ */
return true; return true;
case XID_ABORTED: case XID_ABORTED:
/* /*
* The original xmin must have committed, because the xvac * The original xmin must have committed, because the xvac
* transaction tried to move it later. Since xvac is * transaction tried to move it later. Since xvac is
@ -905,6 +908,7 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false; return false;
case XID_COMMITTED: case XID_COMMITTED:
/* /*
* The original xmin must have committed, because the xvac * The original xmin must have committed, because the xvac
* transaction moved it later. Whether it's still alive * transaction moved it later. Whether it's still alive
@ -913,9 +917,11 @@ check_tuple_visibility(HeapCheckContext *ctx)
break; break;
case XID_ABORTED: case XID_ABORTED:
/* /*
* The tuple is dead, because the xvac transaction moved * The tuple is dead, because the xvac transaction moved
* it off and committed. It's checkable, but also prunable. * it off and committed. It's checkable, but also
* prunable.
*/ */
return true; return true;
} }
@ -924,12 +930,12 @@ check_tuple_visibility(HeapCheckContext *ctx)
{ {
/* /*
* Inserting transaction is not in progress, and not committed, so * Inserting transaction is not in progress, and not committed, so
* it might have changed the TupleDesc in ways we don't know about. * it might have changed the TupleDesc in ways we don't know
* Thus, don't try to check the tuple structure. * about. Thus, don't try to check the tuple structure.
* *
* If xmin_status happens to be XID_IS_CURRENT_XID, then in theory * If xmin_status happens to be XID_IS_CURRENT_XID, then in theory
* any such DDL changes ought to be visible to us, so perhaps * any such DDL changes ought to be visible to us, so perhaps we
* we could check anyway in that case. But, for now, let's be * could check anyway in that case. But, for now, let's be
* conservative and treat this like any other uncommitted insert. * conservative and treat this like any other uncommitted insert.
*/ */
return false; return false;
@ -945,18 +951,19 @@ check_tuple_visibility(HeapCheckContext *ctx)
{ {
/* /*
* xmax is a multixact, so sanity-check the MXID. Note that we do this * xmax is a multixact, so sanity-check the MXID. Note that we do this
* prior to checking for HEAP_XMAX_INVALID or HEAP_XMAX_IS_LOCKED_ONLY. * prior to checking for HEAP_XMAX_INVALID or
* This might therefore complain about things that wouldn't actually * HEAP_XMAX_IS_LOCKED_ONLY. This might therefore complain about
* be a problem during a normal scan, but eventually we're going to * things that wouldn't actually be a problem during a normal scan,
* have to freeze, and that process will ignore hint bits. * but eventually we're going to have to freeze, and that process will
* ignore hint bits.
* *
* Even if the MXID is out of range, we still know that the original * Even if the MXID is out of range, we still know that the original
* insert committed, so we can check the tuple itself. However, we * insert committed, so we can check the tuple itself. However, we
* can't rule out the possibility that this tuple is dead, so don't * can't rule out the possibility that this tuple is dead, so don't
* clear ctx->tuple_could_be_pruned. Possibly we should go ahead and * clear ctx->tuple_could_be_pruned. Possibly we should go ahead and
* clear that flag anyway if HEAP_XMAX_INVALID is set or if * clear that flag anyway if HEAP_XMAX_INVALID is set or if
* HEAP_XMAX_IS_LOCKED_ONLY is true, but for now we err on the side * HEAP_XMAX_IS_LOCKED_ONLY is true, but for now we err on the side of
* of avoiding possibly-bogus complaints about missing TOAST entries. * avoiding possibly-bogus complaints about missing TOAST entries.
*/ */
xmax = HeapTupleHeaderGetRawXmax(tuphdr); xmax = HeapTupleHeaderGetRawXmax(tuphdr);
switch (check_mxid_valid_in_rel(xmax, ctx)) switch (check_mxid_valid_in_rel(xmax, ctx))
@ -1066,9 +1073,10 @@ check_tuple_visibility(HeapCheckContext *ctx)
* away depends on how old the deleting transaction is. * away depends on how old the deleting transaction is.
*/ */
ctx->tuple_could_be_pruned = TransactionIdPrecedes(xmax, ctx->tuple_could_be_pruned = TransactionIdPrecedes(xmax,
ctx->safe_xmin); ctx->safe_xmin);
break; break;
case XID_ABORTED: case XID_ABORTED:
/* /*
* The delete aborted or crashed. The tuple is still live. * The delete aborted or crashed. The tuple is still live.
*/ */
@ -1127,15 +1135,17 @@ check_tuple_visibility(HeapCheckContext *ctx)
break; break;
case XID_COMMITTED: case XID_COMMITTED:
/* /*
* The delete committed. Whether the toast can be vacuumed away * The delete committed. Whether the toast can be vacuumed away
* depends on how old the deleting transaction is. * depends on how old the deleting transaction is.
*/ */
ctx->tuple_could_be_pruned = TransactionIdPrecedes(xmax, ctx->tuple_could_be_pruned = TransactionIdPrecedes(xmax,
ctx->safe_xmin); ctx->safe_xmin);
break; break;
case XID_ABORTED: case XID_ABORTED:
/* /*
* The delete aborted or crashed. The tuple is still live. * The delete aborted or crashed. The tuple is still live.
*/ */
@ -1248,6 +1258,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx,
ta->toast_pointer.va_valueid, ta->toast_pointer.va_valueid,
chunk_seq, chunksize, expected_size)); chunk_seq, chunksize, expected_size));
} }
/* /*
* Check the current attribute as tracked in ctx, recording any corruption * Check the current attribute as tracked in ctx, recording any corruption
* found in ctx->tupstore. * found in ctx->tupstore.

View File

@ -536,7 +536,7 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
ereport(DEBUG1, ereport(DEBUG1,
(errcode(ERRCODE_NO_DATA), (errcode(ERRCODE_NO_DATA),
errmsg_internal("harmless fast root mismatch in index \"%s\"", errmsg_internal("harmless fast root mismatch in index \"%s\"",
RelationGetRelationName(rel)), RelationGetRelationName(rel)),
errdetail_internal("Fast root block %u (level %u) differs from true root block %u (level %u).", errdetail_internal("Fast root block %u (level %u) differs from true root block %u (level %u).",
metad->btm_fastroot, metad->btm_fastlevel, metad->btm_fastroot, metad->btm_fastlevel,
metad->btm_root, metad->btm_level))); metad->btm_root, metad->btm_level)));
@ -722,7 +722,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
ereport(DEBUG1, ereport(DEBUG1,
(errcode(ERRCODE_NO_DATA), (errcode(ERRCODE_NO_DATA),
errmsg_internal("block %u of index \"%s\" concurrently deleted", errmsg_internal("block %u of index \"%s\" concurrently deleted",
current, RelationGetRelationName(state->rel)))); current, RelationGetRelationName(state->rel))));
goto nextpage; goto nextpage;
} }
else if (nextleveldown.leftmost == InvalidBlockNumber) else if (nextleveldown.leftmost == InvalidBlockNumber)
@ -918,7 +918,7 @@ bt_recheck_sibling_links(BtreeCheckState *state,
Buffer newtargetbuf; Buffer newtargetbuf;
Page page; Page page;
BTPageOpaque opaque; BTPageOpaque opaque;
BlockNumber newtargetblock; BlockNumber newtargetblock;
/* Couple locks in the usual order for nbtree: Left to right */ /* Couple locks in the usual order for nbtree: Left to right */
lbuf = ReadBufferExtended(state->rel, MAIN_FORKNUM, leftcurrent, lbuf = ReadBufferExtended(state->rel, MAIN_FORKNUM, leftcurrent,
@ -980,7 +980,7 @@ bt_recheck_sibling_links(BtreeCheckState *state,
ereport(DEBUG1, ereport(DEBUG1,
(errcode(ERRCODE_INTERNAL_ERROR), (errcode(ERRCODE_INTERNAL_ERROR),
errmsg_internal("harmless concurrent page split detected in index \"%s\"", errmsg_internal("harmless concurrent page split detected in index \"%s\"",
RelationGetRelationName(state->rel)), RelationGetRelationName(state->rel)),
errdetail_internal("Block=%u new right sibling=%u original right sibling=%u.", errdetail_internal("Block=%u new right sibling=%u original right sibling=%u.",
leftcurrent, newtargetblock, leftcurrent, newtargetblock,
state->targetblock))); state->targetblock)));
@ -1599,7 +1599,7 @@ bt_right_page_check_scankey(BtreeCheckState *state)
ereport(DEBUG2, ereport(DEBUG2,
(errcode(ERRCODE_NO_DATA), (errcode(ERRCODE_NO_DATA),
errmsg_internal("level %u sibling page in block %u of index \"%s\" was found deleted or half dead", errmsg_internal("level %u sibling page in block %u of index \"%s\" was found deleted or half dead",
opaque->btpo_level, targetnext, RelationGetRelationName(state->rel)), opaque->btpo_level, targetnext, RelationGetRelationName(state->rel)),
errdetail_internal("Deleted page found when building scankey from right sibling."))); errdetail_internal("Deleted page found when building scankey from right sibling.")));
targetnext = opaque->btpo_next; targetnext = opaque->btpo_next;
@ -1729,8 +1729,8 @@ bt_right_page_check_scankey(BtreeCheckState *state)
ereport(DEBUG2, ereport(DEBUG2,
(errcode(ERRCODE_NO_DATA), (errcode(ERRCODE_NO_DATA),
errmsg_internal("%s block %u of index \"%s\" has no first data item", errmsg_internal("%s block %u of index \"%s\" has no first data item",
P_ISLEAF(opaque) ? "leaf" : "internal", targetnext, P_ISLEAF(opaque) ? "leaf" : "internal", targetnext,
RelationGetRelationName(state->rel)))); RelationGetRelationName(state->rel))));
return NULL; return NULL;
} }
@ -2278,7 +2278,7 @@ bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit,
ereport(DEBUG1, ereport(DEBUG1,
(errcode(ERRCODE_NO_DATA), (errcode(ERRCODE_NO_DATA),
errmsg_internal("harmless interrupted page split detected in index \"%s\"", errmsg_internal("harmless interrupted page split detected in index \"%s\"",
RelationGetRelationName(state->rel)), RelationGetRelationName(state->rel)),
errdetail_internal("Block=%u level=%u left sibling=%u page lsn=%X/%X.", errdetail_internal("Block=%u level=%u left sibling=%u page lsn=%X/%X.",
blkno, opaque->btpo_level, blkno, opaque->btpo_level,
opaque->btpo_prev, opaque->btpo_prev,

View File

@ -25,11 +25,11 @@
*/ */
typedef struct typedef struct
{ {
int current_index; int current_index;
int head_offset; int head_offset;
TimestampTz head_timestamp; TimestampTz head_timestamp;
int count_used; int count_used;
TransactionId xid_by_minute[FLEXIBLE_ARRAY_MEMBER]; TransactionId xid_by_minute[FLEXIBLE_ARRAY_MEMBER];
} OldSnapshotTimeMapping; } OldSnapshotTimeMapping;
#define NUM_TIME_MAPPING_COLUMNS 3 #define NUM_TIME_MAPPING_COLUMNS 3
@ -53,7 +53,7 @@ pg_old_snapshot_time_mapping(PG_FUNCTION_ARGS)
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
{ {
MemoryContext oldcontext; MemoryContext oldcontext;
funcctx = SRF_FIRSTCALL_INIT(); funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
@ -127,24 +127,25 @@ MakeOldSnapshotTimeMappingTupleDesc(void)
static HeapTuple static HeapTuple
MakeOldSnapshotTimeMappingTuple(TupleDesc tupdesc, OldSnapshotTimeMapping *mapping) MakeOldSnapshotTimeMappingTuple(TupleDesc tupdesc, OldSnapshotTimeMapping *mapping)
{ {
Datum values[NUM_TIME_MAPPING_COLUMNS]; Datum values[NUM_TIME_MAPPING_COLUMNS];
bool nulls[NUM_TIME_MAPPING_COLUMNS]; bool nulls[NUM_TIME_MAPPING_COLUMNS];
int array_position; int array_position;
TimestampTz timestamp; TimestampTz timestamp;
/* /*
* Figure out the array position corresponding to the current index. * Figure out the array position corresponding to the current index.
* *
* Index 0 means the oldest entry in the mapping, which is stored at * Index 0 means the oldest entry in the mapping, which is stored at
* mapping->head_offset. Index 1 means the next-oldest entry, which is a the * mapping->head_offset. Index 1 means the next-oldest entry, which is a
* following index, and so on. We wrap around when we reach the end of the array. * the following index, and so on. We wrap around when we reach the end of
* the array.
*/ */
array_position = (mapping->head_offset + mapping->current_index) array_position = (mapping->head_offset + mapping->current_index)
% OLD_SNAPSHOT_TIME_MAP_ENTRIES; % OLD_SNAPSHOT_TIME_MAP_ENTRIES;
/* /*
* No explicit timestamp is stored for any entry other than the oldest one, * No explicit timestamp is stored for any entry other than the oldest
* but each entry corresponds to 1-minute period, so we can just add. * one, but each entry corresponds to 1-minute period, so we can just add.
*/ */
timestamp = TimestampTzPlusMilliseconds(mapping->head_timestamp, timestamp = TimestampTzPlusMilliseconds(mapping->head_timestamp,
mapping->current_index * 60000); mapping->current_index * 60000);

View File

@ -1074,9 +1074,10 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
* Force utility statements to get queryId zero. We do this even in cases * Force utility statements to get queryId zero. We do this even in cases
* where the statement contains an optimizable statement for which a * where the statement contains an optimizable statement for which a
* queryId could be derived (such as EXPLAIN or DECLARE CURSOR). For such * queryId could be derived (such as EXPLAIN or DECLARE CURSOR). For such
* cases, runtime control will first go through ProcessUtility and then the * cases, runtime control will first go through ProcessUtility and then
* executor, and we don't want the executor hooks to do anything, since we * the executor, and we don't want the executor hooks to do anything,
* are already measuring the statement's costs at the utility level. * since we are already measuring the statement's costs at the utility
* level.
* *
* Note that this is only done if pg_stat_statements is enabled and * Note that this is only done if pg_stat_statements is enabled and
* configured to track utility statements, in the unlikely possibility * configured to track utility statements, in the unlikely possibility

View File

@ -1779,7 +1779,8 @@ rebuildInsertSql(StringInfo buf, char *orig_query,
int values_end_len, int num_cols, int values_end_len, int num_cols,
int num_rows) int num_rows)
{ {
int i, j; int i,
j;
int pindex; int pindex;
bool first; bool first;
@ -1790,8 +1791,8 @@ rebuildInsertSql(StringInfo buf, char *orig_query,
appendBinaryStringInfo(buf, orig_query, values_end_len); appendBinaryStringInfo(buf, orig_query, values_end_len);
/* /*
* Add records to VALUES clause (we already have parameters for the * Add records to VALUES clause (we already have parameters for the first
* first row, so start at the right offset). * row, so start at the right offset).
*/ */
pindex = num_cols + 1; pindex = num_cols + 1;
for (i = 0; i < num_rows; i++) for (i = 0; i < num_rows; i++)

View File

@ -146,7 +146,7 @@ typedef struct PgFdwScanState
/* for remote query execution */ /* for remote query execution */
PGconn *conn; /* connection for the scan */ PGconn *conn; /* connection for the scan */
PgFdwConnState *conn_state; /* extra per-connection state */ PgFdwConnState *conn_state; /* extra per-connection state */
unsigned int cursor_number; /* quasi-unique ID for my cursor */ unsigned int cursor_number; /* quasi-unique ID for my cursor */
bool cursor_exists; /* have we created the cursor? */ bool cursor_exists; /* have we created the cursor? */
int numParams; /* number of parameters passed to query */ int numParams; /* number of parameters passed to query */
@ -164,7 +164,7 @@ typedef struct PgFdwScanState
bool eof_reached; /* true if last fetch reached EOF */ bool eof_reached; /* true if last fetch reached EOF */
/* for asynchronous execution */ /* for asynchronous execution */
bool async_capable; /* engage asynchronous-capable logic? */ bool async_capable; /* engage asynchronous-capable logic? */
/* working memory contexts */ /* working memory contexts */
MemoryContext batch_cxt; /* context holding current batch of tuples */ MemoryContext batch_cxt; /* context holding current batch of tuples */
@ -183,7 +183,7 @@ typedef struct PgFdwModifyState
/* for remote query execution */ /* for remote query execution */
PGconn *conn; /* connection for the scan */ PGconn *conn; /* connection for the scan */
PgFdwConnState *conn_state; /* extra per-connection state */ PgFdwConnState *conn_state; /* extra per-connection state */
char *p_name; /* name of prepared statement, if created */ char *p_name; /* name of prepared statement, if created */
/* extracted fdw_private data */ /* extracted fdw_private data */
@ -227,7 +227,7 @@ typedef struct PgFdwDirectModifyState
/* for remote query execution */ /* for remote query execution */
PGconn *conn; /* connection for the update */ PGconn *conn; /* connection for the update */
PgFdwConnState *conn_state; /* extra per-connection state */ PgFdwConnState *conn_state; /* extra per-connection state */
int numParams; /* number of parameters passed to query */ int numParams; /* number of parameters passed to query */
FmgrInfo *param_flinfo; /* output conversion functions for them */ FmgrInfo *param_flinfo; /* output conversion functions for them */
List *param_exprs; /* executable expressions for param values */ List *param_exprs; /* executable expressions for param values */
@ -364,10 +364,10 @@ static TupleTableSlot *postgresExecForeignInsert(EState *estate,
TupleTableSlot *slot, TupleTableSlot *slot,
TupleTableSlot *planSlot); TupleTableSlot *planSlot);
static TupleTableSlot **postgresExecForeignBatchInsert(EState *estate, static TupleTableSlot **postgresExecForeignBatchInsert(EState *estate,
ResultRelInfo *resultRelInfo, ResultRelInfo *resultRelInfo,
TupleTableSlot **slots, TupleTableSlot **slots,
TupleTableSlot **planSlots, TupleTableSlot **planSlots,
int *numSlots); int *numSlots);
static int postgresGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo); static int postgresGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo);
static TupleTableSlot *postgresExecForeignUpdate(EState *estate, static TupleTableSlot *postgresExecForeignUpdate(EState *estate,
ResultRelInfo *resultRelInfo, ResultRelInfo *resultRelInfo,
@ -467,11 +467,11 @@ static PgFdwModifyState *create_foreign_modify(EState *estate,
bool has_returning, bool has_returning,
List *retrieved_attrs); List *retrieved_attrs);
static TupleTableSlot **execute_foreign_modify(EState *estate, static TupleTableSlot **execute_foreign_modify(EState *estate,
ResultRelInfo *resultRelInfo, ResultRelInfo *resultRelInfo,
CmdType operation, CmdType operation,
TupleTableSlot **slots, TupleTableSlot **slots,
TupleTableSlot **planSlots, TupleTableSlot **planSlots,
int *numSlots); int *numSlots);
static void prepare_foreign_modify(PgFdwModifyState *fmstate); static void prepare_foreign_modify(PgFdwModifyState *fmstate);
static const char **convert_prep_stmt_params(PgFdwModifyState *fmstate, static const char **convert_prep_stmt_params(PgFdwModifyState *fmstate,
ItemPointer tupleid, ItemPointer tupleid,
@ -545,7 +545,7 @@ static void apply_table_options(PgFdwRelationInfo *fpinfo);
static void merge_fdw_options(PgFdwRelationInfo *fpinfo, static void merge_fdw_options(PgFdwRelationInfo *fpinfo,
const PgFdwRelationInfo *fpinfo_o, const PgFdwRelationInfo *fpinfo_o,
const PgFdwRelationInfo *fpinfo_i); const PgFdwRelationInfo *fpinfo_i);
static int get_batch_size_option(Relation rel); static int get_batch_size_option(Relation rel);
/* /*
@ -1870,7 +1870,7 @@ postgresBeginForeignModify(ModifyTableState *mtstate,
target_attrs = (List *) list_nth(fdw_private, target_attrs = (List *) list_nth(fdw_private,
FdwModifyPrivateTargetAttnums); FdwModifyPrivateTargetAttnums);
values_end_len = intVal(list_nth(fdw_private, values_end_len = intVal(list_nth(fdw_private,
FdwModifyPrivateLen)); FdwModifyPrivateLen));
has_returning = intVal(list_nth(fdw_private, has_returning = intVal(list_nth(fdw_private,
FdwModifyPrivateHasReturning)); FdwModifyPrivateHasReturning));
retrieved_attrs = (List *) list_nth(fdw_private, retrieved_attrs = (List *) list_nth(fdw_private,
@ -1907,7 +1907,7 @@ postgresExecForeignInsert(EState *estate,
{ {
PgFdwModifyState *fmstate = (PgFdwModifyState *) resultRelInfo->ri_FdwState; PgFdwModifyState *fmstate = (PgFdwModifyState *) resultRelInfo->ri_FdwState;
TupleTableSlot **rslot; TupleTableSlot **rslot;
int numSlots = 1; int numSlots = 1;
/* /*
* If the fmstate has aux_fmstate set, use the aux_fmstate (see * If the fmstate has aux_fmstate set, use the aux_fmstate (see
@ -1930,10 +1930,10 @@ postgresExecForeignInsert(EState *estate,
*/ */
static TupleTableSlot ** static TupleTableSlot **
postgresExecForeignBatchInsert(EState *estate, postgresExecForeignBatchInsert(EState *estate,
ResultRelInfo *resultRelInfo, ResultRelInfo *resultRelInfo,
TupleTableSlot **slots, TupleTableSlot **slots,
TupleTableSlot **planSlots, TupleTableSlot **planSlots,
int *numSlots) int *numSlots)
{ {
PgFdwModifyState *fmstate = (PgFdwModifyState *) resultRelInfo->ri_FdwState; PgFdwModifyState *fmstate = (PgFdwModifyState *) resultRelInfo->ri_FdwState;
TupleTableSlot **rslot; TupleTableSlot **rslot;
@ -1964,17 +1964,17 @@ postgresExecForeignBatchInsert(EState *estate,
static int static int
postgresGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo) postgresGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo)
{ {
int batch_size; int batch_size;
PgFdwModifyState *fmstate = resultRelInfo->ri_FdwState ? PgFdwModifyState *fmstate = resultRelInfo->ri_FdwState ?
(PgFdwModifyState *) resultRelInfo->ri_FdwState : (PgFdwModifyState *) resultRelInfo->ri_FdwState :
NULL; NULL;
/* should be called only once */ /* should be called only once */
Assert(resultRelInfo->ri_BatchSize == 0); Assert(resultRelInfo->ri_BatchSize == 0);
/* /*
* Should never get called when the insert is being performed as part of * Should never get called when the insert is being performed as part of a
* a row movement operation. * row movement operation.
*/ */
Assert(fmstate == NULL || fmstate->aux_fmstate == NULL); Assert(fmstate == NULL || fmstate->aux_fmstate == NULL);
@ -2009,10 +2009,10 @@ postgresExecForeignUpdate(EState *estate,
TupleTableSlot *planSlot) TupleTableSlot *planSlot)
{ {
TupleTableSlot **rslot; TupleTableSlot **rslot;
int numSlots = 1; int numSlots = 1;
rslot = execute_foreign_modify(estate, resultRelInfo, CMD_UPDATE, rslot = execute_foreign_modify(estate, resultRelInfo, CMD_UPDATE,
&slot, &planSlot, &numSlots); &slot, &planSlot, &numSlots);
return rslot ? rslot[0] : NULL; return rslot ? rslot[0] : NULL;
} }
@ -2028,10 +2028,10 @@ postgresExecForeignDelete(EState *estate,
TupleTableSlot *planSlot) TupleTableSlot *planSlot)
{ {
TupleTableSlot **rslot; TupleTableSlot **rslot;
int numSlots = 1; int numSlots = 1;
rslot = execute_foreign_modify(estate, resultRelInfo, CMD_DELETE, rslot = execute_foreign_modify(estate, resultRelInfo, CMD_DELETE,
&slot, &planSlot, &numSlots); &slot, &planSlot, &numSlots);
return rslot ? rslot[0] : NULL; return rslot ? rslot[0] : NULL;
} }
@ -2117,13 +2117,13 @@ postgresBeginForeignInsert(ModifyTableState *mtstate,
/* /*
* If the foreign table is a partition that doesn't have a corresponding * If the foreign table is a partition that doesn't have a corresponding
* RTE entry, we need to create a new RTE * RTE entry, we need to create a new RTE describing the foreign table for
* describing the foreign table for use by deparseInsertSql and * use by deparseInsertSql and create_foreign_modify() below, after first
* create_foreign_modify() below, after first copying the parent's RTE and * copying the parent's RTE and modifying some fields to describe the
* modifying some fields to describe the foreign partition to work on. * foreign partition to work on. However, if this is invoked by UPDATE,
* However, if this is invoked by UPDATE, the existing RTE may already * the existing RTE may already correspond to this partition if it is one
* correspond to this partition if it is one of the UPDATE subplan target * of the UPDATE subplan target rels; in that case, we can just use the
* rels; in that case, we can just use the existing RTE as-is. * existing RTE as-is.
*/ */
if (resultRelInfo->ri_RangeTableIndex == 0) if (resultRelInfo->ri_RangeTableIndex == 0)
{ {
@ -2847,8 +2847,8 @@ postgresExplainForeignModify(ModifyTableState *mtstate,
ExplainPropertyText("Remote SQL", sql, es); ExplainPropertyText("Remote SQL", sql, es);
/* /*
* For INSERT we should always have batch size >= 1, but UPDATE * For INSERT we should always have batch size >= 1, but UPDATE and
* and DELETE don't support batching so don't show the property. * DELETE don't support batching so don't show the property.
*/ */
if (rinfo->ri_BatchSize > 0) if (rinfo->ri_BatchSize > 0)
ExplainPropertyInteger("Batch Size", NULL, rinfo->ri_BatchSize, es); ExplainPropertyInteger("Batch Size", NULL, rinfo->ri_BatchSize, es);
@ -7255,18 +7255,18 @@ find_em_expr_for_input_target(PlannerInfo *root,
static int static int
get_batch_size_option(Relation rel) get_batch_size_option(Relation rel)
{ {
Oid foreigntableid = RelationGetRelid(rel); Oid foreigntableid = RelationGetRelid(rel);
ForeignTable *table; ForeignTable *table;
ForeignServer *server; ForeignServer *server;
List *options; List *options;
ListCell *lc; ListCell *lc;
/* we use 1 by default, which means "no batching" */ /* we use 1 by default, which means "no batching" */
int batch_size = 1; int batch_size = 1;
/* /*
* Load options for table and server. We append server options after * Load options for table and server. We append server options after table
* table options, because table options take precedence. * options, because table options take precedence.
*/ */
table = GetForeignTable(foreigntableid); table = GetForeignTable(foreigntableid);
server = GetForeignServer(table->serverid); server = GetForeignServer(table->serverid);

View File

@ -645,11 +645,11 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
* range values; if so, have the pages in the range added * range values; if so, have the pages in the range added
* to the output bitmap. * to the output bitmap.
* *
* The opclass may or may not support processing of multiple * The opclass may or may not support processing of
* scan keys. We can determine that based on the number of * multiple scan keys. We can determine that based on the
* arguments - functions with extra parameter (number of scan * number of arguments - functions with extra parameter
* keys) do support this, otherwise we have to simply pass the * (number of scan keys) do support this, otherwise we
* scan keys one by one. * have to simply pass the scan keys one by one.
*/ */
if (consistentFn[attno - 1].fn_nargs >= 4) if (consistentFn[attno - 1].fn_nargs >= 4)
{ {
@ -667,10 +667,10 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
/* /*
* Check keys one by one * Check keys one by one
* *
* When there are multiple scan keys, failure to meet the * When there are multiple scan keys, failure to meet
* criteria for a single one of them is enough to discard * the criteria for a single one of them is enough to
* the range as a whole, so break out of the loop as soon * discard the range as a whole, so break out of the
* as a false return value is obtained. * loop as soon as a false return value is obtained.
*/ */
int keyno; int keyno;

View File

@ -258,7 +258,7 @@ typedef struct BloomFilter
/* data of the bloom filter */ /* data of the bloom filter */
char data[FLEXIBLE_ARRAY_MEMBER]; char data[FLEXIBLE_ARRAY_MEMBER];
} BloomFilter; } BloomFilter;
/* /*
@ -341,7 +341,7 @@ bloom_init(int ndistinct, double false_positive_rate)
* Add value to the bloom filter. * Add value to the bloom filter.
*/ */
static BloomFilter * static BloomFilter *
bloom_add_value(BloomFilter * filter, uint32 value, bool *updated) bloom_add_value(BloomFilter *filter, uint32 value, bool *updated)
{ {
int i; int i;
uint64 h1, uint64 h1,
@ -378,7 +378,7 @@ bloom_add_value(BloomFilter * filter, uint32 value, bool *updated)
* Check if the bloom filter contains a particular value. * Check if the bloom filter contains a particular value.
*/ */
static bool static bool
bloom_contains_value(BloomFilter * filter, uint32 value) bloom_contains_value(BloomFilter *filter, uint32 value)
{ {
int i; int i;
uint64 h1, uint64 h1,
@ -414,7 +414,7 @@ typedef struct BloomOpaque
*/ */
FmgrInfo extra_procinfos[BLOOM_MAX_PROCNUMS]; FmgrInfo extra_procinfos[BLOOM_MAX_PROCNUMS];
bool extra_proc_missing[BLOOM_MAX_PROCNUMS]; bool extra_proc_missing[BLOOM_MAX_PROCNUMS];
} BloomOpaque; } BloomOpaque;
static FmgrInfo *bloom_get_procinfo(BrinDesc *bdesc, uint16 attno, static FmgrInfo *bloom_get_procinfo(BrinDesc *bdesc, uint16 attno,
uint16 procnum); uint16 procnum);

View File

@ -114,7 +114,7 @@ typedef struct MinmaxMultiOpaque
bool extra_proc_missing[MINMAX_MAX_PROCNUMS]; bool extra_proc_missing[MINMAX_MAX_PROCNUMS];
Oid cached_subtype; Oid cached_subtype;
FmgrInfo strategy_procinfos[BTMaxStrategyNumber]; FmgrInfo strategy_procinfos[BTMaxStrategyNumber];
} MinmaxMultiOpaque; } MinmaxMultiOpaque;
/* /*
* Storage type for BRIN's minmax reloptions * Storage type for BRIN's minmax reloptions
@ -261,7 +261,7 @@ typedef struct compare_context
{ {
FmgrInfo *cmpFn; FmgrInfo *cmpFn;
Oid colloid; Oid colloid;
} compare_context; } compare_context;
static int compare_values(const void *a, const void *b, void *arg); static int compare_values(const void *a, const void *b, void *arg);
@ -670,11 +670,11 @@ range_serialize(Ranges *range)
/* /*
* For values passed by value, we need to copy just the * For values passed by value, we need to copy just the
* significant bytes - we can't use memcpy directly, as that * significant bytes - we can't use memcpy directly, as that
* assumes little endian behavior. store_att_byval does * assumes little endian behavior. store_att_byval does almost
* almost what we need, but it requires properly aligned * what we need, but it requires properly aligned buffer - the
* buffer - the output buffer does not guarantee that. So we * output buffer does not guarantee that. So we simply use a local
* simply use a local Datum variable (which guarantees proper * Datum variable (which guarantees proper alignment), and then
* alignment), and then copy the value from it. * copy the value from it.
*/ */
store_att_byval(&tmp, range->values[i], typlen); store_att_byval(&tmp, range->values[i], typlen);
@ -771,7 +771,7 @@ range_deserialize(int maxvalues, SerializedRanges *serialized)
dataptr = NULL; dataptr = NULL;
for (i = 0; (i < nvalues) && (!typbyval); i++) for (i = 0; (i < nvalues) && (!typbyval); i++)
{ {
if (typlen > 0) /* fixed-length by-ref types */ if (typlen > 0) /* fixed-length by-ref types */
datalen += MAXALIGN(typlen); datalen += MAXALIGN(typlen);
else if (typlen == -1) /* varlena */ else if (typlen == -1) /* varlena */
{ {
@ -824,7 +824,8 @@ range_deserialize(int maxvalues, SerializedRanges *serialized)
} }
else if (typlen == -2) /* cstring */ else if (typlen == -2) /* cstring */
{ {
Size slen = strlen(ptr) + 1; Size slen = strlen(ptr) + 1;
range->values[i] = PointerGetDatum(dataptr); range->values[i] = PointerGetDatum(dataptr);
memcpy(dataptr, ptr, slen); memcpy(dataptr, ptr, slen);
@ -2156,8 +2157,8 @@ brin_minmax_multi_distance_interval(PG_FUNCTION_ARGS)
/* /*
* Delta is (fractional) number of days between the intervals. Assume * Delta is (fractional) number of days between the intervals. Assume
* months have 30 days for consistency with interval_cmp_internal. * months have 30 days for consistency with interval_cmp_internal. We
* We don't need to be exact, in the worst case we'll build a bit less * don't need to be exact, in the worst case we'll build a bit less
* efficient ranges. But we should not contradict interval_cmp. * efficient ranges. But we should not contradict interval_cmp.
*/ */
dayfraction = result->time % USECS_PER_DAY; dayfraction = result->time % USECS_PER_DAY;
@ -2315,13 +2316,12 @@ brin_minmax_multi_distance_inet(PG_FUNCTION_ARGS)
/* /*
* The length is calculated from the mask length, because we sort the * The length is calculated from the mask length, because we sort the
* addresses by first address in the range, so A.B.C.D/24 < A.B.C.1 * addresses by first address in the range, so A.B.C.D/24 < A.B.C.1 (the
* (the first range starts at A.B.C.0, which is before A.B.C.1). We * first range starts at A.B.C.0, which is before A.B.C.1). We don't want
* don't want to produce negative delta in this case, so we just cut * to produce negative delta in this case, so we just cut the extra bytes.
* the extra bytes.
* *
* XXX Maybe this should be a bit more careful and cut the bits, not * XXX Maybe this should be a bit more careful and cut the bits, not just
* just whole bytes. * whole bytes.
*/ */
lena = ip_bits(ipa); lena = ip_bits(ipa);
lenb = ip_bits(ipb); lenb = ip_bits(ipb);
@ -2331,8 +2331,8 @@ brin_minmax_multi_distance_inet(PG_FUNCTION_ARGS)
/* apply the network mask to both addresses */ /* apply the network mask to both addresses */
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
unsigned char mask; unsigned char mask;
int nbits; int nbits;
nbits = lena - (i * 8); nbits = lena - (i * 8);
if (nbits < 8) if (nbits < 8)

View File

@ -371,6 +371,7 @@ brinRevmapDesummarizeRange(Relation idxrel, BlockNumber heapBlk)
regBuf = ReadBuffer(idxrel, ItemPointerGetBlockNumber(iptr)); regBuf = ReadBuffer(idxrel, ItemPointerGetBlockNumber(iptr));
LockBuffer(regBuf, BUFFER_LOCK_EXCLUSIVE); LockBuffer(regBuf, BUFFER_LOCK_EXCLUSIVE);
regPg = BufferGetPage(regBuf); regPg = BufferGetPage(regBuf);
/* /*
* We're only removing data, not reading it, so there's no need to * We're only removing data, not reading it, so there's no need to
* TestForOldSnapshot here. * TestForOldSnapshot here.

View File

@ -177,15 +177,15 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
datumno < brdesc->bd_info[keyno]->oi_nstored; datumno < brdesc->bd_info[keyno]->oi_nstored;
datumno++) datumno++)
{ {
Datum value = tuple->bt_columns[keyno].bv_values[datumno]; Datum value = tuple->bt_columns[keyno].bv_values[datumno];
#ifdef TOAST_INDEX_HACK #ifdef TOAST_INDEX_HACK
/* We must look at the stored type, not at the index descriptor. */ /* We must look at the stored type, not at the index descriptor. */
TypeCacheEntry *atttype = brdesc->bd_info[keyno]->oi_typcache[datumno]; TypeCacheEntry *atttype = brdesc->bd_info[keyno]->oi_typcache[datumno];
/* Do we need to free the value at the end? */ /* Do we need to free the value at the end? */
bool free_value = false; bool free_value = false;
/* For non-varlena types we don't need to do anything special */ /* For non-varlena types we don't need to do anything special */
if (atttype->typlen != -1) if (atttype->typlen != -1)
@ -201,9 +201,9 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
* If value is stored EXTERNAL, must fetch it so we are not * If value is stored EXTERNAL, must fetch it so we are not
* depending on outside storage. * depending on outside storage.
* *
* XXX Is this actually true? Could it be that the summary is * XXX Is this actually true? Could it be that the summary is NULL
* NULL even for range with non-NULL data? E.g. degenerate bloom * even for range with non-NULL data? E.g. degenerate bloom filter
* filter may be thrown away, etc. * may be thrown away, etc.
*/ */
if (VARATT_IS_EXTERNAL(DatumGetPointer(value))) if (VARATT_IS_EXTERNAL(DatumGetPointer(value)))
{ {
@ -213,16 +213,16 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
} }
/* /*
* If value is above size target, and is of a compressible datatype, * If value is above size target, and is of a compressible
* try to compress it in-line. * datatype, try to compress it in-line.
*/ */
if (!VARATT_IS_EXTENDED(DatumGetPointer(value)) && if (!VARATT_IS_EXTENDED(DatumGetPointer(value)) &&
VARSIZE(DatumGetPointer(value)) > TOAST_INDEX_TARGET && VARSIZE(DatumGetPointer(value)) > TOAST_INDEX_TARGET &&
(atttype->typstorage == TYPSTORAGE_EXTENDED || (atttype->typstorage == TYPSTORAGE_EXTENDED ||
atttype->typstorage == TYPSTORAGE_MAIN)) atttype->typstorage == TYPSTORAGE_MAIN))
{ {
Datum cvalue; Datum cvalue;
char compression; char compression;
Form_pg_attribute att = TupleDescAttr(brdesc->bd_tupdesc, Form_pg_attribute att = TupleDescAttr(brdesc->bd_tupdesc,
keyno); keyno);

View File

@ -103,14 +103,14 @@ index_form_tuple(TupleDesc tupleDescriptor,
(att->attstorage == TYPSTORAGE_EXTENDED || (att->attstorage == TYPSTORAGE_EXTENDED ||
att->attstorage == TYPSTORAGE_MAIN)) att->attstorage == TYPSTORAGE_MAIN))
{ {
Datum cvalue; Datum cvalue;
char compression = att->attcompression; char compression = att->attcompression;
/* /*
* If the compression method is not valid, use the default. We * If the compression method is not valid, use the default. We
* don't expect this to happen for regular index columns, which * don't expect this to happen for regular index columns, which
* inherit the setting from the corresponding table column, but * inherit the setting from the corresponding table column, but we
* we do expect it to happen whenever an expression is indexed. * do expect it to happen whenever an expression is indexed.
*/ */
if (!CompressionMethodIsValid(compression)) if (!CompressionMethodIsValid(compression))
compression = GetDefaultToastCompression(); compression = GetDefaultToastCompression();

View File

@ -24,7 +24,7 @@
#include "utils/builtins.h" #include "utils/builtins.h"
/* GUC */ /* GUC */
int default_toast_compression = TOAST_PGLZ_COMPRESSION; int default_toast_compression = TOAST_PGLZ_COMPRESSION;
#define NO_LZ4_SUPPORT() \ #define NO_LZ4_SUPPORT() \
ereport(ERROR, \ ereport(ERROR, \
@ -109,7 +109,7 @@ pglz_decompress_datum(const struct varlena *value)
*/ */
struct varlena * struct varlena *
pglz_decompress_datum_slice(const struct varlena *value, pglz_decompress_datum_slice(const struct varlena *value,
int32 slicelength) int32 slicelength)
{ {
struct varlena *result; struct varlena *result;
int32 rawsize; int32 rawsize;
@ -255,12 +255,12 @@ lz4_decompress_datum_slice(const struct varlena *value, int32 slicelength)
ToastCompressionId ToastCompressionId
toast_get_compression_id(struct varlena *attr) toast_get_compression_id(struct varlena *attr)
{ {
ToastCompressionId cmid = TOAST_INVALID_COMPRESSION_ID; ToastCompressionId cmid = TOAST_INVALID_COMPRESSION_ID;
/* /*
* If it is stored externally then fetch the compression method id from the * If it is stored externally then fetch the compression method id from
* external toast pointer. If compressed inline, fetch it from the toast * the external toast pointer. If compressed inline, fetch it from the
* compression header. * toast compression header.
*/ */
if (VARATT_IS_EXTERNAL_ONDISK(attr)) if (VARATT_IS_EXTERNAL_ONDISK(attr))
{ {

View File

@ -48,7 +48,7 @@ toast_compress_datum(Datum value, char cmethod)
{ {
struct varlena *tmp = NULL; struct varlena *tmp = NULL;
int32 valsize; int32 valsize;
ToastCompressionId cmid = TOAST_INVALID_COMPRESSION_ID; ToastCompressionId cmid = TOAST_INVALID_COMPRESSION_ID;
Assert(!VARATT_IS_EXTERNAL(DatumGetPointer(value))); Assert(!VARATT_IS_EXTERNAL(DatumGetPointer(value)));
Assert(!VARATT_IS_COMPRESSED(DatumGetPointer(value))); Assert(!VARATT_IS_COMPRESSED(DatumGetPointer(value)));

View File

@ -236,7 +236,7 @@ execute_attr_map_slot(AttrMap *attrMap,
Bitmapset * Bitmapset *
execute_attr_map_cols(AttrMap *attrMap, Bitmapset *in_cols) execute_attr_map_cols(AttrMap *attrMap, Bitmapset *in_cols)
{ {
Bitmapset *out_cols; Bitmapset *out_cols;
int out_attnum; int out_attnum;
/* fast path for the common trivial case */ /* fast path for the common trivial case */

View File

@ -35,9 +35,9 @@ static bool rtree_internal_consistent(BOX *key, BOX *query,
static uint64 point_zorder_internal(float4 x, float4 y); static uint64 point_zorder_internal(float4 x, float4 y);
static uint64 part_bits32_by2(uint32 x); static uint64 part_bits32_by2(uint32 x);
static uint32 ieee_float32_to_uint32(float f); static uint32 ieee_float32_to_uint32(float f);
static int gist_bbox_zorder_cmp(Datum a, Datum b, SortSupport ssup); static int gist_bbox_zorder_cmp(Datum a, Datum b, SortSupport ssup);
static Datum gist_bbox_zorder_abbrev_convert(Datum original, SortSupport ssup); static Datum gist_bbox_zorder_abbrev_convert(Datum original, SortSupport ssup);
static int gist_bbox_zorder_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup); static int gist_bbox_zorder_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup);
static bool gist_bbox_zorder_abbrev_abort(int memtupcount, SortSupport ssup); static bool gist_bbox_zorder_abbrev_abort(int memtupcount, SortSupport ssup);

View File

@ -267,7 +267,7 @@ gistvalidate(Oid opclassoid)
continue; /* got it */ continue; /* got it */
if (i == GIST_DISTANCE_PROC || i == GIST_FETCH_PROC || if (i == GIST_DISTANCE_PROC || i == GIST_FETCH_PROC ||
i == GIST_COMPRESS_PROC || i == GIST_DECOMPRESS_PROC || i == GIST_COMPRESS_PROC || i == GIST_DECOMPRESS_PROC ||
i == GIST_OPTIONS_PROC || i == GIST_SORTSUPPORT_PROC) i == GIST_OPTIONS_PROC || i == GIST_SORTSUPPORT_PROC)
continue; /* optional methods */ continue; /* optional methods */
ereport(INFO, ereport(INFO,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),

View File

@ -432,11 +432,11 @@ heapgetpage(TableScanDesc sscan, BlockNumber page)
* transactions on the primary might still be invisible to a read-only * transactions on the primary might still be invisible to a read-only
* transaction in the standby. We partly handle this problem by tracking * transaction in the standby. We partly handle this problem by tracking
* the minimum xmin of visible tuples as the cut-off XID while marking a * the minimum xmin of visible tuples as the cut-off XID while marking a
* page all-visible on the primary and WAL log that along with the visibility * page all-visible on the primary and WAL log that along with the
* map SET operation. In hot standby, we wait for (or abort) all * visibility map SET operation. In hot standby, we wait for (or abort)
* transactions that can potentially may not see one or more tuples on the * all transactions that can potentially may not see one or more tuples on
* page. That's how index-only scans work fine in hot standby. A crucial * the page. That's how index-only scans work fine in hot standby. A
* difference between index-only scans and heap scans is that the * crucial difference between index-only scans and heap scans is that the
* index-only scan completely relies on the visibility map where as heap * 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 * 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 * the page-level flag can be trusted in the same way, because it might
@ -2095,11 +2095,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
/* /*
* If we're inserting frozen entry into an empty page, * If we're inserting frozen entry into an empty page, set visibility map
* set visibility map bits and PageAllVisible() hint. * bits and PageAllVisible() hint.
* *
* If we're inserting frozen entry into already all_frozen page, * If we're inserting frozen entry into already all_frozen page, preserve
* preserve this state. * this state.
*/ */
if (options & HEAP_INSERT_FROZEN) if (options & HEAP_INSERT_FROZEN)
{ {
@ -2109,7 +2109,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
if (visibilitymap_pin_ok(BufferGetBlockNumber(buffer), vmbuffer)) if (visibilitymap_pin_ok(BufferGetBlockNumber(buffer), vmbuffer))
vmstatus = visibilitymap_get_status(relation, vmstatus = visibilitymap_get_status(relation,
BufferGetBlockNumber(buffer), &vmbuffer); BufferGetBlockNumber(buffer), &vmbuffer);
if ((starting_with_empty_page || vmstatus & VISIBILITYMAP_ALL_FROZEN)) if ((starting_with_empty_page || vmstatus & VISIBILITYMAP_ALL_FROZEN))
all_frozen_set = true; all_frozen_set = true;
@ -2139,8 +2139,8 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
(options & HEAP_INSERT_SPECULATIVE) != 0); (options & HEAP_INSERT_SPECULATIVE) != 0);
/* /*
* If the page is all visible, need to clear that, unless we're only * If the page is all visible, need to clear that, unless we're only going
* going to add further frozen rows to it. * to add further frozen rows to it.
* *
* If we're only adding already frozen rows to a page that was empty or * If we're only adding already frozen rows to a page that was empty or
* marked as all visible, mark it as all-visible. * marked as all visible, mark it as all-visible.
@ -2258,11 +2258,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
END_CRIT_SECTION(); END_CRIT_SECTION();
/* /*
* If we've frozen everything on the page, update the visibilitymap. * If we've frozen everything on the page, update the visibilitymap. We're
* We're already holding pin on the vmbuffer. * already holding pin on the vmbuffer.
* *
* No need to update the visibilitymap if it had all_frozen bit set * No need to update the visibilitymap if it had all_frozen bit set before
* before this insertion. * this insertion.
*/ */
if (all_frozen_set && ((vmstatus & VISIBILITYMAP_ALL_FROZEN) == 0)) if (all_frozen_set && ((vmstatus & VISIBILITYMAP_ALL_FROZEN) == 0))
{ {
@ -2270,14 +2270,14 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
Assert(visibilitymap_pin_ok(BufferGetBlockNumber(buffer), vmbuffer)); Assert(visibilitymap_pin_ok(BufferGetBlockNumber(buffer), vmbuffer));
/* /*
* It's fine to use InvalidTransactionId here - this is only used * It's fine to use InvalidTransactionId here - this is only used when
* when HEAP_INSERT_FROZEN is specified, which intentionally * HEAP_INSERT_FROZEN is specified, which intentionally violates
* violates visibility rules. * visibility rules.
*/ */
visibilitymap_set(relation, BufferGetBlockNumber(buffer), buffer, visibilitymap_set(relation, BufferGetBlockNumber(buffer), buffer,
InvalidXLogRecPtr, vmbuffer, InvalidXLogRecPtr, vmbuffer,
InvalidTransactionId, InvalidTransactionId,
VISIBILITYMAP_ALL_VISIBLE | VISIBILITYMAP_ALL_FROZEN); VISIBILITYMAP_ALL_VISIBLE | VISIBILITYMAP_ALL_FROZEN);
} }
UnlockReleaseBuffer(buffer); UnlockReleaseBuffer(buffer);
@ -2547,7 +2547,7 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
tupledata = scratchptr; tupledata = scratchptr;
/* check that the mutually exclusive flags are not both set */ /* check that the mutually exclusive flags are not both set */
Assert (!(all_visible_cleared && all_frozen_set)); Assert(!(all_visible_cleared && all_frozen_set));
xlrec->flags = 0; xlrec->flags = 0;
if (all_visible_cleared) if (all_visible_cleared)
@ -3063,7 +3063,10 @@ l1:
xl_heap_header xlhdr; xl_heap_header xlhdr;
XLogRecPtr recptr; XLogRecPtr recptr;
/* For logical decode we need combo CIDs to properly decode the catalog */ /*
* For logical decode we need combo CIDs to properly decode the
* catalog
*/
if (RelationIsAccessibleInLogicalDecoding(relation)) if (RelationIsAccessibleInLogicalDecoding(relation))
log_heap_new_cid(relation, &tp); log_heap_new_cid(relation, &tp);
@ -7932,16 +7935,16 @@ bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate)
* TIDs as each other. The goal is to ignore relatively small differences * TIDs as each other. The goal is to ignore relatively small differences
* in the total number of promising entries, so that the whole process can * in the total number of promising entries, so that the whole process can
* give a little weight to heapam factors (like heap block locality) * give a little weight to heapam factors (like heap block locality)
* instead. This isn't a trade-off, really -- we have nothing to lose. * instead. This isn't a trade-off, really -- we have nothing to lose. It
* It would be foolish to interpret small differences in npromisingtids * would be foolish to interpret small differences in npromisingtids
* values as anything more than noise. * values as anything more than noise.
* *
* We tiebreak on nhtids when sorting block group subsets that have the * We tiebreak on nhtids when sorting block group subsets that have the
* same npromisingtids, but this has the same issues as npromisingtids, * same npromisingtids, but this has the same issues as npromisingtids,
* and so nhtids is subject to the same power-of-two bucketing scheme. * and so nhtids is subject to the same power-of-two bucketing scheme. The
* The only reason that we don't fix nhtids in the same way here too is * only reason that we don't fix nhtids in the same way here too is that
* that we'll need accurate nhtids values after the sort. We handle * we'll need accurate nhtids values after the sort. We handle nhtids
* nhtids bucketization dynamically instead (in the sort comparator). * bucketization dynamically instead (in the sort comparator).
* *
* See bottomup_nblocksfavorable() for a full explanation of when and how * See bottomup_nblocksfavorable() for a full explanation of when and how
* heap locality/favorable blocks can significantly influence when and how * heap locality/favorable blocks can significantly influence when and how
@ -8944,8 +8947,8 @@ heap_xlog_insert(XLogReaderState *record)
ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum); ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
/* check that the mutually exclusive flags are not both set */ /* check that the mutually exclusive flags are not both set */
Assert (!((xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED) && Assert(!((xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED) &&
(xlrec->flags & XLH_INSERT_ALL_FROZEN_SET))); (xlrec->flags & XLH_INSERT_ALL_FROZEN_SET)));
/* /*
* The visibility map may need to be fixed even if the heap page is * The visibility map may need to be fixed even if the heap page is
@ -9072,8 +9075,8 @@ heap_xlog_multi_insert(XLogReaderState *record)
XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno); XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
/* check that the mutually exclusive flags are not both set */ /* check that the mutually exclusive flags are not both set */
Assert (!((xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED) && Assert(!((xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED) &&
(xlrec->flags & XLH_INSERT_ALL_FROZEN_SET))); (xlrec->flags & XLH_INSERT_ALL_FROZEN_SET)));
/* /*
* The visibility map may need to be fixed even if the heap page is * The visibility map may need to be fixed even if the heap page is

View File

@ -1659,13 +1659,13 @@ heapam_index_build_range_scan(Relation heapRelation,
offnum = ItemPointerGetOffsetNumber(&heapTuple->t_self); offnum = ItemPointerGetOffsetNumber(&heapTuple->t_self);
/* /*
* If a HOT tuple points to a root that we don't know * If a HOT tuple points to a root that we don't know about,
* about, obtain root items afresh. If that still fails, * obtain root items afresh. If that still fails, report it as
* report it as corruption. * corruption.
*/ */
if (root_offsets[offnum - 1] == InvalidOffsetNumber) if (root_offsets[offnum - 1] == InvalidOffsetNumber)
{ {
Page page = BufferGetPage(hscan->rs_cbuf); Page page = BufferGetPage(hscan->rs_cbuf);
LockBuffer(hscan->rs_cbuf, BUFFER_LOCK_SHARE); LockBuffer(hscan->rs_cbuf, BUFFER_LOCK_SHARE);
heap_get_root_tuples(page, root_offsets); heap_get_root_tuples(page, root_offsets);
@ -2482,8 +2482,8 @@ reform_and_rewrite_tuple(HeapTuple tuple,
else if (!isnull[i] && TupleDescAttr(newTupDesc, i)->attlen == -1) else if (!isnull[i] && TupleDescAttr(newTupDesc, i)->attlen == -1)
{ {
struct varlena *new_value; struct varlena *new_value;
ToastCompressionId cmid; ToastCompressionId cmid;
char cmethod; char cmethod;
new_value = (struct varlena *) DatumGetPointer(values[i]); new_value = (struct varlena *) DatumGetPointer(values[i]);
cmid = toast_get_compression_id(new_value); cmid = toast_get_compression_id(new_value);

View File

@ -1608,8 +1608,8 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
/* /*
* another transaction might have (tried to) delete this tuple or * another transaction might have (tried to) delete this tuple or
* cmin/cmax was stored in a combo CID. So we need to lookup the actual * cmin/cmax was stored in a combo CID. So we need to lookup the
* values externally. * actual values externally.
*/ */
resolved = ResolveCminCmaxDuringDecoding(HistoricSnapshotGetTupleCids(), snapshot, resolved = ResolveCminCmaxDuringDecoding(HistoricSnapshotGetTupleCids(), snapshot,
htup, buffer, htup, buffer,
@ -1629,8 +1629,8 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
* elog inside ResolveCminCmaxDuringDecoding. * elog inside ResolveCminCmaxDuringDecoding.
* *
* XXX For the streaming case, we can track the largest combo CID * XXX For the streaming case, we can track the largest combo CID
* assigned, and error out based on this (when unable to resolve * assigned, and error out based on this (when unable to resolve combo
* combo CID below that observed maximum value). * CID below that observed maximum value).
*/ */
if (!resolved) if (!resolved)
return false; return false;
@ -1717,8 +1717,8 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
* elog inside ResolveCminCmaxDuringDecoding. * elog inside ResolveCminCmaxDuringDecoding.
* *
* XXX For the streaming case, we can track the largest combo CID * XXX For the streaming case, we can track the largest combo CID
* assigned, and error out based on this (when unable to resolve * assigned, and error out based on this (when unable to resolve combo
* combo CID below that observed maximum value). * CID below that observed maximum value).
*/ */
if (!resolved || cmax == InvalidCommandId) if (!resolved || cmax == InvalidCommandId)
return true; return true;

View File

@ -410,8 +410,8 @@ RelationGetBufferForTuple(Relation relation, Size len,
} }
/* /*
* If the FSM knows nothing of the rel, try the last page before we * If the FSM knows nothing of the rel, try the last page before we give
* give up and extend. This avoids one-tuple-per-page syndrome during * up and extend. This avoids one-tuple-per-page syndrome during
* bootstrapping or in a recently-started system. * bootstrapping or in a recently-started system.
*/ */
if (targetBlock == InvalidBlockNumber) if (targetBlock == InvalidBlockNumber)

View File

@ -95,8 +95,8 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
/* /*
* We can't write WAL in recovery mode, so there's no point trying to * We can't write WAL in recovery mode, so there's no point trying to
* clean the page. The primary will likely issue a cleaning WAL record soon * clean the page. The primary will likely issue a cleaning WAL record
* anyway, so this is no particular loss. * soon anyway, so this is no particular loss.
*/ */
if (RecoveryInProgress()) if (RecoveryInProgress())
return; return;

View File

@ -691,8 +691,8 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
* *
* Deliberately avoid telling the stats collector about LP_DEAD items that * Deliberately avoid telling the stats collector about LP_DEAD items that
* remain in the table due to VACUUM bypassing index and heap vacuuming. * remain in the table due to VACUUM bypassing index and heap vacuuming.
* ANALYZE will consider the remaining LP_DEAD items to be dead tuples. * ANALYZE will consider the remaining LP_DEAD items to be dead tuples. It
* It seems like a good idea to err on the side of not vacuuming again too * seems like a good idea to err on the side of not vacuuming again too
* soon in cases where the failsafe prevented significant amounts of heap * soon in cases where the failsafe prevented significant amounts of heap
* vacuuming. * vacuuming.
*/ */
@ -2284,7 +2284,7 @@ static void
lazy_vacuum_heap_rel(LVRelState *vacrel) lazy_vacuum_heap_rel(LVRelState *vacrel)
{ {
int tupindex; int tupindex;
BlockNumber vacuumed_pages; BlockNumber vacuumed_pages;
PGRUsage ru0; PGRUsage ru0;
Buffer vmbuffer = InvalidBuffer; Buffer vmbuffer = InvalidBuffer;
LVSavedErrInfo saved_err_info; LVSavedErrInfo saved_err_info;

View File

@ -612,8 +612,8 @@ systable_endscan(SysScanDesc sysscan)
UnregisterSnapshot(sysscan->snapshot); UnregisterSnapshot(sysscan->snapshot);
/* /*
* Reset the bsysscan flag at the end of the systable scan. See * Reset the bsysscan flag at the end of the systable scan. See detailed
* detailed comments in xact.c where these variables are declared. * comments in xact.c where these variables are declared.
*/ */
if (TransactionIdIsValid(CheckXidAlive)) if (TransactionIdIsValid(CheckXidAlive))
bsysscan = false; bsysscan = false;

View File

@ -1054,22 +1054,22 @@ _bt_lockbuf(Relation rel, Buffer buf, int access)
LockBuffer(buf, access); LockBuffer(buf, access);
/* /*
* It doesn't matter that _bt_unlockbuf() won't get called in the * It doesn't matter that _bt_unlockbuf() won't get called in the event of
* event of an nbtree error (e.g. a unique violation error). That * an nbtree error (e.g. a unique violation error). That won't cause
* won't cause Valgrind false positives. * Valgrind false positives.
* *
* The nbtree client requests are superimposed on top of the * The nbtree client requests are superimposed on top of the bufmgr.c
* bufmgr.c buffer pin client requests. In the event of an nbtree * buffer pin client requests. In the event of an nbtree error the buffer
* error the buffer will certainly get marked as defined when the * will certainly get marked as defined when the backend once again
* backend once again acquires its first pin on the buffer. (Of * acquires its first pin on the buffer. (Of course, if the backend never
* course, if the backend never touches the buffer again then it * touches the buffer again then it doesn't matter that it remains
* doesn't matter that it remains non-accessible to Valgrind.) * non-accessible to Valgrind.)
* *
* Note: When an IndexTuple C pointer gets computed using an * Note: When an IndexTuple C pointer gets computed using an ItemId read
* ItemId read from a page while a lock was held, the C pointer * from a page while a lock was held, the C pointer becomes unsafe to
* becomes unsafe to dereference forever as soon as the lock is * dereference forever as soon as the lock is released. Valgrind can only
* released. Valgrind can only detect cases where the pointer * detect cases where the pointer gets dereferenced with no _current_
* gets dereferenced with no _current_ lock/pin held, though. * lock/pin held, though.
*/ */
if (!RelationUsesLocalBuffers(rel)) if (!RelationUsesLocalBuffers(rel))
VALGRIND_MAKE_MEM_DEFINED(BufferGetPage(buf), BLCKSZ); VALGRIND_MAKE_MEM_DEFINED(BufferGetPage(buf), BLCKSZ);
@ -2395,7 +2395,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
opaque = (BTPageOpaque) PageGetSpecialPointer(page); opaque = (BTPageOpaque) PageGetSpecialPointer(page);
while (P_ISDELETED(opaque) || opaque->btpo_next != target) while (P_ISDELETED(opaque) || opaque->btpo_next != target)
{ {
bool leftsibvalid = true; bool leftsibvalid = true;
/* /*
* Before we follow the link from the page that was the left * Before we follow the link from the page that was the left

View File

@ -898,8 +898,8 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record)
* top parent link when deleting leafbuf because it's the last page * top parent link when deleting leafbuf because it's the last page
* we'll delete in the subtree undergoing deletion. * we'll delete in the subtree undergoing deletion.
*/ */
Buffer leafbuf; Buffer leafbuf;
IndexTupleData trunctuple; IndexTupleData trunctuple;
Assert(!isleaf); Assert(!isleaf);

View File

@ -2278,7 +2278,7 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid,
/* Log the info */ /* Log the info */
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("MultiXactId wrap limit is %u, limited by database with OID %u", (errmsg_internal("MultiXactId wrap limit is %u, limited by database with OID %u",
multiWrapLimit, oldest_datoid))); multiWrapLimit, oldest_datoid)));
/* /*
* Computing the actual limits is only possible once the data directory is * Computing the actual limits is only possible once the data directory is
@ -2612,7 +2612,7 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown) if (oldestOffsetKnown)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("oldest MultiXactId member is at offset %u", (errmsg_internal("oldest MultiXactId member is at offset %u",
oldestOffset))); oldestOffset)));
else else
ereport(LOG, ereport(LOG,
(errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk", (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
@ -2641,7 +2641,7 @@ SetOffsetVacuumLimit(bool is_startup)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u", (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
offsetStopLimit, oldestMultiXactId))); offsetStopLimit, oldestMultiXactId)));
} }
else if (prevOldestOffsetKnown) else if (prevOldestOffsetKnown)
{ {
@ -3283,9 +3283,9 @@ multixact_redo(XLogReaderState *record)
xlrec->moff + xlrec->nmembers); xlrec->moff + xlrec->nmembers);
/* /*
* Make sure nextXid is beyond any XID mentioned in the record. * Make sure nextXid is beyond any XID mentioned in the record. This
* This should be unnecessary, since any XID found here ought to have * should be unnecessary, since any XID found here ought to have other
* other evidence in the XLOG, but let's be safe. * evidence in the XLOG, but let's be safe.
*/ */
max_xid = XLogRecGetXid(record); max_xid = XLogRecGetXid(record);
for (i = 0; i < xlrec->nmembers; i++) for (i = 0; i < xlrec->nmembers; i++)

View File

@ -1134,9 +1134,9 @@ EndPrepare(GlobalTransaction gxact)
gxact->prepare_start_lsn = ProcLastRecPtr; gxact->prepare_start_lsn = ProcLastRecPtr;
/* /*
* Mark the prepared transaction as valid. As soon as xact.c marks * Mark the prepared transaction as valid. As soon as xact.c marks MyProc
* MyProc as not running our XID (which it will do immediately after * as not running our XID (which it will do immediately after this
* this function returns), others can commit/rollback the xact. * function returns), others can commit/rollback the xact.
* *
* NB: a side effect of this is to make a dummy ProcArray entry for the * NB: a side effect of this is to make a dummy ProcArray entry for the
* prepared XID. This must happen before we clear the XID from MyProc / * prepared XID. This must happen before we clear the XID from MyProc /

View File

@ -179,10 +179,10 @@ GetNewTransactionId(bool isSubXact)
ExtendSUBTRANS(xid); ExtendSUBTRANS(xid);
/* /*
* Now advance the nextXid counter. This must not happen until after * Now advance the nextXid counter. This must not happen until after we
* we have successfully completed ExtendCLOG() --- if that routine fails, * have successfully completed ExtendCLOG() --- if that routine fails, we
* we want the next incoming transaction to try it again. We cannot * want the next incoming transaction to try it again. We cannot assign
* assign more XIDs until there is CLOG space for them. * more XIDs until there is CLOG space for them.
*/ */
FullTransactionIdAdvance(&ShmemVariableCache->nextXid); FullTransactionIdAdvance(&ShmemVariableCache->nextXid);
@ -192,8 +192,8 @@ GetNewTransactionId(bool isSubXact)
* latestCompletedXid is present in the ProcArray, which is essential for * latestCompletedXid is present in the ProcArray, which is essential for
* correct OldestXmin tracking; see src/backend/access/transam/README. * correct OldestXmin tracking; see src/backend/access/transam/README.
* *
* Note that readers of ProcGlobal->xids/PGPROC->xid should be careful * Note that readers of ProcGlobal->xids/PGPROC->xid should be careful to
* to fetch the value for each proc only once, rather than assume they can * fetch the value for each proc only once, rather than assume they can
* read a value multiple times and get the same answer each time. Note we * read a value multiple times and get the same answer each time. Note we
* are assuming that TransactionId and int fetch/store are atomic. * are assuming that TransactionId and int fetch/store are atomic.
* *
@ -281,9 +281,9 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
uint32 epoch; uint32 epoch;
/* /*
* It is safe to read nextXid without a lock, because this is only * It is safe to read nextXid without a lock, because this is only called
* called from the startup process or single-process mode, meaning that no * from the startup process or single-process mode, meaning that no other
* other process can modify it. * process can modify it.
*/ */
Assert(AmStartupProcess() || !IsUnderPostmaster); Assert(AmStartupProcess() || !IsUnderPostmaster);
@ -426,7 +426,7 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
/* Log the info */ /* Log the info */
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("transaction ID wrap limit is %u, limited by database with OID %u", (errmsg_internal("transaction ID wrap limit is %u, limited by database with OID %u",
xidWrapLimit, oldest_datoid))); xidWrapLimit, oldest_datoid)));
/* /*
* If past the autovacuum force point, immediately signal an autovac * If past the autovacuum force point, immediately signal an autovac
@ -617,8 +617,8 @@ AssertTransactionIdInAllowableRange(TransactionId xid)
* We can't acquire XidGenLock, as this may be called with XidGenLock * We can't acquire XidGenLock, as this may be called with XidGenLock
* already held (or with other locks that don't allow XidGenLock to be * already held (or with other locks that don't allow XidGenLock to be
* nested). That's ok for our purposes though, since we already rely on * nested). That's ok for our purposes though, since we already rely on
* 32bit reads to be atomic. While nextXid is 64 bit, we only look at * 32bit reads to be atomic. While nextXid is 64 bit, we only look at the
* the lower 32bit, so a skewed read doesn't hurt. * lower 32bit, so a skewed read doesn't hurt.
* *
* There's no increased danger of falling outside [oldest, next] by * There's no increased danger of falling outside [oldest, next] by
* accessing them without a lock. xid needs to have been created with * accessing them without a lock. xid needs to have been created with

View File

@ -723,7 +723,7 @@ typedef struct XLogCtlData
*/ */
TimestampTz currentChunkStartTime; TimestampTz currentChunkStartTime;
/* Recovery pause state */ /* Recovery pause state */
RecoveryPauseState recoveryPauseState; RecoveryPauseState recoveryPauseState;
ConditionVariable recoveryNotPausedCV; ConditionVariable recoveryNotPausedCV;
/* /*
@ -2858,8 +2858,8 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force)
ereport(DEBUG2, ereport(DEBUG2,
(errmsg_internal("updated min recovery point to %X/%X on timeline %u", (errmsg_internal("updated min recovery point to %X/%X on timeline %u",
LSN_FORMAT_ARGS(minRecoveryPoint), LSN_FORMAT_ARGS(minRecoveryPoint),
newMinRecoveryPointTLI))); newMinRecoveryPointTLI)));
} }
} }
LWLockRelease(ControlFileLock); LWLockRelease(ControlFileLock);
@ -3357,7 +3357,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
blocks = wal_segment_size / XLOG_BLCKSZ; blocks = wal_segment_size / XLOG_BLCKSZ;
for (int i = 0; i < blocks;) for (int i = 0; i < blocks;)
{ {
int iovcnt = Min(blocks - i, lengthof(iov)); int iovcnt = Min(blocks - i, lengthof(iov));
off_t offset = i * XLOG_BLCKSZ; off_t offset = i * XLOG_BLCKSZ;
if (pg_pwritev_with_retry(fd, iov, iovcnt, offset) < 0) if (pg_pwritev_with_retry(fd, iov, iovcnt, offset) < 0)
@ -3814,8 +3814,8 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
* however, unless we actually find a valid segment. That way if there is * however, unless we actually find a valid segment. That way if there is
* neither a timeline history file nor a WAL segment in the archive, and * neither a timeline history file nor a WAL segment in the archive, and
* streaming replication is set up, we'll read the timeline history file * streaming replication is set up, we'll read the timeline history file
* streamed from the primary when we start streaming, instead of recovering * streamed from the primary when we start streaming, instead of
* with a dummy history generated here. * recovering with a dummy history generated here.
*/ */
if (expectedTLEs) if (expectedTLEs)
tles = expectedTLEs; tles = expectedTLEs;
@ -4229,7 +4229,7 @@ RemoveXlogFile(const char *segname, XLogSegNo recycleSegNo,
{ {
ereport(DEBUG2, ereport(DEBUG2,
(errmsg_internal("recycled write-ahead log file \"%s\"", (errmsg_internal("recycled write-ahead log file \"%s\"",
segname))); segname)));
CheckpointStats.ckpt_segs_recycled++; CheckpointStats.ckpt_segs_recycled++;
/* Needn't recheck that slot on future iterations */ /* Needn't recheck that slot on future iterations */
(*endlogSegNo)++; (*endlogSegNo)++;
@ -4241,7 +4241,7 @@ RemoveXlogFile(const char *segname, XLogSegNo recycleSegNo,
ereport(DEBUG2, ereport(DEBUG2,
(errmsg_internal("removing write-ahead log file \"%s\"", (errmsg_internal("removing write-ahead log file \"%s\"",
segname))); segname)));
#ifdef WIN32 #ifdef WIN32
@ -6093,7 +6093,7 @@ recoveryPausesHere(bool endOfRecovery)
RecoveryPauseState RecoveryPauseState
GetRecoveryPauseState(void) GetRecoveryPauseState(void)
{ {
RecoveryPauseState state; RecoveryPauseState state;
SpinLockAcquire(&XLogCtl->info_lck); SpinLockAcquire(&XLogCtl->info_lck);
state = XLogCtl->recoveryPauseState; state = XLogCtl->recoveryPauseState;
@ -6347,7 +6347,11 @@ RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("promotion is not possible because of insufficient parameter settings"), errmsg("promotion is not possible because of insufficient parameter settings"),
/* Repeat the detail from above so it's easy to find in the log. */
/*
* Repeat the detail from above so it's easy to find
* in the log.
*/
errdetail("%s = %d is a lower setting than on the primary server, where its value was %d.", errdetail("%s = %d is a lower setting than on the primary server, where its value was %d.",
param_name, param_name,
currValue, currValue,
@ -6357,15 +6361,15 @@ RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue
} }
/* /*
* If recovery pause is requested then set it paused. While we * If recovery pause is requested then set it paused. While
* are in the loop, user might resume and pause again so set * we are in the loop, user might resume and pause again so
* this every time. * set this every time.
*/ */
ConfirmRecoveryPaused(); ConfirmRecoveryPaused();
/* /*
* We wait on a condition variable that will wake us as soon as * We wait on a condition variable that will wake us as soon
* the pause ends, but we use a timeout so we can check the * as the pause ends, but we use a timeout so we can check the
* above conditions periodically too. * above conditions periodically too.
*/ */
ConditionVariableTimedSleep(&XLogCtl->recoveryNotPausedCV, 1000, ConditionVariableTimedSleep(&XLogCtl->recoveryNotPausedCV, 1000,
@ -6377,7 +6381,7 @@ RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("recovery aborted because of insufficient parameter settings"), errmsg("recovery aborted because of insufficient parameter settings"),
/* Repeat the detail from above so it's easy to find in the log. */ /* Repeat the detail from above so it's easy to find in the log. */
errdetail("%s = %d is a lower setting than on the primary server, where its value was %d.", errdetail("%s = %d is a lower setting than on the primary server, where its value was %d.",
param_name, param_name,
currValue, currValue,
@ -6920,9 +6924,8 @@ StartupXLOG(void)
StartupReorderBuffer(); StartupReorderBuffer();
/* /*
* Startup CLOG. This must be done after ShmemVariableCache->nextXid * Startup CLOG. This must be done after ShmemVariableCache->nextXid has
* has been initialized and before we accept connections or begin WAL * been initialized and before we accept connections or begin WAL replay.
* replay.
*/ */
StartupCLOG(); StartupCLOG();
@ -6969,11 +6972,11 @@ StartupXLOG(void)
* ourselves - the history file of the recovery target timeline covers all * ourselves - the history file of the recovery target timeline covers all
* the previous timelines in the history too - a cascading standby server * the previous timelines in the history too - a cascading standby server
* might be interested in them. Or, if you archive the WAL from this * might be interested in them. Or, if you archive the WAL from this
* server to a different archive than the primary, it'd be good for all the * server to a different archive than the primary, it'd be good for all
* history files to get archived there after failover, so that you can use * the history files to get archived there after failover, so that you can
* one of the old timelines as a PITR target. Timeline history files are * use one of the old timelines as a PITR target. Timeline history files
* small, so it's better to copy them unnecessarily than not copy them and * are small, so it's better to copy them unnecessarily than not copy them
* regret later. * and regret later.
*/ */
restoreTimeLineHistoryFiles(ThisTimeLineID, recoveryTargetTLI); restoreTimeLineHistoryFiles(ThisTimeLineID, recoveryTargetTLI);
@ -7196,9 +7199,9 @@ StartupXLOG(void)
ProcArrayInitRecovery(XidFromFullTransactionId(ShmemVariableCache->nextXid)); ProcArrayInitRecovery(XidFromFullTransactionId(ShmemVariableCache->nextXid));
/* /*
* Startup subtrans only. CLOG, MultiXact and commit * Startup subtrans only. CLOG, MultiXact and commit timestamp
* timestamp have already been started up and other SLRUs are not * have already been started up and other SLRUs are not maintained
* maintained during recovery and need not be started yet. * during recovery and need not be started yet.
*/ */
StartupSUBTRANS(oldestActiveXID); StartupSUBTRANS(oldestActiveXID);
@ -7400,8 +7403,7 @@ StartupXLOG(void)
error_context_stack = &errcallback; error_context_stack = &errcallback;
/* /*
* ShmemVariableCache->nextXid must be beyond record's * ShmemVariableCache->nextXid must be beyond record's xid.
* xid.
*/ */
AdvanceNextFullTransactionIdPastXid(record->xl_xid); AdvanceNextFullTransactionIdPastXid(record->xl_xid);
@ -8092,10 +8094,10 @@ StartupXLOG(void)
WalSndWakeup(); WalSndWakeup();
/* /*
* If this was a promotion, request an (online) checkpoint now. This * If this was a promotion, request an (online) checkpoint now. This isn't
* isn't required for consistency, but the last restartpoint might be far * required for consistency, but the last restartpoint might be far back,
* back, and in case of a crash, recovering from it might take a longer * and in case of a crash, recovering from it might take a longer than is
* than is appropriate now that we're not in standby mode anymore. * appropriate now that we're not in standby mode anymore.
*/ */
if (promoted) if (promoted)
RequestCheckpoint(CHECKPOINT_FORCE); RequestCheckpoint(CHECKPOINT_FORCE);
@ -8674,7 +8676,7 @@ LogCheckpointStart(int flags, bool restartpoint)
{ {
if (restartpoint) if (restartpoint)
ereport(LOG, ereport(LOG,
/* translator: the placeholders show checkpoint options */ /* translator: the placeholders show checkpoint options */
(errmsg("restartpoint starting:%s%s%s%s%s%s%s%s", (errmsg("restartpoint starting:%s%s%s%s%s%s%s%s",
(flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "", (flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "", (flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
@ -8686,7 +8688,7 @@ LogCheckpointStart(int flags, bool restartpoint)
(flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : ""))); (flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : "")));
else else
ereport(LOG, ereport(LOG,
/* translator: the placeholders show checkpoint options */ /* translator: the placeholders show checkpoint options */
(errmsg("checkpoint starting:%s%s%s%s%s%s%s%s", (errmsg("checkpoint starting:%s%s%s%s%s%s%s%s",
(flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "", (flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "", (flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
@ -11851,12 +11853,12 @@ read_backup_label(XLogRecPtr *checkPointLoc, bool *backupEndRequired,
if (fscanf(lfp, "START TIME: %127[^\n]\n", backuptime) == 1) if (fscanf(lfp, "START TIME: %127[^\n]\n", backuptime) == 1)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("backup time %s in file \"%s\"", (errmsg_internal("backup time %s in file \"%s\"",
backuptime, BACKUP_LABEL_FILE))); backuptime, BACKUP_LABEL_FILE)));
if (fscanf(lfp, "LABEL: %1023[^\n]\n", backuplabel) == 1) if (fscanf(lfp, "LABEL: %1023[^\n]\n", backuplabel) == 1)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("backup label %s in file \"%s\"", (errmsg_internal("backup label %s in file \"%s\"",
backuplabel, BACKUP_LABEL_FILE))); backuplabel, BACKUP_LABEL_FILE)));
/* /*
* START TIMELINE is new as of 11. Its parsing is not mandatory, still use * START TIMELINE is new as of 11. Its parsing is not mandatory, still use
@ -11873,7 +11875,7 @@ read_backup_label(XLogRecPtr *checkPointLoc, bool *backupEndRequired,
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("backup timeline %u in file \"%s\"", (errmsg_internal("backup timeline %u in file \"%s\"",
tli_from_file, BACKUP_LABEL_FILE))); tli_from_file, BACKUP_LABEL_FILE)));
} }
if (ferror(lfp) || FreeFile(lfp)) if (ferror(lfp) || FreeFile(lfp))
@ -12177,8 +12179,8 @@ retry:
Assert(readFile != -1); Assert(readFile != -1);
/* /*
* If the current segment is being streamed from the primary, calculate how * If the current segment is being streamed from the primary, calculate
* much of the current page we have received already. We know the * how much of the current page we have received already. We know the
* requested record has been received, but this is for the benefit of * requested record has been received, but this is for the benefit of
* future calls, to allow quick exit at the top of this function. * future calls, to allow quick exit at the top of this function.
*/ */
@ -12239,12 +12241,13 @@ retry:
* and replay reaches a record that's split across two WAL segments. The * and replay reaches a record that's split across two WAL segments. The
* first page is only available locally, in pg_wal, because it's already * first page is only available locally, in pg_wal, because it's already
* been recycled on the primary. The second page, however, is not present * been recycled on the primary. The second page, however, is not present
* in pg_wal, and we should stream it from the primary. There is a recycled * in pg_wal, and we should stream it from the primary. There is a
* WAL segment present in pg_wal, with garbage contents, however. We would * recycled WAL segment present in pg_wal, with garbage contents, however.
* read the first page from the local WAL segment, but when reading the * We would read the first page from the local WAL segment, but when
* second page, we would read the bogus, recycled, WAL segment. If we * reading the second page, we would read the bogus, recycled, WAL
* didn't catch that case here, we would never recover, because * segment. If we didn't catch that case here, we would never recover,
* ReadRecord() would retry reading the whole record from the beginning. * because ReadRecord() would retry reading the whole record from the
* beginning.
* *
* Of course, this only catches errors in the page header, which is what * Of course, this only catches errors in the page header, which is what
* happens in the case of a recycled WAL segment. Other kinds of errors or * happens in the case of a recycled WAL segment. Other kinds of errors or
@ -12399,15 +12402,15 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
* Failure while streaming. Most likely, we got here * Failure while streaming. Most likely, we got here
* because streaming replication was terminated, or * because streaming replication was terminated, or
* promotion was triggered. But we also get here if we * promotion was triggered. But we also get here if we
* find an invalid record in the WAL streamed from the primary, * find an invalid record in the WAL streamed from the
* in which case something is seriously wrong. There's * primary, in which case something is seriously wrong.
* little chance that the problem will just go away, but * There's little chance that the problem will just go
* PANIC is not good for availability either, especially * away, but PANIC is not good for availability either,
* in hot standby mode. So, we treat that the same as * especially in hot standby mode. So, we treat that the
* disconnection, and retry from archive/pg_wal again. The * same as disconnection, and retry from archive/pg_wal
* WAL in the archive should be identical to what was * again. The WAL in the archive should be identical to
* streamed, so it's unlikely that it helps, but one can * what was streamed, so it's unlikely that it helps, but
* hope... * one can hope...
*/ */
/* /*

View File

@ -600,7 +600,7 @@ pg_is_wal_replay_paused(PG_FUNCTION_ARGS)
Datum Datum
pg_get_wal_replay_pause_state(PG_FUNCTION_ARGS) pg_get_wal_replay_pause_state(PG_FUNCTION_ARGS)
{ {
char *statestr = NULL; char *statestr = NULL;
if (!RecoveryInProgress()) if (!RecoveryInProgress())
ereport(ERROR, ereport(ERROR,
@ -609,7 +609,7 @@ pg_get_wal_replay_pause_state(PG_FUNCTION_ARGS)
errhint("Recovery control functions can only be executed during recovery."))); errhint("Recovery control functions can only be executed during recovery.")));
/* get the recovery pause state */ /* get the recovery pause state */
switch(GetRecoveryPauseState()) switch (GetRecoveryPauseState())
{ {
case RECOVERY_NOT_PAUSED: case RECOVERY_NOT_PAUSED:
statestr = "not paused"; statestr = "not paused";

View File

@ -1065,8 +1065,8 @@ log_newpages(RelFileNode *rnode, ForkNumber forkNum, int num_pages,
for (j = batch_start; j < i; j++) for (j = batch_start; j < i; j++)
{ {
/* /*
* The page may be uninitialized. If so, we can't set the LSN because that * The page may be uninitialized. If so, we can't set the LSN
* would corrupt the page. * because that would corrupt the page.
*/ */
if (!PageIsNew(pages[j])) if (!PageIsNew(pages[j]))
{ {

View File

@ -160,7 +160,7 @@ struct typmap
FormData_pg_type am_typ; FormData_pg_type am_typ;
}; };
static List *Typ = NIL; /* List of struct typmap* */ static List *Typ = NIL; /* List of struct typmap* */
static struct typmap *Ap = NULL; static struct typmap *Ap = NULL;
static Datum values[MAXATTR]; /* current row's attribute values */ static Datum values[MAXATTR]; /* current row's attribute values */
@ -926,11 +926,12 @@ gettype(char *type)
{ {
if (Typ != NIL) if (Typ != NIL)
{ {
ListCell *lc; ListCell *lc;
foreach (lc, Typ) foreach(lc, Typ)
{ {
struct typmap *app = lfirst(lc); struct typmap *app = lfirst(lc);
if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0) if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0)
{ {
Ap = app; Ap = app;
@ -948,12 +949,13 @@ gettype(char *type)
populate_typ_list(); populate_typ_list();
/* /*
* Calling gettype would result in infinite recursion for types missing * Calling gettype would result in infinite recursion for types
* in pg_type, so just repeat the lookup. * missing in pg_type, so just repeat the lookup.
*/ */
foreach (lc, Typ) foreach(lc, Typ)
{ {
struct typmap *app = lfirst(lc); struct typmap *app = lfirst(lc);
if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0) if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0)
{ {
Ap = app; Ap = app;
@ -1004,9 +1006,9 @@ boot_get_type_io_data(Oid typid,
{ {
/* We have the boot-time contents of pg_type, so use it */ /* We have the boot-time contents of pg_type, so use it */
struct typmap *ap = NULL; struct typmap *ap = NULL;
ListCell *lc; ListCell *lc;
foreach (lc, Typ) foreach(lc, Typ)
{ {
ap = lfirst(lc); ap = lfirst(lc);
if (ap->am_oid == typid) if (ap->am_oid == typid)

View File

@ -94,18 +94,21 @@ sub ParseHeader
push @{ $catalog{toasting} }, push @{ $catalog{toasting} },
{ parent_table => $1, toast_oid => $2, toast_index_oid => $3 }; { parent_table => $1, toast_oid => $2, toast_index_oid => $3 };
} }
elsif (/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*(\w+),\s*(\d+),\s*(.+)\)/) elsif (
/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*(\w+),\s*(\d+),\s*(.+)\)/)
{ {
push @{ $catalog{indexing} }, push @{ $catalog{indexing} },
{ {
is_unique => $1 ? 1 : 0, is_unique => $1 ? 1 : 0,
is_pkey => $2 ? 1 : 0, is_pkey => $2 ? 1 : 0,
index_name => $3, index_name => $3,
index_oid => $4, index_oid => $4,
index_decl => $5 index_decl => $5
}; };
} }
elsif (/^DECLARE_(ARRAY_)?FOREIGN_KEY(_OPT)?\(\s*\(([^)]+)\),\s*(\w+),\s*\(([^)]+)\)\)/) elsif (
/^DECLARE_(ARRAY_)?FOREIGN_KEY(_OPT)?\(\s*\(([^)]+)\),\s*(\w+),\s*\(([^)]+)\)\)/
)
{ {
push @{ $catalog{foreign_keys} }, push @{ $catalog{foreign_keys} },
{ {

View File

@ -3926,8 +3926,8 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
/* /*
* Check if ACL_SELECT is being checked and, if so, and not set already * Check if ACL_SELECT is being checked and, if so, and not set already as
* as part of the result, then check if the user is a member of the * part of the result, then check if the user is a member of the
* pg_read_all_data role, which allows read access to all relations. * pg_read_all_data role, which allows read access to all relations.
*/ */
if (mask & ACL_SELECT && !(result & ACL_SELECT) && if (mask & ACL_SELECT && !(result & ACL_SELECT) &&
@ -3935,14 +3935,14 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
result |= ACL_SELECT; result |= ACL_SELECT;
/* /*
* Check if ACL_INSERT, ACL_UPDATE, or ACL_DELETE is being checked * Check if ACL_INSERT, ACL_UPDATE, or ACL_DELETE is being checked and, if
* and, if so, and not set already as part of the result, then check * so, and not set already as part of the result, then check if the user
* if the user is a member of the pg_write_all_data role, which * is a member of the pg_write_all_data role, which allows
* allows INSERT/UPDATE/DELETE access to all relations (except * INSERT/UPDATE/DELETE access to all relations (except system catalogs,
* system catalogs, which requires superuser, see above). * which requires superuser, see above).
*/ */
if (mask & (ACL_INSERT | ACL_UPDATE | ACL_DELETE) && if (mask & (ACL_INSERT | ACL_UPDATE | ACL_DELETE) &&
!(result & (ACL_INSERT | ACL_UPDATE | ACL_DELETE)) && !(result & (ACL_INSERT | ACL_UPDATE | ACL_DELETE)) &&
has_privs_of_role(roleid, ROLE_PG_WRITE_ALL_DATA)) has_privs_of_role(roleid, ROLE_PG_WRITE_ALL_DATA))
result |= (mask & (ACL_INSERT | ACL_UPDATE | ACL_DELETE)); result |= (mask & (ACL_INSERT | ACL_UPDATE | ACL_DELETE));
@ -4273,10 +4273,10 @@ pg_namespace_aclmask(Oid nsp_oid, Oid roleid,
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
/* /*
* Check if ACL_USAGE is being checked and, if so, and not set already * Check if ACL_USAGE is being checked and, if so, and not set already as
* as part of the result, then check if the user is a member of the * part of the result, then check if the user is a member of the
* pg_read_all_data or pg_write_all_data roles, which allow usage * pg_read_all_data or pg_write_all_data roles, which allow usage access
* access to all schemas. * to all schemas.
*/ */
if (mask & ACL_USAGE && !(result & ACL_USAGE) && if (mask & ACL_USAGE && !(result & ACL_USAGE) &&
(has_privs_of_role(roleid, ROLE_PG_READ_ALL_DATA) || (has_privs_of_role(roleid, ROLE_PG_READ_ALL_DATA) ||
@ -4568,7 +4568,7 @@ pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum,
*/ */
AclResult AclResult
pg_attribute_aclcheck_ext(Oid table_oid, AttrNumber attnum, pg_attribute_aclcheck_ext(Oid table_oid, AttrNumber attnum,
Oid roleid, AclMode mode, bool *is_missing) Oid roleid, AclMode mode, bool *is_missing)
{ {
if (pg_attribute_aclmask_ext(table_oid, attnum, roleid, mode, if (pg_attribute_aclmask_ext(table_oid, attnum, roleid, mode,
ACLMASK_ANY, is_missing) != 0) ACLMASK_ANY, is_missing) != 0)

View File

@ -1120,7 +1120,7 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
*/ */
ereport(DEBUG2, ereport(DEBUG2,
(errmsg_internal("drop auto-cascades to %s", (errmsg_internal("drop auto-cascades to %s",
objDesc))); objDesc)));
} }
else if (behavior == DROP_RESTRICT) else if (behavior == DROP_RESTRICT)
{ {

View File

@ -786,9 +786,9 @@ close $fk_info;
close $constraints; close $constraints;
# Finally, rename the completed files into place. # Finally, rename the completed files into place.
Catalog::RenameTempFile($bkifile, $tmpext); Catalog::RenameTempFile($bkifile, $tmpext);
Catalog::RenameTempFile($schemafile, $tmpext); Catalog::RenameTempFile($schemafile, $tmpext);
Catalog::RenameTempFile($fk_info_file, $tmpext); Catalog::RenameTempFile($fk_info_file, $tmpext);
Catalog::RenameTempFile($constraints_file, $tmpext); Catalog::RenameTempFile($constraints_file, $tmpext);
exit 0; exit 0;

View File

@ -382,8 +382,8 @@ ConstructTupleDescriptor(Relation heapRelation,
* For expression columns, set attcompression invalid, since * For expression columns, set attcompression invalid, since
* there's no table column from which to copy the value. Whenever * there's no table column from which to copy the value. Whenever
* we actually need to compress a value, we'll use whatever the * we actually need to compress a value, we'll use whatever the
* current value of default_compression_method is at that point * current value of default_compression_method is at that point in
* in time. * time.
*/ */
to->attcompression = InvalidCompressionMethod; to->attcompression = InvalidCompressionMethod;
@ -2927,14 +2927,14 @@ index_build(Relation heapRelation,
if (indexInfo->ii_ParallelWorkers == 0) if (indexInfo->ii_ParallelWorkers == 0)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("building index \"%s\" on table \"%s\" serially", (errmsg_internal("building index \"%s\" on table \"%s\" serially",
RelationGetRelationName(indexRelation), RelationGetRelationName(indexRelation),
RelationGetRelationName(heapRelation)))); RelationGetRelationName(heapRelation))));
else else
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("building index \"%s\" on table \"%s\" with request for %d parallel workers", (errmsg_internal("building index \"%s\" on table \"%s\" with request for %d parallel workers",
RelationGetRelationName(indexRelation), RelationGetRelationName(indexRelation),
RelationGetRelationName(heapRelation), RelationGetRelationName(heapRelation),
indexInfo->ii_ParallelWorkers))); indexInfo->ii_ParallelWorkers)));
/* /*
* Switch to the table owner's userid, so that any index functions are run * Switch to the table owner's userid, so that any index functions are run
@ -3619,8 +3619,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
SetRelationTableSpace(iRel, params->tablespaceOid, InvalidOid); SetRelationTableSpace(iRel, params->tablespaceOid, InvalidOid);
/* /*
* Schedule unlinking of the old index storage at transaction * Schedule unlinking of the old index storage at transaction commit.
* commit.
*/ */
RelationDropStorage(iRel); RelationDropStorage(iRel);
RelationAssumeNewRelfilenode(iRel); RelationAssumeNewRelfilenode(iRel);

View File

@ -96,7 +96,8 @@
*/ */
typedef struct typedef struct
{ {
const char *class_descr; /* string describing the catalog, for internal error messages */ const char *class_descr; /* string describing the catalog, for internal
* error messages */
Oid class_oid; /* oid of catalog */ Oid class_oid; /* oid of catalog */
Oid oid_index_oid; /* oid of index on system oid column */ Oid oid_index_oid; /* oid of index on system oid column */
int oid_catcache_id; /* id of catcache on system oid column */ int oid_catcache_id; /* id of catcache on system oid column */
@ -2871,6 +2872,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
char *attname = get_attname(object->objectId, char *attname = get_attname(object->objectId,
object->objectSubId, object->objectSubId,
missing_ok); missing_ok);
if (!attname) if (!attname)
break; break;
@ -2888,6 +2890,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
bits16 flags = FORMAT_PROC_INVALID_AS_NULL; bits16 flags = FORMAT_PROC_INVALID_AS_NULL;
char *proname = format_procedure_extended(object->objectId, char *proname = format_procedure_extended(object->objectId,
flags); flags);
if (proname == NULL) if (proname == NULL)
break; break;
@ -2900,6 +2903,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
bits16 flags = FORMAT_TYPE_INVALID_AS_NULL; bits16 flags = FORMAT_TYPE_INVALID_AS_NULL;
char *typname = format_type_extended(object->objectId, -1, char *typname = format_type_extended(object->objectId, -1,
flags); flags);
if (typname == NULL) if (typname == NULL)
break; break;
@ -3861,6 +3865,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
{ {
char *pubname = get_publication_name(object->objectId, char *pubname = get_publication_name(object->objectId,
missing_ok); missing_ok);
if (pubname) if (pubname)
appendStringInfo(&buffer, _("publication %s"), pubname); appendStringInfo(&buffer, _("publication %s"), pubname);
break; break;
@ -3901,6 +3906,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
{ {
char *subname = get_subscription_name(object->objectId, char *subname = get_subscription_name(object->objectId,
missing_ok); missing_ok);
if (subname) if (subname)
appendStringInfo(&buffer, _("subscription %s"), subname); appendStringInfo(&buffer, _("subscription %s"), subname);
break; break;
@ -4708,6 +4714,7 @@ getObjectIdentityParts(const ObjectAddress *object,
bits16 flags = FORMAT_PROC_FORCE_QUALIFY | FORMAT_PROC_INVALID_AS_NULL; bits16 flags = FORMAT_PROC_FORCE_QUALIFY | FORMAT_PROC_INVALID_AS_NULL;
char *proname = format_procedure_extended(object->objectId, char *proname = format_procedure_extended(object->objectId,
flags); flags);
if (proname == NULL) if (proname == NULL)
break; break;
@ -4957,6 +4964,7 @@ getObjectIdentityParts(const ObjectAddress *object,
bits16 flags = FORMAT_OPERATOR_FORCE_QUALIFY | FORMAT_OPERATOR_INVALID_AS_NULL; bits16 flags = FORMAT_OPERATOR_FORCE_QUALIFY | FORMAT_OPERATOR_INVALID_AS_NULL;
char *oprname = format_operator_extended(object->objectId, char *oprname = format_operator_extended(object->objectId,
flags); flags);
if (oprname == NULL) if (oprname == NULL)
break; break;

View File

@ -578,7 +578,7 @@ DeleteInheritsTuple(Oid inhrelid, Oid inhparent, bool expect_detach_pending,
parent = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhparent; parent = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhparent;
if (!OidIsValid(inhparent) || parent == inhparent) if (!OidIsValid(inhparent) || parent == inhparent)
{ {
bool detach_pending; bool detach_pending;
detach_pending = detach_pending =
((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending; ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending;
@ -640,7 +640,7 @@ PartitionHasPendingDetach(Oid partoid)
while (HeapTupleIsValid(inheritsTuple = systable_getnext(scan))) while (HeapTupleIsValid(inheritsTuple = systable_getnext(scan)))
{ {
bool detached; bool detached;
detached = detached =
((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending; ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending;

View File

@ -903,10 +903,10 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
else else
{ {
/* /*
* We can't do full prechecking of the function definition if there * We can't do full prechecking of the function definition if
* are any polymorphic input types, because actual datatypes of * there are any polymorphic input types, because actual datatypes
* expression results will be unresolvable. The check will be done at * of expression results will be unresolvable. The check will be
* runtime instead. * done at runtime instead.
* *
* We can run the text through the raw parser though; this will at * We can run the text through the raw parser though; this will at
* least catch silly syntactic errors. * least catch silly syntactic errors.
@ -917,8 +917,8 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
if (!haspolyarg) if (!haspolyarg)
{ {
/* /*
* OK to do full precheck: analyze and rewrite the queries, then * OK to do full precheck: analyze and rewrite the queries,
* verify the result type. * then verify the result type.
*/ */
SQLFunctionParseInfoPtr pinfo; SQLFunctionParseInfoPtr pinfo;

View File

@ -361,7 +361,7 @@ void
recordDependencyOnTablespace(Oid classId, Oid objectId, Oid tablespace) recordDependencyOnTablespace(Oid classId, Oid objectId, Oid tablespace)
{ {
ObjectAddress myself, ObjectAddress myself,
referenced; referenced;
ObjectAddressSet(myself, classId, objectId); ObjectAddressSet(myself, classId, objectId);
ObjectAddressSet(referenced, TableSpaceRelationId, tablespace); ObjectAddressSet(referenced, TableSpaceRelationId, tablespace);

View File

@ -433,6 +433,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
get_subscription_name(subrel->srsubid, false)), get_subscription_name(subrel->srsubid, false)),
errdetail("Table synchronization for relation \"%s\" is in progress and is in state \"%c\".", errdetail("Table synchronization for relation \"%s\" is in progress and is in state \"%c\".",
get_rel_name(relid), subrel->srsubstate), get_rel_name(relid), subrel->srsubstate),
/* /*
* translator: first %s is a SQL ALTER command and second %s is a * translator: first %s is a SQL ALTER command and second %s is a
* SQL DROP command * SQL DROP command

View File

@ -351,9 +351,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
table_close(class_rel, RowExclusiveLock); table_close(class_rel, RowExclusiveLock);
/* /*
* Register dependency from the toast table to the main, so that the * Register dependency from the toast table to the main, so that the toast
* toast table will be deleted if the main is. Skip this in bootstrap * table will be deleted if the main is. Skip this in bootstrap mode.
* mode.
*/ */
if (!IsBootstrapProcessingMode()) if (!IsBootstrapProcessingMode())
{ {
@ -396,9 +395,9 @@ needs_toast_table(Relation rel)
/* /*
* Ignore attempts to create toast tables on catalog tables after initdb. * Ignore attempts to create toast tables on catalog tables after initdb.
* Which catalogs get toast tables is explicitly chosen in * Which catalogs get toast tables is explicitly chosen in catalog/pg_*.h.
* catalog/pg_*.h. (We could get here via some ALTER TABLE command if * (We could get here via some ALTER TABLE command if the catalog doesn't
* the catalog doesn't have a toast table.) * have a toast table.)
*/ */
if (IsCatalogRelation(rel) && !IsBootstrapProcessingMode()) if (IsCatalogRelation(rel) && !IsBootstrapProcessingMode())
return false; return false;

View File

@ -617,11 +617,10 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
* *
* We assume that VACUUM hasn't set pg_class.reltuples already, even * We assume that VACUUM hasn't set pg_class.reltuples already, even
* during a VACUUM ANALYZE. Although VACUUM often updates pg_class, * during a VACUUM ANALYZE. Although VACUUM often updates pg_class,
* exceptions exist. A "VACUUM (ANALYZE, INDEX_CLEANUP OFF)" command * exceptions exist. A "VACUUM (ANALYZE, INDEX_CLEANUP OFF)" command will
* will never update pg_class entries for index relations. It's also * never update pg_class entries for index relations. It's also possible
* possible that an individual index's pg_class entry won't be updated * that an individual index's pg_class entry won't be updated during
* during VACUUM if the index AM returns NULL from its amvacuumcleanup() * VACUUM if the index AM returns NULL from its amvacuumcleanup() routine.
* routine.
*/ */
if (!inh) if (!inh)
{ {
@ -659,9 +658,9 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
else if (onerel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) else if (onerel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{ {
/* /*
* Partitioned tables don't have storage, so we don't set any fields in * Partitioned tables don't have storage, so we don't set any fields
* their pg_class entries except for reltuples, which is necessary for * in their pg_class entries except for reltuples, which is necessary
* auto-analyze to work properly. * for auto-analyze to work properly.
*/ */
vac_update_relstats(onerel, -1, totalrows, vac_update_relstats(onerel, -1, totalrows,
0, false, InvalidTransactionId, 0, false, InvalidTransactionId,

View File

@ -104,7 +104,7 @@ typedef struct CopyToStateData
typedef struct typedef struct
{ {
DestReceiver pub; /* publicly-known function pointers */ DestReceiver pub; /* publicly-known function pointers */
CopyToState cstate; /* CopyToStateData for the command */ CopyToState cstate; /* CopyToStateData for the command */
uint64 processed; /* # of tuples processed */ uint64 processed; /* # of tuples processed */
} DR_copy; } DR_copy;
@ -348,7 +348,7 @@ BeginCopyTo(ParseState *pstate,
List *attnamelist, List *attnamelist,
List *options) List *options)
{ {
CopyToState cstate; CopyToState cstate;
bool pipe = (filename == NULL); bool pipe = (filename == NULL);
TupleDesc tupDesc; TupleDesc tupDesc;
int num_phys_attrs; int num_phys_attrs;
@ -415,7 +415,7 @@ BeginCopyTo(ParseState *pstate,
oldcontext = MemoryContextSwitchTo(cstate->copycontext); oldcontext = MemoryContextSwitchTo(cstate->copycontext);
/* Extract options from the statement node tree */ /* Extract options from the statement node tree */
ProcessCopyOptions(pstate, &cstate->opts, false /* is_from */, options); ProcessCopyOptions(pstate, &cstate->opts, false /* is_from */ , options);
/* Process the source/target relation or query */ /* Process the source/target relation or query */
if (rel) if (rel)
@ -793,7 +793,7 @@ DoCopyTo(CopyToState cstate)
else else
tupDesc = cstate->queryDesc->tupDesc; tupDesc = cstate->queryDesc->tupDesc;
num_phys_attrs = tupDesc->natts; num_phys_attrs = tupDesc->natts;
cstate->opts.null_print_client = cstate->opts.null_print; /* default */ cstate->opts.null_print_client = cstate->opts.null_print; /* default */
/* We use fe_msgbuf as a per-row buffer regardless of copy_dest */ /* We use fe_msgbuf as a per-row buffer regardless of copy_dest */
cstate->fe_msgbuf = makeStringInfo(); cstate->fe_msgbuf = makeStringInfo();
@ -850,8 +850,8 @@ DoCopyTo(CopyToState cstate)
*/ */
if (cstate->need_transcoding) if (cstate->need_transcoding)
cstate->opts.null_print_client = pg_server_to_any(cstate->opts.null_print, cstate->opts.null_print_client = pg_server_to_any(cstate->opts.null_print,
cstate->opts.null_print_len, cstate->opts.null_print_len,
cstate->file_encoding); cstate->file_encoding);
/* if a header has been requested send the line */ /* if a header has been requested send the line */
if (cstate->opts.header_line) if (cstate->opts.header_line)
@ -1265,7 +1265,7 @@ static bool
copy_dest_receive(TupleTableSlot *slot, DestReceiver *self) copy_dest_receive(TupleTableSlot *slot, DestReceiver *self)
{ {
DR_copy *myState = (DR_copy *) self; DR_copy *myState = (DR_copy *) self;
CopyToState cstate = myState->cstate; CopyToState cstate = myState->cstate;
/* Send the data */ /* Send the data */
CopyOneRowTo(cstate, slot); CopyOneRowTo(cstate, slot);

View File

@ -167,7 +167,7 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt,
ExplainState *es = NewExplainState(); ExplainState *es = NewExplainState();
TupOutputState *tstate; TupOutputState *tstate;
JumbleState *jstate = NULL; JumbleState *jstate = NULL;
Query *query; Query *query;
List *rewritten; List *rewritten;
ListCell *lc; ListCell *lc;
bool timing_set = false; bool timing_set = false;
@ -458,7 +458,7 @@ ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es,
else if (ctas->objtype == OBJECT_MATVIEW) else if (ctas->objtype == OBJECT_MATVIEW)
ExplainDummyGroup("CREATE MATERIALIZED VIEW", NULL, es); ExplainDummyGroup("CREATE MATERIALIZED VIEW", NULL, es);
else else
elog(ERROR, "unexpected object type: %d", elog(ERROR, "unexpected object type: %d",
(int) ctas->objtype); (int) ctas->objtype);
return; return;
} }
@ -612,7 +612,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
if (es->verbose && plannedstmt->queryId != UINT64CONST(0)) if (es->verbose && plannedstmt->queryId != UINT64CONST(0))
{ {
char buf[MAXINT8LEN+1]; char buf[MAXINT8LEN + 1];
pg_lltoa(plannedstmt->queryId, buf); pg_lltoa(plannedstmt->queryId, buf);
ExplainPropertyText("Query Identifier", buf, es); ExplainPropertyText("Query Identifier", buf, es);
@ -3298,7 +3298,7 @@ show_hashagg_info(AggState *aggstate, ExplainState *es)
if (aggstate->hash_batches_used > 1) if (aggstate->hash_batches_used > 1)
{ {
appendStringInfo(es->str, " Disk Usage: " UINT64_FORMAT "kB", appendStringInfo(es->str, " Disk Usage: " UINT64_FORMAT "kB",
aggstate->hash_disk_used); aggstate->hash_disk_used);
} }
} }

View File

@ -3293,8 +3293,8 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
case OBJECT_SUBSCRIPTION: case OBJECT_SUBSCRIPTION:
case OBJECT_TABLESPACE: case OBJECT_TABLESPACE:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("cannot add an object of this type to an extension"))); errmsg("cannot add an object of this type to an extension")));
break; break;
default: default:
/* OK */ /* OK */

View File

@ -1086,9 +1086,9 @@ DefineIndex(Oid relationId,
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("%s %s will create implicit index \"%s\" for table \"%s\"", (errmsg_internal("%s %s will create implicit index \"%s\" for table \"%s\"",
is_alter_table ? "ALTER TABLE / ADD" : "CREATE TABLE /", is_alter_table ? "ALTER TABLE / ADD" : "CREATE TABLE /",
constraint_type, constraint_type,
indexRelationName, RelationGetRelationName(rel)))); indexRelationName, RelationGetRelationName(rel))));
} }
/* /*

View File

@ -628,7 +628,7 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
InvalidXLogRecPtr); InvalidXLogRecPtr);
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("table \"%s.%s\" added to subscription \"%s\"", (errmsg_internal("table \"%s.%s\" added to subscription \"%s\"",
rv->schemaname, rv->relname, sub->name))); rv->schemaname, rv->relname, sub->name)));
} }
} }
@ -702,9 +702,9 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("table \"%s.%s\" removed from subscription \"%s\"", (errmsg_internal("table \"%s.%s\" removed from subscription \"%s\"",
get_namespace_name(get_rel_namespace(relid)), get_namespace_name(get_rel_namespace(relid)),
get_rel_name(relid), get_rel_name(relid),
sub->name))); sub->name)));
} }
} }

View File

@ -563,7 +563,7 @@ static void ATExecGenericOptions(Relation rel, List *options);
static void ATExecSetRowSecurity(Relation rel, bool rls); static void ATExecSetRowSecurity(Relation rel, bool rls);
static void ATExecForceNoForceRowSecurity(Relation rel, bool force_rls); static void ATExecForceNoForceRowSecurity(Relation rel, bool force_rls);
static ObjectAddress ATExecSetCompression(AlteredTableInfo *tab, Relation rel, static ObjectAddress ATExecSetCompression(AlteredTableInfo *tab, Relation rel,
const char *column, Node *newValue, LOCKMODE lockmode); const char *column, Node *newValue, LOCKMODE lockmode);
static void index_copy_data(Relation rel, RelFileNode newrnode); static void index_copy_data(Relation rel, RelFileNode newrnode);
static const char *storage_name(char c); static const char *storage_name(char c);
@ -2593,7 +2593,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
if (CompressionMethodIsValid(attribute->attcompression)) if (CompressionMethodIsValid(attribute->attcompression))
{ {
const char *compression = const char *compression =
GetCompressionMethodName(attribute->attcompression); GetCompressionMethodName(attribute->attcompression);
if (def->compression == NULL) if (def->compression == NULL)
def->compression = pstrdup(compression); def->compression = pstrdup(compression);
@ -2641,7 +2641,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
def->location = -1; def->location = -1;
if (CompressionMethodIsValid(attribute->attcompression)) if (CompressionMethodIsValid(attribute->attcompression))
def->compression = pstrdup(GetCompressionMethodName( def->compression = pstrdup(GetCompressionMethodName(
attribute->attcompression)); attribute->attcompression));
else else
def->compression = NULL; def->compression = NULL;
inhSchema = lappend(inhSchema, def); inhSchema = lappend(inhSchema, def);
@ -4524,7 +4524,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
/* No command-specific prep needed */ /* No command-specific prep needed */
pass = AT_PASS_MISC; pass = AT_PASS_MISC;
break; break;
case AT_SetCompression: /* ALTER COLUMN SET COMPRESSION */ case AT_SetCompression: /* ALTER COLUMN SET COMPRESSION */
ATSimplePermissions(rel, ATT_TABLE | ATT_MATVIEW); ATSimplePermissions(rel, ATT_TABLE | ATT_MATVIEW);
/* This command never recurses */ /* This command never recurses */
/* No command-specific prep needed */ /* No command-specific prep needed */
@ -5666,11 +5666,11 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
if (newrel) if (newrel)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("rewriting table \"%s\"", (errmsg_internal("rewriting table \"%s\"",
RelationGetRelationName(oldrel)))); RelationGetRelationName(oldrel))));
else else
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("verifying table \"%s\"", (errmsg_internal("verifying table \"%s\"",
RelationGetRelationName(oldrel)))); RelationGetRelationName(oldrel))));
if (newrel) if (newrel)
{ {
@ -7297,7 +7297,7 @@ NotNullImpliedByRelConstraints(Relation rel, Form_pg_attribute attr)
{ {
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("existing constraints on column \"%s.%s\" are sufficient to prove that it does not contain nulls", (errmsg_internal("existing constraints on column \"%s.%s\" are sufficient to prove that it does not contain nulls",
RelationGetRelationName(rel), NameStr(attr->attname)))); RelationGetRelationName(rel), NameStr(attr->attname))));
return true; return true;
} }
@ -12876,7 +12876,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
} }
else if (IsA(stm, CreateStatsStmt)) else if (IsA(stm, CreateStatsStmt))
{ {
CreateStatsStmt *stmt = (CreateStatsStmt *) stm; CreateStatsStmt *stmt = (CreateStatsStmt *) stm;
AlterTableCmd *newcmd; AlterTableCmd *newcmd;
/* keep the statistics object's comment */ /* keep the statistics object's comment */
@ -14539,9 +14539,9 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
if (strcmp(child_expr, parent_expr) != 0) if (strcmp(child_expr, parent_expr) != 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("column \"%s\" in child table has a conflicting generation expression", errmsg("column \"%s\" in child table has a conflicting generation expression",
attributeName))); attributeName)));
} }
/* /*
@ -14769,7 +14769,7 @@ static void
MarkInheritDetached(Relation child_rel, Relation parent_rel) MarkInheritDetached(Relation child_rel, Relation parent_rel)
{ {
Relation catalogRelation; Relation catalogRelation;
SysScanDesc scan; SysScanDesc scan;
ScanKeyData key; ScanKeyData key;
HeapTuple inheritsTuple; HeapTuple inheritsTuple;
bool found = false; bool found = false;
@ -15645,7 +15645,7 @@ ATExecSetCompression(AlteredTableInfo *tab,
if (!IsStorageCompressible(typstorage)) if (!IsStorageCompressible(typstorage))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("column data type %s does not support compression", errmsg("column data type %s does not support compression",
format_type_be(atttableform->atttypid)))); format_type_be(atttableform->atttypid))));
/* get the attribute compression method. */ /* get the attribute compression method. */
@ -17010,11 +17010,11 @@ QueuePartitionConstraintValidation(List **wqueue, Relation scanrel,
if (!validate_default) if (!validate_default)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("partition constraint for table \"%s\" is implied by existing constraints", (errmsg_internal("partition constraint for table \"%s\" is implied by existing constraints",
RelationGetRelationName(scanrel)))); RelationGetRelationName(scanrel))));
else else
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("updated partition constraint for default partition \"%s\" is implied by existing constraints", (errmsg_internal("updated partition constraint for default partition \"%s\" is implied by existing constraints",
RelationGetRelationName(scanrel)))); RelationGetRelationName(scanrel))));
return; return;
} }
@ -17745,8 +17745,8 @@ ATExecDetachPartition(List **wqueue, AlteredTableInfo *tab, Relation rel,
AccessExclusiveLock); AccessExclusiveLock);
/* /*
* Check inheritance conditions and either delete the pg_inherits row * Check inheritance conditions and either delete the pg_inherits row (in
* (in non-concurrent mode) or just set the inhdetachpending flag. * non-concurrent mode) or just set the inhdetachpending flag.
*/ */
if (!concurrent) if (!concurrent)
RemoveInheritance(partRel, rel, false); RemoveInheritance(partRel, rel, false);
@ -17771,11 +17771,11 @@ ATExecDetachPartition(List **wqueue, AlteredTableInfo *tab, Relation rel,
*/ */
if (concurrent) if (concurrent)
{ {
Oid partrelid, Oid partrelid,
parentrelid; parentrelid;
LOCKTAG tag; LOCKTAG tag;
char *parentrelname; char *parentrelname;
char *partrelname; char *partrelname;
/* /*
* Add a new constraint to the partition being detached, which * Add a new constraint to the partition being detached, which
@ -17815,10 +17815,10 @@ ATExecDetachPartition(List **wqueue, AlteredTableInfo *tab, Relation rel,
StartTransactionCommand(); StartTransactionCommand();
/* /*
* Now wait. This ensures that all queries that were planned including * Now wait. This ensures that all queries that were planned
* the partition are finished before we remove the rest of catalog * including the partition are finished before we remove the rest of
* entries. We don't need or indeed want to acquire this lock, though * catalog entries. We don't need or indeed want to acquire this
* -- that would block later queries. * lock, though -- that would block later queries.
* *
* We don't need to concern ourselves with waiting for a lock on the * We don't need to concern ourselves with waiting for a lock on the
* partition itself, since we will acquire AccessExclusiveLock below. * partition itself, since we will acquire AccessExclusiveLock below.
@ -18046,7 +18046,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
static ObjectAddress static ObjectAddress
ATExecDetachPartitionFinalize(Relation rel, RangeVar *name) ATExecDetachPartitionFinalize(Relation rel, RangeVar *name)
{ {
Relation partRel; Relation partRel;
ObjectAddress address; ObjectAddress address;
Snapshot snap = GetActiveSnapshot(); Snapshot snap = GetActiveSnapshot();

View File

@ -4353,7 +4353,7 @@ GetAfterTriggersStoreSlot(AfterTriggersTableData *table,
/* Create it if not already done. */ /* Create it if not already done. */
if (!table->storeslot) if (!table->storeslot)
{ {
MemoryContext oldcxt; MemoryContext oldcxt;
/* /*
* We only need this slot only until AfterTriggerEndQuery, but making * We only need this slot only until AfterTriggerEndQuery, but making

View File

@ -1569,7 +1569,7 @@ DefineRange(CreateRangeStmt *stmt)
/* Create the multirange that goes with it */ /* Create the multirange that goes with it */
if (multirangeTypeName) if (multirangeTypeName)
{ {
Oid old_typoid; Oid old_typoid;
/* /*
* Look to see if multirange type already exists. * Look to see if multirange type already exists.
@ -1579,8 +1579,8 @@ DefineRange(CreateRangeStmt *stmt)
ObjectIdGetDatum(multirangeNamespace)); ObjectIdGetDatum(multirangeNamespace));
/* /*
* If it's not a shell, see if it's an autogenerated array type, and if so * If it's not a shell, see if it's an autogenerated array type, and
* rename it out of the way. * if so rename it out of the way.
*/ */
if (OidIsValid(old_typoid) && get_typisdefined(old_typoid)) if (OidIsValid(old_typoid) && get_typisdefined(old_typoid))
{ {
@ -1600,7 +1600,7 @@ DefineRange(CreateRangeStmt *stmt)
mltrngaddress = mltrngaddress =
TypeCreate(multirangeOid, /* force assignment of this type OID */ TypeCreate(multirangeOid, /* force assignment of this type OID */
multirangeTypeName, /* type name */ multirangeTypeName, /* type name */
multirangeNamespace, /* namespace */ multirangeNamespace, /* namespace */
InvalidOid, /* relation oid (n/a here) */ InvalidOid, /* relation oid (n/a here) */
0, /* relation kind (ditto) */ 0, /* relation kind (ditto) */
GetUserId(), /* owner's ID */ GetUserId(), /* owner's ID */
@ -1682,7 +1682,7 @@ DefineRange(CreateRangeStmt *stmt)
TypeCreate(multirangeArrayOid, /* force assignment of this type OID */ TypeCreate(multirangeArrayOid, /* force assignment of this type OID */
multirangeArrayName, /* type name */ multirangeArrayName, /* type name */
multirangeNamespace, /* namespace */ multirangeNamespace, /* namespace */
InvalidOid, /* relation oid (n/a here) */ InvalidOid, /* relation oid (n/a here) */
0, /* relation kind (ditto) */ 0, /* relation kind (ditto) */
GetUserId(), /* owner's ID */ GetUserId(), /* owner's ID */
@ -1844,7 +1844,7 @@ makeMultirangeConstructors(const char *name, Oid namespace,
PROKIND_FUNCTION, PROKIND_FUNCTION,
false, /* security_definer */ false, /* security_definer */
false, /* leakproof */ false, /* leakproof */
true, /* isStrict */ true, /* isStrict */
PROVOLATILE_IMMUTABLE, /* volatility */ PROVOLATILE_IMMUTABLE, /* volatility */
PROPARALLEL_SAFE, /* parallel safety */ PROPARALLEL_SAFE, /* parallel safety */
argtypes, /* parameterTypes */ argtypes, /* parameterTypes */
@ -1929,7 +1929,7 @@ makeMultirangeConstructors(const char *name, Oid namespace,
PROKIND_FUNCTION, PROKIND_FUNCTION,
false, /* security_definer */ false, /* security_definer */
false, /* leakproof */ false, /* leakproof */
true, /* isStrict */ true, /* isStrict */
PROVOLATILE_IMMUTABLE, /* volatility */ PROVOLATILE_IMMUTABLE, /* volatility */
PROPARALLEL_SAFE, /* parallel safety */ PROPARALLEL_SAFE, /* parallel safety */
argtypes, /* parameterTypes */ argtypes, /* parameterTypes */

View File

@ -1173,8 +1173,8 @@ vacuum_xid_failsafe_check(TransactionId relfrozenxid, MultiXactId relminmxid)
/* /*
* Similar to above, determine the index skipping age to use for * Similar to above, determine the index skipping age to use for
* multixact. In any case no less than autovacuum_multixact_freeze_max_age * multixact. In any case no less than autovacuum_multixact_freeze_max_age *
* * 1.05. * 1.05.
*/ */
skip_index_vacuum = Max(vacuum_multixact_failsafe_age, skip_index_vacuum = Max(vacuum_multixact_failsafe_age,
autovacuum_multixact_freeze_max_age * 1.05); autovacuum_multixact_freeze_max_age * 1.05);

View File

@ -427,6 +427,7 @@ ExecSupportsMarkRestore(Path *pathnode)
{ {
case T_IndexScan: case T_IndexScan:
case T_IndexOnlyScan: case T_IndexOnlyScan:
/* /*
* Not all index types support mark/restore. * Not all index types support mark/restore.
*/ */

View File

@ -26,7 +26,7 @@ void
ExecAsyncRequest(AsyncRequest *areq) ExecAsyncRequest(AsyncRequest *areq)
{ {
if (areq->requestee->chgParam != NULL) /* something changed? */ if (areq->requestee->chgParam != NULL) /* something changed? */
ExecReScan(areq->requestee); /* let ReScan handle this */ ExecReScan(areq->requestee); /* let ReScan handle this */
/* must provide our own instrumentation support */ /* must provide our own instrumentation support */
if (areq->requestee->instrument) if (areq->requestee->instrument)
@ -124,7 +124,7 @@ ExecAsyncResponse(AsyncRequest *areq)
default: default:
/* If the node doesn't support async, caller messed up. */ /* If the node doesn't support async, caller messed up. */
elog(ERROR, "unrecognized node type: %d", elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(areq->requestor)); (int) nodeTag(areq->requestor));
} }
} }

View File

@ -132,8 +132,8 @@ ExecutorStart(QueryDesc *queryDesc, int eflags)
/* /*
* In some cases (e.g. an EXECUTE statement) a query execution will skip * In some cases (e.g. an EXECUTE statement) a query execution will skip
* parse analysis, which means that the query_id won't be reported. Note * parse analysis, which means that the query_id won't be reported. Note
* that it's harmless to report the query_id multiple time, as the call will * that it's harmless to report the query_id multiple time, as the call
* be ignored if the top level query_id has already been reported. * will be ignored if the top level query_id has already been reported.
*/ */
pgstat_report_query_id(queryDesc->plannedstmt->queryId, false); pgstat_report_query_id(queryDesc->plannedstmt->queryId, false);

View File

@ -917,8 +917,8 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
partRelInfo->ri_FdwRoutine->BeginForeignInsert(mtstate, partRelInfo); partRelInfo->ri_FdwRoutine->BeginForeignInsert(mtstate, partRelInfo);
/* /*
* Determine if the FDW supports batch insert and determine the batch * Determine if the FDW supports batch insert and determine the batch size
* size (a FDW may support batching, but it may be disabled for the * (a FDW may support batching, but it may be disabled for the
* server/table or for this particular query). * server/table or for this particular query).
* *
* If the FDW does not support batching, we set the batch size to 1. * If the FDW does not support batching, we set the batch size to 1.

View File

@ -349,7 +349,7 @@ typedef struct HashAggSpill
int64 *ntuples; /* number of tuples in each partition */ int64 *ntuples; /* number of tuples in each partition */
uint32 mask; /* mask to find partition from hash value */ uint32 mask; /* mask to find partition from hash value */
int shift; /* after masking, shift by this amount */ int shift; /* after masking, shift by this amount */
hyperLogLogState *hll_card; /* cardinality estimate for contents */ hyperLogLogState *hll_card; /* cardinality estimate for contents */
} HashAggSpill; } HashAggSpill;
/* /*
@ -374,9 +374,9 @@ typedef struct HashAggBatch
/* used to find referenced colnos */ /* used to find referenced colnos */
typedef struct FindColsContext typedef struct FindColsContext
{ {
bool is_aggref; /* is under an aggref */ bool is_aggref; /* is under an aggref */
Bitmapset *aggregated; /* column references under an aggref */ Bitmapset *aggregated; /* column references under an aggref */
Bitmapset *unaggregated; /* other column references */ Bitmapset *unaggregated; /* other column references */
} FindColsContext; } FindColsContext;
static void select_current_set(AggState *aggstate, int setno, bool is_hash); static void select_current_set(AggState *aggstate, int setno, bool is_hash);
@ -1397,7 +1397,7 @@ project_aggregates(AggState *aggstate)
static void static void
find_cols(AggState *aggstate, Bitmapset **aggregated, Bitmapset **unaggregated) find_cols(AggState *aggstate, Bitmapset **aggregated, Bitmapset **unaggregated)
{ {
Agg *agg = (Agg *) aggstate->ss.ps.plan; Agg *agg = (Agg *) aggstate->ss.ps.plan;
FindColsContext context; FindColsContext context;
context.is_aggref = false; context.is_aggref = false;
@ -1579,7 +1579,8 @@ find_hash_columns(AggState *aggstate)
for (int i = 0; i < scanDesc->natts; i++) for (int i = 0; i < scanDesc->natts; i++)
{ {
int colno = i + 1; int colno = i + 1;
if (bms_is_member(colno, aggstate->colnos_needed)) if (bms_is_member(colno, aggstate->colnos_needed))
aggstate->max_colno_needed = colno; aggstate->max_colno_needed = colno;
else else
@ -3158,10 +3159,10 @@ hashagg_spill_finish(AggState *aggstate, HashAggSpill *spill, int setno)
for (i = 0; i < spill->npartitions; i++) for (i = 0; i < spill->npartitions; i++)
{ {
LogicalTapeSet *tapeset = aggstate->hash_tapeinfo->tapeset; LogicalTapeSet *tapeset = aggstate->hash_tapeinfo->tapeset;
int tapenum = spill->partitions[i]; int tapenum = spill->partitions[i];
HashAggBatch *new_batch; HashAggBatch *new_batch;
double cardinality; double cardinality;
/* if the partition is empty, don't create a new batch of work */ /* if the partition is empty, don't create a new batch of work */
if (spill->ntuples[i] == 0) if (spill->ntuples[i] == 0)

View File

@ -566,9 +566,9 @@ choose_next_subplan_locally(AppendState *node)
/* /*
* If first call then have the bms member function choose the first valid * If first call then have the bms member function choose the first valid
* sync subplan by initializing whichplan to -1. If there happen to be * sync subplan by initializing whichplan to -1. If there happen to be no
* no valid sync subplans then the bms member function will handle that * valid sync subplans then the bms member function will handle that by
* by returning a negative number which will allow us to exit returning a * returning a negative number which will allow us to exit returning a
* false value. * false value.
*/ */
if (whichplan == INVALID_SUBPLAN_INDEX) if (whichplan == INVALID_SUBPLAN_INDEX)
@ -925,8 +925,8 @@ ExecAppendAsyncGetNext(AppendState *node, TupleTableSlot **result)
/* /*
* If all sync subplans are complete, we're totally done scanning the * If all sync subplans are complete, we're totally done scanning the
* given node. Otherwise, we're done with the asynchronous stuff but * given node. Otherwise, we're done with the asynchronous stuff but must
* must continue scanning the sync subplans. * continue scanning the sync subplans.
*/ */
if (node->as_syncdone) if (node->as_syncdone)
{ {
@ -1003,7 +1003,7 @@ ExecAppendAsyncEventWait(AppendState *node)
{ {
int nevents = node->as_nasyncplans + 1; int nevents = node->as_nasyncplans + 1;
long timeout = node->as_syncdone ? -1 : 0; long timeout = node->as_syncdone ? -1 : 0;
WaitEvent occurred_event[EVENT_BUFFER_SIZE]; WaitEvent occurred_event[EVENT_BUFFER_SIZE];
int noccurred; int noccurred;
int i; int i;
@ -1054,8 +1054,8 @@ ExecAppendAsyncEventWait(AppendState *node)
/* /*
* Mark it as no longer needing a callback. We must do this * Mark it as no longer needing a callback. We must do this
* before dispatching the callback in case the callback resets * before dispatching the callback in case the callback resets the
* the flag. * flag.
*/ */
Assert(areq->callback_pending); Assert(areq->callback_pending);
areq->callback_pending = false; areq->callback_pending = false;

View File

@ -266,7 +266,7 @@ gather_getnext(GatherState *gatherstate)
PlanState *outerPlan = outerPlanState(gatherstate); PlanState *outerPlan = outerPlanState(gatherstate);
TupleTableSlot *outerTupleSlot; TupleTableSlot *outerTupleSlot;
TupleTableSlot *fslot = gatherstate->funnel_slot; TupleTableSlot *fslot = gatherstate->funnel_slot;
MinimalTuple tup; MinimalTuple tup;
while (gatherstate->nreaders > 0 || gatherstate->need_to_scan_locally) while (gatherstate->nreaders > 0 || gatherstate->need_to_scan_locally)
{ {
@ -278,7 +278,7 @@ gather_getnext(GatherState *gatherstate)
if (HeapTupleIsValid(tup)) if (HeapTupleIsValid(tup))
{ {
ExecStoreMinimalTuple(tup, /* tuple to store */ ExecStoreMinimalTuple(tup, /* tuple to store */
fslot, /* slot to store the tuple */ fslot, /* slot to store the tuple */
false); /* don't pfree tuple */ false); /* don't pfree tuple */
return fslot; return fslot;

View File

@ -700,9 +700,9 @@ gather_merge_readnext(GatherMergeState *gm_state, int reader, bool nowait)
Assert(tup); Assert(tup);
/* Build the TupleTableSlot for the given tuple */ /* Build the TupleTableSlot for the given tuple */
ExecStoreMinimalTuple(tup, /* tuple to store */ ExecStoreMinimalTuple(tup, /* tuple to store */
gm_state->gm_slots[reader], /* slot in which to store gm_state->gm_slots[reader], /* slot in which to
* the tuple */ * store the tuple */
true); /* pfree tuple when done with it */ true); /* pfree tuple when done with it */
return true; return true;

View File

@ -1162,8 +1162,8 @@ ExecReScanIncrementalSort(IncrementalSortState *node)
} }
/* /*
* If chgParam of subnode is not null, then the plan will be re-scanned * If chgParam of subnode is not null, then the plan will be re-scanned by
* by the first ExecProcNode. * the first ExecProcNode.
*/ */
if (outerPlan->chgParam == NULL) if (outerPlan->chgParam == NULL)
ExecReScan(outerPlan); ExecReScan(outerPlan);

View File

@ -61,12 +61,12 @@ typedef struct MTTargetRelLookup
} MTTargetRelLookup; } MTTargetRelLookup;
static void ExecBatchInsert(ModifyTableState *mtstate, static void ExecBatchInsert(ModifyTableState *mtstate,
ResultRelInfo *resultRelInfo, ResultRelInfo *resultRelInfo,
TupleTableSlot **slots, TupleTableSlot **slots,
TupleTableSlot **planSlots, TupleTableSlot **planSlots,
int numSlots, int numSlots,
EState *estate, EState *estate,
bool canSetTag); bool canSetTag);
static bool ExecOnConflictUpdate(ModifyTableState *mtstate, static bool ExecOnConflictUpdate(ModifyTableState *mtstate,
ResultRelInfo *resultRelInfo, ResultRelInfo *resultRelInfo,
ItemPointer conflictTid, ItemPointer conflictTid,
@ -673,17 +673,17 @@ ExecInsert(ModifyTableState *mtstate,
if (resultRelInfo->ri_BatchSize > 1) if (resultRelInfo->ri_BatchSize > 1)
{ {
/* /*
* If a certain number of tuples have already been accumulated, * If a certain number of tuples have already been accumulated, or
* or a tuple has come for a different relation than that for * a tuple has come for a different relation than that for the
* the accumulated tuples, perform the batch insert * accumulated tuples, perform the batch insert
*/ */
if (resultRelInfo->ri_NumSlots == resultRelInfo->ri_BatchSize) if (resultRelInfo->ri_NumSlots == resultRelInfo->ri_BatchSize)
{ {
ExecBatchInsert(mtstate, resultRelInfo, ExecBatchInsert(mtstate, resultRelInfo,
resultRelInfo->ri_Slots, resultRelInfo->ri_Slots,
resultRelInfo->ri_PlanSlots, resultRelInfo->ri_PlanSlots,
resultRelInfo->ri_NumSlots, resultRelInfo->ri_NumSlots,
estate, canSetTag); estate, canSetTag);
resultRelInfo->ri_NumSlots = 0; resultRelInfo->ri_NumSlots = 0;
} }
@ -692,9 +692,9 @@ ExecInsert(ModifyTableState *mtstate,
if (resultRelInfo->ri_Slots == NULL) if (resultRelInfo->ri_Slots == NULL)
{ {
resultRelInfo->ri_Slots = palloc(sizeof(TupleTableSlot *) * resultRelInfo->ri_Slots = palloc(sizeof(TupleTableSlot *) *
resultRelInfo->ri_BatchSize); resultRelInfo->ri_BatchSize);
resultRelInfo->ri_PlanSlots = palloc(sizeof(TupleTableSlot *) * resultRelInfo->ri_PlanSlots = palloc(sizeof(TupleTableSlot *) *
resultRelInfo->ri_BatchSize); resultRelInfo->ri_BatchSize);
} }
resultRelInfo->ri_Slots[resultRelInfo->ri_NumSlots] = resultRelInfo->ri_Slots[resultRelInfo->ri_NumSlots] =
@ -982,12 +982,12 @@ ExecInsert(ModifyTableState *mtstate,
*/ */
static void static void
ExecBatchInsert(ModifyTableState *mtstate, ExecBatchInsert(ModifyTableState *mtstate,
ResultRelInfo *resultRelInfo, ResultRelInfo *resultRelInfo,
TupleTableSlot **slots, TupleTableSlot **slots,
TupleTableSlot **planSlots, TupleTableSlot **planSlots,
int numSlots, int numSlots,
EState *estate, EState *estate,
bool canSetTag) bool canSetTag)
{ {
int i; int i;
int numInserted = numSlots; int numInserted = numSlots;
@ -998,10 +998,10 @@ ExecBatchInsert(ModifyTableState *mtstate,
* insert into foreign table: let the FDW do it * insert into foreign table: let the FDW do it
*/ */
rslots = resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert(estate, rslots = resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert(estate,
resultRelInfo, resultRelInfo,
slots, slots,
planSlots, planSlots,
&numInserted); &numInserted);
for (i = 0; i < numInserted; i++) for (i = 0; i < numInserted; i++)
{ {
@ -2604,10 +2604,10 @@ ExecModifyTable(PlanState *pstate)
resultRelInfo = lfirst(lc); resultRelInfo = lfirst(lc);
if (resultRelInfo->ri_NumSlots > 0) if (resultRelInfo->ri_NumSlots > 0)
ExecBatchInsert(node, resultRelInfo, ExecBatchInsert(node, resultRelInfo,
resultRelInfo->ri_Slots, resultRelInfo->ri_Slots,
resultRelInfo->ri_PlanSlots, resultRelInfo->ri_PlanSlots,
resultRelInfo->ri_NumSlots, resultRelInfo->ri_NumSlots,
estate, node->canSetTag); estate, node->canSetTag);
} }
/* /*
@ -3091,12 +3091,12 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
mtstate->mt_resultOidHash = NULL; mtstate->mt_resultOidHash = NULL;
/* /*
* Determine if the FDW supports batch insert and determine the batch * Determine if the FDW supports batch insert and determine the batch size
* size (a FDW may support batching, but it may be disabled for the * (a FDW may support batching, but it may be disabled for the
* server/table). * server/table).
* *
* We only do this for INSERT, so that for UPDATE/DELETE the batch * We only do this for INSERT, so that for UPDATE/DELETE the batch size
* size remains set to 0. * remains set to 0.
*/ */
if (operation == CMD_INSERT) if (operation == CMD_INSERT)
{ {

View File

@ -769,9 +769,9 @@ llvm_compile_module(LLVMJitContext *context)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("time to inline: %.3fs, opt: %.3fs, emit: %.3fs", (errmsg_internal("time to inline: %.3fs, opt: %.3fs, emit: %.3fs",
INSTR_TIME_GET_DOUBLE(context->base.instr.inlining_counter), INSTR_TIME_GET_DOUBLE(context->base.instr.inlining_counter),
INSTR_TIME_GET_DOUBLE(context->base.instr.optimization_counter), INSTR_TIME_GET_DOUBLE(context->base.instr.optimization_counter),
INSTR_TIME_GET_DOUBLE(context->base.instr.emission_counter)), INSTR_TIME_GET_DOUBLE(context->base.instr.emission_counter)),
errhidestmt(true), errhidestmt(true),
errhidecontext(true))); errhidecontext(true)));
} }
@ -1094,7 +1094,7 @@ llvm_resolve_symbol(const char *symname, void *ctx)
static LLVMErrorRef static LLVMErrorRef
llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx, llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
LLVMOrcLookupStateRef *LookupState, LLVMOrcLookupKind Kind, LLVMOrcLookupStateRef * LookupState, LLVMOrcLookupKind Kind,
LLVMOrcJITDylibRef JD, LLVMOrcJITDylibLookupFlags JDLookupFlags, LLVMOrcJITDylibRef JD, LLVMOrcJITDylibLookupFlags JDLookupFlags,
LLVMOrcCLookupSet LookupSet, size_t LookupSetSize) LLVMOrcCLookupSet LookupSet, size_t LookupSetSize)
{ {

View File

@ -711,17 +711,16 @@ recv_password_packet(Port *port)
if (mtype != 'p') if (mtype != 'p')
{ {
/* /*
* If the client just disconnects without offering a password, * If the client just disconnects without offering a password, don't
* don't make a log entry. This is legal per protocol spec and in * make a log entry. This is legal per protocol spec and in fact
* fact commonly done by psql, so complaining just clutters the * commonly done by psql, so complaining just clutters the log.
* log.
*/ */
if (mtype != EOF) if (mtype != EOF)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION), (errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("expected password response, got message type %d", errmsg("expected password response, got message type %d",
mtype))); mtype)));
return NULL; /* EOF or bad message type */ return NULL; /* EOF or bad message type */
} }
initStringInfo(&buf); initStringInfo(&buf);

View File

@ -602,6 +602,7 @@ aloop:
port->peer_cn = NULL; port->peer_cn = NULL;
return -1; return -1;
} }
/* /*
* RFC2253 is the closest thing to an accepted standard format for * RFC2253 is the closest thing to an accepted standard format for
* DNs. We have documented how to produce this format from a * DNs. We have documented how to produce this format from a

View File

@ -175,8 +175,8 @@ WaitEventSet *FeBeWaitSet;
void void
pq_init(void) pq_init(void)
{ {
int socket_pos PG_USED_FOR_ASSERTS_ONLY; int socket_pos PG_USED_FOR_ASSERTS_ONLY;
int latch_pos PG_USED_FOR_ASSERTS_ONLY; int latch_pos PG_USED_FOR_ASSERTS_ONLY;
/* initialize state variables */ /* initialize state variables */
PqSendBufferSize = PQ_SEND_BUFFER_SIZE; PqSendBufferSize = PQ_SEND_BUFFER_SIZE;

View File

@ -1907,11 +1907,11 @@ create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path)
/* /*
* All gather merge paths should have already guaranteed the necessary sort * All gather merge paths should have already guaranteed the necessary
* order either by adding an explicit sort node or by using presorted input. * sort order either by adding an explicit sort node or by using presorted
* We can't simply add a sort here on additional pathkeys, because we can't * input. We can't simply add a sort here on additional pathkeys, because
* guarantee the sort would be safe. For example, expressions may be * we can't guarantee the sort would be safe. For example, expressions may
* volatile or otherwise parallel unsafe. * be volatile or otherwise parallel unsafe.
*/ */
if (!pathkeys_contained_in(pathkeys, best_path->subpath->pathkeys)) if (!pathkeys_contained_in(pathkeys, best_path->subpath->pathkeys))
elog(ERROR, "gather merge input not sufficiently sorted"); elog(ERROR, "gather merge input not sufficiently sorted");

View File

@ -350,34 +350,34 @@ expand_insert_targetlist(List *tlist, Relation rel)
Oid attcollation = att_tup->attcollation; Oid attcollation = att_tup->attcollation;
Node *new_expr; Node *new_expr;
if (!att_tup->attisdropped) if (!att_tup->attisdropped)
{ {
new_expr = (Node *) makeConst(atttype, new_expr = (Node *) makeConst(atttype,
-1, -1,
attcollation, attcollation,
att_tup->attlen, att_tup->attlen,
(Datum) 0, (Datum) 0,
true, /* isnull */ true, /* isnull */
att_tup->attbyval); att_tup->attbyval);
new_expr = coerce_to_domain(new_expr, new_expr = coerce_to_domain(new_expr,
InvalidOid, -1, InvalidOid, -1,
atttype, atttype,
COERCION_IMPLICIT, COERCION_IMPLICIT,
COERCE_IMPLICIT_CAST, COERCE_IMPLICIT_CAST,
-1, -1,
false); false);
} }
else else
{ {
/* Insert NULL for dropped column */ /* Insert NULL for dropped column */
new_expr = (Node *) makeConst(INT4OID, new_expr = (Node *) makeConst(INT4OID,
-1, -1,
InvalidOid, InvalidOid,
sizeof(int32), sizeof(int32),
(Datum) 0, (Datum) 0,
true, /* isnull */ true, /* isnull */
true /* byval */ ); true /* byval */ );
} }
new_tle = makeTargetEntry((Expr *) new_expr, new_tle = makeTargetEntry((Expr *) new_expr,
attrno, attrno,

View File

@ -2563,9 +2563,9 @@ eval_const_expressions_mutator(Node *node,
} }
case T_NullIfExpr: case T_NullIfExpr:
{ {
NullIfExpr *expr; NullIfExpr *expr;
ListCell *arg; ListCell *arg;
bool has_nonconst_input = false; bool has_nonconst_input = false;
/* Copy the node and const-simplify its arguments */ /* Copy the node and const-simplify its arguments */
expr = (NullIfExpr *) ece_generic_processing(node); expr = (NullIfExpr *) ece_generic_processing(node);
@ -4359,49 +4359,49 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
} }
else else
{ {
/* /*
* Set up to handle parameters while parsing the function body. We need a * Set up to handle parameters while parsing the function body. We
* dummy FuncExpr node containing the already-simplified arguments to pass * need a dummy FuncExpr node containing the already-simplified
* to prepare_sql_fn_parse_info. (In some cases we don't really need * arguments to pass to prepare_sql_fn_parse_info. (In some cases we
* that, but for simplicity we always build it.) * don't really need that, but for simplicity we always build it.)
*/ */
fexpr = makeNode(FuncExpr); fexpr = makeNode(FuncExpr);
fexpr->funcid = funcid; fexpr->funcid = funcid;
fexpr->funcresulttype = result_type; fexpr->funcresulttype = result_type;
fexpr->funcretset = false; fexpr->funcretset = false;
fexpr->funcvariadic = funcvariadic; fexpr->funcvariadic = funcvariadic;
fexpr->funcformat = COERCE_EXPLICIT_CALL; /* doesn't matter */ fexpr->funcformat = COERCE_EXPLICIT_CALL; /* doesn't matter */
fexpr->funccollid = result_collid; /* doesn't matter */ fexpr->funccollid = result_collid; /* doesn't matter */
fexpr->inputcollid = input_collid; fexpr->inputcollid = input_collid;
fexpr->args = args; fexpr->args = args;
fexpr->location = -1; fexpr->location = -1;
pinfo = prepare_sql_fn_parse_info(func_tuple, pinfo = prepare_sql_fn_parse_info(func_tuple,
(Node *) fexpr, (Node *) fexpr,
input_collid); input_collid);
/* fexpr also provides a convenient way to resolve a composite result */ /* fexpr also provides a convenient way to resolve a composite result */
(void) get_expr_result_type((Node *) fexpr, (void) get_expr_result_type((Node *) fexpr,
NULL, NULL,
&rettupdesc); &rettupdesc);
/* /*
* We just do parsing and parse analysis, not rewriting, because rewriting * We just do parsing and parse analysis, not rewriting, because
* will not affect table-free-SELECT-only queries, which is all that we * rewriting will not affect table-free-SELECT-only queries, which is
* care about. Also, we can punt as soon as we detect more than one * all that we care about. Also, we can punt as soon as we detect
* command in the function body. * more than one command in the function body.
*/ */
raw_parsetree_list = pg_parse_query(src); raw_parsetree_list = pg_parse_query(src);
if (list_length(raw_parsetree_list) != 1) if (list_length(raw_parsetree_list) != 1)
goto fail; goto fail;
pstate = make_parsestate(NULL); pstate = make_parsestate(NULL);
pstate->p_sourcetext = src; pstate->p_sourcetext = src;
sql_fn_parser_setup(pstate, pinfo); sql_fn_parser_setup(pstate, pinfo);
querytree = transformTopLevelStmt(pstate, linitial(raw_parsetree_list)); querytree = transformTopLevelStmt(pstate, linitial(raw_parsetree_list));
free_parsestate(pstate); free_parsestate(pstate);
} }
/* /*
@ -4931,31 +4931,31 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
} }
else else
{ {
/* /*
* Set up to handle parameters while parsing the function body. We can * Set up to handle parameters while parsing the function body. We
* use the FuncExpr just created as the input for * can use the FuncExpr just created as the input for
* prepare_sql_fn_parse_info. * prepare_sql_fn_parse_info.
*/ */
pinfo = prepare_sql_fn_parse_info(func_tuple, pinfo = prepare_sql_fn_parse_info(func_tuple,
(Node *) fexpr, (Node *) fexpr,
fexpr->inputcollid); fexpr->inputcollid);
/* /*
* Parse, analyze, and rewrite (unlike inline_function(), we can't skip * Parse, analyze, and rewrite (unlike inline_function(), we can't
* rewriting here). We can fail as soon as we find more than one query, * skip rewriting here). We can fail as soon as we find more than one
* though. * query, though.
*/ */
raw_parsetree_list = pg_parse_query(src); raw_parsetree_list = pg_parse_query(src);
if (list_length(raw_parsetree_list) != 1) if (list_length(raw_parsetree_list) != 1)
goto fail; goto fail;
querytree_list = pg_analyze_and_rewrite_params(linitial(raw_parsetree_list), querytree_list = pg_analyze_and_rewrite_params(linitial(raw_parsetree_list),
src, src,
(ParserSetupHook) sql_fn_parser_setup, (ParserSetupHook) sql_fn_parser_setup,
pinfo, NULL); pinfo, NULL);
if (list_length(querytree_list) != 1) if (list_length(querytree_list) != 1)
goto fail; goto fail;
querytree = linitial(querytree_list); querytree = linitial(querytree_list);
} }
/* /*

View File

@ -2752,7 +2752,7 @@ transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
(stmt->options & CURSOR_OPT_NO_SCROLL)) (stmt->options & CURSOR_OPT_NO_SCROLL))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_CURSOR_DEFINITION), (errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
/* translator: %s is a SQL keyword */ /* translator: %s is a SQL keyword */
errmsg("cannot specify both %s and %s", errmsg("cannot specify both %s and %s",
"SCROLL", "NO SCROLL"))); "SCROLL", "NO SCROLL")));
@ -2760,7 +2760,7 @@ transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
(stmt->options & CURSOR_OPT_INSENSITIVE)) (stmt->options & CURSOR_OPT_INSENSITIVE))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_CURSOR_DEFINITION), (errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
/* translator: %s is a SQL keyword */ /* translator: %s is a SQL keyword */
errmsg("cannot specify both %s and %s", errmsg("cannot specify both %s and %s",
"ASENSITIVE", "INSENSITIVE"))); "ASENSITIVE", "INSENSITIVE")));

View File

@ -1749,19 +1749,20 @@ cmp_list_len_asc(const ListCell *a, const ListCell *b)
static int static int
cmp_list_len_contents_asc(const ListCell *a, const ListCell *b) cmp_list_len_contents_asc(const ListCell *a, const ListCell *b)
{ {
int res = cmp_list_len_asc(a, b); int res = cmp_list_len_asc(a, b);
if (res == 0) if (res == 0)
{ {
List *la = (List *) lfirst(a); List *la = (List *) lfirst(a);
List *lb = (List *) lfirst(b); List *lb = (List *) lfirst(b);
ListCell *lca; ListCell *lca;
ListCell *lcb; ListCell *lcb;
forboth(lca, la, lcb, lb) forboth(lca, la, lcb, lb)
{ {
int va = lfirst_int(lca); int va = lfirst_int(lca);
int vb = lfirst_int(lcb); int vb = lfirst_int(lcb);
if (va > vb) if (va > vb)
return 1; return 1;
if (va < vb) if (va < vb)

View File

@ -356,7 +356,7 @@ analyzeCTE(ParseState *pstate, CommonTableExpr *cte)
* than just being recursive. It basically means the query expression * than just being recursive. It basically means the query expression
* looks like * looks like
* *
* non-recursive query UNION [ALL] recursive query * non-recursive query UNION [ALL] recursive query
* *
* and that the recursive query is not itself a set operation. * and that the recursive query is not itself a set operation.
* *

View File

@ -2360,8 +2360,8 @@ addRangeTableEntryForCTE(ParseState *pstate,
* list --- caller must do that if appropriate. * list --- caller must do that if appropriate.
*/ */
psi = buildNSItemFromLists(rte, list_length(pstate->p_rtable), psi = buildNSItemFromLists(rte, list_length(pstate->p_rtable),
rte->coltypes, rte->coltypmods, rte->coltypes, rte->coltypmods,
rte->colcollations); rte->colcollations);
/* /*
* The columns added by search and cycle clauses are not included in star * The columns added by search and cycle clauses are not included in star

View File

@ -447,8 +447,8 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("%s will create implicit sequence \"%s\" for serial column \"%s.%s\"", (errmsg_internal("%s will create implicit sequence \"%s\" for serial column \"%s.%s\"",
cxt->stmtType, sname, cxt->stmtType, sname,
cxt->relation->relname, column->colname))); cxt->relation->relname, column->colname)));
/* /*
* Build a CREATE SEQUENCE command to create the sequence object, and add * Build a CREATE SEQUENCE command to create the sequence object, and add

View File

@ -2876,7 +2876,10 @@ check_new_partition_bound(char *relname, Relation parent,
{ {
int prev_modulus; int prev_modulus;
/* We found the largest modulus less than or equal to ours. */ /*
* We found the largest modulus less than or equal to
* ours.
*/
prev_modulus = DatumGetInt32(boundinfo->datums[offset][0]); prev_modulus = DatumGetInt32(boundinfo->datums[offset][0]);
if (spec->modulus % prev_modulus != 0) if (spec->modulus % prev_modulus != 0)
@ -3171,7 +3174,7 @@ check_default_partition_contents(Relation parent, Relation default_rel,
{ {
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("updated partition constraint for default partition \"%s\" is implied by existing constraints", (errmsg_internal("updated partition constraint for default partition \"%s\" is implied by existing constraints",
RelationGetRelationName(default_rel)))); RelationGetRelationName(default_rel))));
return; return;
} }
@ -3222,7 +3225,7 @@ check_default_partition_contents(Relation parent, Relation default_rel,
{ {
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("updated partition constraint for default partition \"%s\" is implied by existing constraints", (errmsg_internal("updated partition constraint for default partition \"%s\" is implied by existing constraints",
RelationGetRelationName(part_rel)))); RelationGetRelationName(part_rel))));
table_close(part_rel, NoLock); table_close(part_rel, NoLock);
continue; continue;

View File

@ -336,8 +336,8 @@ RelationBuildPartitionDesc(Relation rel, bool omit_detached)
* descriptor, it contains an old partition descriptor that may still be * descriptor, it contains an old partition descriptor that may still be
* referenced somewhere. Preserve it, while not leaking it, by * referenced somewhere. Preserve it, while not leaking it, by
* reattaching it as a child context of the new one. Eventually it will * reattaching it as a child context of the new one. Eventually it will
* get dropped by either RelationClose or RelationClearRelation. * get dropped by either RelationClose or RelationClearRelation. (We keep
* (We keep the regular partdesc in rd_pdcxt, and the partdesc-excluding- * the regular partdesc in rd_pdcxt, and the partdesc-excluding-
* detached-partitions in rd_pddcxt.) * detached-partitions in rd_pddcxt.)
*/ */
if (is_omit) if (is_omit)

View File

@ -142,7 +142,11 @@ EnableLockPagesPrivilege(int elevel)
{ {
ereport(elevel, ereport(elevel,
(errmsg("could not enable user right \"%s\": error code %lu", (errmsg("could not enable user right \"%s\": error code %lu",
/* translator: This is a term from Windows and should be translated to match the Windows localization. */
/*
* translator: This is a term from Windows and should be translated to
* match the Windows localization.
*/
_("Lock pages in memory"), _("Lock pages in memory"),
GetLastError()), GetLastError()),
errdetail("Failed system call was %s.", "OpenProcessToken"))); errdetail("Failed system call was %s.", "OpenProcessToken")));

View File

@ -403,7 +403,7 @@ BackgroundWorkerStateChange(bool allow_new_workers)
/* Log it! */ /* Log it! */
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("registering background worker \"%s\"", (errmsg_internal("registering background worker \"%s\"",
rw->rw_worker.bgw_name))); rw->rw_worker.bgw_name)));
slist_push_head(&BackgroundWorkerList, &rw->rw_lnode); slist_push_head(&BackgroundWorkerList, &rw->rw_lnode);
} }
@ -435,7 +435,7 @@ ForgetBackgroundWorker(slist_mutable_iter *cur)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("unregistering background worker \"%s\"", (errmsg_internal("unregistering background worker \"%s\"",
rw->rw_worker.bgw_name))); rw->rw_worker.bgw_name)));
slist_delete_current(cur); slist_delete_current(cur);
free(rw); free(rw);

View File

@ -1238,7 +1238,7 @@ CompactCheckpointerRequestQueue(void)
} }
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("compacted fsync request queue from %d entries to %d entries", (errmsg_internal("compacted fsync request queue from %d entries to %d entries",
CheckpointerShmem->num_requests, preserve_count))); CheckpointerShmem->num_requests, preserve_count)));
CheckpointerShmem->num_requests = preserve_count; CheckpointerShmem->num_requests = preserve_count;
/* Cleanup. */ /* Cleanup. */

View File

@ -3708,7 +3708,7 @@ pgstat_write_statsfiles(bool permanent, bool allDbs)
{ {
fputc('R', fpout); fputc('R', fpout);
rc = fwrite(slotent, sizeof(PgStat_StatReplSlotEntry), 1, fpout); rc = fwrite(slotent, sizeof(PgStat_StatReplSlotEntry), 1, fpout);
(void) rc; /* we'll check for error with ferror */ (void) rc; /* we'll check for error with ferror */
} }
} }

View File

@ -660,6 +660,7 @@ PostmasterMain(int argc, char *argv[])
pqsignal_pm(SIGCHLD, reaper); /* handle child termination */ pqsignal_pm(SIGCHLD, reaper); /* handle child termination */
#ifdef SIGURG #ifdef SIGURG
/* /*
* Ignore SIGURG for now. Child processes may change this (see * Ignore SIGURG for now. Child processes may change this (see
* InitializeLatchSupport), but they will not receive any such signals * InitializeLatchSupport), but they will not receive any such signals
@ -5780,7 +5781,7 @@ do_start_bgworker(RegisteredBgWorker *rw)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("starting background worker process \"%s\"", (errmsg_internal("starting background worker process \"%s\"",
rw->rw_worker.bgw_name))); rw->rw_worker.bgw_name)));
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
switch ((worker_pid = bgworker_forkexec(rw->rw_shmem_slot))) switch ((worker_pid = bgworker_forkexec(rw->rw_shmem_slot)))

View File

@ -239,7 +239,8 @@ SysLoggerMain(int argc, char *argv[])
* broken backends... * broken backends...
*/ */
pqsignal(SIGHUP, SignalHandlerForConfigReload); /* set flag to read config file */ pqsignal(SIGHUP, SignalHandlerForConfigReload); /* set flag to read config
* file */
pqsignal(SIGINT, SIG_IGN); pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, SIG_IGN); pqsignal(SIGTERM, SIG_IGN);
pqsignal(SIGQUIT, SIG_IGN); pqsignal(SIGQUIT, SIG_IGN);

View File

@ -414,7 +414,7 @@ perform_base_backup(basebackup_options *opt)
if (ti->path == NULL) if (ti->path == NULL)
{ {
struct stat statbuf; struct stat statbuf;
bool sendtblspclinks = true; bool sendtblspclinks = true;
/* In the main tar, include the backup_label first... */ /* In the main tar, include the backup_label first... */
sendFileWithContent(BACKUP_LABEL_FILE, labelfile->data, sendFileWithContent(BACKUP_LABEL_FILE, labelfile->data,

View File

@ -67,12 +67,6 @@ typedef struct LogicalRepCtxStruct
LogicalRepCtxStruct *LogicalRepCtx; LogicalRepCtxStruct *LogicalRepCtx;
typedef struct LogicalRepWorkerId
{
Oid subid;
Oid relid;
} LogicalRepWorkerId;
static void ApplyLauncherWakeup(void); static void ApplyLauncherWakeup(void);
static void logicalrep_launcher_onexit(int code, Datum arg); static void logicalrep_launcher_onexit(int code, Datum arg);
static void logicalrep_worker_onexit(int code, Datum arg); static void logicalrep_worker_onexit(int code, Datum arg);
@ -283,7 +277,7 @@ logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname, Oid userid,
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("starting logical replication worker for subscription \"%s\"", (errmsg_internal("starting logical replication worker for subscription \"%s\"",
subname))); subname)));
/* Report this after the initial starting message for consistency. */ /* Report this after the initial starting message for consistency. */
if (max_replication_slots == 0) if (max_replication_slots == 0)

View File

@ -576,8 +576,8 @@ CheckPointReplicationOrigin(void)
tmppath))); tmppath)));
/* /*
* no other backend can perform this at the same time; only one * no other backend can perform this at the same time; only one checkpoint
* checkpoint can happen at a time. * can happen at a time.
*/ */
tmpfd = OpenTransientFile(tmppath, tmpfd = OpenTransientFile(tmppath,
O_CREAT | O_EXCL | O_WRONLY | PG_BINARY); O_CREAT | O_EXCL | O_WRONLY | PG_BINARY);

View File

@ -2493,11 +2493,11 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
* need to do the cleanup and return gracefully on this error, see * need to do the cleanup and return gracefully on this error, see
* SetupCheckXidLive. * SetupCheckXidLive.
* *
* This error code can be thrown by one of the callbacks we call during * This error code can be thrown by one of the callbacks we call
* decoding so we need to ensure that we return gracefully only when we are * during decoding so we need to ensure that we return gracefully only
* sending the data in streaming mode and the streaming is not finished yet * when we are sending the data in streaming mode and the streaming is
* or when we are sending the data out on a PREPARE during a two-phase * not finished yet or when we are sending the data out on a PREPARE
* commit. * during a two-phase commit.
*/ */
if (errdata->sqlerrcode == ERRCODE_TRANSACTION_ROLLBACK && if (errdata->sqlerrcode == ERRCODE_TRANSACTION_ROLLBACK &&
(stream_started || rbtxn_prepared(txn))) (stream_started || rbtxn_prepared(txn)))

View File

@ -1395,8 +1395,8 @@ SnapBuildWaitSnapshot(xl_running_xacts *running, TransactionId cutoff)
/* /*
* All transactions we needed to finish finished - try to ensure there is * All transactions we needed to finish finished - try to ensure there is
* another xl_running_xacts record in a timely manner, without having to * another xl_running_xacts record in a timely manner, without having to
* wait for bgwriter or checkpointer to log one. During recovery we * wait for bgwriter or checkpointer to log one. During recovery we can't
* can't enforce that, so we'll have to wait. * enforce that, so we'll have to wait.
*/ */
if (!RecoveryInProgress()) if (!RecoveryInProgress())
{ {

View File

@ -99,8 +99,8 @@ ReplicationSlot *MyReplicationSlot = NULL;
int max_replication_slots = 0; /* the maximum number of replication int max_replication_slots = 0; /* the maximum number of replication
* slots */ * slots */
static int ReplicationSlotAcquireInternal(ReplicationSlot *slot, static int ReplicationSlotAcquireInternal(ReplicationSlot *slot,
const char *name, SlotAcquireBehavior behavior); const char *name, SlotAcquireBehavior behavior);
static void ReplicationSlotDropAcquired(void); static void ReplicationSlotDropAcquired(void);
static void ReplicationSlotDropPtr(ReplicationSlot *slot); static void ReplicationSlotDropPtr(ReplicationSlot *slot);
@ -451,8 +451,8 @@ retry:
/* /*
* If we found the slot but it's already active in another process, we * If we found the slot but it's already active in another process, we
* either error out, return the PID of the owning process, or retry * either error out, return the PID of the owning process, or retry after
* after a short wait, as caller specified. * a short wait, as caller specified.
*/ */
if (active_pid != MyProcPid) if (active_pid != MyProcPid)
{ {
@ -471,7 +471,7 @@ retry:
goto retry; goto retry;
} }
else if (behavior == SAB_Block) else if (behavior == SAB_Block)
ConditionVariableCancelSleep(); /* no sleep needed after all */ ConditionVariableCancelSleep(); /* no sleep needed after all */
/* Let everybody know we've modified this slot */ /* Let everybody know we've modified this slot */
ConditionVariableBroadcast(&s->active_cv); ConditionVariableBroadcast(&s->active_cv);
@ -1180,8 +1180,8 @@ restart:
ReplicationSlot *s = &ReplicationSlotCtl->replication_slots[i]; ReplicationSlot *s = &ReplicationSlotCtl->replication_slots[i];
XLogRecPtr restart_lsn = InvalidXLogRecPtr; XLogRecPtr restart_lsn = InvalidXLogRecPtr;
NameData slotname; NameData slotname;
int wspid; int wspid;
int last_signaled_pid = 0; int last_signaled_pid = 0;
if (!s->in_use) if (!s->in_use)
continue; continue;
@ -1204,20 +1204,20 @@ restart:
/* /*
* Try to mark this slot as used by this process. * Try to mark this slot as used by this process.
* *
* Note that ReplicationSlotAcquireInternal(SAB_Inquire) * Note that ReplicationSlotAcquireInternal(SAB_Inquire) should
* should not cancel the prepared condition variable * not cancel the prepared condition variable if this slot is
* if this slot is active in other process. Because in this case * active in other process. Because in this case we have to wait
* we have to wait on that CV for the process owning * on that CV for the process owning the slot to be terminated,
* the slot to be terminated, later. * later.
*/ */
wspid = ReplicationSlotAcquireInternal(s, NULL, SAB_Inquire); wspid = ReplicationSlotAcquireInternal(s, NULL, SAB_Inquire);
/* /*
* Exit the loop if we successfully acquired the slot or * Exit the loop if we successfully acquired the slot or the slot
* the slot was dropped during waiting for the owning process * was dropped during waiting for the owning process to be
* to be terminated. For example, the latter case is likely to * terminated. For example, the latter case is likely to happen
* happen when the slot is temporary because it's automatically * when the slot is temporary because it's automatically dropped
* dropped by the termination of the owning process. * by the termination of the owning process.
*/ */
if (wspid <= 0) if (wspid <= 0)
break; break;
@ -1225,13 +1225,13 @@ restart:
/* /*
* Signal to terminate the process that owns the slot. * Signal to terminate the process that owns the slot.
* *
* There is the race condition where other process may own * There is the race condition where other process may own the
* the slot after the process using it was terminated and before * slot after the process using it was terminated and before this
* this process owns it. To handle this case, we signal again * process owns it. To handle this case, we signal again if the
* if the PID of the owning process is changed than the last. * PID of the owning process is changed than the last.
* *
* XXX This logic assumes that the same PID is not reused * XXX This logic assumes that the same PID is not reused very
* very quickly. * quickly.
*/ */
if (last_signaled_pid != wspid) if (last_signaled_pid != wspid)
{ {
@ -1248,8 +1248,8 @@ restart:
ConditionVariableCancelSleep(); ConditionVariableCancelSleep();
/* /*
* Do nothing here and start from scratch if the slot has * Do nothing here and start from scratch if the slot has already been
* already been dropped. * dropped.
*/ */
if (wspid == -1) if (wspid == -1)
goto restart; goto restart;

View File

@ -415,11 +415,11 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
nulls[i++] = true; nulls[i++] = true;
else else
{ {
XLogSegNo targetSeg; XLogSegNo targetSeg;
uint64 slotKeepSegs; uint64 slotKeepSegs;
uint64 keepSegs; uint64 keepSegs;
XLogSegNo failSeg; XLogSegNo failSeg;
XLogRecPtr failLSN; XLogRecPtr failLSN;
XLByteToSeg(slot_contents.data.restart_lsn, targetSeg, wal_segment_size); XLByteToSeg(slot_contents.data.restart_lsn, targetSeg, wal_segment_size);

View File

@ -165,12 +165,11 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
* Since this routine gets called every commit time, it's important to * Since this routine gets called every commit time, it's important to
* exit quickly if sync replication is not requested. So we check * exit quickly if sync replication is not requested. So we check
* WalSndCtl->sync_standbys_defined flag without the lock and exit * WalSndCtl->sync_standbys_defined flag without the lock and exit
* immediately if it's false. If it's true, we need to check it again later * immediately if it's false. If it's true, we need to check it again
* while holding the lock, to check the flag and operate the sync rep * later while holding the lock, to check the flag and operate the sync
* queue atomically. This is necessary to avoid the race condition * rep queue atomically. This is necessary to avoid the race condition
* described in SyncRepUpdateSyncStandbysDefined(). On the other * described in SyncRepUpdateSyncStandbysDefined(). On the other hand, if
* hand, if it's false, the lock is not necessary because we don't touch * it's false, the lock is not necessary because we don't touch the queue.
* the queue.
*/ */
if (!SyncRepRequested() || if (!SyncRepRequested() ||
!((volatile WalSndCtlData *) WalSndCtl)->sync_standbys_defined) !((volatile WalSndCtlData *) WalSndCtl)->sync_standbys_defined)
@ -426,7 +425,7 @@ SyncRepInitConfig(void)
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("standby \"%s\" now has synchronous standby priority %u", (errmsg_internal("standby \"%s\" now has synchronous standby priority %u",
application_name, priority))); application_name, priority)));
} }
} }

View File

@ -747,8 +747,8 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last)
writeTimeLineHistoryFile(tli, content, len); writeTimeLineHistoryFile(tli, content, len);
/* /*
* Mark the streamed history file as ready for archiving * Mark the streamed history file as ready for archiving if
* if archive_mode is always. * archive_mode is always.
*/ */
if (XLogArchiveMode != ARCHIVE_MODE_ALWAYS) if (XLogArchiveMode != ARCHIVE_MODE_ALWAYS)
XLogArchiveForceDone(fname); XLogArchiveForceDone(fname);

View File

@ -2326,7 +2326,7 @@ WalSndLoop(WalSndSendDataCallback send_data)
{ {
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("\"%s\" has now caught up with upstream server", (errmsg_internal("\"%s\" has now caught up with upstream server",
application_name))); application_name)));
WalSndSetState(WALSNDSTATE_STREAMING); WalSndSetState(WALSNDSTATE_STREAMING);
} }
@ -3139,7 +3139,7 @@ WalSndWakeup(void)
static void static void
WalSndWait(uint32 socket_events, long timeout, uint32 wait_event) WalSndWait(uint32 socket_events, long timeout, uint32 wait_event)
{ {
WaitEvent event; WaitEvent event;
ModifyWaitEvent(FeBeWaitSet, FeBeWaitSetSocketPos, socket_events, NULL); ModifyWaitEvent(FeBeWaitSet, FeBeWaitSetSocketPos, socket_events, NULL);
if (WaitEventSetWait(FeBeWaitSet, timeout, &event, 1, wait_event) == 1 && if (WaitEventSetWait(FeBeWaitSet, timeout, &event, 1, wait_event) == 1 &&

View File

@ -241,8 +241,8 @@ dependency_degree(StatsBuildData *data, int k, AttrNumber *dependency)
mss = multi_sort_init(k); mss = multi_sort_init(k);
/* /*
* Translate the array of indexes to regular attnums for the dependency (we * Translate the array of indexes to regular attnums for the dependency
* will need this to identify the columns in StatsBuildData). * (we will need this to identify the columns in StatsBuildData).
*/ */
attnums_dep = (AttrNumber *) palloc(k * sizeof(AttrNumber)); attnums_dep = (AttrNumber *) palloc(k * sizeof(AttrNumber));
for (i = 0; i < k; i++) for (i = 0; i < k; i++)

View File

@ -91,9 +91,9 @@ typedef struct AnlExprData
} AnlExprData; } AnlExprData;
static void compute_expr_stats(Relation onerel, double totalrows, static void compute_expr_stats(Relation onerel, double totalrows,
AnlExprData * exprdata, int nexprs, AnlExprData *exprdata, int nexprs,
HeapTuple *rows, int numrows); HeapTuple *rows, int numrows);
static Datum serialize_expr_stats(AnlExprData * exprdata, int nexprs); static Datum serialize_expr_stats(AnlExprData *exprdata, int nexprs);
static Datum expr_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull); static Datum expr_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull);
static AnlExprData *build_expr_data(List *exprs, int stattarget); static AnlExprData *build_expr_data(List *exprs, int stattarget);
@ -539,9 +539,9 @@ examine_attribute(Node *expr)
/* /*
* When analyzing an expression, believe the expression tree's type not * When analyzing an expression, believe the expression tree's type not
* the column datatype --- the latter might be the opckeytype storage * the column datatype --- the latter might be the opckeytype storage type
* type of the opclass, which is not interesting for our purposes. (Note: * of the opclass, which is not interesting for our purposes. (Note: if
* if we did anything with non-expression statistics columns, we'd need to * we did anything with non-expression statistics columns, we'd need to
* figure out where to get the correct type info from, but for now that's * figure out where to get the correct type info from, but for now that's
* not a problem.) It's not clear whether anyone will care about the * not a problem.) It's not clear whether anyone will care about the
* typmod, but we store that too just in case. * typmod, but we store that too just in case.
@ -1788,16 +1788,16 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli
* attnums of expressions from it. Ignore it if it's not fully * attnums of expressions from it. Ignore it if it's not fully
* covered by the chosen statistics. * covered by the chosen statistics.
* *
* We need to check both attributes and expressions, and reject * We need to check both attributes and expressions, and reject if
* if either is not covered. * either is not covered.
*/ */
if (!bms_is_subset(list_attnums[listidx], stat->keys) || if (!bms_is_subset(list_attnums[listidx], stat->keys) ||
!stat_covers_expressions(stat, list_exprs[listidx], NULL)) !stat_covers_expressions(stat, list_exprs[listidx], NULL))
continue; continue;
/* /*
* Now we know the clause is compatible (we have either attnums * Now we know the clause is compatible (we have either attnums or
* or expressions extracted from it), and was not estimated yet. * expressions extracted from it), and was not estimated yet.
*/ */
/* record simple clauses (single column or expression) */ /* record simple clauses (single column or expression) */

View File

@ -3071,7 +3071,7 @@ DropRelFileNodeBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum,
int j; int j;
RelFileNodeBackend rnode; RelFileNodeBackend rnode;
BlockNumber nForkBlock[MAX_FORKNUM]; BlockNumber nForkBlock[MAX_FORKNUM];
uint64 nBlocksToInvalidate = 0; uint64 nBlocksToInvalidate = 0;
rnode = smgr_reln->smgr_rnode; rnode = smgr_reln->smgr_rnode;
@ -3195,7 +3195,7 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
int n = 0; int n = 0;
SMgrRelation *rels; SMgrRelation *rels;
BlockNumber (*block)[MAX_FORKNUM + 1]; BlockNumber (*block)[MAX_FORKNUM + 1];
uint64 nBlocksToInvalidate = 0; uint64 nBlocksToInvalidate = 0;
RelFileNode *nodes; RelFileNode *nodes;
bool cached = true; bool cached = true;
bool use_bsearch; bool use_bsearch;

View File

@ -3288,7 +3288,7 @@ looks_like_temp_rel_name(const char *name)
static void static void
do_syncfs(const char *path) do_syncfs(const char *path)
{ {
int fd; int fd;
fd = OpenTransientFile(path, O_RDONLY); fd = OpenTransientFile(path, O_RDONLY);
if (fd < 0) if (fd < 0)
@ -3394,7 +3394,7 @@ SyncDataDirectory(void)
do_syncfs("pg_wal"); do_syncfs("pg_wal");
return; return;
} }
#endif /* !HAVE_SYNCFS */ #endif /* !HAVE_SYNCFS */
/* /*
* If possible, hint to the kernel that we're soon going to fsync the data * If possible, hint to the kernel that we're soon going to fsync the data

View File

@ -267,8 +267,8 @@ static void
SharedFileSetDeleteOnProcExit(int status, Datum arg) SharedFileSetDeleteOnProcExit(int status, Datum arg)
{ {
/* /*
* Remove all the pending shared fileset entries. We don't use foreach() here * Remove all the pending shared fileset entries. We don't use foreach()
* because SharedFileSetDeleteAll will remove the current element in * here because SharedFileSetDeleteAll will remove the current element in
* filesetlist. Though we have used foreach_delete_current() to remove the * filesetlist. Though we have used foreach_delete_current() to remove the
* element from filesetlist it could only fix up the state of one of the * element from filesetlist it could only fix up the state of one of the
* loops, see SharedFileSetUnregister. * loops, see SharedFileSetUnregister.

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