Skip to content

Commit

Permalink
[ga-format-pr] Run ./format_repo.sh to fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmu committed Oct 22, 2024
1 parent 457a6f7 commit 75aae15
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
10 changes: 5 additions & 5 deletions sql/analyzer/apply_foreign_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func applyForeignKeysToNodes(ctx *sql.Context, a *Analyzer, n sql.Node, cache *f
return nil, transform.SameTree, err
}

// If we are working with a schema-enabled database, alter the foreign key defn to apply the schema name we
// If we are working with a schema-enabled database, alter the foreign key defn to apply the schema name we
// just resolved
dst, ok := parentTbl.(sql.DatabaseSchemaTable)
if ok {
Expand Down Expand Up @@ -434,16 +434,16 @@ func getForeignKeyRefActions(ctx *sql.Context, a *Analyzer, tbl sql.ForeignKeyTa

// foreignKeyTableName is the combination of a table's database along with their name, both lowercased.
type foreignKeyTableName struct {
dbName string
dbName string
schemaName string
tblName string
tblName string
}

func newForeignKeyTableName(dbName, schemaName, tblName string) foreignKeyTableName {
return foreignKeyTableName{
dbName: strings.ToLower(dbName),
dbName: strings.ToLower(dbName),
schemaName: strings.ToLower(schemaName),
tblName: strings.ToLower(tblName),
tblName: strings.ToLower(tblName),
}
}

Expand Down
4 changes: 2 additions & 2 deletions sql/analyzer/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ func (c *Catalog) TableSchema(ctx *sql.Context, dbName, schemaName, tableName st
if err != nil {
return nil, nil, err
}

if schemaName != "" {
sdb, ok := db.(sql.SchemaDatabase)
if !ok {
return nil, nil, sql.ErrDatabaseSchemasNotSupported.New(db.Name())
}

db, ok, err = sdb.GetSchema(ctx, schemaName)
if err != nil {
return nil, nil, err
Expand Down
22 changes: 11 additions & 11 deletions sql/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ func (f ForeignKeyReferentialAction) IsEquivalentToRestrict() bool {
// ForeignKeyConstraint declares a constraint between the columns of two tables.
type ForeignKeyConstraint struct {
// Name is the name of the foreign key constraint
Name string
Name string
// Database is the name of the database of the table with the constraint
Database string
Database string
// SchemaName is the name of the schema of the table, for databases that support schemas.
SchemaName string
SchemaName string
// Table is the name of the table with the constraint
Table string
Table string
// Columns is the list of columns in the table that are part of the foreign key
Columns []string
Columns []string
// ParentDatabase is the name of the database of the parent table
ParentDatabase string
// ParentSchema is the name of the schema of the parent table, for databases that support schemas.
ParentSchema string
ParentSchema string
// ParentTable is the name of the parent table
ParentTable string
ParentTable string
// ParentColumns is the list of columns in the parent table that are part of the foreign key
ParentColumns []string
ParentColumns []string
// OnUpdate is the action to take when the constraint is violated when a row in the parent table is updated
OnUpdate ForeignKeyReferentialAction
OnUpdate ForeignKeyReferentialAction
// OnDelete is the action to take when the constraint is violated when a row in the parent table is deleted
OnDelete ForeignKeyReferentialAction
OnDelete ForeignKeyReferentialAction
// IsResolved is true if the foreign key has been resolved, false otherwise
IsResolved bool
IsResolved bool
}

// IsSelfReferential returns whether this foreign key represents a self-referential foreign key.
Expand Down
4 changes: 2 additions & 2 deletions sql/planbuilder/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,12 @@ func (b *Builder) buildAlterConstraint(inScope *scope, ddl *ast.DDL, table *plan
case *sql.ForeignKeyConstraint:
c.Database = table.SqlDatabase.Name()
c.Table = table.Name()

ds, ok := table.SqlDatabase.(sql.DatabaseSchema)
if ok {
c.SchemaName = ds.SchemaName()
}

alterFk := plan.NewAlterAddForeignKey(c)
alterFk.DbProvider = b.cat
outScope.node = alterFk
Expand Down
14 changes: 7 additions & 7 deletions sql/rowexec/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ func (b *BaseBuilder) buildCreateForeignKey(ctx *sql.Context, n *plan.CreateFore
if err != nil {
return nil, err
}

if n.FkDef.SchemaName != "" {
sdb, ok := db.(sql.SchemaDatabase)
if !ok {
Expand All @@ -1202,7 +1202,7 @@ func (b *BaseBuilder) buildCreateForeignKey(ctx *sql.Context, n *plan.CreateFore
}
db = sch
}

tbl, ok, err := db.GetTableInsensitive(ctx, n.FkDef.Table)
if err != nil {
return nil, err
Expand All @@ -1215,7 +1215,7 @@ func (b *BaseBuilder) buildCreateForeignKey(ctx *sql.Context, n *plan.CreateFore
if err != nil {
return nil, err
}

if n.FkDef.ParentSchema != "" {
sdb, ok := refDb.(sql.SchemaDatabase)
if !ok {
Expand All @@ -1230,16 +1230,16 @@ func (b *BaseBuilder) buildCreateForeignKey(ctx *sql.Context, n *plan.CreateFore
}
refDb = sch
}

refTbl, ok, err := refDb.GetTableInsensitive(ctx, n.FkDef.ParentTable)
if err != nil {
return nil, err
}
if !ok {
return nil, sql.ErrTableNotFound.New(n.FkDef.ParentTable)
}
// If we didn't have an explicit schema, fill in the resolved schema for the fk table defn

// If we didn't have an explicit schema, fill in the resolved schema for the fk table defn
if n.FkDef.ParentSchema == "" {
dst, ok := refTbl.(sql.DatabaseSchemaTable)
if ok {
Expand All @@ -1255,7 +1255,7 @@ func (b *BaseBuilder) buildCreateForeignKey(ctx *sql.Context, n *plan.CreateFore
if !ok {
return nil, sql.ErrNoForeignKeySupport.New(n.FkDef.ParentTable)
}

fkChecks, err := ctx.GetSessionVariable(ctx, "foreign_key_checks")
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions sql/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ type Table interface {
PartitionRows(*Context, Partition) (RowIter, error)
}

// DatabaseSchemaTable is a table that can return the database schema it belongs to. This interface must be implemented
// DatabaseSchemaTable is a table that can return the database schema it belongs to. This interface must be implemented
// for correct function of some DDL in databases that implement SchemaDatabase.
type DatabaseSchemaTable interface {
Table
// DatabaseSchema returns the database schema that this table belongs to.
DatabaseSchema() DatabaseSchema
}
}

// TableFunction is a node that is generated by a function and can be used as a table factor in many SQL queries.
type TableFunction interface {
Expand Down

0 comments on commit 75aae15

Please sign in to comment.