Skip to content

Commit

Permalink
Initial pgindent run for v12.
Browse files Browse the repository at this point in the history
This is still using the 2.0 version of pg_bsd_indent.
I thought it would be good to commit this separately,
so as to document the differences between 2.0 and 2.1 behavior.

Discussion: https://postgr.es/m/[email protected]
  • Loading branch information
tglsfdc committed May 22, 2019
1 parent 66a4bad commit be76af1
Show file tree
Hide file tree
Showing 221 changed files with 1,441 additions and 1,310 deletions.
11 changes: 6 additions & 5 deletions contrib/amcheck/verify_nbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static inline bool invariant_l_nontarget_offset(BtreeCheckState *state,
OffsetNumber upperbound);
static Page palloc_btree_page(BtreeCheckState *state, BlockNumber blocknum);
static inline BTScanInsert bt_mkscankey_pivotsearch(Relation rel,
IndexTuple itup);
IndexTuple itup);
static ItemId PageGetItemIdCareful(BtreeCheckState *state, BlockNumber block,
Page page, OffsetNumber offset);
static inline ItemPointer BTreeTupleGetHeapTIDCareful(BtreeCheckState *state,
Expand Down Expand Up @@ -1029,7 +1029,7 @@ bt_target_page_check(BtreeCheckState *state)
/* Fingerprint leaf page tuples (those that point to the heap) */
if (state->heapallindexed && P_ISLEAF(topaque) && !ItemIdIsDead(itemid))
{
IndexTuple norm;
IndexTuple norm;

norm = bt_normalize_tuple(state, itup);
bloom_add_element(state->filter, (unsigned char *) norm,
Expand Down Expand Up @@ -1174,7 +1174,7 @@ bt_target_page_check(BtreeCheckState *state)
*/
else if (offset == max)
{
BTScanInsert rightkey;
BTScanInsert rightkey;

/* Get item in next/right page */
rightkey = bt_right_page_check_scankey(state);
Expand Down Expand Up @@ -1851,7 +1851,8 @@ bt_tuple_present_callback(Relation index, HeapTuple htup, Datum *values,
bool *isnull, bool tupleIsAlive, void *checkstate)
{
BtreeCheckState *state = (BtreeCheckState *) checkstate;
IndexTuple itup, norm;
IndexTuple itup,
norm;

Assert(state->heapallindexed);

Expand Down Expand Up @@ -1931,7 +1932,7 @@ bt_normalize_tuple(BtreeCheckState *state, IndexTuple itup)

for (i = 0; i < tupleDescriptor->natts; i++)
{
Form_pg_attribute att;
Form_pg_attribute att;

att = TupleDescAttr(tupleDescriptor, i);

Expand Down
10 changes: 5 additions & 5 deletions contrib/cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ cube_a_f8_f8(PG_FUNCTION_ARGS)
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("can't extend cube"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
CUBE_MAX_DIM)));

if (ARRNELEMS(ll) != dim)
ereport(ERROR,
Expand Down Expand Up @@ -220,7 +220,7 @@ cube_a_f8(PG_FUNCTION_ARGS)
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array is too long"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
CUBE_MAX_DIM)));

dur = ARRPTR(ur);

Expand Down Expand Up @@ -260,7 +260,7 @@ cube_subset(PG_FUNCTION_ARGS)
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array is too long"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
CUBE_MAX_DIM)));

size = IS_POINT(c) ? POINT_SIZE(dim) : CUBE_SIZE(dim);
result = (NDBOX *) palloc0(size);
Expand Down Expand Up @@ -1780,7 +1780,7 @@ cube_c_f8(PG_FUNCTION_ARGS)
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("can't extend cube"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
CUBE_MAX_DIM)));

if (IS_POINT(cube))
{
Expand Down Expand Up @@ -1828,7 +1828,7 @@ cube_c_f8_f8(PG_FUNCTION_ARGS)
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("can't extend cube"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
CUBE_MAX_DIM)));

if (IS_POINT(cube) && (x1 == x2))
{
Expand Down
7 changes: 5 additions & 2 deletions contrib/file_fdw/file_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,11 @@ check_selective_binary_conversion(RelOptInfo *baserel,
/* Skip dropped attributes (probably shouldn't see any here). */
if (attr->attisdropped)
continue;
/* Skip generated columns (COPY won't accept them in the column
* list) */

/*
* Skip generated columns (COPY won't accept them in the column
* list)
*/
if (attr->attgenerated)
continue;
*columns = lappend(*columns, makeString(pstrdup(attname)));
Expand Down
23 changes: 13 additions & 10 deletions contrib/intarray/_int_gist.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,41 +212,44 @@ g_int_compress(PG_FUNCTION_ARGS)
*/
for (j = i = len - 1; i > 0 && lenr > 0; i--, j--)
{
int r_end = dr[i];
int r_start = r_end;
while (i > 0 && lenr > 0 && dr[i-1] == r_start - 1)
int r_end = dr[i];
int r_start = r_end;

while (i > 0 && lenr > 0 && dr[i - 1] == r_start - 1)
--r_start, --i, --lenr;
dr[2*j] = r_start;
dr[2*j+1] = r_end;
dr[2 * j] = r_start;
dr[2 * j + 1] = r_end;
}
/* just copy the rest, if any, as trivial ranges */
for (; i >= 0; i--, j--)
dr[2*j] = dr[2*j + 1] = dr[i];
dr[2 * j] = dr[2 * j + 1] = dr[i];

if (++j)
{
/*
* shunt everything down to start at the right place
*/
memmove((void *) &dr[0], (void *) &dr[2*j], 2*(len - j) * sizeof(int32));
memmove((void *) &dr[0], (void *) &dr[2 * j], 2 * (len - j) * sizeof(int32));
}

/*
* make "len" be number of array elements, not ranges
*/
len = 2*(len - j);
len = 2 * (len - j);
cand = 1;
while (len > MAXNUMRANGE * 2)
{
min = PG_INT64_MAX;
for (i = 2; i < len; i += 2)
if (min > ((int64)dr[i] - (int64)dr[i - 1]))
if (min > ((int64) dr[i] - (int64) dr[i - 1]))
{
min = ((int64)dr[i] - (int64)dr[i - 1]);
min = ((int64) dr[i] - (int64) dr[i - 1]);
cand = i;
}
memmove((void *) &dr[cand - 1], (void *) &dr[cand + 1], (len - cand - 1) * sizeof(int32));
len -= 2;
}

/*
* check sparseness of result
*/
Expand Down
4 changes: 2 additions & 2 deletions contrib/intarray/_int_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ internal_size(int *a, int len)
for (i = 0; i < len; i += 2)
{
if (!i || a[i] != a[i - 1]) /* do not count repeated range */
size += (int64)(a[i + 1]) - (int64)(a[i]) + 1;
size += (int64) (a[i + 1]) - (int64) (a[i]) + 1;
}

if (size > (int64)INT_MAX || size < (int64)INT_MIN)
if (size > (int64) INT_MAX || size < (int64) INT_MIN)
return -1; /* overflow */
return (int) size;
}
Expand Down
5 changes: 3 additions & 2 deletions contrib/pg_stat_statements/pg_stat_statements.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,9 @@ pgss_store(const char *query, uint64 queryId,
queryId = pgss_hash_string(query, query_len);

/*
* 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);
Expand Down
6 changes: 3 additions & 3 deletions contrib/pgcrypto/imath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ mp_int_mod(mp_int a, mp_int m, mp_int c)
}

mp_result
mp_int_div_value(mp_int a, mp_small value, mp_int q, mp_small * r)
mp_int_div_value(mp_int a, mp_small value, mp_int q, mp_small *r)
{
mpz_t vtmp;
mp_digit vbuf[MP_VALUE_DIGITS(value)];
Expand Down Expand Up @@ -1819,7 +1819,7 @@ mp_int_root(mp_int a, mp_small b, mp_int c)
}

mp_result
mp_int_to_int(mp_int z, mp_small * out)
mp_int_to_int(mp_int z, mp_small *out)
{
assert(z != NULL);

Expand Down Expand Up @@ -1850,7 +1850,7 @@ mp_int_to_int(mp_int z, mp_small * out)
}

mp_result
mp_int_to_uint(mp_int z, mp_usmall * out)
mp_int_to_uint(mp_int z, mp_usmall *out)
{
assert(z != NULL);

Expand Down
8 changes: 4 additions & 4 deletions contrib/pgcrypto/imath.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ mp_result mp_int_div(mp_int a, mp_int b, mp_int q, mp_int r);
/** Sets `q` and `*r` to the quotent and remainder of `a / value`. Division by
powers of 2 is detected and handled efficiently. The remainder is pinned to
`0 <= *r < b`. Either of `q` or `r` may be NULL. */
mp_result mp_int_div_value(mp_int a, mp_small value, mp_int q, mp_small * r);
mp_result mp_int_div_value(mp_int a, mp_small value, mp_int q, mp_small *r);

/** Sets `q` and `r` to the quotient and remainder of `a / 2^p2`. This is a
special case for division by powers of two that is more efficient than
Expand Down Expand Up @@ -246,7 +246,7 @@ mp_result mp_int_expt_full(mp_int a, mp_int b, mp_int c);
The remainder is pinned to `0 <= r < value`. */
static inline
mp_result
mp_int_mod_value(mp_int a, mp_small value, mp_small * r)
mp_int_mod_value(mp_int a, mp_small value, mp_small *r)
{
return mp_int_div_value(a, value, 0, r);
}
Expand Down Expand Up @@ -339,11 +339,11 @@ mp_int_sqrt(mp_int a, mp_int c)

/** Returns `MP_OK` if `z` is representable as `mp_small`, else `MP_RANGE`.
If `out` is not NULL, `*out` is set to the value of `z` when `MP_OK`. */
mp_result mp_int_to_int(mp_int z, mp_small * out);
mp_result mp_int_to_int(mp_int z, mp_small *out);

/** Returns `MP_OK` if `z` is representable as `mp_usmall`, or `MP_RANGE`.
If `out` is not NULL, `*out` is set to the value of `z` when `MP_OK`. */
mp_result mp_int_to_uint(mp_int z, mp_usmall * out);
mp_result mp_int_to_uint(mp_int z, mp_usmall *out);

/** Converts `z` to a zero-terminated string of characters in the specified
`radix`, writing at most `limit` characters to `str` including the
Expand Down
2 changes: 1 addition & 1 deletion contrib/pgstattuple/pgstattuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)

InitDirtySnapshot(SnapshotDirty);

nblocks = hscan->rs_nblocks; /* # blocks to be scanned */
nblocks = hscan->rs_nblocks; /* # blocks to be scanned */

/* scan the relation */
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
Expand Down
21 changes: 11 additions & 10 deletions contrib/postgres_fdw/postgres_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ postgresExecForeignInsert(EState *estate,
if (fmstate->aux_fmstate)
resultRelInfo->ri_FdwState = fmstate->aux_fmstate;
rslot = execute_foreign_modify(estate, resultRelInfo, CMD_INSERT,
slot, planSlot);
slot, planSlot);
/* Revert that change */
if (fmstate->aux_fmstate)
resultRelInfo->ri_FdwState = fmstate;
Expand Down Expand Up @@ -1934,11 +1934,11 @@ postgresBeginForeignInsert(ModifyTableState *mtstate,
bool doNothing = false;

/*
* If the foreign table we are about to insert routed rows into is also
* an UPDATE subplan result rel that will be updated later, proceeding
* with the INSERT will result in the later UPDATE incorrectly modifying
* those routed rows, so prevent the INSERT --- it would be nice if we
* could handle this case; but for now, throw an error for safety.
* If the foreign table we are about to insert routed rows into is also an
* UPDATE subplan result rel that will be updated later, proceeding with
* the INSERT will result in the later UPDATE incorrectly modifying those
* routed rows, so prevent the INSERT --- it would be nice if we could
* handle this case; but for now, throw an error for safety.
*/
if (plan && plan->operation == CMD_UPDATE &&
(resultRelInfo->ri_usesFdwDirectModify ||
Expand Down Expand Up @@ -3169,7 +3169,7 @@ adjust_foreign_grouping_path_cost(PlannerInfo *root,
if (!grouping_is_sortable(root->parse->groupClause) ||
!pathkeys_contained_in(pathkeys, root->group_pathkeys))
{
Path sort_path; /* dummy for result of cost_sort */
Path sort_path; /* dummy for result of cost_sort */

cost_sort(&sort_path,
root,
Expand All @@ -3191,7 +3191,7 @@ adjust_foreign_grouping_path_cost(PlannerInfo *root,
* add 1/4th of that default.
*/
double sort_multiplier = 1.0 + (DEFAULT_FDW_SORT_MULTIPLIER
- 1.0) * 0.25;
- 1.0) * 0.25;

*p_startup_cost *= sort_multiplier;
*p_run_cost *= sort_multiplier;
Expand Down Expand Up @@ -3773,6 +3773,7 @@ store_returning_result(PgFdwModifyState *fmstate,
fmstate->retrieved_attrs,
NULL,
fmstate->temp_cxt);

/*
* The returning slot will not necessarily be suitable to store
* heaptuples directly, so allow for conversion.
Expand Down Expand Up @@ -6059,8 +6060,8 @@ add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel,
/*
* Grouping and aggregation are not supported with FOR UPDATE/SHARE,
* so the input_rel should be a base, join, or ordered relation; and
* if it's an ordered relation, its input relation should be a base
* or join relation.
* if it's an ordered relation, its input relation should be a base or
* join relation.
*/
Assert(input_rel->reloptkind == RELOPT_BASEREL ||
input_rel->reloptkind == RELOPT_JOINREL ||
Expand Down
4 changes: 2 additions & 2 deletions src/backend/access/common/heaptuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,8 @@ expand_tuple(HeapTuple *targetHeapTuple,
}

/*
* Now walk the missing attributes. If there is a missing value
* make space for it. Otherwise, it's going to be NULL.
* Now walk the missing attributes. If there is a missing value make
* space for it. Otherwise, it's going to be NULL.
*/
for (attnum = firstmissingnum;
attnum < natts;
Expand Down
10 changes: 5 additions & 5 deletions src/backend/access/gin/ginvacuum.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,17 @@ ginVacuumPostingTree(GinVacuumState *gvs, BlockNumber rootBlkno)
* There is at least one empty page. So we have to rescan the tree
* deleting empty pages.
*/
Buffer buffer;
Buffer buffer;
DataPageDeleteStack root,
*ptr,
*tmp;
*ptr,
*tmp;

buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, rootBlkno,
RBM_NORMAL, gvs->strategy);

/*
* Lock posting tree root for cleanup to ensure there are no concurrent
* inserts.
* Lock posting tree root for cleanup to ensure there are no
* concurrent inserts.
*/
LockBufferForCleanup(buffer);

Expand Down
12 changes: 6 additions & 6 deletions src/backend/access/gin/ginxlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
while (segno < a_segno)
{
/*
* Once modification is started and page tail is copied, we've
* to copy unmodified segments.
* Once modification is started and page tail is copied, we've to
* copy unmodified segments.
*/
segsize = SizeOfGinPostingList(oldseg);
if (tailCopy)
Expand Down Expand Up @@ -257,12 +257,12 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
}

/*
* We're about to start modification of the page. So, copy tail of the
* page if it's not done already.
* We're about to start modification of the page. So, copy tail of
* the page if it's not done already.
*/
if (!tailCopy && segptr != segmentend)
{
int tailSize = segmentend - segptr;
int tailSize = segmentend - segptr;

tailCopy = (Pointer) palloc(tailSize);
memcpy(tailCopy, segptr, tailSize);
Expand Down Expand Up @@ -304,7 +304,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
segptr = (Pointer) oldseg;
if (segptr != segmentend && tailCopy)
{
int restSize = segmentend - segptr;
int restSize = segmentend - segptr;

Assert(writePtr + restSize <= PageGetSpecialPointer(page));
memcpy(writePtr, segptr, restSize);
Expand Down
Loading

0 comments on commit be76af1

Please sign in to comment.