Skip to content

Commit 7dbc4bd

Browse files
authored
Merge pull request #2703 from dolthub/fulghum/implicit-prefix-lengths
Minor changes for implicit prefix lengths in Doltgres
2 parents 754f4b7 + cbdedd4 commit 7dbc4bd

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

sql/analyzer/validate_create_table.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func resolveAlterColumn(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.S
258258
return nil, transform.SameTree, err
259259
}
260260

261-
sch, err = validateAddColumn(initialSch, sch, n.(*plan.AddColumn))
261+
sch, err = ValidateAddColumn(sch, n.(*plan.AddColumn))
262262
if err != nil {
263263
return nil, transform.SameTree, err
264264
}
@@ -395,7 +395,10 @@ func validateRenameColumn(initialSch, sch sql.Schema, rc *plan.RenameColumn) (sq
395395
return renameInSchema(sch, rc.ColumnName, rc.NewColumnName, nameable.Name()), nil
396396
}
397397

398-
func validateAddColumn(initialSch sql.Schema, schema sql.Schema, ac *plan.AddColumn) (sql.Schema, error) {
398+
// ValidateAddColumn validates that the column specified in |ac| can be added to the specified
399+
// |schema|. A new Schema is returned, with the added column, if the column can be added. Otherwise,
400+
// an error is returned if there are any validation errors.
401+
func ValidateAddColumn(schema sql.Schema, ac *plan.AddColumn) (sql.Schema, error) {
399402
table := ac.Table
400403
nameable := table.(sql.Nameable)
401404

@@ -828,8 +831,6 @@ func validateAutoIncrementAdd(schema sql.Schema, keyColumns map[string]bool) err
828831
return nil
829832
}
830833

831-
const textIndexPrefix = 1000
832-
833834
func schToColMap(sch sql.Schema) map[string]*sql.Column {
834835
colMap := make(map[string]*sql.Column, len(sch))
835836
for _, col := range sch {

sql/plan/alter_index.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ func (p AlterIndex) WithChildren(children ...sql.Node) (sql.Node, error) {
138138
}
139139
}
140140

141+
func (p AlterIndex) WithColumns(columns []sql.IndexColumn) (sql.Node, error) {
142+
p.Columns = columns
143+
return &p, nil
144+
}
145+
141146
func (p AlterIndex) WithTargetSchema(schema sql.Schema) (sql.Node, error) {
142147
p.targetSchema = schema
143148
return &p, nil

sql/plan/ddl.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ func (c *CreateTable) WithDatabase(db sql.Database) (sql.Node, error) {
133133
return &nc, nil
134134
}
135135

136+
// WithIndexDefs returns a copy of this CreateTable instance, with the index definitions
137+
// set to |idxDefs|.
138+
func (c *CreateTable) WithIndexDefs(idxDefs sql.IndexDefs) (*CreateTable, error) {
139+
nc := *c
140+
nc.idxDefs = idxDefs
141+
return &nc, nil
142+
}
143+
136144
// Name implements the Nameable interface.
137145
func (c *CreateTable) Name() string {
138146
return c.name

0 commit comments

Comments
 (0)