pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Improve error reporting for broken SQL statement

Open microfauna opened this issue 7 months ago • 4 comments

Hello, I have two SQL statements causing issues in the plan stage. The first, I resolved

Error: failed to apply desired state: failed to apply schema SQL to temporary schema pgschema_tmp_20260406_120557_bd36cbfc: ERROR: zero-length delimited identifier at or near """" (SQLSTATE 42601)

Which turned out I needed to change

SET search_path = ""

to

SET search_path = ''

Once I resolved that, I now have this:

Error: failed to apply desired state: failed to apply schema SQL to temporary schema pgschema_tmp_20260406_120648_5bfb9e73: ERROR: syntax error at or near "SELECT" (SQLSTATE 42601)

but it's too generic for me to figure out where it's happening. I enabled verbose logging but it dumps a huge concat of all schemas, making it hard to locate.

microfauna avatar Apr 06 '26 16:04 microfauna

Please provide the schema

tianzhou avatar Apr 07 '26 09:04 tianzhou

Hi @tianzhou , the schema is quite huge - i've attached the output file from plan - the rest is sort of project specific though and spread across a few hundred files.

microfauna avatar Apr 07 '26 23:04 microfauna

Thanks. The fix is on main. We will publish a new release in a week or two

tianzhou avatar Apr 08 '26 07:04 tianzhou

Thank you!!

microfauna avatar Apr 08 '26 17:04 microfauna