pgquarrel icon indicating copy to clipboard operation
pgquarrel copied to clipboard

buildStringList fails to handle search_path with commas

Open jacobwgillespie opened this issue 3 years ago • 0 comments

Describe the bug

It appears that functions with differing search paths result in incorrect output due to buildStringList being unable to parse a search_path with commas.

I'm not super familiar with the codebase here, so I can't pinpoint exactly where the error lives (otherwise I'd open a PR), but I have a function with two differing search paths:

  • search_path=pg_catalog
  • search_path=pg_catalog, public, pg_temp

In function.c, it tries to build a list of options to set by calling setOperationOptions here:

https://github.com/eulerto/pgquarrel/blob/6e6619aeb9b699900560422ba36629f2b0785958/src/function.c#L719-L720

That function in turn calls buildStringList on each of those strings. This results in the following:

Input to buildStringList Value of ret->head->value
search_path=pg_catalog search_path=pg_catalog
search_path=pg_catalog, public, pg_temp pg_temp

I believe the second row's result is incorrect. This results in the following SQL being written, without the SETs being included:

ALTER FUNCTION schema.func_name();

Your environment

  • Mac
  • Postgres 12
  • latest master

jacobwgillespie avatar Oct 11 '20 00:10 jacobwgillespie