github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/allegrosql/server/driver.go (about)

     1  // Copyright 2020 WHTCORPS INC, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package server
    15  
    16  import (
    17  	"context"
    18  	"crypto/tls"
    19  
    20  	"github.com/whtcorpsinc/milevadb/types"
    21  	"github.com/whtcorpsinc/milevadb/soliton/chunk"
    22  )
    23  
    24  // IDriver opens IContext.
    25  type IDriver interface {
    26  	// OpenCtx opens an IContext with connection id, client capability, defCauslation, dbname and optionally the tls state.
    27  	OpenCtx(connID uint64, capability uint32, defCauslation uint8, dbname string, tlsState *tls.ConnectionState) (*MilevaDBContext, error)
    28  }
    29  
    30  // PreparedStatement is the interface to use a prepared memex.
    31  type PreparedStatement interface {
    32  	// ID returns memex ID
    33  	ID() int
    34  
    35  	// InterDircute executes the memex.
    36  	InterDircute(context.Context, []types.Causet) (ResultSet, error)
    37  
    38  	// AppendParam appends parameter to the memex.
    39  	AppendParam(paramID int, data []byte) error
    40  
    41  	// NumParams returns number of parameters.
    42  	NumParams() int
    43  
    44  	// BoundParams returns bound parameters.
    45  	BoundParams() [][]byte
    46  
    47  	// SetParamsType sets type for parameters.
    48  	SetParamsType([]byte)
    49  
    50  	// GetParamsType returns the type for parameters.
    51  	GetParamsType() []byte
    52  
    53  	// StoreResultSet stores ResultSet for subsequent stmt fetching
    54  	StoreResultSet(rs ResultSet)
    55  
    56  	// GetResultSet gets ResultSet associated this memex
    57  	GetResultSet() ResultSet
    58  
    59  	// Reset removes all bound parameters.
    60  	Reset()
    61  
    62  	// Close closes the memex.
    63  	Close() error
    64  }
    65  
    66  // ResultSet is the result set of an query.
    67  type ResultSet interface {
    68  	DeferredCausets() []*DeferredCausetInfo
    69  	NewChunk() *chunk.Chunk
    70  	Next(context.Context, *chunk.Chunk) error
    71  	StoreFetchedRows(rows []chunk.Row)
    72  	GetFetchedRows() []chunk.Row
    73  	Close() error
    74  }
    75  
    76  // fetchNotifier represents notifier will be called in COM_FETCH.
    77  type fetchNotifier interface {
    78  	// OnFetchReturned be called when COM_FETCH returns.
    79  	// it will be used in server-side cursor.
    80  	OnFetchReturned()
    81  }