當前位置: 首頁>>代碼示例>>Golang>>正文


Golang sqlparser.DDLParse函數代碼示例

本文整理匯總了Golang中github.com/youtube/vitess/go/vt/sqlparser.DDLParse函數的典型用法代碼示例。如果您正苦於以下問題:Golang DDLParse函數的具體用法?Golang DDLParse怎麽用?Golang DDLParse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了DDLParse函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: execDDL

func (qe *QueryEngine) execDDL(logStats *sqlQueryStats, ddl string) *mproto.QueryResult {
	ddlPlan := sqlparser.DDLParse(ddl)
	if ddlPlan.Action == 0 {
		panic(NewTabletError(FAIL, "DDL is not understood"))
	}

	// Stolen from Begin
	conn := qe.txPool.Get()
	txid, err := qe.activeTxPool.SafeBegin(conn)
	if err != nil {
		conn.Recycle()
		panic(err)
	}
	// Stolen from Commit
	defer qe.activeTxPool.SafeCommit(txid)

	// Stolen from Execute
	conn = qe.activeTxPool.Get(txid)
	defer conn.Recycle()
	result, err := qe.executeSql(logStats, conn, ddl, false)
	if err != nil {
		panic(NewTabletErrorSql(FAIL, err))
	}

	qe.schemaInfo.DropTable(ddlPlan.TableName)
	if ddlPlan.Action != sqlparser.DROP { // CREATE, ALTER, RENAME
		qe.schemaInfo.CreateTable(ddlPlan.NewName)
	}
	return result
}
開發者ID:jekey,項目名稱:vitess,代碼行數:30,代碼來源:query_engine.go

示例2: InvalidateForDDL

// InvalidateForDDL performs schema and rowcache changes for the ddl.
func (qe *QueryEngine) InvalidateForDDL(ddlInvalidate *proto.DDLInvalidate) {
	ddlPlan := sqlparser.DDLParse(ddlInvalidate.DDL)
	if ddlPlan.Action == 0 {
		panic(NewTabletError(FAIL, "DDL is not understood"))
	}
	qe.schemaInfo.DropTable(ddlPlan.TableName)
	if ddlPlan.Action != sqlparser.DROP { // CREATE, ALTER, RENAME
		qe.schemaInfo.CreateTable(ddlPlan.NewName)
	}
}
開發者ID:kingpro,項目名稱:vitess,代碼行數:11,代碼來源:query_engine.go

示例3: InvalidateForDDL

func (qe *QueryEngine) InvalidateForDDL(ddlInvalidate *proto.DDLInvalidate) {
	qe.mu.RLock()
	defer qe.mu.RUnlock()

	ddlPlan := sqlparser.DDLParse(ddlInvalidate.DDL)
	if ddlPlan.Action == 0 {
		panic(NewTabletError(FAIL, "DDL is not understood"))
	}
	qe.schemaInfo.DropTable(ddlPlan.TableName)
	if ddlPlan.Action != sqlparser.DROP { // CREATE, ALTER, RENAME
		qe.schemaInfo.CreateTable(ddlPlan.NewName)
	}
	qe.adminCache.Set(ROWCACHE_INVALIDATION_POSITION, 0, 0, []byte(ddlInvalidate.Position))
}
開發者ID:shrutip,項目名稱:vitess,代碼行數:14,代碼來源:query_engine.go


注:本文中的github.com/youtube/vitess/go/vt/sqlparser.DDLParse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。