@@ -217,51 +217,55 @@ func New(def string) *Catalog {
217217
218218func (c * Catalog ) Build (stmts []ast.Statement ) error {
219219 for i := range stmts {
220- if stmts [i ].Raw == nil {
221- continue
222- }
223- var err error
224- switch n := stmts [i ].Raw .Stmt .(type ) {
225- case * ast.AlterTableStmt :
226- err = c .alterTable (n )
227- case * ast.AlterTableSetSchemaStmt :
228- err = c .alterTableSetSchema (n )
229- case * ast.AlterTypeAddValueStmt :
230- err = c .alterTypeAddValue (n )
231- case * ast.AlterTypeRenameValueStmt :
232- err = c .alterTypeRenameValue (n )
233- case * ast.CommentOnColumnStmt :
234- err = c .commentOnColumn (n )
235- case * ast.CommentOnSchemaStmt :
236- err = c .commentOnSchema (n )
237- case * ast.CommentOnTableStmt :
238- err = c .commentOnTable (n )
239- case * ast.CommentOnTypeStmt :
240- err = c .commentOnType (n )
241- case * ast.CreateEnumStmt :
242- err = c .createEnum (n )
243- case * ast.CreateFunctionStmt :
244- err = c .createFunction (n )
245- case * ast.CreateSchemaStmt :
246- err = c .createSchema (n )
247- case * ast.CreateTableStmt :
248- err = c .createTable (n )
249- case * ast.DropFunctionStmt :
250- err = c .dropFunction (n )
251- case * ast.DropSchemaStmt :
252- err = c .dropSchema (n )
253- case * ast.DropTableStmt :
254- err = c .dropTable (n )
255- case * ast.DropTypeStmt :
256- err = c .dropType (n )
257- case * ast.RenameColumnStmt :
258- err = c .renameColumn (n )
259- case * ast.RenameTableStmt :
260- err = c .renameTable (n )
261- }
262- if err != nil {
220+ if err := c .Update (stmts [i ]); err != nil {
263221 return err
264222 }
265223 }
266224 return nil
267225}
226+
227+ func (c * Catalog ) Update (stmt ast.Statement ) error {
228+ if stmt .Raw == nil {
229+ return nil
230+ }
231+ var err error
232+ switch n := stmt .Raw .Stmt .(type ) {
233+ case * ast.AlterTableStmt :
234+ err = c .alterTable (n )
235+ case * ast.AlterTableSetSchemaStmt :
236+ err = c .alterTableSetSchema (n )
237+ case * ast.AlterTypeAddValueStmt :
238+ err = c .alterTypeAddValue (n )
239+ case * ast.AlterTypeRenameValueStmt :
240+ err = c .alterTypeRenameValue (n )
241+ case * ast.CommentOnColumnStmt :
242+ err = c .commentOnColumn (n )
243+ case * ast.CommentOnSchemaStmt :
244+ err = c .commentOnSchema (n )
245+ case * ast.CommentOnTableStmt :
246+ err = c .commentOnTable (n )
247+ case * ast.CommentOnTypeStmt :
248+ err = c .commentOnType (n )
249+ case * ast.CreateEnumStmt :
250+ err = c .createEnum (n )
251+ case * ast.CreateFunctionStmt :
252+ err = c .createFunction (n )
253+ case * ast.CreateSchemaStmt :
254+ err = c .createSchema (n )
255+ case * ast.CreateTableStmt :
256+ err = c .createTable (n )
257+ case * ast.DropFunctionStmt :
258+ err = c .dropFunction (n )
259+ case * ast.DropSchemaStmt :
260+ err = c .dropSchema (n )
261+ case * ast.DropTableStmt :
262+ err = c .dropTable (n )
263+ case * ast.DropTypeStmt :
264+ err = c .dropType (n )
265+ case * ast.RenameColumnStmt :
266+ err = c .renameColumn (n )
267+ case * ast.RenameTableStmt :
268+ err = c .renameTable (n )
269+ }
270+ return err
271+ }
0 commit comments