Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bd9e0a9
Add PostgreSQL PARTITION OF syntax support (#2042).
fmguerreiro Dec 8, 2025
4954465
Rename crate to pgmold-sqlparser for crates.io publishing.
fmguerreiro Jan 5, 2026
eb495f2
Add SECURITY DEFINER/INVOKER support for PostgreSQL functions.
fmguerreiro Jan 5, 2026
4094fc8
Add SET configuration_parameter support for PostgreSQL functions.
fmguerreiro Jan 5, 2026
17910f2
Bump version to 0.60.1 and add missing Spanned impls.
fmguerreiro Jan 5, 2026
4176b66
feat(ddl): add ForceRowLevelSecurity and NoForceRowLevelSecurity ALTE…
fmguerreiro Mar 30, 2026
ff0cada
chore: bump version to 0.60.4 (#2)
fmguerreiro Mar 30, 2026
723a21c
feat(data-type): add SETOF type modifier for PostgreSQL function retu…
fmguerreiro Mar 30, 2026
f146c47
feat(ast): add ExclusionConstraint and ExclusionElement types
fmguerreiro Apr 16, 2026
c021efb
feat(parser): parse EXCLUDE constraints in CREATE TABLE and ALTER TABLE
fmguerreiro Apr 16, 2026
c1227c9
test: add EXCLUDE constraint parsing tests
fmguerreiro Apr 16, 2026
d819ea0
chore: bump version to 0.60.6
fmguerreiro Apr 16, 2026
c76e088
Merge pull request #4 from fmguerreiro/feat/exclude-constraint
fmguerreiro Apr 16, 2026
8aaef8d
Merge remote-tracking branch 'upstream/main' into chore/merge-upstrea…
fmguerreiro Apr 17, 2026
b23f2ab
Merge pull request #5 from fmguerreiro/chore/merge-upstream-main
fmguerreiro Apr 17, 2026
a736c67
fix: add missing doc comments on ExclusionConstraint fields
fmguerreiro Apr 17, 2026
613c05f
feat(ast): add CreateForeignDataWrapper and CreateForeignTable types
fmguerreiro Apr 17, 2026
3d90838
feat(ast): add CREATE TEXT SEARCH CONFIGURATION/DICTIONARY/PARSER/TEM…
fmguerreiro Apr 17, 2026
8ecb6c9
feat(parser): parse CREATE FOREIGN DATA WRAPPER and CREATE FOREIGN TABLE
fmguerreiro Apr 17, 2026
82d6848
feat(parser): parse CREATE TEXT SEARCH statements
fmguerreiro Apr 17, 2026
7688828
test: add CREATE TEXT SEARCH round-trip tests
fmguerreiro Apr 17, 2026
ef2ce41
test: add CREATE FOREIGN DATA WRAPPER and CREATE FOREIGN TABLE tests
fmguerreiro Apr 17, 2026
6774b8a
feat(ast): add CreateAggregate type
fmguerreiro Apr 17, 2026
7f7ac31
feat(parser): parse CREATE AGGREGATE
fmguerreiro Apr 17, 2026
aff2e81
test: add CREATE AGGREGATE round-trip tests
fmguerreiro Apr 17, 2026
bf190c0
Merge pull request #6 from fmguerreiro/feat/text-search
fmguerreiro Apr 18, 2026
b131719
Merge remote-tracking branch 'origin/main' into feat/create-aggregate
fmguerreiro Apr 18, 2026
287f90f
Merge remote-tracking branch 'origin/main' into feat/foreign-table-fdw
fmguerreiro Apr 18, 2026
7b14532
Merge pull request #7 from fmguerreiro/feat/create-aggregate
fmguerreiro Apr 18, 2026
c7262b0
Merge remote-tracking branch 'origin/main' into feat/foreign-table-fdw
fmguerreiro Apr 18, 2026
aff2ffd
Merge pull request #8 from fmguerreiro/feat/foreign-table-fdw
fmguerreiro Apr 18, 2026
1fb2b6b
chore: bump version to 0.60.8
fmguerreiro Apr 18, 2026
8248173
Merge pull request #9 from fmguerreiro/chore/release-0.60.8
fmguerreiro Apr 18, 2026
3b35809
fix(spans): add Span::empty() arm for CreateAggregate
fmguerreiro Apr 18, 2026
18b7650
Merge pull request #10 from fmguerreiro/fix/span-create-aggregate
fmguerreiro Apr 18, 2026
35160e8
feat(ast): add CreatePublication and CreateSubscription AST nodes
fmguerreiro Apr 18, 2026
ccf2756
feat(ast): add AlterDomain, AlterTrigger, AlterExtension, extend Alte…
fmguerreiro Apr 18, 2026
145ef5f
Merge pull request #11 from fmguerreiro/feat/logical-repl
fmguerreiro Apr 18, 2026
30cd573
Merge remote-tracking branch 'origin/main' into feat/alter-set
fmguerreiro Apr 18, 2026
2eba8c2
Merge pull request #12 from fmguerreiro/feat/alter-set
fmguerreiro Apr 18, 2026
4bffb07
chore: bump version to 0.60.9
fmguerreiro Apr 18, 2026
4c4d773
Merge pull request #13 from fmguerreiro/chore/release-0.60.9
fmguerreiro Apr 18, 2026
ceb1cf3
feat(ast): add CreateStatistics, CreateAccessMethod, CreateEventTrigg…
fmguerreiro Apr 18, 2026
8c97e3d
feat(parser): parse CREATE STATISTICS, ACCESS METHOD, EVENT TRIGGER, …
fmguerreiro Apr 18, 2026
2be0202
test: add round-trip tests for CREATE STATISTICS, ACCESS METHOD, EVEN…
fmguerreiro Apr 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .worktrees/fix-pr-2307-ci
Submodule fix-pr-2307-ci added at 90803e
90 changes: 90 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Build & Test Commands

```bash
# Build
cargo build
cargo build --all-features

# Run all tests
cargo test --all-features

# Run a single test
cargo test test_name --all-features

# Run tests for a specific dialect
cargo test sqlparser_postgres --all-features

# Lint
cargo clippy --all-targets --all-features -- -D warnings

# Format
cargo fmt --all

# Check (faster than full build)
cargo check --all-targets --all-features

# Build docs
cargo doc --document-private-items --no-deps --workspace --all-features

# Run benchmarks (from sqlparser_bench directory)
cd sqlparser_bench && cargo bench
```

## Crate Features

- `serde`: Adds Serialize/Deserialize for all AST nodes
- `visitor`: Adds a Visitor for recursively walking the AST
- `recursive-protection` (default): Stack overflow protection
- `json_example`: For CLI example only

## Architecture

This is an extensible SQL lexer and parser that produces an Abstract Syntax Tree (AST).

### Core Components

- **`src/tokenizer.rs`**: Lexer that converts SQL text into tokens. `Tokenizer::new(dialect, sql).tokenize()` returns `Vec<TokenWithLocation>`.

- **`src/parser/mod.rs`**: Recursive descent parser using Pratt parsing for expressions. Entry point is `Parser::parse_sql(&dialect, sql)` returning `Vec<Statement>`.

- **`src/ast/mod.rs`**: AST type definitions. `Statement` is the top-level enum. Key types: `Query`, `Select`, `Expr`, `DataType`, `ObjectName`.

- **`src/dialect/mod.rs`**: SQL dialect trait and implementations. Each dialect (PostgreSQL, MySQL, etc.) customizes parsing behavior. `GenericDialect` is the most permissive.

### Dialect System

Dialects customize parsing via the `Dialect` trait. Methods control identifier quoting, keyword handling, and syntax variations. Dialect-specific features should work with both the specific dialect AND `GenericDialect`.

### Testing Patterns

Tests use `TestedDialects` from `src/test_utils.rs`:

```rust
use sqlparser::test_utils::*;

// Test across all dialects
all_dialects().verified_stmt("SELECT 1");

// Test specific dialects
TestedDialects::new(vec![Box::new(PostgreSqlDialect {})]).verified_stmt("...");

// Test all dialects except specific ones
all_dialects_except(|d| d.is::<MySqlDialect>()).verified_stmt("...");
```

Key test helpers:
- `verified_stmt(sql)`: Parse and verify round-trip serialization
- `verified_query(sql)`: Same but returns `Query`
- `one_statement_parses_to(sql, canonical)`: Test with different canonical form

### Round-Trip Invariant

AST nodes implement `Display` to reproduce the original SQL (minus comments/whitespace). Tests verify `parse(sql).to_string() == sql`.

### Source Spans

AST nodes include `Span` information for source locations. When constructing AST nodes manually, use `Span::empty()`.
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
# under the License.

[package]
name = "sqlparser"
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"
version = "0.61.0"
authors = ["Apache DataFusion <dev@datafusion.apache.org>"]
homepage = "https://github.com/apache/datafusion-sqlparser-rs"
documentation = "https://docs.rs/sqlparser/"
keywords = ["ansi", "sql", "lexer", "parser"]
repository = "https://github.com/apache/datafusion-sqlparser-rs"
name = "pgmold-sqlparser"
description = "Fork of sqlparser with additional PostgreSQL features (PARTITION OF, SECURITY DEFINER/INVOKER, SET params, EXCLUDE, TEXT SEARCH, AGGREGATE, FOREIGN TABLE/FDW, PUBLICATION, SUBSCRIPTION, ALTER DOMAIN/TRIGGER/EXTENSION)"
version = "0.60.9"
authors = ["Filipe Guerreiro <filipe.m.guerreiro@gmail.com>"]
homepage = "https://github.com/fmguerreiro/datafusion-sqlparser-rs"
documentation = "https://docs.rs/pgmold-sqlparser/"
keywords = ["ansi", "sql", "lexer", "parser", "postgresql"]
repository = "https://github.com/fmguerreiro/datafusion-sqlparser-rs"
license = "Apache-2.0"
include = [
"src/**/*.rs",
Expand Down
6 changes: 6 additions & 0 deletions src/ast/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ pub enum DataType {
///
/// [PostgreSQL]: https://www.postgresql.org/docs/current/plpgsql-trigger.html
Trigger,
/// SETOF type modifier for [PostgreSQL] function return types,
/// e.g. `CREATE FUNCTION ... RETURNS SETOF text`.
///
/// [PostgreSQL]: https://www.postgresql.org/docs/current/sql-createfunction.html
SetOf(Box<DataType>),
/// Any data type, used in BigQuery UDF definitions for templated parameters, see [BigQuery].
///
/// [BigQuery]: https://cloud.google.com/bigquery/docs/user-defined-functions#templated-sql-udf-parameters
Expand Down Expand Up @@ -796,6 +801,7 @@ impl fmt::Display for DataType {
}
DataType::Unspecified => Ok(()),
DataType::Trigger => write!(f, "TRIGGER"),
DataType::SetOf(inner) => write!(f, "SETOF {inner}"),
DataType::AnyType => write!(f, "ANY TYPE"),
DataType::Table(fields) => match fields {
Some(fields) => {
Expand Down
Loading
Loading