Commit a971343
committed
Fix nil pointer dereference in skip_parser with managed database
The skip_parser feature was failing with a nil pointer dereference when
used with managed databases because parseCatalog() was trying to use
the parser and catalog, which are nil when skip_parser is enabled.
## Root Cause
When skip_parser is enabled:
1. Parser and catalog are set to nil in NewCompiler
2. parseCatalog() was unconditionally calling c.parser.Parse() (line 46)
3. This caused a nil pointer dereference
However, parseCatalog() still needs to be called even in skip_parser
mode because:
- The schema SQL text needs to be stored in c.schema
- The database analyzer needs c.schema to pass to PostgreSQL
## Fix
Modified parseCatalog() to check if skip_parser is enabled:
- If skip_parser: Read schema files and store in c.schema, skip parsing
- If normal mode: Parse schemas and update catalog as before
Also reverted the change in generate.go that was skipping ParseCatalog
entirely, since we always need to call it (it now handles skip_parser
internally).
## Testing
This fixes the panic in the managed-db context test:
- TestReplay/managed-db/skip_parser/postgresql/pgx/v5
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent cc41ace commit a971343
2 files changed
+29
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
322 | 313 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
| 314 | + | |
| 315 | + | |
327 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
328 | 321 | | |
329 | | - | |
330 | 322 | | |
331 | 323 | | |
332 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
37 | 55 | | |
38 | 56 | | |
39 | 57 | | |
| |||
0 commit comments