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');
$node->safe_psql('postgres', q(VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test));
detects_no_corruption(
"verify_heapam('test')",
detects_no_corruption("verify_heapam('test')",
"all-frozen not corrupted table");
corrupt_first_page('test');
detects_heap_corruption("verify_heapam('test')",

View File

@ -839,13 +839,16 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_COMMITTED:
/*
* 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;
case XID_ABORTED:
/*
* The original xmin must have committed, because the xvac
* transaction tried to move it later. Since xvac is
@ -905,6 +908,7 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_COMMITTED:
/*
* The original xmin must have committed, because the xvac
* transaction moved it later. Whether it's still alive
@ -913,9 +917,11 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_ABORTED:
/*
* 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;
}
@ -924,12 +930,12 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
/*
* Inserting transaction is not in progress, and not committed, so
* it might have changed the TupleDesc in ways we don't know about.
* Thus, don't try to check the tuple structure.
* it might have changed the TupleDesc in ways we don't know
* about. Thus, don't try to check the tuple structure.
*
* 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
* we could check anyway in that case. But, for now, let's be
* any such DDL changes ought to be visible to us, so perhaps we
* could check anyway in that case. But, for now, let's be
* conservative and treat this like any other uncommitted insert.
*/
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
* prior to checking for HEAP_XMAX_INVALID or HEAP_XMAX_IS_LOCKED_ONLY.
* This might therefore complain about things that wouldn't actually
* be a problem during a normal scan, but eventually we're going to
* have to freeze, and that process will ignore hint bits.
* prior to checking for HEAP_XMAX_INVALID or
* HEAP_XMAX_IS_LOCKED_ONLY. This might therefore complain about
* things that wouldn't actually be a problem during a normal scan,
* 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
* 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
* clear ctx->tuple_could_be_pruned. Possibly we should go ahead and
* 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
* of avoiding possibly-bogus complaints about missing TOAST entries.
* HEAP_XMAX_IS_LOCKED_ONLY is true, but for now we err on the side of
* avoiding possibly-bogus complaints about missing TOAST entries.
*/
xmax = HeapTupleHeaderGetRawXmax(tuphdr);
switch (check_mxid_valid_in_rel(xmax, ctx))
@ -1069,6 +1076,7 @@ check_tuple_visibility(HeapCheckContext *ctx)
ctx->safe_xmin);
break;
case XID_ABORTED:
/*
* The delete aborted or crashed. The tuple is still live.
*/
@ -1127,6 +1135,7 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_COMMITTED:
/*
* The delete committed. Whether the toast can be vacuumed away
* depends on how old the deleting transaction is.
@ -1136,6 +1145,7 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_ABORTED:
/*
* 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,
chunk_seq, chunksize, expected_size));
}
/*
* Check the current attribute as tracked in ctx, recording any corruption
* found in ctx->tupstore.

View File

@ -136,15 +136,16 @@ MakeOldSnapshotTimeMappingTuple(TupleDesc tupdesc, OldSnapshotTimeMapping *mappi
* Figure out the array position corresponding to the current index.
*
* 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
* following index, and so on. We wrap around when we reach the end of the array.
* mapping->head_offset. Index 1 means the next-oldest entry, which is a
* 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)
% OLD_SNAPSHOT_TIME_MAP_ENTRIES;
/*
* No explicit timestamp is stored for any entry other than the oldest one,
* but each entry corresponds to 1-minute period, so we can just add.
* No explicit timestamp is stored for any entry other than the oldest
* one, but each entry corresponds to 1-minute period, so we can just add.
*/
timestamp = TimestampTzPlusMilliseconds(mapping->head_timestamp,
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
* where the statement contains an optimizable statement for which a
* queryId could be derived (such as EXPLAIN or DECLARE CURSOR). For such
* cases, runtime control will first go through ProcessUtility and then the
* executor, and we don't want the executor hooks to do anything, since we
* are already measuring the statement's costs at the utility level.
* cases, runtime control will first go through ProcessUtility and then
* the executor, and we don't want the executor hooks to do anything,
* 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
* 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 num_rows)
{
int i, j;
int i,
j;
int pindex;
bool first;
@ -1790,8 +1791,8 @@ rebuildInsertSql(StringInfo buf, char *orig_query,
appendBinaryStringInfo(buf, orig_query, values_end_len);
/*
* Add records to VALUES clause (we already have parameters for the
* first row, so start at the right offset).
* Add records to VALUES clause (we already have parameters for the first
* row, so start at the right offset).
*/
pindex = num_cols + 1;
for (i = 0; i < num_rows; i++)

View File

@ -1973,8 +1973,8 @@ postgresGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo)
Assert(resultRelInfo->ri_BatchSize == 0);
/*
* Should never get called when the insert is being performed as part of
* a row movement operation.
* Should never get called when the insert is being performed as part of a
* row movement operation.
*/
Assert(fmstate == NULL || fmstate->aux_fmstate == NULL);
@ -2117,13 +2117,13 @@ postgresBeginForeignInsert(ModifyTableState *mtstate,
/*
* If the foreign table is a partition that doesn't have a corresponding
* RTE entry, we need to create a new RTE
* describing the foreign table for use by deparseInsertSql and
* create_foreign_modify() below, after first copying the parent's RTE and
* modifying some fields to describe the foreign partition to work on.
* However, if this is invoked by UPDATE, the existing RTE may already
* correspond to this partition if it is one of the UPDATE subplan target
* rels; in that case, we can just use the existing RTE as-is.
* RTE entry, we need to create a new RTE describing the foreign table for
* use by deparseInsertSql and create_foreign_modify() below, after first
* copying the parent's RTE and modifying some fields to describe the
* foreign partition to work on. However, if this is invoked by UPDATE,
* the existing RTE may already correspond to this partition if it is one
* of the UPDATE subplan target rels; in that case, we can just use the
* existing RTE as-is.
*/
if (resultRelInfo->ri_RangeTableIndex == 0)
{
@ -2847,8 +2847,8 @@ postgresExplainForeignModify(ModifyTableState *mtstate,
ExplainPropertyText("Remote SQL", sql, es);
/*
* For INSERT we should always have batch size >= 1, but UPDATE
* and DELETE don't support batching so don't show the property.
* For INSERT we should always have batch size >= 1, but UPDATE and
* DELETE don't support batching so don't show the property.
*/
if (rinfo->ri_BatchSize > 0)
ExplainPropertyInteger("Batch Size", NULL, rinfo->ri_BatchSize, es);
@ -7265,8 +7265,8 @@ get_batch_size_option(Relation rel)
int batch_size = 1;
/*
* Load options for table and server. We append server options after
* table options, because table options take precedence.
* Load options for table and server. We append server options after table
* options, because table options take precedence.
*/
table = GetForeignTable(foreigntableid);
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
* to the output bitmap.
*
* The opclass may or may not support processing of multiple
* scan keys. We can determine that based on the number of
* arguments - functions with extra parameter (number of scan
* keys) do support this, otherwise we have to simply pass the
* scan keys one by one.
* The opclass may or may not support processing of
* multiple scan keys. We can determine that based on the
* number of arguments - functions with extra parameter
* (number of scan keys) do support this, otherwise we
* have to simply pass the scan keys one by one.
*/
if (consistentFn[attno - 1].fn_nargs >= 4)
{
@ -667,10 +667,10 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
/*
* Check keys one by one
*
* When there are multiple scan keys, failure to meet the
* criteria for a single one of them is enough to discard
* the range as a whole, so break out of the loop as soon
* as a false return value is obtained.
* When there are multiple scan keys, failure to meet
* the criteria for a single one of them is enough to
* discard the range as a whole, so break out of the
* loop as soon as a false return value is obtained.
*/
int keyno;

View File

@ -670,11 +670,11 @@ range_serialize(Ranges *range)
/*
* For values passed by value, we need to copy just the
* significant bytes - we can't use memcpy directly, as that
* assumes little endian behavior. store_att_byval does
* almost what we need, but it requires properly aligned
* buffer - the output buffer does not guarantee that. So we
* simply use a local Datum variable (which guarantees proper
* alignment), and then copy the value from it.
* assumes little endian behavior. store_att_byval does almost
* what we need, but it requires properly aligned buffer - the
* output buffer does not guarantee that. So we simply use a local
* Datum variable (which guarantees proper alignment), and then
* copy the value from it.
*/
store_att_byval(&tmp, range->values[i], typlen);
@ -825,6 +825,7 @@ range_deserialize(int maxvalues, SerializedRanges *serialized)
else if (typlen == -2) /* cstring */
{
Size slen = strlen(ptr) + 1;
range->values[i] = PointerGetDatum(dataptr);
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
* months have 30 days for consistency with interval_cmp_internal.
* We don't need to be exact, in the worst case we'll build a bit less
* months have 30 days for consistency with interval_cmp_internal. We
* 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.
*/
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
* addresses by first address in the range, so A.B.C.D/24 < A.B.C.1
* (the first range starts at A.B.C.0, which is before A.B.C.1). We
* don't want to produce negative delta in this case, so we just cut
* the extra bytes.
* addresses by first address in the range, so A.B.C.D/24 < A.B.C.1 (the
* first range starts at A.B.C.0, which is before A.B.C.1). We don't want
* to produce negative delta in this case, so we just cut the extra bytes.
*
* XXX Maybe this should be a bit more careful and cut the bits, not
* just whole bytes.
* XXX Maybe this should be a bit more careful and cut the bits, not just
* whole bytes.
*/
lena = ip_bits(ipa);
lenb = ip_bits(ipb);

View File

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

View File

@ -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
* depending on outside storage.
*
* XXX Is this actually true? Could it be that the summary is
* NULL even for range with non-NULL data? E.g. degenerate bloom
* filter may be thrown away, etc.
* XXX Is this actually true? Could it be that the summary is NULL
* even for range with non-NULL data? E.g. degenerate bloom filter
* may be thrown away, etc.
*/
if (VARATT_IS_EXTERNAL(DatumGetPointer(value)))
{
@ -213,8 +213,8 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
}
/*
* If value is above size target, and is of a compressible datatype,
* try to compress it in-line.
* If value is above size target, and is of a compressible
* datatype, try to compress it in-line.
*/
if (!VARATT_IS_EXTENDED(DatumGetPointer(value)) &&
VARSIZE(DatumGetPointer(value)) > TOAST_INDEX_TARGET &&

View File

@ -109,8 +109,8 @@ index_form_tuple(TupleDesc tupleDescriptor,
/*
* If the compression method is not valid, use the default. We
* don't expect this to happen for regular index columns, which
* inherit the setting from the corresponding table column, but
* we do expect it to happen whenever an expression is indexed.
* inherit the setting from the corresponding table column, but we
* do expect it to happen whenever an expression is indexed.
*/
if (!CompressionMethodIsValid(compression))
compression = GetDefaultToastCompression();

View File

@ -258,9 +258,9 @@ toast_get_compression_id(struct varlena *attr)
ToastCompressionId cmid = TOAST_INVALID_COMPRESSION_ID;
/*
* If it is stored externally then fetch the compression method id from the
* external toast pointer. If compressed inline, fetch it from the toast
* compression header.
* If it is stored externally then fetch the compression method id from
* the external toast pointer. If compressed inline, fetch it from the
* toast compression header.
*/
if (VARATT_IS_EXTERNAL_ONDISK(attr))
{

View File

@ -432,11 +432,11 @@ heapgetpage(TableScanDesc sscan, BlockNumber page)
* transactions on the primary might still be invisible to a read-only
* 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
* page all-visible on the primary and WAL log that along with the visibility
* map SET operation. In hot standby, we wait for (or abort) all
* transactions that can potentially may not see one or more tuples on the
* page. That's how index-only scans work fine in hot standby. A crucial
* difference between index-only scans and heap scans is that the
* page all-visible on the primary and WAL log that along with the
* visibility map SET operation. In hot standby, we wait for (or abort)
* all transactions that can potentially may not see one or more tuples on
* the page. That's how index-only scans work fine in hot standby. A
* crucial difference between index-only scans and heap scans is that the
* index-only scan completely relies on the visibility map where as heap
* scan looks at the page-level PD_ALL_VISIBLE flag. We are not sure if
* the page-level flag can be trusted in the same way, because it might
@ -2095,11 +2095,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
/*
* If we're inserting frozen entry into an empty page,
* set visibility map bits and PageAllVisible() hint.
* If we're inserting frozen entry into an empty page, set visibility map
* bits and PageAllVisible() hint.
*
* If we're inserting frozen entry into already all_frozen page,
* preserve this state.
* If we're inserting frozen entry into already all_frozen page, preserve
* this state.
*/
if (options & HEAP_INSERT_FROZEN)
{
@ -2139,8 +2139,8 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
(options & HEAP_INSERT_SPECULATIVE) != 0);
/*
* If the page is all visible, need to clear that, unless we're only
* going to add further frozen rows to it.
* If the page is all visible, need to clear that, unless we're only going
* to add further frozen rows to it.
*
* If we're only adding already frozen rows to a page that was empty or
* marked as all visible, mark it as all-visible.
@ -2258,11 +2258,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
END_CRIT_SECTION();
/*
* If we've frozen everything on the page, update the visibilitymap.
* We're already holding pin on the vmbuffer.
* If we've frozen everything on the page, update the visibilitymap. We're
* already holding pin on the vmbuffer.
*
* No need to update the visibilitymap if it had all_frozen bit set
* before this insertion.
* No need to update the visibilitymap if it had all_frozen bit set before
* this insertion.
*/
if (all_frozen_set && ((vmstatus & VISIBILITYMAP_ALL_FROZEN) == 0))
{
@ -2270,9 +2270,9 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
Assert(visibilitymap_pin_ok(BufferGetBlockNumber(buffer), vmbuffer));
/*
* It's fine to use InvalidTransactionId here - this is only used
* when HEAP_INSERT_FROZEN is specified, which intentionally
* violates visibility rules.
* It's fine to use InvalidTransactionId here - this is only used when
* HEAP_INSERT_FROZEN is specified, which intentionally violates
* visibility rules.
*/
visibilitymap_set(relation, BufferGetBlockNumber(buffer), buffer,
InvalidXLogRecPtr, vmbuffer,
@ -3063,7 +3063,10 @@ l1:
xl_heap_header xlhdr;
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))
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
* in the total number of promising entries, so that the whole process can
* give a little weight to heapam factors (like heap block locality)
* instead. This isn't a trade-off, really -- we have nothing to lose.
* It would be foolish to interpret small differences in npromisingtids
* instead. This isn't a trade-off, really -- we have nothing to lose. It
* would be foolish to interpret small differences in npromisingtids
* values as anything more than noise.
*
* We tiebreak on nhtids when sorting block group subsets that have the
* same npromisingtids, but this has the same issues as npromisingtids,
* and so nhtids is subject to the same power-of-two bucketing scheme.
* The only reason that we don't fix nhtids in the same way here too is
* that we'll need accurate nhtids values after the sort. We handle
* nhtids bucketization dynamically instead (in the sort comparator).
* and so nhtids is subject to the same power-of-two bucketing scheme. The
* only reason that we don't fix nhtids in the same way here too is that
* we'll need accurate nhtids values after the sort. We handle nhtids
* bucketization dynamically instead (in the sort comparator).
*
* See bottomup_nblocksfavorable() for a full explanation of when and how
* heap locality/favorable blocks can significantly influence when and how

View File

@ -1659,9 +1659,9 @@ heapam_index_build_range_scan(Relation heapRelation,
offnum = ItemPointerGetOffsetNumber(&heapTuple->t_self);
/*
* If a HOT tuple points to a root that we don't know
* about, obtain root items afresh. If that still fails,
* report it as corruption.
* If a HOT tuple points to a root that we don't know about,
* obtain root items afresh. If that still fails, report it as
* corruption.
*/
if (root_offsets[offnum - 1] == InvalidOffsetNumber)
{

View File

@ -1608,8 +1608,8 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
/*
* 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
* values externally.
* cmin/cmax was stored in a combo CID. So we need to lookup the
* actual values externally.
*/
resolved = ResolveCminCmaxDuringDecoding(HistoricSnapshotGetTupleCids(), snapshot,
htup, buffer,
@ -1629,8 +1629,8 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
* elog inside ResolveCminCmaxDuringDecoding.
*
* XXX For the streaming case, we can track the largest combo CID
* assigned, and error out based on this (when unable to resolve
* combo CID below that observed maximum value).
* assigned, and error out based on this (when unable to resolve combo
* CID below that observed maximum value).
*/
if (!resolved)
return false;
@ -1717,8 +1717,8 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
* elog inside ResolveCminCmaxDuringDecoding.
*
* XXX For the streaming case, we can track the largest combo CID
* assigned, and error out based on this (when unable to resolve
* combo CID below that observed maximum value).
* assigned, and error out based on this (when unable to resolve combo
* CID below that observed maximum value).
*/
if (!resolved || cmax == InvalidCommandId)
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
* give up and extend. This avoids one-tuple-per-page syndrome during
* If the FSM knows nothing of the rel, try the last page before we give
* up and extend. This avoids one-tuple-per-page syndrome during
* bootstrapping or in a recently-started system.
*/
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
* clean the page. The primary will likely issue a cleaning WAL record soon
* anyway, so this is no particular loss.
* clean the page. The primary will likely issue a cleaning WAL record
* soon anyway, so this is no particular loss.
*/
if (RecoveryInProgress())
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
* remain in the table due to VACUUM bypassing index and heap vacuuming.
* ANALYZE will consider the remaining LP_DEAD items to be dead tuples.
* It seems like a good idea to err on the side of not vacuuming again too
* ANALYZE will consider the remaining LP_DEAD items to be dead tuples. It
* 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
* vacuuming.
*/

View File

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

View File

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

View File

@ -3283,9 +3283,9 @@ multixact_redo(XLogReaderState *record)
xlrec->moff + xlrec->nmembers);
/*
* Make sure nextXid is beyond any XID mentioned in the record.
* This should be unnecessary, since any XID found here ought to have
* other evidence in the XLOG, but let's be safe.
* Make sure nextXid is beyond any XID mentioned in the record. This
* should be unnecessary, since any XID found here ought to have other
* evidence in the XLOG, but let's be safe.
*/
max_xid = XLogRecGetXid(record);
for (i = 0; i < xlrec->nmembers; i++)

View File

@ -1134,9 +1134,9 @@ EndPrepare(GlobalTransaction gxact)
gxact->prepare_start_lsn = ProcLastRecPtr;
/*
* Mark the prepared transaction as valid. As soon as xact.c marks
* MyProc as not running our XID (which it will do immediately after
* this function returns), others can commit/rollback the xact.
* Mark the prepared transaction as valid. As soon as xact.c marks MyProc
* as not running our XID (which it will do immediately after this
* function returns), others can commit/rollback the xact.
*
* 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 /

View File

@ -179,10 +179,10 @@ GetNewTransactionId(bool isSubXact)
ExtendSUBTRANS(xid);
/*
* Now advance the nextXid counter. This must not happen until after
* we have successfully completed ExtendCLOG() --- if that routine fails,
* we want the next incoming transaction to try it again. We cannot
* assign more XIDs until there is CLOG space for them.
* Now advance the nextXid counter. This must not happen until after we
* have successfully completed ExtendCLOG() --- if that routine fails, we
* want the next incoming transaction to try it again. We cannot assign
* more XIDs until there is CLOG space for them.
*/
FullTransactionIdAdvance(&ShmemVariableCache->nextXid);
@ -192,8 +192,8 @@ GetNewTransactionId(bool isSubXact)
* latestCompletedXid is present in the ProcArray, which is essential for
* correct OldestXmin tracking; see src/backend/access/transam/README.
*
* Note that readers of ProcGlobal->xids/PGPROC->xid should be careful
* to fetch the value for each proc only once, rather than assume they can
* Note that readers of ProcGlobal->xids/PGPROC->xid should be careful to
* 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
* are assuming that TransactionId and int fetch/store are atomic.
*
@ -281,9 +281,9 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
uint32 epoch;
/*
* It is safe to read nextXid without a lock, because this is only
* called from the startup process or single-process mode, meaning that no
* other process can modify it.
* It is safe to read nextXid without a lock, because this is only called
* from the startup process or single-process mode, meaning that no other
* process can modify it.
*/
Assert(AmStartupProcess() || !IsUnderPostmaster);
@ -617,8 +617,8 @@ AssertTransactionIdInAllowableRange(TransactionId xid)
* 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
* 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
* the lower 32bit, so a skewed read doesn't hurt.
* 32bit reads to be atomic. While nextXid is 64 bit, we only look at the
* lower 32bit, so a skewed read doesn't hurt.
*
* There's no increased danger of falling outside [oldest, next] by
* accessing them without a lock. xid needs to have been created with

View File

@ -3814,8 +3814,8 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
* 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
* streaming replication is set up, we'll read the timeline history file
* streamed from the primary when we start streaming, instead of recovering
* with a dummy history generated here.
* streamed from the primary when we start streaming, instead of
* recovering with a dummy history generated here.
*/
if (expectedTLEs)
tles = expectedTLEs;
@ -6347,7 +6347,11 @@ RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
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.",
param_name,
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
* are in the loop, user might resume and pause again so set
* this every time.
* If recovery pause is requested then set it paused. While
* we are in the loop, user might resume and pause again so
* set this every time.
*/
ConfirmRecoveryPaused();
/*
* We wait on a condition variable that will wake us as soon as
* the pause ends, but we use a timeout so we can check the
* We wait on a condition variable that will wake us as soon
* as the pause ends, but we use a timeout so we can check the
* above conditions periodically too.
*/
ConditionVariableTimedSleep(&XLogCtl->recoveryNotPausedCV, 1000,
@ -6920,9 +6924,8 @@ StartupXLOG(void)
StartupReorderBuffer();
/*
* Startup CLOG. This must be done after ShmemVariableCache->nextXid
* has been initialized and before we accept connections or begin WAL
* replay.
* Startup CLOG. This must be done after ShmemVariableCache->nextXid has
* been initialized and before we accept connections or begin WAL replay.
*/
StartupCLOG();
@ -6969,11 +6972,11 @@ StartupXLOG(void)
* ourselves - the history file of the recovery target timeline covers all
* the previous timelines in the history too - a cascading standby server
* might be interested in them. Or, if you archive the WAL from this
* server to a different archive than the primary, it'd be good for all the
* history files to get archived there after failover, so that you can use
* one of the old timelines as a PITR target. Timeline history files are
* small, so it's better to copy them unnecessarily than not copy them and
* regret later.
* server to a different archive than the primary, it'd be good for all
* the history files to get archived there after failover, so that you can
* use one of the old timelines as a PITR target. Timeline history files
* are small, so it's better to copy them unnecessarily than not copy them
* and regret later.
*/
restoreTimeLineHistoryFiles(ThisTimeLineID, recoveryTargetTLI);
@ -7196,9 +7199,9 @@ StartupXLOG(void)
ProcArrayInitRecovery(XidFromFullTransactionId(ShmemVariableCache->nextXid));
/*
* Startup subtrans only. CLOG, MultiXact and commit
* timestamp have already been started up and other SLRUs are not
* maintained during recovery and need not be started yet.
* Startup subtrans only. CLOG, MultiXact and commit timestamp
* have already been started up and other SLRUs are not maintained
* during recovery and need not be started yet.
*/
StartupSUBTRANS(oldestActiveXID);
@ -7400,8 +7403,7 @@ StartupXLOG(void)
error_context_stack = &errcallback;
/*
* ShmemVariableCache->nextXid must be beyond record's
* xid.
* ShmemVariableCache->nextXid must be beyond record's xid.
*/
AdvanceNextFullTransactionIdPastXid(record->xl_xid);
@ -8092,10 +8094,10 @@ StartupXLOG(void)
WalSndWakeup();
/*
* If this was a promotion, request an (online) checkpoint now. This
* isn't required for consistency, but the last restartpoint might be far
* back, and in case of a crash, recovering from it might take a longer
* than is appropriate now that we're not in standby mode anymore.
* If this was a promotion, request an (online) checkpoint now. This isn't
* required for consistency, but the last restartpoint might be far back,
* and in case of a crash, recovering from it might take a longer than is
* appropriate now that we're not in standby mode anymore.
*/
if (promoted)
RequestCheckpoint(CHECKPOINT_FORCE);
@ -12177,8 +12179,8 @@ retry:
Assert(readFile != -1);
/*
* If the current segment is being streamed from the primary, calculate how
* much of the current page we have received already. We know the
* If the current segment is being streamed from the primary, calculate
* 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
* 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
* 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
* in pg_wal, and we should stream it from the primary. There is a recycled
* WAL segment present in pg_wal, with garbage contents, however. We would
* read the first page from the local WAL segment, but when reading the
* second page, we would read the bogus, recycled, WAL segment. If we
* didn't catch that case here, we would never recover, because
* ReadRecord() would retry reading the whole record from the beginning.
* in pg_wal, and we should stream it from the primary. There is a
* recycled WAL segment present in pg_wal, with garbage contents, however.
* We would read the first page from the local WAL segment, but when
* reading the second page, we would read the bogus, recycled, WAL
* segment. If we didn't catch that case here, we would never recover,
* because ReadRecord() would retry reading the whole record from the
* beginning.
*
* 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
@ -12399,15 +12402,15 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
* Failure while streaming. Most likely, we got here
* because streaming replication was terminated, or
* promotion was triggered. But we also get here if we
* find an invalid record in the WAL streamed from the primary,
* in which case something is seriously wrong. There's
* little chance that the problem will just go away, but
* PANIC is not good for availability either, especially
* in hot standby mode. So, we treat that the same as
* disconnection, and retry from archive/pg_wal again. The
* WAL in the archive should be identical to what was
* streamed, so it's unlikely that it helps, but one can
* hope...
* find an invalid record in the WAL streamed from the
* primary, in which case something is seriously wrong.
* There's little chance that the problem will just go
* away, but PANIC is not good for availability either,
* especially in hot standby mode. So, we treat that the
* same as disconnection, and retry from archive/pg_wal
* again. The WAL in the archive should be identical to
* what was streamed, so it's unlikely that it helps, but
* one can hope...
*/
/*

View File

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

View File

@ -931,6 +931,7 @@ gettype(char *type)
foreach(lc, Typ)
{
struct typmap *app = lfirst(lc);
if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0)
{
Ap = app;
@ -948,12 +949,13 @@ gettype(char *type)
populate_typ_list();
/*
* Calling gettype would result in infinite recursion for types missing
* in pg_type, so just repeat the lookup.
* Calling gettype would result in infinite recursion for types
* missing in pg_type, so just repeat the lookup.
*/
foreach(lc, Typ)
{
struct typmap *app = lfirst(lc);
if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0)
{
Ap = app;

View File

@ -94,7 +94,8 @@ sub ParseHeader
push @{ $catalog{toasting} },
{ 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} },
{
@ -105,7 +106,9 @@ sub ParseHeader
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} },
{

View File

@ -3926,8 +3926,8 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
ReleaseSysCache(tuple);
/*
* Check if ACL_SELECT is being checked and, if so, and not set already
* as part of the result, then check if the user is a member of the
* Check if ACL_SELECT is being checked and, if so, and not set already as
* 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.
*/
if (mask & ACL_SELECT && !(result & ACL_SELECT) &&
@ -3935,11 +3935,11 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
result |= ACL_SELECT;
/*
* Check if ACL_INSERT, ACL_UPDATE, or ACL_DELETE is being checked
* and, if so, and not set already as part of the result, then check
* if the user is a member of the pg_write_all_data role, which
* allows INSERT/UPDATE/DELETE access to all relations (except
* system catalogs, which requires superuser, see above).
* Check if ACL_INSERT, ACL_UPDATE, or ACL_DELETE is being checked and, if
* so, and not set already as part of the result, then check if the user
* is a member of the pg_write_all_data role, which allows
* INSERT/UPDATE/DELETE access to all relations (except system catalogs,
* which requires superuser, see above).
*/
if (mask & (ACL_INSERT | ACL_UPDATE | ACL_DELETE) &&
!(result & (ACL_INSERT | ACL_UPDATE | ACL_DELETE)) &&
@ -4273,10 +4273,10 @@ pg_namespace_aclmask(Oid nsp_oid, Oid roleid,
ReleaseSysCache(tuple);
/*
* Check if ACL_USAGE is being checked and, if so, and not set already
* as 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
* access to all schemas.
* Check if ACL_USAGE is being checked and, if so, and not set already as
* 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 access
* to all schemas.
*/
if (mask & ACL_USAGE && !(result & ACL_USAGE) &&
(has_privs_of_role(roleid, ROLE_PG_READ_ALL_DATA) ||

View File

@ -382,8 +382,8 @@ ConstructTupleDescriptor(Relation heapRelation,
* For expression columns, set attcompression invalid, since
* there's no table column from which to copy the value. Whenever
* we actually need to compress a value, we'll use whatever the
* current value of default_compression_method is at that point
* in time.
* current value of default_compression_method is at that point in
* time.
*/
to->attcompression = InvalidCompressionMethod;
@ -3619,8 +3619,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
SetRelationTableSpace(iRel, params->tablespaceOid, InvalidOid);
/*
* Schedule unlinking of the old index storage at transaction
* commit.
* Schedule unlinking of the old index storage at transaction commit.
*/
RelationDropStorage(iRel);
RelationAssumeNewRelfilenode(iRel);

View File

@ -96,7 +96,8 @@
*/
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 oid_index_oid; /* oid of index 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,
object->objectSubId,
missing_ok);
if (!attname)
break;
@ -2888,6 +2890,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
bits16 flags = FORMAT_PROC_INVALID_AS_NULL;
char *proname = format_procedure_extended(object->objectId,
flags);
if (proname == NULL)
break;
@ -2900,6 +2903,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
bits16 flags = FORMAT_TYPE_INVALID_AS_NULL;
char *typname = format_type_extended(object->objectId, -1,
flags);
if (typname == NULL)
break;
@ -3861,6 +3865,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
{
char *pubname = get_publication_name(object->objectId,
missing_ok);
if (pubname)
appendStringInfo(&buffer, _("publication %s"), pubname);
break;
@ -3901,6 +3906,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
{
char *subname = get_subscription_name(object->objectId,
missing_ok);
if (subname)
appendStringInfo(&buffer, _("subscription %s"), subname);
break;
@ -4708,6 +4714,7 @@ getObjectIdentityParts(const ObjectAddress *object,
bits16 flags = FORMAT_PROC_FORCE_QUALIFY | FORMAT_PROC_INVALID_AS_NULL;
char *proname = format_procedure_extended(object->objectId,
flags);
if (proname == NULL)
break;
@ -4957,6 +4964,7 @@ getObjectIdentityParts(const ObjectAddress *object,
bits16 flags = FORMAT_OPERATOR_FORCE_QUALIFY | FORMAT_OPERATOR_INVALID_AS_NULL;
char *oprname = format_operator_extended(object->objectId,
flags);
if (oprname == NULL)
break;

View File

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

View File

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

View File

@ -351,9 +351,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
table_close(class_rel, RowExclusiveLock);
/*
* Register dependency from the toast table to the main, so that the
* toast table will be deleted if the main is. Skip this in bootstrap
* mode.
* Register dependency from the toast table to the main, so that the toast
* table will be deleted if the main is. Skip this in bootstrap mode.
*/
if (!IsBootstrapProcessingMode())
{
@ -396,9 +395,9 @@ needs_toast_table(Relation rel)
/*
* Ignore attempts to create toast tables on catalog tables after initdb.
* Which catalogs get toast tables is explicitly chosen in
* catalog/pg_*.h. (We could get here via some ALTER TABLE command if
* the catalog doesn't have a toast table.)
* Which catalogs get toast tables is explicitly chosen in catalog/pg_*.h.
* (We could get here via some ALTER TABLE command if the catalog doesn't
* have a toast table.)
*/
if (IsCatalogRelation(rel) && !IsBootstrapProcessingMode())
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
* during a VACUUM ANALYZE. Although VACUUM often updates pg_class,
* exceptions exist. A "VACUUM (ANALYZE, INDEX_CLEANUP OFF)" command
* will never update pg_class entries for index relations. It's also
* possible that an individual index's pg_class entry won't be updated
* during VACUUM if the index AM returns NULL from its amvacuumcleanup()
* routine.
* exceptions exist. A "VACUUM (ANALYZE, INDEX_CLEANUP OFF)" command will
* never update pg_class entries for index relations. It's also possible
* that an individual index's pg_class entry won't be updated during
* VACUUM if the index AM returns NULL from its amvacuumcleanup() routine.
*/
if (!inh)
{
@ -659,9 +658,9 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
else if (onerel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
/*
* Partitioned tables don't have storage, so we don't set any fields in
* their pg_class entries except for reltuples, which is necessary for
* auto-analyze to work properly.
* Partitioned tables don't have storage, so we don't set any fields
* in their pg_class entries except for reltuples, which is necessary
* for auto-analyze to work properly.
*/
vac_update_relstats(onerel, -1, totalrows,
0, false, InvalidTransactionId,

View File

@ -17745,8 +17745,8 @@ ATExecDetachPartition(List **wqueue, AlteredTableInfo *tab, Relation rel,
AccessExclusiveLock);
/*
* Check inheritance conditions and either delete the pg_inherits row
* (in non-concurrent mode) or just set the inhdetachpending flag.
* Check inheritance conditions and either delete the pg_inherits row (in
* non-concurrent mode) or just set the inhdetachpending flag.
*/
if (!concurrent)
RemoveInheritance(partRel, rel, false);
@ -17815,10 +17815,10 @@ ATExecDetachPartition(List **wqueue, AlteredTableInfo *tab, Relation rel,
StartTransactionCommand();
/*
* Now wait. This ensures that all queries that were planned including
* the partition are finished before we remove the rest of catalog
* entries. We don't need or indeed want to acquire this lock, though
* -- that would block later queries.
* Now wait. This ensures that all queries that were planned
* including the partition are finished before we remove the rest of
* catalog entries. We don't need or indeed want to acquire this
* lock, though -- that would block later queries.
*
* We don't need to concern ourselves with waiting for a lock on the
* partition itself, since we will acquire AccessExclusiveLock below.

View File

@ -1579,8 +1579,8 @@ DefineRange(CreateRangeStmt *stmt)
ObjectIdGetDatum(multirangeNamespace));
/*
* If it's not a shell, see if it's an autogenerated array type, and if so
* rename it out of the way.
* If it's not a shell, see if it's an autogenerated array type, and
* if so rename it out of the way.
*/
if (OidIsValid(old_typoid) && get_typisdefined(old_typoid))
{

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
* multixact. In any case no less than autovacuum_multixact_freeze_max_age
* * 1.05.
* multixact. In any case no less than autovacuum_multixact_freeze_max_age *
* 1.05.
*/
skip_index_vacuum = Max(vacuum_multixact_failsafe_age,
autovacuum_multixact_freeze_max_age * 1.05);

View File

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

View File

@ -132,8 +132,8 @@ ExecutorStart(QueryDesc *queryDesc, int eflags)
/*
* 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
* that it's harmless to report the query_id multiple time, as the call will
* be ignored if the top level query_id has already been reported.
* that it's harmless to report the query_id multiple time, as the call
* will be ignored if the top level query_id has already been reported.
*/
pgstat_report_query_id(queryDesc->plannedstmt->queryId, false);

View File

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

View File

@ -1580,6 +1580,7 @@ find_hash_columns(AggState *aggstate)
for (int i = 0; i < scanDesc->natts; i++)
{
int colno = i + 1;
if (bms_is_member(colno, aggstate->colnos_needed))
aggstate->max_colno_needed = colno;
else

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
* sync subplan by initializing whichplan to -1. If there happen to be
* no valid sync subplans then the bms member function will handle that
* by returning a negative number which will allow us to exit returning a
* sync subplan by initializing whichplan to -1. If there happen to be no
* valid sync subplans then the bms member function will handle that by
* returning a negative number which will allow us to exit returning a
* false value.
*/
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
* given node. Otherwise, we're done with the asynchronous stuff but
* must continue scanning the sync subplans.
* given node. Otherwise, we're done with the asynchronous stuff but must
* continue scanning the sync subplans.
*/
if (node->as_syncdone)
{
@ -1054,8 +1054,8 @@ ExecAppendAsyncEventWait(AppendState *node)
/*
* Mark it as no longer needing a callback. We must do this
* before dispatching the callback in case the callback resets
* the flag.
* before dispatching the callback in case the callback resets the
* flag.
*/
Assert(areq->callback_pending);
areq->callback_pending = false;

View File

@ -701,8 +701,8 @@ gather_merge_readnext(GatherMergeState *gm_state, int reader, bool nowait)
/* Build the TupleTableSlot for the given tuple */
ExecStoreMinimalTuple(tup, /* tuple to store */
gm_state->gm_slots[reader], /* slot in which to store
* the tuple */
gm_state->gm_slots[reader], /* slot in which to
* store the tuple */
true); /* pfree tuple when done with it */
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
* by the first ExecProcNode.
* If chgParam of subnode is not null, then the plan will be re-scanned by
* the first ExecProcNode.
*/
if (outerPlan->chgParam == NULL)
ExecReScan(outerPlan);

View File

@ -673,9 +673,9 @@ ExecInsert(ModifyTableState *mtstate,
if (resultRelInfo->ri_BatchSize > 1)
{
/*
* If a certain number of tuples have already been accumulated,
* or a tuple has come for a different relation than that for
* the accumulated tuples, perform the batch insert
* If a certain number of tuples have already been accumulated, or
* a tuple has come for a different relation than that for the
* accumulated tuples, perform the batch insert
*/
if (resultRelInfo->ri_NumSlots == resultRelInfo->ri_BatchSize)
{
@ -3091,12 +3091,12 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
mtstate->mt_resultOidHash = NULL;
/*
* Determine if the FDW supports batch insert and determine the batch
* size (a FDW may support batching, but it may be disabled for the
* Determine if the FDW supports batch insert and determine the batch size
* (a FDW may support batching, but it may be disabled for the
* server/table).
*
* We only do this for INSERT, so that for UPDATE/DELETE the batch
* size remains set to 0.
* We only do this for INSERT, so that for UPDATE/DELETE the batch size
* remains set to 0.
*/
if (operation == CMD_INSERT)
{

View File

@ -711,10 +711,9 @@ recv_password_packet(Port *port)
if (mtype != 'p')
{
/*
* If the client just disconnects without offering a password,
* don't make a log entry. This is legal per protocol spec and in
* fact commonly done by psql, so complaining just clutters the
* log.
* If the client just disconnects without offering a password, don't
* make a log entry. This is legal per protocol spec and in fact
* commonly done by psql, so complaining just clutters the log.
*/
if (mtype != EOF)
ereport(ERROR,

View File

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

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

View File

@ -4360,10 +4360,10 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
else
{
/*
* Set up to handle parameters while parsing the function body. We need a
* dummy FuncExpr node containing the already-simplified arguments to pass
* to prepare_sql_fn_parse_info. (In some cases we don't really need
* that, but for simplicity we always build it.)
* Set up to handle parameters while parsing the function body. We
* need a dummy FuncExpr node containing the already-simplified
* arguments to pass to prepare_sql_fn_parse_info. (In some cases we
* don't really need that, but for simplicity we always build it.)
*/
fexpr = makeNode(FuncExpr);
fexpr->funcid = funcid;
@ -4386,10 +4386,10 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
&rettupdesc);
/*
* We just do parsing and parse analysis, not rewriting, because rewriting
* will not affect table-free-SELECT-only queries, which is all that we
* care about. Also, we can punt as soon as we detect more than one
* command in the function body.
* We just do parsing and parse analysis, not rewriting, because
* rewriting will not affect table-free-SELECT-only queries, which is
* all that we care about. Also, we can punt as soon as we detect
* more than one command in the function body.
*/
raw_parsetree_list = pg_parse_query(src);
if (list_length(raw_parsetree_list) != 1)
@ -4932,8 +4932,8 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
else
{
/*
* Set up to handle parameters while parsing the function body. We can
* use the FuncExpr just created as the input for
* Set up to handle parameters while parsing the function body. We
* can use the FuncExpr just created as the input for
* prepare_sql_fn_parse_info.
*/
pinfo = prepare_sql_fn_parse_info(func_tuple,
@ -4941,9 +4941,9 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
fexpr->inputcollid);
/*
* Parse, analyze, and rewrite (unlike inline_function(), we can't skip
* rewriting here). We can fail as soon as we find more than one query,
* though.
* Parse, analyze, and rewrite (unlike inline_function(), we can't
* skip rewriting here). We can fail as soon as we find more than one
* query, though.
*/
raw_parsetree_list = pg_parse_query(src);
if (list_length(raw_parsetree_list) != 1)

View File

@ -1762,6 +1762,7 @@ cmp_list_len_contents_asc(const ListCell *a, const ListCell *b)
{
int va = lfirst_int(lca);
int vb = lfirst_int(lcb);
if (va > vb)
return 1;
if (va < vb)

View File

@ -2876,7 +2876,10 @@ check_new_partition_bound(char *relname, Relation parent,
{
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]);
if (spec->modulus % prev_modulus != 0)

View File

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

View File

@ -142,7 +142,11 @@ EnableLockPagesPrivilege(int elevel)
{
ereport(elevel,
(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"),
GetLastError()),
errdetail("Failed system call was %s.", "OpenProcessToken")));

View File

@ -660,6 +660,7 @@ PostmasterMain(int argc, char *argv[])
pqsignal_pm(SIGCHLD, reaper); /* handle child termination */
#ifdef SIGURG
/*
* Ignore SIGURG for now. Child processes may change this (see
* InitializeLatchSupport), but they will not receive any such signals

View File

@ -239,7 +239,8 @@ SysLoggerMain(int argc, char *argv[])
* 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(SIGTERM, SIG_IGN);
pqsignal(SIGQUIT, SIG_IGN);

View File

@ -67,12 +67,6 @@ typedef struct LogicalRepCtxStruct
LogicalRepCtxStruct *LogicalRepCtx;
typedef struct LogicalRepWorkerId
{
Oid subid;
Oid relid;
} LogicalRepWorkerId;
static void ApplyLauncherWakeup(void);
static void logicalrep_launcher_onexit(int code, Datum arg);
static void logicalrep_worker_onexit(int code, Datum arg);

View File

@ -576,8 +576,8 @@ CheckPointReplicationOrigin(void)
tmppath)));
/*
* no other backend can perform this at the same time; only one
* checkpoint can happen at a time.
* no other backend can perform this at the same time; only one checkpoint
* can happen at a time.
*/
tmpfd = OpenTransientFile(tmppath,
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
* SetupCheckXidLive.
*
* This error code can be thrown by one of the callbacks we call during
* decoding so we need to ensure that we return gracefully only when we are
* sending the data in streaming mode and the streaming is not finished yet
* or when we are sending the data out on a PREPARE during a two-phase
* commit.
* This error code can be thrown by one of the callbacks we call
* during decoding so we need to ensure that we return gracefully only
* when we are sending the data in streaming mode and the streaming is
* not finished yet or when we are sending the data out on a PREPARE
* during a two-phase commit.
*/
if (errdata->sqlerrcode == ERRCODE_TRANSACTION_ROLLBACK &&
(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
* another xl_running_xacts record in a timely manner, without having to
* wait for bgwriter or checkpointer to log one. During recovery we
* can't enforce that, so we'll have to wait.
* wait for bgwriter or checkpointer to log one. During recovery we can't
* enforce that, so we'll have to wait.
*/
if (!RecoveryInProgress())
{

View File

@ -451,8 +451,8 @@ retry:
/*
* 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
* after a short wait, as caller specified.
* either error out, return the PID of the owning process, or retry after
* a short wait, as caller specified.
*/
if (active_pid != MyProcPid)
{
@ -1204,20 +1204,20 @@ restart:
/*
* Try to mark this slot as used by this process.
*
* Note that ReplicationSlotAcquireInternal(SAB_Inquire)
* should not cancel the prepared condition variable
* if this slot is active in other process. Because in this case
* we have to wait on that CV for the process owning
* the slot to be terminated, later.
* Note that ReplicationSlotAcquireInternal(SAB_Inquire) should
* not cancel the prepared condition variable if this slot is
* active in other process. Because in this case we have to wait
* on that CV for the process owning the slot to be terminated,
* later.
*/
wspid = ReplicationSlotAcquireInternal(s, NULL, SAB_Inquire);
/*
* Exit the loop if we successfully acquired the slot or
* the slot was dropped during waiting for the owning process
* to be terminated. For example, the latter case is likely to
* happen when the slot is temporary because it's automatically
* dropped by the termination of the owning process.
* Exit the loop if we successfully acquired the slot or the slot
* was dropped during waiting for the owning process to be
* terminated. For example, the latter case is likely to happen
* when the slot is temporary because it's automatically dropped
* by the termination of the owning process.
*/
if (wspid <= 0)
break;
@ -1225,13 +1225,13 @@ restart:
/*
* Signal to terminate the process that owns the slot.
*
* There is the race condition where other process may own
* the slot after the process using it was terminated and before
* this process owns it. To handle this case, we signal again
* if the PID of the owning process is changed than the last.
* There is the race condition where other process may own the
* slot after the process using it was terminated and before this
* process owns it. To handle this case, we signal again if the
* PID of the owning process is changed than the last.
*
* XXX This logic assumes that the same PID is not reused
* very quickly.
* XXX This logic assumes that the same PID is not reused very
* quickly.
*/
if (last_signaled_pid != wspid)
{
@ -1248,8 +1248,8 @@ restart:
ConditionVariableCancelSleep();
/*
* Do nothing here and start from scratch if the slot has
* already been dropped.
* Do nothing here and start from scratch if the slot has already been
* dropped.
*/
if (wspid == -1)
goto restart;

View File

@ -165,12 +165,11 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
* Since this routine gets called every commit time, it's important to
* exit quickly if sync replication is not requested. So we check
* 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
* while holding the lock, to check the flag and operate the sync rep
* queue atomically. This is necessary to avoid the race condition
* described in SyncRepUpdateSyncStandbysDefined(). On the other
* hand, if it's false, the lock is not necessary because we don't touch
* the queue.
* immediately if it's false. If it's true, we need to check it again
* later while holding the lock, to check the flag and operate the sync
* rep queue atomically. This is necessary to avoid the race condition
* described in SyncRepUpdateSyncStandbysDefined(). On the other hand, if
* it's false, the lock is not necessary because we don't touch the queue.
*/
if (!SyncRepRequested() ||
!((volatile WalSndCtlData *) WalSndCtl)->sync_standbys_defined)

View File

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

View File

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

View File

@ -539,9 +539,9 @@ examine_attribute(Node *expr)
/*
* When analyzing an expression, believe the expression tree's type not
* the column datatype --- the latter might be the opckeytype storage
* type of the opclass, which is not interesting for our purposes. (Note:
* if we did anything with non-expression statistics columns, we'd need to
* the column datatype --- the latter might be the opckeytype storage type
* of the opclass, which is not interesting for our purposes. (Note: if
* 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
* not a problem.) It's not clear whether anyone will care about the
* 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
* covered by the chosen statistics.
*
* We need to check both attributes and expressions, and reject
* if either is not covered.
* We need to check both attributes and expressions, and reject if
* either is not covered.
*/
if (!bms_is_subset(list_attnums[listidx], stat->keys) ||
!stat_covers_expressions(stat, list_exprs[listidx], NULL))
continue;
/*
* Now we know the clause is compatible (we have either attnums
* or expressions extracted from it), and was not estimated yet.
* Now we know the clause is compatible (we have either attnums or
* expressions extracted from it), and was not estimated yet.
*/
/* record simple clauses (single column or expression) */

View File

@ -267,8 +267,8 @@ static void
SharedFileSetDeleteOnProcExit(int status, Datum arg)
{
/*
* Remove all the pending shared fileset entries. We don't use foreach() here
* because SharedFileSetDeleteAll will remove the current element in
* Remove all the pending shared fileset entries. We don't use foreach()
* here because SharedFileSetDeleteAll will remove the current element in
* 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
* loops, see SharedFileSetUnregister.

View File

@ -1655,9 +1655,9 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
(cur_kqueue_event->fflags & NOTE_EXIT) != 0)
{
/*
* The kernel will tell this kqueue object only once about the exit
* of the postmaster, so let's remember that for next time so that
* we provide level-triggered semantics.
* The kernel will tell this kqueue object only once about the
* exit of the postmaster, so let's remember that for next time so
* that we provide level-triggered semantics.
*/
set->report_postmaster_not_running = true;

View File

@ -2080,8 +2080,8 @@ GetSnapshotDataReuse(Snapshot snapshot)
* holding ProcArrayLock) exclusively). Thus the xactCompletionCount check
* ensures we would detect if the snapshot would have changed.
*
* As the snapshot contents are the same as it was before, it is safe
* to re-enter the snapshot's xmin into the PGPROC array. None of the rows
* As the snapshot contents are the same as it was before, it is safe to
* re-enter the snapshot's xmin into the PGPROC array. None of the rows
* visible under the snapshot could already have been removed (that'd
* require the set of running transactions to change) and it fulfills the
* requirement that concurrent GetSnapshotData() calls yield the same
@ -2259,10 +2259,10 @@ GetSnapshotData(Snapshot snapshot)
continue;
/*
* The only way we are able to get here with a non-normal xid
* is during bootstrap - with this backend using
* BootstrapTransactionId. But the above test should filter
* that out.
* The only way we are able to get here with a non-normal xid is
* during bootstrap - with this backend using
* BootstrapTransactionId. But the above test should filter that
* out.
*/
Assert(TransactionIdIsNormal(xid));

View File

@ -484,15 +484,15 @@ ProcessProcSignalBarrier(void)
* extract the flags, and that any subsequent state changes happen
* afterward.
*
* NB: In order to avoid race conditions, we must zero pss_barrierCheckMask
* first and only afterwards try to do barrier processing. If we did it
* in the other order, someone could send us another barrier of some
* type right after we called the barrier-processing function but before
* we cleared the bit. We would have no way of knowing that the bit needs
* to stay set in that case, so the need to call the barrier-processing
* function again would just get forgotten. So instead, we tentatively
* clear all the bits and then put back any for which we don't manage
* to successfully absorb the barrier.
* NB: In order to avoid race conditions, we must zero
* pss_barrierCheckMask first and only afterwards try to do barrier
* processing. If we did it in the other order, someone could send us
* another barrier of some type right after we called the
* barrier-processing function but before we cleared the bit. We would
* have no way of knowing that the bit needs to stay set in that case, so
* the need to call the barrier-processing function again would just get
* forgotten. So instead, we tentatively clear all the bits and then put
* back any for which we don't manage to successfully absorb the barrier.
*/
flags = pg_atomic_exchange_u32(&MyProcSignalSlot->pss_barrierCheckMask, 0);
@ -509,9 +509,9 @@ ProcessProcSignalBarrier(void)
{
/*
* Process each type of barrier. The barrier-processing functions
* should normally return true, but may return false if the barrier
* can't be absorbed at the current time. This should be rare,
* because it's pretty expensive. Every single
* should normally return true, but may return false if the
* barrier can't be absorbed at the current time. This should be
* rare, because it's pretty expensive. Every single
* CHECK_FOR_INTERRUPTS() will return here until we manage to
* absorb the barrier, and that cost will add up in a hurry.
*
@ -533,8 +533,8 @@ ProcessProcSignalBarrier(void)
}
/*
* To avoid an infinite loop, we must always unset the bit
* in flags.
* To avoid an infinite loop, we must always unset the bit in
* flags.
*/
BARRIER_CLEAR_BIT(flags, type);

View File

@ -138,6 +138,7 @@ pg_wait_until_termination(int pid, int64 timeout)
* timeout.
*/
int64 waittime = 100;
/*
* Initially remaining time is the entire timeout specified by the user.
*/

View File

@ -1245,8 +1245,8 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
/*
* Set timer so we can wake up after awhile and check for a deadlock. If a
* deadlock is detected, the handler sets MyProc->waitStatus =
* PROC_WAIT_STATUS_ERROR, allowing us to know that we must report failure rather
* than success.
* PROC_WAIT_STATUS_ERROR, allowing us to know that we must report failure
* rather than success.
*
* By delaying the check until we've waited for a bit, we can avoid
* running the rather expensive deadlock-check code in most cases.
@ -1371,9 +1371,9 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
}
/*
* waitStatus could change from PROC_WAIT_STATUS_WAITING to something else
* asynchronously. Read it just once per loop to prevent surprising
* behavior (such as missing log messages).
* waitStatus could change from PROC_WAIT_STATUS_WAITING to something
* else asynchronously. Read it just once per loop to prevent
* surprising behavior (such as missing log messages).
*/
myWaitStatus = *((volatile ProcWaitStatus *) &MyProc->waitStatus);
@ -1587,11 +1587,12 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
/*
* Currently, the deadlock checker always kicks its own
* process, which means that we'll only see PROC_WAIT_STATUS_ERROR when
* deadlock_state == DS_HARD_DEADLOCK, and there's no need to
* print redundant messages. But for completeness and
* future-proofing, print a message if it looks like someone
* else kicked us off the lock.
* process, which means that we'll only see
* PROC_WAIT_STATUS_ERROR when deadlock_state ==
* DS_HARD_DEADLOCK, and there's no need to print redundant
* messages. But for completeness and future-proofing, print
* a message if it looks like someone else kicked us off the
* lock.
*/
if (deadlock_state != DS_HARD_DEADLOCK)
ereport(LOG,
@ -1830,9 +1831,9 @@ CheckDeadLock(void)
* preserve the flexibility to kill some other transaction than the
* one detecting the deadlock.)
*
* RemoveFromWaitQueue sets MyProc->waitStatus to PROC_WAIT_STATUS_ERROR, so
* ProcSleep will report an error after we return from the signal
* handler.
* RemoveFromWaitQueue sets MyProc->waitStatus to
* PROC_WAIT_STATUS_ERROR, so ProcSleep will report an error after we
* return from the signal handler.
*/
Assert(MyProc->waitLock != NULL);
RemoveFromWaitQueue(MyProc, LockTagHashCode(&(MyProc->waitLock->tag)));

View File

@ -1033,7 +1033,8 @@ pgstat_get_my_query_id(void)
if (!MyBEEntry)
return 0;
/* There's no need for a lock around pgstat_begin_read_activity /
/*
* There's no need for a lock around pgstat_begin_read_activity /
* pgstat_end_read_activity here as it's only called from
* pg_stat_get_activity which is already protected, or from the same
* backend which means that there won't be concurrent writes.

View File

@ -2453,9 +2453,9 @@ column_privilege_check(Oid tableoid, AttrNumber attnum,
return -1;
/*
* Check for column-level privileges first. This serves in
* part as a check on whether the column even exists, so we
* need to do it before checking table-level privilege.
* Check for column-level privileges first. This serves in part as a check
* on whether the column even exists, so we need to do it before checking
* table-level privilege.
*/
aclresult = pg_attribute_aclcheck_ext(tableoid, attnum, roleid,
mode, &is_missing);

View File

@ -160,12 +160,11 @@ read_binary_file(const char *filename, int64 seek_offset, int64 bytes_to_read,
#define MIN_READ_SIZE 4096
/*
* If not at end of file, and sbuf.len is equal to
* MaxAllocSize - 1, then either the file is too large, or
* there is nothing left to read. Attempt to read one more
* byte to see if the end of file has been reached. If not,
* the file is too large; we'd rather give the error message
* for that ourselves.
* If not at end of file, and sbuf.len is equal to MaxAllocSize -
* 1, then either the file is too large, or there is nothing left
* to read. Attempt to read one more byte to see if the end of
* file has been reached. If not, the file is too large; we'd
* rather give the error message for that ourselves.
*/
if (sbuf.len == MaxAllocSize - 1)
{

View File

@ -636,10 +636,10 @@ pg_isolation_test_session_is_blocked(PG_FUNCTION_ARGS)
* Check if any of these are in the list of interesting PIDs, that being
* the sessions that the isolation tester is running. We don't use
* "arrayoverlaps" here, because it would lead to cache lookups and one of
* our goals is to run quickly with debug_invalidate_system_caches_always > 0. We expect
* blocking_pids to be usually empty and otherwise a very small number in
* isolation tester cases, so make that the outer loop of a naive search
* for a match.
* our goals is to run quickly with debug_invalidate_system_caches_always
* > 0. We expect blocking_pids to be usually empty and otherwise a very
* small number in isolation tester cases, so make that the outer loop of
* a naive search for a match.
*/
for (i = 0; i < num_blocking_pids; i++)
for (j = 0; j < num_interesting_pids; j++)

View File

@ -52,8 +52,8 @@ PutMemoryContextsStatsTupleStore(Tuplestorestate *tupstore,
ident = context->ident;
/*
* To be consistent with logging output, we label dynahash contexts
* with just the hash table name as with MemoryContextStatsPrint().
* To be consistent with logging output, we label dynahash contexts with
* just the hash table name as with MemoryContextStatsPrint().
*/
if (ident && strcmp(name, "dynahash") == 0)
{

View File

@ -394,8 +394,8 @@ RI_FKey_check(TriggerData *trigdata)
* Now check that foreign key exists in PK table
*
* XXX detectNewRows must be true when a partitioned table is on the
* referenced side. The reason is that our snapshot must be fresh
* in order for the hack in find_inheritance_children() to work.
* referenced side. The reason is that our snapshot must be fresh in
* order for the hack in find_inheritance_children() to work.
*/
ri_PerformCheck(riinfo, &qkey, qplan,
fk_rel, pk_rel,

View File

@ -1802,8 +1802,8 @@ hash_record(PG_FUNCTION_ARGS)
tuple.t_data = record;
/*
* We arrange to look up the needed hashing info just once per series
* of calls, assuming the record type doesn't change underneath us.
* We arrange to look up the needed hashing info just once per series of
* calls, assuming the record type doesn't change underneath us.
*/
my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
if (my_extra == NULL ||
@ -1923,8 +1923,8 @@ hash_record_extended(PG_FUNCTION_ARGS)
tuple.t_data = record;
/*
* We arrange to look up the needed hashing info just once per series
* of calls, assuming the record type doesn't change underneath us.
* We arrange to look up the needed hashing info just once per series of
* calls, assuming the record type doesn't change underneath us.
*/
my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
if (my_extra == NULL ||

View File

@ -2998,8 +2998,9 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
* We always use dollar quoting. Figure out a suitable delimiter.
*
* Since the user is likely to be editing the function body string, we
* shouldn't use a short delimiter that he might easily create a conflict
* with. Hence prefer "$function$"/"$procedure$", but extend if needed.
* shouldn't use a short delimiter that he might easily create a
* conflict with. Hence prefer "$function$"/"$procedure$", but extend
* if needed.
*/
initStringInfo(&dq);
appendStringInfoChar(&dq, '$');

View File

@ -3446,10 +3446,10 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows,
* XXX This has the consequence that if there's a statistics on the
* expression, we don't split it into individual Vars. This affects
* our selection of statistics in estimate_multivariate_ndistinct,
* because it's probably better to use more accurate estimate for
* each expression and treat them as independent, than to combine
* estimates for the extracted variables when we don't know how that
* relates to the expressions.
* because it's probably better to use more accurate estimate for each
* expression and treat them as independent, than to combine estimates
* for the extracted variables when we don't know how that relates to
* the expressions.
*/
examine_variable(root, groupexpr, 0, &vardata);
if (HeapTupleIsValid(vardata.statsTuple) || vardata.isunique)
@ -4039,16 +4039,16 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
/*
* Process a simple Var expression, by matching it to keys
* directly. If there's a matching expression, we'll try
* matching it later.
* directly. If there's a matching expression, we'll try matching
* it later.
*/
if (IsA(varinfo->var, Var))
{
AttrNumber attnum = ((Var *) varinfo->var)->varattno;
/*
* Ignore expressions on system attributes. Can't rely on
* the bms check for negative values.
* Ignore expressions on system attributes. Can't rely on the
* bms check for negative values.
*/
if (!AttrNumberIsForUserDefinedAttr(attnum))
continue;

View File

@ -3847,8 +3847,8 @@ timestamp_bin(PG_FUNCTION_ARGS)
tm_delta = tm_diff - tm_diff % stride_usecs;
/*
* Make sure the returned timestamp is at the start of the bin,
* even if the origin is in the future.
* Make sure the returned timestamp is at the start of the bin, even if
* the origin is in the future.
*/
if (origin > timestamp && stride_usecs > 1)
tm_delta -= stride_usecs;
@ -4025,8 +4025,8 @@ timestamptz_bin(PG_FUNCTION_ARGS)
tm_delta = tm_diff - tm_diff % stride_usecs;
/*
* Make sure the returned timestamp is at the start of the bin,
* even if the origin is in the future.
* Make sure the returned timestamp is at the start of the bin, even if
* the origin is in the future.
*/
if (origin > timestamp && stride_usecs > 1)
tm_delta -= stride_usecs;

View File

@ -692,26 +692,27 @@ AcceptInvalidationMessages(void)
/*
* Test code to force cache flushes anytime a flush could happen.
*
* This helps detect intermittent faults caused by code that reads a
* cache entry and then performs an action that could invalidate the entry,
* but rarely actually does so. This can spot issues that would otherwise
* This helps detect intermittent faults caused by code that reads a cache
* entry and then performs an action that could invalidate the entry, but
* rarely actually does so. This can spot issues that would otherwise
* only arise with badly timed concurrent DDL, for example.
*
* The default debug_invalidate_system_caches_always = 0 does no forced cache flushes.
* The default debug_invalidate_system_caches_always = 0 does no forced
* cache flushes.
*
* If used with CLOBBER_FREED_MEMORY, debug_invalidate_system_caches_always = 1
* (CLOBBER_CACHE_ALWAYS) provides a fairly thorough test that the system
* contains no cache-flush hazards. However, it also makes the system
* unbelievably slow --- the regression tests take about 100 times longer
* than normal.
* If used with CLOBBER_FREED_MEMORY,
* debug_invalidate_system_caches_always = 1 (CLOBBER_CACHE_ALWAYS)
* provides a fairly thorough test that the system contains no cache-flush
* hazards. However, it also makes the system unbelievably slow --- the
* regression tests take about 100 times longer than normal.
*
* If you're a glutton for punishment, try debug_invalidate_system_caches_always = 3
* (CLOBBER_CACHE_RECURSIVELY). This slows things by at least a factor
* of 10000, so I wouldn't suggest trying to run the entire regression
* tests that way. It's useful to try a few simple tests, to make sure
* that cache reload isn't subject to internal cache-flush hazards, but
* after you've done a few thousand recursive reloads it's unlikely
* you'll learn more.
* If you're a glutton for punishment, try
* debug_invalidate_system_caches_always = 3 (CLOBBER_CACHE_RECURSIVELY).
* This slows things by at least a factor of 10000, so I wouldn't suggest
* trying to run the entire regression tests that way. It's useful to try
* a few simple tests, to make sure that cache reload isn't subject to
* internal cache-flush hazards, but after you've done a few thousand
* recursive reloads it's unlikely you'll learn more.
*/
#ifdef CLOBBER_CACHE_ENABLED
{

View File

@ -897,8 +897,9 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
* rejected a generic plan, it's possible to reach here with is_valid
* false due to an invalidation while making the generic plan. In theory
* the invalidation must be a false positive, perhaps a consequence of an
* sinval reset event or the debug_invalidate_system_caches_always code. But for
* safety, let's treat it as real and redo the RevalidateCachedQuery call.
* sinval reset event or the debug_invalidate_system_caches_always code.
* But for safety, let's treat it as real and redo the
* RevalidateCachedQuery call.
*/
if (!plansource->is_valid)
qlist = RevalidateCachedQuery(plansource, queryEnv);

View File

@ -1016,9 +1016,9 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
*
* When cache clobbering is enabled or when forced to by
* RECOVER_RELATION_BUILD_MEMORY=1, arrange to allocate the junk in a
* temporary context that we'll free before returning. Make it a child
* of caller's context so that it will get cleaned up appropriately if
* we error out partway through.
* temporary context that we'll free before returning. Make it a child of
* caller's context so that it will get cleaned up appropriately if we
* error out partway through.
*/
#ifdef MAYBE_RECOVER_RELATION_BUILD_MEMORY
MemoryContext tmpcxt = NULL;

View File

@ -3257,6 +3257,7 @@ static struct config_int ConfigureNamesInt[] =
NULL
},
&autovacuum_freeze_max_age,
/*
* see pg_resetwal and vacuum_failsafe_age if you change the
* upper-limit value.

View File

@ -95,6 +95,7 @@ JumbleState *
JumbleQuery(Query *query, const char *querytext)
{
JumbleState *jstate = NULL;
if (query->utilityStmt)
{
query->queryId = compute_utility_query_id(querytext,
@ -141,8 +142,8 @@ compute_utility_query_id(const char *query_text, int query_location, int query_l
const char *sql;
/*
* Confine our attention to the relevant part of the string, if the
* query is a portion of a multi-statement source string.
* Confine our attention to the relevant part of the string, if the query
* is a portion of a multi-statement source string.
*/
sql = CleanQuerytext(query_text, &query_location, &query_len);
@ -150,9 +151,8 @@ compute_utility_query_id(const char *query_text, int query_location, int query_l
query_len, 0));
/*
* If we are unlucky enough to get a hash of zero(invalid), use
* queryID as 2 instead, queryID 1 is already in use for normal
* statements.
* If we are unlucky enough to get a hash of zero(invalid), use queryID as
* 2 instead, queryID 1 is already in use for normal statements.
*/
if (queryId == UINT64CONST(0))
queryId = UINT64CONST(2);

View File

@ -1275,6 +1275,7 @@ LogicalTapeSetBlocks(LogicalTapeSet *lts)
for (int i = 0; i < lts->nTapes; i++)
{
LogicalTape *lt = &lts->tapes[i];
Assert(!lt->writing || lt->buffer == NULL);
}
#endif

View File

@ -1808,8 +1808,8 @@ TransactionIdLimitedForOldSnapshots(TransactionId recentXmin,
if (ts == threshold_timestamp)
{
/*
* Current timestamp is in same bucket as the last limit that
* was applied. Reuse.
* Current timestamp is in same bucket as the last limit that was
* applied. Reuse.
*/
xlimit = threshold_xid;
}
@ -1965,13 +1965,13 @@ MaintainOldSnapshotTimeMapping(TimestampTz whenTaken, TransactionId xmin)
* number of minutes of difference between ts and the current
* head_timestamp.
*
* The distance from the current head to the current tail is one
* less than the number of entries in the mapping, because the
* entry at the head_offset is for 0 minutes after head_timestamp.
* The distance from the current head to the current tail is one less
* than the number of entries in the mapping, because the entry at the
* head_offset is for 0 minutes after head_timestamp.
*
* The difference between these two values is the number of minutes
* by which we need to advance the mapping, either adding new entries
* or rotating old ones out.
* The difference between these two values is the number of minutes by
* which we need to advance the mapping, either adding new entries or
* rotating old ones out.
*/
distance_to_new_tail =
(ts - oldSnapshotControl->head_timestamp) / USECS_PER_MINUTE;

View File

@ -24,8 +24,7 @@ $node->safe_psql('postgres', q(CREATE EXTENSION amcheck));
# Failing to connect to the initial database is an error.
$node->command_checks_all(
[ 'pg_amcheck', 'qqq' ],
1,
[ qr/^$/ ],
1, [qr/^$/],
[qr/FATAL: database "qqq" does not exist/],
'checking a non-existent database');
@ -42,7 +41,9 @@ $node->command_checks_all(
[ 'pg_amcheck', '--no-strict-names', '-d', 'qqq', '-d', 'postgres' ],
0,
[qr/^$/],
[ qr/pg_amcheck: warning: no connectable databases to check matching "qqq"/ ],
[
qr/pg_amcheck: warning: no connectable databases to check matching "qqq"/
],
'checking an unresolvable database pattern under --no-strict-names');
# Check that a substring of an existent database name does not get interpreted
@ -51,8 +52,11 @@ $node->command_checks_all(
[ 'pg_amcheck', '-d', 'post', '-d', 'postgres' ],
1,
[qr/^$/],
[ qr/pg_amcheck: error: no connectable databases to check matching "post"/ ],
'checking an unresolvable database pattern (substring of existent database)');
[
qr/pg_amcheck: error: no connectable databases to check matching "post"/
],
'checking an unresolvable database pattern (substring of existent database)'
);
# Check that a superstring of an existent database name does not get interpreted
# as a matching pattern.
@ -60,19 +64,18 @@ $node->command_checks_all(
[ 'pg_amcheck', '-d', 'postgresql', '-d', 'postgres' ],
1,
[qr/^$/],
[ qr/pg_amcheck: error: no connectable databases to check matching "postgresql"/ ],
'checking an unresolvable database pattern (superstring of existent database)');
[
qr/pg_amcheck: error: no connectable databases to check matching "postgresql"/
],
'checking an unresolvable database pattern (superstring of existent database)'
);
#########################################
# Test connecting with a non-existent user
# Failing to connect to the initial database due to bad username is an error.
$node->command_checks_all(
[ 'pg_amcheck', '-U', 'no_such_user', 'postgres' ],
1,
[ qr/^$/ ],
[ ],
'checking with a non-existent user');
$node->command_checks_all([ 'pg_amcheck', '-U', 'no_such_user', 'postgres' ],
1, [qr/^$/], [], 'checking with a non-existent user');
#########################################
# Test checking databases without amcheck installed
@ -84,25 +87,34 @@ $node->command_checks_all(
[ 'pg_amcheck', 'template1' ],
1,
[qr/^$/],
[ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
qr/pg_amcheck: error: no relations to check/ ],
'checking a database by name without amcheck installed, no other databases');
[
qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
qr/pg_amcheck: error: no relations to check/
],
'checking a database by name without amcheck installed, no other databases'
);
# Again, but this time with another database to check, so no error is raised.
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'template1', '-d', 'postgres' ],
0,
[qr/^$/],
[ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/ ],
'checking a database by name without amcheck installed, with other databases');
[
qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/
],
'checking a database by name without amcheck installed, with other databases'
);
# Again, but by way of checking all databases
$node->command_checks_all(
[ 'pg_amcheck', '--all' ],
0,
[qr/^$/],
[ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/ ],
'checking a database by pattern without amcheck installed, with other databases');
[
qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/
],
'checking a database by pattern without amcheck installed, with other databases'
);
#########################################
# Test unreasonable patterns
@ -112,7 +124,9 @@ $node->command_checks_all(
[ 'pg_amcheck', '-d', 'postgres', '-t', '..' ],
1,
[qr/^$/],
[ qr/pg_amcheck: error: no connectable databases to check matching "\.\."/ ],
[
qr/pg_amcheck: error: no connectable databases to check matching "\.\."/
],
'checking table pattern ".."');
# Again, but with non-trivial schema and relation parts
@ -120,7 +134,9 @@ $node->command_checks_all(
[ 'pg_amcheck', '-d', 'postgres', '-t', '.foo.bar' ],
1,
[qr/^$/],
[ qr/pg_amcheck: error: no connectable databases to check matching "\.foo\.bar"/ ],
[
qr/pg_amcheck: error: no connectable databases to check matching "\.foo\.bar"/
],
'checking table pattern ".foo.bar"');
# Check two-part unreasonable pattern that has zero-length names
@ -137,7 +153,8 @@ $node->command_checks_all(
# Use --no-strict-names and a single existent table so we only get warnings
# about the failed pattern matches
$node->command_checks_all(
[ 'pg_amcheck', '--no-strict-names',
[
'pg_amcheck', '--no-strict-names',
'-t', 'no_such_table',
'-t', 'no*such*table',
'-i', 'no_such_index',
@ -157,7 +174,8 @@ $node->command_checks_all(
],
0,
[qr/^$/],
[ qr/pg_amcheck: warning: no heap tables to check matching "no_such_table"/,
[
qr/pg_amcheck: warning: no heap tables to check matching "no_such_table"/,
qr/pg_amcheck: warning: no heap tables to check matching "no\*such\*table"/,
qr/pg_amcheck: warning: no btree indexes to check matching "no_such_index"/,
qr/pg_amcheck: warning: no btree indexes to check matching "no\*such\*index"/,
@ -174,19 +192,23 @@ $node->command_checks_all(
qr/pg_amcheck: warning: no relations to check matching "postgres\.pg_catalog\.none"/,
qr/pg_amcheck: warning: no relations to check matching "postgres\.none\.pg_class"/,
],
'many unmatched patterns and one matched pattern under --no-strict-names');
'many unmatched patterns and one matched pattern under --no-strict-names'
);
#########################################
# Test checking otherwise existent objects but in databases where they do not exist
$node->safe_psql('postgres', q(
$node->safe_psql(
'postgres', q(
CREATE TABLE public.foo (f integer);
CREATE INDEX foo_idx ON foo(f);
));
$node->safe_psql('postgres', q(CREATE DATABASE another_db));
$node->command_checks_all(
[ 'pg_amcheck', '-d', 'postgres', '--no-strict-names',
[
'pg_amcheck', '-d',
'postgres', '--no-strict-names',
'-t', 'template1.public.foo',
'-t', 'another_db.public.foo',
'-t', 'no_such_database.public.foo',
@ -196,7 +218,8 @@ $node->command_checks_all(
],
1,
[qr/^$/],
[ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
[
qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
qr/pg_amcheck: warning: no heap tables to check matching "template1\.public\.foo"/,
qr/pg_amcheck: warning: no heap tables to check matching "another_db\.public\.foo"/,
qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database\.public\.foo"/,
@ -213,30 +236,31 @@ $node->command_checks_all(
# Check with only schema exclusion patterns
$node->command_checks_all(
[ 'pg_amcheck', '--all', '--no-strict-names',
'-S', 'public',
'-S', 'pg_catalog',
'-S', 'pg_toast',
'-S', 'information_schema',
[
'pg_amcheck', '--all', '--no-strict-names', '-S',
'public', '-S', 'pg_catalog', '-S',
'pg_toast', '-S', 'information_schema',
],
1,
[qr/^$/],
[ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
qr/pg_amcheck: error: no relations to check/ ],
[
qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
qr/pg_amcheck: error: no relations to check/
],
'schema exclusion patterns exclude all relations');
# Check with schema exclusion patterns overriding relation and schema inclusion patterns
$node->command_checks_all(
[ 'pg_amcheck', '--all', '--no-strict-names',
'-s', 'public',
'-s', 'pg_catalog',
'-s', 'pg_toast',
'-s', 'information_schema',
'-t', 'pg_catalog.pg_class',
'-S*'
[
'pg_amcheck', '--all', '--no-strict-names', '-s',
'public', '-s', 'pg_catalog', '-s',
'pg_toast', '-s', 'information_schema', '-t',
'pg_catalog.pg_class', '-S*'
],
1,
[qr/^$/],
[ qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
qr/pg_amcheck: error: no relations to check/ ],
[
qr/pg_amcheck: warning: skipping database "template1": amcheck is not installed/,
qr/pg_amcheck: error: no relations to check/
],
'schema exclusion pattern overrides all inclusion patterns');

View File

@ -20,8 +20,8 @@ sub relation_filepath
my ($dbname, $relname) = @_;
my $pgdata = $node->data_dir;
my $rel = $node->safe_psql($dbname,
qq(SELECT pg_relation_filepath('$relname')));
my $rel =
$node->safe_psql($dbname, qq(SELECT pg_relation_filepath('$relname')));
die "path not found for relation $relname" unless defined $rel;
return "$pgdata/$rel";
}
@ -33,7 +33,8 @@ sub relation_toast
{
my ($dbname, $relname) = @_;
my $rel = $node->safe_psql($dbname, qq(
my $rel = $node->safe_psql(
$dbname, qq(
SELECT c.reltoastrelid::regclass
FROM pg_catalog.pg_class c
WHERE c.oid = '$relname'::regclass
@ -94,9 +95,8 @@ sub corrupt_first_page
syswrite(
$fh,
pack("L*",
0xAAA15550, 0xAAA0D550, 0x00010000,
0x00008000, 0x0000800F, 0x001e8000,
0xFFFFFFFF)
0xAAA15550, 0xAAA0D550, 0x00010000, 0x00008000,
0x0000800F, 0x001e8000, 0xFFFFFFFF)
) or BAIL_OUT("syswrite failed: $!");
close($fh)
or BAIL_OUT("close failed: $!");
@ -137,7 +137,8 @@ for my $dbname (qw(db1 db2 db3))
# check that pg_amcheck does not get confused by them. Create functions in
# schema public that look like amcheck functions to check that pg_amcheck
# does not use them.
$node->safe_psql($dbname, q(
$node->safe_psql(
$dbname, q(
CREATE SCHEMA amcheck_schema;
CREATE EXTENSION amcheck WITH SCHEMA amcheck_schema;
CREATE TABLE amcheck_schema.pg_database (junk text);
@ -187,7 +188,8 @@ for my $dbname (qw(db1 db2 db3))
#
for my $schema (qw(s1 s2 s3 s4 s5))
{
$node->safe_psql($dbname, qq(
$node->safe_psql(
$dbname, qq(
CREATE SCHEMA $schema;
CREATE SEQUENCE $schema.seq1;
CREATE SEQUENCE $schema.seq2;
@ -321,18 +323,15 @@ my @cmd = ('pg_amcheck', '--quiet', '-p', $port);
my $no_output_re = qr/^$/;
my $line_pointer_corruption_re = qr/line pointer/;
my $missing_file_re = qr/could not open file ".*": No such file or directory/;
my $index_missing_relation_fork_re = qr/index ".*" lacks a main relation fork/;
my $index_missing_relation_fork_re =
qr/index ".*" lacks a main relation fork/;
# We have created test databases with tables populated with data, but have not
# yet corrupted anything. As such, we expect no corruption and verify that
# none is reported
#
$node->command_checks_all(
[ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3' ],
0,
[ $no_output_re ],
[ $no_output_re ],
'pg_amcheck prior to corruption');
$node->command_checks_all([ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3' ],
0, [$no_output_re], [$no_output_re], 'pg_amcheck prior to corruption');
# Perform the corruptions we planned above using only a single database restart.
#
@ -347,8 +346,8 @@ perform_all_corruptions();
$node->command_checks_all(
[ @cmd, 'db1' ],
2,
[ $index_missing_relation_fork_re,
$line_pointer_corruption_re,
[
$index_missing_relation_fork_re, $line_pointer_corruption_re,
$missing_file_re,
],
[$no_output_re],
@ -357,12 +356,13 @@ $node->command_checks_all(
$node->command_checks_all(
[ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3' ],
2,
[ $index_missing_relation_fork_re,
$line_pointer_corruption_re,
[
$index_missing_relation_fork_re, $line_pointer_corruption_re,
$missing_file_re,
],
[$no_output_re],
'pg_amcheck all schemas, tables and indexes in databases db1, db2, and db3');
'pg_amcheck all schemas, tables and indexes in databases db1, db2, and db3'
);
# Scans of indexes in s1 should detect the specific corruption that we created
# above. For missing relation forks, we know what the error message looks
@ -377,7 +377,9 @@ $node->command_checks_all(
[ @cmd, '--all', '-s', 's1', '-i', 't1_btree' ],
2,
[$index_missing_relation_fork_re],
[ qr/pg_amcheck: warning: skipping database "postgres": amcheck is not installed/ ],
[
qr/pg_amcheck: warning: skipping database "postgres": amcheck is not installed/
],
'pg_amcheck index s1.t1_btree reports missing main relation fork');
$node->command_checks_all(
@ -393,18 +395,14 @@ $node->command_checks_all(
#
$node->command_checks_all(
[ @cmd, '-t', 's1.*', '--no-dependent-indexes', 'db1' ],
0,
[ $no_output_re ],
[ $no_output_re ],
0, [$no_output_re], [$no_output_re],
'pg_amcheck of db1.s1 excluding indexes');
# Checking db2.s1 should show table corruptions if indexes are excluded
#
$node->command_checks_all(
[ @cmd, '-t', 's1.*', '--no-dependent-indexes', 'db2' ],
2,
[ $missing_file_re ],
[ $no_output_re ],
2, [$missing_file_re], [$no_output_re],
'pg_amcheck of db2.s1 excluding indexes');
# In schema db1.s3, the tables and indexes are both corrupt. We should see
@ -413,8 +411,8 @@ $node->command_checks_all(
$node->command_checks_all(
[ @cmd, '-s', 's3', 'db1' ],
2,
[ $index_missing_relation_fork_re,
$line_pointer_corruption_re,
[
$index_missing_relation_fork_re, $line_pointer_corruption_re,
$missing_file_re,
],
[$no_output_re],
@ -423,26 +421,23 @@ $node->command_checks_all(
# In schema db1.s4, only toast tables are corrupt. Check that under default
# options the toast corruption is reported, but when excluding toast we get no
# error reports.
$node->command_checks_all(
[ @cmd, '-s', 's4', 'db1' ],
2,
[ $missing_file_re ],
[ $no_output_re ],
$node->command_checks_all([ @cmd, '-s', 's4', 'db1' ],
2, [$missing_file_re], [$no_output_re],
'pg_amcheck in schema s4 reports toast corruption');
$node->command_checks_all(
[ @cmd, '--no-dependent-toast', '--exclude-toast-pointers', '-s', 's4', 'db1' ],
[
@cmd, '--no-dependent-toast', '--exclude-toast-pointers', '-s', 's4',
'db1'
],
0,
[$no_output_re],
[$no_output_re],
'pg_amcheck in schema s4 excluding toast reports no corruption');
# Check that no corruption is reported in schema db1.s5
$node->command_checks_all(
[ @cmd, '-s', 's5', 'db1' ],
0,
[ $no_output_re ],
[ $no_output_re ],
$node->command_checks_all([ @cmd, '-s', 's5', 'db1' ],
0, [$no_output_re], [$no_output_re],
'pg_amcheck over schema s5 reports no corruption');
# In schema db1.s1, only indexes are corrupt. Verify that when we exclude
@ -453,7 +448,8 @@ $node->command_checks_all(
0,
[$no_output_re],
[$no_output_re],
'pg_amcheck over schema s1 with corrupt indexes excluded reports no corruption');
'pg_amcheck over schema s1 with corrupt indexes excluded reports no corruption'
);
# In schema db1.s1, only indexes are corrupt. Verify that when we provide only
# table inclusions, and disable index expansion, no corruption is reported
@ -464,7 +460,8 @@ $node->command_checks_all(
0,
[$no_output_re],
[$no_output_re],
'pg_amcheck over schema s1 with all indexes excluded reports no corruption');
'pg_amcheck over schema s1 with all indexes excluded reports no corruption'
);
# In schema db1.s2, only tables are corrupt. Verify that when we exclude those
# tables that no corruption is reported.
@ -474,7 +471,8 @@ $node->command_checks_all(
0,
[$no_output_re],
[$no_output_re],
'pg_amcheck over schema s2 with corrupt tables excluded reports no corruption');
'pg_amcheck over schema s2 with corrupt tables excluded reports no corruption'
);
# Check errors about bad block range command line arguments. We use schema s5
# to avoid getting messages about corrupt tables or indexes.
@ -506,7 +504,10 @@ $node->command_checks_all(
'pg_amcheck smoke test --parent-check');
$node->command_checks_all(
[ @cmd, '-s', 's1', '-i', 't1_btree', '--heapallindexed', '--rootdescend', 'db1' ],
[
@cmd, '-s', 's1', '-i', 't1_btree', '--heapallindexed',
'--rootdescend', 'db1'
],
2,
[$index_missing_relation_fork_re],
[$no_output_re],
@ -514,7 +515,5 @@ $node->command_checks_all(
$node->command_checks_all(
[ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3', '-S', 's*' ],
0,
[ $no_output_re ],
[ $no_output_re ],
0, [$no_output_re], [$no_output_re],
'pg_amcheck excluding all corrupt schemas');

View File

@ -105,7 +105,8 @@ sub read_tuple
or BAIL_OUT("sysread failed: $!");
@_ = unpack(HEAPTUPLE_PACK_CODE, $buffer);
%tup = (t_xmin => shift,
%tup = (
t_xmin => shift,
t_xmax => shift,
t_field3 => shift,
bi_hi => shift,
@ -149,33 +150,21 @@ sub read_tuple
sub write_tuple
{
my ($fh, $offset, $tup) = @_;
my $buffer = pack(HEAPTUPLE_PACK_CODE,
$tup->{t_xmin},
$tup->{t_xmax},
$tup->{t_field3},
$tup->{bi_hi},
$tup->{bi_lo},
$tup->{ip_posid},
$tup->{t_infomask2},
$tup->{t_infomask},
$tup->{t_hoff},
$tup->{t_bits},
$tup->{a_1},
$tup->{a_2},
$tup->{b_header},
$tup->{b_body1},
$tup->{b_body2},
$tup->{b_body3},
$tup->{b_body4},
$tup->{b_body5},
$tup->{b_body6},
$tup->{b_body7},
$tup->{c_va_header},
$tup->{c_va_vartag},
$tup->{c_va_rawsize},
$tup->{c_va_extinfo},
$tup->{c_va_valueid},
$tup->{c_va_toastrelid});
my $buffer = pack(
HEAPTUPLE_PACK_CODE,
$tup->{t_xmin}, $tup->{t_xmax},
$tup->{t_field3}, $tup->{bi_hi},
$tup->{bi_lo}, $tup->{ip_posid},
$tup->{t_infomask2}, $tup->{t_infomask},
$tup->{t_hoff}, $tup->{t_bits},
$tup->{a_1}, $tup->{a_2},
$tup->{b_header}, $tup->{b_body1},
$tup->{b_body2}, $tup->{b_body3},
$tup->{b_body4}, $tup->{b_body5},
$tup->{b_body6}, $tup->{b_body7},
$tup->{c_va_header}, $tup->{c_va_vartag},
$tup->{c_va_rawsize}, $tup->{c_va_extinfo},
$tup->{c_va_valueid}, $tup->{c_va_toastrelid});
seek($fh, $offset, SEEK_SET)
or BAIL_OUT("seek failed: $!");
defined(syswrite($fh, $buffer, HEAPTUPLE_PACK_LENGTH))
@ -224,12 +213,14 @@ $node->safe_psql(
VACUUM FREEZE public.junk
));
my $rel = $node->safe_psql('postgres', qq(SELECT pg_relation_filepath('public.test')));
my $rel = $node->safe_psql('postgres',
qq(SELECT pg_relation_filepath('public.test')));
my $relpath = "$pgdata/$rel";
# Insert data and freeze public.test
use constant ROWCOUNT => 16;
$node->safe_psql('postgres', qq(
$node->safe_psql(
'postgres', qq(
INSERT INTO public.test (a, b, c)
VALUES (
x'DEADF9F9DEADF9F9'::bigint,
@ -250,7 +241,8 @@ my $datfrozenxid = $node->safe_psql('postgres',
if ($datfrozenxid <= 3 || $datfrozenxid >= $relfrozenxid)
{
$node->clean_node;
plan skip_all => "Xid thresholds not as expected: got datfrozenxid = $datfrozenxid, relfrozenxid = $relfrozenxid";
plan skip_all =>
"Xid thresholds not as expected: got datfrozenxid = $datfrozenxid, relfrozenxid = $relfrozenxid";
exit;
}
@ -258,7 +250,10 @@ if ($datfrozenxid <= 3 || $datfrozenxid >= $relfrozenxid)
my @lp_off;
for my $tup (0 .. ROWCOUNT - 1)
{
push (@lp_off, $node->safe_psql('postgres', qq(
push(
@lp_off,
$node->safe_psql(
'postgres', qq(
select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
offset $tup limit 1)));
}
@ -287,7 +282,9 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
{
close($file); # ignore errors on close; we're exiting anyway
$node->clean_node;
plan skip_all => sprintf("Page layout differs from our expectations: expected (%x, %x, \"%s\"), got (%x, %x, \"%s\")",
plan skip_all =>
sprintf(
"Page layout differs from our expectations: expected (%x, %x, \"%s\"), got (%x, %x, \"%s\")",
0xDEADF9F9, 0xDEADF9F9, "abcdefg", $a_1, $a_2, $b);
exit;
}
@ -303,7 +300,8 @@ $node->start;
plan tests => 19;
# Check that pg_amcheck runs against the uncorrupted table without error.
$node->command_ok(['pg_amcheck', '-p', $port, 'postgres'],
$node->command_ok(
[ 'pg_amcheck', '-p', $port, 'postgres' ],
'pg_amcheck test table, prior to corruption');
# Check that pg_amcheck runs against the uncorrupted table and index without error.
@ -328,9 +326,11 @@ use constant HEAP_KEYS_UPDATED => 0x2000;
sub header
{
my ($blkno, $offnum, $attnum) = @_;
return qr/heap table "postgres"\."public"\."test", block $blkno, offset $offnum, attribute $attnum:\s+/ms
return
qr/heap table "postgres"\."public"\."test", block $blkno, offset $offnum, attribute $attnum:\s+/ms
if (defined $attnum);
return qr/heap table "postgres"\."public"\."test", block $blkno, offset $offnum:\s+/ms
return
qr/heap table "postgres"\."public"\."test", block $blkno, offset $offnum:\s+/ms
if (defined $offnum);
return qr/heap table "postgres"\."public"\."test", block $blkno:\s+/ms
if (defined $blkno);
@ -492,8 +492,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{c_va_valueid} = 0xFFFFFFFF;
$header = header(0, $offnum, 2);
push @expected,
qr/${header}toast value \d+ not found in toast table/;
push @expected, qr/${header}toast value \d+ not found in toast table/;
}
elsif ($offnum == 14)
{
@ -525,10 +524,7 @@ $node->start;
# corruption messages against the expected messages
$node->command_checks_all(
[ 'pg_amcheck', '--no-dependent-indexes', '-p', $port, 'postgres' ],
2,
[ @expected ],
[ ],
'Expected corruption message output');
2, [@expected], [], 'Expected corruption message output');
$node->teardown_node;
$node->clean_node;

View File

@ -15,7 +15,8 @@ $node->init;
$node->start;
# Create a custom operator class and an index which uses it.
$node->safe_psql('postgres', q(
$node->safe_psql(
'postgres', q(
CREATE EXTENSION amcheck;
CREATE FUNCTION int4_asc_cmp (a int4, b int4) RETURNS int LANGUAGE sql AS $$
@ -39,7 +40,8 @@ $node->command_like(
# Change the operator class to use a function which sorts in a different
# order to corrupt the btree index
$node->safe_psql('postgres', q(
$node->safe_psql(
'postgres', q(
CREATE FUNCTION int4_desc_cmp (int4, int4) RETURNS int LANGUAGE sql AS $$
SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN -1 ELSE 1 END; $$;
UPDATE pg_catalog.pg_amproc

View File

@ -393,7 +393,8 @@ struct _tocEntry
/* working state while dumping/restoring */
pgoff_t dataLength; /* item's data size; 0 if none or unknown */
int reqs; /* do we need schema and/or data of object (REQ_* bit mask) */
int reqs; /* do we need schema and/or data of object
* (REQ_* bit mask) */
bool created; /* set for DATA member if TABLE was created */
/* working state (needed only for parallel restore) */

View File

@ -74,7 +74,8 @@ sub run_test
primary_psql("VACUUM tail_tbl");
# Drop drop_tbl. pg_rewind should copy it back.
primary_psql("insert into drop_tbl values ('in primary, after promotion')");
primary_psql(
"insert into drop_tbl values ('in primary, after promotion')");
primary_psql("DROP TABLE drop_tbl");
# Before running pg_rewind, do a couple of extra tests with several

View File

@ -27,10 +27,13 @@ sub run_test
# Create a subdir and files that will be present in both
mkdir "$test_primary_datadir/tst_both_dir";
append_to_file "$test_primary_datadir/tst_both_dir/both_file1", "in both1";
append_to_file "$test_primary_datadir/tst_both_dir/both_file2", "in both2";
append_to_file "$test_primary_datadir/tst_both_dir/both_file1",
"in both1";
append_to_file "$test_primary_datadir/tst_both_dir/both_file2",
"in both2";
mkdir "$test_primary_datadir/tst_both_dir/both_subdir/";
append_to_file "$test_primary_datadir/tst_both_dir/both_subdir/both_file3",
append_to_file
"$test_primary_datadir/tst_both_dir/both_subdir/both_file3",
"in both3";
RewindTest::create_standby($test_mode);

View File

@ -42,7 +42,8 @@ my $tmp_folder = TestLib::tempdir;
my $node_1 = get_new_node('node_1');
$node_1->init(allows_streaming => 1);
$node_1->append_conf('postgresql.conf', qq(
$node_1->append_conf(
'postgresql.conf', qq(
wal_keep_size='100 MB'
));
@ -60,13 +61,11 @@ my $backup_name = 'my_backup';
$node_1->backup($backup_name);
my $node_2 = get_new_node('node_2');
$node_2->init_from_backup($node_1, $backup_name,
has_streaming => 1);
$node_2->init_from_backup($node_1, $backup_name, has_streaming => 1);
$node_2->start;
my $node_3 = get_new_node('node_3');
$node_3->init_from_backup($node_1, $backup_name,
has_streaming => 1);
$node_3->init_from_backup($node_1, $backup_name, has_streaming => 1);
$node_3->start;
# Wait until node 3 has connected and caught up
@ -88,14 +87,16 @@ $node_3->safe_psql('postgres', "checkpoint");
# reconfigure node_1 as a standby following node_3
my $node_3_connstr = $node_3->connstr;
$node_1->append_conf('postgresql.conf', qq(
$node_1->append_conf(
'postgresql.conf', qq(
primary_conninfo='$node_3_connstr'
));
$node_1->set_standby_mode();
$node_1->start();
# also reconfigure node_2 to follow node_3
$node_2->append_conf('postgresql.conf', qq(
$node_2->append_conf(
'postgresql.conf', qq(
primary_conninfo='$node_3_connstr'
));
$node_2->restart();
@ -117,17 +118,21 @@ $node_1->safe_psql('postgres', "checkpoint");
# demonstratively create a split brain. After the rewind, we should only
# see the insert on 1, as the insert on node 3 is rewound away.
#
$node_1->safe_psql('postgres', "INSERT INTO public.foo (t) VALUES ('keep this')");
$node_1->safe_psql('postgres',
"INSERT INTO public.foo (t) VALUES ('keep this')");
# 'bar' is unmodified in node 1, so it won't be overwritten by replaying the
# WAL from node 1.
$node_3->safe_psql('postgres', "INSERT INTO public.bar (t) VALUES ('rewind this')");
$node_3->safe_psql('postgres',
"INSERT INTO public.bar (t) VALUES ('rewind this')");
# Insert more rows in node 1, to bump up the XID counter. Otherwise, if
# rewind doesn't correctly rewind the changes made on the other node,
# we might fail to notice if the inserts are invisible because the XIDs
# are not marked as committed.
$node_1->safe_psql('postgres', "INSERT INTO public.foo (t) VALUES ('and this')");
$node_1->safe_psql('postgres', "INSERT INTO public.foo (t) VALUES ('and this too')");
$node_1->safe_psql('postgres',
"INSERT INTO public.foo (t) VALUES ('and this')");
$node_1->safe_psql('postgres',
"INSERT INTO public.foo (t) VALUES ('and this too')");
# Wait for node 2 to catch up
$node_2->poll_query_until('postgres',
@ -148,10 +153,8 @@ copy(
command_ok(
[
'pg_rewind',
"--source-server=$node_1_connstr",
"--target-pgdata=$node_2_pgdata",
"--debug"
'pg_rewind', "--source-server=$node_1_connstr",
"--target-pgdata=$node_2_pgdata", "--debug"
],
'run pg_rewind');

View File

@ -401,6 +401,7 @@ test_sync(int writes_per_op)
buf,
XLOG_BLCKSZ,
writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
/*
* This can generate write failures if the filesystem has
* a large block size, e.g. 4k, and there is no support

View File

@ -6577,8 +6577,8 @@ threadRun(void *arg)
* GO before proceeding to the "done" path which will cleanup,
* so as to avoid locking the process.
*
* It is unclear whether it is worth doing anything rather than
* coldly exiting with an error message.
* It is unclear whether it is worth doing anything rather
* than coldly exiting with an error message.
*/
THREAD_BARRIER_WAIT(&barrier);
goto done;

View File

@ -1091,8 +1091,10 @@ SELECT LEAST(} . join(', ', (':i') x 256) . q{)}
[qr{malformed variable.*trueXXX}], q{\set b :badtrue or true}
],
[
'invalid permute size', 2,
[qr{permute size parameter must be greater than zero}], q{\set i permute(0, 0)}
'invalid permute size',
2,
[qr{permute size parameter must be greater than zero}],
q{\set i permute(0, 0)}
],
# GSET

View File

@ -72,8 +72,8 @@ typedef enum
SYNCHRONOUS_COMMIT_REMOTE_WRITE, /* wait for local flush and remote
* write */
SYNCHRONOUS_COMMIT_REMOTE_FLUSH, /* wait for local and remote flush */
SYNCHRONOUS_COMMIT_REMOTE_APPLY /* wait for local and remote flush
and remote apply */
SYNCHRONOUS_COMMIT_REMOTE_APPLY /* wait for local and remote flush and
* remote apply */
} SyncCommitLevel;
/* Define the default setting for synchronous_commit */

View File

@ -505,20 +505,20 @@
aggcombinefn => 'int2and', aggtranstype => 'int2' },
{ aggfnoid => 'bit_or(int2)', aggtransfn => 'int2or', aggcombinefn => 'int2or',
aggtranstype => 'int2' },
{ aggfnoid => 'bit_xor(int2)', aggtransfn => 'int2xor', aggcombinefn => 'int2xor',
aggtranstype => 'int2' },
{ aggfnoid => 'bit_xor(int2)', aggtransfn => 'int2xor',
aggcombinefn => 'int2xor', aggtranstype => 'int2' },
{ aggfnoid => 'bit_and(int4)', aggtransfn => 'int4and',
aggcombinefn => 'int4and', aggtranstype => 'int4' },
{ aggfnoid => 'bit_or(int4)', aggtransfn => 'int4or', aggcombinefn => 'int4or',
aggtranstype => 'int4' },
{ aggfnoid => 'bit_xor(int4)', aggtransfn => 'int4xor', aggcombinefn => 'int4xor',
aggtranstype => 'int4' },
{ aggfnoid => 'bit_xor(int4)', aggtransfn => 'int4xor',
aggcombinefn => 'int4xor', aggtranstype => 'int4' },
{ aggfnoid => 'bit_and(int8)', aggtransfn => 'int8and',
aggcombinefn => 'int8and', aggtranstype => 'int8' },
{ aggfnoid => 'bit_or(int8)', aggtransfn => 'int8or', aggcombinefn => 'int8or',
aggtranstype => 'int8' },
{ aggfnoid => 'bit_xor(int8)', aggtransfn => 'int8xor', aggcombinefn => 'int8xor',
aggtranstype => 'int8' },
{ aggfnoid => 'bit_xor(int8)', aggtransfn => 'int8xor',
aggcombinefn => 'int8xor', aggtranstype => 'int8' },
{ aggfnoid => 'bit_and(bit)', aggtransfn => 'bitand', aggcombinefn => 'bitand',
aggtranstype => 'bit' },
{ aggfnoid => 'bit_or(bit)', aggtransfn => 'bitor', aggcombinefn => 'bitor',

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