Commit 134f680
feat: code review fixes and LSP enhancements (#129)
* fix: address critical issues from code review
CRITICAL fixes:
- Fix unchecked type assertions in alter.go (RoleOption.String())
- Fix unchecked type assertions in value.go (Value.String())
- Fix race condition in metrics.go using atomic operations
- Fix race condition in LSP documents.go with defensive copy
- Fix race condition in watch.go with RWMutex protection
HIGH priority fixes:
- Add missing Node interface methods to WindowFrameBound
- Fix LSP hover returning nil instead of empty response
MEDIUM priority fixes:
- Add semantic error builders (E3001-E3004) for UndefinedTable,
UndefinedColumn, TypeMismatch, AmbiguousColumn
- Add missing object pools for FunctionCall, CaseExpression,
BetweenExpression, InExpression, SubqueryExpression, CastExpression
- Improve UTF-8 handling in LSP GetWordAtPosition
All changes verified with race detection tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: add MATERIALIZED CTE support and improve metrics
Features:
- Add MATERIALIZED/NOT MATERIALIZED parsing for CTEs (SQL standard)
- Add comprehensive parser and AST metrics tracking
- Add pool metrics for AST, statement, and expression objects
Fixes:
- Fix tokenizer negative column numbers in toSQLPosition
- Correct column calculation to be consistently 1-based
Metrics additions:
- RecordParse() for parser operation tracking
- RecordASTPoolGet/Put() for AST pool metrics
- RecordStatementPoolGet/Put() for statement pool metrics
- RecordExpressionPoolGet/Put() for expression pool metrics
- Extended Stats struct with parser and pool metrics
Tests:
- Add TestParser_MaterializedCTE test cases
- Update tokenizer error location test for correct column value
- Add column validation to fuzz tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat(lsp): add documentSymbol, signatureHelp, and codeAction methods
- Add textDocument/documentSymbol for SQL statement outline
- Add textDocument/signatureHelp with signatures for 20+ SQL functions
- Add textDocument/codeAction for quick fixes (semicolon, uppercase)
- Add protocol types: DocumentSymbol, SignatureHelp, CodeAction, etc.
- Update ServerCapabilities to advertise new features
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: improve LSP security and AST pool efficiency
LSP Server Security:
- Add rate limiting (100 requests/second) to prevent DoS
- Add content length validation (max 10MB per message)
- Add document size limits (max 5MB for validation)
- Improve error handling for malformed JSON-RPC requests
- Add missing LSP error codes (RequestCancelled, etc.)
AST Pool Efficiency:
- Convert recursive PutExpression() to iterative approach with work queue
- Add MaxCleanupDepth and MaxWorkQueueSize limits to prevent stack overflow
- Add pools for missing expression types: ExistsExpression, AnyExpression,
AllExpression, ListExpression, UnaryExpression, ExtractExpression,
PositionExpression, SubstringExpression
- Update PutSelectStatement to use iterative expression cleanup
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Ajit Pratap Singh <ajitpratapsingh@Ajits-Mac-mini.local>
Co-authored-by: Claude <noreply@anthropic.com>1 parent a0b5675 commit 134f680
17 files changed
Lines changed: 1737 additions & 103 deletions
File tree
- cmd/gosqlx/cmd
- pkg
- errors
- lsp
- metrics
- sql
- ast
- parser
- tokenizer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
| 126 | + | |
122 | 127 | | |
| 128 | + | |
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
| |||
228 | 234 | | |
229 | 235 | | |
230 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
231 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
232 | 246 | | |
233 | 247 | | |
234 | 248 | | |
| |||
291 | 305 | | |
292 | 306 | | |
293 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
294 | 311 | | |
295 | 312 | | |
296 | 313 | | |
| |||
328 | 345 | | |
329 | 346 | | |
330 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
331 | 351 | | |
332 | 352 | | |
333 | 353 | | |
| |||
358 | 378 | | |
359 | 379 | | |
360 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
361 | 393 | | |
362 | 394 | | |
363 | | - | |
364 | | - | |
| 395 | + | |
| 396 | + | |
365 | 397 | | |
366 | 398 | | |
367 | 399 | | |
368 | 400 | | |
369 | | - | |
| 401 | + | |
370 | 402 | | |
371 | 403 | | |
372 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
| |||
138 | 151 | | |
139 | 152 | | |
140 | 153 | | |
| 154 | + | |
141 | 155 | | |
142 | 156 | | |
143 | 157 | | |
144 | 158 | | |
145 | 159 | | |
146 | 160 | | |
147 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
148 | 164 | | |
149 | 165 | | |
150 | 166 | | |
151 | | - | |
| 167 | + | |
152 | 168 | | |
153 | 169 | | |
154 | 170 | | |
155 | 171 | | |
156 | | - | |
| 172 | + | |
157 | 173 | | |
158 | 174 | | |
159 | 175 | | |
160 | 176 | | |
161 | | - | |
| 177 | + | |
162 | 178 | | |
163 | 179 | | |
164 | 180 | | |
165 | 181 | | |
166 | 182 | | |
167 | 183 | | |
168 | 184 | | |
169 | | - | |
| 185 | + | |
170 | 186 | | |
171 | 187 | | |
172 | 188 | | |
| |||
0 commit comments