File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -240,12 +240,21 @@ func (c *Catalog) createTable(stmt *ast.CreateTableStmt) error {
240
240
}
241
241
242
242
tbl := Table {Rel : stmt .Name , Comment : stmt .Comment }
243
+ m := make (map [string ]struct {}) // used to check for duplicate column names
243
244
for _ , inheritTable := range stmt .Inherits {
244
245
t , _ , err := schema .getTable (inheritTable )
245
246
if err != nil {
246
247
return err
247
248
}
248
- tbl .Columns = append (tbl .Columns , t .Columns ... )
249
+ // check and ignore duplicate columns
250
+ for _ , col := range t .Columns {
251
+ if _ , ok := m [col .Name ]; ok {
252
+ continue
253
+ } else {
254
+ m [col .Name ] = struct {}{}
255
+ tbl .Columns = append (tbl .Columns , col )
256
+ }
257
+ }
249
258
}
250
259
251
260
if stmt .ReferTable != nil && len (stmt .Cols ) != 0 {
You can’t perform that action at this time.
0 commit comments