aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/misc.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-11-21 16:21:43 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2019-11-21 16:21:43 -0500
commit5186f7625e5fc0e3ae85419099a75d6aa93d8351 (patch)
treeda1abddf7337507a2ddda21165a4fc26a1d5b2a8 /src/backend/utils/adt/misc.c
parentc644407f757c26c9037e4dfc67f57b841489afd4 (diff)
downloadpostgresql-5186f7625e5fc0e3ae85419099a75d6aa93d8351.tar.gz
postgresql-5186f7625e5fc0e3ae85419099a75d6aa93d8351.zip
Defend against self-referential views in relation_is_updatable().
While a self-referential view doesn't actually work, it's possible to create one, and it turns out that this breaks some of the information_schema views. Those views call relation_is_updatable(), which neglected to consider the hazards of being recursive. In older PG versions you get a "stack depth limit exceeded" error, but since v10 it'd recurse to the point of stack overrun and crash, because commit a4c35ea1c took out the expression_returns_set() call that was incidentally checking the stack depth. Since this function is only used by information_schema views, it seems like it'd be better to return "not updatable" than suffer an error. Hence, add tracking of what views we're examining, in just the same way that the nearby fireRIRrules() code detects self-referential views. I added a check_stack_depth() call too, just to be defensive. Per private report from Manuel Rigger. Back-patch to all supported versions.
Diffstat (limited to 'src/backend/utils/adt/misc.c')
-rw-r--r--src/backend/utils/adt/misc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index d330a88e3c1..e59b61ba6f2 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -510,7 +510,7 @@ pg_relation_is_updatable(PG_FUNCTION_ARGS)
Oid reloid = PG_GETARG_OID(0);
bool include_triggers = PG_GETARG_BOOL(1);
- PG_RETURN_INT32(relation_is_updatable(reloid, include_triggers, NULL));
+ PG_RETURN_INT32(relation_is_updatable(reloid, NIL, include_triggers, NULL));
}
/*
@@ -534,7 +534,7 @@ pg_column_is_updatable(PG_FUNCTION_ARGS)
if (attnum <= 0)
PG_RETURN_BOOL(false);
- events = relation_is_updatable(reloid, include_triggers,
+ events = relation_is_updatable(reloid, NIL, include_triggers,
bms_make_singleton(col));
/* We require both updatability and deletability of the relation */