Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-release-notes] correct comment on analyzer rule #2831

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
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
25 changes: 2 additions & 23 deletions sql/analyzer/resolve_column_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,8 @@ import (
"github.com/dolthub/go-mysql-server/sql/types"
)

// Resolving column defaults is a multi-phase process, with different analyzer rules for each phase.
//
// - parseColumnDefaults: Some integrators (dolt but not GMS) store their column defaults as strings, which we need to
// parse into expressions before we can analyze them any further.
// - resolveColumnDefaults: Once we have an expression for a default value, it may contain expressions that need
// simplification before further phases of processing can take place.
//
// After this stage, expressions in column default values are handled by the normal analyzer machinery responsible for
// resolving expressions, including things like columns and functions. Every node that needs to do this for its default
// values implements `sql.Expressioner` to expose such expressions. There is custom logic in `resolveColumns` to help
// identify the correct indexes for column references, which can vary based on the node type.
//
// Finally there are cleanup phases:
// - validateColumnDefaults: ensures that newly created column defaults from a DDL statement are legal for the type of
// column, various other business logic checks to match MySQL's logic.
// - stripTableNamesFromDefault: column defaults headed for storage or serialization in a query result need the table
// names in any GetField expressions stripped out so that they serialize to strings without such table names. Table
// names in GetField expressions are expected in much of the rest of the analyzer, so we do this after the bulk of
// analyzer work.
//
// The `information_schema.columns` table also needs access to the default values of every column in the database, and
// because it's a table it can't implement `sql.Expressioner` like other node types. Instead it has special handling
// here, as well as in the `resolve_functions` rule.
// validateColumnDefaults ensures that newly created column defaults from a DDL statement are legal for the type of
// column, various other business logic checks to match MySQL's logic.
func validateColumnDefaults(ctx *sql.Context, _ *Analyzer, n sql.Node, _ *plan.Scope, _ RuleSelector, qFlags *sql.QueryFlags) (sql.Node, transform.TreeIdentity, error) {
span, ctx := ctx.Span("validateColumnDefaults")
defer span.End()
Expand Down
Loading