Skip to content

Commit 646d8cf

Browse files
Ajit Pratap Singhclaude
authored andcommitted
docs: comprehensive documentation update for v1.4+ features
## docs/README.md - Updated to v1.5.1+ with current date - Added new documentation sections (Getting Started, CLI Guide, Error Codes) - Added Testing & Quality section (Fuzz Testing, Performance Regression) - Added Migration Guides section - Updated documentation structure to 22 files - Added Recent Feature Additions section (v1.4+) - Updated all version references from v1.0.0 to v1.5.1 ## docs/SQL_COMPATIBILITY.md - Added MERGE statement support (SQL:2003 F312) - Added GROUPING SETS, ROLLUP, CUBE section (SQL-99 T431) - Added ORDER BY Extensions (NULLS FIRST/LAST - SQL-99 F851) - Added Expression Operators section (BETWEEN, IN, LIKE, IS NULL) - Added Materialized Views and Table Partitioning to DDL - Updated test suite to 600+ test cases, 95% coverage - Added SQL-99 compliance rating (~80-85%) ## docs/SECURITY.md - Added Security Package (pkg/sql/security) section - Added SQL injection detection overview with code example - Updated security score to 9.0/10 - Added PROACTIVE finding for built-in injection detection - Updated version to v1.5.1+ ## docs/ARCHITECTURE.md - Added modular parser architecture (11 parser modules) - Updated method hierarchy with all new parsing methods - Added new AST statement types (Merge, MaterializedView, etc.) - Added new expression types (Between, In, Like, IsNull) - Added Grouping Types section (GroupingSet, Rollup, Cube) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e74fa9a commit 646d8cf

4 files changed

Lines changed: 229 additions & 41 deletions

File tree

docs/ARCHITECTURE.md

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,56 @@ The parser builds Abstract Syntax Trees from token streams.
125125
└──────────────────────────────────────┘
126126
```
127127

128-
**Parser Methods Hierarchy:**
128+
**Parser Methods Hierarchy (v1.4+ Modular Architecture):**
129+
130+
The parser is organized into logical modules for maintainability:
131+
132+
```
133+
pkg/sql/parser/
134+
├── parser.go # Core parser and entry points
135+
├── select.go # SELECT statement parsing
136+
├── dml.go # INSERT, UPDATE, DELETE parsing
137+
├── cte.go # Common Table Expressions (WITH clause)
138+
├── expressions.go # Expression parsing (BETWEEN, IN, LIKE, etc.)
139+
├── window.go # Window functions (OVER, PARTITION BY)
140+
├── grouping.go # GROUPING SETS, ROLLUP, CUBE
141+
├── alter.go # ALTER TABLE statements
142+
├── create.go # CREATE statements (TABLE, VIEW, INDEX)
143+
├── drop.go # DROP statements
144+
├── merge.go # MERGE statements (SQL:2003)
145+
└── token_converter.go # Token format conversion
146+
```
147+
148+
**Method Hierarchy:**
129149

130150
```
131151
Parse()
132152
├── parseStatement()
133-
│ ├── parseSelectStatement()
153+
│ ├── parseWithStatement() # CTEs (cte.go)
154+
│ ├── parseSelectWithSetOperations() # SELECT + UNION/EXCEPT/INTERSECT (select.go)
134155
│ │ ├── parseSelectClause()
135156
│ │ ├── parseFromClause()
136157
│ │ ├── parseJoinClause()
137158
│ │ ├── parseWhereClause()
138-
│ │ ├── parseGroupByClause()
159+
│ │ ├── parseGroupByClause() # Includes GROUPING SETS (grouping.go)
139160
│ │ ├── parseHavingClause()
140-
│ │ └── parseOrderByClause()
141-
│ ├── parseInsertStatement()
142-
│ ├── parseUpdateStatement()
143-
│ ├── parseDeleteStatement()
144-
│ └── parseDDLStatement()
145-
└── parseExpression()
161+
│ │ └── parseOrderByClause() # Includes NULLS FIRST/LAST
162+
│ ├── parseInsertStatement() # (dml.go)
163+
│ ├── parseUpdateStatement() # (dml.go)
164+
│ ├── parseDeleteStatement() # (dml.go)
165+
│ ├── parseMergeStatement() # (merge.go)
166+
│ ├── parseCreateStatement() # (create.go) - TABLE, VIEW, MATERIALIZED VIEW, INDEX
167+
│ ├── parseAlterStatement() # (alter.go)
168+
│ └── parseDropStatement() # (drop.go)
169+
└── parseExpression() # (expressions.go)
146170
├── parsePrimaryExpression()
147171
├── parseBinaryExpression()
172+
├── parseBetweenExpression()
173+
├── parseInExpression()
174+
├── parseLikeExpression()
175+
├── parseIsNullExpression()
148176
├── parseFunctionCall()
177+
│ └── parseWindowSpec() # (window.go)
149178
└── parseSubquery()
150179
```
151180

@@ -167,21 +196,47 @@ The Abstract Syntax Tree represents the structure of SQL statements.
167196
│ │ ├── Columns: []Expression │ │
168197
│ │ ├── From: []Table │ │
169198
│ │ ├── Where: Expression │ │
199+
│ │ ├── GroupBy: []GroupingElement │ │
170200
│ │ └── ... │ │
171201
│ └────────────────────────────┘ │
172202
│ ┌────────────────────────────┐ │
173-
│ │ InsertStatement │ │
174-
│ │ UpdateStatement │ │
175-
│ │ DeleteStatement │ │
176-
│ │ CreateTableStatement │ │
203+
│ │ DML Statements │ │
204+
│ │ ├── InsertStatement │ │
205+
│ │ ├── UpdateStatement │ │
206+
│ │ ├── DeleteStatement │ │
207+
│ │ └── MergeStatement (v1.4+) │ │
208+
│ └────────────────────────────┘ │
209+
│ ┌────────────────────────────┐ │
210+
│ │ DDL Statements │ │
211+
│ │ ├── CreateTableStatement │ │
212+
│ │ ├── CreateViewStatement │ │
213+
│ │ ├── CreateMaterializedView │ │
214+
│ │ ├── CreateIndexStatement │ │
215+
│ │ ├── AlterTableStatement │ │
216+
│ │ ├── DropTableStatement │ │
217+
│ │ └── RefreshMaterializedView│ │
177218
│ └────────────────────────────┘ │
178219
├──────────────────────────────────────┤
179220
│ Expression Types │
180221
│ ┌────────────────────────────┐ │
181222
│ │ BinaryExpression │ │
223+
│ │ UnaryExpression │ │
182224
│ │ FunctionCall │ │
225+
│ │ WindowFunction (v1.3+) │ │
183226
│ │ Identifier │ │
184227
│ │ Literal │ │
228+
│ │ BetweenExpression (v1.4+) │ │
229+
│ │ InExpression (v1.4+) │ │
230+
│ │ LikeExpression (v1.4+) │ │
231+
│ │ IsNullExpression (v1.4+) │ │
232+
│ │ Subquery │ │
233+
│ │ CaseExpression │ │
234+
│ └────────────────────────────┘ │
235+
│ ┌────────────────────────────┐ │
236+
│ │ Grouping Types (v1.4+) │ │
237+
│ │ ├── GroupingSet │ │
238+
│ │ ├── RollupGrouping │ │
239+
│ │ └── CubeGrouping │ │
185240
│ └────────────────────────────┘ │
186241
└──────────────────────────────────────┘
187242
```

docs/README.md

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,58 @@
22

33
Comprehensive documentation for the GoSQLX SQL parsing SDK.
44

5+
**Current Version**: v1.5.1+ | **Last Updated**: November 2025
6+
57
## 📚 Documentation Index
68

9+
### Getting Started
10+
11+
| Document | Description | Audience |
12+
|----------|-------------|----------|
13+
| [**GETTING_STARTED.md**](GETTING_STARTED.md) | 5-minute quickstart guide for new users | Beginners |
14+
| [**CLI_GUIDE.md**](CLI_GUIDE.md) | Command-line tool usage and examples | CLI Users |
15+
716
### Core Documentation
817

918
| Document | Description | Audience |
1019
|----------|-------------|----------|
11-
| [**API_REFERENCE.md**](API_REFERENCE.md) | Complete API documentation with method signatures, parameters, and examples | Developers |
20+
| [**API_REFERENCE.md**](API_REFERENCE.md) | Complete API documentation with 4,400+ lines of examples | Developers |
1221
| [**USAGE_GUIDE.md**](USAGE_GUIDE.md) | Detailed usage patterns, best practices, and real-world examples | All Users |
1322
| [**ARCHITECTURE.md**](ARCHITECTURE.md) | System design, component architecture, and internal implementation | Contributors/Advanced |
1423
| [**TROUBLESHOOTING.md**](TROUBLESHOOTING.md) | Common issues, error messages, debugging techniques, and FAQ | Support/Debug |
1524

25+
### Reference Documentation
26+
27+
| Document | Description | Audience |
28+
|----------|-------------|----------|
29+
| [**ERROR_CODES.md**](ERROR_CODES.md) | Comprehensive error code reference (E1xxx-E4xxx) | Developers |
30+
| [**ERROR_REFERENCE.md**](ERROR_REFERENCE.md) | Error handling patterns and recovery strategies | Developers |
31+
| [**sql99-compliance-analysis.md**](sql99-compliance-analysis.md) | SQL-99 standard compliance analysis (~80-85%) | Architects |
32+
1633
### Deployment & Operations
1734

1835
| Document | Description | Audience |
1936
|----------|-------------|----------|
2037
| [**PRODUCTION_GUIDE.md**](PRODUCTION_GUIDE.md) | Production deployment, monitoring, and performance optimization | DevOps/SRE |
38+
| [**PERFORMANCE_TUNING.md**](PERFORMANCE_TUNING.md) | Performance optimization and benchmarking guide | Performance Engineers |
2139
| [**SQL_COMPATIBILITY.md**](SQL_COMPATIBILITY.md) | SQL dialect support matrix and feature compatibility | Architects |
22-
| [**SECURITY.md**](SECURITY.md) | Security analysis, vulnerability assessment, and best practices | Security Teams |
40+
| [**SECURITY.md**](SECURITY.md) | Security analysis, vulnerability assessment, and SQL injection detection | Security Teams |
41+
42+
### Testing & Quality
43+
44+
| Document | Description | Audience |
45+
|----------|-------------|----------|
46+
| [**FUZZ_TESTING_GUIDE.md**](FUZZ_TESTING_GUIDE.md) | Fuzz testing methodology and coverage | QA Engineers |
47+
| [**performance_regression_testing.md**](performance_regression_testing.md) | Performance regression testing guide | QA Engineers |
48+
| [**COMPARISON.md**](COMPARISON.md) | Comparison with other SQL parsers | Evaluators |
2349

24-
### Release Information
50+
### Migration Guides
2551

26-
| Document | Description | Version |
27-
|----------|-------------|---------|
28-
| [**RELEASE_v1.0.md**](RELEASE_v1.0.md) | v1.0.0 release notes, features, and validation results | v1.0.0 |
52+
| Document | Description |
53+
|----------|-------------|
54+
| [**migration/FROM_JSQLPARSER.md**](migration/FROM_JSQLPARSER.md) | Migrating from JSqlParser |
55+
| [**migration/FROM_PG_QUERY.md**](migration/FROM_PG_QUERY.md) | Migrating from pg_query |
56+
| [**migration/FROM_SQLFLUFF.md**](migration/FROM_SQLFLUFF.md) | Migrating from SQLFluff |
2957

3058
## 🚀 Quick Start Guides
3159

@@ -48,15 +76,27 @@ Comprehensive documentation for the GoSQLX SQL parsing SDK.
4876

4977
```
5078
docs/
51-
├── API_REFERENCE.md # API documentation
79+
├── README.md # This documentation index
80+
├── GETTING_STARTED.md # 5-minute quickstart guide
81+
├── CLI_GUIDE.md # CLI tool documentation
82+
├── API_REFERENCE.md # Complete API documentation (4,400+ lines)
5283
├── USAGE_GUIDE.md # Usage patterns and examples
5384
├── ARCHITECTURE.md # System architecture
5485
├── TROUBLESHOOTING.md # Problem solving guide
5586
├── PRODUCTION_GUIDE.md # Production deployment
87+
├── PERFORMANCE_TUNING.md # Performance optimization
5688
├── SQL_COMPATIBILITY.md # SQL dialect matrix
57-
├── SECURITY.md # Security analysis
58-
├── RELEASE_v1.0.md # Release notes
59-
└── README.md # This file
89+
├── SECURITY.md # Security analysis
90+
├── ERROR_CODES.md # Error code reference
91+
├── ERROR_REFERENCE.md # Error handling guide
92+
├── COMPARISON.md # Parser comparison
93+
├── FUZZ_TESTING_GUIDE.md # Fuzz testing guide
94+
├── sql99-compliance-analysis.md # SQL-99 compliance
95+
├── CLEAN_ARCHITECTURE.md # Architecture principles
96+
└── migration/ # Migration guides
97+
├── FROM_JSQLPARSER.md
98+
├── FROM_PG_QUERY.md
99+
└── FROM_SQLFLUFF.md
60100
```
61101

62102
## 🔍 Finding Information
@@ -161,13 +201,28 @@ If you can't find what you need:
161201

162202
| Document | Last Updated | Version |
163203
|----------|--------------|---------|
164-
| API_REFERENCE.md | 2024-08 | v1.0.0 |
165-
| USAGE_GUIDE.md | 2024-08 | v1.0.0 |
166-
| ARCHITECTURE.md | 2024-08 | v1.0.0 |
167-
| TROUBLESHOOTING.md | 2024-08 | v1.0.0 |
168-
| PRODUCTION_GUIDE.md | 2024-08 | v1.0.0 |
169-
| SQL_COMPATIBILITY.md | 2024-08 | v1.0.0 |
170-
| SECURITY.md | 2024-08 | v1.0.0 |
204+
| API_REFERENCE.md | 2025-11 | v1.5.1 |
205+
| GETTING_STARTED.md | 2025-11 | v1.5.1 |
206+
| CLI_GUIDE.md | 2025-11 | v1.5.1 |
207+
| USAGE_GUIDE.md | 2025-11 | v1.5.1 |
208+
| ARCHITECTURE.md | 2025-11 | v1.5.1 |
209+
| TROUBLESHOOTING.md | 2025-11 | v1.5.1 |
210+
| PRODUCTION_GUIDE.md | 2025-11 | v1.5.1 |
211+
| SQL_COMPATIBILITY.md | 2025-11 | v1.5.1 |
212+
| SECURITY.md | 2025-11 | v1.5.1 |
213+
| ERROR_CODES.md | 2025-11 | v1.5.1 |
214+
| PERFORMANCE_TUNING.md | 2025-11 | v1.5.1 |
215+
216+
## 🆕 Recent Feature Additions (v1.4+)
217+
218+
- **SQL Injection Detection** - `pkg/sql/security` package for pattern detection
219+
- **MERGE Statements** - SQL Server/PostgreSQL MERGE support
220+
- **Grouping Sets** - ROLLUP, CUBE, GROUPING SETS (SQL-99 T431)
221+
- **Materialized Views** - CREATE/DROP/REFRESH MATERIALIZED VIEW
222+
- **Table Partitioning** - PARTITION BY RANGE/LIST/HASH
223+
- **Advanced Operators** - BETWEEN, IN, LIKE, IS NULL with full expression support
224+
- **Subquery Support** - Scalar, table, correlated, EXISTS subqueries
225+
- **NULLS FIRST/LAST** - ORDER BY with null ordering (SQL-99 F851)
171226

172227
---
173228

docs/SECURITY.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,45 @@
22

33
## 🛡️ Comprehensive Security Assessment
44

5-
**Analysis Date**: August 2025
6-
**Version**: v1.0.0
7-
**Security Score**: 8.5/10 ⭐⭐⭐⭐⭐
5+
**Analysis Date**: November 2025
6+
**Version**: v1.5.1+
7+
**Security Score**: 9.0/10 ⭐⭐⭐⭐⭐
88

99
---
1010

1111
## 📋 Executive Summary
1212

1313
GoSQLX has undergone a comprehensive security analysis across 7 critical security domains. The library demonstrates **strong security characteristics** suitable for production deployment with **minimal security concerns**.
1414

15+
### 🆕 Security Package (v1.4+)
16+
17+
GoSQLX now includes a dedicated **SQL Injection Detection** package (`pkg/sql/security`) that provides:
18+
19+
- **8 Pattern Types**: Tautology, Comment Bypass, Stacked Query, UNION-based, Time-based, Boolean-based, Out-of-Band, Dangerous Functions
20+
- **4 Severity Levels**: CRITICAL, HIGH, MEDIUM, LOW
21+
- **Multi-Database Support**: PostgreSQL, MySQL, SQL Server, SQLite system table detection
22+
- **Thread-Safe**: Safe for concurrent use across goroutines
23+
- **High Performance**: 100,000+ queries/second scanning throughput
24+
25+
```go
26+
import "github.com/ajitpratap0/GoSQLX/pkg/sql/security"
27+
28+
scanner := security.NewScanner()
29+
result := scanner.Scan(ast)
30+
if result.HasCritical() {
31+
// Block potentially malicious query
32+
}
33+
```
34+
35+
See [API_REFERENCE.md#security-package](API_REFERENCE.md#security-package) for complete documentation.
36+
1537
### 🎯 Key Security Findings
1638

17-
**SECURE**: No critical vulnerabilities identified
18-
**HARDENED**: Robust input validation and error handling
19-
**RESILIENT**: Excellent memory safety and resource management
20-
**COMPLIANT**: Safe Unicode handling across international character sets
39+
**SECURE**: No critical vulnerabilities identified
40+
**HARDENED**: Robust input validation and error handling
41+
**RESILIENT**: Excellent memory safety and resource management
42+
**COMPLIANT**: Safe Unicode handling across international character sets
43+
**PROACTIVE**: Built-in SQL injection pattern detection (NEW in v1.4+)
2144
⚠️ **MONITOR**: Large input processing requires operational monitoring
2245

2346
---

0 commit comments

Comments
 (0)