예제 #1
0
func (rci *RowcacheInvalidator) handleDDLEvent(ddl string) {
	ddlPlan := planbuilder.DDLParse(ddl)
	if ddlPlan.Action == "" {
		panic(NewTabletError(FAIL, "DDL is not understood"))
	}
	if ddlPlan.TableName != "" && ddlPlan.TableName != ddlPlan.NewName {
		// It's a drop or rename.
		rci.qe.schemaInfo.DropTable(ddlPlan.TableName)
	}
	if ddlPlan.NewName != "" {
		rci.qe.schemaInfo.CreateOrUpdateTable(ddlPlan.NewName)
	}
}
예제 #2
0
func (qre *QueryExecutor) execDDL() *mproto.QueryResult {
	ddlPlan := planbuilder.DDLParse(qre.query)
	if ddlPlan.Action == "" {
		panic(NewTabletError(FAIL, "DDL is not understood"))
	}

	txid := qre.qe.txPool.Begin()
	defer qre.qe.txPool.SafeCommit(txid)

	// Stolen from Execute
	conn := qre.qe.txPool.Get(txid)
	defer conn.Recycle()
	result := qre.execSQL(conn, qre.query, false)

	if ddlPlan.TableName != "" && ddlPlan.TableName != ddlPlan.NewName {
		// It's a drop or rename.
		qre.qe.schemaInfo.DropTable(ddlPlan.TableName)
	}
	if ddlPlan.NewName != "" {
		qre.qe.schemaInfo.CreateOrUpdateTable(ddlPlan.NewName)
	}
	return result
}