本文整理汇总了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
}
示例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)
}
}
示例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))
}