supabase / splinter

Supabase Postgres Linter
https://supabase.github.io/splinter/
70 stars 6 forks source link

Lint to enforce functions have an empty search path #12

Closed olirice closed 3 months ago

olirice commented 4 months ago

When function bodies don't fully qualify their references e.g.

create function xyz()
  return text
  as 
$$
  select some_func()
$$

then some_func must be on the querying user's search path in order for it to function.

99% of the time, its better to fully qualify the function

create function xyz()
  return text
  as 
$$
  select <some_schema>.some_func()
$$

we can make this mandatory by enforcing that functions set their search path to ''

create function xyz()
  return text
  set search_path = ''
  as 
$$
  select <some_schema>.some_func()
$$
olirice commented 3 months ago

resolved by https://github.com/supabase/splinter/blob/main/lints/0011_function_search_path_mutable.sql