Skip to content

Function create/update fails for config_params like statement_timeout #1142

Description

@hsusul

Bug

functions.create / regenerating a function via functions.update emits unquoted SET values:

SET statement_timeout TO 5s

That is invalid PostgreSQL (trailing junk after numeric literal). Values that look like identifiers (e.g. search_path TO hooks, auth) happen to work but fold case and cannot carry commas inside a single GUC value safely.

Role config creation already quotes via literal() / list-item quoting; function config_params does not.

Repro

await pgMeta.functions.create({
  name: 'test_timeout_func',
  schema: 'public',
  args: [],
  definition: 'select 1',
  return_type: 'integer',
  language: 'sql',
  behavior: 'VOLATILE',
  security_definer: false,
  config_params: { statement_timeout: '5s' },
})
// → SQL error near 5s

Also breaks body updates for any existing function that already has statement_timeout (or similar) in config_params, because update regenerates CREATE OR REPLACE from those values.

Expected

SET statement_timeout TO '5s'
SET search_path TO 'hooks', 'auth'

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions