TupleTableSlot *newslot;
RI_QueryKey qkey;
SPIPlanPtr qplan;
- int i;
riinfo = ri_FetchConstraintInfo(trigdata->tg_trigger,
trigdata->tg_relation, false);
quoteRelationName(pkrelname, pk_rel);
appendStringInfo(&querybuf, "SELECT 1 FROM ONLY %s x", pkrelname);
querysep = "WHERE";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
{
SPIPlanPtr qplan;
RI_QueryKey qkey;
- int i;
bool result;
/* Only called for non-null rows */
quoteRelationName(pkrelname, pk_rel);
appendStringInfo(&querybuf, "SELECT 1 FROM ONLY %s x", pkrelname);
querysep = "WHERE";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
const char *querysep;
Oid queryoids[RI_MAX_NUMKEYS];
const char *fk_only;
- int i;
/* ----------
* The query string built is
appendStringInfo(&querybuf, "SELECT 1 FROM %s%s x",
fk_only, fkrelname);
querysep = "WHERE";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
TupleTableSlot *old_slot;
RI_QueryKey qkey;
SPIPlanPtr qplan;
- int i;
/* Check that this is a valid trigger call on the right time and event. */
ri_CheckTrigger(fcinfo, "RI_FKey_cascade_del", RI_TRIGTYPE_DELETE);
appendStringInfo(&querybuf, "DELETE FROM %s%s",
fk_only, fkrelname);
querysep = "WHERE";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
TupleTableSlot *old_slot;
RI_QueryKey qkey;
SPIPlanPtr qplan;
- int i;
- int j;
/* Check that this is a valid trigger call on the right time and event. */
ri_CheckTrigger(fcinfo, "RI_FKey_cascade_upd", RI_TRIGTYPE_UPDATE);
fk_only, fkrelname);
querysep = "";
qualsep = "WHERE";
- for (i = 0, j = riinfo->nkeys; i < riinfo->nkeys; i++, j++)
+ for (int i = 0, j = riinfo->nkeys; i < riinfo->nkeys; i++, j++)
{
Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
TupleTableSlot *old_slot;
RI_QueryKey qkey;
SPIPlanPtr qplan;
- int i;
riinfo = ri_FetchConstraintInfo(trigdata->tg_trigger,
trigdata->tg_relation, true);
fk_only, fkrelname);
querysep = "";
qualsep = "WHERE";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
const char *qualsep;
Oid queryoids[RI_MAX_NUMKEYS];
const char *fk_only;
- int i;
/* ----------
* The query string built is
fk_only, fkrelname);
querysep = "";
qualsep = "WHERE";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
RangeTblEntry *fkrte;
const char *sep;
const char *fk_only;
- int i;
int save_nestlevel;
char workmembuf[32];
int spi_result;
fkrte->rellockmode = AccessShareLock;
fkrte->requiredPerms = ACL_SELECT;
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
int attno;
initStringInfo(&querybuf);
appendStringInfoString(&querybuf, "SELECT ");
sep = "";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
quoteOneName(fkattname,
RIAttName(fk_rel, riinfo->fk_attnums[i]));
strcpy(pkattname, "pk.");
strcpy(fkattname, "fk.");
sep = "(";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
appendStringInfo(&querybuf, ") WHERE pk.%s IS NULL AND (", pkattname);
sep = "";
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
quoteOneName(fkattname, RIAttName(fk_rel, riinfo->fk_attnums[i]));
appendStringInfo(&querybuf,
* or fk_rel's tupdesc.
*/
memcpy(&fake_riinfo, riinfo, sizeof(RI_ConstraintInfo));
- for (i = 0; i < fake_riinfo.nkeys; i++)
+ for (int i = 0; i < fake_riinfo.nkeys; i++)
fake_riinfo.fk_attnums[i] = i + 1;
/*
Datum *vals, char *nulls)
{
const int16 *attnums;
- int i;
bool isnull;
if (rel_is_pk)
else
attnums = riinfo->fk_attnums;
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
vals[i] = slot_getattr(slot, attnums[i], &isnull);
nulls[i] = isnull ? 'n' : ' ';
StringInfoData key_values;
bool onfk;
const int16 *attnums;
- int idx;
Oid rel_oid;
AclResult aclresult;
bool has_perm = true;
if (aclresult != ACLCHECK_OK)
{
/* Try for column-level permissions */
- for (idx = 0; idx < riinfo->nkeys; idx++)
+ for (int idx = 0; idx < riinfo->nkeys; idx++)
{
aclresult = pg_attribute_aclcheck(rel_oid, attnums[idx],
GetUserId(),
/* Get printable versions of the keys involved */
initStringInfo(&key_names);
initStringInfo(&key_values);
- for (idx = 0; idx < riinfo->nkeys; idx++)
+ for (int idx = 0; idx < riinfo->nkeys; idx++)
{
int fnum = attnums[idx];
Form_pg_attribute att = TupleDescAttr(tupdesc, fnum - 1);
const RI_ConstraintInfo *riinfo, bool rel_is_pk)
{
const int16 *attnums;
- int i;
bool allnull = true;
bool nonenull = true;
else
attnums = riinfo->fk_attnums;
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
if (slot_attisnull(slot, attnums[i]))
nonenull = false;
{
const int16 *attnums;
const Oid *eq_oprs;
- int i;
if (rel_is_pk)
{
}
/* XXX: could be worthwhile to fetch all necessary attrs at once */
- for (i = 0; i < riinfo->nkeys; i++)
+ for (int i = 0; i < riinfo->nkeys; i++)
{
Datum oldvalue;
Datum newvalue;