本文整理匯總了Golang中C.vt_execute函數的典型用法代碼示例。如果您正苦於以下問題:Golang vt_execute函數的具體用法?Golang vt_execute怎麽用?Golang vt_execute使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了vt_execute函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExecuteFetch
// ExecuteFetch executes the query on the connection
func (conn *Connection) ExecuteFetch(query string, maxrows int, wantfields bool) (qr *sqltypes.Result, err error) {
if conn.IsClosed() {
return nil, sqldb.NewSQLError(2006, "Connection is closed")
}
if C.vt_execute(&conn.c, (*C.char)(hack.StringPointer(query)), C.ulong(len(query)), 0) != 0 {
return nil, conn.lastError(query)
}
defer conn.CloseResult()
qr = &sqltypes.Result{}
qr.RowsAffected = uint64(conn.c.affected_rows)
qr.InsertID = uint64(conn.c.insert_id)
if conn.c.num_fields == 0 {
return qr, nil
}
if qr.RowsAffected > uint64(maxrows) {
return nil, &sqldb.SQLError{
Num: 0,
Message: fmt.Sprintf("Row count exceeded %d", maxrows),
Query: string(query),
}
}
if wantfields {
qr.Fields = conn.Fields()
}
qr.Rows, err = conn.fetchAll()
return qr, err
}
示例2: ExecuteStreamFetch
// ExecuteStreamFetch starts a streaming query to mysql. Use FetchNext
// on the Connection until it returns nil or error
func (conn *Connection) ExecuteStreamFetch(query string) (err error) {
if conn.IsClosed() {
return sqldb.NewSQLError(2006, "Connection is closed")
}
if C.vt_execute(&conn.c, (*C.char)(hack.StringPointer(query)), C.ulong(len(query)), 1) != 0 {
return conn.lastError(query)
}
return nil
}