ExecuteNormal used to execute non-2pc querys to shards with timeout limits. timeout: 0x01. if timeout <= 0, no limits. 0x02. if timeout > 0, the query will be interrupted if the timeout(in millisecond) is exceeded.
(session *driver.Session, database string, query string, node sqlparser.Statement, timeout int)
| 127 | // 0x01. if timeout <= 0, no limits. |
| 128 | // 0x02. if timeout > 0, the query will be interrupted if the timeout(in millisecond) is exceeded. |
| 129 | func (spanner *Spanner) executeWithTimeout(session *driver.Session, database string, query string, node sqlparser.Statement, timeout int) (*sqltypes.Result, error) { |
| 130 | log := spanner.log |
| 131 | conf := spanner.conf |
| 132 | router := spanner.router |
| 133 | scatter := spanner.scatter |
| 134 | sessions := spanner.sessions |
| 135 | |
| 136 | // transaction. |
| 137 | txn, err := scatter.CreateTransaction() |
| 138 | if err != nil { |
| 139 | log.Error("spanner.txn.create.error:[%v]", err) |
| 140 | return nil, err |
| 141 | } |
| 142 | defer txn.Finish() |
| 143 | |
| 144 | // txn limits. |
| 145 | txn.SetTimeout(timeout) |
| 146 | txn.SetMaxResult(conf.Proxy.MaxResultSize) |
| 147 | txn.SetMaxJoinRows(conf.Proxy.MaxJoinRows) |
| 148 | txn.SetIsExecOnRep(isExecOnRep(conf.Proxy.LoadBalance, node)) |
| 149 | |
| 150 | // binding. |
| 151 | sessions.TxnBinding(session, txn, node, query) |
| 152 | defer sessions.TxnUnBinding(session) |
| 153 | |
| 154 | plans, err := optimizer.NewSimpleOptimizer(log, database, query, node, router).BuildPlanTree() |
| 155 | if err != nil { |
| 156 | return nil, err |
| 157 | } |
| 158 | executors := executor.NewTree(log, plans, txn) |
| 159 | qr, err := executors.Execute() |
| 160 | if err != nil { |
| 161 | return nil, err |
| 162 | } |
| 163 | return qr, nil |
| 164 | } |
| 165 | |
| 166 | // ExecuteStreamFetch used to execute a stream fetch query. |
| 167 | func (spanner *Spanner) ExecuteStreamFetch(session *driver.Session, database string, query string, node sqlparser.Statement, callback func(qr *sqltypes.Result) error) error { |
no test coverage detected