Skip to content

Dependency tracking #4

Open
Open
@steve-chavez

Description

@steve-chavez

BEGIN ATOMIC works like this right now:

create table person (
	firstname text,
	lastname text
);

create function foo(person) returns text begin atomic select $1.firstname || $1.lastname; end;

select foo('(x,y)');
 foo 
-----
 xy
(1 row)

After a column rename, the function keeps working:

alter table person rename column lastname to last_name;

select foo('(x,y)');
 foo 
-----
 xy
(1 row)

This because it automatically updates the function body:

\df+ foo

BEGIN ATOMIC                               +
 SELECT (($1).firstname || ($1).last_name);+
END                                         

If the foo function were to be created with language sql, it wouldn't work that way:

create or replace function foo(person) returns text as $$
	select $1.firstname || $1.lastname;
$$ language sql;

select foo('(x,y)');

ERROR:  column "lastname" not found in data type person
LINE 2: select $1.firstname || $1.lastname;

Not sure if we can achieve the BEGIN ATOMIC behavior, but could we at least fail if a column is renamed? Maybe by inserting an entry into pg_depend?

This will make more sense once #2 is done.

It would also be a compelling reason to do HTML rendering on the database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions