Merge pull request #3719 from citusdata/stricter-trigger-checks

Verify trigger relation before reading old/new tuples
pull/3738/head
Philip Dubé 2020-04-07 16:18:36 +00:00 committed by GitHub
commit 76a8a3c7c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -2558,6 +2558,12 @@ master_dist_partition_cache_invalidate(PG_FUNCTION_ARGS)
CheckCitusVersion(ERROR);
if (RelationGetRelid(triggerData->tg_relation) != DistPartitionRelationId())
{
ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
errmsg("triggered on incorrect relation")));
}
HeapTuple newTuple = triggerData->tg_newtuple;
HeapTuple oldTuple = triggerData->tg_trigtuple;
@ -2619,6 +2625,12 @@ master_dist_shard_cache_invalidate(PG_FUNCTION_ARGS)
CheckCitusVersion(ERROR);
if (RelationGetRelid(triggerData->tg_relation) != DistShardRelationId())
{
ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
errmsg("triggered on incorrect relation")));
}
HeapTuple newTuple = triggerData->tg_newtuple;
HeapTuple oldTuple = triggerData->tg_trigtuple;
@ -2680,6 +2692,23 @@ master_dist_placement_cache_invalidate(PG_FUNCTION_ARGS)
CheckCitusVersion(ERROR);
/*
* Before 7.0-2 this trigger is on pg_dist_shard_placement,
* ignore trigger in this scenario.
*/
Oid pgDistShardPlacementId = get_relname_relid("pg_dist_shard_placement",
PG_CATALOG_NAMESPACE);
if (RelationGetRelid(triggerData->tg_relation) == pgDistShardPlacementId)
{
PG_RETURN_DATUM(PointerGetDatum(NULL));
}
if (RelationGetRelid(triggerData->tg_relation) != DistPlacementRelationId())
{
ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
errmsg("triggered on incorrect relation")));
}
HeapTuple newTuple = triggerData->tg_newtuple;
HeapTuple oldTuple = triggerData->tg_trigtuple;

View File

@ -242,7 +242,7 @@ task_tracker_cleanup_job(PG_FUNCTION_ARGS)
/*
* task_tracker_conninfo_cache_invalidate is a trigger function that signals to
* the task tracker to refresh its conn params cache after a authinfo change.
* the task tracker to refresh its conn params cache after an authinfo change.
*
* NB: We decided there is little point in checking permissions here, there
* are much easier ways to waste CPU than causing cache invalidations.