mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Teach relation_is_updatable() about partitioned tables.
Table partitioning, introduced in commit f0e44751d7
, added a new
relkind - RELKIND_PARTITIONED_TABLE. Update relation_is_updatable() to
handle it. Specifically, partitioned tables and simple views built on
top of them are updatable.
This affects the SQL-callable functions pg_relation_is_updatable() and
pg_column_is_updatable(), and the views information_schema.views and
information_schema.columns.
Dean Rasheed, reviewed by Ashutosh Bapat.
Discussion: https://postgr.es/m/CAEZATCXnbiFkMXgF4Ez1pmM2c-tS1z33bSq7OGbw7QQhHov%2B6Q%40mail.gmail.com
This commit is contained in:
@ -2454,7 +2454,8 @@ relation_is_updatable(Oid reloid,
|
||||
return 0;
|
||||
|
||||
/* If the relation is a table, it is always updatable */
|
||||
if (rel->rd_rel->relkind == RELKIND_RELATION)
|
||||
if (rel->rd_rel->relkind == RELKIND_RELATION ||
|
||||
rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||
{
|
||||
relation_close(rel, AccessShareLock);
|
||||
return ALL_EVENTS;
|
||||
@ -2568,7 +2569,8 @@ relation_is_updatable(Oid reloid,
|
||||
base_rte = rt_fetch(rtr->rtindex, viewquery->rtable);
|
||||
Assert(base_rte->rtekind == RTE_RELATION);
|
||||
|
||||
if (base_rte->relkind != RELKIND_RELATION)
|
||||
if (base_rte->relkind != RELKIND_RELATION &&
|
||||
base_rte->relkind != RELKIND_PARTITIONED_TABLE)
|
||||
{
|
||||
baseoid = base_rte->relid;
|
||||
include_cols = adjust_view_column_set(updatable_cols,
|
||||
|
Reference in New Issue
Block a user