agent_patch
runs/2026-02-21__03-36-16__gpt-5-1-codex-mini/flux-pr-1908/flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/agent-logs/agent.patch
10548 bytes
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/ast/ddl.rs b/app/src/ast/ddl.rs
index 9134412..f1b5b5e 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/ast/ddl.rs
+++ b/app/src/ast/ddl.rs
@@ -68,7 +68,10 @@ impl fmt::Display for ReplicaIdentity {
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum AlterTableOperation {
/// `ADD <table_constraint>`
- AddConstraint(TableConstraint),
+ AddConstraint {
+ constraint: TableConstraint,
+ not_valid: bool,
+ },
/// `ADD [COLUMN] [IF NOT EXISTS] <column_def>`
AddColumn {
/// `[COLUMN]`.
@@ -287,6 +290,12 @@ pub enum AlterTableOperation {
old_name: Ident,
new_name: Ident,
},
+ /// `VALIDATE CONSTRAINT <name>`
+ ///
+ /// Note: this is a PostgreSQL-specific operation.
+ ValidateConstraint {
+ name: Ident,
+ },
/// `ALTER [ COLUMN ]`
AlterColumn {
column_name: Ident,
@@ -494,7 +503,16 @@ impl fmt::Display for AlterTableOperation {
display_separated(new_partitions, " "),
ine = if *if_not_exists { " IF NOT EXISTS" } else { "" }
),
- AlterTableOperation::AddConstraint(c) => write!(f, "ADD {c}"),
+ AlterTableOperation::AddConstraint {
+ constraint,
+ not_valid,
+ } => {
+ write!(f, "ADD {constraint}")?;
+ if *not_valid {
+ write!(f, " NOT VALID")?;
+ }
+ Ok(())
+ }
AlterTableOperation::AddColumn {
column_keyword,
if_not_exists,
@@ -709,6 +727,9 @@ impl fmt::Display for AlterTableOperation {
AlterTableOperation::RenameConstraint { old_name, new_name } => {
write!(f, "RENAME CONSTRAINT {old_name} TO {new_name}")
}
+ AlterTableOperation::ValidateConstraint { name } => {
+ write!(f, "VALIDATE CONSTRAINT {name}")
+ }
AlterTableOperation::SwapWith { table_name } => {
write!(f, "SWAP WITH {table_name}")
}
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/ast/spans.rs b/app/src/ast/spans.rs
index 0088260..330d13c 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/ast/spans.rs
+++ b/app/src/ast/spans.rs
@@ -1075,7 +1075,10 @@ impl Spanned for CreateTableOptions {
impl Spanned for AlterTableOperation {
fn span(&self) -> Span {
match self {
- AlterTableOperation::AddConstraint(table_constraint) => table_constraint.span(),
+ AlterTableOperation::AddConstraint {
+ constraint,
+ not_valid: _,
+ } => constraint.span(),
AlterTableOperation::AddColumn {
column_keyword: _,
if_not_exists: _,
@@ -1180,6 +1183,7 @@ impl Spanned for AlterTableOperation {
AlterTableOperation::RenameConstraint { old_name, new_name } => {
old_name.span.union(&new_name.span)
}
+ AlterTableOperation::ValidateConstraint { name } => name.span,
AlterTableOperation::AlterColumn { column_name, op } => {
column_name.span.union(&op.span())
}
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/parser/mod.rs b/app/src/parser/mod.rs
index 6360817..20f99d1 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/parser/mod.rs
+++ b/app/src/parser/mod.rs
@@ -8477,7 +8477,11 @@ impl<'a> Parser<'a> {
pub fn parse_alter_table_operation(&mut self) -> Result<AlterTableOperation, ParserError> {
let operation = if self.parse_keyword(Keyword::ADD) {
if let Some(constraint) = self.parse_optional_table_constraint()? {
- AlterTableOperation::AddConstraint(constraint)
+ let not_valid = self.parse_keywords(&[Keyword::NOT, Keyword::VALID]);
+ AlterTableOperation::AddConstraint {
+ constraint,
+ not_valid,
+ }
} else if dialect_of!(self is ClickHouseDialect|GenericDialect)
&& self.parse_keyword(Keyword::PROJECTION)
{
@@ -8582,6 +8586,10 @@ impl<'a> Parser<'a> {
self.peek_token(),
);
}
+ } else if self.parse_keyword(Keyword::VALIDATE) {
+ self.expect_keyword_is(Keyword::CONSTRAINT)?;
+ let name = self.parse_identifier()?;
+ AlterTableOperation::ValidateConstraint { name }
} else if self.parse_keywords(&[Keyword::CLEAR, Keyword::PROJECTION])
&& dialect_of!(self is ClickHouseDialect|GenericDialect)
{
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/test_utils.rs b/app/src/test_utils.rs
index db7b3dd..e419bb0 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/test_utils.rs
+++ b/app/src/test_utils.rs
@@ -479,19 +479,22 @@ pub fn index_column(stmt: Statement) -> Expr {
}
}
Statement::AlterTable { operations, .. } => match operations.first().unwrap() {
- AlterTableOperation::AddConstraint(TableConstraint::Index { columns, .. }) => {
- columns.first().unwrap().column.expr.clone()
- }
- AlterTableOperation::AddConstraint(TableConstraint::Unique { columns, .. }) => {
- columns.first().unwrap().column.expr.clone()
- }
- AlterTableOperation::AddConstraint(TableConstraint::PrimaryKey { columns, .. }) => {
- columns.first().unwrap().column.expr.clone()
- }
- AlterTableOperation::AddConstraint(TableConstraint::FulltextOrSpatial {
- columns,
+ AlterTableOperation::AddConstraint {
+ constraint: TableConstraint::Index { columns, .. },
+ ..
+ } => columns.first().unwrap().column.expr.clone(),
+ AlterTableOperation::AddConstraint {
+ constraint: TableConstraint::Unique { columns, .. },
+ ..
+ } => columns.first().unwrap().column.expr.clone(),
+ AlterTableOperation::AddConstraint {
+ constraint: TableConstraint::PrimaryKey { columns, .. },
+ ..
+ } => columns.first().unwrap().column.expr.clone(),
+ AlterTableOperation::AddConstraint {
+ constraint: TableConstraint::FulltextOrSpatial { columns, .. },
..
- }) => columns.first().unwrap().column.expr.clone(),
+ } => columns.first().unwrap().column.expr.clone(),
_ => panic!("Expected an index, unique, primary, full text, or spatial constraint (foreign key does not support general key part expressions)"),
},
_ => panic!("Expected CREATE INDEX, ALTER TABLE, or CREATE TABLE, got: {stmt:?}"),
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/tests/sqlparser_common.rs b/app/tests/sqlparser_common.rs
index 380bd47..cd324e6 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/tests/sqlparser_common.rs
+++ b/app/tests/sqlparser_common.rs
@@ -75,6 +75,40 @@ fn parse_numeric_literal_underscore() {
);
}
+#[test]
+fn parse_alter_table_add_constraint_not_valid() {
+ match alter_table_op(verified_stmt(
+ "ALTER TABLE tab ADD CONSTRAINT ck CHECK (value > 0) NOT VALID",
+ )) {
+ AlterTableOperation::AddConstraint {
+ constraint,
+ not_valid,
+ } => {
+ assert_eq!("CONSTRAINT ck CHECK (value > 0)", constraint.to_string());
+ assert!(not_valid);
+ }
+ _ => unreachable!(),
+ }
+ one_statement_parses_to(
+ "ALTER TABLE tab ADD CONSTRAINT ck CHECK (value > 0) NOT VALID",
+ "ALTER TABLE tab ADD CONSTRAINT ck CHECK (value > 0) NOT VALID",
+ );
+}
+
+#[test]
+fn parse_alter_table_validate_constraint() {
+ match alter_table_op(verified_stmt("ALTER TABLE tab VALIDATE CONSTRAINT ck")) {
+ AlterTableOperation::ValidateConstraint { name } => {
+ assert_eq!("ck", name.to_string());
+ }
+ _ => unreachable!(),
+ }
+ one_statement_parses_to(
+ "ALTER TABLE tab VALIDATE CONSTRAINT ck",
+ "ALTER TABLE tab VALIDATE CONSTRAINT ck",
+ );
+}
+
#[test]
fn parse_function_object_name() {
let select = verified_only_select("SELECT a.b.c.d(1, 2, 3) FROM T");
@@ -4956,8 +4990,12 @@ fn parse_alter_table_constraints() {
match alter_table_op(verified_stmt(&format!(
"ALTER TABLE tab ADD {constraint_text}"
))) {
- AlterTableOperation::AddConstraint(constraint) => {
+ AlterTableOperation::AddConstraint {
+ constraint,
+ not_valid,
+ } => {
assert_eq!(constraint_text, constraint.to_string());
+ assert!(!not_valid);
}
_ => unreachable!(),
}
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/tests/sqlparser_postgres.rs b/app/tests/sqlparser_postgres.rs
index e1a49c6..cb475c9 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/tests/sqlparser_postgres.rs
+++ b/app/tests/sqlparser_postgres.rs
@@ -606,9 +606,13 @@ fn parse_alter_table_constraints_unique_nulls_distinct() {
.verified_stmt("ALTER TABLE t ADD CONSTRAINT b UNIQUE NULLS NOT DISTINCT (c)")
{
Statement::AlterTable { operations, .. } => match &operations[0] {
- AlterTableOperation::AddConstraint(TableConstraint::Unique {
- nulls_distinct, ..
- }) => {
+ AlterTableOperation::AddConstraint {
+ constraint: TableConstraint::Unique {
+ nulls_distinct, ..
+ },
+ not_valid,
+ } => {
+ assert!(!not_valid);
assert_eq!(nulls_distinct, &NullsDistinctOption::NotDistinct)
}
_ => unreachable!(),