The func (me *Engine) schemaChanged(tables map[string]*schema.Table, created, altered, dropped []string) assumes that tables in both the created and altered arrays exist in the tables map, leading to a null pointer error in the subsequent code.
for _, name := range append(created, altered...) {
t := tables[name]
if t.Type != schema.Message {
continue
}
...
}
However, in reality, if tables in the created and altered arrays are not explicitly defined with primary keys, they will not exist in the tables map (as determined in the func (se *Engine) populatePrimaryKeys(ctx context.Context, conn *connpool.DBConn, tables map[string]*Table) error).
Therefore, we should add an additional check to verify whether the tables exist in the tables map.
Related Issue(s) & Descriptions
fix #468
The
func (me *Engine) schemaChanged(tables map[string]*schema.Table, created, altered, dropped []string)
assumes that tables in both thecreated
andaltered
arrays exist in thetables
map, leading to a null pointer error in the subsequent code.However, in reality, if tables in the
created
andaltered
arrays are not explicitly defined with primary keys, they will not exist in the tables map (as determined in thefunc (se *Engine) populatePrimaryKeys(ctx context.Context, conn *connpool.DBConn, tables map[string]*Table) error
).Therefore, we should add an additional check to verify whether the tables exist in the tables map.
Checklist