mirror of
https://github.com/postgres/postgres.git
synced 2026-10-25 01:39:28 +03:00
Fix for loop variables
A number of for loops used loop variables that did not match the type of the end condition. This could lead to wraparound or signed/unsigned mismatches. Probably none of these are a problem in practice, but it's fragile code. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/d639aede-209f-412b-927a-d38d4848b370%40eisentraut.org
This commit is contained in:
@@ -38,7 +38,6 @@ fsm_page_contents(PG_FUNCTION_ARGS)
|
||||
StringInfoData sinfo;
|
||||
Page page;
|
||||
FSMPage fsmpage;
|
||||
int i;
|
||||
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
@@ -54,10 +53,10 @@ fsm_page_contents(PG_FUNCTION_ARGS)
|
||||
|
||||
initStringInfo(&sinfo);
|
||||
|
||||
for (i = 0; i < NodesPerPage; i++)
|
||||
for (size_t i = 0; i < NodesPerPage; i++)
|
||||
{
|
||||
if (fsmpage->fp_nodes[i] != 0)
|
||||
appendStringInfo(&sinfo, "%d: %d\n", i, fsmpage->fp_nodes[i]);
|
||||
appendStringInfo(&sinfo, "%zu: %d\n", i, fsmpage->fp_nodes[i]);
|
||||
}
|
||||
appendStringInfo(&sinfo, "fp_next_slot: %d\n", fsmpage->fp_next_slot);
|
||||
|
||||
|
||||
@@ -404,8 +404,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
|
||||
int32 bitmappage,
|
||||
bitmapbit;
|
||||
HeapTuple tuple;
|
||||
int i,
|
||||
j;
|
||||
int j;
|
||||
Datum values[3];
|
||||
bool nulls[3] = {0};
|
||||
uint32 *freep;
|
||||
@@ -456,7 +455,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid overflow block number %u",
|
||||
(BlockNumber) ovflblkno)));
|
||||
for (i = 0; i < metap->hashm_nmaps; i++)
|
||||
for (uint32 i = 0; i < metap->hashm_nmaps; i++)
|
||||
if (metap->hashm_mapp[i] == ovflblkno)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
|
||||
@@ -170,7 +170,7 @@ pg_get_logical_snapshot_info(PG_FUNCTION_ARGS)
|
||||
|
||||
arrayelems = (Datum *) palloc(ondisk.builder.committed.xcnt * sizeof(Datum));
|
||||
|
||||
for (int j = 0; j < ondisk.builder.committed.xcnt; j++)
|
||||
for (size_t j = 0; j < ondisk.builder.committed.xcnt; j++)
|
||||
arrayelems[j] = TransactionIdGetDatum(ondisk.builder.committed.xip[j]);
|
||||
|
||||
values[i++] = PointerGetDatum(construct_array_builtin(arrayelems,
|
||||
@@ -187,7 +187,7 @@ pg_get_logical_snapshot_info(PG_FUNCTION_ARGS)
|
||||
|
||||
arrayelems = (Datum *) palloc(ondisk.builder.catchange.xcnt * sizeof(Datum));
|
||||
|
||||
for (int j = 0; j < ondisk.builder.catchange.xcnt; j++)
|
||||
for (size_t j = 0; j < ondisk.builder.catchange.xcnt; j++)
|
||||
arrayelems[j] = TransactionIdGetDatum(ondisk.builder.catchange.xip[j]);
|
||||
|
||||
values[i++] = PointerGetDatum(construct_array_builtin(arrayelems,
|
||||
|
||||
@@ -355,7 +355,7 @@ pgpa_compute_rti_from_identifier(int rtable_length,
|
||||
{
|
||||
Index result = 0;
|
||||
|
||||
for (Index rti = 1; rti <= rtable_length; ++rti)
|
||||
for (int rti = 1; rti <= rtable_length; ++rti)
|
||||
{
|
||||
pgpa_identifier *rti_rid = &rt_identifiers[rti - 1];
|
||||
|
||||
|
||||
@@ -231,7 +231,6 @@ pgpa_build_unrolled_join(pgpa_plan_walker_context *walker,
|
||||
pgpa_join_unroller *join_unroller)
|
||||
{
|
||||
pgpa_unrolled_join *ujoin;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* We shouldn't have gone even so far as to create a join unroller unless
|
||||
@@ -260,7 +259,7 @@ pgpa_build_unrolled_join(pgpa_plan_walker_context *walker,
|
||||
* the reverse of that order, so we need to flip the order of the arrays
|
||||
* when constructing the final result.
|
||||
*/
|
||||
for (i = 0; i < join_unroller->nused; ++i)
|
||||
for (unsigned i = 0; i < join_unroller->nused; ++i)
|
||||
{
|
||||
int k = join_unroller->nused - i - 1;
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ pgpa_output_advice(StringInfo buf, pgpa_plan_walker_context *walker,
|
||||
* portion of the query didn't make it into the final plan.
|
||||
*/
|
||||
context.rid_strings = palloc0_array(const char *, rtable_length);
|
||||
for (int i = 0; i < rtable_length; ++i)
|
||||
for (Index i = 0; i < rtable_length; ++i)
|
||||
if (rt_identifiers[i].alias_name != NULL)
|
||||
context.rid_strings[i] = pgpa_identifier_string(&rt_identifiers[i]);
|
||||
|
||||
@@ -173,7 +173,7 @@ pgpa_output_unrolled_join(pgpa_output_context *context,
|
||||
{
|
||||
pgpa_output_join_member(context, &join->outer);
|
||||
|
||||
for (int k = 0; k < join->ninner; ++k)
|
||||
for (unsigned k = 0; k < join->ninner; ++k)
|
||||
{
|
||||
pgpa_join_member *member = &join->inner[k];
|
||||
|
||||
|
||||
@@ -502,7 +502,7 @@ pgpa_process_unrolled_join(pgpa_plan_walker_context *walker,
|
||||
/* If this fails, we didn't unroll properly. */
|
||||
Assert(ujoin->outer.unrolled_join == NULL);
|
||||
|
||||
for (int k = 0; k < ujoin->ninner; ++k)
|
||||
for (unsigned k = 0; k < ujoin->ninner; ++k)
|
||||
{
|
||||
pgpa_join_member *member = &ujoin->inner[k];
|
||||
Bitmapset *relids;
|
||||
|
||||
@@ -535,10 +535,9 @@ gtrgm_distance(PG_FUNCTION_ARGS)
|
||||
static int32
|
||||
unionkey(BITVECP sbase, TRGM *add, int siglen)
|
||||
{
|
||||
int32 i;
|
||||
|
||||
if (ISSIGNKEY(add))
|
||||
{
|
||||
int32 i;
|
||||
BITVECP sadd = GETSIGN(add);
|
||||
|
||||
if (ISALLTRUE(add))
|
||||
@@ -552,7 +551,7 @@ unionkey(BITVECP sbase, TRGM *add, int siglen)
|
||||
trgm *ptr = GETARR(add);
|
||||
int32 tmp = 0;
|
||||
|
||||
for (i = 0; i < ARRNELEM(add); i++)
|
||||
for (unsigned i = 0; i < ARRNELEM(add); i++)
|
||||
{
|
||||
CPTRGM(&tmp, ptr + i);
|
||||
HASH(sbase, tmp, siglen);
|
||||
|
||||
@@ -507,8 +507,6 @@ static void
|
||||
startScanKey(GinState *ginstate, GinScanOpaque so, GinScanKey key)
|
||||
{
|
||||
MemoryContext oldCtx = CurrentMemoryContext;
|
||||
int i;
|
||||
int j;
|
||||
int *entryIndexes;
|
||||
|
||||
ItemPointerSetMin(&key->curItem);
|
||||
@@ -545,11 +543,14 @@ startScanKey(GinState *ginstate, GinScanOpaque so, GinScanKey key)
|
||||
key->nrequired = 0;
|
||||
key->nadditional = key->nentries;
|
||||
key->additionalEntries = palloc(key->nadditional * sizeof(GinScanEntry));
|
||||
for (i = 0; i < key->nadditional; i++)
|
||||
for (int i = 0; i < key->nadditional; i++)
|
||||
key->additionalEntries[i] = key->scanEntry[i];
|
||||
}
|
||||
else if (key->nentries > 1)
|
||||
{
|
||||
uint32 i;
|
||||
int j;
|
||||
|
||||
MemoryContextSwitchTo(so->tempCtx);
|
||||
|
||||
entryIndexes = palloc_array(int, key->nentries);
|
||||
@@ -581,10 +582,10 @@ startScanKey(GinState *ginstate, GinScanOpaque so, GinScanKey key)
|
||||
key->additionalEntries = palloc(key->nadditional * sizeof(GinScanEntry));
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < key->nrequired; i++)
|
||||
key->requiredEntries[i] = key->scanEntry[entryIndexes[j++]];
|
||||
for (i = 0; i < key->nadditional; i++)
|
||||
key->additionalEntries[i] = key->scanEntry[entryIndexes[j++]];
|
||||
for (int k = 0; k < key->nrequired; k++)
|
||||
key->requiredEntries[k] = key->scanEntry[entryIndexes[j++]];
|
||||
for (int k = 0; k < key->nadditional; k++)
|
||||
key->additionalEntries[k] = key->scanEntry[entryIndexes[j++]];
|
||||
|
||||
/* clean up after consistentFn calls (also frees entryIndexes) */
|
||||
MemoryContextReset(so->tempCtx);
|
||||
@@ -1007,7 +1008,6 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
|
||||
{
|
||||
ItemPointerData minItem;
|
||||
ItemPointerData curPageLossy;
|
||||
uint32 i;
|
||||
bool haveLossyEntry;
|
||||
GinScanEntry entry;
|
||||
GinTernaryValue res;
|
||||
@@ -1034,7 +1034,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
|
||||
*/
|
||||
ItemPointerSetMax(&minItem);
|
||||
allFinished = true;
|
||||
for (i = 0; i < key->nrequired; i++)
|
||||
for (int i = 0; i < key->nrequired; i++)
|
||||
{
|
||||
entry = key->requiredEntries[i];
|
||||
|
||||
@@ -1116,7 +1116,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
|
||||
* decide with partial information, that could be a big loss. So, load all
|
||||
* the additional entries, before calling the consistent function.
|
||||
*/
|
||||
for (i = 0; i < key->nadditional; i++)
|
||||
for (int i = 0; i < key->nadditional; i++)
|
||||
{
|
||||
entry = key->additionalEntries[i];
|
||||
|
||||
@@ -1176,7 +1176,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
|
||||
ItemPointerSetLossyPage(&curPageLossy,
|
||||
GinItemPointerGetBlockNumber(&key->curItem));
|
||||
haveLossyEntry = false;
|
||||
for (i = 0; i < key->nentries; i++)
|
||||
for (uint32 i = 0; i < key->nentries; i++)
|
||||
{
|
||||
entry = key->scanEntry[i];
|
||||
if (entry->isFinished == false &&
|
||||
@@ -1224,7 +1224,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
|
||||
*
|
||||
* Prepare entryRes array to be passed to consistentFn.
|
||||
*/
|
||||
for (i = 0; i < key->nentries; i++)
|
||||
for (uint32 i = 0; i < key->nentries; i++)
|
||||
{
|
||||
entry = key->scanEntry[i];
|
||||
if (entry->isFinished)
|
||||
@@ -1625,13 +1625,11 @@ collectMatchesForHeapRow(IndexScanDesc scan, pendingPosition *pos)
|
||||
OffsetNumber attrnum;
|
||||
Page page;
|
||||
IndexTuple itup;
|
||||
int i,
|
||||
j;
|
||||
|
||||
/*
|
||||
* Reset all entryRes and hasMatchKey flags
|
||||
*/
|
||||
for (i = 0; i < so->nkeys; i++)
|
||||
for (uint32 i = 0; i < so->nkeys; i++)
|
||||
{
|
||||
GinScanKey key = so->keys + i;
|
||||
|
||||
@@ -1655,11 +1653,11 @@ collectMatchesForHeapRow(IndexScanDesc scan, pendingPosition *pos)
|
||||
|
||||
page = BufferGetPage(pos->pendingBuffer);
|
||||
|
||||
for (i = 0; i < so->nkeys; i++)
|
||||
for (uint32 i = 0; i < so->nkeys; i++)
|
||||
{
|
||||
GinScanKey key = so->keys + i;
|
||||
|
||||
for (j = 0; j < key->nentries; j++)
|
||||
for (uint32 j = 0; j < key->nentries; j++)
|
||||
{
|
||||
GinScanEntry entry = key->scanEntry[j];
|
||||
OffsetNumber StopLow = pos->firstOffset,
|
||||
@@ -1821,7 +1819,7 @@ collectMatchesForHeapRow(IndexScanDesc scan, pendingPosition *pos)
|
||||
* GIN_CAT_EMPTY_QUERY scanEntry always matches. So return "true" if all
|
||||
* non-excludeOnly scan keys have at least one match.
|
||||
*/
|
||||
for (i = 0; i < so->nkeys; i++)
|
||||
for (uint32 i = 0; i < so->nkeys; i++)
|
||||
{
|
||||
if (pos->hasMatchKey[i] == false && !so->keys[i].excludeOnly)
|
||||
return false;
|
||||
@@ -1840,7 +1838,6 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids)
|
||||
MemoryContext oldCtx;
|
||||
bool recheck,
|
||||
match;
|
||||
int i;
|
||||
pendingPosition pos;
|
||||
Buffer metabuffer = ReadBuffer(scan->indexRelation, GIN_METAPAGE_BLKNO);
|
||||
Page page;
|
||||
@@ -1899,7 +1896,7 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids)
|
||||
recheck = false;
|
||||
match = true;
|
||||
|
||||
for (i = 0; i < so->nkeys; i++)
|
||||
for (uint32 i = 0; i < so->nkeys; i++)
|
||||
{
|
||||
GinScanKey key = so->keys + i;
|
||||
|
||||
|
||||
@@ -148,8 +148,7 @@ static GinTernaryValue
|
||||
shimTriConsistentFn(GinScanKey key)
|
||||
{
|
||||
int nmaybe;
|
||||
int maybeEntries[MAX_MAYBE_ENTRIES];
|
||||
int i;
|
||||
uint32 maybeEntries[MAX_MAYBE_ENTRIES];
|
||||
bool boolResult;
|
||||
bool recheck;
|
||||
GinTernaryValue curResult;
|
||||
@@ -160,7 +159,7 @@ shimTriConsistentFn(GinScanKey key)
|
||||
* test all combinations, so give up and return MAYBE.
|
||||
*/
|
||||
nmaybe = 0;
|
||||
for (i = 0; i < key->nentries; i++)
|
||||
for (uint32 i = 0; i < key->nentries; i++)
|
||||
{
|
||||
if (key->entryRes[i] == GIN_MAYBE)
|
||||
{
|
||||
@@ -178,13 +177,15 @@ shimTriConsistentFn(GinScanKey key)
|
||||
return directBoolConsistentFn(key);
|
||||
|
||||
/* First call consistent function with all the maybe-inputs set FALSE */
|
||||
for (i = 0; i < nmaybe; i++)
|
||||
for (int i = 0; i < nmaybe; i++)
|
||||
key->entryRes[maybeEntries[i]] = GIN_FALSE;
|
||||
curResult = directBoolConsistentFn(key);
|
||||
recheck = key->recheckCurItem;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Twiddle the entries for next combination. */
|
||||
for (i = 0; i < nmaybe; i++)
|
||||
{
|
||||
@@ -214,7 +215,7 @@ shimTriConsistentFn(GinScanKey key)
|
||||
curResult = GIN_MAYBE;
|
||||
|
||||
/* We must restore the original state of the entryRes array */
|
||||
for (i = 0; i < nmaybe; i++)
|
||||
for (int i = 0; i < nmaybe; i++)
|
||||
key->entryRes[maybeEntries[i]] = GIN_MAYBE;
|
||||
|
||||
return curResult;
|
||||
|
||||
@@ -268,7 +268,6 @@ ginNewScanKey(IndexScanDesc scan)
|
||||
{
|
||||
ScanKey scankey = scan->keyData;
|
||||
GinScanOpaque so = (GinScanOpaque) scan->opaque;
|
||||
int i;
|
||||
int numExcludeOnly;
|
||||
bool hasNullQuery = false;
|
||||
bool attrHasNormalScan[INDEX_MAX_KEYS] = {false};
|
||||
@@ -294,7 +293,7 @@ ginNewScanKey(IndexScanDesc scan)
|
||||
|
||||
so->isVoidRes = false;
|
||||
|
||||
for (i = 0; i < scan->numberOfKeys; i++)
|
||||
for (int i = 0; i < scan->numberOfKeys; i++)
|
||||
{
|
||||
ScanKey skey = &scankey[i];
|
||||
Datum *queryValues;
|
||||
@@ -393,7 +392,7 @@ ginNewScanKey(IndexScanDesc scan)
|
||||
* and be set to normal (excludeOnly = false).
|
||||
*/
|
||||
numExcludeOnly = 0;
|
||||
for (i = 0; i < so->nkeys; i++)
|
||||
for (uint32 i = 0; i < so->nkeys; i++)
|
||||
{
|
||||
GinScanKey key = &so->keys[i];
|
||||
|
||||
@@ -427,7 +426,7 @@ ginNewScanKey(IndexScanDesc scan)
|
||||
/* Re-order the keys ... */
|
||||
iNormalKey = 0;
|
||||
iExcludeOnly = so->nkeys - numExcludeOnly;
|
||||
for (i = 0; i < so->nkeys; i++)
|
||||
for (uint32 i = 0; i < so->nkeys; i++)
|
||||
{
|
||||
GinScanKey key = &so->keys[i];
|
||||
|
||||
|
||||
@@ -3049,7 +3049,7 @@ _bt_pendingfsm_finalize(Relation rel, BTVacState *vstate)
|
||||
*/
|
||||
GetOldestNonRemovableTransactionId(heaprel);
|
||||
|
||||
for (int i = 0; i < vstate->npendingpages; i++)
|
||||
for (unsigned int i = 0; i < vstate->npendingpages; i++)
|
||||
{
|
||||
BlockNumber target = vstate->pendingpages[i].target;
|
||||
FullTransactionId safexid = vstate->pendingpages[i].safexid;
|
||||
|
||||
@@ -34,7 +34,7 @@ logicalmsg_desc(StringInfo buf, XLogReaderState *record)
|
||||
xlrec->transactional ? "transactional" : "non-transactional",
|
||||
prefix, xlrec->message_size);
|
||||
/* Write message payload as a series of hex bytes */
|
||||
for (int cnt = 0; cnt < xlrec->message_size; cnt++)
|
||||
for (Size cnt = 0; cnt < xlrec->message_size; cnt++)
|
||||
{
|
||||
appendStringInfo(buf, "%s%02X", sep, (unsigned char) message[cnt]);
|
||||
sep = " ";
|
||||
|
||||
@@ -95,14 +95,13 @@ execCurrentOf(CurrentOfExpr *cexpr,
|
||||
if (queryDesc->estate->es_rowmarks)
|
||||
{
|
||||
ExecRowMark *erm;
|
||||
Index i;
|
||||
|
||||
/*
|
||||
* Here, the query must have exactly one FOR UPDATE/SHARE reference to
|
||||
* the target table, and we dig the ctid info out of that.
|
||||
*/
|
||||
erm = NULL;
|
||||
for (i = 0; i < queryDesc->estate->es_range_table_size; i++)
|
||||
for (int i = 0; i < queryDesc->estate->es_range_table_size; i++)
|
||||
{
|
||||
ExecRowMark *thiserm = queryDesc->estate->es_rowmarks[i];
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@ llvm_copy_attributes(LLVMValueRef v_from, LLVMValueRef v_to)
|
||||
/* and each function parameter's attribute */
|
||||
param_count = LLVMCountParams(v_from);
|
||||
|
||||
for (int paramidx = 1; paramidx <= param_count; paramidx++)
|
||||
for (uint32 paramidx = 1; paramidx <= param_count; paramidx++)
|
||||
llvm_copy_attributes_at_index(v_from, v_to, paramidx);
|
||||
}
|
||||
|
||||
@@ -1138,7 +1138,7 @@ llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
|
||||
LLVMErrorRef error;
|
||||
LLVMOrcMaterializationUnitRef mu;
|
||||
|
||||
for (int i = 0; i < LookupSetSize; i++)
|
||||
for (size_t i = 0; i < LookupSetSize; i++)
|
||||
{
|
||||
const char *name = LLVMOrcSymbolStringPoolEntryStr(LookupSet[i].Name);
|
||||
|
||||
|
||||
@@ -187,9 +187,8 @@ estimateHyperLogLog(hyperLogLogState *cState)
|
||||
{
|
||||
double result;
|
||||
double sum = 0.0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cState->nRegisters; i++)
|
||||
for (Size i = 0; i < cState->nRegisters; i++)
|
||||
{
|
||||
sum += 1.0 / pow(2.0, cState->hashesArr[i]);
|
||||
}
|
||||
@@ -202,7 +201,7 @@ estimateHyperLogLog(hyperLogLogState *cState)
|
||||
/* Small range correction */
|
||||
int zero_count = 0;
|
||||
|
||||
for (i = 0; i < cState->nRegisters; i++)
|
||||
for (Size i = 0; i < cState->nRegisters; i++)
|
||||
{
|
||||
if (cState->hashesArr[i] == 0)
|
||||
zero_count++;
|
||||
|
||||
@@ -1081,7 +1081,7 @@ markNullableIfNeeded(ParseState *pstate, Var *var)
|
||||
Bitmapset *relids;
|
||||
|
||||
/* Find the appropriate pstate */
|
||||
for (int lv = 0; lv < var->varlevelsup; lv++)
|
||||
for (Index lv = 0; lv < var->varlevelsup; lv++)
|
||||
pstate = pstate->parentParseState;
|
||||
|
||||
/* Find currently-relevant join relids for the Var's rel */
|
||||
|
||||
@@ -1620,7 +1620,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
|
||||
ParseState mypstate = {0};
|
||||
|
||||
/* this loop must work, since GetRTEByRangeTablePosn did */
|
||||
for (Index level = 0; level < netlevelsup; level++)
|
||||
for (int level = 0; level < netlevelsup; level++)
|
||||
pstate = pstate->parentParseState;
|
||||
mypstate.parentParseState = pstate;
|
||||
mypstate.p_rtable = rte->subquery->rtable;
|
||||
|
||||
@@ -521,7 +521,6 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
|
||||
* 2*FD_SETSIZE sockets */
|
||||
SOCKET sockets[FD_SETSIZE * 2];
|
||||
int numevents = 0;
|
||||
int i;
|
||||
int r;
|
||||
DWORD timeoutval = WSA_INFINITE;
|
||||
FD_SET outreadfds;
|
||||
@@ -548,7 +547,7 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
|
||||
*/
|
||||
if (writefds != NULL)
|
||||
{
|
||||
for (i = 0; i < writefds->fd_count; i++)
|
||||
for (u_int i = 0; i < writefds->fd_count; i++)
|
||||
{
|
||||
char c;
|
||||
WSABUF buf;
|
||||
@@ -583,7 +582,7 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
|
||||
|
||||
if (readfds != NULL)
|
||||
{
|
||||
for (i = 0; i < readfds->fd_count; i++)
|
||||
for (u_int i = 0; i < readfds->fd_count; i++)
|
||||
{
|
||||
events[numevents] = WSACreateEvent();
|
||||
sockets[numevents] = readfds->fd_array[i];
|
||||
@@ -592,7 +591,7 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
|
||||
}
|
||||
if (writefds != NULL)
|
||||
{
|
||||
for (i = 0; i < writefds->fd_count; i++)
|
||||
for (u_int i = 0; i < writefds->fd_count; i++)
|
||||
{
|
||||
if (!readfds ||
|
||||
!FD_ISSET(writefds->fd_array[i], readfds))
|
||||
@@ -605,7 +604,7 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < numevents; i++)
|
||||
for (int i = 0; i < numevents; i++)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
@@ -637,7 +636,7 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
|
||||
*/
|
||||
WSANETWORKEVENTS resEvents;
|
||||
|
||||
for (i = 0; i < numevents; i++)
|
||||
for (int i = 0; i < numevents; i++)
|
||||
{
|
||||
ZeroMemory(&resEvents, sizeof(resEvents));
|
||||
if (WSAEnumNetworkEvents(sockets[i], events[i], &resEvents) != 0)
|
||||
@@ -670,7 +669,7 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
|
||||
}
|
||||
|
||||
/* Clean up all the event objects */
|
||||
for (i = 0; i < numevents; i++)
|
||||
for (int i = 0; i < numevents; i++)
|
||||
{
|
||||
WSAEventSelect(sockets[i], NULL, 0);
|
||||
WSACloseEvent(events[i]);
|
||||
|
||||
@@ -1288,7 +1288,7 @@ ReorderBufferIterTXNInit(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
Size nr_txns = 0;
|
||||
ReorderBufferIterTXNState *state;
|
||||
dlist_iter cur_txn_i;
|
||||
int32 off;
|
||||
Size off;
|
||||
|
||||
*iter_state = NULL;
|
||||
|
||||
@@ -1505,7 +1505,7 @@ static void
|
||||
ReorderBufferIterTXNFinish(ReorderBuffer *rb,
|
||||
ReorderBufferIterTXNState *state)
|
||||
{
|
||||
int32 off;
|
||||
Size off;
|
||||
|
||||
for (off = 0; off < state->nr_txns; off++)
|
||||
{
|
||||
@@ -3252,7 +3252,6 @@ ReorderBufferImmediateInvalidation(ReorderBuffer *rb, uint32 ninvalidations,
|
||||
bool use_subtxn = IsTransactionOrTransactionBlock();
|
||||
MemoryContext ccxt = CurrentMemoryContext;
|
||||
ResourceOwner cowner = CurrentResourceOwner;
|
||||
int i;
|
||||
|
||||
if (use_subtxn)
|
||||
BeginInternalSubTransaction("replay");
|
||||
@@ -3266,7 +3265,7 @@ ReorderBufferImmediateInvalidation(ReorderBuffer *rb, uint32 ninvalidations,
|
||||
if (use_subtxn)
|
||||
AbortCurrentTransaction();
|
||||
|
||||
for (i = 0; i < ninvalidations; i++)
|
||||
for (uint32 i = 0; i < ninvalidations; i++)
|
||||
LocalExecuteInvalidationMessage(&invalidations[i]);
|
||||
|
||||
if (use_subtxn)
|
||||
@@ -3636,9 +3635,7 @@ ReorderBufferAddDistributedInvalidations(ReorderBuffer *rb, TransactionId xid,
|
||||
static void
|
||||
ReorderBufferExecuteInvalidations(uint32 nmsgs, SharedInvalidationMessage *msgs)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nmsgs; i++)
|
||||
for (uint32 i = 0; i < nmsgs; i++)
|
||||
LocalExecuteInvalidationMessage(&msgs[i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -866,7 +866,6 @@ SnapBuildAddCommittedTxn(SnapBuild *builder, TransactionId xid)
|
||||
static void
|
||||
SnapBuildPurgeOlderTxn(SnapBuild *builder)
|
||||
{
|
||||
int off;
|
||||
TransactionId *workspace;
|
||||
int surviving_xids = 0;
|
||||
|
||||
@@ -880,7 +879,7 @@ SnapBuildPurgeOlderTxn(SnapBuild *builder)
|
||||
builder->committed.xcnt * sizeof(TransactionId));
|
||||
|
||||
/* copy xids that still are interesting to workspace */
|
||||
for (off = 0; off < builder->committed.xcnt; off++)
|
||||
for (size_t off = 0; off < builder->committed.xcnt; off++)
|
||||
{
|
||||
if (NormalTransactionIdPrecedes(builder->committed.xip[off],
|
||||
builder->xmin))
|
||||
@@ -906,6 +905,8 @@ SnapBuildPurgeOlderTxn(SnapBuild *builder)
|
||||
*/
|
||||
if (builder->catchange.xcnt > 0)
|
||||
{
|
||||
size_t off;
|
||||
|
||||
/*
|
||||
* Since catchange.xip is sorted, we find the lower bound of xids that
|
||||
* are still interesting.
|
||||
|
||||
@@ -436,7 +436,6 @@ statext_dependencies_build(StatsBuildData *data)
|
||||
bytea *
|
||||
statext_dependencies_serialize(MVDependencies *dependencies)
|
||||
{
|
||||
int i;
|
||||
bytea *output;
|
||||
char *tmp;
|
||||
Size len;
|
||||
@@ -445,7 +444,7 @@ statext_dependencies_serialize(MVDependencies *dependencies)
|
||||
len = VARHDRSZ + SizeOfHeader;
|
||||
|
||||
/* and also include space for the actual attribute numbers and degrees */
|
||||
for (i = 0; i < dependencies->ndeps; i++)
|
||||
for (uint32 i = 0; i < dependencies->ndeps; i++)
|
||||
len += SizeOfItem(dependencies->deps[i]->nattributes);
|
||||
|
||||
output = (bytea *) palloc0(len);
|
||||
@@ -462,7 +461,7 @@ statext_dependencies_serialize(MVDependencies *dependencies)
|
||||
tmp += sizeof(uint32);
|
||||
|
||||
/* store number of attributes and attribute numbers for each dependency */
|
||||
for (i = 0; i < dependencies->ndeps; i++)
|
||||
for (uint32 i = 0; i < dependencies->ndeps; i++)
|
||||
{
|
||||
MVDependency *d = dependencies->deps[i];
|
||||
|
||||
@@ -491,7 +490,6 @@ statext_dependencies_serialize(MVDependencies *dependencies)
|
||||
MVDependencies *
|
||||
statext_dependencies_deserialize(bytea *data)
|
||||
{
|
||||
int i;
|
||||
Size min_expected_size;
|
||||
MVDependencies *dependencies;
|
||||
char *tmp;
|
||||
@@ -539,7 +537,7 @@ statext_dependencies_deserialize(bytea *data)
|
||||
dependencies = repalloc(dependencies, offsetof(MVDependencies, deps)
|
||||
+ (dependencies->ndeps * sizeof(MVDependency *)));
|
||||
|
||||
for (i = 0; i < dependencies->ndeps; i++)
|
||||
for (uint32 i = 0; i < dependencies->ndeps; i++)
|
||||
{
|
||||
double degree;
|
||||
AttrNumber k;
|
||||
@@ -585,7 +583,7 @@ statext_dependencies_deserialize(bytea *data)
|
||||
void
|
||||
statext_dependencies_free(MVDependencies *dependencies)
|
||||
{
|
||||
for (int i = 0; i < dependencies->ndeps; i++)
|
||||
for (uint32 i = 0; i < dependencies->ndeps; i++)
|
||||
pfree(dependencies->deps[i]);
|
||||
pfree(dependencies);
|
||||
}
|
||||
@@ -610,7 +608,7 @@ statext_dependencies_validate(const MVDependencies *dependencies,
|
||||
int attnum_expr_lowbound = 0 - numexprs;
|
||||
|
||||
/* Scan through each dependency entry */
|
||||
for (int i = 0; i < dependencies->ndeps; i++)
|
||||
for (uint32 i = 0; i < dependencies->ndeps; i++)
|
||||
{
|
||||
const MVDependency *dep = dependencies->deps[i];
|
||||
|
||||
@@ -913,8 +911,6 @@ static MVDependency *
|
||||
find_strongest_dependency(MVDependencies **dependencies, int ndependencies,
|
||||
Bitmapset *attnums)
|
||||
{
|
||||
int i,
|
||||
j;
|
||||
MVDependency *strongest = NULL;
|
||||
|
||||
/* number of attnums in clauses */
|
||||
@@ -925,9 +921,9 @@ find_strongest_dependency(MVDependencies **dependencies, int ndependencies,
|
||||
* fully-matched dependencies. We do the cheap checks first, before
|
||||
* matching it against the attnums.
|
||||
*/
|
||||
for (i = 0; i < ndependencies; i++)
|
||||
for (int i = 0; i < ndependencies; i++)
|
||||
{
|
||||
for (j = 0; j < dependencies[i]->ndeps; j++)
|
||||
for (uint32 j = 0; j < dependencies[i]->ndeps; j++)
|
||||
{
|
||||
MVDependency *dependency = dependencies[i]->deps[j];
|
||||
|
||||
@@ -1369,7 +1365,6 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
|
||||
int total_ndeps;
|
||||
MVDependency **dependencies;
|
||||
int ndependencies;
|
||||
int i;
|
||||
AttrNumber attnum_offset;
|
||||
RangeTblEntry *rte = planner_rt_fetch(rel->relid, root);
|
||||
|
||||
@@ -1439,7 +1434,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
|
||||
Assert(expr != NULL);
|
||||
|
||||
/* If the expression is duplicate, use the same attnum. */
|
||||
for (i = 0; i < unique_exprs_cnt; i++)
|
||||
for (int i = 0; i < unique_exprs_cnt; i++)
|
||||
{
|
||||
if (equal(unique_exprs[i], expr))
|
||||
{
|
||||
@@ -1482,7 +1477,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
|
||||
* Now that we know how many expressions there are, we can offset the
|
||||
* values just enough to build the bitmapset.
|
||||
*/
|
||||
for (i = 0; i < list_length(clauses); i++)
|
||||
for (int i = 0; i < list_length(clauses); i++)
|
||||
{
|
||||
AttrNumber attnum;
|
||||
|
||||
@@ -1587,7 +1582,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
|
||||
|
||||
/* count matching expressions */
|
||||
nexprs = 0;
|
||||
for (i = 0; i < unique_exprs_cnt; i++)
|
||||
for (int i = 0; i < unique_exprs_cnt; i++)
|
||||
{
|
||||
ListCell *lc;
|
||||
|
||||
@@ -1638,15 +1633,14 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
|
||||
*/
|
||||
if (unique_exprs_cnt > 0 || stat->exprs != NIL)
|
||||
{
|
||||
int ndeps = 0;
|
||||
uint32 ndeps = 0;
|
||||
|
||||
for (i = 0; i < deps->ndeps; i++)
|
||||
for (uint32 i = 0; i < deps->ndeps; i++)
|
||||
{
|
||||
bool skip = false;
|
||||
MVDependency *dep = deps->deps[i];
|
||||
int j;
|
||||
|
||||
for (j = 0; j < dep->nattributes; j++)
|
||||
for (int j = 0; j < dep->nattributes; j++)
|
||||
{
|
||||
int idx;
|
||||
Node *expr;
|
||||
@@ -1797,7 +1791,7 @@ dependencies_clauselist_selectivity(PlannerInfo *root,
|
||||
list_attnums, estimatedclauses);
|
||||
|
||||
/* free deserialized functional dependencies (and then the array) */
|
||||
for (i = 0; i < nfunc_dependencies; i++)
|
||||
for (int i = 0; i < nfunc_dependencies; i++)
|
||||
pfree(func_dependencies[i]);
|
||||
|
||||
pfree(dependencies);
|
||||
|
||||
@@ -618,7 +618,6 @@ statext_mcv_load(Oid mvoid, bool inh)
|
||||
bytea *
|
||||
statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
|
||||
{
|
||||
int i;
|
||||
int dim;
|
||||
int ndims = mcvlist->ndimensions;
|
||||
|
||||
@@ -668,7 +667,7 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
|
||||
/* allocate space for values in the attribute and collect them */
|
||||
values[dim] = palloc0_array(Datum, mcvlist->nitems);
|
||||
|
||||
for (i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
{
|
||||
/* skip NULL values - we don't need to deduplicate those */
|
||||
if (mcvlist->items[i].isnull[dim])
|
||||
@@ -700,7 +699,7 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
|
||||
* element.
|
||||
*/
|
||||
ndistinct = 1; /* number of distinct values */
|
||||
for (i = 1; i < counts[dim]; i++)
|
||||
for (int i = 1; i < counts[dim]; i++)
|
||||
{
|
||||
/* expect sorted array */
|
||||
Assert(compare_datums_simple(values[dim][i - 1], values[dim][i], &ssup[dim]) <= 0);
|
||||
@@ -752,7 +751,7 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
|
||||
{
|
||||
info[dim].nbytes = 0;
|
||||
info[dim].nbytes_aligned = 0;
|
||||
for (i = 0; i < info[dim].nvalues; i++)
|
||||
for (int i = 0; i < info[dim].nvalues; i++)
|
||||
{
|
||||
Size len;
|
||||
|
||||
@@ -780,7 +779,7 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
|
||||
{
|
||||
info[dim].nbytes = 0;
|
||||
info[dim].nbytes_aligned = 0;
|
||||
for (i = 0; i < info[dim].nvalues; i++)
|
||||
for (int i = 0; i < info[dim].nvalues; i++)
|
||||
{
|
||||
Size len;
|
||||
|
||||
@@ -818,7 +817,7 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
|
||||
total_length += ndims * sizeof(DimensionInfo);
|
||||
|
||||
/* add space for the arrays of deduplicated values */
|
||||
for (i = 0; i < ndims; i++)
|
||||
for (int i = 0; i < ndims; i++)
|
||||
total_length += info[i].nbytes;
|
||||
|
||||
/*
|
||||
@@ -863,7 +862,7 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
|
||||
/* remember the starting point for Asserts later */
|
||||
char *start PG_USED_FOR_ASSERTS_ONLY = ptr;
|
||||
|
||||
for (i = 0; i < info[dim].nvalues; i++)
|
||||
for (int i = 0; i < info[dim].nvalues; i++)
|
||||
{
|
||||
Datum value = values[dim][i];
|
||||
|
||||
@@ -925,7 +924,7 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
|
||||
}
|
||||
|
||||
/* Serialize the items, with uint16 indexes instead of the values. */
|
||||
for (i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
{
|
||||
MCVItem *mcvitem = &mcvlist->items[i];
|
||||
|
||||
@@ -1652,7 +1651,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
* can skip items that were already ruled out, and terminate if
|
||||
* there are no remaining MCV items that might possibly match.
|
||||
*/
|
||||
for (int i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
{
|
||||
bool match = true;
|
||||
MCVItem *item = &mcvlist->items[i];
|
||||
@@ -1759,7 +1758,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
* can skip items that were already ruled out, and terminate if
|
||||
* there are no remaining MCV items that might possibly match.
|
||||
*/
|
||||
for (int i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
{
|
||||
int j;
|
||||
bool match = !expr->useOr;
|
||||
@@ -1830,7 +1829,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
* can skip items that were already ruled out, and terminate if
|
||||
* there are no remaining MCV items that might possibly match.
|
||||
*/
|
||||
for (int i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
{
|
||||
bool match = false; /* assume mismatch */
|
||||
MCVItem *item = &mcvlist->items[i];
|
||||
@@ -1855,7 +1854,6 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
{
|
||||
/* AND/OR clause, with all subclauses being compatible */
|
||||
|
||||
int i;
|
||||
BoolExpr *bool_clause = ((BoolExpr *) clause);
|
||||
List *bool_clauses = bool_clause->args;
|
||||
|
||||
@@ -1874,7 +1872,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
* current one. We need to consider if we're evaluating AND or OR
|
||||
* condition when merging the results.
|
||||
*/
|
||||
for (i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
matches[i] = RESULT_MERGE(matches[i], is_or, bool_matches[i]);
|
||||
|
||||
pfree(bool_matches);
|
||||
@@ -1883,7 +1881,6 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
{
|
||||
/* NOT clause, with all subclauses compatible */
|
||||
|
||||
int i;
|
||||
BoolExpr *not_clause = ((BoolExpr *) clause);
|
||||
List *not_args = not_clause->args;
|
||||
|
||||
@@ -1902,7 +1899,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
* current one. We're handling a NOT clause, so invert the result
|
||||
* before merging it into the global bitmap.
|
||||
*/
|
||||
for (i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
matches[i] = RESULT_MERGE(matches[i], is_or, !not_matches[i]);
|
||||
|
||||
pfree(not_matches);
|
||||
@@ -1923,7 +1920,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
* can skip items that were already ruled out, and terminate if
|
||||
* there are no remaining MCV items that might possibly match.
|
||||
*/
|
||||
for (int i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
{
|
||||
MCVItem *item = &mcvlist->items[i];
|
||||
bool match = false;
|
||||
@@ -1949,7 +1946,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
|
||||
* can skip items that were already ruled out, and terminate if
|
||||
* there are no remaining MCV items that might possibly match.
|
||||
*/
|
||||
for (int i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
{
|
||||
bool match;
|
||||
MCVItem *item = &mcvlist->items[i];
|
||||
@@ -2049,7 +2046,6 @@ mcv_clauselist_selectivity(PlannerInfo *root, StatisticExtInfo *stat,
|
||||
RelOptInfo *rel,
|
||||
Selectivity *basesel, Selectivity *totalsel)
|
||||
{
|
||||
int i;
|
||||
MCVList *mcv;
|
||||
Selectivity s = 0.0;
|
||||
RangeTblEntry *rte = root->simple_rte_array[rel->relid];
|
||||
@@ -2067,7 +2063,7 @@ mcv_clauselist_selectivity(PlannerInfo *root, StatisticExtInfo *stat,
|
||||
/* sum frequencies for all the matching MCV items */
|
||||
*basesel = 0.0;
|
||||
*totalsel = 0.0;
|
||||
for (i = 0; i < mcv->nitems; i++)
|
||||
for (uint32 i = 0; i < mcv->nitems; i++)
|
||||
{
|
||||
*totalsel += mcv->items[i].frequency;
|
||||
|
||||
@@ -2128,7 +2124,6 @@ mcv_clause_selectivity_or(PlannerInfo *root, StatisticExtInfo *stat,
|
||||
{
|
||||
Selectivity s = 0.0;
|
||||
bool *new_matches;
|
||||
int i;
|
||||
|
||||
/* build the OR-matches bitmap, if not built already */
|
||||
if (*or_matches == NULL)
|
||||
@@ -2147,7 +2142,7 @@ mcv_clause_selectivity_or(PlannerInfo *root, StatisticExtInfo *stat,
|
||||
*overlap_mcvsel = 0.0;
|
||||
*overlap_basesel = 0.0;
|
||||
*totalsel = 0.0;
|
||||
for (i = 0; i < mcv->nitems; i++)
|
||||
for (uint32 i = 0; i < mcv->nitems; i++)
|
||||
{
|
||||
*totalsel += mcv->items[i].frequency;
|
||||
|
||||
@@ -2178,7 +2173,7 @@ mcv_clause_selectivity_or(PlannerInfo *root, StatisticExtInfo *stat,
|
||||
void
|
||||
statext_mcv_free(MCVList *mcvlist)
|
||||
{
|
||||
for (int i = 0; i < mcvlist->nitems; i++)
|
||||
for (uint32 i = 0; i < mcvlist->nitems; i++)
|
||||
{
|
||||
MCVItem *item = &mcvlist->items[i];
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ statext_ndistinct_build(double totalrows, StatsBuildData *data)
|
||||
{
|
||||
MVNDistinct *result;
|
||||
int k;
|
||||
int itemcnt;
|
||||
uint32 itemcnt;
|
||||
int numattrs = data->nattnums;
|
||||
int numcombs = num_combinations(numattrs);
|
||||
|
||||
@@ -175,7 +175,6 @@ statext_ndistinct_load(Oid mvoid, bool inh)
|
||||
bytea *
|
||||
statext_ndistinct_serialize(MVNDistinct *ndistinct)
|
||||
{
|
||||
int i;
|
||||
bytea *output;
|
||||
char *tmp;
|
||||
Size len;
|
||||
@@ -190,7 +189,7 @@ statext_ndistinct_serialize(MVNDistinct *ndistinct)
|
||||
len = VARHDRSZ + SizeOfHeader;
|
||||
|
||||
/* and also include space for the actual attribute numbers */
|
||||
for (i = 0; i < ndistinct->nitems; i++)
|
||||
for (uint32 i = 0; i < ndistinct->nitems; i++)
|
||||
{
|
||||
int nmembers;
|
||||
|
||||
@@ -216,7 +215,7 @@ statext_ndistinct_serialize(MVNDistinct *ndistinct)
|
||||
/*
|
||||
* store number of attributes and attribute numbers for each entry
|
||||
*/
|
||||
for (i = 0; i < ndistinct->nitems; i++)
|
||||
for (uint32 i = 0; i < ndistinct->nitems; i++)
|
||||
{
|
||||
MVNDistinctItem item = ndistinct->items[i];
|
||||
int nmembers = item.nattributes;
|
||||
@@ -246,7 +245,6 @@ statext_ndistinct_serialize(MVNDistinct *ndistinct)
|
||||
MVNDistinct *
|
||||
statext_ndistinct_deserialize(bytea *data)
|
||||
{
|
||||
int i;
|
||||
Size minimum_size;
|
||||
MVNDistinct ndist;
|
||||
MVNDistinct *ndistinct;
|
||||
@@ -296,7 +294,7 @@ statext_ndistinct_deserialize(bytea *data)
|
||||
ndistinct->type = ndist.type;
|
||||
ndistinct->nitems = ndist.nitems;
|
||||
|
||||
for (i = 0; i < ndistinct->nitems; i++)
|
||||
for (uint32 i = 0; i < ndistinct->nitems; i++)
|
||||
{
|
||||
MVNDistinctItem *item = &ndistinct->items[i];
|
||||
|
||||
@@ -331,7 +329,7 @@ statext_ndistinct_deserialize(bytea *data)
|
||||
void
|
||||
statext_ndistinct_free(MVNDistinct *ndistinct)
|
||||
{
|
||||
for (int i = 0; i < ndistinct->nitems; i++)
|
||||
for (uint32 i = 0; i < ndistinct->nitems; i++)
|
||||
pfree(ndistinct->items[i].attributes);
|
||||
pfree(ndistinct);
|
||||
}
|
||||
@@ -356,7 +354,7 @@ statext_ndistinct_validate(const MVNDistinct *ndistinct,
|
||||
int attnum_expr_lowbound = 0 - numexprs;
|
||||
|
||||
/* Scan through each MVNDistinct entry */
|
||||
for (int i = 0; i < ndistinct->nitems; i++)
|
||||
for (uint32 i = 0; i < ndistinct->nitems; i++)
|
||||
{
|
||||
MVNDistinctItem item = ndistinct->items[i];
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ AioShmemInit(void *arg)
|
||||
pgaio_ctl->iovecs = AioHandleIOVShmemPtr;
|
||||
pgaio_ctl->handle_data = AioHandleDataShmemPtr;
|
||||
|
||||
for (int procno = 0; procno < AioProcs(); procno++)
|
||||
for (uint32 procno = 0; procno < AioProcs(); procno++)
|
||||
{
|
||||
PgAioBackend *bs = &pgaio_ctl->backend_state[procno];
|
||||
|
||||
|
||||
@@ -544,7 +544,7 @@ pgaio_uring_drain_locked(PgAioUringContext *context)
|
||||
|
||||
ready -= ncqes;
|
||||
|
||||
for (int i = 0; i < ncqes; i++)
|
||||
for (uint32 i = 0; i < ncqes; i++)
|
||||
{
|
||||
struct io_uring_cqe *cqe = cqes[i];
|
||||
PgAioHandle *ioh = io_uring_cqe_get_data(cqe);
|
||||
|
||||
@@ -3181,9 +3181,7 @@ void
|
||||
AtEOSubXact_Files(bool isCommit, SubTransactionId mySubid,
|
||||
SubTransactionId parentSubid)
|
||||
{
|
||||
Index i;
|
||||
|
||||
for (i = 0; i < numAllocatedDescs; i++)
|
||||
for (int i = 0; i < numAllocatedDescs; i++)
|
||||
{
|
||||
if (allocatedDescs[i].create_subid == mySubid)
|
||||
{
|
||||
|
||||
@@ -1162,7 +1162,6 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
|
||||
/* output all allocated entries */
|
||||
while ((ent = (ShmemIndexEnt *) hash_seq_search(&hstat)) != NULL)
|
||||
{
|
||||
int i;
|
||||
char *startptr,
|
||||
*endptr;
|
||||
Size total_len;
|
||||
@@ -1194,7 +1193,7 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
|
||||
* pages, so that inquiry about NUMA memory node doesn't return -2
|
||||
* (ENOENT, which indicates unmapped/unallocated pages).
|
||||
*/
|
||||
for (i = 0; i < shm_ent_page_count; i++)
|
||||
for (uint64 i = 0; i < shm_ent_page_count; i++)
|
||||
{
|
||||
page_ptrs[i] = startptr + (i * os_page_size);
|
||||
|
||||
@@ -1210,7 +1209,7 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
|
||||
/* Count number of NUMA nodes used for this shared memory entry */
|
||||
memset(nodes, 0, sizeof(Size) * (max_nodes + 2));
|
||||
|
||||
for (i = 0; i < shm_ent_page_count; i++)
|
||||
for (uint64 i = 0; i < shm_ent_page_count; i++)
|
||||
{
|
||||
int s = pages_status[i];
|
||||
|
||||
@@ -1239,7 +1238,7 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
|
||||
* Add one entry for each NUMA node, including those without allocated
|
||||
* memory for this segment.
|
||||
*/
|
||||
for (i = 0; i <= max_nodes; i++)
|
||||
for (uint64 i = 0; i <= max_nodes; i++)
|
||||
{
|
||||
values[0] = CStringGetTextDatum(ent->key);
|
||||
values[1] = Int32GetDatum(i);
|
||||
|
||||
@@ -3122,7 +3122,6 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
|
||||
*/
|
||||
if (ConflictsWithRelationFastPath(locktag, lockmode))
|
||||
{
|
||||
int i;
|
||||
Oid relid = locktag->locktag_field2;
|
||||
VirtualTransactionId vxid;
|
||||
|
||||
@@ -3139,7 +3138,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
|
||||
* time we return the value and the time the caller does something
|
||||
* with it.
|
||||
*/
|
||||
for (i = 0; i < ProcGlobal->allProcCount; i++)
|
||||
for (uint32 i = 0; i < ProcGlobal->allProcCount; i++)
|
||||
{
|
||||
PGPROC *proc = GetPGProcByNumber(i);
|
||||
uint32 j;
|
||||
@@ -3780,7 +3779,6 @@ GetLockStatusData(void)
|
||||
HASH_SEQ_STATUS seqstat;
|
||||
int els;
|
||||
int el;
|
||||
int i;
|
||||
|
||||
data = palloc_object(LockData);
|
||||
|
||||
@@ -3801,7 +3799,7 @@ GetLockStatusData(void)
|
||||
* lockGroupLeader field without holding all lock partition locks, and
|
||||
* it's not worth that.)
|
||||
*/
|
||||
for (i = 0; i < ProcGlobal->allProcCount; ++i)
|
||||
for (uint32 i = 0; i < ProcGlobal->allProcCount; ++i)
|
||||
{
|
||||
PGPROC *proc = GetPGProcByNumber(i);
|
||||
|
||||
@@ -3900,7 +3898,7 @@ GetLockStatusData(void)
|
||||
*
|
||||
* Must grab LWLocks in partition-number order to avoid LWLock deadlock.
|
||||
*/
|
||||
for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
|
||||
for (int i = 0; i < NUM_LOCK_PARTITIONS; i++)
|
||||
LWLockAcquire(LockHashPartitionLockByIndex(i), LW_SHARED);
|
||||
|
||||
/* Now we can safely count the number of proclocks */
|
||||
@@ -3944,7 +3942,7 @@ GetLockStatusData(void)
|
||||
* until it can get all the locks it needs. (2) This avoids O(N^2)
|
||||
* behavior inside LWLockRelease.
|
||||
*/
|
||||
for (i = NUM_LOCK_PARTITIONS; --i >= 0;)
|
||||
for (int i = NUM_LOCK_PARTITIONS; --i >= 0;)
|
||||
LWLockRelease(LockHashPartitionLockByIndex(i));
|
||||
|
||||
Assert(el == data->nelements);
|
||||
|
||||
@@ -1988,7 +1988,6 @@ void
|
||||
NISortAffixes(IspellDict *Conf)
|
||||
{
|
||||
AFFIX *Affix;
|
||||
size_t i;
|
||||
CMPDAffix *ptr;
|
||||
int firstsuffix = Conf->naffixes;
|
||||
|
||||
@@ -2001,7 +2000,7 @@ NISortAffixes(IspellDict *Conf)
|
||||
Conf->CompoundAffix = ptr = palloc_array(CMPDAffix, Conf->naffixes);
|
||||
ptr->affix = NULL;
|
||||
|
||||
for (i = 0; i < Conf->naffixes; i++)
|
||||
for (int i = 0; i < Conf->naffixes; i++)
|
||||
{
|
||||
Affix = &(((AFFIX *) Conf->Affix)[i]);
|
||||
if (Affix->type == FF_SUFFIX && i < firstsuffix)
|
||||
|
||||
@@ -1676,7 +1676,7 @@ escape_json_with_len(StringInfo buf, const char *str, int len)
|
||||
* Per-byte loop for Vector8s containing special chars and for
|
||||
* processing the tail of the string.
|
||||
*/
|
||||
for (int b = 0; b < sizeof(Vector8); b++)
|
||||
for (size_t b = 0; b < sizeof(Vector8); b++)
|
||||
{
|
||||
/* check if we've finished */
|
||||
if (i == len)
|
||||
|
||||
@@ -819,7 +819,7 @@ pg_dependencies_out(PG_FUNCTION_ARGS)
|
||||
initStringInfo(&str);
|
||||
appendStringInfoChar(&str, '[');
|
||||
|
||||
for (int i = 0; i < dependencies->ndeps; i++)
|
||||
for (uint32 i = 0; i < dependencies->ndeps; i++)
|
||||
{
|
||||
MVDependency *dependency = dependencies->deps[i];
|
||||
|
||||
|
||||
@@ -1270,7 +1270,7 @@ get_collation_actual_version(char collprovider, const char *collcollate)
|
||||
static size_t
|
||||
strlower_c(char *dst, size_t dstsize, const char *src, size_t srclen)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < srclen && i < dstsize; i++)
|
||||
dst[i] = pg_ascii_tolower(src[i]);
|
||||
@@ -1284,7 +1284,7 @@ static size_t
|
||||
strtitle_c(char *dst, size_t dstsize, const char *src, size_t srclen)
|
||||
{
|
||||
bool wasalnum = false;
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < srclen && i < dstsize; i++)
|
||||
{
|
||||
@@ -1308,7 +1308,7 @@ strtitle_c(char *dst, size_t dstsize, const char *src, size_t srclen)
|
||||
static size_t
|
||||
strupper_c(char *dst, size_t dstsize, const char *src, size_t srclen)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < srclen && i < dstsize; i++)
|
||||
dst[i] = pg_ascii_toupper(src[i]);
|
||||
|
||||
@@ -712,7 +712,7 @@ static size_t
|
||||
downcase_ident_icu(char *dst, size_t dstsize, const char *src,
|
||||
size_t srclen, pg_locale_t locale)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
bool libc_lower;
|
||||
locale_t lt = locale->icu.lt;
|
||||
|
||||
|
||||
@@ -372,7 +372,7 @@ downcase_ident_libc_sb(char *dst, size_t dstsize, const char *src,
|
||||
size_t srclen, pg_locale_t locale)
|
||||
{
|
||||
locale_t loc = locale->lt;
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < srclen && i < dstsize; i++)
|
||||
{
|
||||
|
||||
@@ -793,13 +793,12 @@ pg_ndistinct_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bytea *data = PG_GETARG_BYTEA_PP(0);
|
||||
MVNDistinct *ndist = statext_ndistinct_deserialize(data);
|
||||
int i;
|
||||
StringInfoData str;
|
||||
|
||||
initStringInfo(&str);
|
||||
appendStringInfoChar(&str, '[');
|
||||
|
||||
for (i = 0; i < ndist->nitems; i++)
|
||||
for (uint32 i = 0; i < ndist->nitems; i++)
|
||||
{
|
||||
MVNDistinctItem item = ndist->items[i];
|
||||
|
||||
|
||||
@@ -4687,7 +4687,6 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
|
||||
*/
|
||||
if (stats)
|
||||
{
|
||||
int i;
|
||||
List *newlist = NIL;
|
||||
MVNDistinctItem *item = NULL;
|
||||
ListCell *lc2;
|
||||
@@ -4777,9 +4776,8 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
|
||||
}
|
||||
|
||||
/* Find the specific item that exactly matches the combination */
|
||||
for (i = 0; i < stats->nitems; i++)
|
||||
for (uint32 i = 0; i < stats->nitems; i++)
|
||||
{
|
||||
int j;
|
||||
MVNDistinctItem *tmpitem = &stats->items[i];
|
||||
|
||||
if (tmpitem->nattributes != bms_num_members(matched))
|
||||
@@ -4789,7 +4787,7 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
|
||||
item = tmpitem;
|
||||
|
||||
/* check that all item attributes/expressions fit the match */
|
||||
for (j = 0; j < tmpitem->nattributes; j++)
|
||||
for (int j = 0; j < tmpitem->nattributes; j++)
|
||||
{
|
||||
AttrNumber attnum = tmpitem->attributes[j];
|
||||
|
||||
|
||||
@@ -365,10 +365,9 @@ gtsvector_consistent(PG_FUNCTION_ARGS)
|
||||
static int32
|
||||
unionkey(BITVECP sbase, SignTSVector *add, int siglen)
|
||||
{
|
||||
int32 i;
|
||||
|
||||
if (ISSIGNKEY(add))
|
||||
{
|
||||
int32 i;
|
||||
BITVECP sadd = GETSIGN(add);
|
||||
|
||||
if (ISALLTRUE(add))
|
||||
@@ -383,7 +382,7 @@ unionkey(BITVECP sbase, SignTSVector *add, int siglen)
|
||||
{
|
||||
int32 *ptr = GETARR(add);
|
||||
|
||||
for (i = 0; i < ARRNELEM(add); i++)
|
||||
for (uint32 i = 0; i < ARRNELEM(add); i++)
|
||||
HASH(sbase, ptr[i], siglen);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1227,8 +1227,7 @@ tsqueryrecv(PG_FUNCTION_ARGS)
|
||||
{
|
||||
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
||||
TSQuery query;
|
||||
int i,
|
||||
len;
|
||||
int len;
|
||||
QueryItem *item;
|
||||
int datalen;
|
||||
char *ptr;
|
||||
@@ -1250,7 +1249,7 @@ tsqueryrecv(PG_FUNCTION_ARGS)
|
||||
item = GETQUERY(query);
|
||||
|
||||
datalen = 0;
|
||||
for (i = 0; i < size; i++)
|
||||
for (uint32 i = 0; i < size; i++)
|
||||
{
|
||||
item->type = (int8) pq_getmsgint(buf, sizeof(int8));
|
||||
|
||||
@@ -1335,7 +1334,7 @@ tsqueryrecv(PG_FUNCTION_ARGS)
|
||||
Assert(!needcleanup);
|
||||
|
||||
/* Copy operands to output struct */
|
||||
for (i = 0; i < size; i++)
|
||||
for (uint32 i = 0; i < size; i++)
|
||||
{
|
||||
if (item->type == QI_VAL)
|
||||
{
|
||||
|
||||
@@ -119,10 +119,9 @@ gtsquery_same(PG_FUNCTION_ARGS)
|
||||
static int
|
||||
sizebitvec(TSQuerySign sign)
|
||||
{
|
||||
int size = 0,
|
||||
i;
|
||||
int size = 0;
|
||||
|
||||
for (i = 0; i < TSQS_SIGLEN; i++)
|
||||
for (size_t i = 0; i < TSQS_SIGLEN; i++)
|
||||
size += 0x01 & (sign >> i);
|
||||
|
||||
return size;
|
||||
|
||||
@@ -1247,8 +1247,7 @@ bit_and(PG_FUNCTION_ARGS)
|
||||
VarBit *result;
|
||||
int len,
|
||||
bitlen1,
|
||||
bitlen2,
|
||||
i;
|
||||
bitlen2;
|
||||
uint8 *p1,
|
||||
*p2,
|
||||
*r;
|
||||
@@ -1268,7 +1267,7 @@ bit_and(PG_FUNCTION_ARGS)
|
||||
p1 = VARBITS(arg1);
|
||||
p2 = VARBITS(arg2);
|
||||
r = VARBITS(result);
|
||||
for (i = 0; i < VARBITBYTES(arg1); i++)
|
||||
for (size_t i = 0; i < VARBITBYTES(arg1); i++)
|
||||
*r++ = *p1++ & *p2++;
|
||||
|
||||
/* Padding is not needed as & of 0 pads is 0 */
|
||||
@@ -1288,8 +1287,7 @@ bit_or(PG_FUNCTION_ARGS)
|
||||
VarBit *result;
|
||||
int len,
|
||||
bitlen1,
|
||||
bitlen2,
|
||||
i;
|
||||
bitlen2;
|
||||
uint8 *p1,
|
||||
*p2,
|
||||
*r;
|
||||
@@ -1308,7 +1306,7 @@ bit_or(PG_FUNCTION_ARGS)
|
||||
p1 = VARBITS(arg1);
|
||||
p2 = VARBITS(arg2);
|
||||
r = VARBITS(result);
|
||||
for (i = 0; i < VARBITBYTES(arg1); i++)
|
||||
for (size_t i = 0; i < VARBITBYTES(arg1); i++)
|
||||
*r++ = *p1++ | *p2++;
|
||||
|
||||
/* Padding is not needed as | of 0 pads is 0 */
|
||||
@@ -1328,8 +1326,7 @@ bitxor(PG_FUNCTION_ARGS)
|
||||
VarBit *result;
|
||||
int len,
|
||||
bitlen1,
|
||||
bitlen2,
|
||||
i;
|
||||
bitlen2;
|
||||
uint8 *p1,
|
||||
*p2,
|
||||
*r;
|
||||
@@ -1349,7 +1346,7 @@ bitxor(PG_FUNCTION_ARGS)
|
||||
p1 = VARBITS(arg1);
|
||||
p2 = VARBITS(arg2);
|
||||
r = VARBITS(result);
|
||||
for (i = 0; i < VARBITBYTES(arg1); i++)
|
||||
for (size_t i = 0; i < VARBITBYTES(arg1); i++)
|
||||
*r++ = *p1++ ^ *p2++;
|
||||
|
||||
/* Padding is not needed as ^ of 0 pads is 0 */
|
||||
@@ -1701,7 +1698,6 @@ bitposition(PG_FUNCTION_ARGS)
|
||||
VarBit *substr = PG_GETARG_VARBIT_P(1);
|
||||
int substr_length,
|
||||
str_length,
|
||||
i,
|
||||
is;
|
||||
uint8 *s, /* pointer into substring */
|
||||
*p; /* pointer into str */
|
||||
@@ -1727,7 +1723,7 @@ bitposition(PG_FUNCTION_ARGS)
|
||||
/* Initialise the padding masks */
|
||||
end_mask = BITMASK << VARBITPAD(substr);
|
||||
str_mask = BITMASK << VARBITPAD(str);
|
||||
for (i = 0; i < VARBITBYTES(str) - VARBITBYTES(substr) + 1; i++)
|
||||
for (size_t i = 0; i < VARBITBYTES(str) - VARBITBYTES(substr) + 1; i++)
|
||||
{
|
||||
for (is = 0; is < BITS_PER_BYTE; is++)
|
||||
{
|
||||
|
||||
@@ -291,13 +291,12 @@ unsigned short
|
||||
BIG5toCNS(unsigned short big5, unsigned char *lc)
|
||||
{
|
||||
unsigned short cns = 0;
|
||||
int i;
|
||||
|
||||
if (big5 < 0xc940U)
|
||||
{
|
||||
/* level 1 */
|
||||
|
||||
for (i = 0; i < sizeof(b1c4) / (sizeof(unsigned short) * 2); i++)
|
||||
for (size_t i = 0; i < sizeof(b1c4) / (sizeof(unsigned short) * 2); i++)
|
||||
{
|
||||
if (b1c4[i][0] == big5)
|
||||
{
|
||||
@@ -318,7 +317,7 @@ BIG5toCNS(unsigned short big5, unsigned char *lc)
|
||||
else
|
||||
{
|
||||
/* level 2 */
|
||||
for (i = 0; i < sizeof(b2c3) / (sizeof(unsigned short) * 2); i++)
|
||||
for (size_t i = 0; i < sizeof(b2c3) / (sizeof(unsigned short) * 2); i++)
|
||||
{
|
||||
if (b2c3[i][0] == big5)
|
||||
{
|
||||
@@ -343,7 +342,6 @@ BIG5toCNS(unsigned short big5, unsigned char *lc)
|
||||
unsigned short
|
||||
CNStoBIG5(unsigned short cns, unsigned char lc)
|
||||
{
|
||||
int i;
|
||||
unsigned int big5 = 0;
|
||||
|
||||
cns &= 0x7f7f;
|
||||
@@ -357,14 +355,14 @@ CNStoBIG5(unsigned short cns, unsigned char lc)
|
||||
big5 = BinarySearchRange(cnsPlane2ToBig5Level2, 47, cns);
|
||||
break;
|
||||
case LC_CNS11643_3:
|
||||
for (i = 0; i < sizeof(b2c3) / (sizeof(unsigned short) * 2); i++)
|
||||
for (size_t i = 0; i < sizeof(b2c3) / (sizeof(unsigned short) * 2); i++)
|
||||
{
|
||||
if (b2c3[i][1] == cns)
|
||||
return b2c3[i][0];
|
||||
}
|
||||
break;
|
||||
case LC_CNS11643_4:
|
||||
for (i = 0; i < sizeof(b1c4) / (sizeof(unsigned short) * 2); i++)
|
||||
for (size_t i = 0; i < sizeof(b1c4) / (sizeof(unsigned short) * 2); i++)
|
||||
{
|
||||
if (b1c4[i][1] == cns)
|
||||
return b1c4[i][0];
|
||||
|
||||
@@ -292,7 +292,7 @@ InjectionPointAttach(const char *name,
|
||||
max_inuse = pg_atomic_read_u32(&ActiveInjectionPoints->max_inuse);
|
||||
free_idx = -1;
|
||||
|
||||
for (int idx = 0; idx < max_inuse; idx++)
|
||||
for (uint32 idx = 0; idx < max_inuse; idx++)
|
||||
{
|
||||
entry = &ActiveInjectionPoints->entries[idx];
|
||||
generation = pg_atomic_read_u64(&entry->generation);
|
||||
@@ -458,7 +458,7 @@ InjectionPointCacheRefresh(const char *name)
|
||||
* cases.
|
||||
*/
|
||||
namelen = strlen(name);
|
||||
for (int idx = 0; idx < max_inuse; idx++)
|
||||
for (uint32 idx = 0; idx < max_inuse; idx++)
|
||||
{
|
||||
InjectionPointEntry *entry = &ActiveInjectionPoints->entries[idx];
|
||||
uint64 generation;
|
||||
|
||||
@@ -26,13 +26,12 @@ pg_config(PG_FUNCTION_ARGS)
|
||||
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
||||
ConfigData *configdata;
|
||||
size_t configdata_len;
|
||||
int i = 0;
|
||||
|
||||
/* initialize our tuplestore */
|
||||
InitMaterializedSRF(fcinfo, 0);
|
||||
|
||||
configdata = get_configdata(my_exec_path, &configdata_len);
|
||||
for (i = 0; i < configdata_len; i++)
|
||||
for (size_t i = 0; i < configdata_len; i++)
|
||||
{
|
||||
Datum values[2];
|
||||
bool nulls[2];
|
||||
|
||||
@@ -620,7 +620,6 @@ void
|
||||
dsa_release_in_place(void *place)
|
||||
{
|
||||
dsa_area_control *control = (dsa_area_control *) place;
|
||||
int i;
|
||||
|
||||
LWLockAcquire(&control->lock, LW_EXCLUSIVE);
|
||||
Assert(control->segment_header.magic ==
|
||||
@@ -628,7 +627,7 @@ dsa_release_in_place(void *place)
|
||||
Assert(control->refcnt > 0);
|
||||
if (--control->refcnt == 0)
|
||||
{
|
||||
for (i = 0; i <= control->high_segment_index; ++i)
|
||||
for (dsa_segment_index i = 0; i <= control->high_segment_index; ++i)
|
||||
{
|
||||
dsm_handle handle;
|
||||
|
||||
@@ -649,13 +648,11 @@ dsa_release_in_place(void *place)
|
||||
void
|
||||
dsa_pin_mapping(dsa_area *area)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (area->resowner != NULL)
|
||||
{
|
||||
area->resowner = NULL;
|
||||
|
||||
for (i = 0; i <= area->high_segment_index; ++i)
|
||||
for (dsa_segment_index i = 0; i <= area->high_segment_index; ++i)
|
||||
if (area->segment_maps[i].segment != NULL)
|
||||
dsm_pin_mapping(area->segment_maps[i].segment);
|
||||
}
|
||||
@@ -1246,7 +1243,7 @@ size_t
|
||||
dsa_minimum_size(void)
|
||||
{
|
||||
size_t size;
|
||||
int pages = 0;
|
||||
size_t pages = 0;
|
||||
|
||||
size = MAXALIGN(sizeof(dsa_area_control)) +
|
||||
MAXALIGN(sizeof(FreePageManager));
|
||||
@@ -1277,7 +1274,6 @@ create_internal(void *place, size_t size,
|
||||
size_t usable_pages;
|
||||
size_t total_pages;
|
||||
size_t metadata_bytes;
|
||||
int i;
|
||||
|
||||
/* Check the initial and maximum block sizes */
|
||||
Assert(init_segment_size >= DSA_MIN_SEGMENT_SIZE);
|
||||
@@ -1320,7 +1316,7 @@ create_internal(void *place, size_t size,
|
||||
control->max_total_segment_size = (size_t) -1;
|
||||
control->total_segment_size = size;
|
||||
control->segment_handles[0] = control_handle;
|
||||
for (i = 0; i < DSA_NUM_SEGMENT_BINS; ++i)
|
||||
for (int i = 0; i < DSA_NUM_SEGMENT_BINS; ++i)
|
||||
control->segment_bins[i] = DSA_SEGMENT_INDEX_NONE;
|
||||
control->refcnt = 1;
|
||||
control->lwlock_tranche_id = tranche_id;
|
||||
@@ -1337,7 +1333,7 @@ create_internal(void *place, size_t size,
|
||||
area->high_segment_index = 0;
|
||||
area->freed_segment_counter = 0;
|
||||
LWLockInitialize(&control->lock, control->lwlock_tranche_id);
|
||||
for (i = 0; i < DSA_NUM_SIZE_CLASSES; ++i)
|
||||
for (size_t i = 0; i < DSA_NUM_SIZE_CLASSES; ++i)
|
||||
LWLockInitialize(DSA_SCLASS_LOCK(area, i),
|
||||
control->lwlock_tranche_id);
|
||||
|
||||
@@ -2001,10 +1997,8 @@ add_span_to_fullness_class(dsa_area *area, dsa_area_span *span,
|
||||
void
|
||||
dsa_detach(dsa_area *area)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Detach from all segments. */
|
||||
for (i = 0; i <= area->high_segment_index; ++i)
|
||||
for (dsa_segment_index i = 0; i <= area->high_segment_index; ++i)
|
||||
if (area->segment_maps[i].segment != NULL)
|
||||
dsm_detach(area->segment_maps[i].segment);
|
||||
|
||||
@@ -2367,13 +2361,12 @@ static void
|
||||
check_for_freed_segments_locked(dsa_area *area)
|
||||
{
|
||||
size_t freed_segment_counter;
|
||||
int i;
|
||||
|
||||
Assert(LWLockHeldByMe(DSA_AREA_LOCK(area)));
|
||||
freed_segment_counter = area->control->freed_segment_counter;
|
||||
if (unlikely(area->freed_segment_counter != freed_segment_counter))
|
||||
{
|
||||
for (i = 0; i <= area->high_segment_index; ++i)
|
||||
for (dsa_segment_index i = 0; i <= area->high_segment_index; ++i)
|
||||
{
|
||||
if (area->segment_maps[i].header != NULL &&
|
||||
area->segment_maps[i].header->freed)
|
||||
|
||||
@@ -304,7 +304,7 @@ ResourceOwnerSort(ResourceOwner owner)
|
||||
*/
|
||||
uint32 dst = 0;
|
||||
|
||||
for (int idx = 0; idx < owner->capacity; idx++)
|
||||
for (uint32 idx = 0; idx < owner->capacity; idx++)
|
||||
{
|
||||
if (owner->hash[idx].kind != NULL)
|
||||
{
|
||||
@@ -852,7 +852,7 @@ ResourceOwnerReleaseAllOfKind(ResourceOwner owner, const ResourceOwnerDesc *kind
|
||||
}
|
||||
|
||||
/* Then hash */
|
||||
for (int i = 0; i < owner->capacity; i++)
|
||||
for (uint32 i = 0; i < owner->capacity; i++)
|
||||
{
|
||||
if (owner->hash[i].kind == kind)
|
||||
{
|
||||
|
||||
@@ -1121,7 +1121,6 @@ ExportSnapshot(Snapshot snapshot)
|
||||
int addTopXid;
|
||||
StringInfoData buf;
|
||||
FILE *f;
|
||||
int i;
|
||||
MemoryContext oldcxt;
|
||||
char path[MAXPGPATH];
|
||||
char pathtmp[MAXPGPATH];
|
||||
@@ -1218,7 +1217,7 @@ ExportSnapshot(Snapshot snapshot)
|
||||
addTopXid = (TransactionIdIsValid(topXid) &&
|
||||
TransactionIdPrecedes(topXid, snapshot->xmax)) ? 1 : 0;
|
||||
appendStringInfo(&buf, "xcnt:%d\n", snapshot->xcnt + addTopXid);
|
||||
for (i = 0; i < snapshot->xcnt; i++)
|
||||
for (uint32 i = 0; i < snapshot->xcnt; i++)
|
||||
appendStringInfo(&buf, "xip:%u\n", snapshot->xip[i]);
|
||||
if (addTopXid)
|
||||
appendStringInfo(&buf, "xip:%u\n", topXid);
|
||||
@@ -1234,9 +1233,9 @@ ExportSnapshot(Snapshot snapshot)
|
||||
{
|
||||
appendStringInfoString(&buf, "sof:0\n");
|
||||
appendStringInfo(&buf, "sxcnt:%d\n", snapshot->subxcnt + nchildren);
|
||||
for (i = 0; i < snapshot->subxcnt; i++)
|
||||
for (int32 i = 0; i < snapshot->subxcnt; i++)
|
||||
appendStringInfo(&buf, "sxp:%u\n", snapshot->subxip[i]);
|
||||
for (i = 0; i < nchildren; i++)
|
||||
for (int32 i = 0; i < nchildren; i++)
|
||||
appendStringInfo(&buf, "sxp:%u\n", children[i]);
|
||||
}
|
||||
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
|
||||
|
||||
@@ -232,7 +232,6 @@ main(int argc, char *argv[])
|
||||
uint64 pageschecked = 0;
|
||||
uint64 pagestotal = 0;
|
||||
uint64 relprogress = 0;
|
||||
int pattern_id;
|
||||
|
||||
static struct option long_options[] = {
|
||||
/* Connection options */
|
||||
@@ -640,7 +639,7 @@ main(int argc, char *argv[])
|
||||
* Check that all inclusion patterns matched at least one schema or
|
||||
* relation that we can check.
|
||||
*/
|
||||
for (pattern_id = 0; pattern_id < opts.include.len; pattern_id++)
|
||||
for (size_t pattern_id = 0; pattern_id < opts.include.len; pattern_id++)
|
||||
{
|
||||
PatternInfo *pat = &opts.include.data[pattern_id];
|
||||
|
||||
@@ -1539,13 +1538,12 @@ static bool
|
||||
append_db_pattern_cte(PQExpBuffer buf, const PatternInfoArray *pia,
|
||||
PGconn *conn, bool inclusive)
|
||||
{
|
||||
int pattern_id;
|
||||
const char *comma;
|
||||
bool have_values;
|
||||
|
||||
comma = "";
|
||||
have_values = false;
|
||||
for (pattern_id = 0; pattern_id < pia->len; pattern_id++)
|
||||
for (size_t pattern_id = 0; pattern_id < pia->len; pattern_id++)
|
||||
{
|
||||
PatternInfo *info = &pia->data[pattern_id];
|
||||
|
||||
@@ -1555,7 +1553,7 @@ append_db_pattern_cte(PQExpBuffer buf, const PatternInfoArray *pia,
|
||||
if (!have_values)
|
||||
appendPQExpBufferStr(buf, "\nVALUES");
|
||||
have_values = true;
|
||||
appendPQExpBuffer(buf, "%s\n(%d, ", comma, pattern_id);
|
||||
appendPQExpBuffer(buf, "%s\n(%zu, ", comma, pattern_id);
|
||||
appendStringLiteralConn(buf, info->db_regex, conn);
|
||||
appendPQExpBufferChar(buf, ')');
|
||||
comma = ",";
|
||||
@@ -1777,20 +1775,19 @@ static void
|
||||
append_rel_pattern_raw_cte(PQExpBuffer buf, const PatternInfoArray *pia,
|
||||
PGconn *conn)
|
||||
{
|
||||
int pattern_id;
|
||||
const char *comma;
|
||||
bool have_values;
|
||||
|
||||
comma = "";
|
||||
have_values = false;
|
||||
for (pattern_id = 0; pattern_id < pia->len; pattern_id++)
|
||||
for (size_t pattern_id = 0; pattern_id < pia->len; pattern_id++)
|
||||
{
|
||||
PatternInfo *info = &pia->data[pattern_id];
|
||||
|
||||
if (!have_values)
|
||||
appendPQExpBufferStr(buf, "\nVALUES");
|
||||
have_values = true;
|
||||
appendPQExpBuffer(buf, "%s\n(%d::INTEGER, ", comma, pattern_id);
|
||||
appendPQExpBuffer(buf, "%s\n(%zu::INTEGER, ", comma, pattern_id);
|
||||
if (info->db_regex == NULL)
|
||||
appendPQExpBufferStr(buf, "NULL");
|
||||
else
|
||||
|
||||
@@ -223,7 +223,6 @@ StreamLogicalLog(void)
|
||||
PGresult *res;
|
||||
char *copybuf = NULL;
|
||||
TimestampTz last_status = -1;
|
||||
int i;
|
||||
PQExpBuffer query;
|
||||
XLogRecPtr cur_record_lsn;
|
||||
|
||||
@@ -256,7 +255,7 @@ StreamLogicalLog(void)
|
||||
if (noptions)
|
||||
appendPQExpBufferStr(query, " (");
|
||||
|
||||
for (i = 0; i < noptions; i++)
|
||||
for (size_t i = 0; i < noptions; i++)
|
||||
{
|
||||
/* separator */
|
||||
if (i > 0)
|
||||
|
||||
@@ -105,7 +105,6 @@ reconstruct_from_incremental_file(char *input_filename,
|
||||
rfile **sourcemap;
|
||||
off_t *offsetmap;
|
||||
unsigned block_length;
|
||||
unsigned i;
|
||||
unsigned sidx = n_prior_backups;
|
||||
bool full_copy_possible = true;
|
||||
int copy_source_index = -1;
|
||||
@@ -147,7 +146,7 @@ reconstruct_from_incremental_file(char *input_filename,
|
||||
* output but would not have needed to be found in an older backup if it
|
||||
* had not been present.
|
||||
*/
|
||||
for (i = 0; i < latest_source->num_blocks; ++i)
|
||||
for (unsigned i = 0; i < latest_source->num_blocks; ++i)
|
||||
{
|
||||
BlockNumber b = latest_source->relative_block_numbers[i];
|
||||
|
||||
@@ -261,7 +260,7 @@ reconstruct_from_incremental_file(char *input_filename,
|
||||
* Since we found another incremental file, source all blocks from it
|
||||
* that we need but don't yet have.
|
||||
*/
|
||||
for (i = 0; i < s->num_blocks; ++i)
|
||||
for (unsigned i = 0; i < s->num_blocks; ++i)
|
||||
{
|
||||
BlockNumber b = s->relative_block_numbers[i];
|
||||
|
||||
@@ -359,7 +358,7 @@ reconstruct_from_incremental_file(char *input_filename,
|
||||
/*
|
||||
* Close files and release memory.
|
||||
*/
|
||||
for (i = 0; i <= n_prior_backups; ++i)
|
||||
for (int i = 0; i <= n_prior_backups; ++i)
|
||||
{
|
||||
rfile *s = source[i];
|
||||
|
||||
@@ -383,9 +382,7 @@ reconstruct_from_incremental_file(char *input_filename,
|
||||
static void
|
||||
debug_reconstruction(int n_source, rfile **sources, bool dry_run)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < n_source; ++i)
|
||||
for (int i = 0; i < n_source; ++i)
|
||||
{
|
||||
rfile *s = sources[i];
|
||||
|
||||
|
||||
@@ -116,9 +116,7 @@ show_item(const char *configname,
|
||||
ConfigData *configdata,
|
||||
size_t configdata_len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < configdata_len; i++)
|
||||
for (size_t i = 0; i < configdata_len; i++)
|
||||
{
|
||||
if (strcmp(configname, configdata[i].name) == 0)
|
||||
printf("%s\n", configdata[i].setting);
|
||||
@@ -131,15 +129,13 @@ main(int argc, char **argv)
|
||||
ConfigData *configdata;
|
||||
size_t configdata_len;
|
||||
char my_exec_path[MAXPGPATH];
|
||||
int i;
|
||||
int j;
|
||||
|
||||
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_config"));
|
||||
|
||||
progname = get_progname(argv[0]);
|
||||
|
||||
/* check for --help */
|
||||
for (i = 1; i < argc; i++)
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0)
|
||||
{
|
||||
@@ -158,14 +154,16 @@ main(int argc, char **argv)
|
||||
/* no arguments -> print everything */
|
||||
if (argc < 2)
|
||||
{
|
||||
for (i = 0; i < configdata_len; i++)
|
||||
for (size_t i = 0; i < configdata_len; i++)
|
||||
printf("%s = %s\n", configdata[i].name, configdata[i].setting);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* otherwise print requested items */
|
||||
for (i = 1; i < argc; i++)
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; info_items[j].switchname != NULL; j++)
|
||||
{
|
||||
if (strcmp(argv[i], info_items[j].switchname) == 0)
|
||||
|
||||
@@ -1907,8 +1907,6 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
|
||||
static PTOKEN_PRIVILEGES
|
||||
GetPrivilegesToDelete(HANDLE hToken)
|
||||
{
|
||||
int i,
|
||||
j;
|
||||
DWORD length;
|
||||
PTOKEN_PRIVILEGES tokenPrivs;
|
||||
LUID luidLockPages;
|
||||
@@ -1946,12 +1944,12 @@ GetPrivilegesToDelete(HANDLE hToken)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < tokenPrivs->PrivilegeCount; i++)
|
||||
for (DWORD i = 0; i < tokenPrivs->PrivilegeCount; i++)
|
||||
{
|
||||
if (memcmp(&tokenPrivs->Privileges[i].Luid, &luidLockPages, sizeof(LUID)) == 0 ||
|
||||
memcmp(&tokenPrivs->Privileges[i].Luid, &luidChangeNotify, sizeof(LUID)) == 0)
|
||||
{
|
||||
for (j = i; j < tokenPrivs->PrivilegeCount - 1; j++)
|
||||
for (DWORD j = i; j < tokenPrivs->PrivilegeCount - 1; j++)
|
||||
tokenPrivs->Privileges[j] = tokenPrivs->Privileges[j + 1];
|
||||
tokenPrivs->PrivilegeCount--;
|
||||
}
|
||||
|
||||
@@ -981,7 +981,7 @@ generate_restrict_key(void)
|
||||
if (!pg_strong_random(buf, sizeof(buf)))
|
||||
return NULL;
|
||||
|
||||
for (int i = 0; i < sizeof(buf) - 1; i++)
|
||||
for (size_t i = 0; i < sizeof(buf) - 1; i++)
|
||||
{
|
||||
uint8 idx = buf[i] % strlen(restrict_chars);
|
||||
|
||||
|
||||
@@ -2058,13 +2058,11 @@ TocIDRequired(ArchiveHandle *AH, DumpId id)
|
||||
size_t
|
||||
WriteOffset(ArchiveHandle *AH, pgoff_t o, int wasSet)
|
||||
{
|
||||
int off;
|
||||
|
||||
/* Save the flag */
|
||||
AH->WriteBytePtr(AH, wasSet);
|
||||
|
||||
/* Write out pgoff_t smallest byte first, prevents endian mismatch */
|
||||
for (off = 0; off < sizeof(pgoff_t); off++)
|
||||
for (size_t off = 0; off < sizeof(pgoff_t); off++)
|
||||
{
|
||||
AH->WriteBytePtr(AH, o & 0xFF);
|
||||
o >>= 8;
|
||||
@@ -2076,7 +2074,6 @@ int
|
||||
ReadOffset(ArchiveHandle *AH, pgoff_t *o)
|
||||
{
|
||||
int i;
|
||||
int off;
|
||||
int offsetFlg;
|
||||
|
||||
/* Initialize to zero */
|
||||
@@ -2122,7 +2119,7 @@ ReadOffset(ArchiveHandle *AH, pgoff_t *o)
|
||||
/*
|
||||
* Read the bytes
|
||||
*/
|
||||
for (off = 0; off < AH->offSize; off++)
|
||||
for (size_t off = 0; off < AH->offSize; off++)
|
||||
{
|
||||
if (off < sizeof(pgoff_t))
|
||||
*o |= ((pgoff_t) (AH->ReadBytePtr(AH))) << (off * 8);
|
||||
@@ -2139,8 +2136,6 @@ ReadOffset(ArchiveHandle *AH, pgoff_t *o)
|
||||
size_t
|
||||
WriteInt(ArchiveHandle *AH, int i)
|
||||
{
|
||||
int b;
|
||||
|
||||
/*
|
||||
* This is a bit yucky, but I don't want to make the binary format very
|
||||
* dependent on representation, and not knowing much about it, I write out
|
||||
@@ -2158,7 +2153,7 @@ WriteInt(ArchiveHandle *AH, int i)
|
||||
else
|
||||
AH->WriteBytePtr(AH, 0);
|
||||
|
||||
for (b = 0; b < AH->intSize; b++)
|
||||
for (size_t b = 0; b < AH->intSize; b++)
|
||||
{
|
||||
AH->WriteBytePtr(AH, i & 0xFF);
|
||||
i >>= 8;
|
||||
@@ -2171,8 +2166,7 @@ int
|
||||
ReadInt(ArchiveHandle *AH)
|
||||
{
|
||||
int res = 0;
|
||||
int bv,
|
||||
b;
|
||||
int bv;
|
||||
int sign = 0; /* Default positive */
|
||||
int bitShift = 0;
|
||||
|
||||
@@ -2180,7 +2174,7 @@ ReadInt(ArchiveHandle *AH)
|
||||
/* Read a sign byte */
|
||||
sign = AH->ReadBytePtr(AH);
|
||||
|
||||
for (b = 0; b < AH->intSize; b++)
|
||||
for (size_t b = 0; b < AH->intSize; b++)
|
||||
{
|
||||
bv = AH->ReadBytePtr(AH) & 0xFF;
|
||||
if (bv != 0)
|
||||
|
||||
@@ -291,8 +291,7 @@ printCrosstab(const PGresult *result,
|
||||
{
|
||||
printQueryOpt popt = pset.popt;
|
||||
printTableContent cont;
|
||||
int i,
|
||||
rn;
|
||||
int rn;
|
||||
char col_align;
|
||||
int *horiz_map;
|
||||
Oid col_ftype = PQftype(result, field_for_columns);
|
||||
@@ -316,7 +315,7 @@ printCrosstab(const PGresult *result,
|
||||
* This avoids an O(N^2) loop later.
|
||||
*/
|
||||
horiz_map = pg_malloc_array(int, num_columns);
|
||||
for (i = 0; i < num_columns; i++)
|
||||
for (int i = 0; i < num_columns; i++)
|
||||
horiz_map[piv_columns[i].rank] = i;
|
||||
|
||||
/*
|
||||
@@ -324,7 +323,7 @@ printCrosstab(const PGresult *result,
|
||||
*/
|
||||
col_align = column_type_alignment(data_ftype);
|
||||
|
||||
for (i = 0; i < num_columns; i++)
|
||||
for (int i = 0; i < num_columns; i++)
|
||||
{
|
||||
char *colname;
|
||||
|
||||
@@ -335,7 +334,7 @@ printCrosstab(const PGresult *result,
|
||||
pg_free(horiz_map);
|
||||
|
||||
/* Step 2: set row names in the first output column (vertical header) */
|
||||
for (i = 0; i < num_rows; i++)
|
||||
for (int i = 0; i < num_rows; i++)
|
||||
{
|
||||
int k = piv_rows[i].rank;
|
||||
int idx = k * (num_columns + 1);
|
||||
@@ -414,7 +413,7 @@ printCrosstab(const PGresult *result,
|
||||
* The non-initialized cells must be set to an empty string for the print
|
||||
* functions
|
||||
*/
|
||||
for (i = 0; i < cont.cellsadded; i++)
|
||||
for (uint64 i = 0; i < cont.cellsadded; i++)
|
||||
{
|
||||
if (cont.cells[i] == NULL)
|
||||
cont.cells[i] = "";
|
||||
|
||||
@@ -137,7 +137,6 @@ pg_hmac_create(pg_cryptohash_type type)
|
||||
int
|
||||
pg_hmac_init(pg_hmac_ctx *ctx, const uint8 *key, size_t len)
|
||||
{
|
||||
int i;
|
||||
int digest_size;
|
||||
int block_size;
|
||||
uint8 *shrinkbuf = NULL;
|
||||
@@ -192,7 +191,7 @@ pg_hmac_init(pg_hmac_ctx *ctx, const uint8 *key, size_t len)
|
||||
pg_cryptohash_free(hash_ctx);
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
ctx->k_ipad[i] ^= key[i];
|
||||
ctx->k_opad[i] ^= key[i];
|
||||
|
||||
@@ -342,7 +342,7 @@ check_final_sigma(const unsigned char *str, size_t len, size_t offset)
|
||||
int ulen;
|
||||
|
||||
/* iterate backwards looking for preceding character */
|
||||
for (int i = offset; i > 0;)
|
||||
for (size_t i = offset; i > 0;)
|
||||
{
|
||||
/* skip backwards through continuation bytes */
|
||||
i--;
|
||||
@@ -370,7 +370,7 @@ check_final_sigma(const unsigned char *str, size_t len, size_t offset)
|
||||
ulen = utf8_mblen((const unsigned char *) str + offset);
|
||||
|
||||
/* iterate forward looking for following character */
|
||||
for (int i = offset + ulen; i < len;)
|
||||
for (size_t i = offset + ulen; i < len;)
|
||||
{
|
||||
ulen = utf8_mblen((const unsigned char *) str + i);
|
||||
|
||||
|
||||
@@ -1569,8 +1569,8 @@ print_aligned_vertical(const printTableContent *cont,
|
||||
if (cont->opt->format == PRINT_WRAPPED && cont->ncolumns > 0)
|
||||
{
|
||||
width_wrap = pg_malloc_array(unsigned int, cont->ncolumns);
|
||||
for (i = 0; i < cont->ncolumns; i++)
|
||||
width_wrap[i] = dwidth;
|
||||
for (int j = 0; j < cont->ncolumns; j++)
|
||||
width_wrap[j] = dwidth;
|
||||
}
|
||||
|
||||
IsPagerNeeded(cont, width_wrap, true, &fout, &is_pager);
|
||||
|
||||
@@ -585,13 +585,13 @@ typedef struct RT_NODE_256
|
||||
*/
|
||||
|
||||
#if SIZEOF_DSA_POINTER < 8
|
||||
#define RT_FANOUT_16_LO ((96 - offsetof(RT_NODE_16, children)) / sizeof(RT_PTR_ALLOC))
|
||||
#define RT_FANOUT_16_HI Min(RT_FANOUT_16_MAX, (160 - offsetof(RT_NODE_16, children)) / sizeof(RT_PTR_ALLOC))
|
||||
#define RT_FANOUT_48 Min(RT_FANOUT_48_MAX, (512 - offsetof(RT_NODE_48, children)) / sizeof(RT_PTR_ALLOC))
|
||||
#define RT_FANOUT_16_LO ((int) ((96 - offsetof(RT_NODE_16, children)) / sizeof(RT_PTR_ALLOC)))
|
||||
#define RT_FANOUT_16_HI ((int) Min(RT_FANOUT_16_MAX, (160 - offsetof(RT_NODE_16, children)) / sizeof(RT_PTR_ALLOC)))
|
||||
#define RT_FANOUT_48 ((int) Min(RT_FANOUT_48_MAX, (512 - offsetof(RT_NODE_48, children)) / sizeof(RT_PTR_ALLOC)))
|
||||
#else
|
||||
#define RT_FANOUT_16_LO ((160 - offsetof(RT_NODE_16, children)) / sizeof(RT_PTR_ALLOC))
|
||||
#define RT_FANOUT_16_HI Min(RT_FANOUT_16_MAX, (320 - offsetof(RT_NODE_16, children)) / sizeof(RT_PTR_ALLOC))
|
||||
#define RT_FANOUT_48 Min(RT_FANOUT_48_MAX, (768 - offsetof(RT_NODE_48, children)) / sizeof(RT_PTR_ALLOC))
|
||||
#define RT_FANOUT_16_LO ((int) ((160 - offsetof(RT_NODE_16, children)) / sizeof(RT_PTR_ALLOC)))
|
||||
#define RT_FANOUT_16_HI ((int) Min(RT_FANOUT_16_MAX, (320 - offsetof(RT_NODE_16, children)) / sizeof(RT_PTR_ALLOC)))
|
||||
#define RT_FANOUT_48 ((int) Min(RT_FANOUT_48_MAX, (768 - offsetof(RT_NODE_48, children)) / sizeof(RT_PTR_ALLOC)))
|
||||
#endif /* SIZEOF_DSA_POINTER < 8 */
|
||||
|
||||
#else /* ! RT_SHMEM */
|
||||
@@ -675,7 +675,7 @@ static const RT_SIZE_CLASS_ELEM RT_SIZE_CLASS_INFO[] = {
|
||||
},
|
||||
};
|
||||
|
||||
#define RT_NUM_SIZE_CLASSES lengthof(RT_SIZE_CLASS_INFO)
|
||||
#define RT_NUM_SIZE_CLASSES ((int) lengthof(RT_SIZE_CLASS_INFO))
|
||||
|
||||
#ifdef RT_SHMEM
|
||||
/* A magic value used to identify our radix tree */
|
||||
|
||||
@@ -414,8 +414,8 @@ if (sqlca.sqlcode < 0) sqlprint();}
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 114 "sqljson.pgc"
|
||||
|
||||
for (int i = 0; i < sizeof(is_json); i++)
|
||||
printf("Found is_json[%d]: %s\n", i, is_json[i] ? "true" : "false");
|
||||
for (size_t i = 0; i < sizeof(is_json); i++)
|
||||
printf("Found is_json[%zu]: %s\n", i, is_json[i] ? "true" : "false");
|
||||
|
||||
{ ECPGdisconnect(__LINE__, "CURRENT");
|
||||
#line 118 "sqljson.pgc"
|
||||
|
||||
@@ -112,8 +112,8 @@ EXEC SQL END DECLARE SECTION;
|
||||
INTO :is_json[0], :is_json[1], :is_json[2], :is_json[3], :is_json[4],
|
||||
:is_json[5], :is_json[6], :is_json[7]
|
||||
FROM val;
|
||||
for (int i = 0; i < sizeof(is_json); i++)
|
||||
printf("Found is_json[%d]: %s\n", i, is_json[i] ? "true" : "false");
|
||||
for (size_t i = 0; i < sizeof(is_json); i++)
|
||||
printf("Found is_json[%zu]: %s\n", i, is_json[i] ? "true" : "false");
|
||||
|
||||
EXEC SQL DISCONNECT;
|
||||
|
||||
|
||||
@@ -1704,7 +1704,7 @@ debug_callback(CURL *handle, curl_infotype type, char *data, size_t size,
|
||||
* are included in a single call. We also don't allow unprintable ASCII
|
||||
* through without a basic <XX> escape.
|
||||
*/
|
||||
for (int i = 0; i < size; i++)
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
char c = data[i];
|
||||
|
||||
|
||||
@@ -5517,10 +5517,10 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
|
||||
int port = LDAP_DEF_PORT,
|
||||
scope,
|
||||
rc,
|
||||
size,
|
||||
state,
|
||||
oldstate,
|
||||
i;
|
||||
size_t size;
|
||||
#ifndef WIN32
|
||||
int msgid;
|
||||
#endif
|
||||
|
||||
@@ -277,11 +277,10 @@ const char *
|
||||
winsock_strerror(int err, char *strerrbuf, size_t buflen)
|
||||
{
|
||||
unsigned long flags;
|
||||
int offs,
|
||||
i;
|
||||
int offs;
|
||||
int success = LookupWSErrorMessage(err, strerrbuf);
|
||||
|
||||
for (i = 0; !success && i < DLLS_SIZE; i++)
|
||||
for (size_t i = 0; !success && i < DLLS_SIZE; i++)
|
||||
{
|
||||
|
||||
if (!dlls[i].loaded)
|
||||
|
||||
@@ -564,7 +564,7 @@ evict_rel(PG_FUNCTION_ARGS)
|
||||
|
||||
nblocks = smgrnblocks(smgr, forknum);
|
||||
|
||||
for (int blkno = 0; blkno < nblocks; blkno++)
|
||||
for (BlockNumber blkno = 0; blkno < nblocks; blkno++)
|
||||
{
|
||||
invalidate_one_block(rel, forknum, blkno);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ test_binaryheap(PG_FUNCTION_ARGS)
|
||||
{
|
||||
static const int test_sizes[] = {1, 2, 3, 10, 100, 1000};
|
||||
|
||||
for (int i = 0; i < sizeof(test_sizes) / sizeof(int); i++)
|
||||
for (size_t i = 0; i < sizeof(test_sizes) / sizeof(int); i++)
|
||||
{
|
||||
int size = test_sizes[i];
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ escape_replace(PGconn *conn, PQExpBuffer target,
|
||||
|
||||
appendPQExpBufferChar(target, '\'');
|
||||
|
||||
for (int i = 0; i < unescaped_len; i++)
|
||||
for (size_t i = 0; i < unescaped_len; i++)
|
||||
{
|
||||
char c = *s;
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ test_pattern(const test_spec *spec)
|
||||
{
|
||||
uint64 x = 0;
|
||||
|
||||
for (int i = 0; i < pattern_num_values && n < spec->num_values; i++)
|
||||
for (uint64 i = 0; i < pattern_num_values && n < spec->num_values; i++)
|
||||
{
|
||||
x = last_int + pattern_values[i];
|
||||
|
||||
@@ -283,7 +283,7 @@ test_pattern(const test_spec *spec)
|
||||
last_int = 0;
|
||||
while (n < spec->num_values)
|
||||
{
|
||||
for (int i = 0; i < pattern_num_values && n < spec->num_values; i++)
|
||||
for (uint64 i = 0; i < pattern_num_values && n < spec->num_values; i++)
|
||||
{
|
||||
uint64 expected = last_int + pattern_values[i];
|
||||
uint64 x;
|
||||
|
||||
@@ -51,7 +51,6 @@ test_predtest(PG_FUNCTION_ARGS)
|
||||
weak_refuted_by;
|
||||
Datum values[8];
|
||||
bool nulls[8] = {0};
|
||||
int i;
|
||||
|
||||
/* We use SPI to parse, plan, and execute the test query */
|
||||
SPI_connect();
|
||||
@@ -76,7 +75,7 @@ test_predtest(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "test_predtest query must yield two boolean columns");
|
||||
|
||||
s_i_holds = w_i_holds = s_r_holds = w_r_holds = true;
|
||||
for (i = 0; i < SPI_processed; i++)
|
||||
for (uint64 i = 0; i < SPI_processed; i++)
|
||||
{
|
||||
HeapTuple tup = SPI_tuptable->vals[i];
|
||||
Datum dat;
|
||||
|
||||
@@ -320,7 +320,7 @@ test_random(void)
|
||||
/* add some random values */
|
||||
pg_prng_seed(&state, seed);
|
||||
keys = (TestValueType *) palloc(sizeof(uint64) * num_keys);
|
||||
for (uint64 i = 0; i < num_keys; i++)
|
||||
for (int i = 0; i < num_keys; i++)
|
||||
{
|
||||
uint64 key = pg_prng_uint64(&state) & filter;
|
||||
TestValueType val = (TestValueType) key;
|
||||
@@ -333,7 +333,7 @@ test_random(void)
|
||||
|
||||
rt_stats(radixtree);
|
||||
|
||||
for (uint64 i = 0; i < num_keys; i++)
|
||||
for (int i = 0; i < num_keys; i++)
|
||||
{
|
||||
TestValueType *value;
|
||||
|
||||
@@ -348,7 +348,7 @@ test_random(void)
|
||||
qsort(keys, num_keys, sizeof(uint64), key_cmp);
|
||||
|
||||
/* should not find numbers in between the keys */
|
||||
for (uint64 i = 0; i < num_keys - 1; i++)
|
||||
for (int i = 0; i < num_keys - 1; i++)
|
||||
{
|
||||
TestValueType *value;
|
||||
|
||||
@@ -410,7 +410,7 @@ test_random(void)
|
||||
pg_prng_seed(&state, seed);
|
||||
|
||||
/* delete in original random order */
|
||||
for (uint64 i = 0; i < num_keys; i++)
|
||||
for (int i = 0; i < num_keys; i++)
|
||||
{
|
||||
uint64 key = pg_prng_uint64(&state) & filter;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user