Skip to content

Commit 6bfcc10

Browse files
authored
PostgreSQL: fix broken main (test compile, clippy, keyword sort, doctest) (#23)
* chore(tests): restore green main; fix clippy and keyword sort regressions `cargo test --all-features` and `cargo clippy --all-targets --all-features -- -D warnings` were both failing on `main`; CI never ran on the fork to catch it. This commit makes them green so subsequent PRs can be verified. Test compile errors: - `Statement::AlterTable` was refactored from struct to tuple form carrying `AlterTable`. Update 10 ATTACH/DETACH PARTITION test sites in `sqlparser_postgres.rs` to match the new shape. - `CreateView` gained a `with_data` field (added with the `WITH [NO] DATA` parser support). Add `with_data: _,` to 6 destructure sites in `sqlparser_common.rs`. Test runtime failures: - `all_keywords_sorted`: `CONFIGURATION`, `INLINE`, and `TRANSFORM` were inserted out of ASCII order in `keywords.rs`; move each to its alphabetical slot. - `alter_procedure_rename` / `alter_procedure_set_search_path` / `parse_fulltext_column_and_index_in_postgres`: `verified_stmt` round-trip fails because Display canonicalises type names and access methods to uppercase. Update the input SQL to match. Lib clippy regressions (forbidden via `#![forbid(clippy::unreachable)]` and `-D warnings`): - `parse_create_aggregate_options` PARALLEL arm: replace `_ => unreachable!()` with an explicit `Internal parser error` so `clippy::unreachable` is satisfied. - `parse_create_aggregate_args`: drop the let-and-return. - `parse_create_rule` INSTEAD/ALSO: collapse the always-false else-if branches into a single optional-keyword consume. Doctest: - `Statement::CreateStatistics` doc block was missing its opening ```sql fence. Spans: - Drop the duplicate `ForceRowLevelSecurity` / `NoForceRowLevelSecurity` arms in `AlterTableOperation::span()` (warnings, but `-D warnings` blocks clippy). * chore(ci): fix lint, no-std, RAT, and benchmark-lint regressions CI on `main` was failing five jobs (test/lint/compile-no-std/RAT/ benchmark-lint). The first commit on this branch fixed test compile + runtime + a few clippy and doctest issues found locally. CI surfaced the rest. This commit covers them. `lint` (clippy 1.95 — 8 collapsible_match errors) - Fold inner `if` blocks into match guards in `parse_sql` (END token delimiter), `parse_compound_field` (period-qualified identifier), the DO/loop sequence terminator, and the five `HiveRowFormat::DELIMITED` arms (FIELDS / COLLECTION / MAP / LINES / NULL DEFINED AS). `compile-no-std` (`thumbv6m-none-eabi`) - `src/ast/table_constraints.rs` introduced an EXCLUDE-constraint type with `pub operator: String` but did not import `String` in the `#[cfg(not(feature = "std"))]` alloc block. Add `string::String`. `Release Audit Tool (RAT)` - Add `CLAUDE.md` to `dev/release/rat_exclude_files.txt` next to the existing `AGENTS.md` exclusion. Both are agent-guideline files that do not need an Apache header. `benchmark-lint` - `sqlparser_bench/Cargo.toml` referenced the path-dep as `sqlparser` but the fork's package was renamed to `pgmold-sqlparser`. Add the `package = "pgmold-sqlparser"` rename so the bench resolves. Verified locally on rustc 1.95.0: cargo fmt --all -- --check cargo clippy --all-targets --all-features -- -D warnings cargo test --all-features cargo check --no-default-features --target thumbv6m-none-eabi (cd sqlparser_bench && cargo clippy --all-targets --all-features -- -D warnings)
1 parent f04ad35 commit 6bfcc10

10 files changed

Lines changed: 197 additions & 202 deletions

File tree

dev/release/rat_exclude_files.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ dev/release/rat_exclude_files.txt
66
sqlparser_bench/img/flamegraph.svg
77
**Cargo.lock
88
filtered_rat.txt
9-
AGENTS.md
9+
AGENTS.md
10+
CLAUDE.md

sqlparser_bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ authors = ["Dandandan <danielheres@gmail.com>"]
2323
edition = "2018"
2424

2525
[dependencies]
26-
sqlparser = { path = "../" }
26+
sqlparser = { package = "pgmold-sqlparser", path = "../" }
2727

2828
[dev-dependencies]
2929
criterion = "0.8"

src/ast/ddl.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ use crate::ast::{
4343
},
4444
ArgMode, AttachedToken, CommentDef, ConditionalStatements, CreateFunctionBody,
4545
CreateFunctionUsing, CreateServerOption, CreateTableLikeKind, CreateTableOptions,
46-
CreateViewParams, DataType, Expr,
47-
FileFormat, FunctionBehavior, FunctionCalledOnNull, FunctionDefinitionSetParam, FunctionDesc,
48-
FunctionDeterminismSpecifier, FunctionParallel, FunctionSecurity, HiveDistributionStyle,
49-
HiveFormat, HiveIOFormat, HiveRowFormat, HiveSetLocation, Ident, InitializeKind,
50-
MySQLColumnPosition, ObjectName, OnCommit, OneOrManyWithParens, OperateFunctionArg,
51-
OrderByExpr, ProjectionSelect, Query, RefreshModeKind, ResetConfig, RowAccessPolicy,
52-
SequenceOptions, Spanned, SqlOption, StorageLifecyclePolicy, StorageSerializationPolicy,
53-
TableVersion, Tag, TriggerEvent, TriggerExecBody, TriggerObject, TriggerPeriod,
54-
TriggerReferencing, Value, ValueWithSpan, WrappedCollection,
46+
CreateViewParams, DataType, Expr, FileFormat, FunctionBehavior, FunctionCalledOnNull,
47+
FunctionDefinitionSetParam, FunctionDesc, FunctionDeterminismSpecifier, FunctionParallel,
48+
FunctionSecurity, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat,
49+
HiveSetLocation, Ident, InitializeKind, MySQLColumnPosition, ObjectName, OnCommit,
50+
OneOrManyWithParens, OperateFunctionArg, OrderByExpr, ProjectionSelect, Query, RefreshModeKind,
51+
ResetConfig, RowAccessPolicy, SequenceOptions, Spanned, SqlOption, StorageLifecyclePolicy,
52+
StorageSerializationPolicy, TableVersion, Tag, TriggerEvent, TriggerExecBody, TriggerObject,
53+
TriggerPeriod, TriggerReferencing, Value, ValueWithSpan, WrappedCollection,
5554
};
5655
use crate::display_utils::{DisplayCommaSeparated, Indent, NewLine, SpaceOrNewline};
5756
use crate::keywords::Keyword;
@@ -3555,7 +3554,6 @@ impl fmt::Display for DistStyle {
35553554
}
35563555
}
35573556

3558-
35593557
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
35603558
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
35613559
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
@@ -5919,7 +5917,11 @@ impl fmt::Display for CreateForeignTable {
59195917
write!(
59205918
f,
59215919
"CREATE FOREIGN TABLE {if_not_exists}{name} ({columns}) SERVER {server_name}",
5922-
if_not_exists = if self.if_not_exists { "IF NOT EXISTS " } else { "" },
5920+
if_not_exists = if self.if_not_exists {
5921+
"IF NOT EXISTS "
5922+
} else {
5923+
""
5924+
},
59235925
name = self.name,
59245926
columns = display_comma_separated(&self.columns),
59255927
server_name = self.server_name,
@@ -6967,11 +6969,7 @@ impl fmt::Display for CreateUserMapping {
69676969
}
69686970
write!(f, " FOR {} SERVER {}", self.user, self.server_name)?;
69696971
if let Some(options) = &self.options {
6970-
write!(
6971-
f,
6972-
" OPTIONS ({})",
6973-
display_comma_separated(options)
6974-
)?;
6972+
write!(f, " OPTIONS ({})", display_comma_separated(options))?;
69756973
}
69766974
Ok(())
69776975
}

src/ast/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub use self::ddl::{
9090
SecurityLabelObjectKind, StatisticsKind, TagsColumnOption, TransformElement, TriggerObjectKind,
9191
Truncate, UserDefinedTypeCompositeAttributeDef, UserDefinedTypeInternalLength,
9292
UserDefinedTypeRangeOption, UserDefinedTypeRepresentation, UserDefinedTypeSqlDefinitionOption,
93-
UserDefinedTypeStorage, UserMappingUser, ViewColumnDef
93+
UserDefinedTypeStorage, UserMappingUser, ViewColumnDef,
9494
};
9595
pub use self::dml::{
9696
Delete, Insert, Merge, MergeAction, MergeClause, MergeClauseKind, MergeInsertExpr,
@@ -4077,6 +4077,7 @@ pub enum Statement {
40774077
/// Note: this is a PostgreSQL-specific statement.
40784078
/// <https://www.postgresql.org/docs/current/sql-createrule.html>
40794079
CreateRule(CreateRule),
4080+
/// ```sql
40804081
/// CREATE STATISTICS [ IF NOT EXISTS ] name [ ( kind [, ...] ) ] ON expr [, ...] FROM table_name
40814082
/// ```
40824083
/// Note: this is a PostgreSQL-specific statement.

src/ast/spans.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,6 @@ impl Spanned for AlterTableOperation {
11871187
AlterTableOperation::EnableReplicaRule { name } => name.span,
11881188
AlterTableOperation::EnableReplicaTrigger { name } => name.span,
11891189
AlterTableOperation::EnableRowLevelSecurity => Span::empty(),
1190-
AlterTableOperation::ForceRowLevelSecurity => Span::empty(),
1191-
AlterTableOperation::NoForceRowLevelSecurity => Span::empty(),
11921190
AlterTableOperation::EnableRule { name } => name.span,
11931191
AlterTableOperation::EnableTrigger { name } => name.span,
11941192
AlterTableOperation::RenamePartitions {

src/ast/table_constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::tokenizer::Span;
2626
use core::fmt;
2727

2828
#[cfg(not(feature = "std"))]
29-
use alloc::{boxed::Box, vec::Vec};
29+
use alloc::{boxed::Box, string::String, vec::Vec};
3030

3131
#[cfg(feature = "serde")]
3232
use serde::{Deserialize, Serialize};

src/keywords.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ define_keywords!(
246246
COMPRESSION,
247247
COMPUPDATE,
248248
COMPUTE,
249-
CONFIGURATION,
250249
CONCURRENTLY,
251250
CONDITION,
251+
CONFIGURATION,
252252
CONFLICT,
253253
CONNECT,
254254
CONNECTION,
@@ -514,7 +514,6 @@ define_keywords!(
514514
IN,
515515
INCLUDE,
516516
INCLUDE_NULL_VALUES,
517-
INLINE,
518517
INCLUDING,
519518
INCREMENT,
520519
INCREMENTAL,
@@ -524,6 +523,7 @@ define_keywords!(
524523
INHERITS,
525524
INITIALIZE,
526525
INITIALLY,
526+
INLINE,
527527
INNER,
528528
INOUT,
529529
INPATH,
@@ -1082,8 +1082,8 @@ define_keywords!(
10821082
TRAILING,
10831083
TRAN,
10841084
TRANSACTION,
1085-
TRANSIENT,
10861085
TRANSFORM,
1086+
TRANSIENT,
10871087
TRANSLATE,
10881088
TRANSLATE_REGEX,
10891089
TRANSLATION,

0 commit comments

Comments
 (0)