};
int nestlevel = -1;
- int i;
- for (i = 0; i < lengthof(GUCsAffectingIO); i++)
+ for (size_t i = 0; i < lengthof(GUCsAffectingIO); i++)
{
const char *gucName = GUCsAffectingIO[i];
const char *remoteVal = PQparameterStatus(conn, gucName);
StaticAssertDecl(sizeof(TM_IndexDelete) <= 8,
"element size exceeds 8 bytes");
- for (int g = 0; g < lengthof(gaps); g++)
+ for (size_t g = 0; g < lengthof(gaps); g++)
{
for (int hi = gaps[g], i = hi; i < ndeltids; i++)
{
*/
if (strcmp(libraryname, "postgres") == 0)
{
- int i;
-
- for (i = 0; i < lengthof(InternalParallelWorkers); i++)
+ for (size_t i = 0; i < lengthof(InternalParallelWorkers); i++)
{
if (strcmp(InternalParallelWorkers[i].fn_name, funcname) == 0)
return InternalParallelWorkers[i].fn_addr;
Oid
boot_get_role_oid(const char *rolname)
{
- for (int i = 0; i < lengthof(RolInfo); i++)
+ for (size_t i = 0; i < lengthof(RolInfo); i++)
{
if (strcmp(RolInfo[i].rolname, rolname) == 0)
return RolInfo[i].oid;
int
read_objtype_from_string(const char *objtype)
{
- int i;
-
- for (i = 0; i < lengthof(ObjectTypeMap); i++)
+ for (size_t i = 0; i < lengthof(ObjectTypeMap); i++)
{
if (strcmp(ObjectTypeMap[i].tm_name, objtype) == 0)
return ObjectTypeMap[i].tm_type;
bool
is_objectclass_supported(Oid class_id)
{
- int index;
-
- for (index = 0; index < lengthof(ObjectProperty); index++)
+ for (size_t index = 0; index < lengthof(ObjectProperty); index++)
{
if (ObjectProperty[index].class_oid == class_id)
return true;
get_object_property_data(Oid class_id)
{
static const ObjectPropertyType *prop_last = NULL;
- int index;
/*
* A shortcut to speed up multiple consecutive lookups of a particular
if (prop_last && prop_last->class_oid == class_id)
return prop_last;
- for (index = 0; index < lengthof(ObjectProperty); index++)
+ for (size_t index = 0; index < lengthof(ObjectProperty); index++)
{
if (ObjectProperty[index].class_oid == class_id)
{
Oid constructorArgTypes[3];
ObjectAddress myself,
referenced;
- int i;
constructorArgTypes[0] = subtype;
constructorArgTypes[1] = subtype;
referenced.objectId = rangeOid;
referenced.objectSubId = 0;
- for (i = 0; i < lengthof(prosrc); i++)
+ for (size_t i = 0; i < lengthof(prosrc); i++)
{
oidvector *constructorArgTypesVector;
DispatchOption
parse_dispatch_option(const char *name)
{
- for (int i = 0; i < lengthof(DispatchOptionNames); i++)
+ for (size_t i = 0; i < lengthof(DispatchOptionNames); i++)
{
/*
* Unlike the other dispatch options, "forkchild" takes an argument,
*/
if (strcmp(libraryname, "postgres") == 0)
{
- int i;
-
- for (i = 0; i < lengthof(InternalBGWorkers); i++)
+ for (size_t i = 0; i < lengthof(InternalBGWorkers); i++)
{
if (strcmp(InternalBGWorkers[i].fn_name, funcname) == 0)
return InternalBGWorkers[i].fn_addr;
* a condition would be a grave programmer error as the states are a
* discrete set.
*/
- for (int i = 0; i < lengthof(checksum_barriers) && !found; i++)
+ for (size_t i = 0; i < lengthof(checksum_barriers) && !found; i++)
{
if (checksum_barriers[i].from == current && checksum_barriers[i].to == target_state)
found = true;
int64 vals[lengthof(index)];
- for (int i = 0; i < lengthof(index); i++)
+ for (size_t i = 0; i < lengthof(index); i++)
vals[i] = -1;
pgstat_progress_update_multi_param(lengthof(index), index, vals);
{.attname = "local_conflicts", .atttypid = JSONARRAYOID}
};
-#define NUM_CONFLICT_ATTRS lengthof(ConflictLogSchema)
+#define NUM_CONFLICT_ATTRS ((AttrNumber) lengthof(ConflictLogSchema))
static const char *const ConflictTypeNames[] = {
[CT_INSERT_EXISTS] = "insert_exists",
static IndexAMProperty
lookup_prop_name(const char *name)
{
- int i;
-
- for (i = 0; i < lengthof(am_propnames); i++)
+ for (size_t i = 0; i < lengthof(am_propnames); i++)
{
if (pg_strcasecmp(am_propnames[i].name, name) == 0)
return am_propnames[i].prop;
{jbvObject, gettext_noop("cannot cast jsonb object to type %s")},
{jbvBinary, gettext_noop("cannot cast jsonb array or object to type %s")}
};
- int i;
- for (i = 0; i < lengthof(messages); i++)
+ for (size_t i = 0; i < lengthof(messages); i++)
if (messages[i].type == type)
ereturn(escontext, (Datum) 0,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
/* cache for format texts */
static text *fmt_txt[lengthof(fmt_str)] = {0};
- int i;
/*
* Check for optional precision for methods other than .datetime() and
}
/* loop until datetime format fits */
- for (i = 0; i < lengthof(fmt_str); i++)
+ for (size_t i = 0; i < lengthof(fmt_str); i++)
{
ErrorSaveContext escontext = {T_ErrorSaveContext};
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
bool noError = PG_GETARG_BOOL(5);
- int i;
CHECK_ENCODING_CONVERSION_ARGS(-1, PG_UTF8);
- for (i = 0; i < lengthof(maps); i++)
+ for (size_t i = 0; i < lengthof(maps); i++)
{
if (encoding == maps[i].encoding)
{
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
bool noError = PG_GETARG_BOOL(5);
- int i;
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, -1);
- for (i = 0; i < lengthof(maps); i++)
+ for (size_t i = 0; i < lengthof(maps); i++)
{
if (encoding == maps[i].encoding)
{
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
bool noError = PG_GETARG_BOOL(5);
- int i;
CHECK_ENCODING_CONVERSION_ARGS(-1, PG_UTF8);
- for (i = 0; i < lengthof(maps); i++)
+ for (size_t i = 0; i < lengthof(maps); i++)
{
if (encoding == maps[i].encoding)
{
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
bool noError = PG_GETARG_BOOL(5);
- int i;
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, -1);
- for (i = 0; i < lengthof(maps); i++)
+ for (size_t i = 0; i < lengthof(maps); i++)
{
if (encoding == maps[i].encoding)
{
{
PG_CMD_DECL;
PQExpBufferData cmd;
- int i;
setup_signals();
printf(_("creating subdirectories ... "));
fflush(stdout);
- for (i = 0; i < lengthof(subdirs); i++)
+ for (size_t i = 0; i < lengthof(subdirs); i++)
{
char *path;
static inline SeqType
parse_sequence_type(const char *name)
{
- for (int i = 0; i < lengthof(SeqTypeNames); i++)
+ for (size_t i = 0; i < lengthof(SeqTypeNames); i++)
{
if (strcmp(SeqTypeNames[i], name) == 0)
return (SeqType) i;
1
}
};
- int i;
PQExpBufferData query;
fprintf(stderr, "creating tables...\n");
initPQExpBuffer(&query);
- for (i = 0; i < lengthof(DDLs); i++)
+ for (size_t i = 0; i < lengthof(DDLs); i++)
{
const struct ddlinfo *ddl = &DDLs[i];
"alter table pgbench_tellers add primary key (tid)",
"alter table pgbench_accounts add primary key (aid)"
};
- int i;
PQExpBufferData query;
fprintf(stderr, "creating primary keys...\n");
initPQExpBuffer(&query);
- for (i = 0; i < lengthof(DDLINDEXes); i++)
+ for (size_t i = 0; i < lengthof(DDLINDEXes); i++)
{
resetPQExpBuffer(&query);
appendPQExpBufferStr(&query, DDLINDEXes[i]);
"alter table pgbench_history add constraint pgbench_history_tid_fkey foreign key (tid) references pgbench_tellers",
"alter table pgbench_history add constraint pgbench_history_aid_fkey foreign key (aid) references pgbench_accounts"
};
- int i;
fprintf(stderr, "creating foreign keys...\n");
- for (i = 0; i < lengthof(DDLKEYs); i++)
+ for (size_t i = 0; i < lengthof(DDLKEYs); i++)
{
executeStatement(con, DDLKEYs[i]);
}
static void
listAvailableScripts(void)
{
- int i;
-
fprintf(stderr, "Available builtin scripts:\n");
- for (i = 0; i < lengthof(builtin_script); i++)
+ for (size_t i = 0; i < lengthof(builtin_script); i++)
fprintf(stderr, " %13s: %s\n", builtin_script[i].name, builtin_script[i].desc);
fprintf(stderr, "\n");
}
static const BuiltinScript *
findBuiltin(const char *name)
{
- int i,
- found = 0,
+ int found = 0,
len = strlen(name);
const BuiltinScript *result = NULL;
- for (i = 0; i < lengthof(builtin_script); i++)
+ for (size_t i = 0; i < lengthof(builtin_script); i++)
{
if (strncmp(builtin_script[i].name, name, len) == 0)
{
if (active_branch)
{
- int i;
-
- for (i = 0; i < lengthof(pset.ctv_args); i++)
+ for (size_t i = 0; i < lengthof(pset.ctv_args); i++)
pset.ctv_args[i] = psql_scan_slash_option(scan_state,
OT_NORMAL, NULL, true);
pset.crosstab_flag = true;
{
int match_pos = -1;
- for (int i = 0; i < lengthof(formats); i++)
+ for (size_t i = 0; i < lengthof(formats); i++)
{
if (pg_strncasecmp(formats[i].name, value, vallen) == 0)
{
* as desirable interactions hidden in the order of the pattern
* checks. TODO: think about a better way to manage that.
*/
- for (int tindx = 0; tindx < lengthof(tcpatterns); tindx++)
+ for (size_t tindx = 0; tindx < lengthof(tcpatterns); tindx++)
{
const TCPattern *tcpat = tcpatterns + tindx;
bool match = false;
#else
- int i;
-
- for (i = 0; i < lengthof(UnicodeDecompMain); i++)
+ for (size_t i = 0; i < lengthof(UnicodeDecompMain); i++)
{
entry = &UnicodeDecompMain[i];
{
bool allowed = false;
- for (int i = 0; i < lengthof(conn->allowed_sasl_mechs); i++)
+ for (size_t i = 0; i < lengthof(conn->allowed_sasl_mechs); i++)
{
if (conn->sasl == conn->allowed_sasl_mechs[i])
{
StaticAssertDecl(lengthof(conn->allowed_sasl_mechs) == SASL_MECHANISM_COUNT,
"conn->allowed_sasl_mechs[] is not sufficiently large for holding all supported SASL mechanisms");
- for (int i = 0; i < SASL_MECHANISM_COUNT; i++)
+ for (size_t i = 0; i < SASL_MECHANISM_COUNT; i++)
conn->allowed_sasl_mechs[i] = supported_sasl_mechs[i];
}
static inline void
clear_allowed_sasl_mechs(PGconn *conn)
{
- for (int i = 0; i < lengthof(conn->allowed_sasl_mechs); i++)
+ for (size_t i = 0; i < lengthof(conn->allowed_sasl_mechs); i++)
conn->allowed_sasl_mechs[i] = NULL;
}
static inline int
index_of_allowed_sasl_mech(PGconn *conn, const pg_fe_sasl_mech *mech)
{
- for (int i = 0; i < lengthof(conn->allowed_sasl_mechs); i++)
+ for (size_t i = 0; i < lengthof(conn->allowed_sasl_mechs); i++)
{
if (conn->allowed_sasl_mechs[i] == mech)
return i;
bool
pqConnectOptions2(PGconn *conn)
{
- int i;
-
/*
* Allocate memory for details about each host to which we might possibly
* try to connect. For that, count the number of elements in the hostaddr
*/
if (conn->pghostaddr != NULL && conn->pghostaddr[0] != '\0')
{
+ int i;
char *s = conn->pghostaddr;
bool more = true;
if (conn->pghost != NULL && conn->pghost[0] != '\0')
{
+ int i;
char *s = conn->pghost;
bool more = true;
* Now, for each host slot, identify the type of address spec, and fill in
* the default address if nothing was given.
*/
- for (i = 0; i < conn->nconnhost; i++)
+ for (int i = 0; i < conn->nconnhost; i++)
{
pg_conn_host *ch = &conn->connhost[i];
*/
if (conn->pgport != NULL && conn->pgport[0] != '\0')
{
+ int i;
char *s = conn->pgport;
bool more = true;
if (conn->pgpassfile != NULL && conn->pgpassfile[0] != '\0')
{
- for (i = 0; i < conn->nconnhost; i++)
+ for (int i = 0; i < conn->nconnhost; i++)
{
/*
* Try to get a password for this host from file. We use host
if (negated)
{
+ int i;
+
/* Remove the existing mechanism from the list. */
i = index_of_allowed_sasl_mech(conn, mech);
if (i < 0)
}
else
{
+ int i;
+
/*
* Find a space to put the new mechanism (after making
* sure it's not already there).
| (1 << AUTH_REQ_SASL_CONT)
| (1 << AUTH_REQ_SASL_FIN);
- for (i = 0; i < lengthof(conn->allowed_sasl_mechs); i++)
+ for (size_t i = 0; i < lengthof(conn->allowed_sasl_mechs); i++)
{
if (conn->allowed_sasl_mechs[i])
{
* last integer last). The swap step can be optimized by combining it
* with the insertion.
*/
- for (i = 1; i < conn->nconnhost; i++)
+ for (int i = 1; i < conn->nconnhost; i++)
{
int j = pg_prng_uint64_range(&conn->prng_state, 0, i);
pg_conn_host temp = conn->connhost[j];
bool
plpgsql_token_is_unreserved_keyword(int token)
{
- int i;
-
- for (i = 0; i < lengthof(UnreservedPLKeywordTokens); i++)
+ for (size_t i = 0; i < lengthof(UnreservedPLKeywordTokens); i++)
{
if (UnreservedPLKeywordTokens[i] == token)
return true;
void
pg_localeconv_free(struct lconv *lconv)
{
- for (int i = 0; i < lengthof(table); ++i)
+ for (size_t i = 0; i < lengthof(table); ++i)
if (table[i].is_string)
free(*lconv_string_member(lconv, i));
}
locale_t monetary_locale,
locale_t numeric_locale)
{
- for (int i = 0; i < lengthof(table); ++i)
+ for (size_t i = 0; i < lengthof(table); ++i)
{
locale_t locale;
struct lconv *src,
int category)
{
- for (int i = 0; i < lengthof(table); ++i)
+ for (size_t i = 0; i < lengthof(table); ++i)
{
if (table[i].category != category)
continue;
void
_dosmaperr(unsigned long e)
{
- int i;
-
if (e == 0)
{
errno = 0;
return;
}
- for (i = 0; i < lengthof(doserrors); i++)
+ for (size_t i = 0; i < lengthof(doserrors); i++)
{
if (doserrors[i].winerr == e)
{
return -1;
}
- for (int i = 0; i < lengthof(routines); ++i)
+ for (size_t i = 0; i < lengthof(routines); ++i)
{
pg_funcptr_t address;
* startup_cb).
*/
RegisterOAuthHBAOptions(state, lengthof(hba_opts), hba_opts);
- for (int i = 0; i < lengthof(hba_opts); i++)
+ for (size_t i = 0; i < lengthof(hba_opts); i++)
{
if (GetOAuthHBAOption(state, hba_opts[i]))
elog(ERROR,
exit(1);
}
- for (int escoff = 0; escoff < lengthof(pe_test_escape_funcs); escoff++)
+ for (size_t escoff = 0; escoff < lengthof(pe_test_escape_funcs); escoff++)
{
const pe_test_escape_func *ef = &pe_test_escape_funcs[escoff];
test_gb18030_page_multiple(&tc);
test_gb18030_json(&tc);
- for (int i = 0; i < lengthof(pe_test_vectors); i++)
+ for (size_t i = 0; i < lengthof(pe_test_vectors); i++)
{
test_one_vector(&tc, &pe_test_vectors[i]);
}
test_single_value_and_filler(PG_UINT64_MAX, 1000, 2000);
/* Test different test patterns, with lots of entries */
- for (int i = 0; i < lengthof(test_specs); i++)
+ for (size_t i = 0; i < lengthof(test_specs); i++)
{
test_pattern(&test_specs[i]);
}
test_empty();
- for (int i = 0; i < lengthof(rt_node_class_tests); i++)
+ for (size_t i = 0; i < lengthof(rt_node_class_tests); i++)
{
rt_node_class_test_elem *test_info = &(rt_node_class_tests[i]);
*/
max_err = (ticks_per_ns_scaled >> TICKS_TO_NS_SHIFT) + 1;
- for (int i = 0; i < lengthof(test_ns); i++)
+ for (size_t i = 0; i < lengthof(test_ns); i++)
{
int64 result;
#endif
SIGTERM
};
- int i;
+ size_t i;
for (i = 0; i < sizeof signals / sizeof signals[0]; i++)
{