Skip to content

feat(grammar): SET configuration_parameter in CREATE FUNCTION and PROCEDURE - #375

Open
sebsnyk wants to merge 1 commit into
DerekStride:mainfrom
sebsnyk:fix/function-set-option
Open

sebsnyk wants to merge 1 commit into
DerekStride:mainfrom
sebsnyk:fix/function-set-option

Conversation

@sebsnyk

@sebsnyk sebsnyk commented Sep 10, 2026

Copy link
Copy Markdown

Problem

CREATE FUNCTION ... SET search_path = public, pg_temp AS $$ ... $$ does not parse; #364 reports it. Any function that pins search_path (most SECURITY DEFINER functions, and every function in pg_partman) fails at the SET.

Solution

A function_set option: SET name { TO | = } value [, value ...], with DEFAULT, ON and OFF as values like set_statement, plus SET name FROM CURRENT. It joins the other options on create_function and create_procedure, so it is accepted before or after the body in any order.

create_function and create_procedure are now prec.right. Without it a trailing SET inside a T-SQL WHILE cond BEGIN ... END body, where statements have no terminating semicolon, could also be read as the next statement; right associativity keeps it with the definition, which is the PostgreSQL reading.

Notes

Closes #364

…CEDURE

`SET name { TO | = } value, ...`, `SET name = DEFAULT` and `SET name
FROM CURRENT` are accepted among the other function options, before or
after the body. `create_function` and `create_procedure` take right
associativity so a trailing `SET` binds to the definition rather than
starting a new statement inside a T-SQL `WHILE ... BEGIN ... END`.

Closes DerekStride#364

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support SET in functions

2 participants