// Start parsing after `CREATE TABLE *** (`
422993
func (p *Parser) parseCreateTableFields(ctx *parseCtx, stmt model.Table) error {
	for {
		ctx.skipWhiteSpaces()
		switch t := ctx.peek(); t.Type {
		case CONSTRAINT:
			if err := p.parseTableConstraint(ctx, stmt); err != nil {
				return err
			}
		case PRIMARY:
			if err := p.parseTablePrimaryKey(ctx, stmt); err != nil {
				return err
			}
		case UNIQUE:
			if err := p.parseTableUniqueKey(ctx, stmt); err != nil {
				return err
			}
		case INDEX, KEY:
			// TODO. separate to KEY and INDEX
			if err := p.parseTableIndex(ctx, stmt); err != nil {
				return err
			}
		case FULLTEXT:
			if err := p.parseTableFulltextIndex(ctx, stmt); err != nil {
				return err
			}
		case SPATIAL:
			if err := p.parseTableSpatialIndex(ctx, stmt); err != nil {
				return err
			}
		case FOREIGN:
			if err := p.parseTableForeignKey(ctx, stmt); err != nil {
				return err
			}
		case CHECK: // TODO
			return newParseError(ctx, t, "unsupported field: CHECK")
		case IDENT, BACKTICK_IDENT:
			if err := p.parseTableColumn(ctx, stmt); err != nil {
				return err
			}
		default:
			return newParseError(ctx, t, "unexpected create table field token: %s", t.Type)
		}

		ctx.skipWhiteSpaces()
		switch t := ctx.peek(); t.Type {
		case RPAREN:
			ctx.advance()
			if err := p.parseCreateTableOptions(ctx, stmt); err != nil {
				return err
			}
			// partition option
			if !p.eol(ctx) {
				return newParseError(ctx, t, "expected EOL")
			}
			return nil
		case COMMA:
			ctx.advance()
			// Expecting another table field, keep looping
		default:
			return newParseError(ctx, t, "expected RPAREN or COMMA")
		}
	}
}
562981
func (buf *Buffer) Start() error {
	if buf.pos <= 0 {
		return nil
	}

	buf.pos = 0
	return buf.Refresh()
}
345040
func (s *Server) Start() error {
	go func() {
		s.wg.Add(1)
		defer s.wg.Done()
		HandleRXPackets(&s.wg)
	}()

	go func() {
		s.wg.Add(1)
		defer s.wg.Done()
		HandleDownlinkTXAcks(&s.wg)
	}()
	return nil
}
1100059
func init() {
	dcrsqlite.UseLogger(sqliteLog)
	dcrpg.UseLogger(postgresqlLog)
	stakedb.UseLogger(stakedbLog)
	blockdata.UseLogger(BlockdataLog)
	rpcclient.UseLogger(clientLog)
	rpcutils.UseLogger(clientLog)
	mempool.UseLogger(mempoolLog)
	explorer.UseLogger(expLog)
	api.UseLogger(apiLog)
	insight.UseLogger(iapiLog)
	middleware.UseLogger(apiLog)
	notify.UseLogger(notifyLog)
	pubsub.UseLogger(pubsubLog)
	exchanges.UseLogger(xcBotLog)
	agendas.UseLogger(agendasLog)
	politeia.UseLogger(proposalsLog)
}
771623
func (m *DbMap) CreateTablesSql() (map[string]string, error) {
	return m.createTables(false, false)
}
447068
func (processor *processor) Start() error {
	var errs qor.Errors
	processor.Initialize()
	if errs.AddError(processor.Validate()); !errs.HasError() {
		errs.AddError(processor.Commit())
	}
	if errs.HasError() {
		return errs
	}
	return nil
}
1061485
func (it *invDatastoreIter) start(c context.Context, query *datastore.Query) {
	it.results = make(chan *Invocation)
	it.done = make(chan struct{})
	go func() {
		defer close(it.results)
		err := datastore.Run(c, query, func(obj *Invocation, cb datastore.CursorCB) error {
			select {
			case it.results <- obj:
				return nil
			case <-it.done:
				return datastore.Stop
			}
		})
		// Let 'next' and 'stop' know about the error. They look here if they
		// receive 'nil' from the results channel (which happens if it is closed).
		it.err = err
	}()
}
637008
func (c *asyncConnHdl) startup() {

	protocol := c.spec().protocol

	go c.worker(manager, "manager", managementTask, c.managerCtl, nil)
	c.managerCtl <- start

	// heartbeat only on REDIS_DB protocol
	if protocol == REDIS_DB {
		go c.worker(heartbeatworker, "heartbeat", heartbeatTask, c.heartbeatCtl, c.feedback)
		c.heartbeatCtl <- start
	}

	go c.worker(requesthandler, "request-processor", reqProcessingTask, c.reqProcCtl, c.feedback)
	c.reqProcCtl <- start

	var rspProcTask workerTask
	switch protocol {
	case REDIS_DB:
		rspProcTask = dbRspProcessingTask
	case REDIS_PUBSUB:
		rspProcTask = msgProcessingTask
		//		cmd := SUBSCRIBE
		//		c.pendingResps <- &asyncRequestInfo{0, 0, &cmd, nil, nil, nil}
	}
	go c.worker(responsehandler, "response-processor", rspProcTask, c.rspProcCtl, c.feedback)
	c.rspProcCtl <- start

	// REVU - pretty please TODO do the customized log
	//	log.Printf("<INFO> %s - READY", c)
}
437797
func (s *Server) Start() error {
	if s.HostPortHTTP == "" {
		s.HostPortHTTP = ":" + common.DefaultServerPortHTTP
	}

	s.eHandler = endtoend.NewHandler(s.AgentHostPort, s.SamplingServerURL)

	mux := http.NewServeMux()
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { return }) // health check
	mux.HandleFunc("/start_trace", func(w http.ResponseWriter, r *http.Request) {
		s.handleJSON(w, r, func() interface{} {
			return tracetest.NewStartTraceRequest()
		}, func(ctx context.Context, req interface{}) (interface{}, error) {
			return s.doStartTrace(req.(*tracetest.StartTraceRequest))
		})
	})
	mux.HandleFunc("/join_trace", func(w http.ResponseWriter, r *http.Request) {
		s.handleJSON(w, r, func() interface{} {
			return tracetest.NewJoinTraceRequest()
		}, func(ctx context.Context, req interface{}) (interface{}, error) {
			return s.doJoinTrace(ctx, req.(*tracetest.JoinTraceRequest))
		})
	})
	mux.HandleFunc("/create_traces", s.eHandler.GenerateTraces)

	listener, err := net.Listen("tcp", s.HostPortHTTP)
	if err != nil {
		return err
	}
	s.listener = listener
	s.HostPortHTTP = listener.Addr().String()

	var started sync.WaitGroup
	started.Add(1)
	go func() {
		started.Done()
		http.Serve(listener, mux)
	}()
	started.Wait()
	log.Printf("Started http server at %s\n", s.HostPortHTTP)
	return nil
}
642142
func (t *Table) init() error {
	if t.initialized {
		return nil
	}

	if err := t.initBuild(); err != nil {
		return err
	}

	// initialize all the nested fields
	for i := range t.Fields {
		if err := t.Fields[i].init(); err != nil {
			return Errorf(err, "initializing field %s", t.Fields[i].Name)
		}
	}

	t.initialized = true
	return nil
}
683491
func (starter *starter) Start() (err error) {
	for {
		if err = starter.server.Handle(); err != nil {
			return err
		}
		starter.c = make(chan os.Signal, 1)
		signal.Notify(starter.c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
		s := <-starter.c
		starter.server.Close()
		switch s {
		case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL:
			signal.Stop(starter.c)
			return
		}
	}
}
1275572
func (sr *SimpleRedis) start(db keyval.BytesBroker) {
	sr.log.Info("Start putting data to Redis...")
	time.Sleep(2 * time.Second)

	// basic key-value entry
	if err := db.Put(sr.prefix+"/key1", []byte("data1")); err != nil {
		sr.log.Errorf("put key1 failed: %v", err)
	} else {
		sr.log.Info("key1 stored in DB")
	}
	if data, found, _, err := db.GetValue(sr.prefix + "/key1"); err != nil {
		sr.log.Errorf("get key1 failed: %v", err)
	} else if !found {
		sr.log.Errorf("expected key1 does not exist: %v", err)
	} else {
		sr.log.Infof("key1 read from DB (data: %v)", data)
	}

	// key-value entry with TTL
	if err := db.Put(sr.prefix+"/key2", []byte("data2"), datasync.WithTTL(2*time.Second)); err != nil {
		sr.log.Errorf("put key1 failed: %v", err)
	}
	if data, found, _, err := db.GetValue(sr.prefix + "/key2"); err != nil {
		sr.log.Errorf("get key2 failed: %v", err)
	} else if !found {
		sr.log.Errorf("expected key2 does not exist: %v", err)
	} else {
		sr.log.Infof("key2 read from DB (data: %v)", data)
	}
	sr.log.Info("waiting for key2 TTL...")
	time.Sleep(3 * time.Second)
	if _, found, _, err := db.GetValue(sr.prefix + "/key2"); err != nil {
		sr.log.Errorf("get key2 after TTL failed: %v", err)
	} else if !found {
		sr.log.Info("key2 does not exist (expired TTL)")
	} else {
		sr.log.Error("key2 should not exist")
	}

	// put several another keys as txn
	sr.log.Info("Put a few more keys as transaction...")
	txn := db.NewTxn()
	for i := 3; i <= 11; i++ {
		txn.Put(sr.prefix+"/key"+strconv.Itoa(i), []byte("data"+strconv.Itoa(i)))
	}
	if err := txn.Commit(context.Background()); err != nil {
		sr.log.Errorf("failed to commit transaction: %v", err)
	}
	sr.log.Info("... done")

	// list keys
	sr.log.Info("Listing keys (expected 10 entries)")
	var count int8
	keys, err := db.ListKeys(sr.prefix)
	if err != nil {
		sr.log.Errorf("failed to list keys: %v", err)
	} else {
		for {
			key, _, done := keys.GetNext()
			if done {
				break
			}
			sr.log.Debugf("Found key %s", key)
			count++
		}
		if count == 10 {
			sr.log.Info("all expected keys were found")
		} else {
			sr.log.Errorf("failed to get all the keys (expected 10, got %d)", count)
		}
	}

	// list keys
	sr.log.Info("Listing values (expected 10 entries)")
	count = 0
	values, err := db.ListValues(sr.prefix)
	if err != nil {
		sr.log.Errorf("failed to list values: %v", err)
	} else {
		for {
			kv, done := values.GetNext()
			if done {
				break
			}
			sr.log.Debugf("Found value %s", string(kv.GetValue()))
			count++
		}
		if count == 10 {
			sr.log.Info("all expected values were found")
		} else {
			sr.log.Errorf("failed to get all the values (expected 10, got %d)", count)
		}
	}
}
596258
func (c *command) Start() error {
	cmd := endpointToCommand(c.command, c.endpoint)

	e := pktline.NewEncoder(c.conn)
	return e.Encode([]byte(cmd))
}
22126
func (m *mysqlWriter) Table(tbl *schema.Table) string {

	w := &bytes.Buffer{}
	//u.Infof("%s tbl=%p fields? %#v fields?%v", tbl.Name, tbl, tbl.FieldMap, len(tbl.Fields))
	fmt.Fprintf(w, "CREATE TABLE `%s` (", tbl.Name)
	for i, fld := range tbl.Fields {
		if i != 0 {
			w.WriteByte(',')
		}
		fmt.Fprint(w, "\n    ")
		mysqlWriteField(w, fld)
	}
	fmt.Fprint(w, "\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;")
	//tblStr := fmt.Sprintf("CREATE TABLE `%s` (\n\n);", tbl.Name, strings.Join(cols, ","))
	//return tblStr, nil
	return w.String()
}
392327
func TableCreate(name interface{}, optArgs ...TableCreateOpts) Term {
	opts := map[string]interface{}{}
	if len(optArgs) >= 1 {
		opts = optArgs[0].toMap()
	}
	return constructRootTerm("TableCreate", p.Term_TABLE_CREATE, []interface{}{name}, opts)
}
249529
func CreateTables(db *sql.DB) error {
	// Create all of the data tables.
	for tableName, createCommand := range createTableStatements {
		err := createTable(db, tableName, createCommand)
		if err != nil {
			return err
		}
	}

	return ClearTestingTable(db)
}
845482
func buildParser(name string, tbl *ast.Table) (parsers.Parser, error) {
	config, err := getParserConfig(name, tbl)
	if err != nil {
		return nil, err
	}
	return parsers.NewParser(config)
}