ScriptDom interprets ambiguously the next word right after transaction control statement
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia riproducendo gli esempi di BEGIN, SAVE, COMMIT e ROLLBACK con i livelli di compatibilità 150 e 160 di ScriptDom. Verifica come vengono classificati i nomi delle transazioni e le istruzioni successive costituite da una sola parola, quindi definisci il comportamento previsto per casi come THROW e CONTINUE; l'issue è completata quando l'ambiguità viene risolta o viene fornito un avviso in modo coerente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
- ScriptDom Version: 161.8910.0
- CompatibilityLevel used for parsing: 150, 160
Some keywords written right next to the transaction control statement are treated as transaction name and some as a separate command/next statement. This may lead to significant misunderstanding of what the code will actually do.
Statements:
- BEGIN TRAN
- SAVE TRAN
- COMMIT TRAN
- ROLLBACK TRAN
Examples of keywords/statements treated as valid identifier for transaction name:
- THROW
- RECEIVE
- SEND
Steps to Reproduce:
If you write BEGIN TRAN THROW - here THROW will be treated as a valid transaction name. However in BEGIN TRAN CONTINUE the CONTINUE will be treated as a separate command. BEGIN/COMMIT/ROLLBACK behave similarly - they can take modern keywords/commands as a valid tran name but "ignore" "oldschool" keywords/commands and treat them as a separate statement even if no statement terminator is present between them. SAVE TRAN unlikely mentioned statements requires transaction name to be provided and if the next word is parsed as an invalid tran identifier candidate the parsing fails with syntax error.
Examples of ambiguity:
COMMIT TRAN CONTINUE
COMMIT TRAN BREAK
COMMIT TRAN THROW -- tran name
COMMIT TRAN RECEIVE -- tran name
COMMIT TRAN SEND -- tran name
COMMIT TRAN RETURN
COMMIT TRAN COMMIT
COMMIT TRAN ROLLBACK
in all lines not marked with comment the last word is treated as a separate statement.
SAVE TRAN requires third word in statement and in all lines except marked with comment parser would say that syntax is broken:
The most ambiguous case to me is this one:
BEGIN TRY
BEGIN TRAN
SELECT 1 / 0
COMMIT TRAN
END TRY
BEGIN CATCH
ROLLBACK TRAN
THROW -- "Divide by zero" error will not be rethrown here
-- new error will be generated:
-- Cannot roll back THROW. No transaction or savepoint of that name was found
END CATCH
On ROLLBACK TRAN docs page it is said that transaction name must be a valid identifier, identifier is valid if it does not match any of reserved words and THROW is not listed there. On THROW docs page it is said that preceding statement must end with semicolon. Thus ROLLBACK TRAN THROW in the example above behaves expectedly speaking of the docs. But it is an error so easy to make and you need so much to remember to avoid it while coding.
It would be great if
- all one-word statements were included into reserved keywords (especially
THROW); maybe in future compatibility levels - SSDT/DacFx would show at least a warning in such cases and recommend to put semicolon before
THROWor choose another identifier for transaction name
As a workaround I'm developing another rule for our custom linter which would detect such suspicious cases.
(DacFx/SqlPackage/SSMS/Azure Data Studio)
- Lingua principale
- GAP
- Stelle
- 277
- Fork
- 43
- Merge medio
- 6g 17h
- PR unite (30g)
- 3
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/SqlScriptDOM
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/SqlScriptDOM#228 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/SqlScriptDOM#183 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
microsoft/SqlScriptDOM#226 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
microsoft/SqlScriptDOM#225 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
microsoft/SqlScriptDOM#224 ·
Tutte le issue di microsoft/SqlScriptDOM
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
objectionary/jeo-maven-plugin#1774 ·
-
compiler/runtime
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
leanprover/lean4#15255 ·
-
bot-triaged module: correctness (silent) module: fx release triage triage review
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
Grammar Gap: activated › effect clause › {self} deals damage equal to its power to target creature Apertaarea:mechanics ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
fil-donadoni/tolaria#4317 ·