Skip to content

sql: allow table and column renaming if only references are in udfs #101934

@rharding6373

Description

@rharding6373

Postgres allows tables and columns to be renamed using ALTER TABLE even if they are referenced by UDFs. For example, the following commands succeed in postgres:

CREATE TABLE t_twocol (a INT, b INT);

CREATE FUNCTION f_unqualified_twocol() RETURNS t_twocol AS
$$
  SELECT * FROM t_twocol;
$$ LANGUAGE SQL;

-- CRDB failure: cannot rename column "a" because function "f_unqualified_twocol" depends on it
ALTER TABLE t_twocol RENAME COLUMN a TO d;

-- CRDB failure: cannot rename relation "t_twocol" because function "f_unqualified_twocol" depends on it
ALTER TABLE t_twocol RENAME TO t_twocol_prime;

This should be possible once we're able to rewrite queries with table and column IDs.

Jira issue: CRDB-27189

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-routineUDFs and Stored ProceduresC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries Team

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions