StringInfoData sinfo;
Page page;
FSMPage fsmpage;
- int i;
if (!superuser())
ereport(ERROR,
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);
int32 bitmappage,
bitmapbit;
HeapTuple tuple;
- int i,
- j;
+ int j;
Datum values[3];
bool nulls[3] = {0};
uint32 *freep;
(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),
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,
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,
{
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];
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
* 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;
* 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]);
{
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];
/* 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;
static int32
unionkey(BITVECP sbase, TRGM *add, int siglen)
{
- int32 i;
-
if (ISSIGNKEY(add))
{
+ int32 i;
BITVECP sadd = GETSIGN(add);
if (ISALLTRUE(add))
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);
startScanKey(GinState *ginstate, GinScanOpaque so, GinScanKey key)
{
MemoryContext oldCtx = CurrentMemoryContext;
- int i;
- int j;
int *entryIndexes;
ItemPointerSetMin(&key->curItem);
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);
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);
{
ItemPointerData minItem;
ItemPointerData curPageLossy;
- uint32 i;
bool haveLossyEntry;
GinScanEntry entry;
GinTernaryValue res;
*/
ItemPointerSetMax(&minItem);
allFinished = true;
- for (i = 0; i < key->nrequired; i++)
+ for (int i = 0; i < key->nrequired; i++)
{
entry = key->requiredEntries[i];
* 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];
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 &&
*
* 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)
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;
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,
* 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;
MemoryContext oldCtx;
bool recheck,
match;
- int i;
pendingPosition pos;
Buffer metabuffer = ReadBuffer(scan->indexRelation, GIN_METAPAGE_BLKNO);
Page page;
recheck = false;
match = true;
- for (i = 0; i < so->nkeys; i++)
+ for (uint32 i = 0; i < so->nkeys; i++)
{
GinScanKey key = so->keys + i;
shimTriConsistentFn(GinScanKey key)
{
int nmaybe;
- int maybeEntries[MAX_MAYBE_ENTRIES];
- int i;
+ uint32 maybeEntries[MAX_MAYBE_ENTRIES];
bool boolResult;
bool recheck;
GinTernaryValue curResult;
* 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)
{
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++)
{
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;
{
ScanKey scankey = scan->keyData;
GinScanOpaque so = (GinScanOpaque) scan->opaque;
- int i;
int numExcludeOnly;
bool hasNullQuery = false;
bool attrHasNormalScan[INDEX_MAX_KEYS] = {false};
so->isVoidRes = false;
- for (i = 0; i < scan->numberOfKeys; i++)
+ for (int i = 0; i < scan->numberOfKeys; i++)
{
ScanKey skey = &scankey[i];
Datum *queryValues;
* 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];
/* 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];
*/
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;
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 = " ";
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];
/* 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);
}
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);
{
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]);
}
/* 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++;
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 */
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;
* 2*FD_SETSIZE sockets */
SOCKET sockets[FD_SETSIZE * 2];
int numevents = 0;
- int i;
int r;
DWORD timeoutval = WSA_INFINITE;
FD_SET outreadfds;
*/
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;
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];
}
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))
}
}
- for (i = 0; i < numevents; i++)
+ for (int i = 0; i < numevents; i++)
{
int flags = 0;
*/
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)
}
/* 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]);
Size nr_txns = 0;
ReorderBufferIterTXNState *state;
dlist_iter cur_txn_i;
- int32 off;
+ Size off;
*iter_state = NULL;
ReorderBufferIterTXNFinish(ReorderBuffer *rb,
ReorderBufferIterTXNState *state)
{
- int32 off;
+ Size off;
for (off = 0; off < state->nr_txns; off++)
{
bool use_subtxn = IsTransactionOrTransactionBlock();
MemoryContext ccxt = CurrentMemoryContext;
ResourceOwner cowner = CurrentResourceOwner;
- int i;
if (use_subtxn)
BeginInternalSubTransaction("replay");
if (use_subtxn)
AbortCurrentTransaction();
- for (i = 0; i < ninvalidations; i++)
+ for (uint32 i = 0; i < ninvalidations; i++)
LocalExecuteInvalidationMessage(&invalidations[i]);
if (use_subtxn)
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]);
}
static void
SnapBuildPurgeOlderTxn(SnapBuild *builder)
{
- int off;
TransactionId *workspace;
int surviving_xids = 0;
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))
*/
if (builder->catchange.xcnt > 0)
{
+ size_t off;
+
/*
* Since catchange.xip is sorted, we find the lower bound of xids that
* are still interesting.
bytea *
statext_dependencies_serialize(MVDependencies *dependencies)
{
- int i;
bytea *output;
char *tmp;
Size len;
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);
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];
MVDependencies *
statext_dependencies_deserialize(bytea *data)
{
- int i;
Size min_expected_size;
MVDependencies *dependencies;
char *tmp;
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;
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);
}
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];
find_strongest_dependency(MVDependencies **dependencies, int ndependencies,
Bitmapset *attnums)
{
- int i,
- j;
MVDependency *strongest = NULL;
/* number of attnums in clauses */
* 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];
int total_ndeps;
MVDependency **dependencies;
int ndependencies;
- int i;
AttrNumber attnum_offset;
RangeTblEntry *rte = planner_rt_fetch(rel->relid, 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))
{
* 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;
/* count matching expressions */
nexprs = 0;
- for (i = 0; i < unique_exprs_cnt; i++)
+ for (int i = 0; i < unique_exprs_cnt; i++)
{
ListCell *lc;
*/
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;
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);
bytea *
statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats)
{
- int i;
int dim;
int ndims = mcvlist->ndimensions;
/* 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])
* 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);
{
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;
{
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;
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;
/*
/* 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];
}
/* 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];
* 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];
* 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;
* 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];
{
/* AND/OR clause, with all subclauses being compatible */
- int i;
BoolExpr *bool_clause = ((BoolExpr *) clause);
List *bool_clauses = bool_clause->args;
* 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);
{
/* NOT clause, with all subclauses compatible */
- int i;
BoolExpr *not_clause = ((BoolExpr *) clause);
List *not_args = not_clause->args;
* 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);
* 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;
* 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];
RelOptInfo *rel,
Selectivity *basesel, Selectivity *totalsel)
{
- int i;
MCVList *mcv;
Selectivity s = 0.0;
RangeTblEntry *rte = root->simple_rte_array[rel->relid];
/* 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;
{
Selectivity s = 0.0;
bool *new_matches;
- int i;
/* build the OR-matches bitmap, if not built already */
if (*or_matches == NULL)
*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;
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];
{
MVNDistinct *result;
int k;
- int itemcnt;
+ uint32 itemcnt;
int numattrs = data->nattnums;
int numcombs = num_combinations(numattrs);
bytea *
statext_ndistinct_serialize(MVNDistinct *ndistinct)
{
- int i;
bytea *output;
char *tmp;
Size len;
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;
/*
* 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;
MVNDistinct *
statext_ndistinct_deserialize(bytea *data)
{
- int i;
Size minimum_size;
MVNDistinct ndist;
MVNDistinct *ndistinct;
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];
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);
}
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];
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];
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);
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)
{
/* output all allocated entries */
while ((ent = (ShmemIndexEnt *) hash_seq_search(&hstat)) != NULL)
{
- int i;
char *startptr,
*endptr;
Size total_len;
* 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);
/* 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];
* 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);
*/
if (ConflictsWithRelationFastPath(locktag, lockmode))
{
- int i;
Oid relid = locktag->locktag_field2;
VirtualTransactionId vxid;
* 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;
HASH_SEQ_STATUS seqstat;
int els;
int el;
- int i;
data = palloc_object(LockData);
* 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);
*
* 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 */
* 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);
NISortAffixes(IspellDict *Conf)
{
AFFIX *Affix;
- size_t i;
CMPDAffix *ptr;
int firstsuffix = Conf->naffixes;
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)
* 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)
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];
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]);
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++)
{
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]);
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;
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++)
{
{
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];
*/
if (stats)
{
- int i;
List *newlist = NIL;
MVNDistinctItem *item = NULL;
ListCell *lc2;
}
/* 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))
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];
static int32
unionkey(BITVECP sbase, SignTSVector *add, int siglen)
{
- int32 i;
-
if (ISSIGNKEY(add))
{
+ int32 i;
BITVECP sadd = GETSIGN(add);
if (ISALLTRUE(add))
{
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;
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
TSQuery query;
- int i,
- len;
+ int len;
QueryItem *item;
int datalen;
char *ptr;
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));
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)
{
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;
VarBit *result;
int len,
bitlen1,
- bitlen2,
- i;
+ bitlen2;
uint8 *p1,
*p2,
*r;
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 */
VarBit *result;
int len,
bitlen1,
- bitlen2,
- i;
+ bitlen2;
uint8 *p1,
*p2,
*r;
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 */
VarBit *result;
int len,
bitlen1,
- bitlen2,
- i;
+ bitlen2;
uint8 *p1,
*p2,
*r;
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 */
VarBit *substr = PG_GETARG_VARBIT_P(1);
int substr_length,
str_length,
- i,
is;
uint8 *s, /* pointer into substring */
*p; /* pointer into str */
/* 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++)
{
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)
{
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)
{
unsigned short
CNStoBIG5(unsigned short cns, unsigned char lc)
{
- int i;
unsigned int big5 = 0;
cns &= 0x7f7f;
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];
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);
* 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;
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];
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 ==
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;
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);
}
dsa_minimum_size(void)
{
size_t size;
- int pages = 0;
+ size_t pages = 0;
size = MAXALIGN(sizeof(dsa_area_control)) +
MAXALIGN(sizeof(FreePageManager));
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);
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;
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);
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);
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)
*/
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)
{
}
/* Then hash */
- for (int i = 0; i < owner->capacity; i++)
+ for (uint32 i = 0; i < owner->capacity; i++)
{
if (owner->hash[i].kind == kind)
{
int addTopXid;
StringInfoData buf;
FILE *f;
- int i;
MemoryContext oldcxt;
char path[MAXPGPATH];
char pathtmp[MAXPGPATH];
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);
{
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);
uint64 pageschecked = 0;
uint64 pagestotal = 0;
uint64 relprogress = 0;
- int pattern_id;
static struct option long_options[] = {
/* Connection options */
* 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];
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];
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 = ",";
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
PGresult *res;
char *copybuf = NULL;
TimestampTz last_status = -1;
- int i;
PQExpBuffer query;
XLogRecPtr cur_record_lsn;
if (noptions)
appendPQExpBufferStr(query, " (");
- for (i = 0; i < noptions; i++)
+ for (size_t i = 0; i < noptions; i++)
{
/* separator */
if (i > 0)
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;
* 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];
* 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];
/*
* 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];
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];
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);
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)
{
/* 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)
static PTOKEN_PRIVILEGES
GetPrivilegesToDelete(HANDLE hToken)
{
- int i,
- j;
DWORD length;
PTOKEN_PRIVILEGES tokenPrivs;
LUID luidLockPages;
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--;
}
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);
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;
ReadOffset(ArchiveHandle *AH, pgoff_t *o)
{
int i;
- int off;
int offsetFlg;
/* Initialize to zero */
/*
* 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);
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
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;
ReadInt(ArchiveHandle *AH)
{
int res = 0;
- int bv,
- b;
+ int bv;
int sign = 0; /* Default positive */
int bitShift = 0;
/* 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)
{
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);
* 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;
/*
*/
col_align = column_type_alignment(data_ftype);
- for (i = 0; i < num_columns; i++)
+ for (int i = 0; i < num_columns; i++)
{
char *colname;
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);
* 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] = "";
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;
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];
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--;
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);
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);
*/
#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 */
},
};
-#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 */
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"
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;
* 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];
int port = LDAP_DEF_PORT,
scope,
rc,
- size,
state,
oldstate,
i;
+ size_t size;
#ifndef WIN32
int msgid;
#endif
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)
nblocks = smgrnblocks(smgr, forknum);
- for (int blkno = 0; blkno < nblocks; blkno++)
+ for (BlockNumber blkno = 0; blkno < nblocks; blkno++)
{
invalidate_one_block(rel, forknum, blkno);
}
{
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];
appendPQExpBufferChar(target, '\'');
- for (int i = 0; i < unescaped_len; i++)
+ for (size_t i = 0; i < unescaped_len; i++)
{
char c = *s;
{
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];
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;
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();
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;
/* 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;
rt_stats(radixtree);
- for (uint64 i = 0; i < num_keys; i++)
+ for (int i = 0; i < num_keys; i++)
{
TestValueType *value;
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;
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;