Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency tracking #4

Open
steve-chavez opened this issue Sep 10, 2023 · 0 comments
Open

Dependency tracking #4

steve-chavez opened this issue Sep 10, 2023 · 0 comments
Labels

Comments

@steve-chavez
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant