alex-hhh / emacs-sql-indent

Syntax based indentation for SQL files inside GNU Emacs
GNU General Public License v3.0
121 stars 18 forks source link

PostgreSQL DO blocks throws "end statement closes nothing" when encountering a CREATE statement #89

Closed sfllaw closed 4 years ago

sfllaw commented 4 years ago

Test case in PostgreSQL:

DO $$
  BEGIN
    CREATE TABLE t ();
  END -- end statement closes nothing (40, 40)
$$ LANGUAGE plpgsql;

When running sqlind-indent-line on the END statement, sqlind-refine-end-syntax throws the end statement closes nothing syntax error.

It looks like after the CREATE TABLE statement, sqlind thinks that it is back to 'toplevel, even though it should be 'in-begin-block.

alex-hhh commented 4 years ago

Thanks for reporting this issue -- it was indeed a defect where create table (and view and index) statements were incorrectly considered to start an SQL block. I pushed a fix for this. Can you please try it out? Thanks, Alex.

sfllaw commented 4 years ago

Fixed!