Skip to content

Add ALTER FUNCTION and COMMENT ON FUNCTION - #437

Merged
tamnd merged 4 commits into
mainfrom
alter-function
Oct 20, 2026
Merged

tamnd merged 4 commits into
mainfrom
alter-function

Conversation

@tamnd

@tamnd tamnd commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds ALTER FUNCTION, ALTER ROUTINE and COMMENT ON FUNCTION for the functions in SQL of the catalog.

Changes

  • ALTER FUNCTION changes the options IMMUTABLE, STABLE, VOLATILE, STRICT, CALLED ON NULL INPUT, PARALLEL, COST and ROWS, as AlterFunction does. A second option of the same kind gives 42601 at the place of the option. COST and ROWS must be positive, and ROWS needs a function that returns a set.
  • ALTER FUNCTION ... RENAME TO gives the function a new name. A schema that has a function with the new name and the same argument types gives 42723, as IsThereFunctionInNamespace does. The views that call the function get a new text.
  • ALTER FUNCTION ... SET SCHEMA moves the function and its pg_depend entry to the new schema. A move to the schema that has the function already does nothing.
  • ALTER FUNCTION ... OWNER TO changes proowner, with the checks of AlterObjectOwner_internal for a user that is not a superuser.
  • COMMENT ON FUNCTION sets and clears the comment of a function.
  • The lookup is the same as for DROP FUNCTION, so the errors for a name that is not unique and for a function that does not exist are the same as in PostgreSQL.
  • The command tags are ALTER FUNCTION and ALTER ROUTINE.
  • New Catalog::alter_function.

Known differences

  • rupg keeps procost and prorows as whole numbers. A value with a fraction gives 0A000.
  • SECURITY DEFINER, LEAKPROOF, SUPPORT, SET and RESET give 0A000.
  • rupg cannot change or comment on a built-in function. These statements give 0A000.
  • The catalog keeps the text of the body of a function. So a new name or a new schema for a function that the body of another function calls gives 0A000.
  • ALTER PROCEDURE gives 0A000, because rupg has no procedures yet.

Tests

  • New session test alter_function. Its expected output is the output of PostgreSQL 19 for the same script.
  • fmt, clippy, the workspace tests and the checks of xtask pass on server1.

@tamnd tamnd added kind/feature It does not do something that it must do. area/session Sessions, settings, pooling and the server runtime. area/sql The grammar, the lexer, the analyzer and the rewriter. labels Oct 20, 2026
@tamnd
tamnd merged commit 2f9fd48 into main Oct 20, 2026
@tamnd
tamnd deleted the alter-function branch October 20, 2026 02:43
@tamnd tamnd mentioned this pull request Oct 20, 2026
1 of 17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/session Sessions, settings, pooling and the server runtime. area/sql The grammar, the lexer, the analyzer and the rewriter. kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant