Skip to content

Commit

Permalink
Merge pull request #130904 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-24.2-130895

release-24.2: tree: fix walkStmt for SHOW EXPERIMENTAL_FINGERPRINTS
  • Loading branch information
rafiss authored Sep 18, 2024
2 parents 8a15441 + 7f2d783 commit ee05cd3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/sql/sem/tree/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1184,12 +1184,14 @@ func (n *ShowFingerprints) copyNode() *ShowFingerprints {
// walkStmt is part of the walkableStmt interface.
func (n *ShowFingerprints) walkStmt(v Visitor) Statement {
ret := n
ts, changed := walkTenantSpec(v, n.TenantSpec)
if changed {
if ret == n {
ret = n.copyNode()
if n.TenantSpec != nil {
ts, changed := walkTenantSpec(v, n.TenantSpec)
if changed {
if ret == n {
ret = n.copyNode()
}
ret.TenantSpec = ts
}
ret.TenantSpec = ts
}
if n.Options.StartTimestamp != nil {
e, changed := WalkExpr(v, n.Options.StartTimestamp)
Expand Down
9 changes: 9 additions & 0 deletions pkg/testutils/sqlutils/pretty.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ func VerifyStatementPrettyRoundtrip(t *testing.T, sql string) {
for i := range stmts {
origStmt := stmts[i].AST
verifyStatementPrettyRoundTrip(t, sql, origStmt, false /* plpgsql */)

// Verify that the AST can be walked.
if _, err := tree.SimpleStmtVisit(
origStmt,
func(expr tree.Expr) (recurse bool, newExpr tree.Expr, err error) { return },
); err != nil {
t.Fatalf("cannot walk stmt %s %v", stmts[i].SQL, err)
}

}
}

Expand Down

0 comments on commit ee05cd3

Please sign in to comment.