Commit b317381
authored
Sync repos: Release 180.18.1 (#204)
* Merged PR 2053371: [SECURITY] Bump dotnet-sdk from 8.0.419 to 8.0.420
* Merged PR 2040726: Fix invalid OVER clause parsing - reject OVER([col]) syntax
<!-- COPILOT_AI_GENERATED_START -->
# Fix invalid OVER clause parsing - reject OVER([col]) syntax
## Summary
Fixed a parser bug where invalid OVER clause syntax like `COUNT(*) OVER([col])` was incorrectly accepted. The parser now properly rejects OVER clauses that contain only an identifier in parentheses without PARTITION BY or ORDER BY clauses.
## Problem
The parser was accepting invalid syntax such as:
```sql
SELECT COUNT(*) OVER([col]) FROM t1
SELECT SUM(Amount) OVER(MyColumn) FROM t1
```
This is invalid because an OVER clause with parentheses must contain one of:
- `PARTITION BY` clause
- `ORDER BY` clause
- Window frame clause
- Or be empty: `OVER()`
Valid window name references (introduced in SQL Server 2022) must be written WITHOUT parentheses:
```sql
SELECT SUM(c1) OVER Win1 FROM t1 WINDOW Win1 AS (PARTITION BY c1)
```
Additionally, partial window specifications CAN include a window name inside parentheses, but ONLY when combined with other clauses:
```sql
SELECT SUM(c1) OVER (Win1 ORDER BY c2) FROM t1 WINDOW Win1 AS (PARTITION BY c1)
```
## Root Cause
In SQL Server 2022 (TSql160), support was added for the WINDOW clause feature, which allows referencing named windows. The grammar rule `overClauseBeginning` was modified to accept an optional identifier inside parentheses to support partial window specifications like `OVER (Win1 PARTITION BY ...)`.
However, the rule `overClauseNoOrderBy` (used by aggregate functions like COUNT, SUM, AVG) was still using `overClauseBeginning`, which meant it would accept `OVER(identifier)` and interpret the identifier as a window name, even though no other clauses were present. This resulted in invalid syntax being accepted.
## Solution
Created a new grammar rule `overClauseBeginningNoWindowName` that does not allow window name identifiers inside parentheses. Modified `overClauseNoOrderBy` to use this new rule instead of `overClauseBeginning`.
The new rule uses explicit alternatives instead of an optional clause to ensure ANTLR properly rejects identifiers that aren't followed by the `BY` keyword:
```antlr
overClauseBeginningNoWindowName:
OVER LeftParenthesis
(
Identifier { Match("PARTITION") } BY expressionList
|
/* empty - allow OVER() with no PARTITION BY */
)
```
This ensures that when parsing `OVER([col])`, the parser will:
1. Try to match the PARTITION BY alternative
2. See the identifier but realize it's not followed by BY
3. Try the empty alternative
4. Fail because `[col]` is present when nothing was expected
5. Generate an error
## Files Modified
- `SqlScriptDom/Parser/TSql/TSql160.g` - Added `overClauseBeginningNoWindowName` rule and updated `overClauseNoOrderBy`
- `SqlScriptDom/Parser/TSql/TSql170.g` - Same changes as TSql160.g
- `SqlScriptDom/Parser/TSql/TSql180.g` - Same changes as TSql180.g
- `Test/SqlDom/ParserErrorsTests.cs` - Added `InvalidOverClauseNegative...
* Merged PR 2072841: Adding release notes for 180.18.1
Adding release notes for 180.18.1
----
#### AI description (iteration 1)
#### PR Classification
Documentation update adding release notes for version 180.18.1 of Microsoft.SqlServer.TransactSql.ScriptDom.
#### PR Summary
This pull request adds comprehensive release notes for version 180.18.1, documenting bug fixes, dependency updates, and changes to the SQL script generator.
- `/release-notes/180/180.18.1.md`: Documents platform support for .NET Framework 4.7.2, .NET 8, and .NET Standard 2.0+
- `/release-notes/180/180.18.1.md`: Lists five parser bug fixes including TRIM clause parsing, DATEADD/DATEDIFF/DATEPART function argument handling, and OVER clause validation
- `/release-notes/180/180.18.1.md`: Notes .NET SDK update to version 8.0.420 and script generator improvement for semicolon placement before trailing comments
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
---------
Co-authored-by: Dependabot <Dependabot>
Co-authored-by: GitHub Copilot <GitHub Copilot>1 parent 6e95673 commit b317381
9 files changed
Lines changed: 166 additions & 6 deletions
File tree
- SqlScriptDom/Parser/TSql
- Test/SqlDom
- Baselines160
- TestScripts
- release-notes/180
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31967 | 31967 | | |
31968 | 31968 | | |
31969 | 31969 | | |
| 31970 | + | |
| 31971 | + | |
| 31972 | + | |
| 31973 | + | |
| 31974 | + | |
31970 | 31975 | | |
31971 | 31976 | | |
31972 | 31977 | | |
| |||
31989 | 31994 | | |
31990 | 31995 | | |
31991 | 31996 | | |
31992 | | - | |
| 31997 | + | |
31993 | 31998 | | |
31994 | 31999 | | |
31995 | 32000 | | |
| |||
32021 | 32026 | | |
32022 | 32027 | | |
32023 | 32028 | | |
| 32029 | + | |
| 32030 | + | |
| 32031 | + | |
| 32032 | + | |
| 32033 | + | |
| 32034 | + | |
| 32035 | + | |
| 32036 | + | |
| 32037 | + | |
| 32038 | + | |
| 32039 | + | |
| 32040 | + | |
| 32041 | + | |
| 32042 | + | |
| 32043 | + | |
| 32044 | + | |
| 32045 | + | |
| 32046 | + | |
| 32047 | + | |
32024 | 32048 | | |
32025 | 32049 | | |
32026 | 32050 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32956 | 32956 | | |
32957 | 32957 | | |
32958 | 32958 | | |
| 32959 | + | |
| 32960 | + | |
| 32961 | + | |
| 32962 | + | |
| 32963 | + | |
32959 | 32964 | | |
32960 | 32965 | | |
32961 | 32966 | | |
| |||
32978 | 32983 | | |
32979 | 32984 | | |
32980 | 32985 | | |
32981 | | - | |
| 32986 | + | |
32982 | 32987 | | |
32983 | 32988 | | |
32984 | 32989 | | |
| |||
33010 | 33015 | | |
33011 | 33016 | | |
33012 | 33017 | | |
| 33018 | + | |
| 33019 | + | |
| 33020 | + | |
| 33021 | + | |
| 33022 | + | |
| 33023 | + | |
| 33024 | + | |
| 33025 | + | |
| 33026 | + | |
| 33027 | + | |
| 33028 | + | |
| 33029 | + | |
| 33030 | + | |
| 33031 | + | |
| 33032 | + | |
| 33033 | + | |
| 33034 | + | |
| 33035 | + | |
| 33036 | + | |
33013 | 33037 | | |
33014 | 33038 | | |
33015 | 33039 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32956 | 32956 | | |
32957 | 32957 | | |
32958 | 32958 | | |
| 32959 | + | |
| 32960 | + | |
| 32961 | + | |
| 32962 | + | |
| 32963 | + | |
32959 | 32964 | | |
32960 | 32965 | | |
32961 | 32966 | | |
| |||
32978 | 32983 | | |
32979 | 32984 | | |
32980 | 32985 | | |
32981 | | - | |
| 32986 | + | |
32982 | 32987 | | |
32983 | 32988 | | |
32984 | 32989 | | |
| |||
33010 | 33015 | | |
33011 | 33016 | | |
33012 | 33017 | | |
| 33018 | + | |
| 33019 | + | |
| 33020 | + | |
| 33021 | + | |
| 33022 | + | |
| 33023 | + | |
| 33024 | + | |
| 33025 | + | |
| 33026 | + | |
| 33027 | + | |
| 33028 | + | |
| 33029 | + | |
| 33030 | + | |
| 33031 | + | |
| 33032 | + | |
| 33033 | + | |
| 33034 | + | |
| 33035 | + | |
| 33036 | + | |
33013 | 33037 | | |
33014 | 33038 | | |
33015 | 33039 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2156 | 2156 | | |
2157 | 2157 | | |
2158 | 2158 | | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
2159 | 2194 | | |
2160 | 2195 | | |
2161 | 2196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
80 | 90 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments