|
|
|
|
@ -428,13 +428,13 @@ RI_FKey_check(TriggerData *trigdata) |
|
|
|
|
{ |
|
|
|
|
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[riinfo->nkeys - 1]); |
|
|
|
|
|
|
|
|
|
appendStringInfo(&querybuf, ") x1 HAVING "); |
|
|
|
|
appendStringInfoString(&querybuf, ") x1 HAVING "); |
|
|
|
|
sprintf(paramname, "$%d", riinfo->nkeys); |
|
|
|
|
ri_GenerateQual(&querybuf, "", |
|
|
|
|
paramname, fk_type, |
|
|
|
|
riinfo->agged_period_contained_by_oper, |
|
|
|
|
"pg_catalog.range_agg", ANYMULTIRANGEOID); |
|
|
|
|
appendStringInfo(&querybuf, "(x1.r)"); |
|
|
|
|
appendStringInfoString(&querybuf, "(x1.r)"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Prepare and save the plan */ |
|
|
|
|
@ -597,13 +597,13 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel, |
|
|
|
|
{ |
|
|
|
|
Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[riinfo->nkeys - 1]); |
|
|
|
|
|
|
|
|
|
appendStringInfo(&querybuf, ") x1 HAVING "); |
|
|
|
|
appendStringInfoString(&querybuf, ") x1 HAVING "); |
|
|
|
|
sprintf(paramname, "$%d", riinfo->nkeys); |
|
|
|
|
ri_GenerateQual(&querybuf, "", |
|
|
|
|
paramname, fk_type, |
|
|
|
|
riinfo->agged_period_contained_by_oper, |
|
|
|
|
"pg_catalog.range_agg", ANYMULTIRANGEOID); |
|
|
|
|
appendStringInfo(&querybuf, "(x1.r)"); |
|
|
|
|
appendStringInfoString(&querybuf, "(x1.r)"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Prepare and save the plan */ |
|
|
|
|
@ -838,12 +838,12 @@ ri_restrict(TriggerData *trigdata, bool is_no_action) |
|
|
|
|
|
|
|
|
|
/* Intersect the fk with the old pk range */ |
|
|
|
|
initStringInfo(&intersectbuf); |
|
|
|
|
appendStringInfoString(&intersectbuf, "("); |
|
|
|
|
appendStringInfoChar(&intersectbuf, '('); |
|
|
|
|
ri_GenerateQual(&intersectbuf, "", |
|
|
|
|
attname, fk_period_type, |
|
|
|
|
riinfo->period_intersect_oper, |
|
|
|
|
paramname, pk_period_type); |
|
|
|
|
appendStringInfoString(&intersectbuf, ")"); |
|
|
|
|
appendStringInfoChar(&intersectbuf, ')'); |
|
|
|
|
|
|
|
|
|
/* Find the remaining history */ |
|
|
|
|
initStringInfo(&replacementsbuf); |
|
|
|
|
|