// NewDiff returns a Diff instance.
NewDiff returns a Diff instance.
// NewDiff returns a Diff instance .
func NewDiff(ctx context.Context, db1, db2 *sql.DB, cfg *Config) (diff *Diff, err error) {
	diff = &Diff{
		db1:              db1,
		db2:              db2,
		schema:           cfg.SourceDBCfg.Schema,
		chunkSize:        cfg.ChunkSize,
		sample:           cfg.Sample,
		checkThreadCount: cfg.CheckThreadCount,
		useRowID:         cfg.UseRowID,
		tables:           cfg.Tables,
		sqlCh:            make(chan string),
		report:           NewReport(cfg.SourceDBCfg.Schema),
		ctx:              ctx,
	}
	for _, table := range diff.tables {
		table.Info, err = dbutil.GetTableInfoWithRowID(ctx, diff.db1, diff.schema, table.Name, cfg.UseRowID)
		if err != nil {
			return nil, errors.Trace(err)
		}
		table.Schema = diff.schema
	}
	diff.fixSQLFile, err = os.Create(cfg.FixSQLFile)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return diff, nil
}
func NewDiff ( ctx context . Context , db1 , db2 * sql . DB , cfg * Config ) ( diff * Diff , err error ) { diff = & Diff { db1 : db1 , db2 : db2 , schema : cfg . SourceDBCfg . Schema , chunkSize : cfg . ChunkSize , sample : cfg . Sample , checkThreadCount : cfg . CheckThreadCount , useRowID : cfg . UseRowID , tables : cfg . Tables , sqlCh : make ( chan string ) , report : NewReport ( cfg . SourceDBCfg . Schema ) , ctx : ctx , } for _ , table := range diff . tables { table . Info , err = dbutil . GetTableInfoWithRowID ( ctx , diff . db1 , diff . schema , table . Name , cfg . UseRowID ) if err != nil { return nil , errors . Trace ( err ) } table . Schema = diff . schema } diff . fixSQLFile , err = os . Create ( cfg . FixSQLFile ) if err != nil { return nil , errors . Trace ( err ) } return diff , nil }
NewDiff returns a Diff instance.
NewDiff returns a Diff instance .