Search Postgresql Archives

Re: ISO something like "#if 0 ... #endif" for SQL code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 11, 2008 at 10:10 AM, Gurjeet Singh <singh.gurjeet@xxxxxxxxx> wrote:
The SQL standard, and Postgres, allow you to nest comments; some commercial RDBMS' do not provide this, and hence people think it's not possible in SQL.

Ah!  Finally I see what Martin was getting at in his reply.

Well, among those who seem unaware of the standard is the author of the Emacs SQL mode, because its syntax highlighting gets all messed up with nested C-style comments...

Thanks for the tip!

Kynn


P.S.  For any interested Emacs user:  as it happens, it was pretty easy to fix sql.el to allow C-style comments to nest.  It just required adding a couple of n's, to change the lines

    (modify-syntax-entry ?/ ". 14" table)
    (modify-syntax-entry ?* ". 23" table)

to

    (modify-syntax-entry ?/ ". 14n" table)
    (modify-syntax-entry ?* ". 23n" table)

(actually either one of the two changes would have sufficed) in the syntax table definition

(defvar sql-mode-syntax-table
  (let ((table (make-syntax-table)))
    ;; C-style comments /**/ (see elisp manual "Syntax Flags"))
    (modify-syntax-entry ?/ ". 14" table)
    (modify-syntax-entry ?* ". 23" table)
    ;; double-dash starts comments
    (modify-syntax-entry ?- ". 12b" table)
    ;; newline and formfeed end comments
    (modify-syntax-entry ?\n "> b" table)
    (modify-syntax-entry ?\f "> b" table)
    ;; single quotes (') delimit strings
    (modify-syntax-entry ?' "\"" table)
    ;; double quotes (") don't delimit strings
    (modify-syntax-entry ?\" "." table)
    ;; backslash is no escape character
    (modify-syntax-entry ?\\ "." table)
    table)
  "Syntax table used in `sql-mode' and `sql-interactive-mode'.")

(I also had to restart Emacs to get this change to have an effect.  Just executing the revised definition was not enough.  Maybe there's a way to do achieve the same without restarting, but I couldn't think of it.)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux