// executeSchemaCommands executes some SQL commands, using the mysql
// command line tool. It uses the dba connection parameters, with credentials.
2571
func (mysqld *Mysqld) executeSchemaCommands(sql string) error {
	params, err := dbconfigs.WithCredentials(mysqld.dbcfgs.Dba())
	if err != nil {
		return err
	}

	return mysqld.executeMysqlScript(params, strings.NewReader(sql))
}
265795
func (p *ListCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
	c.Conf.Debug = p.debug
	c.Conf.DebugSQL = p.debugSQL
	c.Conf.DBPath = p.dbpath
	c.Conf.DBType = p.dbtype
	c.Conf.HTTPProxy = p.httpProxy
	log.SetLogger(p.logDir, c.Conf.Quiet, c.Conf.Debug, p.logJSON)
	if !c.Conf.Validate() {
		return subcommands.ExitUsageError
	}

	driver, locked, err := db.NewDB(c.Conf.DBType, c.Conf.DBPath, c.Conf.DebugSQL)
	if err != nil {
		if locked {
			log.Errorf("Failed to Open DB. Close DB connection: %s", err)
			return subcommands.ExitFailure
		}
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	defer driver.CloseDB()

	jsonMetas, xmlMetas, err := nvd.ListFetchedFeeds(driver)
	if err != nil {
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	sort.Slice(jsonMetas, func(i, j int) bool {
		return jsonMetas[i].URL < jsonMetas[j].URL
	})
	sort.Slice(xmlMetas, func(i, j int) bool {
		return xmlMetas[i].URL < xmlMetas[j].URL
	})

	jvnMetas, err := jvn.ListFetchedFeeds(driver)
	if err != nil {
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	sort.Slice(jvnMetas, func(i, j int) bool {
		return jvnMetas[i].URL < jvnMetas[j].URL
	})

	metas := []models.FeedMeta{}
	for _, mm := range [][]models.FeedMeta{jsonMetas, xmlMetas, jvnMetas} {
		metas = append(metas, mm...)
	}
	data := [][]string{}
	for _, meta := range metas {
		data = append(data, meta.ToTableWriterRow())
	}
	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"Source", "Year", "Status", "Fetched", "Latest"})
	table.SetBorder(true)
	table.SetHeaderColor(
		tablewriter.Colors{tablewriter.Bold},
		tablewriter.Colors{tablewriter.Bold},
		tablewriter.Colors{tablewriter.Bold},
		tablewriter.Colors{tablewriter.Bold},
		tablewriter.Colors{tablewriter.Bold})
	table.AppendBulk(data)
	table.Render()

	cmds := []string{}
	for _, mm := range [][]models.FeedMeta{jsonMetas, xmlMetas, jvnMetas} {
		cmd := getUpdateCommand(mm)
		if cmd != "" {
			cmds = append(cmds, cmd)
		}
	}

	if 0 < len(cmds) {
		fmt.Printf("\nTo update feeds, execute the following commands.\n")
		for _, cmd := range cmds {
			fmt.Println(cmd)
		}
	}

	return subcommands.ExitSuccess
}
602136
func (c *SchemaStatus) Execute(args []string) error {
	if c.Verbose {
		fmt.Printf("executing schema status with %v\n", args)
		fmt.Printf("options are %+v\n", *c)
		fmt.Printf("global options are %+v\n", options)
	}

	// TODO(eculver): use options/configurator pattern to apply defaults
	if options.ServiceName == "" {
		options.ServiceName = _defServiceName
	}

	client, err := c.provideClient(options)
	if err != nil {
		return err
	}
	defer shutdownAdminClient(client)

	if c.Scope.String() != "" {
		client.Scope(c.Scope.String())
	}

	ctx, cancel := context.WithTimeout(context.Background(), options.Timeout.Duration())
	defer cancel()

	var prefix string
	if prefix, err = getNamePrefix(c.NamePrefix, c.Prefix); err != nil {
		return err
	}
	status, err := client.CheckSchemaStatus(ctx, prefix, c.Version)
	if err != nil {
		if c.Verbose {
			fmt.Printf("detail:%+v\n", err)
		}
		fmt.Println("Status: NOT OK")
		return err
	}
	fmt.Printf("Version: %d\n", status.Version)
	fmt.Printf("Status: %s\n", status.Status)
	return nil
}
11540
func (c *Database) ExecuteSQL(databaseId string, query string) ([]string, []interface{}, *DatabaseError, error) {
	var v DatabaseExecuteSQLParams
	v.DatabaseId = databaseId
	v.Query = query
	return c.ExecuteSQLWithParams(&v)
}
565522
func (d *domainClient) ExecuteSQL(ctx context.Context, args *ExecuteSQLArgs) (reply *ExecuteSQLReply, err error) {
	reply = new(ExecuteSQLReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "Database.executeSQL", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "Database.executeSQL", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "Database", Op: "ExecuteSQL", Err: err}
	}
	return
}
964452
func ExecuteQuery(c context.Context, q *datastore.Query, dst interface{}) error {

	keys, err := q.GetAll(c, dst)
	if err != nil {
		return errors.WrapOr(err)
	}

	return forEach(dst, func(index int, elem interface{}) error {
		if hk, ok := elem.(HasKey); ok {
			hk.SetKey(keys[index])
		}
		return nil
	})
}
1198353
func (c *SchemaUpsert) Execute(args []string) error {
	return c.doSchemaOp(schemaUpsert, dosa.AdminClient.UpsertSchema, c.Args.Paths)
}
117026
func (c *QueryRange) Execute(args []string) error {
	return c.doQueryOp(ShellQueryClient.Range, c.Args.EntityName, c.Args.Queries, c.Limit)
}
1031993
func TableInfo2Schema(ctx sessionctx.Context, tbl *model.TableInfo) *Schema {
	return TableInfo2SchemaWithDBName(ctx, model.CIStr{}, tbl)
}
801023
func (a *API) executeMcpCommand(res http.ResponseWriter, req *http.Request) {
	a.executeCommand(a.master.Command(req.URL.Query().Get(":command")),
		res,
		req,
	)
}
730344
func (m *DirectoryMigratorService) RunCommand(c *cli.Context) {
	fmt.Println("Running migrations...")

	db, _ := m.Connections.Make()
	db.LogMode(true)

	m.Migrations.Run(m.Directory.GetModels())

	fmt.Println("✔︎ Done!")
}
1330322
func (*localExecutor) Execute(command []string, in io.Reader, out, errOut io.Writer) error {
	klog.V(3).Infof("Local executor running command: %s", strings.Join(command, " "))
	cmd := exec.Command(command[0], command[1:]...)
	cmd.Stdout = out
	cmd.Stderr = errOut
	cmd.Stdin = in
	err := cmd.Run()
	if err != nil {
		klog.V(4).Infof("Error from local command execution: %v", err)
	}
	return err
}
520746
func ExecuteDBQuery(ctx context.Context, db *sql.DB, params map[string]string, query string) error {

	parsedQuery := parseQuery(params, query)

	stmt, err := db.PrepareContext(ctx, parsedQuery)
	if err != nil {
		return err
	}
	defer stmt.Close()

	return execute(ctx, stmt)
}
1017420
func (exec *TabletExecutor) Execute(ctx context.Context, sqls []string) *ExecuteResult {
	execResult := ExecuteResult{}
	execResult.Sqls = sqls
	if exec.isClosed {
		execResult.ExecutorErr = "executor is closed"
		return &execResult
	}
	startTime := time.Now()
	defer func() { execResult.TotalTimeSpent = time.Since(startTime) }()

	// Lock the keyspace so our schema change doesn't overlap with other
	// keyspace-wide operations like resharding migrations.
	ctx, unlock, lockErr := exec.wr.TopoServer().LockKeyspace(ctx, exec.keyspace, "ApplySchemaKeyspace")
	if lockErr != nil {
		execResult.ExecutorErr = lockErr.Error()
		return &execResult
	}
	defer func() {
		// This is complicated because execResult.ExecutorErr
		// is not of type error.
		var unlockErr error
		unlock(&unlockErr)
		if execResult.ExecutorErr == "" && unlockErr != nil {
			execResult.ExecutorErr = unlockErr.Error()
		}
	}()

	// Make sure the schema changes introduce a table definition change.
	if err := exec.preflightSchemaChanges(ctx, sqls); err != nil {
		execResult.ExecutorErr = err.Error()
		return &execResult
	}

	for index, sql := range sqls {
		execResult.CurSQLIndex = index
		exec.executeOnAllTablets(ctx, &execResult, sql)
		if len(execResult.FailedShards) > 0 {
			break
		}
	}
	return &execResult
}
1003912
func (environProviderCredentials) CredentialSchemas() map[cloud.AuthType]cloud.CredentialSchema {
	return map[cloud.AuthType]cloud.CredentialSchema{
		cloud.OAuth1AuthType: {{
			credAttrMAASOAuth, cloud.CredentialAttr{
				Description: "OAuth/API-key credentials for MAAS",
				Hidden:      true,
			},
		}},
	}
}
1114426
func sqlExec(db SqlExecutor, stmt, execErrPrefix string, args ...interface{}) (int64, error) {
	res, err := db.Exec(stmt, args...)
	if err != nil {
		return 0, fmt.Errorf(execErrPrefix + " " + err.Error())
	}
	if res == nil {
		return 0, nil
	}

	var N int64
	N, err = res.RowsAffected()
	if err != nil {
		return 0, fmt.Errorf(`error in RowsAffected: %v`, err)
	}
	return N, err
}
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()
}