PostgreSQL CREATE EXTENSION IF NOT EXISTS
Closed this issue · 2 comments
sql-indent-mode
appears to be confused by the IF NOT
clause that may appear in pgSQL's CREATE EXTENSION
statement. See the following example -
CREATE EXTENSION "uuid-ossp" WITH SCHEMA public;
-- indentation is correct here
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public
-- invalid syntax, but this treated as a block
END;
-- indentation is correct here
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
-- autoindents to this level
sql-product
is set to postgres
.
Thanks for reporting this. I pushed a fix for this, you can check it out.
Note however that the invalid syntax line is not detected where you point it out, but it will be detected at the "END" statement and the next "CREATE" statement. The aim of sql-indent
is not really to detect syntax errors in SQL code, and this error detection is very limited -- I have no plans to improve that, as it would be a lot of work.
Thanks! I'll take a look
Note however that the invalid syntax line is not detected where you point it out
Ah, sorry for the confusion there. I used this as an example to try and illustrate how I thought this was happening. The invalid syntax bit was just an acknowledgement that the CREATE ... END;
statement given wasn't something that would occur in the wild.