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 {
240240 }
241241
242242 tbl := Table {Rel : stmt .Name , Comment : stmt .Comment }
243+ m := make (map [string ]struct {}) // used to check for duplicate column names
243244 for _ , inheritTable := range stmt .Inherits {
244245 t , _ , err := schema .getTable (inheritTable )
245246 if err != nil {
246247 return err
247248 }
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+ }
249258 }
250259
251260 if stmt .ReferTable != nil && len (stmt .Cols ) != 0 {
You can’t perform that action at this time.
0 commit comments