You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After a column rename, the function keeps working:
altertable 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 replacefunctionfoo(person) returns textas $$
select $1.firstname || $1.lastname;
$$ language sql;
select foo('(x,y)');
ERROR: column "lastname" not found in data type person
LINE2: 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?
BEGIN ATOMIC works like this right now:
After a column rename, the function keeps working:
This because it automatically updates the function body:
If the foo function were to be created with
language sql
, it wouldn't work that way: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.
The text was updated successfully, but these errors were encountered: