[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sql-indent b79a5faa9c 1/3: Add support for BEGIN ATOMIC
From: |
ELPA Syncer |
Subject: |
[elpa] externals/sql-indent b79a5faa9c 1/3: Add support for BEGIN ATOMIC keywords |
Date: |
Fri, 22 Sep 2023 18:59:07 -0400 (EDT) |
branch: externals/sql-indent
commit b79a5faa9c15baefc2eade4cbff172d05bf9fc87
Author: Alex Harsányi <AlexHarsanyi@gmail.com>
Commit: Alex Harsányi <AlexHarsanyi@gmail.com>
Add support for BEGIN ATOMIC keywords
... as well as BEGIN NOT ATOMIC
---
sql-indent-test.el | 5 +++
sql-indent.el | 3 +-
test-data/pr106-syn.eld | 96 +++++++++++++++++++++++++++++++++++++++++++++++++
test-data/pr106.sql | 38 ++++++++++++++++++++
4 files changed, 140 insertions(+), 2 deletions(-)
diff --git a/sql-indent-test.el b/sql-indent-test.el
index b753e1242a..74f6cfec90 100644
--- a/sql-indent-test.el
+++ b/sql-indent-test.el
@@ -503,4 +503,9 @@ information read from DATA-FILE (as generated by
"test-data/pr105.sql"
"test-data/pr105-syn.eld"))
+(ert-deftest sqlind-ert-pr106 ()
+ (sqlind-ert-check-file-syntax
+ "test-data/pr106.sql"
+ "test-data/pr106-syn.eld"))
+
;;; sql-indent-test.el ends here
diff --git a/sql-indent.el b/sql-indent.el
index 1bf8fe265e..8d55510497 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -308,8 +308,7 @@ But don't go before LIMIT."
(save-excursion
(catch 'done
(while (> (point) (or limit (point-min)))
- (when (re-search-backward
-
";\\|:=\\|\\_<\\(declare\\|begin\\|cursor\\|for\\|while\\|loop\\|if\\|then\\|else\\|elsif\\|elseif\\)\\_>\\|)\\|\\$\\$"
+ (when (re-search-backward
";\\|:=\\|\\_<\\(declare\\|\\(begin\\(\\(\\s-+not\\)?\\s-+atomic\\)?\\)\\|cursor\\|for\\|while\\|loop\\|if\\|then\\|else\\|elsif\\|elseif\\)\\_>\\|)\\|\\$\\$"
limit 'noerror)
(unless (sqlind-in-comment-or-string (point))
(let ((candidate-pos (match-end 0)))
diff --git a/test-data/pr106-syn.eld b/test-data/pr106-syn.eld
new file mode 100644
index 0000000000..4696909497
--- /dev/null
+++ b/test-data/pr106-syn.eld
@@ -0,0 +1,96 @@
+(((toplevel . 1))
+ (((defun-start "iota")
+ . 1))
+ (((block-start begin)
+ . 1)
+ ((defun-start "iota")
+ . 1))
+ (((in-begin-block defun "iota")
+ . 58))
+ ((nested-statement-open . 100)
+ (statement-continuation . 100))
+ ((select-clause . 106)
+ (nested-statement-continuation . 100)
+ (statement-continuation . 100))
+ ((select-clause . 106)
+ (nested-statement-continuation . 100)
+ (statement-continuation . 100))
+ ((select-clause . 106)
+ (nested-statement-continuation . 100)
+ (statement-continuation . 100))
+ ((select-clause . 106)
+ (nested-statement-continuation . 100)
+ (statement-continuation . 100))
+ ((nested-statement-close . 100)
+ (statement-continuation . 100))
+ ((with-clause . 73)
+ (statement-continuation . 73))
+ (((block-end defun "iota")
+ . 58)
+ ((in-begin-block defun "iota")
+ . 58))
+ ((toplevel . 1))
+ ((toplevel . 1))
+ (((defun-start "iota")
+ . 221))
+ (((block-start begin)
+ . 221)
+ ((defun-start "iota")
+ . 221))
+ (((in-begin-block defun "iota")
+ . 278))
+ ((nested-statement-open . 324)
+ (statement-continuation . 324))
+ ((select-clause . 330)
+ (nested-statement-continuation . 324)
+ (statement-continuation . 324))
+ ((select-clause . 330)
+ (nested-statement-continuation . 324)
+ (statement-continuation . 324))
+ ((select-clause . 330)
+ (nested-statement-continuation . 324)
+ (statement-continuation . 324))
+ ((select-clause . 330)
+ (nested-statement-continuation . 324)
+ (statement-continuation . 324))
+ ((nested-statement-close . 324)
+ (statement-continuation . 324))
+ ((with-clause . 297)
+ (statement-continuation . 297))
+ (((block-end defun "iota")
+ . 278)
+ ((in-begin-block defun "iota")
+ . 278))
+ ((toplevel . 1))
+ ((toplevel . 1))
+ (((defun-start "iota")
+ . 445))
+ (((block-start begin)
+ . 445)
+ ((defun-start "iota")
+ . 445))
+ (((in-begin-block defun "iota")
+ . 502))
+ ((nested-statement-open . 537)
+ (statement-continuation . 537))
+ ((select-clause . 543)
+ (nested-statement-continuation . 537)
+ (statement-continuation . 537))
+ ((select-clause . 543)
+ (nested-statement-continuation . 537)
+ (statement-continuation . 537))
+ ((select-clause . 543)
+ (nested-statement-continuation . 537)
+ (statement-continuation . 537))
+ ((select-clause . 543)
+ (nested-statement-continuation . 537)
+ (statement-continuation . 537))
+ ((nested-statement-close . 537)
+ (statement-continuation . 537))
+ ((with-clause . 510)
+ (statement-continuation . 510))
+ (((block-end defun "iota")
+ . 502)
+ ((in-begin-block defun "iota")
+ . 502))
+ ((toplevel . 1)))
diff --git a/test-data/pr106.sql b/test-data/pr106.sql
new file mode 100644
index 0000000000..24d23ecf5e
--- /dev/null
+++ b/test-data/pr106.sql
@@ -0,0 +1,38 @@
+CREATE FUNCTION iota (count INT)
+ RETURNS TABLE (n INT)
+BEGIN ATOMIC
+ WITH RECURSIVE iota (n) AS (
+ SELECT 1 AS n
+ UNION ALL
+ SELECT n + 1
+ FROM iota
+ WHERE n < count
+ )
+ SELECT * FROM iota;
+END;
+
+CREATE FUNCTION iota (count INT)
+ RETURNS TABLE (n INT)
+BEGIN NOT ATOMIC
+ WITH RECURSIVE iota (n) AS (
+ SELECT 1 AS n
+ UNION ALL
+ SELECT n + 1
+ FROM iota
+ WHERE n < count
+ )
+ SELECT * FROM iota;
+END;
+
+CREATE FUNCTION iota (count INT)
+ RETURNS TABLE (n INT)
+BEGIN
+ WITH RECURSIVE iota (n) AS (
+ SELECT 1 AS n
+ UNION ALL
+ SELECT n + 1
+ FROM iota
+ WHERE n < count
+ )
+ SELECT * FROM iota;
+END;