Skip to content

SET search_path not showing correct on plan or apply if you use '' #354

@silentworks

Description

@silentworks

When I create a function and set the search_path to '' and then run the plan I see the output showing search_path with "" instead. When I run the apply this fails as that is the wrong delimiter to use. It also seems like the namespaces aren't qualifying too when I set the search_path to say pg_temp, the namespaces get stripped from the function.

Table creation snippet:

create table public.test (
  id bigint generated by default as identity not null,
  title text null,
  created_at timestamp with time zone not null default now(),
  constraint test_pkey primary key (id)
);

Here is an example function:

CREATE OR REPLACE FUNCTION create_hello(p_title text)
LANGUAGE plpgsql
SECURITY INVOKER
SET search_path = ''
AS $$
BEGIN
  INSERT INTO public.test (title) VALUES (p_title)
  RETURNING id;
END;
$$;

I am expecting the example function to remain as it is with '' for the value of search_path, but instead it is showing as:

CREATE OR REPLACE FUNCTION create_hello(p_title text)
LANGUAGE plpgsql
SECURITY INVOKER
SET search_path = ""
AS $$
BEGIN
  INSERT INTO test (title) VALUES (p_title)
  RETURNING id;
END;
$$;

after a plan or apply.

edit: updated the snippet to remove public. from test in the current output.

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