Function: sqlind-maybe-skip-create-options

sqlind-maybe-skip-create-options is a natively compiled function defined in sql-indent.el.

Signature

(sqlind-maybe-skip-create-options)

Documentation

Move point past any MySQL option declarations.

Statements like "CREATE VIEW" or "CREATE TABLE" can have various options betwen the CREATE keyword and the thing being created. If such options exist at (point) the cursor is moved past them.

Currently we move over the following options, for different products:

MySQL:

  TEMPORARY
  ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}
  DEFINER = { user | CURENT_USER }
  SQL SECURITY { DEFINER | INVOKER }

PostgresSQL

  TEMP
  TEMPORARY
  GLOBAL
  LOCAL
  UNLOGGED
  MATERIALIZED

Oracle

  PRIVATE
  TEMP
  TEMPORARY
  MATERIALIZED

We don't consider if the options are valid or not for the thing being created. We just skip any and all of them that are present.

Source Code

;; Defined in /nix/store/jxjf2h9nnkdqnn1w1mr0ag8bqng2rlrs-emacs-packages-deps/share/emacs/site-lisp/elpa/sql-indent-1.7/sql-indent.el
(defun sqlind-maybe-skip-create-options ()
  "Move point past any MySQL option declarations.

Statements like \"CREATE VIEW\" or \"CREATE TABLE\" can have
various options betwen the CREATE keyword and the thing being
created.  If such options exist at (point) the cursor is moved
past them.

Currently we move over the following options, for different
products:

MySQL:

  TEMPORARY
  ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}
  DEFINER = { user | CURENT_USER }
  SQL SECURITY { DEFINER | INVOKER }

PostgresSQL

  TEMP
  TEMPORARY
  GLOBAL
  LOCAL
  UNLOGGED
  MATERIALIZED

Oracle

  PRIVATE
  TEMP
  TEMPORARY
  MATERIALIZED

We don't consider if the options are valid or not for the thing
being created.  We just skip any and all of them that are
present."
  (cond
    ((eq sql-product 'mysql)
     (catch 'finished
       (while t
         (cond
           ((looking-at "temporary\\_>")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           ((looking-at "\\(definer\\|algorithm\\)\\(\\s-\\|[\n]\\)*=\\(\\s-\\|[\n]\\)*\\S-+")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           ((looking-at "sql\\(\\s-\\|[\n]\\)+security\\(\\s-\\|[\n]\\)+\\S-+")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           (t (throw 'finished nil))))))
    ((eq sql-product 'postgres)
     (catch 'finished
       (while t
         (cond
           ((looking-at "temp\\(orary\\)?\\_>")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           ((looking-at "\\(global\\|local\\|unlogged\\)\\_>")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           ((looking-at "materialized\\_>")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           (t (throw 'finished nil))))))
    ((eq sql-product 'oracle)
     (catch 'finished
       (while t
         (cond
           ((looking-at "temp\\(orary\\)\\_>")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           ((looking-at "materialized\\_>")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           ((looking-at "private\\_>")
            (goto-char (match-end 0))
            (sqlind-forward-syntactic-ws))
           (t (throw 'finished nil))))))))