Skip to content

Commit

Permalink
MB-50370, MB-50377. EXECUTE statement get the underneath statement type
Browse files Browse the repository at this point in the history
Change-Id: If8310832581fa60f13cdfb4333e565daa2c624bc
Reviewed-on: https://review.couchbase.org/c/query/+/168646
Reviewed-by: Bingjie Miao <bingjie.miao@couchbase.com>
Tested-by: Sitaram Vemulapalli <sitaram.vemulapalli@couchbase.com>
  • Loading branch information
sitaramv committed Jan 13, 2022
1 parent 637f0fb commit c9272b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion execution/context.go
Expand Up @@ -748,7 +748,7 @@ func (this *Context) SetTransactionInfo(txId string, txStmtNum int64) (err error
func (this *Context) SetTransactionContext(stmtType string, txImplicit bool, rTxTimeout, sTxTimeout time.Duration,
atrCollection string, numAtrs int, txData []byte) (err errors.Error) {

if this.txContext != nil || txImplicit || stmtType == "START_TRANSACTION" {
if this.txContext != nil || stmtType == "START_TRANSACTION" || (txImplicit && stmtType != "EXECUTE_FUNCTION") {
this.txData = txData
if len(txData) > 0 {
this.txDataVal = value.NewValue(txData)
Expand Down
16 changes: 14 additions & 2 deletions execution/eval_stmt.go
Expand Up @@ -143,8 +143,12 @@ func (this *Context) EvaluateStatement(statement string, namedArgs map[string]va
if err != nil {
return nil, 0, err
}
stmtType := stmt.Type()
if stmtType == "EXECUTE" && isPrepared {
stmtType = prepared.Type()
}
rv, mutations, err := newContext.ExecutePrepared(prepared, isPrepared, namedArgs, positionalArgs)
newErr := newContext.completeStatement(stmt.Type(), err == nil, this)
newErr := newContext.completeStatement(stmtType, err == nil, this)
if newErr != nil {
err = newErr
}
Expand Down Expand Up @@ -190,12 +194,16 @@ func (this *Context) OpenStatement(statement string, namedArgs map[string]value.
if err != nil {
return nil, err
}
stmtType := stmt.Type()
if stmtType == "EXECUTE" && isPrepared {
stmtType = prepared.Type()
}

namedArgs, positionalArgs, err = newContext.handleUsing(stmt, namedArgs, positionalArgs)
if err != nil {
return nil, err
}
rv, err := newContext.OpenPrepared(stmt.Type(), prepared, isPrepared, namedArgs, positionalArgs)
rv, err := newContext.OpenPrepared(stmtType, prepared, isPrepared, namedArgs, positionalArgs)
if rv != nil {
h := rv.(*executionHandle)
h.baseContext = this
Expand Down Expand Up @@ -311,6 +319,10 @@ func (this *Context) PrepareStatement(statement string, namedArgs map[string]val
if err != nil {
return nil, prepared, isPrepared, err
}

if ok, msg := transactions.IsValidStatement(txId, prepared.Type(), txImplicit, false); !ok {
return nil, nil, false, errors.NewTranStatementNotSupportedError(stype, msg)
}
isPrepared = true

default:
Expand Down

0 comments on commit c9272b4

Please sign in to comment.