driver/driver_legacy.go
func (c *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (rows driver.Rows, err error) {
	if c.session.IsBad() {
		return nil, driver.ErrBadConn
	}

	if len(args) != 0 {
		return nil, driver.ErrSkip //fast path not possible (prepare needed)
	}

	// direct execution of call procedure
	// - returns no parameter metadata (sps 82) but only field values
	// --> let's take the 'prepare way' for stored procedures
	if checkCallProcedure(query) {
		return nil, driver.ErrSkip
	}

	sqltrace.Traceln(query)

	id, idx, ok := decodeTableQuery(query)
	if ok {
		r := procedureCallResultStore.get(id)
		if r == nil {
			return nil, fmt.Errorf("invalid procedure table query %s", query)
		}
		return r.tableRows(int(idx))
	}

	done := make(chan struct{})
	go func() {
		var (
			id             uint64
			resultFieldSet *p.ResultFieldSet
			fieldValues    *p.FieldValues
			attributes     p.PartAttributes
		)
		id, resultFieldSet, fieldValues, attributes, err = c.session.QueryDirect(query)
		if err != nil {
			goto done
		}
		select {
		default:
		case <-ctx.Done():
			return
		}
		if id == 0 { // non select query
			rows = noResult
		} else {
			rows, err = newQueryResult(c.session, id, resultFieldSet, fieldValues, attributes)
		}
	done:
		close(done)
	}()

	select {
	case <-ctx.Done():
		return nil, ctx.Err()
	case <-done:
		return rows, err
	}
}
func (c *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (rows driver.Rows, err error) {
	if c.session.IsBad() {
		return nil, driver.ErrBadConn
	}

	if len(args) != 0 {
		return nil, driver.ErrSkip //fast path not possible (prepare needed)
	}

	// direct execution of call procedure
	// - returns no parameter metadata (sps 82) but only field values
	// --> let's take the 'prepare way' for stored procedures
	if checkCallProcedure(query) {
		return nil, driver.ErrSkip
	}

	sqltrace.Traceln(query)

	id, idx, ok := decodeTableQuery(query)
	if ok {
		r := procedureCallResultStore.get(id)
		if r == nil {
			return nil, fmt.Errorf("invalid procedure table query %s", query)
		}
		return r.tableRows(int(idx))
	}

	done := make(chan struct{})
	go func() {
		var (
			id             uint64
			resultFieldSet *p.ResultFieldSet
			fieldValues    *p.FieldValues
			attributes     p.PartAttributes
		)
		id, resultFieldSet, fieldValues, attributes, err = c.session.QueryDirect(query)
		if err != nil {
			goto done
		}
		select {
		default:
		case <-ctx.Done():
			return
		}
		if id == 0 { // non select query
			rows = noResult
		} else {
			rows, err = newQueryResult(c.session, id, resultFieldSet, fieldValues, attributes)
		}
	done:
		close(done)
	}()

	select {
	case <-ctx.Done():
		return nil, ctx.Err()
	case <-done:
		return rows, err
	}
}
func ( c * conn ) QueryContext ( ctx context . Context , query string , args [ ] driver . NamedValue ) ( rows driver . Rows , err error ) { if c . session . IsBad ( ) { return nil , driver . ErrBadConn } if len ( args ) != 0 { return nil , driver . ErrSkip //fast path not possible (prepare needed) } // direct execution of call procedure // - returns no parameter metadata (sps 82) but only field values // --> let's take the 'prepare way' for stored procedures if checkCallProcedure ( query ) { return nil , driver . ErrSkip } sqltrace . Traceln ( query ) id , idx , ok := decodeTableQuery ( query ) if ok { r := procedureCallResultStore . get ( id ) if r == nil { return nil , fmt . Errorf ( " " , query ) } return r . tableRows ( int ( idx ) ) } done := make ( chan struct { } ) go func ( ) { var ( id uint64 resultFieldSet * p . ResultFieldSet fieldValues * p . FieldValues attributes p . PartAttributes ) id , resultFieldSet , fieldValues , attributes , err = c . session . QueryDirect ( query ) if err != nil { goto done } select { default : case <- ctx . Done ( ) : return } if id == 0 { // non select query rows = noResult } else { rows , err = newQueryResult ( c . session , id , resultFieldSet , fieldValues , attributes ) } done : close ( done ) } ( ) select { case <- ctx . Done ( ) : return nil , ctx . Err ( ) case <- done : return rows , err } }
// QueryContext implements the database/sql/driver/QueryerContext interface.
QueryContext implements the database / sql / driver / QueryerContext interface .