// Execute a set of migrations
//
// Returns the number of applied migrations.
518644
func Exec(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection) (int, error) {
	return ExecMax(db, dialect, m, dir, 0)
}
284359
func (c *Context) Execute(ctx context.Context, sql string) ([]sqlexec.RecordSet, error) {
	return nil, errors.Errorf("Not Support.")
}
463141
func (mf Migration) Run(c *Connection) error {
	if mf.Runner == nil {
		return errors.Errorf("no runner defined for %s", mf.Path)
	}
	return mf.Runner(mf, c)
}
108899
func MigrateAll(client *Client) error {
	for _, m := range migrations {
		err := m.Migrate(client)

		if err != nil {
			return err
		}
	}

	return nil
}
33509
func (s *StreamMigrator) Migrate() {
	for _, st := range s.Streams {
		if s.isCreated(st) {
			log.Printf("action=migrate at=create-stream stream=%s status=previously-created", st.StreamName)
		} else {
			s.create(st)
			log.Printf("action=migrate at=create-stream stream=%s status=created", st.StreamName)
		}
	}
}
642091
func (t *migrateTracker) run() {
	for r := range t.results {
		if r.found {
			t.found++
		}
		if r.retry {
			t.report("retry:", r.data.info, r.data.err)
			continue // retry attempts do not have results to process
		}

		switch r.result {
		case attemptResultError:
			t.report("error:", r.data.info, r.data.err)
			t.errors++
			groupResource := r.data.info.Mapping.Resource.GroupResource()
			t.resourcesWithErrors.Insert((&groupResource).String())
		case attemptResultIgnore:
			t.ignored++
			if klog.V(2) {
				t.report("ignored:", r.data.info, nil)
			}
		case attemptResultUnchanged:
			t.unchanged++
			if klog.V(2) {
				t.report("unchanged:", r.data.info, nil)
			}
		case attemptResultSuccess:
			if klog.V(1) {
				if t.dryRun {
					t.report("migrated (dry run):", r.data.info, nil)
				} else {
					t.report("migrated:", r.data.info, nil)
				}
			}
		}
	}
}
1171200
func (t *TemplateRenderable) Execute(v interface{}) error {
	t.cache.Reset()
	err := t.tmpl.Execute(t.cache, v)
	return err
}
638152
func (c *SchemaDump) Execute(args []string) error {
	if c.Verbose {
		fmt.Printf("executing schema dump with %v\n", args)
		fmt.Printf("options are %+v\n", *c)
		fmt.Printf("global options are %+v\n", options)
	}

	if c.JarPath != "" {
		if _, err := os.Stat(javaclient); os.IsNotExist(err) {
			downloadJar()
		}
		c.doSchemaDumpInJavaClient()
		return nil
	}

	// no connection necessary
	client := dosa.NewAdminClient(&devnull.Connector{})
	if len(c.Args.Paths) != 0 {
		dirs, err := expandDirectories(c.Args.Paths)
		if err != nil {
			return errors.Wrap(err, "could not expand directories")
		}
		client.Directories(dirs)
	}
	if len(c.Excludes) != 0 {
		client.Excludes(c.Excludes)
	}

	// try to parse entities in each directory
	defs, err := client.GetSchema()
	if err != nil {
		return err
	}

	// for each of those entities, format it in the specified way
	for _, d := range defs {
		switch c.Format {
		case "cql":
			fmt.Println(cql.ToCQL(d))
		case "uql":
			fmt.Println(uql.ToUQL(d))
		case "avro":
			s, err := avro.ToAvro("TODO", d)
			fmt.Println(string(s), err)
		}
	}

	return nil
}
680732
func (p *showPlan) Execute(ctx context.Context) (*table.Table, error) {
	t, err := table.New([]string{"?graph_id"})
	if err != nil {
		return nil, err
	}
	errs := make(chan error)
	names := make(chan string)
	go func() {
		errs <- p.store.GraphNames(ctx, names)
		close(errs)
	}()

	for name := range names {
		id := name
		t.AddRow(table.Row{
			"?graph_id": &table.Cell{
				S: &id,
			},
		})
	}
	if <-errs != nil {
		return nil, err
	}
	return t, nil
}
1196351
func (p *insertPlan) Execute(ctx context.Context) (*table.Table, error) {
	t, err := table.New([]string{})
	if err != nil {
		return nil, err
	}
	return t, update(ctx, p.stm.Data(), p.stm.OutputGraphNames(), p.store, func(g storage.Graph, d []*triple.Triple) error {
		tracer.Trace(p.tracer, func() []string {
			return []string{"Inserting triples to graph \"" + g.ID(ctx) + "\""}
		})
		return g.AddTriples(ctx, d)
	})
}
898700
func (t *MigrateServedTypesTask) Run(parameters map[string]string) ([]*automationpb.TaskContainer, string, error) {
	args := []string{"MigrateServedTypes"}
	if cells := parameters["cells"]; cells != "" {
		args = append(args, "--cells="+cells)
	}
	if reverse := parameters["reverse"]; reverse != "" {
		args = append(args, "--reverse="+reverse)
	}
	args = append(args,
		topoproto.KeyspaceShardString(parameters["keyspace"], parameters["source_shard"]),
		parameters["type"])
	output, err := ExecuteVtctl(context.TODO(), parameters["vtctld_endpoint"], args)
	return nil, output, err
}
399550
func (m *DirectoryMigratorService) Run() error {
	return m.Migrations.Run(m.Directory.GetModels())
}
740082
func (command *ServerCommand) Execute() error {
	var apiDocsDir string

	log.Infof("Generating a %v server", command.Language)

	if !command.NoAPIDocs {
		apiDocsDir = "apidocs"
	}

	cs := codegen.Server{
		RAMLFile:       command.RamlFile,
		Kind:           command.Kind,
		Dir:            command.Dir,
		PackageName:    command.PackageName,
		Lang:           command.Language,
		APIDocsDir:     apiDocsDir,
		RootImportPath: command.ImportPath,
		WithMain:       !command.NoMainGeneration,
		LibRootURLs:    strings.Split(command.LibRootURLs, ","),
	}
	return cs.Generate()
}
26184
func (c *Conn) Execute(queries []string, tx, xTime bool) ([]*Result, error) {
	stats.Add(numExecutions, int64(len(queries)))
	if tx {
		stats.Add(numETx, 1)
	}

	type Execer interface {
		Exec(query string, args []driver.Value) (driver.Result, error)
	}

	var allResults []*Result
	err := func() error {
		var execer Execer
		var rollback bool
		var t driver.Tx
		var err error

		// Check for the err, if set rollback.
		defer func() {
			if t != nil {
				if rollback {
					t.Rollback()
					return
				}
				t.Commit()
			}
		}()

		// handleError sets the error field on the given result. It returns
		// whether the caller should continue processing or break.
		handleError := func(result *Result, err error) bool {
			stats.Add(numExecutionErrors, 1)

			result.Error = err.Error()
			allResults = append(allResults, result)
			if tx {
				rollback = true // Will trigger the rollback.
				return false
			}
			return true
		}

		execer = c.sqlite

		// Create the correct execution object, depending on whether a
		// transaction was requested.
		if tx {
			t, err = c.sqlite.Begin()
			if err != nil {
				return err
			}
		}

		// Execute each query.
		for _, q := range queries {
			if q == "" {
				continue
			}

			result := &Result{}
			start := time.Now()

			r, err := execer.Exec(q, nil)
			if err != nil {
				if handleError(result, err) {
					continue
				}
				break
			}
			if r == nil {
				continue
			}

			lid, err := r.LastInsertId()
			if err != nil {
				if handleError(result, err) {
					continue
				}
				break
			}
			result.LastInsertID = lid

			ra, err := r.RowsAffected()
			if err != nil {
				if handleError(result, err) {
					continue
				}
				break
			}
			result.RowsAffected = ra
			if xTime {
				result.Time = time.Now().Sub(start).Seconds()
			}
			allResults = append(allResults, result)
		}

		return nil
	}()

	return allResults, err
}
477388
func Execute(a *Action) error {
	seen := make(map[*Action]error)
	return execute(seen, a)
}
873681
func (p *createPlan) Execute(ctx context.Context) (*table.Table, error) {
	t, err := table.New([]string{})
	if err != nil {
		return nil, err
	}
	errs := []string{}
	for _, g := range p.stm.GraphNames() {
		tracer.Trace(p.tracer, func() []string {
			return []string{"Creating new graph \"" + g + "\""}
		})
		if _, err := p.store.NewGraph(ctx, g); err != nil {
			errs = append(errs, err.Error())
		}
	}
	if len(errs) > 0 {
		return nil, errors.New(strings.Join(errs, "; "))
	}
	return t, nil
}
371015
func (c *ServicedStorageVersion) Execute(args []string) error {
	fmt.Println(App.version)
	return nil
}