diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d8738df..6cb2b71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,4 +21,6 @@ jobs: - name: Test env: GOPROXY: "https://proxy.golang.org" - run: go test -v . \ No newline at end of file + run: | + go test -v ./ ./internal/cache -covermode=count -coverprofile=coverage.out + go tool cover -func=coverage.out -o=coverage.out diff --git a/Makefile b/Makefile index 2eff84a..c607fde 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,15 @@ build: fmt: go fmt ./... -test: test-mariadb test-postgres test-mssql +test: test-go test-mariadb test-postgres test-mssql + +test-go: + go test ./ ./internal/cache -covermode=count -coverprofile=coverage.out + go tool cover -func=coverage.out -o=coverage.out + test-mariadb: docker compose run --rm mariadb_test - go tool cover -html test/acceptance/mariadb/coverage.out -o test/acceptance/mariadb/coverage.html test-postgres: docker compose run --rm postgres_test diff --git a/conn.go b/conn.go index f38869d..35c5b3f 100644 --- a/conn.go +++ b/conn.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "database/sql/driver" + "errors" "fmt" "github.com/ninthclowd/unixodbc/internal/cache" "github.com/ninthclowd/unixodbc/internal/odbc" @@ -18,7 +19,6 @@ var ( _ driver.Pinger = (*Connection)(nil) _ driver.Conn = (*Connection)(nil) _ driver.NamedValueChecker = (*Connection)(nil) - _ driver.SessionResetter = (*Connection)(nil) _ driver.Validator = (*Connection)(nil) ) @@ -31,7 +31,7 @@ var toODBCIsoLvl = map[sql.IsolationLevel]odbc.IsolationLevel{ type Connection struct { connector *Connector - odbcConnection *odbc.Connection + odbcConnection odbc.Connection openTX *TX cachedStatements *cache.LRU[PreparedStatement] } @@ -45,12 +45,6 @@ func (c *Connection) IsValid() bool { return true } -// ResetSession implements driver.SessionResetter -func (c *Connection) ResetSession(ctx context.Context) error { - //TODO implement me - return nil -} - // CheckNamedValue implements driver.NamedValueChecker func (c *Connection) CheckNamedValue(value *driver.NamedValue) error { switch value.Value.(type) { @@ -131,7 +125,7 @@ func (c *Connection) Prepare(query string) (driver.Stmt, error) { // PrepareContext implements driver.ConnPrepareContext func (c *Connection) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) { - ctx, trace := Tracer.NewTask(ctx, "Connection::PrepareContext") + ctx, trace := Tracer.NewTask(ctx, "connection::PrepareContext") defer trace.End() Tracer.Logf(ctx, "query", query) @@ -152,7 +146,7 @@ func (c *Connection) PrepareContext(ctx context.Context, query string) (driver.S return stmt, nil } - var st *odbc.Statement + var st odbc.Statement Tracer.WithRegion(ctx, "Create statement", func() { st, err = c.odbcConnection.Statement() }) @@ -186,10 +180,10 @@ func (c *Connection) PrepareContext(ctx context.Context, query string) (driver.S // ExecContext implements driver.ExecerContext func (c *Connection) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) { - ctx, trace := Tracer.NewTask(ctx, "Connection::ExecContext") + ctx, trace := Tracer.NewTask(ctx, "connection::ExecContext") defer trace.End() Tracer.Logf(ctx, "query", query) - var st *odbc.Statement + var st odbc.Statement var err error Tracer.WithRegion(ctx, "Create statement", func() { @@ -200,7 +194,7 @@ func (c *Connection) ExecContext(ctx context.Context, query string, args []drive } defer func() { Tracer.WithRegion(ctx, "Close statement", func() { - st.Close() + _ = st.Close() }) }() Tracer.WithRegion(ctx, "Bind parameters", func() { @@ -220,11 +214,11 @@ func (c *Connection) ExecContext(ctx context.Context, query string, args []drive // QueryContext implements driver.QueryerContext func (c *Connection) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) { - ctx, trace := Tracer.NewTask(ctx, "Connection::QueryContext") + ctx, trace := Tracer.NewTask(ctx, "connection::QueryContext") defer trace.End() Tracer.Logf(ctx, "query", query) - var st *odbc.Statement + var st odbc.Statement var err error Tracer.WithRegion(ctx, "Create statement", func() { @@ -249,7 +243,7 @@ func (c *Connection) QueryContext(ctx context.Context, query string, args []driv _ = st.Close() return nil, err } - var rs *odbc.RecordSet + var rs odbc.RecordSet Tracer.WithRegion(ctx, "Getting recordset", func() { rs, err = st.RecordSet() }) @@ -263,18 +257,17 @@ func (c *Connection) QueryContext(ctx context.Context, query string, args []driv // Ping implements driver.Pinger func (c *Connection) Ping(ctx context.Context) error { - ctx, trace := Tracer.NewTask(ctx, "Connection::Ping") + ctx, trace := Tracer.NewTask(ctx, "connection::Ping") defer trace.End() if c.odbcConnection == nil { return driver.ErrBadConn } - switch err := c.odbcConnection.Ping(); err { - case odbc.ErrConnectionDead: + switch err := c.odbcConnection.Ping(); { + case errors.Is(err, odbc.ErrConnectionDead): return driver.ErrBadConn default: return err } - return nil } func toValues(args []driver.NamedValue) (values []interface{}) { diff --git a/conn_test.go b/conn_test.go new file mode 100644 index 0000000..f5f1bbc --- /dev/null +++ b/conn_test.go @@ -0,0 +1,390 @@ +package unixodbc + +import ( + "context" + "database/sql" + "database/sql/driver" + "errors" + "github.com/golang/mock/gomock" + "github.com/ninthclowd/unixodbc/internal/cache" + "github.com/ninthclowd/unixodbc/internal/mocks" + "github.com/ninthclowd/unixodbc/internal/odbc" + "testing" + "time" +) + +func testDBConnection(t *testing.T, cacheSize int) (ctrl *gomock.Controller, conn *sql.Conn, mockConn *mocks.MockConnection) { + + ctrl = gomock.NewController(t) + mockEnv := mocks.NewMockEnvironment(ctrl) + + mockEnv.EXPECT().SetVersion(odbc.Version380).Return(nil).Times(1) + mockEnv.EXPECT().SetPoolOption(odbc.PoolOff).Return(nil).Times(1) + + connString := "connString" + + db := sql.OpenDB(&Connector{ + ConnectionString: StaticConnStr(connString), + StatementCacheSize: cacheSize, + odbcEnvironment: mockEnv, + }) + + ctx := context.Background() + + mockConn = mocks.NewMockConnection(ctrl) + mockConn.EXPECT().SetAutoCommit(true).Return(nil).Times(1) + + mockEnv.EXPECT().Connect(gomock.Any(), connString).Return(mockConn, nil) + var err error + conn, err = db.Conn(ctx) + if err != nil { + t.Fatalf("unable to open connection: %v", err) + } + + return +} + +func testConnection(t *testing.T) (ctrl *gomock.Controller, conn *Connection, mockConn *mocks.MockConnection) { + ctrl = gomock.NewController(t) + + mockConn = mocks.NewMockConnection(ctrl) + conn = &Connection{ + odbcConnection: mockConn, + cachedStatements: cache.NewLRU[PreparedStatement](1, onCachePurged), + } + return +} + +func TestConnection_IsValid(t *testing.T) { + ctrl, conn, mockConn := testConnection(t) + defer ctrl.Finish() + + mockConn.EXPECT().Ping().Return(nil).Times(1) + + if conn.IsValid() != true { + t.Fatal("expected IsValid to be true if the Ping is successful") + } + + mockConn.EXPECT().Ping().Return(odbc.ErrConnectionDead).Times(1) + + if conn.IsValid() != false { + t.Fatal("expected IsValid to be false if the Ping fails") + } + +} + +func TestConnection_Ping(t *testing.T) { + + type Test struct { + Description string + HasConnection bool + PingError error + WantError error + } + tests := []Test{ + { + Description: "it should return ErrBadConn if Ping returns ErrConnectionDead", + WantError: driver.ErrBadConn, + PingError: odbc.ErrConnectionDead, + HasConnection: true, + }, + { + Description: "it should return ErrBadConn if no connection", + WantError: driver.ErrBadConn, + HasConnection: false, + }, + + { + Description: "it should return no error if ping is successful", + WantError: nil, + PingError: nil, + HasConnection: true, + }, + } + for _, test := range tests { + t.Run(test.Description, func(t *testing.T) { + ctrl, conn, mockConn := testConnection(t) + defer ctrl.Finish() + + mockConn.EXPECT().Ping().Return(test.PingError).AnyTimes() + + if !test.HasConnection { + conn.odbcConnection = nil + } + + gotErr := conn.Ping(context.Background()) + + if !errors.Is(gotErr, test.WantError) { + t.Fatalf("expected error %v, got %v", test.WantError, gotErr) + } + }) + } +} + +func TestConnection_CheckNamedValue(t *testing.T) { + + type Test struct { + Description string + Value any + ShouldReject bool + } + tests := []Test{ + { + Description: "int8", + Value: int8(1), + ShouldReject: false, + }, + { + Description: "int16", + Value: int16(1), + ShouldReject: false, + }, + { + Description: "int32", + Value: int32(1), + ShouldReject: false, + }, + { + Description: "int64", + Value: int64(1), + ShouldReject: false, + }, + { + Description: "string", + Value: "string", + ShouldReject: false, + }, + { + Description: "boolean", + Value: true, + ShouldReject: false, + }, + { + Description: "nil", + Value: nil, + ShouldReject: false, + }, + { + Description: "time", + Value: time.Now(), + ShouldReject: false, + }, + { + Description: "[]byte", + Value: []byte{1, 2, 3}, + ShouldReject: false, + }, + { + Description: "struct", + Value: struct{}{}, + ShouldReject: true, + }, + } + + for _, test := range tests { + t.Run(test.Description, func(t *testing.T) { + ctrl, conn, _ := testConnection(t) + defer ctrl.Finish() + + gotErr := conn.CheckNamedValue(&driver.NamedValue{ + Name: "Col", + Ordinal: 0, + Value: test.Value, + }) + if test.ShouldReject { + if !errors.Is(gotErr, driver.ErrRemoveArgument) { + t.Fatal("expected ErrRemoveArgument") + } + } else if gotErr != nil { + t.Fatalf("expected no error but got %v", gotErr) + + } + + }) + + } +} + +func TestConnection_Close(t *testing.T) { + + ctrl, conn, mockConn := testConnection(t) + defer ctrl.Finish() + + mockConn.EXPECT().Close().Return(nil).Times(1) + + err := conn.Close() + if err != nil { + t.Errorf("expected no error but got %v", err) + } + if conn.odbcConnection != nil { + t.Error("expected connection to be closed") + } + +} + +func TestConnection_BeginTx(t *testing.T) { + ctrl, conn, mockConn := testConnection(t) + defer ctrl.Finish() + + mockConn.EXPECT().SetIsolationLevel(odbc.LevelReadCommitted).Return(nil).Times(1) + mockConn.EXPECT().SetReadOnlyMode(odbc.ModeReadOnly).Return(nil).Times(1) + mockConn.EXPECT().SetAutoCommit(false).Return(nil).Times(1) + tx, err := conn.BeginTx(context.Background(), driver.TxOptions{ + Isolation: driver.IsolationLevel(sql.LevelReadCommitted), + ReadOnly: true, + }) + if err != nil { + t.Errorf("expected no error but got %v", err) + } + if tx == nil { + t.Errorf("expected a transaction but got nil") + } + + mockConn.EXPECT().Commit().Return(nil).Times(1) + mockConn.EXPECT().SetAutoCommit(true).Return(nil).Times(1) + + err = tx.Commit() + if err != nil { + t.Errorf("expected no error from commit but got %v", err) + } +} + +func TestConnection_PrepareContext(t *testing.T) { + ctrl, conn, mockConn := testConnection(t) + defer ctrl.Finish() + + q := "SELECT * FROM foo WHERE bar = ?" + + ctx := context.Background() + mockStmt1 := mocks.NewMockStatement(ctrl) + + mockStmt1.EXPECT().Prepare(gomock.Any(), q).Return(nil).Times(1) + mockStmt1.EXPECT().NumParams().Return(1, nil).Times(1) + mockConn.EXPECT().Statement().Return(mockStmt1, nil).Times(1) + + stmt1, err := conn.PrepareContext(ctx, q) + if err != nil { + t.Fatalf("expected no error from prepareContext but got %v", err) + } + ps, ok := stmt1.(*PreparedStatement) + if !ok { + t.Fatalf("expected a statement to be returnedbut got %v", err) + } + if ps.odbcStatement != mockStmt1 { + t.Errorf("expected statement to be %v but got %v", mockStmt1, ps.odbcStatement) + + } + if gotNumInput := ps.NumInput(); gotNumInput != 1 { + t.Errorf("expected num input to be %v but got %v", 1, gotNumInput) + } + + //since prepared statement caching is on, the statement shouldn't be closed + stmt1.Close() + + //parameters should be reset when the statement is reused + mockStmt1.EXPECT().ResetParams().Times(1) + + stmt2, err := conn.PrepareContext(ctx, q) + if err != nil { + t.Fatalf("expected no error from prepareContext but got %v", err) + } + if stmt1 != stmt2 { + t.Fatalf("expected the second statement to be the same but got %v", stmt2) + } + + //since prepared statement caching is on, the statement shouldn't be closed + stmt2.Close() + + q3 := "SELECT * FROM all" + + mockStmt2 := mocks.NewMockStatement(ctrl) + + mockStmt2.EXPECT().Prepare(gomock.Any(), q3).Return(nil).Times(1) + mockStmt2.EXPECT().NumParams().Return(1, nil).Times(1) + mockConn.EXPECT().Statement().Return(mockStmt2, nil).Times(1) + + //first statement should be evicted from cache when the next statement is created + mockStmt1.EXPECT().Close().Return(nil).Times(1) + + stmt3, err := conn.PrepareContext(ctx, q3) + if err != nil { + t.Fatalf("expected no error from prepareContext but got %v", err) + } + if ps, ok := stmt3.(*PreparedStatement); !ok { + t.Fatalf("expected a statement to be returnedbut got %v", err) + } else if ps.odbcStatement != mockStmt2 { + t.Errorf("expected statement to be %v but got %v", mockStmt2, ps.odbcStatement) + + } + + stmt3.Close() + + //first statement should be evicted from cache when the next statement is created + mockStmt2.EXPECT().Close().Return(nil).Times(1) + + mockConn.EXPECT().Close().Return(nil).Times(1) + + conn.Close() + +} + +func TestConnection_ExecContext(t *testing.T) { + ctrl, conn, mockConn := testConnection(t) + defer ctrl.Finish() + + q := "SELECT * FROM foo WHERE bar = ?" + + ctx := context.Background() + mockStmt := mocks.NewMockStatement(ctrl) + + mockConn.EXPECT().Statement().Return(mockStmt, nil).Times(1) + + mockStmt.EXPECT().BindParams("Value").Return(nil).Times(1) + mockStmt.EXPECT().Close().Return(nil).Times(1) + mockStmt.EXPECT().ExecDirect(gomock.Any(), q).Return(nil).Times(1) + + _, err := conn.ExecContext(ctx, q, []driver.NamedValue{ + {Name: "", Ordinal: 1, Value: "Value"}, + }) + if err != nil { + t.Fatalf("expected no error but got %v", err) + } + +} + +func TestConnection_QueryContext(t *testing.T) { + ctrl, conn, mockConn := testConnection(t) + defer ctrl.Finish() + + q := "SELECT * FROM foo WHERE bar = ?" + + ctx := context.Background() + mockStmt := mocks.NewMockStatement(ctrl) + + mockConn.EXPECT().Statement().Return(mockStmt, nil).Times(1) + + mockStmt.EXPECT().BindParams("Value").Return(nil).Times(1) + mockStmt.EXPECT().ExecDirect(gomock.Any(), q).Return(nil).Times(1) + + mockRS := mocks.NewMockRecordSet(ctrl) + + mockStmt.EXPECT().RecordSet().Return(mockRS, nil).Times(1) + + gotRows, err := conn.QueryContext(ctx, q, []driver.NamedValue{ + {Name: "", Ordinal: 1, Value: "Value"}, + }) + if err != nil { + t.Fatalf("expected no error but got %v", err) + } + r, ok := gotRows.(*Rows) + if !ok { + t.Fatalf("unexpected rows result. got %v", gotRows) + } + if r.closeStmtOnRSClose != mockStmt { + t.Errorf("stmt not populated on rows. got %v", gotRows) + } + if r.odbcRecordset != mockRS { + t.Errorf("recordset not populated on Rows. got %v", gotRows) + } + +} diff --git a/connector.go b/connector.go index c9773ed..868d4f4 100644 --- a/connector.go +++ b/connector.go @@ -37,7 +37,7 @@ type Connector struct { // statement caching. StatementCacheSize int - odbcEnvironment *odbc.Environment + odbcEnvironment odbc.Environment } // Close implements io.Closer @@ -46,23 +46,24 @@ func (c *Connector) Close() error { } func (c *Connector) initEnvironment(ctx context.Context) (err error) { - if c.odbcEnvironment != nil { - return nil - } - var env *odbc.Environment - ctx, trace := Tracer.NewTask(ctx, "Connection::initEnvironment") + env := c.odbcEnvironment + + ctx, trace := Tracer.NewTask(ctx, "connection::initEnvironment") defer trace.End() - Tracer.WithRegion(ctx, "initializing ODBC environment", func() { - env, err = odbc.NewEnvironment(nil) - }) - if err != nil { - return + if c.odbcEnvironment == nil { + + Tracer.WithRegion(ctx, "initializing ODBC environment", func() { + env, err = odbc.NewEnvironment() + }) + if err != nil { + return + } } Tracer.WithRegion(ctx, "setting version", func() { - err = env.SetVersion(odbc.Version3_80) + err = env.SetVersion(odbc.Version380) }) if err != nil { return @@ -76,10 +77,6 @@ func (c *Connector) initEnvironment(ctx context.Context) (err error) { return } - //if err = env.SetTraceFile(c.TraceFile); err != nil { - // return - //} - c.odbcEnvironment = env return } @@ -107,10 +104,8 @@ func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) { } conn := &Connection{ - connector: c, - cachedStatements: cache.NewLRU[PreparedStatement](c.StatementCacheSize, func(key string, value *PreparedStatement) error { - return value.odbcStatement.Close() - }), + connector: c, + cachedStatements: cache.NewLRU[PreparedStatement](c.StatementCacheSize, onCachePurged), } Tracer.WithRegion(ctx, "connecting", func() { @@ -132,3 +127,7 @@ func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) { func (c *Connector) Driver() driver.Driver { return driverInstance } + +func onCachePurged(key string, value *PreparedStatement) error { + return value.odbcStatement.Close() +} diff --git a/connector_test.go b/connector_test.go new file mode 100644 index 0000000..ebb14e7 --- /dev/null +++ b/connector_test.go @@ -0,0 +1,54 @@ +package unixodbc + +import ( + "context" + "github.com/golang/mock/gomock" + "github.com/ninthclowd/unixodbc/internal/mocks" + "github.com/ninthclowd/unixodbc/internal/odbc" + "testing" +) + +func TestConnector_Connect(t *testing.T) { + + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockEnv := mocks.NewMockEnvironment(ctrl) + + connString := "connString" + connector := &Connector{ + ConnectionString: StaticConnStr(connString), + StatementCacheSize: 5, + odbcEnvironment: mockEnv, + } + + ctx := context.Background() + + mockConn := mocks.NewMockConnection(ctrl) + + mockConn.EXPECT().SetAutoCommit(true).Return(nil).Times(1) + mockEnv.EXPECT().SetVersion(odbc.Version380).Return(nil).Times(1) + mockEnv.EXPECT().SetPoolOption(odbc.PoolOff).Return(nil).Times(1) + mockEnv.EXPECT().Connect(gomock.Any(), connString).Return(mockConn, nil) + + gotConn, err := connector.Connect(ctx) + if err != nil { + t.Fatalf("expected no error connecting, got %v", err) + } + c, ok := gotConn.(*Connection) + if !ok { + t.Fatalf("connection was unexpected, got %v", err) + } + + if c.odbcConnection != mockConn { + t.Errorf("connection reference was unexpected, got %v", c.odbcConnection) + } + if capacity := c.cachedStatements.Capacity(); capacity != 5 { + t.Errorf("capacity not set on cache unexpected, got %v", capacity) + } + + if connector.Driver() != driverInstance { + t.Errorf("driver instance not set on connector, got %v", driverInstance) + } + +} diff --git a/docker-compose.yml b/docker-compose.yml index 1b0dc2f..9079baf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: "3.8" services: mariadb_test: build: test/acceptance/mariadb/container @@ -9,7 +8,7 @@ services: depends_on: mariadb: condition: service_healthy - command: go test -count 1 -race -coverpkg=./... -coverprofile=./test/acceptance/mariadb/coverage.out -tags acceptance ./test/acceptance/mariadb + command: go test -count 1 -race -tags acceptance ./test/acceptance/mariadb mariadb: image: "mariadb:10.9-jammy" @@ -34,7 +33,7 @@ services: depends_on: postgres: condition: service_healthy - command: go test -count 1 -race -coverpkg=./... -coverprofile=./test/acceptance/postgres/coverage.out -tags acceptance ./test/acceptance/postgres + command: go test -count 1 -race -tags acceptance ./test/acceptance/postgres postgres: image: "postgres:16-bookworm" @@ -59,7 +58,7 @@ services: depends_on: mssql: condition: service_healthy - command: go test -count 1 -race -coverpkg=./... -coverprofile=./test/acceptance/mssql/coverage.out -tags acceptance ./test/acceptance/mssql + command: go test -count 1 -race -tags acceptance ./test/acceptance/mssql mssql: diff --git a/driver.go b/driver.go index 4102138..bd98377 100644 --- a/driver.go +++ b/driver.go @@ -6,6 +6,8 @@ import ( "github.com/ninthclowd/unixodbc/internal/odbc" ) +const DefaultCacheSize = 0 + var driverInstance = &Driver{} func init() { @@ -25,7 +27,7 @@ type Driver struct{} func (d *Driver) OpenConnector(connStr string) (driver.Connector, error) { return &Connector{ ConnectionString: StaticConnStr(connStr), - StatementCacheSize: 0, + StatementCacheSize: DefaultCacheSize, }, nil } diff --git a/driver_test.go b/driver_test.go new file mode 100644 index 0000000..298c9ab --- /dev/null +++ b/driver_test.go @@ -0,0 +1,46 @@ +package unixodbc + +import ( + "database/sql" + "github.com/ninthclowd/unixodbc/internal/odbc" + "testing" +) + +func TestOpenHandles(t *testing.T) { + want := odbc.OpenHandles() + got := OpenHandles() + if got != want { + t.Fatalf("OpenHandles()=%v, want %v", got, want) + } +} + +func TestSQL_Open(t *testing.T) { + db, err := sql.Open("unixodbc", "MyDSN") + if err != nil { + t.Fatalf("expected no error opening, got %v", err.Error()) + } + if db.Driver() != driverInstance { + t.Fatalf("incorrect driver, got %v", db.Driver()) + } +} + +func TestDriver_OpenConnector(t *testing.T) { + db, err := driverInstance.OpenConnector("MyDSN") + if err != nil { + t.Fatalf("expected no error opening, got %v", err.Error()) + } + if db.Driver() != driverInstance { + t.Fatalf("incorrect driver, got %v", db.Driver()) + } + connector, ok := db.(*Connector) + if !ok { + t.Fatalf("incorrect connector, got %v", db) + } + if connStr, _ := connector.ConnectionString.ConnectionString(); connStr != "MyDSN" { + t.Errorf("incorrect connection string, got %v", connStr) + } + if connector.StatementCacheSize != DefaultCacheSize { + t.Errorf("incorrect default cache size, got %v", connector.StatementCacheSize) + } + +} diff --git a/errors.go b/errors.go index 60aae02..21c7f0c 100644 --- a/errors.go +++ b/errors.go @@ -18,7 +18,7 @@ func (m MultipleErrors) Error() error { var combinedErrMsg string for desc, err := range m { if err != nil { - //TODO in go1.20 use errors.join and implement unwrap + //TODO(ninthclowd): use errors.join and implement unwrap if combinedErrMsg == "" { combinedErrMsg = fmt.Sprintf("%s: %s", desc, err.Error()) } else { diff --git a/internal/api/api.go b/internal/api/api.go index 490077b..96fdcef 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -1,6 +1,6 @@ // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. -// WARNING: This file has automatically been generated on Tue, 10 Oct 2023 12:49:57 MDT. +// WARNING: This file has automatically been generated on Wed, 22 May 2024 15:11:09 MDT. // Code generated by https://git.io/c-for-go. DO NOT EDIT. package api @@ -15,3 +15,2797 @@ package api #include "cgo_helpers.h" */ import "C" +import ( + "runtime" + "unsafe" +) + +// SQLAllocConnect function as declared in include/sql.h:577 +func SQLAllocConnect(environmentHandle *SQLHENV, connectionHandle []*SQLHDBC) SQLRETURN { + cenvironmentHandle, cenvironmentHandleAllocMap := (C.SQLHENV)(unsafe.Pointer(environmentHandle)), cgoAllocsUnknown + cconnectionHandle, cconnectionHandleAllocMap := copyPSQLHDBCBytes((*sliceHeader)(unsafe.Pointer(&connectionHandle))) + __ret := C.SQLAllocConnect(cenvironmentHandle, cconnectionHandle) + runtime.KeepAlive(cconnectionHandleAllocMap) + runtime.KeepAlive(cenvironmentHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLAllocEnv function as declared in include/sql.h:580 +func SQLAllocEnv(environmentHandle []*SQLHENV) SQLRETURN { + cenvironmentHandle, cenvironmentHandleAllocMap := copyPSQLHENVBytes((*sliceHeader)(unsafe.Pointer(&environmentHandle))) + __ret := C.SQLAllocEnv(cenvironmentHandle) + runtime.KeepAlive(cenvironmentHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLAllocHandle function as declared in include/sql.h:583 +func SQLAllocHandle(handleType SQLSMALLINT, inputHandle *SQLHANDLE, outputHandle **SQLHANDLE) SQLRETURN { + chandleType, chandleTypeAllocMap := (C.SQLSMALLINT)(handleType), cgoAllocsUnknown + cinputHandle, cinputHandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(inputHandle)), cgoAllocsUnknown + coutputHandle, coutputHandleAllocMap := (*C.SQLHANDLE)(unsafe.Pointer(outputHandle)), cgoAllocsUnknown + __ret := C.SQLAllocHandle(chandleType, cinputHandle, coutputHandle) + runtime.KeepAlive(coutputHandleAllocMap) + runtime.KeepAlive(cinputHandleAllocMap) + runtime.KeepAlive(chandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLAllocStmt function as declared in include/sql.h:587 +func SQLAllocStmt(connectionHandle *SQLHDBC, statementHandle []*SQLHSTMT) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + cstatementHandle, cstatementHandleAllocMap := copyPSQLHSTMTBytes((*sliceHeader)(unsafe.Pointer(&statementHandle))) + __ret := C.SQLAllocStmt(cconnectionHandle, cstatementHandle) + runtime.KeepAlive(cstatementHandleAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLBindCol function as declared in include/sql.h:590 +func SQLBindCol(statementHandle *SQLHSTMT, columnNumber SQLUSMALLINT, targetType SQLSMALLINT, targetValue *SQLPOINTER, bufferLength SQLLEN, strLen_or_Ind []SQLLEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccolumnNumber, ccolumnNumberAllocMap := (C.SQLUSMALLINT)(columnNumber), cgoAllocsUnknown + ctargetType, ctargetTypeAllocMap := (C.SQLSMALLINT)(targetType), cgoAllocsUnknown + ctargetValue, ctargetValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(targetValue)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLLEN)(bufferLength), cgoAllocsUnknown + cstrLen_or_Ind, cstrLen_or_IndAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&strLen_or_Ind))) + __ret := C.SQLBindCol(cstatementHandle, ccolumnNumber, ctargetType, ctargetValue, cbufferLength, cstrLen_or_Ind) + runtime.KeepAlive(cstrLen_or_IndAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(ctargetValueAllocMap) + runtime.KeepAlive(ctargetTypeAllocMap) + runtime.KeepAlive(ccolumnNumberAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLBindParam function as declared in include/sql.h:596 +func SQLBindParam(statementHandle *SQLHSTMT, parameterNumber SQLUSMALLINT, valueType SQLSMALLINT, parameterType SQLSMALLINT, lengthPrecision SQLULEN, parameterScale SQLSMALLINT, parameterValue *SQLPOINTER, strLen_or_Ind []SQLLEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cparameterNumber, cparameterNumberAllocMap := (C.SQLUSMALLINT)(parameterNumber), cgoAllocsUnknown + cvalueType, cvalueTypeAllocMap := (C.SQLSMALLINT)(valueType), cgoAllocsUnknown + cparameterType, cparameterTypeAllocMap := (C.SQLSMALLINT)(parameterType), cgoAllocsUnknown + clengthPrecision, clengthPrecisionAllocMap := (C.SQLULEN)(lengthPrecision), cgoAllocsUnknown + cparameterScale, cparameterScaleAllocMap := (C.SQLSMALLINT)(parameterScale), cgoAllocsUnknown + cparameterValue, cparameterValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(parameterValue)), cgoAllocsUnknown + cstrLen_or_Ind, cstrLen_or_IndAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&strLen_or_Ind))) + __ret := C.SQLBindParam(cstatementHandle, cparameterNumber, cvalueType, cparameterType, clengthPrecision, cparameterScale, cparameterValue, cstrLen_or_Ind) + runtime.KeepAlive(cstrLen_or_IndAllocMap) + runtime.KeepAlive(cparameterValueAllocMap) + runtime.KeepAlive(cparameterScaleAllocMap) + runtime.KeepAlive(clengthPrecisionAllocMap) + runtime.KeepAlive(cparameterTypeAllocMap) + runtime.KeepAlive(cvalueTypeAllocMap) + runtime.KeepAlive(cparameterNumberAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLCancel function as declared in include/sql.h:603 +func SQLCancel(statementHandle *SQLHSTMT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + __ret := C.SQLCancel(cstatementHandle) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLCancelHandle function as declared in include/sql.h:606 +func SQLCancelHandle(handleType SQLSMALLINT, inputHandle *SQLHANDLE) SQLRETURN { + chandleType, chandleTypeAllocMap := (C.SQLSMALLINT)(handleType), cgoAllocsUnknown + cinputHandle, cinputHandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(inputHandle)), cgoAllocsUnknown + __ret := C.SQLCancelHandle(chandleType, cinputHandle) + runtime.KeepAlive(cinputHandleAllocMap) + runtime.KeepAlive(chandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLCloseCursor function as declared in include/sql.h:611 +func SQLCloseCursor(statementHandle *SQLHSTMT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + __ret := C.SQLCloseCursor(cstatementHandle) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColAttribute function as declared in include/sql.h:613 +func SQLColAttribute(statementHandle *SQLHSTMT, columnNumber SQLUSMALLINT, fieldIdentifier SQLUSMALLINT, characterAttribute *SQLPOINTER, bufferLength SQLSMALLINT, stringLength []SQLSMALLINT, numericAttribute []SQLLEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccolumnNumber, ccolumnNumberAllocMap := (C.SQLUSMALLINT)(columnNumber), cgoAllocsUnknown + cfieldIdentifier, cfieldIdentifierAllocMap := (C.SQLUSMALLINT)(fieldIdentifier), cgoAllocsUnknown + ccharacterAttribute, ccharacterAttributeAllocMap := (C.SQLPOINTER)(unsafe.Pointer(characterAttribute)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLSMALLINT)(bufferLength), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&stringLength))) + cnumericAttribute, cnumericAttributeAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&numericAttribute))) + __ret := C.SQLColAttribute(cstatementHandle, ccolumnNumber, cfieldIdentifier, ccharacterAttribute, cbufferLength, cstringLength, cnumericAttribute) + runtime.KeepAlive(cnumericAttributeAllocMap) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(ccharacterAttributeAllocMap) + runtime.KeepAlive(cfieldIdentifierAllocMap) + runtime.KeepAlive(ccolumnNumberAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColumns function as declared in include/sql.h:625 +func SQLColumns(statementHandle *SQLHSTMT, catalogName []SQLCHAR, nameLength1 SQLSMALLINT, schemaName []SQLCHAR, nameLength2 SQLSMALLINT, tableName []SQLCHAR, nameLength3 SQLSMALLINT, columnName []SQLCHAR, nameLength4 SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccatalogName, ccatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&catalogName))) + cnameLength1, cnameLength1AllocMap := (C.SQLSMALLINT)(nameLength1), cgoAllocsUnknown + cschemaName, cschemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&schemaName))) + cnameLength2, cnameLength2AllocMap := (C.SQLSMALLINT)(nameLength2), cgoAllocsUnknown + ctableName, ctableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&tableName))) + cnameLength3, cnameLength3AllocMap := (C.SQLSMALLINT)(nameLength3), cgoAllocsUnknown + ccolumnName, ccolumnNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&columnName))) + cnameLength4, cnameLength4AllocMap := (C.SQLSMALLINT)(nameLength4), cgoAllocsUnknown + __ret := C.SQLColumns(cstatementHandle, ccatalogName, cnameLength1, cschemaName, cnameLength2, ctableName, cnameLength3, ccolumnName, cnameLength4) + runtime.KeepAlive(cnameLength4AllocMap) + runtime.KeepAlive(ccolumnNameAllocMap) + runtime.KeepAlive(cnameLength3AllocMap) + runtime.KeepAlive(ctableNameAllocMap) + runtime.KeepAlive(cnameLength2AllocMap) + runtime.KeepAlive(cschemaNameAllocMap) + runtime.KeepAlive(cnameLength1AllocMap) + runtime.KeepAlive(ccatalogNameAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLConnect function as declared in include/sql.h:632 +func SQLConnect(connectionHandle *SQLHDBC, serverName []SQLCHAR, nameLength1 SQLSMALLINT, userName []SQLCHAR, nameLength2 SQLSMALLINT, authentication []SQLCHAR, nameLength3 SQLSMALLINT) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + cserverName, cserverNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&serverName))) + cnameLength1, cnameLength1AllocMap := (C.SQLSMALLINT)(nameLength1), cgoAllocsUnknown + cuserName, cuserNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&userName))) + cnameLength2, cnameLength2AllocMap := (C.SQLSMALLINT)(nameLength2), cgoAllocsUnknown + cauthentication, cauthenticationAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&authentication))) + cnameLength3, cnameLength3AllocMap := (C.SQLSMALLINT)(nameLength3), cgoAllocsUnknown + __ret := C.SQLConnect(cconnectionHandle, cserverName, cnameLength1, cuserName, cnameLength2, cauthentication, cnameLength3) + runtime.KeepAlive(cnameLength3AllocMap) + runtime.KeepAlive(cauthenticationAllocMap) + runtime.KeepAlive(cnameLength2AllocMap) + runtime.KeepAlive(cuserNameAllocMap) + runtime.KeepAlive(cnameLength1AllocMap) + runtime.KeepAlive(cserverNameAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLCopyDesc function as declared in include/sql.h:638 +func SQLCopyDesc(sourceDescHandle *SQLHDESC, targetDescHandle *SQLHDESC) SQLRETURN { + csourceDescHandle, csourceDescHandleAllocMap := (C.SQLHDESC)(unsafe.Pointer(sourceDescHandle)), cgoAllocsUnknown + ctargetDescHandle, ctargetDescHandleAllocMap := (C.SQLHDESC)(unsafe.Pointer(targetDescHandle)), cgoAllocsUnknown + __ret := C.SQLCopyDesc(csourceDescHandle, ctargetDescHandle) + runtime.KeepAlive(ctargetDescHandleAllocMap) + runtime.KeepAlive(csourceDescHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDataSources function as declared in include/sql.h:642 +func SQLDataSources(environmentHandle *SQLHENV, direction SQLUSMALLINT, serverName []SQLCHAR, bufferLength1 SQLSMALLINT, nameLength1 []SQLSMALLINT, description []SQLCHAR, bufferLength2 SQLSMALLINT, nameLength2 []SQLSMALLINT) SQLRETURN { + cenvironmentHandle, cenvironmentHandleAllocMap := (C.SQLHENV)(unsafe.Pointer(environmentHandle)), cgoAllocsUnknown + cdirection, cdirectionAllocMap := (C.SQLUSMALLINT)(direction), cgoAllocsUnknown + cserverName, cserverNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&serverName))) + cbufferLength1, cbufferLength1AllocMap := (C.SQLSMALLINT)(bufferLength1), cgoAllocsUnknown + cnameLength1, cnameLength1AllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&nameLength1))) + cdescription, cdescriptionAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&description))) + cbufferLength2, cbufferLength2AllocMap := (C.SQLSMALLINT)(bufferLength2), cgoAllocsUnknown + cnameLength2, cnameLength2AllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&nameLength2))) + __ret := C.SQLDataSources(cenvironmentHandle, cdirection, cserverName, cbufferLength1, cnameLength1, cdescription, cbufferLength2, cnameLength2) + runtime.KeepAlive(cnameLength2AllocMap) + runtime.KeepAlive(cbufferLength2AllocMap) + runtime.KeepAlive(cdescriptionAllocMap) + runtime.KeepAlive(cnameLength1AllocMap) + runtime.KeepAlive(cbufferLength1AllocMap) + runtime.KeepAlive(cserverNameAllocMap) + runtime.KeepAlive(cdirectionAllocMap) + runtime.KeepAlive(cenvironmentHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDescribeCol function as declared in include/sql.h:648 +func SQLDescribeCol(statementHandle *SQLHSTMT, columnNumber SQLUSMALLINT, columnName *SQLCHAR, bufferLength SQLSMALLINT, nameLength *SQLSMALLINT, dataType *SQLSMALLINT, columnSize *SQLULEN, decimalDigits *SQLSMALLINT, nullable *SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccolumnNumber, ccolumnNumberAllocMap := (C.SQLUSMALLINT)(columnNumber), cgoAllocsUnknown + ccolumnName, ccolumnNameAllocMap := (*C.SQLCHAR)(unsafe.Pointer(columnName)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLSMALLINT)(bufferLength), cgoAllocsUnknown + cnameLength, cnameLengthAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(nameLength)), cgoAllocsUnknown + cdataType, cdataTypeAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(dataType)), cgoAllocsUnknown + ccolumnSize, ccolumnSizeAllocMap := (*C.SQLULEN)(unsafe.Pointer(columnSize)), cgoAllocsUnknown + cdecimalDigits, cdecimalDigitsAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(decimalDigits)), cgoAllocsUnknown + cnullable, cnullableAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(nullable)), cgoAllocsUnknown + __ret := C.SQLDescribeCol(cstatementHandle, ccolumnNumber, ccolumnName, cbufferLength, cnameLength, cdataType, ccolumnSize, cdecimalDigits, cnullable) + runtime.KeepAlive(cnullableAllocMap) + runtime.KeepAlive(cdecimalDigitsAllocMap) + runtime.KeepAlive(ccolumnSizeAllocMap) + runtime.KeepAlive(cdataTypeAllocMap) + runtime.KeepAlive(cnameLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(ccolumnNameAllocMap) + runtime.KeepAlive(ccolumnNumberAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDisconnect function as declared in include/sql.h:654 +func SQLDisconnect(connectionHandle *SQLHDBC) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + __ret := C.SQLDisconnect(cconnectionHandle) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLEndTran function as declared in include/sql.h:657 +func SQLEndTran(handleType SQLSMALLINT, handle *SQLHANDLE, completionType SQLSMALLINT) SQLRETURN { + chandleType, chandleTypeAllocMap := (C.SQLSMALLINT)(handleType), cgoAllocsUnknown + chandle, chandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(handle)), cgoAllocsUnknown + ccompletionType, ccompletionTypeAllocMap := (C.SQLSMALLINT)(completionType), cgoAllocsUnknown + __ret := C.SQLEndTran(chandleType, chandle, ccompletionType) + runtime.KeepAlive(ccompletionTypeAllocMap) + runtime.KeepAlive(chandleAllocMap) + runtime.KeepAlive(chandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLError function as declared in include/sql.h:661 +func SQLError(environmentHandle *SQLHENV, connectionHandle *SQLHDBC, statementHandle *SQLHSTMT, sqlstate []SQLCHAR, nativeError []SQLINTEGER, messageText []SQLCHAR, bufferLength SQLSMALLINT, textLength []SQLSMALLINT) SQLRETURN { + cenvironmentHandle, cenvironmentHandleAllocMap := (C.SQLHENV)(unsafe.Pointer(environmentHandle)), cgoAllocsUnknown + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + csqlstate, csqlstateAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&sqlstate))) + cnativeError, cnativeErrorAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&nativeError))) + cmessageText, cmessageTextAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&messageText))) + cbufferLength, cbufferLengthAllocMap := (C.SQLSMALLINT)(bufferLength), cgoAllocsUnknown + ctextLength, ctextLengthAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&textLength))) + __ret := C.SQLError(cenvironmentHandle, cconnectionHandle, cstatementHandle, csqlstate, cnativeError, cmessageText, cbufferLength, ctextLength) + runtime.KeepAlive(ctextLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cmessageTextAllocMap) + runtime.KeepAlive(cnativeErrorAllocMap) + runtime.KeepAlive(csqlstateAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + runtime.KeepAlive(cenvironmentHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLExecDirect function as declared in include/sql.h:667 +func SQLExecDirect(statementHandle *SQLHSTMT, statementText *SQLCHAR, textLength SQLINTEGER) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cstatementText, cstatementTextAllocMap := (*C.SQLCHAR)(unsafe.Pointer(statementText)), cgoAllocsUnknown + ctextLength, ctextLengthAllocMap := (C.SQLINTEGER)(textLength), cgoAllocsUnknown + __ret := C.SQLExecDirect(cstatementHandle, cstatementText, ctextLength) + runtime.KeepAlive(ctextLengthAllocMap) + runtime.KeepAlive(cstatementTextAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLExecute function as declared in include/sql.h:670 +func SQLExecute(statementHandle *SQLHSTMT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + __ret := C.SQLExecute(cstatementHandle) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLFetch function as declared in include/sql.h:672 +func SQLFetch(statementHandle *SQLHSTMT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + __ret := C.SQLFetch(cstatementHandle) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLFetchScroll function as declared in include/sql.h:675 +func SQLFetchScroll(statementHandle *SQLHSTMT, fetchOrientation SQLSMALLINT, fetchOffset SQLLEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cfetchOrientation, cfetchOrientationAllocMap := (C.SQLSMALLINT)(fetchOrientation), cgoAllocsUnknown + cfetchOffset, cfetchOffsetAllocMap := (C.SQLLEN)(fetchOffset), cgoAllocsUnknown + __ret := C.SQLFetchScroll(cstatementHandle, cfetchOrientation, cfetchOffset) + runtime.KeepAlive(cfetchOffsetAllocMap) + runtime.KeepAlive(cfetchOrientationAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLFreeConnect function as declared in include/sql.h:679 +func SQLFreeConnect(connectionHandle *SQLHDBC) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + __ret := C.SQLFreeConnect(cconnectionHandle) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLFreeEnv function as declared in include/sql.h:681 +func SQLFreeEnv(environmentHandle *SQLHENV) SQLRETURN { + cenvironmentHandle, cenvironmentHandleAllocMap := (C.SQLHENV)(unsafe.Pointer(environmentHandle)), cgoAllocsUnknown + __ret := C.SQLFreeEnv(cenvironmentHandle) + runtime.KeepAlive(cenvironmentHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLFreeHandle function as declared in include/sql.h:684 +func SQLFreeHandle(handleType SQLSMALLINT, handle *SQLHANDLE) SQLRETURN { + chandleType, chandleTypeAllocMap := (C.SQLSMALLINT)(handleType), cgoAllocsUnknown + chandle, chandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(handle)), cgoAllocsUnknown + __ret := C.SQLFreeHandle(chandleType, chandle) + runtime.KeepAlive(chandleAllocMap) + runtime.KeepAlive(chandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLFreeStmt function as declared in include/sql.h:687 +func SQLFreeStmt(statementHandle *SQLHSTMT, option SQLUSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + coption, coptionAllocMap := (C.SQLUSMALLINT)(option), cgoAllocsUnknown + __ret := C.SQLFreeStmt(cstatementHandle, coption) + runtime.KeepAlive(coptionAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetConnectAttr function as declared in include/sql.h:691 +func SQLGetConnectAttr(connectionHandle *SQLHDBC, attribute SQLINTEGER, value *SQLPOINTER, bufferLength SQLINTEGER, stringLength *SQLINTEGER) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + cattribute, cattributeAllocMap := (C.SQLINTEGER)(attribute), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLINTEGER)(bufferLength), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := (*C.SQLINTEGER)(unsafe.Pointer(stringLength)), cgoAllocsUnknown + __ret := C.SQLGetConnectAttr(cconnectionHandle, cattribute, cvalue, cbufferLength, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cattributeAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetConnectOption function as declared in include/sql.h:696 +func SQLGetConnectOption(connectionHandle *SQLHDBC, option SQLUSMALLINT, value *SQLPOINTER) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + coption, coptionAllocMap := (C.SQLUSMALLINT)(option), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + __ret := C.SQLGetConnectOption(cconnectionHandle, coption, cvalue) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(coptionAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetCursorName function as declared in include/sql.h:699 +func SQLGetCursorName(statementHandle *SQLHSTMT, cursorName []SQLCHAR, bufferLength SQLSMALLINT, nameLength []SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccursorName, ccursorNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&cursorName))) + cbufferLength, cbufferLengthAllocMap := (C.SQLSMALLINT)(bufferLength), cgoAllocsUnknown + cnameLength, cnameLengthAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&nameLength))) + __ret := C.SQLGetCursorName(cstatementHandle, ccursorName, cbufferLength, cnameLength) + runtime.KeepAlive(cnameLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(ccursorNameAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetData function as declared in include/sql.h:703 +func SQLGetData(statementHandle *SQLHSTMT, columnNumber SQLUSMALLINT, targetType SQLSMALLINT, targetValue *SQLPOINTER, bufferLength SQLLEN, strLen_or_Ind *SQLLEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccolumnNumber, ccolumnNumberAllocMap := (C.SQLUSMALLINT)(columnNumber), cgoAllocsUnknown + ctargetType, ctargetTypeAllocMap := (C.SQLSMALLINT)(targetType), cgoAllocsUnknown + ctargetValue, ctargetValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(targetValue)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLLEN)(bufferLength), cgoAllocsUnknown + cstrLen_or_Ind, cstrLen_or_IndAllocMap := (*C.SQLLEN)(unsafe.Pointer(strLen_or_Ind)), cgoAllocsUnknown + __ret := C.SQLGetData(cstatementHandle, ccolumnNumber, ctargetType, ctargetValue, cbufferLength, cstrLen_or_Ind) + runtime.KeepAlive(cstrLen_or_IndAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(ctargetValueAllocMap) + runtime.KeepAlive(ctargetTypeAllocMap) + runtime.KeepAlive(ccolumnNumberAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDescField function as declared in include/sql.h:709 +func SQLGetDescField(descriptorHandle *SQLHDESC, recNumber SQLSMALLINT, fieldIdentifier SQLSMALLINT, value *SQLPOINTER, bufferLength SQLINTEGER, stringLength []SQLINTEGER) SQLRETURN { + cdescriptorHandle, cdescriptorHandleAllocMap := (C.SQLHDESC)(unsafe.Pointer(descriptorHandle)), cgoAllocsUnknown + crecNumber, crecNumberAllocMap := (C.SQLSMALLINT)(recNumber), cgoAllocsUnknown + cfieldIdentifier, cfieldIdentifierAllocMap := (C.SQLSMALLINT)(fieldIdentifier), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLINTEGER)(bufferLength), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&stringLength))) + __ret := C.SQLGetDescField(cdescriptorHandle, crecNumber, cfieldIdentifier, cvalue, cbufferLength, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cfieldIdentifierAllocMap) + runtime.KeepAlive(crecNumberAllocMap) + runtime.KeepAlive(cdescriptorHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDescRec function as declared in include/sql.h:714 +func SQLGetDescRec(descriptorHandle *SQLHDESC, recNumber SQLSMALLINT, name []SQLCHAR, bufferLength SQLSMALLINT, stringLength []SQLSMALLINT, kind []SQLSMALLINT, subType []SQLSMALLINT, length []SQLLEN, precision []SQLSMALLINT, scale []SQLSMALLINT, nullable []SQLSMALLINT) SQLRETURN { + cdescriptorHandle, cdescriptorHandleAllocMap := (C.SQLHDESC)(unsafe.Pointer(descriptorHandle)), cgoAllocsUnknown + crecNumber, crecNumberAllocMap := (C.SQLSMALLINT)(recNumber), cgoAllocsUnknown + cname, cnameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&name))) + cbufferLength, cbufferLengthAllocMap := (C.SQLSMALLINT)(bufferLength), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&stringLength))) + ckind, ckindAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&kind))) + csubType, csubTypeAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&subType))) + clength, clengthAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&length))) + cprecision, cprecisionAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&precision))) + cscale, cscaleAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&scale))) + cnullable, cnullableAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&nullable))) + __ret := C.SQLGetDescRec(cdescriptorHandle, crecNumber, cname, cbufferLength, cstringLength, ckind, csubType, clength, cprecision, cscale, cnullable) + runtime.KeepAlive(cnullableAllocMap) + runtime.KeepAlive(cscaleAllocMap) + runtime.KeepAlive(cprecisionAllocMap) + runtime.KeepAlive(clengthAllocMap) + runtime.KeepAlive(csubTypeAllocMap) + runtime.KeepAlive(ckindAllocMap) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cnameAllocMap) + runtime.KeepAlive(crecNumberAllocMap) + runtime.KeepAlive(cdescriptorHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDiagField function as declared in include/sql.h:721 +func SQLGetDiagField(handleType SQLSMALLINT, handle *SQLHANDLE, recNumber SQLSMALLINT, diagIdentifier SQLSMALLINT, diagInfo *SQLPOINTER, bufferLength SQLSMALLINT, stringLength []SQLSMALLINT) SQLRETURN { + chandleType, chandleTypeAllocMap := (C.SQLSMALLINT)(handleType), cgoAllocsUnknown + chandle, chandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(handle)), cgoAllocsUnknown + crecNumber, crecNumberAllocMap := (C.SQLSMALLINT)(recNumber), cgoAllocsUnknown + cdiagIdentifier, cdiagIdentifierAllocMap := (C.SQLSMALLINT)(diagIdentifier), cgoAllocsUnknown + cdiagInfo, cdiagInfoAllocMap := (C.SQLPOINTER)(unsafe.Pointer(diagInfo)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLSMALLINT)(bufferLength), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&stringLength))) + __ret := C.SQLGetDiagField(chandleType, chandle, crecNumber, cdiagIdentifier, cdiagInfo, cbufferLength, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cdiagInfoAllocMap) + runtime.KeepAlive(cdiagIdentifierAllocMap) + runtime.KeepAlive(crecNumberAllocMap) + runtime.KeepAlive(chandleAllocMap) + runtime.KeepAlive(chandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDiagRec function as declared in include/sql.h:726 +func SQLGetDiagRec(handleType SQLSMALLINT, handle *SQLHANDLE, recNumber SQLSMALLINT, sqlstate *SQLCHAR, nativeError *SQLINTEGER, messageText *SQLCHAR, bufferLength SQLSMALLINT, textLength *SQLSMALLINT) SQLRETURN { + chandleType, chandleTypeAllocMap := (C.SQLSMALLINT)(handleType), cgoAllocsUnknown + chandle, chandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(handle)), cgoAllocsUnknown + crecNumber, crecNumberAllocMap := (C.SQLSMALLINT)(recNumber), cgoAllocsUnknown + csqlstate, csqlstateAllocMap := (*C.SQLCHAR)(unsafe.Pointer(sqlstate)), cgoAllocsUnknown + cnativeError, cnativeErrorAllocMap := (*C.SQLINTEGER)(unsafe.Pointer(nativeError)), cgoAllocsUnknown + cmessageText, cmessageTextAllocMap := (*C.SQLCHAR)(unsafe.Pointer(messageText)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLSMALLINT)(bufferLength), cgoAllocsUnknown + ctextLength, ctextLengthAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(textLength)), cgoAllocsUnknown + __ret := C.SQLGetDiagRec(chandleType, chandle, crecNumber, csqlstate, cnativeError, cmessageText, cbufferLength, ctextLength) + runtime.KeepAlive(ctextLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cmessageTextAllocMap) + runtime.KeepAlive(cnativeErrorAllocMap) + runtime.KeepAlive(csqlstateAllocMap) + runtime.KeepAlive(crecNumberAllocMap) + runtime.KeepAlive(chandleAllocMap) + runtime.KeepAlive(chandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetEnvAttr function as declared in include/sql.h:731 +func SQLGetEnvAttr(environmentHandle *SQLHENV, attribute SQLINTEGER, value *SQLPOINTER, bufferLength SQLINTEGER, stringLength []SQLINTEGER) SQLRETURN { + cenvironmentHandle, cenvironmentHandleAllocMap := (C.SQLHENV)(unsafe.Pointer(environmentHandle)), cgoAllocsUnknown + cattribute, cattributeAllocMap := (C.SQLINTEGER)(attribute), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLINTEGER)(bufferLength), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&stringLength))) + __ret := C.SQLGetEnvAttr(cenvironmentHandle, cattribute, cvalue, cbufferLength, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cattributeAllocMap) + runtime.KeepAlive(cenvironmentHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetFunctions function as declared in include/sql.h:736 +func SQLGetFunctions(connectionHandle *SQLHDBC, functionId SQLUSMALLINT, supported []SQLUSMALLINT) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + cfunctionId, cfunctionIdAllocMap := (C.SQLUSMALLINT)(functionId), cgoAllocsUnknown + csupported, csupportedAllocMap := copyPSQLUSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&supported))) + __ret := C.SQLGetFunctions(cconnectionHandle, cfunctionId, csupported) + runtime.KeepAlive(csupportedAllocMap) + runtime.KeepAlive(cfunctionIdAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetInfo function as declared in include/sql.h:739 +func SQLGetInfo(connectionHandle *SQLHDBC, infoType SQLUSMALLINT, infoValue *SQLPOINTER, bufferLength SQLSMALLINT, stringLength []SQLSMALLINT) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + cinfoType, cinfoTypeAllocMap := (C.SQLUSMALLINT)(infoType), cgoAllocsUnknown + cinfoValue, cinfoValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(infoValue)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLSMALLINT)(bufferLength), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&stringLength))) + __ret := C.SQLGetInfo(cconnectionHandle, cinfoType, cinfoValue, cbufferLength, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cinfoValueAllocMap) + runtime.KeepAlive(cinfoTypeAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetStmtAttr function as declared in include/sql.h:744 +func SQLGetStmtAttr(statementHandle *SQLHSTMT, attribute SQLINTEGER, value *SQLPOINTER, bufferLength SQLINTEGER, stringLength []SQLINTEGER) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cattribute, cattributeAllocMap := (C.SQLINTEGER)(attribute), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLINTEGER)(bufferLength), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&stringLength))) + __ret := C.SQLGetStmtAttr(cstatementHandle, cattribute, cvalue, cbufferLength, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cattributeAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetStmtOption function as declared in include/sql.h:749 +func SQLGetStmtOption(statementHandle *SQLHSTMT, option SQLUSMALLINT, value *SQLPOINTER) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + coption, coptionAllocMap := (C.SQLUSMALLINT)(option), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + __ret := C.SQLGetStmtOption(cstatementHandle, coption, cvalue) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(coptionAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetTypeInfo function as declared in include/sql.h:752 +func SQLGetTypeInfo(statementHandle *SQLHSTMT, dataType SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cdataType, cdataTypeAllocMap := (C.SQLSMALLINT)(dataType), cgoAllocsUnknown + __ret := C.SQLGetTypeInfo(cstatementHandle, cdataType) + runtime.KeepAlive(cdataTypeAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLNumResultCols function as declared in include/sql.h:755 +func SQLNumResultCols(statementHandle *SQLHSTMT, columnCount *SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccolumnCount, ccolumnCountAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(columnCount)), cgoAllocsUnknown + __ret := C.SQLNumResultCols(cstatementHandle, ccolumnCount) + runtime.KeepAlive(ccolumnCountAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLParamData function as declared in include/sql.h:758 +func SQLParamData(statementHandle *SQLHSTMT, value []*SQLPOINTER) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cvalue, cvalueAllocMap := copyPSQLPOINTERBytes((*sliceHeader)(unsafe.Pointer(&value))) + __ret := C.SQLParamData(cstatementHandle, cvalue) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLPrepare function as declared in include/sql.h:761 +func SQLPrepare(statementHandle *SQLHSTMT, statementText *SQLCHAR, textLength SQLINTEGER) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cstatementText, cstatementTextAllocMap := (*C.SQLCHAR)(unsafe.Pointer(statementText)), cgoAllocsUnknown + ctextLength, ctextLengthAllocMap := (C.SQLINTEGER)(textLength), cgoAllocsUnknown + __ret := C.SQLPrepare(cstatementHandle, cstatementText, ctextLength) + runtime.KeepAlive(ctextLengthAllocMap) + runtime.KeepAlive(cstatementTextAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLPutData function as declared in include/sql.h:764 +func SQLPutData(statementHandle *SQLHSTMT, data *SQLPOINTER, strLen_or_Ind SQLLEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cdata, cdataAllocMap := (C.SQLPOINTER)(unsafe.Pointer(data)), cgoAllocsUnknown + cstrLen_or_Ind, cstrLen_or_IndAllocMap := (C.SQLLEN)(strLen_or_Ind), cgoAllocsUnknown + __ret := C.SQLPutData(cstatementHandle, cdata, cstrLen_or_Ind) + runtime.KeepAlive(cstrLen_or_IndAllocMap) + runtime.KeepAlive(cdataAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLRowCount function as declared in include/sql.h:767 +func SQLRowCount(statementHandle *SQLHSTMT, rowCount []SQLLEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + crowCount, crowCountAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&rowCount))) + __ret := C.SQLRowCount(cstatementHandle, crowCount) + runtime.KeepAlive(crowCountAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetConnectAttr function as declared in include/sql.h:771 +func SQLSetConnectAttr(connectionHandle *SQLHDBC, attribute SQLINTEGER, value *SQLPOINTER, stringLength SQLINTEGER) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + cattribute, cattributeAllocMap := (C.SQLINTEGER)(attribute), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := (C.SQLINTEGER)(stringLength), cgoAllocsUnknown + __ret := C.SQLSetConnectAttr(cconnectionHandle, cattribute, cvalue, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cattributeAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetConnectOption function as declared in include/sql.h:776 +func SQLSetConnectOption(connectionHandle *SQLHDBC, option SQLUSMALLINT, value SQLULEN) SQLRETURN { + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + coption, coptionAllocMap := (C.SQLUSMALLINT)(option), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLULEN)(value), cgoAllocsUnknown + __ret := C.SQLSetConnectOption(cconnectionHandle, coption, cvalue) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(coptionAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetCursorName function as declared in include/sql.h:779 +func SQLSetCursorName(statementHandle *SQLHSTMT, cursorName []SQLCHAR, nameLength SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccursorName, ccursorNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&cursorName))) + cnameLength, cnameLengthAllocMap := (C.SQLSMALLINT)(nameLength), cgoAllocsUnknown + __ret := C.SQLSetCursorName(cstatementHandle, ccursorName, cnameLength) + runtime.KeepAlive(cnameLengthAllocMap) + runtime.KeepAlive(ccursorNameAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetDescField function as declared in include/sql.h:783 +func SQLSetDescField(descriptorHandle *SQLHDESC, recNumber SQLSMALLINT, fieldIdentifier SQLSMALLINT, value *SQLPOINTER, bufferLength SQLINTEGER) SQLRETURN { + cdescriptorHandle, cdescriptorHandleAllocMap := (C.SQLHDESC)(unsafe.Pointer(descriptorHandle)), cgoAllocsUnknown + crecNumber, crecNumberAllocMap := (C.SQLSMALLINT)(recNumber), cgoAllocsUnknown + cfieldIdentifier, cfieldIdentifierAllocMap := (C.SQLSMALLINT)(fieldIdentifier), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLINTEGER)(bufferLength), cgoAllocsUnknown + __ret := C.SQLSetDescField(cdescriptorHandle, crecNumber, cfieldIdentifier, cvalue, cbufferLength) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cfieldIdentifierAllocMap) + runtime.KeepAlive(crecNumberAllocMap) + runtime.KeepAlive(cdescriptorHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetDescRec function as declared in include/sql.h:787 +func SQLSetDescRec(descriptorHandle *SQLHDESC, recNumber SQLSMALLINT, kind SQLSMALLINT, subType SQLSMALLINT, length SQLLEN, precision SQLSMALLINT, scale SQLSMALLINT, data *SQLPOINTER, stringLength []SQLLEN, indicator []SQLLEN) SQLRETURN { + cdescriptorHandle, cdescriptorHandleAllocMap := (C.SQLHDESC)(unsafe.Pointer(descriptorHandle)), cgoAllocsUnknown + crecNumber, crecNumberAllocMap := (C.SQLSMALLINT)(recNumber), cgoAllocsUnknown + ckind, ckindAllocMap := (C.SQLSMALLINT)(kind), cgoAllocsUnknown + csubType, csubTypeAllocMap := (C.SQLSMALLINT)(subType), cgoAllocsUnknown + clength, clengthAllocMap := (C.SQLLEN)(length), cgoAllocsUnknown + cprecision, cprecisionAllocMap := (C.SQLSMALLINT)(precision), cgoAllocsUnknown + cscale, cscaleAllocMap := (C.SQLSMALLINT)(scale), cgoAllocsUnknown + cdata, cdataAllocMap := (C.SQLPOINTER)(unsafe.Pointer(data)), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&stringLength))) + cindicator, cindicatorAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&indicator))) + __ret := C.SQLSetDescRec(cdescriptorHandle, crecNumber, ckind, csubType, clength, cprecision, cscale, cdata, cstringLength, cindicator) + runtime.KeepAlive(cindicatorAllocMap) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cdataAllocMap) + runtime.KeepAlive(cscaleAllocMap) + runtime.KeepAlive(cprecisionAllocMap) + runtime.KeepAlive(clengthAllocMap) + runtime.KeepAlive(csubTypeAllocMap) + runtime.KeepAlive(ckindAllocMap) + runtime.KeepAlive(crecNumberAllocMap) + runtime.KeepAlive(cdescriptorHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetEnvAttr function as declared in include/sql.h:794 +func SQLSetEnvAttr(environmentHandle *SQLHENV, attribute SQLINTEGER, value *SQLPOINTER, stringLength SQLINTEGER) SQLRETURN { + cenvironmentHandle, cenvironmentHandleAllocMap := (C.SQLHENV)(unsafe.Pointer(environmentHandle)), cgoAllocsUnknown + cattribute, cattributeAllocMap := (C.SQLINTEGER)(attribute), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := (C.SQLINTEGER)(stringLength), cgoAllocsUnknown + __ret := C.SQLSetEnvAttr(cenvironmentHandle, cattribute, cvalue, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cattributeAllocMap) + runtime.KeepAlive(cenvironmentHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetParam function as declared in include/sql.h:799 +func SQLSetParam(statementHandle *SQLHSTMT, parameterNumber SQLUSMALLINT, valueType SQLSMALLINT, parameterType SQLSMALLINT, lengthPrecision SQLULEN, parameterScale SQLSMALLINT, parameterValue *SQLPOINTER, strLen_or_Ind []SQLLEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cparameterNumber, cparameterNumberAllocMap := (C.SQLUSMALLINT)(parameterNumber), cgoAllocsUnknown + cvalueType, cvalueTypeAllocMap := (C.SQLSMALLINT)(valueType), cgoAllocsUnknown + cparameterType, cparameterTypeAllocMap := (C.SQLSMALLINT)(parameterType), cgoAllocsUnknown + clengthPrecision, clengthPrecisionAllocMap := (C.SQLULEN)(lengthPrecision), cgoAllocsUnknown + cparameterScale, cparameterScaleAllocMap := (C.SQLSMALLINT)(parameterScale), cgoAllocsUnknown + cparameterValue, cparameterValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(parameterValue)), cgoAllocsUnknown + cstrLen_or_Ind, cstrLen_or_IndAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&strLen_or_Ind))) + __ret := C.SQLSetParam(cstatementHandle, cparameterNumber, cvalueType, cparameterType, clengthPrecision, cparameterScale, cparameterValue, cstrLen_or_Ind) + runtime.KeepAlive(cstrLen_or_IndAllocMap) + runtime.KeepAlive(cparameterValueAllocMap) + runtime.KeepAlive(cparameterScaleAllocMap) + runtime.KeepAlive(clengthPrecisionAllocMap) + runtime.KeepAlive(cparameterTypeAllocMap) + runtime.KeepAlive(cvalueTypeAllocMap) + runtime.KeepAlive(cparameterNumberAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetStmtAttr function as declared in include/sql.h:806 +func SQLSetStmtAttr(statementHandle *SQLHSTMT, attribute SQLINTEGER, value *SQLPOINTER, stringLength SQLINTEGER) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cattribute, cattributeAllocMap := (C.SQLINTEGER)(attribute), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cstringLength, cstringLengthAllocMap := (C.SQLINTEGER)(stringLength), cgoAllocsUnknown + __ret := C.SQLSetStmtAttr(cstatementHandle, cattribute, cvalue, cstringLength) + runtime.KeepAlive(cstringLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cattributeAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetStmtOption function as declared in include/sql.h:811 +func SQLSetStmtOption(statementHandle *SQLHSTMT, option SQLUSMALLINT, value SQLULEN) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + coption, coptionAllocMap := (C.SQLUSMALLINT)(option), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLULEN)(value), cgoAllocsUnknown + __ret := C.SQLSetStmtOption(cstatementHandle, coption, cvalue) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(coptionAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSpecialColumns function as declared in include/sql.h:814 +func SQLSpecialColumns(statementHandle *SQLHSTMT, identifierType SQLUSMALLINT, catalogName []SQLCHAR, nameLength1 SQLSMALLINT, schemaName []SQLCHAR, nameLength2 SQLSMALLINT, tableName []SQLCHAR, nameLength3 SQLSMALLINT, scope SQLUSMALLINT, nullable SQLUSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cidentifierType, cidentifierTypeAllocMap := (C.SQLUSMALLINT)(identifierType), cgoAllocsUnknown + ccatalogName, ccatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&catalogName))) + cnameLength1, cnameLength1AllocMap := (C.SQLSMALLINT)(nameLength1), cgoAllocsUnknown + cschemaName, cschemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&schemaName))) + cnameLength2, cnameLength2AllocMap := (C.SQLSMALLINT)(nameLength2), cgoAllocsUnknown + ctableName, ctableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&tableName))) + cnameLength3, cnameLength3AllocMap := (C.SQLSMALLINT)(nameLength3), cgoAllocsUnknown + cscope, cscopeAllocMap := (C.SQLUSMALLINT)(scope), cgoAllocsUnknown + cnullable, cnullableAllocMap := (C.SQLUSMALLINT)(nullable), cgoAllocsUnknown + __ret := C.SQLSpecialColumns(cstatementHandle, cidentifierType, ccatalogName, cnameLength1, cschemaName, cnameLength2, ctableName, cnameLength3, cscope, cnullable) + runtime.KeepAlive(cnullableAllocMap) + runtime.KeepAlive(cscopeAllocMap) + runtime.KeepAlive(cnameLength3AllocMap) + runtime.KeepAlive(ctableNameAllocMap) + runtime.KeepAlive(cnameLength2AllocMap) + runtime.KeepAlive(cschemaNameAllocMap) + runtime.KeepAlive(cnameLength1AllocMap) + runtime.KeepAlive(ccatalogNameAllocMap) + runtime.KeepAlive(cidentifierTypeAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLStatistics function as declared in include/sql.h:821 +func SQLStatistics(statementHandle *SQLHSTMT, catalogName []SQLCHAR, nameLength1 SQLSMALLINT, schemaName []SQLCHAR, nameLength2 SQLSMALLINT, tableName []SQLCHAR, nameLength3 SQLSMALLINT, unique SQLUSMALLINT, reserved SQLUSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccatalogName, ccatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&catalogName))) + cnameLength1, cnameLength1AllocMap := (C.SQLSMALLINT)(nameLength1), cgoAllocsUnknown + cschemaName, cschemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&schemaName))) + cnameLength2, cnameLength2AllocMap := (C.SQLSMALLINT)(nameLength2), cgoAllocsUnknown + ctableName, ctableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&tableName))) + cnameLength3, cnameLength3AllocMap := (C.SQLSMALLINT)(nameLength3), cgoAllocsUnknown + cunique, cuniqueAllocMap := (C.SQLUSMALLINT)(unique), cgoAllocsUnknown + creserved, creservedAllocMap := (C.SQLUSMALLINT)(reserved), cgoAllocsUnknown + __ret := C.SQLStatistics(cstatementHandle, ccatalogName, cnameLength1, cschemaName, cnameLength2, ctableName, cnameLength3, cunique, creserved) + runtime.KeepAlive(creservedAllocMap) + runtime.KeepAlive(cuniqueAllocMap) + runtime.KeepAlive(cnameLength3AllocMap) + runtime.KeepAlive(ctableNameAllocMap) + runtime.KeepAlive(cnameLength2AllocMap) + runtime.KeepAlive(cschemaNameAllocMap) + runtime.KeepAlive(cnameLength1AllocMap) + runtime.KeepAlive(ccatalogNameAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLTables function as declared in include/sql.h:827 +func SQLTables(statementHandle *SQLHSTMT, catalogName []SQLCHAR, nameLength1 SQLSMALLINT, schemaName []SQLCHAR, nameLength2 SQLSMALLINT, tableName []SQLCHAR, nameLength3 SQLSMALLINT, tableType []SQLCHAR, nameLength4 SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + ccatalogName, ccatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&catalogName))) + cnameLength1, cnameLength1AllocMap := (C.SQLSMALLINT)(nameLength1), cgoAllocsUnknown + cschemaName, cschemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&schemaName))) + cnameLength2, cnameLength2AllocMap := (C.SQLSMALLINT)(nameLength2), cgoAllocsUnknown + ctableName, ctableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&tableName))) + cnameLength3, cnameLength3AllocMap := (C.SQLSMALLINT)(nameLength3), cgoAllocsUnknown + ctableType, ctableTypeAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&tableType))) + cnameLength4, cnameLength4AllocMap := (C.SQLSMALLINT)(nameLength4), cgoAllocsUnknown + __ret := C.SQLTables(cstatementHandle, ccatalogName, cnameLength1, cschemaName, cnameLength2, ctableName, cnameLength3, ctableType, cnameLength4) + runtime.KeepAlive(cnameLength4AllocMap) + runtime.KeepAlive(ctableTypeAllocMap) + runtime.KeepAlive(cnameLength3AllocMap) + runtime.KeepAlive(ctableNameAllocMap) + runtime.KeepAlive(cnameLength2AllocMap) + runtime.KeepAlive(cschemaNameAllocMap) + runtime.KeepAlive(cnameLength1AllocMap) + runtime.KeepAlive(ccatalogNameAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLTransact function as declared in include/sql.h:833 +func SQLTransact(environmentHandle *SQLHENV, connectionHandle *SQLHDBC, completionType SQLUSMALLINT) SQLRETURN { + cenvironmentHandle, cenvironmentHandleAllocMap := (C.SQLHENV)(unsafe.Pointer(environmentHandle)), cgoAllocsUnknown + cconnectionHandle, cconnectionHandleAllocMap := (C.SQLHDBC)(unsafe.Pointer(connectionHandle)), cgoAllocsUnknown + ccompletionType, ccompletionTypeAllocMap := (C.SQLUSMALLINT)(completionType), cgoAllocsUnknown + __ret := C.SQLTransact(cenvironmentHandle, cconnectionHandle, ccompletionType) + runtime.KeepAlive(ccompletionTypeAllocMap) + runtime.KeepAlive(cconnectionHandleAllocMap) + runtime.KeepAlive(cenvironmentHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDriverConnect function as declared in include/sqlext.h:1790 +func SQLDriverConnect(hdbc *SQLHDBC, hwnd *SQLHWND, szConnStrIn *SQLCHAR, cbConnStrIn SQLSMALLINT, szConnStrOut *SQLCHAR, cbConnStrOutMax SQLSMALLINT, pcbConnStrOut *SQLSMALLINT, fDriverCompletion SQLUSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + chwnd, chwndAllocMap := (C.SQLHWND)(unsafe.Pointer(hwnd)), cgoAllocsUnknown + cszConnStrIn, cszConnStrInAllocMap := (*C.SQLCHAR)(unsafe.Pointer(szConnStrIn)), cgoAllocsUnknown + ccbConnStrIn, ccbConnStrInAllocMap := (C.SQLSMALLINT)(cbConnStrIn), cgoAllocsUnknown + cszConnStrOut, cszConnStrOutAllocMap := (*C.SQLCHAR)(unsafe.Pointer(szConnStrOut)), cgoAllocsUnknown + ccbConnStrOutMax, ccbConnStrOutMaxAllocMap := (C.SQLSMALLINT)(cbConnStrOutMax), cgoAllocsUnknown + cpcbConnStrOut, cpcbConnStrOutAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pcbConnStrOut)), cgoAllocsUnknown + cfDriverCompletion, cfDriverCompletionAllocMap := (C.SQLUSMALLINT)(fDriverCompletion), cgoAllocsUnknown + __ret := C.SQLDriverConnect(chdbc, chwnd, cszConnStrIn, ccbConnStrIn, cszConnStrOut, ccbConnStrOutMax, cpcbConnStrOut, cfDriverCompletion) + runtime.KeepAlive(cfDriverCompletionAllocMap) + runtime.KeepAlive(cpcbConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrOutMaxAllocMap) + runtime.KeepAlive(cszConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrInAllocMap) + runtime.KeepAlive(cszConnStrInAllocMap) + runtime.KeepAlive(chwndAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLBrowseConnect function as declared in include/sqlext.h:1901 +func SQLBrowseConnect(hdbc *SQLHDBC, szConnStrIn []SQLCHAR, cbConnStrIn SQLSMALLINT, szConnStrOut []SQLCHAR, cbConnStrOutMax SQLSMALLINT, pcbConnStrOut []SQLSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cszConnStrIn, cszConnStrInAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szConnStrIn))) + ccbConnStrIn, ccbConnStrInAllocMap := (C.SQLSMALLINT)(cbConnStrIn), cgoAllocsUnknown + cszConnStrOut, cszConnStrOutAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szConnStrOut))) + ccbConnStrOutMax, ccbConnStrOutMaxAllocMap := (C.SQLSMALLINT)(cbConnStrOutMax), cgoAllocsUnknown + cpcbConnStrOut, cpcbConnStrOutAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbConnStrOut))) + __ret := C.SQLBrowseConnect(chdbc, cszConnStrIn, ccbConnStrIn, cszConnStrOut, ccbConnStrOutMax, cpcbConnStrOut) + runtime.KeepAlive(cpcbConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrOutMaxAllocMap) + runtime.KeepAlive(cszConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrInAllocMap) + runtime.KeepAlive(cszConnStrInAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLBulkOperations function as declared in include/sqlext.h:1910 +func SQLBulkOperations(statementHandle *SQLHSTMT, operation SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + coperation, coperationAllocMap := (C.SQLSMALLINT)(operation), cgoAllocsUnknown + __ret := C.SQLBulkOperations(cstatementHandle, coperation) + runtime.KeepAlive(coperationAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColAttributes function as declared in include/sqlext.h:1915 +func SQLColAttributes(hstmt *SQLHSTMT, icol SQLUSMALLINT, fDescType SQLUSMALLINT, rgbDesc *SQLPOINTER, cbDescMax SQLSMALLINT, pcbDesc []SQLSMALLINT, pfDesc []SQLLEN) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cicol, cicolAllocMap := (C.SQLUSMALLINT)(icol), cgoAllocsUnknown + cfDescType, cfDescTypeAllocMap := (C.SQLUSMALLINT)(fDescType), cgoAllocsUnknown + crgbDesc, crgbDescAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbDesc)), cgoAllocsUnknown + ccbDescMax, ccbDescMaxAllocMap := (C.SQLSMALLINT)(cbDescMax), cgoAllocsUnknown + cpcbDesc, cpcbDescAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDesc))) + cpfDesc, cpfDescAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&pfDesc))) + __ret := C.SQLColAttributes(chstmt, cicol, cfDescType, crgbDesc, ccbDescMax, cpcbDesc, cpfDesc) + runtime.KeepAlive(cpfDescAllocMap) + runtime.KeepAlive(cpcbDescAllocMap) + runtime.KeepAlive(ccbDescMaxAllocMap) + runtime.KeepAlive(crgbDescAllocMap) + runtime.KeepAlive(cfDescTypeAllocMap) + runtime.KeepAlive(cicolAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColumnPrivileges function as declared in include/sqlext.h:1924 +func SQLColumnPrivileges(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT, szColumnName []SQLCHAR, cbColumnName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cszColumnName, cszColumnNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szColumnName))) + ccbColumnName, ccbColumnNameAllocMap := (C.SQLSMALLINT)(cbColumnName), cgoAllocsUnknown + __ret := C.SQLColumnPrivileges(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cszColumnName, ccbColumnName) + runtime.KeepAlive(ccbColumnNameAllocMap) + runtime.KeepAlive(cszColumnNameAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDescribeParam function as declared in include/sqlext.h:1935 +func SQLDescribeParam(hstmt *SQLHSTMT, ipar SQLUSMALLINT, pfSqlType *SQLSMALLINT, pcbParamDef *SQLULEN, pibScale *SQLSMALLINT, pfNullable *SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cipar, ciparAllocMap := (C.SQLUSMALLINT)(ipar), cgoAllocsUnknown + cpfSqlType, cpfSqlTypeAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pfSqlType)), cgoAllocsUnknown + cpcbParamDef, cpcbParamDefAllocMap := (*C.SQLULEN)(unsafe.Pointer(pcbParamDef)), cgoAllocsUnknown + cpibScale, cpibScaleAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pibScale)), cgoAllocsUnknown + cpfNullable, cpfNullableAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pfNullable)), cgoAllocsUnknown + __ret := C.SQLDescribeParam(chstmt, cipar, cpfSqlType, cpcbParamDef, cpibScale, cpfNullable) + runtime.KeepAlive(cpfNullableAllocMap) + runtime.KeepAlive(cpibScaleAllocMap) + runtime.KeepAlive(cpcbParamDefAllocMap) + runtime.KeepAlive(cpfSqlTypeAllocMap) + runtime.KeepAlive(ciparAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLExtendedFetch function as declared in include/sqlext.h:1943 +func SQLExtendedFetch(hstmt *SQLHSTMT, fFetchType SQLUSMALLINT, irow SQLLEN, pcrow []SQLULEN, rgfRowStatus []SQLUSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cfFetchType, cfFetchTypeAllocMap := (C.SQLUSMALLINT)(fFetchType), cgoAllocsUnknown + cirow, cirowAllocMap := (C.SQLLEN)(irow), cgoAllocsUnknown + cpcrow, cpcrowAllocMap := copyPSQLULENBytes((*sliceHeader)(unsafe.Pointer(&pcrow))) + crgfRowStatus, crgfRowStatusAllocMap := copyPSQLUSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&rgfRowStatus))) + __ret := C.SQLExtendedFetch(chstmt, cfFetchType, cirow, cpcrow, crgfRowStatus) + runtime.KeepAlive(crgfRowStatusAllocMap) + runtime.KeepAlive(cpcrowAllocMap) + runtime.KeepAlive(cirowAllocMap) + runtime.KeepAlive(cfFetchTypeAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLForeignKeys function as declared in include/sqlext.h:1950 +func SQLForeignKeys(hstmt *SQLHSTMT, szPkCatalogName []SQLCHAR, cbPkCatalogName SQLSMALLINT, szPkSchemaName []SQLCHAR, cbPkSchemaName SQLSMALLINT, szPkTableName []SQLCHAR, cbPkTableName SQLSMALLINT, szFkCatalogName []SQLCHAR, cbFkCatalogName SQLSMALLINT, szFkSchemaName []SQLCHAR, cbFkSchemaName SQLSMALLINT, szFkTableName []SQLCHAR, cbFkTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszPkCatalogName, cszPkCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkCatalogName))) + ccbPkCatalogName, ccbPkCatalogNameAllocMap := (C.SQLSMALLINT)(cbPkCatalogName), cgoAllocsUnknown + cszPkSchemaName, cszPkSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkSchemaName))) + ccbPkSchemaName, ccbPkSchemaNameAllocMap := (C.SQLSMALLINT)(cbPkSchemaName), cgoAllocsUnknown + cszPkTableName, cszPkTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkTableName))) + ccbPkTableName, ccbPkTableNameAllocMap := (C.SQLSMALLINT)(cbPkTableName), cgoAllocsUnknown + cszFkCatalogName, cszFkCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkCatalogName))) + ccbFkCatalogName, ccbFkCatalogNameAllocMap := (C.SQLSMALLINT)(cbFkCatalogName), cgoAllocsUnknown + cszFkSchemaName, cszFkSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkSchemaName))) + ccbFkSchemaName, ccbFkSchemaNameAllocMap := (C.SQLSMALLINT)(cbFkSchemaName), cgoAllocsUnknown + cszFkTableName, cszFkTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkTableName))) + ccbFkTableName, ccbFkTableNameAllocMap := (C.SQLSMALLINT)(cbFkTableName), cgoAllocsUnknown + __ret := C.SQLForeignKeys(chstmt, cszPkCatalogName, ccbPkCatalogName, cszPkSchemaName, ccbPkSchemaName, cszPkTableName, ccbPkTableName, cszFkCatalogName, ccbFkCatalogName, cszFkSchemaName, ccbFkSchemaName, cszFkTableName, ccbFkTableName) + runtime.KeepAlive(ccbFkTableNameAllocMap) + runtime.KeepAlive(cszFkTableNameAllocMap) + runtime.KeepAlive(ccbFkSchemaNameAllocMap) + runtime.KeepAlive(cszFkSchemaNameAllocMap) + runtime.KeepAlive(ccbFkCatalogNameAllocMap) + runtime.KeepAlive(cszFkCatalogNameAllocMap) + runtime.KeepAlive(ccbPkTableNameAllocMap) + runtime.KeepAlive(cszPkTableNameAllocMap) + runtime.KeepAlive(ccbPkSchemaNameAllocMap) + runtime.KeepAlive(cszPkSchemaNameAllocMap) + runtime.KeepAlive(ccbPkCatalogNameAllocMap) + runtime.KeepAlive(cszPkCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLMoreResults function as declared in include/sqlext.h:1965 +func SQLMoreResults(hstmt *SQLHSTMT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + __ret := C.SQLMoreResults(chstmt) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLNativeSql function as declared in include/sqlext.h:1968 +func SQLNativeSql(hdbc *SQLHDBC, szSqlStrIn []SQLCHAR, cbSqlStrIn SQLINTEGER, szSqlStr []SQLCHAR, cbSqlStrMax SQLINTEGER, pcbSqlStr []SQLINTEGER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cszSqlStrIn, cszSqlStrInAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSqlStrIn))) + ccbSqlStrIn, ccbSqlStrInAllocMap := (C.SQLINTEGER)(cbSqlStrIn), cgoAllocsUnknown + cszSqlStr, cszSqlStrAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSqlStr))) + ccbSqlStrMax, ccbSqlStrMaxAllocMap := (C.SQLINTEGER)(cbSqlStrMax), cgoAllocsUnknown + cpcbSqlStr, cpcbSqlStrAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pcbSqlStr))) + __ret := C.SQLNativeSql(chdbc, cszSqlStrIn, ccbSqlStrIn, cszSqlStr, ccbSqlStrMax, cpcbSqlStr) + runtime.KeepAlive(cpcbSqlStrAllocMap) + runtime.KeepAlive(ccbSqlStrMaxAllocMap) + runtime.KeepAlive(cszSqlStrAllocMap) + runtime.KeepAlive(ccbSqlStrInAllocMap) + runtime.KeepAlive(cszSqlStrInAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLNumParams function as declared in include/sqlext.h:1976 +func SQLNumParams(hstmt *SQLHSTMT, pcpar *SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cpcpar, cpcparAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pcpar)), cgoAllocsUnknown + __ret := C.SQLNumParams(chstmt, cpcpar) + runtime.KeepAlive(cpcparAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLParamOptions function as declared in include/sqlext.h:1980 +func SQLParamOptions(hstmt *SQLHSTMT, crow SQLULEN, pirow []SQLULEN) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + ccrow, ccrowAllocMap := (C.SQLULEN)(crow), cgoAllocsUnknown + cpirow, cpirowAllocMap := copyPSQLULENBytes((*sliceHeader)(unsafe.Pointer(&pirow))) + __ret := C.SQLParamOptions(chstmt, ccrow, cpirow) + runtime.KeepAlive(cpirowAllocMap) + runtime.KeepAlive(ccrowAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLPrimaryKeys function as declared in include/sqlext.h:1985 +func SQLPrimaryKeys(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + __ret := C.SQLPrimaryKeys(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLProcedureColumns function as declared in include/sqlext.h:1994 +func SQLProcedureColumns(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szProcName []SQLCHAR, cbProcName SQLSMALLINT, szColumnName []SQLCHAR, cbColumnName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszProcName, cszProcNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szProcName))) + ccbProcName, ccbProcNameAllocMap := (C.SQLSMALLINT)(cbProcName), cgoAllocsUnknown + cszColumnName, cszColumnNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szColumnName))) + ccbColumnName, ccbColumnNameAllocMap := (C.SQLSMALLINT)(cbColumnName), cgoAllocsUnknown + __ret := C.SQLProcedureColumns(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszProcName, ccbProcName, cszColumnName, ccbColumnName) + runtime.KeepAlive(ccbColumnNameAllocMap) + runtime.KeepAlive(cszColumnNameAllocMap) + runtime.KeepAlive(ccbProcNameAllocMap) + runtime.KeepAlive(cszProcNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLProcedures function as declared in include/sqlext.h:2005 +func SQLProcedures(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szProcName []SQLCHAR, cbProcName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszProcName, cszProcNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szProcName))) + ccbProcName, ccbProcNameAllocMap := (C.SQLSMALLINT)(cbProcName), cgoAllocsUnknown + __ret := C.SQLProcedures(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszProcName, ccbProcName) + runtime.KeepAlive(ccbProcNameAllocMap) + runtime.KeepAlive(cszProcNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetPos function as declared in include/sqlext.h:2014 +func SQLSetPos(hstmt *SQLHSTMT, irow SQLSETPOSIROW, fOption SQLUSMALLINT, fLock SQLUSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cirow, cirowAllocMap := (C.SQLSETPOSIROW)(irow), cgoAllocsUnknown + cfOption, cfOptionAllocMap := (C.SQLUSMALLINT)(fOption), cgoAllocsUnknown + cfLock, cfLockAllocMap := (C.SQLUSMALLINT)(fLock), cgoAllocsUnknown + __ret := C.SQLSetPos(chstmt, cirow, cfOption, cfLock) + runtime.KeepAlive(cfLockAllocMap) + runtime.KeepAlive(cfOptionAllocMap) + runtime.KeepAlive(cirowAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLTablePrivileges function as declared in include/sqlext.h:2020 +func SQLTablePrivileges(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + __ret := C.SQLTablePrivileges(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDrivers function as declared in include/sqlext.h:2029 +func SQLDrivers(henv *SQLHENV, fDirection SQLUSMALLINT, szDriverDesc []SQLCHAR, cbDriverDescMax SQLSMALLINT, pcbDriverDesc []SQLSMALLINT, szDriverAttributes []SQLCHAR, cbDrvrAttrMax SQLSMALLINT, pcbDrvrAttr []SQLSMALLINT) SQLRETURN { + chenv, chenvAllocMap := (C.SQLHENV)(unsafe.Pointer(henv)), cgoAllocsUnknown + cfDirection, cfDirectionAllocMap := (C.SQLUSMALLINT)(fDirection), cgoAllocsUnknown + cszDriverDesc, cszDriverDescAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szDriverDesc))) + ccbDriverDescMax, ccbDriverDescMaxAllocMap := (C.SQLSMALLINT)(cbDriverDescMax), cgoAllocsUnknown + cpcbDriverDesc, cpcbDriverDescAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDriverDesc))) + cszDriverAttributes, cszDriverAttributesAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szDriverAttributes))) + ccbDrvrAttrMax, ccbDrvrAttrMaxAllocMap := (C.SQLSMALLINT)(cbDrvrAttrMax), cgoAllocsUnknown + cpcbDrvrAttr, cpcbDrvrAttrAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDrvrAttr))) + __ret := C.SQLDrivers(chenv, cfDirection, cszDriverDesc, ccbDriverDescMax, cpcbDriverDesc, cszDriverAttributes, ccbDrvrAttrMax, cpcbDrvrAttr) + runtime.KeepAlive(cpcbDrvrAttrAllocMap) + runtime.KeepAlive(ccbDrvrAttrMaxAllocMap) + runtime.KeepAlive(cszDriverAttributesAllocMap) + runtime.KeepAlive(cpcbDriverDescAllocMap) + runtime.KeepAlive(ccbDriverDescMaxAllocMap) + runtime.KeepAlive(cszDriverDescAllocMap) + runtime.KeepAlive(cfDirectionAllocMap) + runtime.KeepAlive(chenvAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLBindParameter function as declared in include/sqlext.h:2039 +func SQLBindParameter(hstmt *SQLHSTMT, ipar SQLUSMALLINT, fParamType SQLSMALLINT, fCType SQLSMALLINT, fSqlType SQLSMALLINT, cbColDef SQLULEN, ibScale SQLSMALLINT, rgbValue *SQLPOINTER, cbValueMax SQLLEN, pcbValue *SQLLEN) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cipar, ciparAllocMap := (C.SQLUSMALLINT)(ipar), cgoAllocsUnknown + cfParamType, cfParamTypeAllocMap := (C.SQLSMALLINT)(fParamType), cgoAllocsUnknown + cfCType, cfCTypeAllocMap := (C.SQLSMALLINT)(fCType), cgoAllocsUnknown + cfSqlType, cfSqlTypeAllocMap := (C.SQLSMALLINT)(fSqlType), cgoAllocsUnknown + ccbColDef, ccbColDefAllocMap := (C.SQLULEN)(cbColDef), cgoAllocsUnknown + cibScale, cibScaleAllocMap := (C.SQLSMALLINT)(ibScale), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValueMax, ccbValueMaxAllocMap := (C.SQLLEN)(cbValueMax), cgoAllocsUnknown + cpcbValue, cpcbValueAllocMap := (*C.SQLLEN)(unsafe.Pointer(pcbValue)), cgoAllocsUnknown + __ret := C.SQLBindParameter(chstmt, cipar, cfParamType, cfCType, cfSqlType, ccbColDef, cibScale, crgbValue, ccbValueMax, cpcbValue) + runtime.KeepAlive(cpcbValueAllocMap) + runtime.KeepAlive(ccbValueMaxAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(cibScaleAllocMap) + runtime.KeepAlive(ccbColDefAllocMap) + runtime.KeepAlive(cfSqlTypeAllocMap) + runtime.KeepAlive(cfCTypeAllocMap) + runtime.KeepAlive(cfParamTypeAllocMap) + runtime.KeepAlive(ciparAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLAllocHandleStd function as declared in include/sqlext.h:2077 +func SQLAllocHandleStd(fHandleType SQLSMALLINT, hInput *SQLHANDLE, phOutput **SQLHANDLE) SQLRETURN { + cfHandleType, cfHandleTypeAllocMap := (C.SQLSMALLINT)(fHandleType), cgoAllocsUnknown + chInput, chInputAllocMap := (C.SQLHANDLE)(unsafe.Pointer(hInput)), cgoAllocsUnknown + cphOutput, cphOutputAllocMap := (*C.SQLHANDLE)(unsafe.Pointer(phOutput)), cgoAllocsUnknown + __ret := C.SQLAllocHandleStd(cfHandleType, chInput, cphOutput) + runtime.KeepAlive(cphOutputAllocMap) + runtime.KeepAlive(chInputAllocMap) + runtime.KeepAlive(cfHandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetScrollOptions function as declared in include/sqlext.h:2104 +func SQLSetScrollOptions(hstmt *SQLHSTMT, fConcurrency SQLUSMALLINT, crowKeyset SQLLEN, crowRowset SQLUSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cfConcurrency, cfConcurrencyAllocMap := (C.SQLUSMALLINT)(fConcurrency), cgoAllocsUnknown + ccrowKeyset, ccrowKeysetAllocMap := (C.SQLLEN)(crowKeyset), cgoAllocsUnknown + ccrowRowset, ccrowRowsetAllocMap := (C.SQLUSMALLINT)(crowRowset), cgoAllocsUnknown + __ret := C.SQLSetScrollOptions(chstmt, cfConcurrency, ccrowKeyset, ccrowRowset) + runtime.KeepAlive(ccrowRowsetAllocMap) + runtime.KeepAlive(ccrowKeysetAllocMap) + runtime.KeepAlive(cfConcurrencyAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColAttributeW function as declared in include/sqlucode.h:29 +func SQLColAttributeW(hstmt *SQLHSTMT, iCol SQLUSMALLINT, iField SQLUSMALLINT, pCharAttr *SQLPOINTER, cbCharAttrMax SQLSMALLINT, pcbCharAttr []SQLSMALLINT, pNumAttr []SQLLEN) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + ciCol, ciColAllocMap := (C.SQLUSMALLINT)(iCol), cgoAllocsUnknown + ciField, ciFieldAllocMap := (C.SQLUSMALLINT)(iField), cgoAllocsUnknown + cpCharAttr, cpCharAttrAllocMap := (C.SQLPOINTER)(unsafe.Pointer(pCharAttr)), cgoAllocsUnknown + ccbCharAttrMax, ccbCharAttrMaxAllocMap := (C.SQLSMALLINT)(cbCharAttrMax), cgoAllocsUnknown + cpcbCharAttr, cpcbCharAttrAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbCharAttr))) + cpNumAttr, cpNumAttrAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&pNumAttr))) + __ret := C.SQLColAttributeW(chstmt, ciCol, ciField, cpCharAttr, ccbCharAttrMax, cpcbCharAttr, cpNumAttr) + runtime.KeepAlive(cpNumAttrAllocMap) + runtime.KeepAlive(cpcbCharAttrAllocMap) + runtime.KeepAlive(ccbCharAttrMaxAllocMap) + runtime.KeepAlive(cpCharAttrAllocMap) + runtime.KeepAlive(ciFieldAllocMap) + runtime.KeepAlive(ciColAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColAttributesW function as declared in include/sqlucode.h:38 +func SQLColAttributesW(hstmt *SQLHSTMT, icol SQLUSMALLINT, fDescType SQLUSMALLINT, rgbDesc *SQLPOINTER, cbDescMax SQLSMALLINT, pcbDesc []SQLSMALLINT, pfDesc []SQLLEN) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cicol, cicolAllocMap := (C.SQLUSMALLINT)(icol), cgoAllocsUnknown + cfDescType, cfDescTypeAllocMap := (C.SQLUSMALLINT)(fDescType), cgoAllocsUnknown + crgbDesc, crgbDescAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbDesc)), cgoAllocsUnknown + ccbDescMax, ccbDescMaxAllocMap := (C.SQLSMALLINT)(cbDescMax), cgoAllocsUnknown + cpcbDesc, cpcbDescAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDesc))) + cpfDesc, cpfDescAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&pfDesc))) + __ret := C.SQLColAttributesW(chstmt, cicol, cfDescType, crgbDesc, ccbDescMax, cpcbDesc, cpfDesc) + runtime.KeepAlive(cpfDescAllocMap) + runtime.KeepAlive(cpcbDescAllocMap) + runtime.KeepAlive(ccbDescMaxAllocMap) + runtime.KeepAlive(crgbDescAllocMap) + runtime.KeepAlive(cfDescTypeAllocMap) + runtime.KeepAlive(cicolAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLConnectW function as declared in include/sqlucode.h:47 +func SQLConnectW(hdbc *SQLHDBC, szDSN []SQLWCHAR, cbDSN SQLSMALLINT, szUID []SQLWCHAR, cbUID SQLSMALLINT, szAuthStr []SQLWCHAR, cbAuthStr SQLSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cszDSN, cszDSNAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szDSN))) + ccbDSN, ccbDSNAllocMap := (C.SQLSMALLINT)(cbDSN), cgoAllocsUnknown + cszUID, cszUIDAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szUID))) + ccbUID, ccbUIDAllocMap := (C.SQLSMALLINT)(cbUID), cgoAllocsUnknown + cszAuthStr, cszAuthStrAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szAuthStr))) + ccbAuthStr, ccbAuthStrAllocMap := (C.SQLSMALLINT)(cbAuthStr), cgoAllocsUnknown + __ret := C.SQLConnectW(chdbc, cszDSN, ccbDSN, cszUID, ccbUID, cszAuthStr, ccbAuthStr) + runtime.KeepAlive(ccbAuthStrAllocMap) + runtime.KeepAlive(cszAuthStrAllocMap) + runtime.KeepAlive(ccbUIDAllocMap) + runtime.KeepAlive(cszUIDAllocMap) + runtime.KeepAlive(ccbDSNAllocMap) + runtime.KeepAlive(cszDSNAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDescribeColW function as declared in include/sqlucode.h:57 +func SQLDescribeColW(hstmt *SQLHSTMT, icol SQLUSMALLINT, szColName *SQLWCHAR, cbColNameMax SQLSMALLINT, pcbColName *SQLSMALLINT, pfSqlType *SQLSMALLINT, pcbColDef *SQLULEN, pibScale *SQLSMALLINT, pfNullable *SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cicol, cicolAllocMap := (C.SQLUSMALLINT)(icol), cgoAllocsUnknown + cszColName, cszColNameAllocMap := (*C.SQLWCHAR)(unsafe.Pointer(szColName)), cgoAllocsUnknown + ccbColNameMax, ccbColNameMaxAllocMap := (C.SQLSMALLINT)(cbColNameMax), cgoAllocsUnknown + cpcbColName, cpcbColNameAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pcbColName)), cgoAllocsUnknown + cpfSqlType, cpfSqlTypeAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pfSqlType)), cgoAllocsUnknown + cpcbColDef, cpcbColDefAllocMap := (*C.SQLULEN)(unsafe.Pointer(pcbColDef)), cgoAllocsUnknown + cpibScale, cpibScaleAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pibScale)), cgoAllocsUnknown + cpfNullable, cpfNullableAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pfNullable)), cgoAllocsUnknown + __ret := C.SQLDescribeColW(chstmt, cicol, cszColName, ccbColNameMax, cpcbColName, cpfSqlType, cpcbColDef, cpibScale, cpfNullable) + runtime.KeepAlive(cpfNullableAllocMap) + runtime.KeepAlive(cpibScaleAllocMap) + runtime.KeepAlive(cpcbColDefAllocMap) + runtime.KeepAlive(cpfSqlTypeAllocMap) + runtime.KeepAlive(cpcbColNameAllocMap) + runtime.KeepAlive(ccbColNameMaxAllocMap) + runtime.KeepAlive(cszColNameAllocMap) + runtime.KeepAlive(cicolAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLErrorW function as declared in include/sqlucode.h:69 +func SQLErrorW(henv *SQLHENV, hdbc *SQLHDBC, hstmt *SQLHSTMT, szSqlState []SQLWCHAR, pfNativeError []SQLINTEGER, szErrorMsg []SQLWCHAR, cbErrorMsgMax SQLSMALLINT, pcbErrorMsg []SQLSMALLINT) SQLRETURN { + chenv, chenvAllocMap := (C.SQLHENV)(unsafe.Pointer(henv)), cgoAllocsUnknown + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszSqlState, cszSqlStateAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSqlState))) + cpfNativeError, cpfNativeErrorAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pfNativeError))) + cszErrorMsg, cszErrorMsgAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szErrorMsg))) + ccbErrorMsgMax, ccbErrorMsgMaxAllocMap := (C.SQLSMALLINT)(cbErrorMsgMax), cgoAllocsUnknown + cpcbErrorMsg, cpcbErrorMsgAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbErrorMsg))) + __ret := C.SQLErrorW(chenv, chdbc, chstmt, cszSqlState, cpfNativeError, cszErrorMsg, ccbErrorMsgMax, cpcbErrorMsg) + runtime.KeepAlive(cpcbErrorMsgAllocMap) + runtime.KeepAlive(ccbErrorMsgMaxAllocMap) + runtime.KeepAlive(cszErrorMsgAllocMap) + runtime.KeepAlive(cpfNativeErrorAllocMap) + runtime.KeepAlive(cszSqlStateAllocMap) + runtime.KeepAlive(chstmtAllocMap) + runtime.KeepAlive(chdbcAllocMap) + runtime.KeepAlive(chenvAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLExecDirectW function as declared in include/sqlucode.h:79 +func SQLExecDirectW(hstmt *SQLHSTMT, szSqlStr *SQLWCHAR, cbSqlStr SQLINTEGER) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszSqlStr, cszSqlStrAllocMap := (*C.SQLWCHAR)(unsafe.Pointer(szSqlStr)), cgoAllocsUnknown + ccbSqlStr, ccbSqlStrAllocMap := (C.SQLINTEGER)(cbSqlStr), cgoAllocsUnknown + __ret := C.SQLExecDirectW(chstmt, cszSqlStr, ccbSqlStr) + runtime.KeepAlive(ccbSqlStrAllocMap) + runtime.KeepAlive(cszSqlStrAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetConnectAttrW function as declared in include/sqlucode.h:84 +func SQLGetConnectAttrW(hdbc *SQLHDBC, fAttribute SQLINTEGER, rgbValue *SQLPOINTER, cbValueMax SQLINTEGER, pcbValue *SQLINTEGER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfAttribute, cfAttributeAllocMap := (C.SQLINTEGER)(fAttribute), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValueMax, ccbValueMaxAllocMap := (C.SQLINTEGER)(cbValueMax), cgoAllocsUnknown + cpcbValue, cpcbValueAllocMap := (*C.SQLINTEGER)(unsafe.Pointer(pcbValue)), cgoAllocsUnknown + __ret := C.SQLGetConnectAttrW(chdbc, cfAttribute, crgbValue, ccbValueMax, cpcbValue) + runtime.KeepAlive(cpcbValueAllocMap) + runtime.KeepAlive(ccbValueMaxAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(cfAttributeAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetCursorNameW function as declared in include/sqlucode.h:91 +func SQLGetCursorNameW(hstmt *SQLHSTMT, szCursor []SQLWCHAR, cbCursorMax SQLSMALLINT, pcbCursor []SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCursor, cszCursorAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCursor))) + ccbCursorMax, ccbCursorMaxAllocMap := (C.SQLSMALLINT)(cbCursorMax), cgoAllocsUnknown + cpcbCursor, cpcbCursorAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbCursor))) + __ret := C.SQLGetCursorNameW(chstmt, cszCursor, ccbCursorMax, cpcbCursor) + runtime.KeepAlive(cpcbCursorAllocMap) + runtime.KeepAlive(ccbCursorMaxAllocMap) + runtime.KeepAlive(cszCursorAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetDescFieldW function as declared in include/sqlucode.h:98 +func SQLSetDescFieldW(descriptorHandle *SQLHDESC, recNumber SQLSMALLINT, fieldIdentifier SQLSMALLINT, value *SQLPOINTER, bufferLength SQLINTEGER) SQLRETURN { + cdescriptorHandle, cdescriptorHandleAllocMap := (C.SQLHDESC)(unsafe.Pointer(descriptorHandle)), cgoAllocsUnknown + crecNumber, crecNumberAllocMap := (C.SQLSMALLINT)(recNumber), cgoAllocsUnknown + cfieldIdentifier, cfieldIdentifierAllocMap := (C.SQLSMALLINT)(fieldIdentifier), cgoAllocsUnknown + cvalue, cvalueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(value)), cgoAllocsUnknown + cbufferLength, cbufferLengthAllocMap := (C.SQLINTEGER)(bufferLength), cgoAllocsUnknown + __ret := C.SQLSetDescFieldW(cdescriptorHandle, crecNumber, cfieldIdentifier, cvalue, cbufferLength) + runtime.KeepAlive(cbufferLengthAllocMap) + runtime.KeepAlive(cvalueAllocMap) + runtime.KeepAlive(cfieldIdentifierAllocMap) + runtime.KeepAlive(crecNumberAllocMap) + runtime.KeepAlive(cdescriptorHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDescFieldW function as declared in include/sqlucode.h:106 +func SQLGetDescFieldW(hdesc *SQLHDESC, iRecord SQLSMALLINT, iField SQLSMALLINT, rgbValue *SQLPOINTER, cbValueMax SQLINTEGER, pcbValue []SQLINTEGER) SQLRETURN { + chdesc, chdescAllocMap := (C.SQLHDESC)(unsafe.Pointer(hdesc)), cgoAllocsUnknown + ciRecord, ciRecordAllocMap := (C.SQLSMALLINT)(iRecord), cgoAllocsUnknown + ciField, ciFieldAllocMap := (C.SQLSMALLINT)(iField), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValueMax, ccbValueMaxAllocMap := (C.SQLINTEGER)(cbValueMax), cgoAllocsUnknown + cpcbValue, cpcbValueAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pcbValue))) + __ret := C.SQLGetDescFieldW(chdesc, ciRecord, ciField, crgbValue, ccbValueMax, cpcbValue) + runtime.KeepAlive(cpcbValueAllocMap) + runtime.KeepAlive(ccbValueMaxAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(ciFieldAllocMap) + runtime.KeepAlive(ciRecordAllocMap) + runtime.KeepAlive(chdescAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDescRecW function as declared in include/sqlucode.h:114 +func SQLGetDescRecW(hdesc *SQLHDESC, iRecord SQLSMALLINT, szName []SQLWCHAR, cbNameMax SQLSMALLINT, pcbName []SQLSMALLINT, pfType []SQLSMALLINT, pfSubType []SQLSMALLINT, pLength []SQLLEN, pPrecision []SQLSMALLINT, pScale []SQLSMALLINT, pNullable []SQLSMALLINT) SQLRETURN { + chdesc, chdescAllocMap := (C.SQLHDESC)(unsafe.Pointer(hdesc)), cgoAllocsUnknown + ciRecord, ciRecordAllocMap := (C.SQLSMALLINT)(iRecord), cgoAllocsUnknown + cszName, cszNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szName))) + ccbNameMax, ccbNameMaxAllocMap := (C.SQLSMALLINT)(cbNameMax), cgoAllocsUnknown + cpcbName, cpcbNameAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbName))) + cpfType, cpfTypeAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pfType))) + cpfSubType, cpfSubTypeAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pfSubType))) + cpLength, cpLengthAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&pLength))) + cpPrecision, cpPrecisionAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pPrecision))) + cpScale, cpScaleAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pScale))) + cpNullable, cpNullableAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pNullable))) + __ret := C.SQLGetDescRecW(chdesc, ciRecord, cszName, ccbNameMax, cpcbName, cpfType, cpfSubType, cpLength, cpPrecision, cpScale, cpNullable) + runtime.KeepAlive(cpNullableAllocMap) + runtime.KeepAlive(cpScaleAllocMap) + runtime.KeepAlive(cpPrecisionAllocMap) + runtime.KeepAlive(cpLengthAllocMap) + runtime.KeepAlive(cpfSubTypeAllocMap) + runtime.KeepAlive(cpfTypeAllocMap) + runtime.KeepAlive(cpcbNameAllocMap) + runtime.KeepAlive(ccbNameMaxAllocMap) + runtime.KeepAlive(cszNameAllocMap) + runtime.KeepAlive(ciRecordAllocMap) + runtime.KeepAlive(chdescAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDiagFieldW function as declared in include/sqlucode.h:127 +func SQLGetDiagFieldW(fHandleType SQLSMALLINT, handle *SQLHANDLE, iRecord SQLSMALLINT, fDiagField SQLSMALLINT, rgbDiagInfo *SQLPOINTER, cbDiagInfoMax SQLSMALLINT, pcbDiagInfo []SQLSMALLINT) SQLRETURN { + cfHandleType, cfHandleTypeAllocMap := (C.SQLSMALLINT)(fHandleType), cgoAllocsUnknown + chandle, chandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(handle)), cgoAllocsUnknown + ciRecord, ciRecordAllocMap := (C.SQLSMALLINT)(iRecord), cgoAllocsUnknown + cfDiagField, cfDiagFieldAllocMap := (C.SQLSMALLINT)(fDiagField), cgoAllocsUnknown + crgbDiagInfo, crgbDiagInfoAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbDiagInfo)), cgoAllocsUnknown + ccbDiagInfoMax, ccbDiagInfoMaxAllocMap := (C.SQLSMALLINT)(cbDiagInfoMax), cgoAllocsUnknown + cpcbDiagInfo, cpcbDiagInfoAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDiagInfo))) + __ret := C.SQLGetDiagFieldW(cfHandleType, chandle, ciRecord, cfDiagField, crgbDiagInfo, ccbDiagInfoMax, cpcbDiagInfo) + runtime.KeepAlive(cpcbDiagInfoAllocMap) + runtime.KeepAlive(ccbDiagInfoMaxAllocMap) + runtime.KeepAlive(crgbDiagInfoAllocMap) + runtime.KeepAlive(cfDiagFieldAllocMap) + runtime.KeepAlive(ciRecordAllocMap) + runtime.KeepAlive(chandleAllocMap) + runtime.KeepAlive(cfHandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDiagRecW function as declared in include/sqlucode.h:136 +func SQLGetDiagRecW(fHandleType SQLSMALLINT, handle *SQLHANDLE, iRecord SQLSMALLINT, szSqlState *SQLWCHAR, pfNativeError *SQLINTEGER, szErrorMsg *SQLWCHAR, cbErrorMsgMax SQLSMALLINT, pcbErrorMsg *SQLSMALLINT) SQLRETURN { + cfHandleType, cfHandleTypeAllocMap := (C.SQLSMALLINT)(fHandleType), cgoAllocsUnknown + chandle, chandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(handle)), cgoAllocsUnknown + ciRecord, ciRecordAllocMap := (C.SQLSMALLINT)(iRecord), cgoAllocsUnknown + cszSqlState, cszSqlStateAllocMap := (*C.SQLWCHAR)(unsafe.Pointer(szSqlState)), cgoAllocsUnknown + cpfNativeError, cpfNativeErrorAllocMap := (*C.SQLINTEGER)(unsafe.Pointer(pfNativeError)), cgoAllocsUnknown + cszErrorMsg, cszErrorMsgAllocMap := (*C.SQLWCHAR)(unsafe.Pointer(szErrorMsg)), cgoAllocsUnknown + ccbErrorMsgMax, ccbErrorMsgMaxAllocMap := (C.SQLSMALLINT)(cbErrorMsgMax), cgoAllocsUnknown + cpcbErrorMsg, cpcbErrorMsgAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pcbErrorMsg)), cgoAllocsUnknown + __ret := C.SQLGetDiagRecW(cfHandleType, chandle, ciRecord, cszSqlState, cpfNativeError, cszErrorMsg, ccbErrorMsgMax, cpcbErrorMsg) + runtime.KeepAlive(cpcbErrorMsgAllocMap) + runtime.KeepAlive(ccbErrorMsgMaxAllocMap) + runtime.KeepAlive(cszErrorMsgAllocMap) + runtime.KeepAlive(cpfNativeErrorAllocMap) + runtime.KeepAlive(cszSqlStateAllocMap) + runtime.KeepAlive(ciRecordAllocMap) + runtime.KeepAlive(chandleAllocMap) + runtime.KeepAlive(cfHandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLPrepareW function as declared in include/sqlucode.h:150 +func SQLPrepareW(hstmt *SQLHSTMT, szSqlStr *SQLWCHAR, cbSqlStr SQLINTEGER) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszSqlStr, cszSqlStrAllocMap := (*C.SQLWCHAR)(unsafe.Pointer(szSqlStr)), cgoAllocsUnknown + ccbSqlStr, ccbSqlStrAllocMap := (C.SQLINTEGER)(cbSqlStr), cgoAllocsUnknown + __ret := C.SQLPrepareW(chstmt, cszSqlStr, ccbSqlStr) + runtime.KeepAlive(ccbSqlStrAllocMap) + runtime.KeepAlive(cszSqlStrAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetConnectAttrW function as declared in include/sqlucode.h:155 +func SQLSetConnectAttrW(hdbc *SQLHDBC, fAttribute SQLINTEGER, rgbValue *SQLPOINTER, cbValue SQLINTEGER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfAttribute, cfAttributeAllocMap := (C.SQLINTEGER)(fAttribute), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValue, ccbValueAllocMap := (C.SQLINTEGER)(cbValue), cgoAllocsUnknown + __ret := C.SQLSetConnectAttrW(chdbc, cfAttribute, crgbValue, ccbValue) + runtime.KeepAlive(ccbValueAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(cfAttributeAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetCursorNameW function as declared in include/sqlucode.h:161 +func SQLSetCursorNameW(hstmt *SQLHSTMT, szCursor []SQLWCHAR, cbCursor SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCursor, cszCursorAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCursor))) + ccbCursor, ccbCursorAllocMap := (C.SQLSMALLINT)(cbCursor), cgoAllocsUnknown + __ret := C.SQLSetCursorNameW(chstmt, cszCursor, ccbCursor) + runtime.KeepAlive(ccbCursorAllocMap) + runtime.KeepAlive(cszCursorAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColumnsW function as declared in include/sqlucode.h:172 +func SQLColumnsW(hstmt *SQLHSTMT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLWCHAR, cbTableName SQLSMALLINT, szColumnName []SQLWCHAR, cbColumnName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cszColumnName, cszColumnNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szColumnName))) + ccbColumnName, ccbColumnNameAllocMap := (C.SQLSMALLINT)(cbColumnName), cgoAllocsUnknown + __ret := C.SQLColumnsW(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cszColumnName, ccbColumnName) + runtime.KeepAlive(ccbColumnNameAllocMap) + runtime.KeepAlive(cszColumnNameAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetConnectOptionW function as declared in include/sqlucode.h:183 +func SQLGetConnectOptionW(hdbc *SQLHDBC, fOption SQLUSMALLINT, pvParam *SQLPOINTER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfOption, cfOptionAllocMap := (C.SQLUSMALLINT)(fOption), cgoAllocsUnknown + cpvParam, cpvParamAllocMap := (C.SQLPOINTER)(unsafe.Pointer(pvParam)), cgoAllocsUnknown + __ret := C.SQLGetConnectOptionW(chdbc, cfOption, cpvParam) + runtime.KeepAlive(cpvParamAllocMap) + runtime.KeepAlive(cfOptionAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetInfoW function as declared in include/sqlucode.h:190 +func SQLGetInfoW(hdbc *SQLHDBC, fInfoType SQLUSMALLINT, rgbInfoValue *SQLPOINTER, cbInfoValueMax SQLSMALLINT, pcbInfoValue []SQLSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfInfoType, cfInfoTypeAllocMap := (C.SQLUSMALLINT)(fInfoType), cgoAllocsUnknown + crgbInfoValue, crgbInfoValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbInfoValue)), cgoAllocsUnknown + ccbInfoValueMax, ccbInfoValueMaxAllocMap := (C.SQLSMALLINT)(cbInfoValueMax), cgoAllocsUnknown + cpcbInfoValue, cpcbInfoValueAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbInfoValue))) + __ret := C.SQLGetInfoW(chdbc, cfInfoType, crgbInfoValue, ccbInfoValueMax, cpcbInfoValue) + runtime.KeepAlive(cpcbInfoValueAllocMap) + runtime.KeepAlive(ccbInfoValueMaxAllocMap) + runtime.KeepAlive(crgbInfoValueAllocMap) + runtime.KeepAlive(cfInfoTypeAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetTypeInfoW function as declared in include/sqlucode.h:197 +func SQLGetTypeInfoW(statementHandle *SQLHSTMT, dataType SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cdataType, cdataTypeAllocMap := (C.SQLSMALLINT)(dataType), cgoAllocsUnknown + __ret := C.SQLGetTypeInfoW(cstatementHandle, cdataType) + runtime.KeepAlive(cdataTypeAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetConnectOptionW function as declared in include/sqlucode.h:202 +func SQLSetConnectOptionW(hdbc *SQLHDBC, fOption SQLUSMALLINT, vParam SQLULEN) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfOption, cfOptionAllocMap := (C.SQLUSMALLINT)(fOption), cgoAllocsUnknown + cvParam, cvParamAllocMap := (C.SQLULEN)(vParam), cgoAllocsUnknown + __ret := C.SQLSetConnectOptionW(chdbc, cfOption, cvParam) + runtime.KeepAlive(cvParamAllocMap) + runtime.KeepAlive(cfOptionAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSpecialColumnsW function as declared in include/sqlucode.h:208 +func SQLSpecialColumnsW(hstmt *SQLHSTMT, fColType SQLUSMALLINT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLWCHAR, cbTableName SQLSMALLINT, fScope SQLUSMALLINT, fNullable SQLUSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cfColType, cfColTypeAllocMap := (C.SQLUSMALLINT)(fColType), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cfScope, cfScopeAllocMap := (C.SQLUSMALLINT)(fScope), cgoAllocsUnknown + cfNullable, cfNullableAllocMap := (C.SQLUSMALLINT)(fNullable), cgoAllocsUnknown + __ret := C.SQLSpecialColumnsW(chstmt, cfColType, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cfScope, cfNullable) + runtime.KeepAlive(cfNullableAllocMap) + runtime.KeepAlive(cfScopeAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(cfColTypeAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLStatisticsW function as declared in include/sqlucode.h:220 +func SQLStatisticsW(hstmt *SQLHSTMT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLWCHAR, cbTableName SQLSMALLINT, fUnique SQLUSMALLINT, fAccuracy SQLUSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cfUnique, cfUniqueAllocMap := (C.SQLUSMALLINT)(fUnique), cgoAllocsUnknown + cfAccuracy, cfAccuracyAllocMap := (C.SQLUSMALLINT)(fAccuracy), cgoAllocsUnknown + __ret := C.SQLStatisticsW(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cfUnique, cfAccuracy) + runtime.KeepAlive(cfAccuracyAllocMap) + runtime.KeepAlive(cfUniqueAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLTablesW function as declared in include/sqlucode.h:231 +func SQLTablesW(hstmt *SQLHSTMT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLWCHAR, cbTableName SQLSMALLINT, szTableType []SQLWCHAR, cbTableType SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cszTableType, cszTableTypeAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableType))) + ccbTableType, ccbTableTypeAllocMap := (C.SQLSMALLINT)(cbTableType), cgoAllocsUnknown + __ret := C.SQLTablesW(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cszTableType, ccbTableType) + runtime.KeepAlive(ccbTableTypeAllocMap) + runtime.KeepAlive(cszTableTypeAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDataSourcesW function as declared in include/sqlucode.h:244 +func SQLDataSourcesW(henv *SQLHENV, fDirection SQLUSMALLINT, szDSN []SQLWCHAR, cbDSNMax SQLSMALLINT, pcbDSN []SQLSMALLINT, szDescription []SQLWCHAR, cbDescriptionMax SQLSMALLINT, pcbDescription []SQLSMALLINT) SQLRETURN { + chenv, chenvAllocMap := (C.SQLHENV)(unsafe.Pointer(henv)), cgoAllocsUnknown + cfDirection, cfDirectionAllocMap := (C.SQLUSMALLINT)(fDirection), cgoAllocsUnknown + cszDSN, cszDSNAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szDSN))) + ccbDSNMax, ccbDSNMaxAllocMap := (C.SQLSMALLINT)(cbDSNMax), cgoAllocsUnknown + cpcbDSN, cpcbDSNAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDSN))) + cszDescription, cszDescriptionAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szDescription))) + ccbDescriptionMax, ccbDescriptionMaxAllocMap := (C.SQLSMALLINT)(cbDescriptionMax), cgoAllocsUnknown + cpcbDescription, cpcbDescriptionAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDescription))) + __ret := C.SQLDataSourcesW(chenv, cfDirection, cszDSN, ccbDSNMax, cpcbDSN, cszDescription, ccbDescriptionMax, cpcbDescription) + runtime.KeepAlive(cpcbDescriptionAllocMap) + runtime.KeepAlive(ccbDescriptionMaxAllocMap) + runtime.KeepAlive(cszDescriptionAllocMap) + runtime.KeepAlive(cpcbDSNAllocMap) + runtime.KeepAlive(ccbDSNMaxAllocMap) + runtime.KeepAlive(cszDSNAllocMap) + runtime.KeepAlive(cfDirectionAllocMap) + runtime.KeepAlive(chenvAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDriverConnectW function as declared in include/sqlucode.h:257 +func SQLDriverConnectW(hdbc *SQLHDBC, hwnd *SQLHWND, szConnStrIn *SQLWCHAR, cbConnStrIn SQLSMALLINT, szConnStrOut *SQLWCHAR, cbConnStrOutMax SQLSMALLINT, pcbConnStrOut *SQLSMALLINT, fDriverCompletion SQLUSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + chwnd, chwndAllocMap := (C.SQLHWND)(unsafe.Pointer(hwnd)), cgoAllocsUnknown + cszConnStrIn, cszConnStrInAllocMap := (*C.SQLWCHAR)(unsafe.Pointer(szConnStrIn)), cgoAllocsUnknown + ccbConnStrIn, ccbConnStrInAllocMap := (C.SQLSMALLINT)(cbConnStrIn), cgoAllocsUnknown + cszConnStrOut, cszConnStrOutAllocMap := (*C.SQLWCHAR)(unsafe.Pointer(szConnStrOut)), cgoAllocsUnknown + ccbConnStrOutMax, ccbConnStrOutMaxAllocMap := (C.SQLSMALLINT)(cbConnStrOutMax), cgoAllocsUnknown + cpcbConnStrOut, cpcbConnStrOutAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pcbConnStrOut)), cgoAllocsUnknown + cfDriverCompletion, cfDriverCompletionAllocMap := (C.SQLUSMALLINT)(fDriverCompletion), cgoAllocsUnknown + __ret := C.SQLDriverConnectW(chdbc, chwnd, cszConnStrIn, ccbConnStrIn, cszConnStrOut, ccbConnStrOutMax, cpcbConnStrOut, cfDriverCompletion) + runtime.KeepAlive(cfDriverCompletionAllocMap) + runtime.KeepAlive(cpcbConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrOutMaxAllocMap) + runtime.KeepAlive(cszConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrInAllocMap) + runtime.KeepAlive(cszConnStrInAllocMap) + runtime.KeepAlive(chwndAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLBrowseConnectW function as declared in include/sqlucode.h:268 +func SQLBrowseConnectW(hdbc *SQLHDBC, szConnStrIn []SQLWCHAR, cbConnStrIn SQLSMALLINT, szConnStrOut []SQLWCHAR, cbConnStrOutMax SQLSMALLINT, pcbConnStrOut []SQLSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cszConnStrIn, cszConnStrInAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szConnStrIn))) + ccbConnStrIn, ccbConnStrInAllocMap := (C.SQLSMALLINT)(cbConnStrIn), cgoAllocsUnknown + cszConnStrOut, cszConnStrOutAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szConnStrOut))) + ccbConnStrOutMax, ccbConnStrOutMaxAllocMap := (C.SQLSMALLINT)(cbConnStrOutMax), cgoAllocsUnknown + cpcbConnStrOut, cpcbConnStrOutAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbConnStrOut))) + __ret := C.SQLBrowseConnectW(chdbc, cszConnStrIn, ccbConnStrIn, cszConnStrOut, ccbConnStrOutMax, cpcbConnStrOut) + runtime.KeepAlive(cpcbConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrOutMaxAllocMap) + runtime.KeepAlive(cszConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrInAllocMap) + runtime.KeepAlive(cszConnStrInAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColumnPrivilegesW function as declared in include/sqlucode.h:276 +func SQLColumnPrivilegesW(hstmt *SQLHSTMT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLWCHAR, cbTableName SQLSMALLINT, szColumnName []SQLWCHAR, cbColumnName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cszColumnName, cszColumnNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szColumnName))) + ccbColumnName, ccbColumnNameAllocMap := (C.SQLSMALLINT)(cbColumnName), cgoAllocsUnknown + __ret := C.SQLColumnPrivilegesW(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cszColumnName, ccbColumnName) + runtime.KeepAlive(ccbColumnNameAllocMap) + runtime.KeepAlive(cszColumnNameAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetStmtAttrW function as declared in include/sqlucode.h:287 +func SQLGetStmtAttrW(hstmt *SQLHSTMT, fAttribute SQLINTEGER, rgbValue *SQLPOINTER, cbValueMax SQLINTEGER, pcbValue []SQLINTEGER) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cfAttribute, cfAttributeAllocMap := (C.SQLINTEGER)(fAttribute), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValueMax, ccbValueMaxAllocMap := (C.SQLINTEGER)(cbValueMax), cgoAllocsUnknown + cpcbValue, cpcbValueAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pcbValue))) + __ret := C.SQLGetStmtAttrW(chstmt, cfAttribute, crgbValue, ccbValueMax, cpcbValue) + runtime.KeepAlive(cpcbValueAllocMap) + runtime.KeepAlive(ccbValueMaxAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(cfAttributeAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetStmtAttrW function as declared in include/sqlucode.h:294 +func SQLSetStmtAttrW(hstmt *SQLHSTMT, fAttribute SQLINTEGER, rgbValue *SQLPOINTER, cbValueMax SQLINTEGER) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cfAttribute, cfAttributeAllocMap := (C.SQLINTEGER)(fAttribute), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValueMax, ccbValueMaxAllocMap := (C.SQLINTEGER)(cbValueMax), cgoAllocsUnknown + __ret := C.SQLSetStmtAttrW(chstmt, cfAttribute, crgbValue, ccbValueMax) + runtime.KeepAlive(ccbValueMaxAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(cfAttributeAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLForeignKeysW function as declared in include/sqlucode.h:300 +func SQLForeignKeysW(hstmt *SQLHSTMT, szPkCatalogName []SQLWCHAR, cbPkCatalogName SQLSMALLINT, szPkSchemaName []SQLWCHAR, cbPkSchemaName SQLSMALLINT, szPkTableName []SQLWCHAR, cbPkTableName SQLSMALLINT, szFkCatalogName []SQLWCHAR, cbFkCatalogName SQLSMALLINT, szFkSchemaName []SQLWCHAR, cbFkSchemaName SQLSMALLINT, szFkTableName []SQLWCHAR, cbFkTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszPkCatalogName, cszPkCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkCatalogName))) + ccbPkCatalogName, ccbPkCatalogNameAllocMap := (C.SQLSMALLINT)(cbPkCatalogName), cgoAllocsUnknown + cszPkSchemaName, cszPkSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkSchemaName))) + ccbPkSchemaName, ccbPkSchemaNameAllocMap := (C.SQLSMALLINT)(cbPkSchemaName), cgoAllocsUnknown + cszPkTableName, cszPkTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkTableName))) + ccbPkTableName, ccbPkTableNameAllocMap := (C.SQLSMALLINT)(cbPkTableName), cgoAllocsUnknown + cszFkCatalogName, cszFkCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkCatalogName))) + ccbFkCatalogName, ccbFkCatalogNameAllocMap := (C.SQLSMALLINT)(cbFkCatalogName), cgoAllocsUnknown + cszFkSchemaName, cszFkSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkSchemaName))) + ccbFkSchemaName, ccbFkSchemaNameAllocMap := (C.SQLSMALLINT)(cbFkSchemaName), cgoAllocsUnknown + cszFkTableName, cszFkTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkTableName))) + ccbFkTableName, ccbFkTableNameAllocMap := (C.SQLSMALLINT)(cbFkTableName), cgoAllocsUnknown + __ret := C.SQLForeignKeysW(chstmt, cszPkCatalogName, ccbPkCatalogName, cszPkSchemaName, ccbPkSchemaName, cszPkTableName, ccbPkTableName, cszFkCatalogName, ccbFkCatalogName, cszFkSchemaName, ccbFkSchemaName, cszFkTableName, ccbFkTableName) + runtime.KeepAlive(ccbFkTableNameAllocMap) + runtime.KeepAlive(cszFkTableNameAllocMap) + runtime.KeepAlive(ccbFkSchemaNameAllocMap) + runtime.KeepAlive(cszFkSchemaNameAllocMap) + runtime.KeepAlive(ccbFkCatalogNameAllocMap) + runtime.KeepAlive(cszFkCatalogNameAllocMap) + runtime.KeepAlive(ccbPkTableNameAllocMap) + runtime.KeepAlive(cszPkTableNameAllocMap) + runtime.KeepAlive(ccbPkSchemaNameAllocMap) + runtime.KeepAlive(cszPkSchemaNameAllocMap) + runtime.KeepAlive(ccbPkCatalogNameAllocMap) + runtime.KeepAlive(cszPkCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLNativeSqlW function as declared in include/sqlucode.h:316 +func SQLNativeSqlW(hdbc *SQLHDBC, szSqlStrIn []SQLWCHAR, cbSqlStrIn SQLINTEGER, szSqlStr []SQLWCHAR, cbSqlStrMax SQLINTEGER, pcbSqlStr []SQLINTEGER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cszSqlStrIn, cszSqlStrInAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSqlStrIn))) + ccbSqlStrIn, ccbSqlStrInAllocMap := (C.SQLINTEGER)(cbSqlStrIn), cgoAllocsUnknown + cszSqlStr, cszSqlStrAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSqlStr))) + ccbSqlStrMax, ccbSqlStrMaxAllocMap := (C.SQLINTEGER)(cbSqlStrMax), cgoAllocsUnknown + cpcbSqlStr, cpcbSqlStrAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pcbSqlStr))) + __ret := C.SQLNativeSqlW(chdbc, cszSqlStrIn, ccbSqlStrIn, cszSqlStr, ccbSqlStrMax, cpcbSqlStr) + runtime.KeepAlive(cpcbSqlStrAllocMap) + runtime.KeepAlive(ccbSqlStrMaxAllocMap) + runtime.KeepAlive(cszSqlStrAllocMap) + runtime.KeepAlive(ccbSqlStrInAllocMap) + runtime.KeepAlive(cszSqlStrInAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLPrimaryKeysW function as declared in include/sqlucode.h:325 +func SQLPrimaryKeysW(hstmt *SQLHSTMT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLWCHAR, cbTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + __ret := C.SQLPrimaryKeysW(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLProcedureColumnsW function as declared in include/sqlucode.h:334 +func SQLProcedureColumnsW(hstmt *SQLHSTMT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szProcName []SQLWCHAR, cbProcName SQLSMALLINT, szColumnName []SQLWCHAR, cbColumnName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszProcName, cszProcNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szProcName))) + ccbProcName, ccbProcNameAllocMap := (C.SQLSMALLINT)(cbProcName), cgoAllocsUnknown + cszColumnName, cszColumnNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szColumnName))) + ccbColumnName, ccbColumnNameAllocMap := (C.SQLSMALLINT)(cbColumnName), cgoAllocsUnknown + __ret := C.SQLProcedureColumnsW(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszProcName, ccbProcName, cszColumnName, ccbColumnName) + runtime.KeepAlive(ccbColumnNameAllocMap) + runtime.KeepAlive(cszColumnNameAllocMap) + runtime.KeepAlive(ccbProcNameAllocMap) + runtime.KeepAlive(cszProcNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLProceduresW function as declared in include/sqlucode.h:345 +func SQLProceduresW(hstmt *SQLHSTMT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szProcName []SQLWCHAR, cbProcName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszProcName, cszProcNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szProcName))) + ccbProcName, ccbProcNameAllocMap := (C.SQLSMALLINT)(cbProcName), cgoAllocsUnknown + __ret := C.SQLProceduresW(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszProcName, ccbProcName) + runtime.KeepAlive(ccbProcNameAllocMap) + runtime.KeepAlive(cszProcNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLTablePrivilegesW function as declared in include/sqlucode.h:355 +func SQLTablePrivilegesW(hstmt *SQLHSTMT, szCatalogName []SQLWCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLWCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLWCHAR, cbTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + __ret := C.SQLTablePrivilegesW(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDriversW function as declared in include/sqlucode.h:364 +func SQLDriversW(henv *SQLHENV, fDirection SQLUSMALLINT, szDriverDesc []SQLWCHAR, cbDriverDescMax SQLSMALLINT, pcbDriverDesc []SQLSMALLINT, szDriverAttributes []SQLWCHAR, cbDrvrAttrMax SQLSMALLINT, pcbDrvrAttr []SQLSMALLINT) SQLRETURN { + chenv, chenvAllocMap := (C.SQLHENV)(unsafe.Pointer(henv)), cgoAllocsUnknown + cfDirection, cfDirectionAllocMap := (C.SQLUSMALLINT)(fDirection), cgoAllocsUnknown + cszDriverDesc, cszDriverDescAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szDriverDesc))) + ccbDriverDescMax, ccbDriverDescMaxAllocMap := (C.SQLSMALLINT)(cbDriverDescMax), cgoAllocsUnknown + cpcbDriverDesc, cpcbDriverDescAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDriverDesc))) + cszDriverAttributes, cszDriverAttributesAllocMap := copyPSQLWCHARBytes((*sliceHeader)(unsafe.Pointer(&szDriverAttributes))) + ccbDrvrAttrMax, ccbDrvrAttrMaxAllocMap := (C.SQLSMALLINT)(cbDrvrAttrMax), cgoAllocsUnknown + cpcbDrvrAttr, cpcbDrvrAttrAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDrvrAttr))) + __ret := C.SQLDriversW(chenv, cfDirection, cszDriverDesc, ccbDriverDescMax, cpcbDriverDesc, cszDriverAttributes, ccbDrvrAttrMax, cpcbDrvrAttr) + runtime.KeepAlive(cpcbDrvrAttrAllocMap) + runtime.KeepAlive(ccbDrvrAttrMaxAllocMap) + runtime.KeepAlive(cszDriverAttributesAllocMap) + runtime.KeepAlive(cpcbDriverDescAllocMap) + runtime.KeepAlive(ccbDriverDescMaxAllocMap) + runtime.KeepAlive(cszDriverDescAllocMap) + runtime.KeepAlive(cfDirectionAllocMap) + runtime.KeepAlive(chenvAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColAttributeA function as declared in include/sqlucode.h:377 +func SQLColAttributeA(hstmt *SQLHSTMT, iCol SQLSMALLINT, iField SQLSMALLINT, pCharAttr *SQLPOINTER, cbCharAttrMax SQLSMALLINT, pcbCharAttr []SQLSMALLINT, pNumAttr []SQLLEN) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + ciCol, ciColAllocMap := (C.SQLSMALLINT)(iCol), cgoAllocsUnknown + ciField, ciFieldAllocMap := (C.SQLSMALLINT)(iField), cgoAllocsUnknown + cpCharAttr, cpCharAttrAllocMap := (C.SQLPOINTER)(unsafe.Pointer(pCharAttr)), cgoAllocsUnknown + ccbCharAttrMax, ccbCharAttrMaxAllocMap := (C.SQLSMALLINT)(cbCharAttrMax), cgoAllocsUnknown + cpcbCharAttr, cpcbCharAttrAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbCharAttr))) + cpNumAttr, cpNumAttrAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&pNumAttr))) + __ret := C.SQLColAttributeA(chstmt, ciCol, ciField, cpCharAttr, ccbCharAttrMax, cpcbCharAttr, cpNumAttr) + runtime.KeepAlive(cpNumAttrAllocMap) + runtime.KeepAlive(cpcbCharAttrAllocMap) + runtime.KeepAlive(ccbCharAttrMaxAllocMap) + runtime.KeepAlive(cpCharAttrAllocMap) + runtime.KeepAlive(ciFieldAllocMap) + runtime.KeepAlive(ciColAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColAttributesA function as declared in include/sqlucode.h:386 +func SQLColAttributesA(hstmt *SQLHSTMT, icol SQLUSMALLINT, fDescType SQLUSMALLINT, rgbDesc *SQLPOINTER, cbDescMax SQLSMALLINT, pcbDesc []SQLSMALLINT, pfDesc []SQLLEN) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cicol, cicolAllocMap := (C.SQLUSMALLINT)(icol), cgoAllocsUnknown + cfDescType, cfDescTypeAllocMap := (C.SQLUSMALLINT)(fDescType), cgoAllocsUnknown + crgbDesc, crgbDescAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbDesc)), cgoAllocsUnknown + ccbDescMax, ccbDescMaxAllocMap := (C.SQLSMALLINT)(cbDescMax), cgoAllocsUnknown + cpcbDesc, cpcbDescAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDesc))) + cpfDesc, cpfDescAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&pfDesc))) + __ret := C.SQLColAttributesA(chstmt, cicol, cfDescType, crgbDesc, ccbDescMax, cpcbDesc, cpfDesc) + runtime.KeepAlive(cpfDescAllocMap) + runtime.KeepAlive(cpcbDescAllocMap) + runtime.KeepAlive(ccbDescMaxAllocMap) + runtime.KeepAlive(crgbDescAllocMap) + runtime.KeepAlive(cfDescTypeAllocMap) + runtime.KeepAlive(cicolAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLConnectA function as declared in include/sqlucode.h:395 +func SQLConnectA(hdbc *SQLHDBC, szDSN []SQLCHAR, cbDSN SQLSMALLINT, szUID []SQLCHAR, cbUID SQLSMALLINT, szAuthStr []SQLCHAR, cbAuthStr SQLSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cszDSN, cszDSNAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szDSN))) + ccbDSN, ccbDSNAllocMap := (C.SQLSMALLINT)(cbDSN), cgoAllocsUnknown + cszUID, cszUIDAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szUID))) + ccbUID, ccbUIDAllocMap := (C.SQLSMALLINT)(cbUID), cgoAllocsUnknown + cszAuthStr, cszAuthStrAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szAuthStr))) + ccbAuthStr, ccbAuthStrAllocMap := (C.SQLSMALLINT)(cbAuthStr), cgoAllocsUnknown + __ret := C.SQLConnectA(chdbc, cszDSN, ccbDSN, cszUID, ccbUID, cszAuthStr, ccbAuthStr) + runtime.KeepAlive(ccbAuthStrAllocMap) + runtime.KeepAlive(cszAuthStrAllocMap) + runtime.KeepAlive(ccbUIDAllocMap) + runtime.KeepAlive(cszUIDAllocMap) + runtime.KeepAlive(ccbDSNAllocMap) + runtime.KeepAlive(cszDSNAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDescribeColA function as declared in include/sqlucode.h:405 +func SQLDescribeColA(hstmt *SQLHSTMT, icol SQLUSMALLINT, szColName []SQLCHAR, cbColNameMax SQLSMALLINT, pcbColName []SQLSMALLINT, pfSqlType []SQLSMALLINT, pcbColDef []SQLULEN, pibScale []SQLSMALLINT, pfNullable []SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cicol, cicolAllocMap := (C.SQLUSMALLINT)(icol), cgoAllocsUnknown + cszColName, cszColNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szColName))) + ccbColNameMax, ccbColNameMaxAllocMap := (C.SQLSMALLINT)(cbColNameMax), cgoAllocsUnknown + cpcbColName, cpcbColNameAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbColName))) + cpfSqlType, cpfSqlTypeAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pfSqlType))) + cpcbColDef, cpcbColDefAllocMap := copyPSQLULENBytes((*sliceHeader)(unsafe.Pointer(&pcbColDef))) + cpibScale, cpibScaleAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pibScale))) + cpfNullable, cpfNullableAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pfNullable))) + __ret := C.SQLDescribeColA(chstmt, cicol, cszColName, ccbColNameMax, cpcbColName, cpfSqlType, cpcbColDef, cpibScale, cpfNullable) + runtime.KeepAlive(cpfNullableAllocMap) + runtime.KeepAlive(cpibScaleAllocMap) + runtime.KeepAlive(cpcbColDefAllocMap) + runtime.KeepAlive(cpfSqlTypeAllocMap) + runtime.KeepAlive(cpcbColNameAllocMap) + runtime.KeepAlive(ccbColNameMaxAllocMap) + runtime.KeepAlive(cszColNameAllocMap) + runtime.KeepAlive(cicolAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLErrorA function as declared in include/sqlucode.h:417 +func SQLErrorA(henv *SQLHENV, hdbc *SQLHDBC, hstmt *SQLHSTMT, szSqlState []SQLCHAR, pfNativeError []SQLINTEGER, szErrorMsg []SQLCHAR, cbErrorMsgMax SQLSMALLINT, pcbErrorMsg []SQLSMALLINT) SQLRETURN { + chenv, chenvAllocMap := (C.SQLHENV)(unsafe.Pointer(henv)), cgoAllocsUnknown + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszSqlState, cszSqlStateAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSqlState))) + cpfNativeError, cpfNativeErrorAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pfNativeError))) + cszErrorMsg, cszErrorMsgAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szErrorMsg))) + ccbErrorMsgMax, ccbErrorMsgMaxAllocMap := (C.SQLSMALLINT)(cbErrorMsgMax), cgoAllocsUnknown + cpcbErrorMsg, cpcbErrorMsgAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbErrorMsg))) + __ret := C.SQLErrorA(chenv, chdbc, chstmt, cszSqlState, cpfNativeError, cszErrorMsg, ccbErrorMsgMax, cpcbErrorMsg) + runtime.KeepAlive(cpcbErrorMsgAllocMap) + runtime.KeepAlive(ccbErrorMsgMaxAllocMap) + runtime.KeepAlive(cszErrorMsgAllocMap) + runtime.KeepAlive(cpfNativeErrorAllocMap) + runtime.KeepAlive(cszSqlStateAllocMap) + runtime.KeepAlive(chstmtAllocMap) + runtime.KeepAlive(chdbcAllocMap) + runtime.KeepAlive(chenvAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLExecDirectA function as declared in include/sqlucode.h:427 +func SQLExecDirectA(hstmt *SQLHSTMT, szSqlStr *SQLCHAR, cbSqlStr SQLINTEGER) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszSqlStr, cszSqlStrAllocMap := (*C.SQLCHAR)(unsafe.Pointer(szSqlStr)), cgoAllocsUnknown + ccbSqlStr, ccbSqlStrAllocMap := (C.SQLINTEGER)(cbSqlStr), cgoAllocsUnknown + __ret := C.SQLExecDirectA(chstmt, cszSqlStr, ccbSqlStr) + runtime.KeepAlive(ccbSqlStrAllocMap) + runtime.KeepAlive(cszSqlStrAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetConnectAttrA function as declared in include/sqlucode.h:432 +func SQLGetConnectAttrA(hdbc *SQLHDBC, fAttribute SQLINTEGER, rgbValue *SQLPOINTER, cbValueMax SQLINTEGER, pcbValue *SQLINTEGER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfAttribute, cfAttributeAllocMap := (C.SQLINTEGER)(fAttribute), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValueMax, ccbValueMaxAllocMap := (C.SQLINTEGER)(cbValueMax), cgoAllocsUnknown + cpcbValue, cpcbValueAllocMap := (*C.SQLINTEGER)(unsafe.Pointer(pcbValue)), cgoAllocsUnknown + __ret := C.SQLGetConnectAttrA(chdbc, cfAttribute, crgbValue, ccbValueMax, cpcbValue) + runtime.KeepAlive(cpcbValueAllocMap) + runtime.KeepAlive(ccbValueMaxAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(cfAttributeAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetCursorNameA function as declared in include/sqlucode.h:439 +func SQLGetCursorNameA(hstmt *SQLHSTMT, szCursor []SQLCHAR, cbCursorMax SQLSMALLINT, pcbCursor []SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCursor, cszCursorAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCursor))) + ccbCursorMax, ccbCursorMaxAllocMap := (C.SQLSMALLINT)(cbCursorMax), cgoAllocsUnknown + cpcbCursor, cpcbCursorAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbCursor))) + __ret := C.SQLGetCursorNameA(chstmt, cszCursor, ccbCursorMax, cpcbCursor) + runtime.KeepAlive(cpcbCursorAllocMap) + runtime.KeepAlive(ccbCursorMaxAllocMap) + runtime.KeepAlive(cszCursorAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDescFieldA function as declared in include/sqlucode.h:446 +func SQLGetDescFieldA(hdesc *SQLHDESC, iRecord SQLSMALLINT, iField SQLSMALLINT, rgbValue *SQLPOINTER, cbValueMax SQLINTEGER, pcbValue []SQLINTEGER) SQLRETURN { + chdesc, chdescAllocMap := (C.SQLHDESC)(unsafe.Pointer(hdesc)), cgoAllocsUnknown + ciRecord, ciRecordAllocMap := (C.SQLSMALLINT)(iRecord), cgoAllocsUnknown + ciField, ciFieldAllocMap := (C.SQLSMALLINT)(iField), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValueMax, ccbValueMaxAllocMap := (C.SQLINTEGER)(cbValueMax), cgoAllocsUnknown + cpcbValue, cpcbValueAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pcbValue))) + __ret := C.SQLGetDescFieldA(chdesc, ciRecord, ciField, crgbValue, ccbValueMax, cpcbValue) + runtime.KeepAlive(cpcbValueAllocMap) + runtime.KeepAlive(ccbValueMaxAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(ciFieldAllocMap) + runtime.KeepAlive(ciRecordAllocMap) + runtime.KeepAlive(chdescAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDescRecA function as declared in include/sqlucode.h:454 +func SQLGetDescRecA(hdesc *SQLHDESC, iRecord SQLSMALLINT, szName []SQLCHAR, cbNameMax SQLSMALLINT, pcbName []SQLSMALLINT, pfType []SQLSMALLINT, pfSubType []SQLSMALLINT, pLength []SQLLEN, pPrecision []SQLSMALLINT, pScale []SQLSMALLINT, pNullable []SQLSMALLINT) SQLRETURN { + chdesc, chdescAllocMap := (C.SQLHDESC)(unsafe.Pointer(hdesc)), cgoAllocsUnknown + ciRecord, ciRecordAllocMap := (C.SQLSMALLINT)(iRecord), cgoAllocsUnknown + cszName, cszNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szName))) + ccbNameMax, ccbNameMaxAllocMap := (C.SQLSMALLINT)(cbNameMax), cgoAllocsUnknown + cpcbName, cpcbNameAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbName))) + cpfType, cpfTypeAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pfType))) + cpfSubType, cpfSubTypeAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pfSubType))) + cpLength, cpLengthAllocMap := copyPSQLLENBytes((*sliceHeader)(unsafe.Pointer(&pLength))) + cpPrecision, cpPrecisionAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pPrecision))) + cpScale, cpScaleAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pScale))) + cpNullable, cpNullableAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pNullable))) + __ret := C.SQLGetDescRecA(chdesc, ciRecord, cszName, ccbNameMax, cpcbName, cpfType, cpfSubType, cpLength, cpPrecision, cpScale, cpNullable) + runtime.KeepAlive(cpNullableAllocMap) + runtime.KeepAlive(cpScaleAllocMap) + runtime.KeepAlive(cpPrecisionAllocMap) + runtime.KeepAlive(cpLengthAllocMap) + runtime.KeepAlive(cpfSubTypeAllocMap) + runtime.KeepAlive(cpfTypeAllocMap) + runtime.KeepAlive(cpcbNameAllocMap) + runtime.KeepAlive(ccbNameMaxAllocMap) + runtime.KeepAlive(cszNameAllocMap) + runtime.KeepAlive(ciRecordAllocMap) + runtime.KeepAlive(chdescAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDiagFieldA function as declared in include/sqlucode.h:467 +func SQLGetDiagFieldA(fHandleType SQLSMALLINT, handle *SQLHANDLE, iRecord SQLSMALLINT, fDiagField SQLSMALLINT, rgbDiagInfo *SQLPOINTER, cbDiagInfoMax SQLSMALLINT, pcbDiagInfo []SQLSMALLINT) SQLRETURN { + cfHandleType, cfHandleTypeAllocMap := (C.SQLSMALLINT)(fHandleType), cgoAllocsUnknown + chandle, chandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(handle)), cgoAllocsUnknown + ciRecord, ciRecordAllocMap := (C.SQLSMALLINT)(iRecord), cgoAllocsUnknown + cfDiagField, cfDiagFieldAllocMap := (C.SQLSMALLINT)(fDiagField), cgoAllocsUnknown + crgbDiagInfo, crgbDiagInfoAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbDiagInfo)), cgoAllocsUnknown + ccbDiagInfoMax, ccbDiagInfoMaxAllocMap := (C.SQLSMALLINT)(cbDiagInfoMax), cgoAllocsUnknown + cpcbDiagInfo, cpcbDiagInfoAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDiagInfo))) + __ret := C.SQLGetDiagFieldA(cfHandleType, chandle, ciRecord, cfDiagField, crgbDiagInfo, ccbDiagInfoMax, cpcbDiagInfo) + runtime.KeepAlive(cpcbDiagInfoAllocMap) + runtime.KeepAlive(ccbDiagInfoMaxAllocMap) + runtime.KeepAlive(crgbDiagInfoAllocMap) + runtime.KeepAlive(cfDiagFieldAllocMap) + runtime.KeepAlive(ciRecordAllocMap) + runtime.KeepAlive(chandleAllocMap) + runtime.KeepAlive(cfHandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetDiagRecA function as declared in include/sqlucode.h:476 +func SQLGetDiagRecA(fHandleType SQLSMALLINT, handle *SQLHANDLE, iRecord SQLSMALLINT, szSqlState *SQLCHAR, pfNativeError *SQLINTEGER, szErrorMsg *SQLCHAR, cbErrorMsgMax SQLSMALLINT, pcbErrorMsg *SQLSMALLINT) SQLRETURN { + cfHandleType, cfHandleTypeAllocMap := (C.SQLSMALLINT)(fHandleType), cgoAllocsUnknown + chandle, chandleAllocMap := (C.SQLHANDLE)(unsafe.Pointer(handle)), cgoAllocsUnknown + ciRecord, ciRecordAllocMap := (C.SQLSMALLINT)(iRecord), cgoAllocsUnknown + cszSqlState, cszSqlStateAllocMap := (*C.SQLCHAR)(unsafe.Pointer(szSqlState)), cgoAllocsUnknown + cpfNativeError, cpfNativeErrorAllocMap := (*C.SQLINTEGER)(unsafe.Pointer(pfNativeError)), cgoAllocsUnknown + cszErrorMsg, cszErrorMsgAllocMap := (*C.SQLCHAR)(unsafe.Pointer(szErrorMsg)), cgoAllocsUnknown + ccbErrorMsgMax, ccbErrorMsgMaxAllocMap := (C.SQLSMALLINT)(cbErrorMsgMax), cgoAllocsUnknown + cpcbErrorMsg, cpcbErrorMsgAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pcbErrorMsg)), cgoAllocsUnknown + __ret := C.SQLGetDiagRecA(cfHandleType, chandle, ciRecord, cszSqlState, cpfNativeError, cszErrorMsg, ccbErrorMsgMax, cpcbErrorMsg) + runtime.KeepAlive(cpcbErrorMsgAllocMap) + runtime.KeepAlive(ccbErrorMsgMaxAllocMap) + runtime.KeepAlive(cszErrorMsgAllocMap) + runtime.KeepAlive(cpfNativeErrorAllocMap) + runtime.KeepAlive(cszSqlStateAllocMap) + runtime.KeepAlive(ciRecordAllocMap) + runtime.KeepAlive(chandleAllocMap) + runtime.KeepAlive(cfHandleTypeAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetStmtAttrA function as declared in include/sqlucode.h:487 +func SQLGetStmtAttrA(hstmt *SQLHSTMT, fAttribute SQLINTEGER, rgbValue *SQLPOINTER, cbValueMax SQLINTEGER, pcbValue []SQLINTEGER) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cfAttribute, cfAttributeAllocMap := (C.SQLINTEGER)(fAttribute), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValueMax, ccbValueMaxAllocMap := (C.SQLINTEGER)(cbValueMax), cgoAllocsUnknown + cpcbValue, cpcbValueAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pcbValue))) + __ret := C.SQLGetStmtAttrA(chstmt, cfAttribute, crgbValue, ccbValueMax, cpcbValue) + runtime.KeepAlive(cpcbValueAllocMap) + runtime.KeepAlive(ccbValueMaxAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(cfAttributeAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetTypeInfoA function as declared in include/sqlucode.h:496 +func SQLGetTypeInfoA(statementHandle *SQLHSTMT, dataTyoe SQLSMALLINT) SQLRETURN { + cstatementHandle, cstatementHandleAllocMap := (C.SQLHSTMT)(unsafe.Pointer(statementHandle)), cgoAllocsUnknown + cdataTyoe, cdataTyoeAllocMap := (C.SQLSMALLINT)(dataTyoe), cgoAllocsUnknown + __ret := C.SQLGetTypeInfoA(cstatementHandle, cdataTyoe) + runtime.KeepAlive(cdataTyoeAllocMap) + runtime.KeepAlive(cstatementHandleAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLPrepareA function as declared in include/sqlucode.h:500 +func SQLPrepareA(hstmt *SQLHSTMT, szSqlStr *SQLCHAR, cbSqlStr SQLINTEGER) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszSqlStr, cszSqlStrAllocMap := (*C.SQLCHAR)(unsafe.Pointer(szSqlStr)), cgoAllocsUnknown + ccbSqlStr, ccbSqlStrAllocMap := (C.SQLINTEGER)(cbSqlStr), cgoAllocsUnknown + __ret := C.SQLPrepareA(chstmt, cszSqlStr, ccbSqlStr) + runtime.KeepAlive(ccbSqlStrAllocMap) + runtime.KeepAlive(cszSqlStrAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetConnectAttrA function as declared in include/sqlucode.h:505 +func SQLSetConnectAttrA(hdbc *SQLHDBC, fAttribute SQLINTEGER, rgbValue *SQLPOINTER, cbValue SQLINTEGER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfAttribute, cfAttributeAllocMap := (C.SQLINTEGER)(fAttribute), cgoAllocsUnknown + crgbValue, crgbValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbValue)), cgoAllocsUnknown + ccbValue, ccbValueAllocMap := (C.SQLINTEGER)(cbValue), cgoAllocsUnknown + __ret := C.SQLSetConnectAttrA(chdbc, cfAttribute, crgbValue, ccbValue) + runtime.KeepAlive(ccbValueAllocMap) + runtime.KeepAlive(crgbValueAllocMap) + runtime.KeepAlive(cfAttributeAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetCursorNameA function as declared in include/sqlucode.h:511 +func SQLSetCursorNameA(hstmt *SQLHSTMT, szCursor []SQLCHAR, cbCursor SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCursor, cszCursorAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCursor))) + ccbCursor, ccbCursorAllocMap := (C.SQLSMALLINT)(cbCursor), cgoAllocsUnknown + __ret := C.SQLSetCursorNameA(chstmt, cszCursor, ccbCursor) + runtime.KeepAlive(ccbCursorAllocMap) + runtime.KeepAlive(cszCursorAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColumnsA function as declared in include/sqlucode.h:522 +func SQLColumnsA(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT, szColumnName []SQLCHAR, cbColumnName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cszColumnName, cszColumnNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szColumnName))) + ccbColumnName, ccbColumnNameAllocMap := (C.SQLSMALLINT)(cbColumnName), cgoAllocsUnknown + __ret := C.SQLColumnsA(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cszColumnName, ccbColumnName) + runtime.KeepAlive(ccbColumnNameAllocMap) + runtime.KeepAlive(cszColumnNameAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetConnectOptionA function as declared in include/sqlucode.h:533 +func SQLGetConnectOptionA(hdbc *SQLHDBC, fOption SQLUSMALLINT, pvParam *SQLPOINTER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfOption, cfOptionAllocMap := (C.SQLUSMALLINT)(fOption), cgoAllocsUnknown + cpvParam, cpvParamAllocMap := (C.SQLPOINTER)(unsafe.Pointer(pvParam)), cgoAllocsUnknown + __ret := C.SQLGetConnectOptionA(chdbc, cfOption, cpvParam) + runtime.KeepAlive(cpvParamAllocMap) + runtime.KeepAlive(cfOptionAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLGetInfoA function as declared in include/sqlucode.h:540 +func SQLGetInfoA(hdbc *SQLHDBC, fInfoType SQLUSMALLINT, rgbInfoValue *SQLPOINTER, cbInfoValueMax SQLSMALLINT, pcbInfoValue []SQLSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfInfoType, cfInfoTypeAllocMap := (C.SQLUSMALLINT)(fInfoType), cgoAllocsUnknown + crgbInfoValue, crgbInfoValueAllocMap := (C.SQLPOINTER)(unsafe.Pointer(rgbInfoValue)), cgoAllocsUnknown + ccbInfoValueMax, ccbInfoValueMaxAllocMap := (C.SQLSMALLINT)(cbInfoValueMax), cgoAllocsUnknown + cpcbInfoValue, cpcbInfoValueAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbInfoValue))) + __ret := C.SQLGetInfoA(chdbc, cfInfoType, crgbInfoValue, ccbInfoValueMax, cpcbInfoValue) + runtime.KeepAlive(cpcbInfoValueAllocMap) + runtime.KeepAlive(ccbInfoValueMaxAllocMap) + runtime.KeepAlive(crgbInfoValueAllocMap) + runtime.KeepAlive(cfInfoTypeAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetConnectOptionA function as declared in include/sqlucode.h:552 +func SQLSetConnectOptionA(hdbc *SQLHDBC, fOption SQLUSMALLINT, vParam SQLULEN) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cfOption, cfOptionAllocMap := (C.SQLUSMALLINT)(fOption), cgoAllocsUnknown + cvParam, cvParamAllocMap := (C.SQLULEN)(vParam), cgoAllocsUnknown + __ret := C.SQLSetConnectOptionA(chdbc, cfOption, cvParam) + runtime.KeepAlive(cvParamAllocMap) + runtime.KeepAlive(cfOptionAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSetStmtOptionA function as declared in include/sqlucode.h:557 +func SQLSetStmtOptionA(hstmt *SQLHSTMT, fOption SQLUSMALLINT, vParam SQLULEN) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cfOption, cfOptionAllocMap := (C.SQLUSMALLINT)(fOption), cgoAllocsUnknown + cvParam, cvParamAllocMap := (C.SQLULEN)(vParam), cgoAllocsUnknown + __ret := C.SQLSetStmtOptionA(chstmt, cfOption, cvParam) + runtime.KeepAlive(cvParamAllocMap) + runtime.KeepAlive(cfOptionAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLSpecialColumnsA function as declared in include/sqlucode.h:562 +func SQLSpecialColumnsA(hstmt *SQLHSTMT, fColType SQLUSMALLINT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT, fScope SQLUSMALLINT, fNullable SQLUSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cfColType, cfColTypeAllocMap := (C.SQLUSMALLINT)(fColType), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cfScope, cfScopeAllocMap := (C.SQLUSMALLINT)(fScope), cgoAllocsUnknown + cfNullable, cfNullableAllocMap := (C.SQLUSMALLINT)(fNullable), cgoAllocsUnknown + __ret := C.SQLSpecialColumnsA(chstmt, cfColType, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cfScope, cfNullable) + runtime.KeepAlive(cfNullableAllocMap) + runtime.KeepAlive(cfScopeAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(cfColTypeAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLStatisticsA function as declared in include/sqlucode.h:574 +func SQLStatisticsA(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT, fUnique SQLUSMALLINT, fAccuracy SQLUSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cfUnique, cfUniqueAllocMap := (C.SQLUSMALLINT)(fUnique), cgoAllocsUnknown + cfAccuracy, cfAccuracyAllocMap := (C.SQLUSMALLINT)(fAccuracy), cgoAllocsUnknown + __ret := C.SQLStatisticsA(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cfUnique, cfAccuracy) + runtime.KeepAlive(cfAccuracyAllocMap) + runtime.KeepAlive(cfUniqueAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLTablesA function as declared in include/sqlucode.h:586 +func SQLTablesA(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT, szTableType []SQLCHAR, cbTableType SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cszTableType, cszTableTypeAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableType))) + ccbTableType, ccbTableTypeAllocMap := (C.SQLSMALLINT)(cbTableType), cgoAllocsUnknown + __ret := C.SQLTablesA(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cszTableType, ccbTableType) + runtime.KeepAlive(ccbTableTypeAllocMap) + runtime.KeepAlive(cszTableTypeAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDataSourcesA function as declared in include/sqlucode.h:601 +func SQLDataSourcesA(henv *SQLHENV, fDirection SQLUSMALLINT, szDSN []SQLCHAR, cbDSNMax SQLSMALLINT, pcbDSN []SQLSMALLINT, szDescription []SQLCHAR, cbDescriptionMax SQLSMALLINT, pcbDescription []SQLSMALLINT) SQLRETURN { + chenv, chenvAllocMap := (C.SQLHENV)(unsafe.Pointer(henv)), cgoAllocsUnknown + cfDirection, cfDirectionAllocMap := (C.SQLUSMALLINT)(fDirection), cgoAllocsUnknown + cszDSN, cszDSNAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szDSN))) + ccbDSNMax, ccbDSNMaxAllocMap := (C.SQLSMALLINT)(cbDSNMax), cgoAllocsUnknown + cpcbDSN, cpcbDSNAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDSN))) + cszDescription, cszDescriptionAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szDescription))) + ccbDescriptionMax, ccbDescriptionMaxAllocMap := (C.SQLSMALLINT)(cbDescriptionMax), cgoAllocsUnknown + cpcbDescription, cpcbDescriptionAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDescription))) + __ret := C.SQLDataSourcesA(chenv, cfDirection, cszDSN, ccbDSNMax, cpcbDSN, cszDescription, ccbDescriptionMax, cpcbDescription) + runtime.KeepAlive(cpcbDescriptionAllocMap) + runtime.KeepAlive(ccbDescriptionMaxAllocMap) + runtime.KeepAlive(cszDescriptionAllocMap) + runtime.KeepAlive(cpcbDSNAllocMap) + runtime.KeepAlive(ccbDSNMaxAllocMap) + runtime.KeepAlive(cszDSNAllocMap) + runtime.KeepAlive(cfDirectionAllocMap) + runtime.KeepAlive(chenvAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDriverConnectA function as declared in include/sqlucode.h:614 +func SQLDriverConnectA(hdbc *SQLHDBC, hwnd *SQLHWND, szConnStrIn *SQLCHAR, cbConnStrIn SQLSMALLINT, szConnStrOut *SQLCHAR, cbConnStrOutMax SQLSMALLINT, pcbConnStrOut *SQLSMALLINT, fDriverCompletion SQLUSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + chwnd, chwndAllocMap := (C.SQLHWND)(unsafe.Pointer(hwnd)), cgoAllocsUnknown + cszConnStrIn, cszConnStrInAllocMap := (*C.SQLCHAR)(unsafe.Pointer(szConnStrIn)), cgoAllocsUnknown + ccbConnStrIn, ccbConnStrInAllocMap := (C.SQLSMALLINT)(cbConnStrIn), cgoAllocsUnknown + cszConnStrOut, cszConnStrOutAllocMap := (*C.SQLCHAR)(unsafe.Pointer(szConnStrOut)), cgoAllocsUnknown + ccbConnStrOutMax, ccbConnStrOutMaxAllocMap := (C.SQLSMALLINT)(cbConnStrOutMax), cgoAllocsUnknown + cpcbConnStrOut, cpcbConnStrOutAllocMap := (*C.SQLSMALLINT)(unsafe.Pointer(pcbConnStrOut)), cgoAllocsUnknown + cfDriverCompletion, cfDriverCompletionAllocMap := (C.SQLUSMALLINT)(fDriverCompletion), cgoAllocsUnknown + __ret := C.SQLDriverConnectA(chdbc, chwnd, cszConnStrIn, ccbConnStrIn, cszConnStrOut, ccbConnStrOutMax, cpcbConnStrOut, cfDriverCompletion) + runtime.KeepAlive(cfDriverCompletionAllocMap) + runtime.KeepAlive(cpcbConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrOutMaxAllocMap) + runtime.KeepAlive(cszConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrInAllocMap) + runtime.KeepAlive(cszConnStrInAllocMap) + runtime.KeepAlive(chwndAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLBrowseConnectA function as declared in include/sqlucode.h:625 +func SQLBrowseConnectA(hdbc *SQLHDBC, szConnStrIn []SQLCHAR, cbConnStrIn SQLSMALLINT, szConnStrOut []SQLCHAR, cbConnStrOutMax SQLSMALLINT, pcbConnStrOut []SQLSMALLINT) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cszConnStrIn, cszConnStrInAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szConnStrIn))) + ccbConnStrIn, ccbConnStrInAllocMap := (C.SQLSMALLINT)(cbConnStrIn), cgoAllocsUnknown + cszConnStrOut, cszConnStrOutAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szConnStrOut))) + ccbConnStrOutMax, ccbConnStrOutMaxAllocMap := (C.SQLSMALLINT)(cbConnStrOutMax), cgoAllocsUnknown + cpcbConnStrOut, cpcbConnStrOutAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbConnStrOut))) + __ret := C.SQLBrowseConnectA(chdbc, cszConnStrIn, ccbConnStrIn, cszConnStrOut, ccbConnStrOutMax, cpcbConnStrOut) + runtime.KeepAlive(cpcbConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrOutMaxAllocMap) + runtime.KeepAlive(cszConnStrOutAllocMap) + runtime.KeepAlive(ccbConnStrInAllocMap) + runtime.KeepAlive(cszConnStrInAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLColumnPrivilegesA function as declared in include/sqlucode.h:633 +func SQLColumnPrivilegesA(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT, szColumnName []SQLCHAR, cbColumnName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + cszColumnName, cszColumnNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szColumnName))) + ccbColumnName, ccbColumnNameAllocMap := (C.SQLSMALLINT)(cbColumnName), cgoAllocsUnknown + __ret := C.SQLColumnPrivilegesA(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName, cszColumnName, ccbColumnName) + runtime.KeepAlive(ccbColumnNameAllocMap) + runtime.KeepAlive(cszColumnNameAllocMap) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLForeignKeysA function as declared in include/sqlucode.h:653 +func SQLForeignKeysA(hstmt *SQLHSTMT, szPkCatalogName []SQLCHAR, cbPkCatalogName SQLSMALLINT, szPkSchemaName []SQLCHAR, cbPkSchemaName SQLSMALLINT, szPkTableName []SQLCHAR, cbPkTableName SQLSMALLINT, szFkCatalogName []SQLCHAR, cbFkCatalogName SQLSMALLINT, szFkSchemaName []SQLCHAR, cbFkSchemaName SQLSMALLINT, szFkTableName []SQLCHAR, cbFkTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszPkCatalogName, cszPkCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkCatalogName))) + ccbPkCatalogName, ccbPkCatalogNameAllocMap := (C.SQLSMALLINT)(cbPkCatalogName), cgoAllocsUnknown + cszPkSchemaName, cszPkSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkSchemaName))) + ccbPkSchemaName, ccbPkSchemaNameAllocMap := (C.SQLSMALLINT)(cbPkSchemaName), cgoAllocsUnknown + cszPkTableName, cszPkTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szPkTableName))) + ccbPkTableName, ccbPkTableNameAllocMap := (C.SQLSMALLINT)(cbPkTableName), cgoAllocsUnknown + cszFkCatalogName, cszFkCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkCatalogName))) + ccbFkCatalogName, ccbFkCatalogNameAllocMap := (C.SQLSMALLINT)(cbFkCatalogName), cgoAllocsUnknown + cszFkSchemaName, cszFkSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkSchemaName))) + ccbFkSchemaName, ccbFkSchemaNameAllocMap := (C.SQLSMALLINT)(cbFkSchemaName), cgoAllocsUnknown + cszFkTableName, cszFkTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szFkTableName))) + ccbFkTableName, ccbFkTableNameAllocMap := (C.SQLSMALLINT)(cbFkTableName), cgoAllocsUnknown + __ret := C.SQLForeignKeysA(chstmt, cszPkCatalogName, ccbPkCatalogName, cszPkSchemaName, ccbPkSchemaName, cszPkTableName, ccbPkTableName, cszFkCatalogName, ccbFkCatalogName, cszFkSchemaName, ccbFkSchemaName, cszFkTableName, ccbFkTableName) + runtime.KeepAlive(ccbFkTableNameAllocMap) + runtime.KeepAlive(cszFkTableNameAllocMap) + runtime.KeepAlive(ccbFkSchemaNameAllocMap) + runtime.KeepAlive(cszFkSchemaNameAllocMap) + runtime.KeepAlive(ccbFkCatalogNameAllocMap) + runtime.KeepAlive(cszFkCatalogNameAllocMap) + runtime.KeepAlive(ccbPkTableNameAllocMap) + runtime.KeepAlive(cszPkTableNameAllocMap) + runtime.KeepAlive(ccbPkSchemaNameAllocMap) + runtime.KeepAlive(cszPkSchemaNameAllocMap) + runtime.KeepAlive(ccbPkCatalogNameAllocMap) + runtime.KeepAlive(cszPkCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLNativeSqlA function as declared in include/sqlucode.h:669 +func SQLNativeSqlA(hdbc *SQLHDBC, szSqlStrIn []SQLCHAR, cbSqlStrIn SQLINTEGER, szSqlStr []SQLCHAR, cbSqlStrMax SQLINTEGER, pcbSqlStr []SQLINTEGER) SQLRETURN { + chdbc, chdbcAllocMap := (C.SQLHDBC)(unsafe.Pointer(hdbc)), cgoAllocsUnknown + cszSqlStrIn, cszSqlStrInAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSqlStrIn))) + ccbSqlStrIn, ccbSqlStrInAllocMap := (C.SQLINTEGER)(cbSqlStrIn), cgoAllocsUnknown + cszSqlStr, cszSqlStrAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSqlStr))) + ccbSqlStrMax, ccbSqlStrMaxAllocMap := (C.SQLINTEGER)(cbSqlStrMax), cgoAllocsUnknown + cpcbSqlStr, cpcbSqlStrAllocMap := copyPSQLINTEGERBytes((*sliceHeader)(unsafe.Pointer(&pcbSqlStr))) + __ret := C.SQLNativeSqlA(chdbc, cszSqlStrIn, ccbSqlStrIn, cszSqlStr, ccbSqlStrMax, cpcbSqlStr) + runtime.KeepAlive(cpcbSqlStrAllocMap) + runtime.KeepAlive(ccbSqlStrMaxAllocMap) + runtime.KeepAlive(cszSqlStrAllocMap) + runtime.KeepAlive(ccbSqlStrInAllocMap) + runtime.KeepAlive(cszSqlStrInAllocMap) + runtime.KeepAlive(chdbcAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLPrimaryKeysA function as declared in include/sqlucode.h:678 +func SQLPrimaryKeysA(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + __ret := C.SQLPrimaryKeysA(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLProcedureColumnsA function as declared in include/sqlucode.h:687 +func SQLProcedureColumnsA(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szProcName []SQLCHAR, cbProcName SQLSMALLINT, szColumnName []SQLCHAR, cbColumnName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszProcName, cszProcNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szProcName))) + ccbProcName, ccbProcNameAllocMap := (C.SQLSMALLINT)(cbProcName), cgoAllocsUnknown + cszColumnName, cszColumnNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szColumnName))) + ccbColumnName, ccbColumnNameAllocMap := (C.SQLSMALLINT)(cbColumnName), cgoAllocsUnknown + __ret := C.SQLProcedureColumnsA(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszProcName, ccbProcName, cszColumnName, ccbColumnName) + runtime.KeepAlive(ccbColumnNameAllocMap) + runtime.KeepAlive(cszColumnNameAllocMap) + runtime.KeepAlive(ccbProcNameAllocMap) + runtime.KeepAlive(cszProcNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLProceduresA function as declared in include/sqlucode.h:698 +func SQLProceduresA(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szProcName []SQLCHAR, cbProcName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszProcName, cszProcNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szProcName))) + ccbProcName, ccbProcNameAllocMap := (C.SQLSMALLINT)(cbProcName), cgoAllocsUnknown + __ret := C.SQLProceduresA(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszProcName, ccbProcName) + runtime.KeepAlive(ccbProcNameAllocMap) + runtime.KeepAlive(cszProcNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLTablePrivilegesA function as declared in include/sqlucode.h:708 +func SQLTablePrivilegesA(hstmt *SQLHSTMT, szCatalogName []SQLCHAR, cbCatalogName SQLSMALLINT, szSchemaName []SQLCHAR, cbSchemaName SQLSMALLINT, szTableName []SQLCHAR, cbTableName SQLSMALLINT) SQLRETURN { + chstmt, chstmtAllocMap := (C.SQLHSTMT)(unsafe.Pointer(hstmt)), cgoAllocsUnknown + cszCatalogName, cszCatalogNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szCatalogName))) + ccbCatalogName, ccbCatalogNameAllocMap := (C.SQLSMALLINT)(cbCatalogName), cgoAllocsUnknown + cszSchemaName, cszSchemaNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szSchemaName))) + ccbSchemaName, ccbSchemaNameAllocMap := (C.SQLSMALLINT)(cbSchemaName), cgoAllocsUnknown + cszTableName, cszTableNameAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szTableName))) + ccbTableName, ccbTableNameAllocMap := (C.SQLSMALLINT)(cbTableName), cgoAllocsUnknown + __ret := C.SQLTablePrivilegesA(chstmt, cszCatalogName, ccbCatalogName, cszSchemaName, ccbSchemaName, cszTableName, ccbTableName) + runtime.KeepAlive(ccbTableNameAllocMap) + runtime.KeepAlive(cszTableNameAllocMap) + runtime.KeepAlive(ccbSchemaNameAllocMap) + runtime.KeepAlive(cszSchemaNameAllocMap) + runtime.KeepAlive(ccbCatalogNameAllocMap) + runtime.KeepAlive(cszCatalogNameAllocMap) + runtime.KeepAlive(chstmtAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} + +// SQLDriversA function as declared in include/sqlucode.h:717 +func SQLDriversA(henv *SQLHENV, fDirection SQLUSMALLINT, szDriverDesc []SQLCHAR, cbDriverDescMax SQLSMALLINT, pcbDriverDesc []SQLSMALLINT, szDriverAttributes []SQLCHAR, cbDrvrAttrMax SQLSMALLINT, pcbDrvrAttr []SQLSMALLINT) SQLRETURN { + chenv, chenvAllocMap := (C.SQLHENV)(unsafe.Pointer(henv)), cgoAllocsUnknown + cfDirection, cfDirectionAllocMap := (C.SQLUSMALLINT)(fDirection), cgoAllocsUnknown + cszDriverDesc, cszDriverDescAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szDriverDesc))) + ccbDriverDescMax, ccbDriverDescMaxAllocMap := (C.SQLSMALLINT)(cbDriverDescMax), cgoAllocsUnknown + cpcbDriverDesc, cpcbDriverDescAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDriverDesc))) + cszDriverAttributes, cszDriverAttributesAllocMap := copyPSQLCHARBytes((*sliceHeader)(unsafe.Pointer(&szDriverAttributes))) + ccbDrvrAttrMax, ccbDrvrAttrMaxAllocMap := (C.SQLSMALLINT)(cbDrvrAttrMax), cgoAllocsUnknown + cpcbDrvrAttr, cpcbDrvrAttrAllocMap := copyPSQLSMALLINTBytes((*sliceHeader)(unsafe.Pointer(&pcbDrvrAttr))) + __ret := C.SQLDriversA(chenv, cfDirection, cszDriverDesc, ccbDriverDescMax, cpcbDriverDesc, cszDriverAttributes, ccbDrvrAttrMax, cpcbDrvrAttr) + runtime.KeepAlive(cpcbDrvrAttrAllocMap) + runtime.KeepAlive(ccbDrvrAttrMaxAllocMap) + runtime.KeepAlive(cszDriverAttributesAllocMap) + runtime.KeepAlive(cpcbDriverDescAllocMap) + runtime.KeepAlive(ccbDriverDescMaxAllocMap) + runtime.KeepAlive(cszDriverDescAllocMap) + runtime.KeepAlive(cfDirectionAllocMap) + runtime.KeepAlive(chenvAllocMap) + __v := (SQLRETURN)(__ret) + return __v +} diff --git a/internal/api/api.yml b/internal/api/api.yml index c447ded..a232cb2 100644 --- a/internal/api/api.yml +++ b/internal/api/api.yml @@ -29,28 +29,30 @@ TRANSLATOR: enum: expand PtrTips: function: -# - { target: ^SQLBindParameter$, tips: [ref,0,0,0,0,0,0,ref,size,ref] } -# - { target: ^SQLDescribeCol$, tips: [ref,0,ref,size,ref,ref,ref,ref,ref] } -# - { target: ^SQLDescribeParam$, tips: [ref,0,ref,ref,ref,ref] } -# - { target: ^SQLDriverConnect, tips: [ref,ref,ref,size, ref,size,ref,0] } -# - { target: ^SQLPrepare, tips: [ref,ref,size] } -# - { target: ^SQLNumParams$, tips: [ref,ref] } -# - { target: ^SQLGetData, tips: [ref,0,0,ref,size,ref] } -# - { target: ^SQLNumResultCols$, tips: [ref,ref] } -# - { target: ^SQLGetConnectAttr, tips: [ref,0,ref,size,ref] } -# - { target: ^SQLAllocHandle, tips: [0,ref,ref] } -# - { target: ^SQLGetDiagRec, tips: [0,ref,0,ref,ref,ref,size,ref] } -# - { target: ^SQLSetEnvAttr, tips: [ref,0,0,size] } + - { target: ^SQLBindParameter$, tips: [ref,0,0,0,0,0,0,ref,size,ref] } + - { target: ^SQLDescribeCol$, tips: [ref,0,ref,size,ref,ref,ref,ref,ref] } + - { target: ^SQLDescribeColW$, tips: [ref,0,ref,size,ref,ref,ref,ref,ref] } + - { target: ^SQLDescribeParam$, tips: [ref,0,ref,ref,ref,ref] } + - { target: ^SQLDriverConnect, tips: [ref,ref,ref,size, ref,size,ref,0] } + - { target: ^SQLExecDirect, tips: [ref,ref,size] } + - { target: ^SQLPrepare, tips: [ref,ref,size] } + - { target: ^SQLNumParams$, tips: [ref,ref] } + - { target: ^SQLGetData, tips: [ref,0,0,ref,size,ref] } + - { target: ^SQLNumResultCols$, tips: [ref,ref] } + - { target: ^SQLGetConnectAttr, tips: [ref,0,ref,size,ref] } + - { target: ^SQLAllocHandle, tips: [0,ref,ref] } + - { target: ^SQLGetDiagRec, tips: [0,ref,0,ref,ref,ref,size,ref] } + - { target: ^SQLSetEnvAttr, tips: [ref,0,0,size] } TypeTips: MemTips: # - { target: SQL_DATE_STRUCT, self: raw } Rules: global: - - { action: ignore, from: ^SQL } -# - { action: ignore, from: ^SQLDescribeParamA } -# - { action: ignore, from: ^SQLGetStmtOptionA } -# - { transform: unexport } + - { action: accept, from: ^SQL } + - { action: ignore, from: ^SQLDescribeParamA } + - { action: ignore, from: ^SQLGetStmtOptionA } + - { transform: export } type: - {action: accept, from: ^SQL } - {transform: export } diff --git a/internal/api/cgo_helpers.go b/internal/api/cgo_helpers.go index bb58214..1f7f837 100644 --- a/internal/api/cgo_helpers.go +++ b/internal/api/cgo_helpers.go @@ -1,6 +1,6 @@ // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. -// WARNING: This file has automatically been generated on Tue, 10 Oct 2023 12:49:57 MDT. +// WARNING: This file has automatically been generated on Wed, 22 May 2024 15:11:09 MDT. // Code generated by https://git.io/c-for-go. DO NOT EDIT. package api @@ -17,6 +17,7 @@ package api import "C" import ( "fmt" + "runtime" "sync" "unsafe" ) @@ -828,3 +829,328 @@ func (x *SQLGUID) Deref() { x.Data3 = (uint16)(x.refe93ebf54.Data3) x.Data4 = *(*[8]byte)(unsafe.Pointer(&x.refe93ebf54.Data4)) } + +type sliceHeader struct { + Data unsafe.Pointer + Len int + Cap int +} + +// copyPSQLHDBCBytes copies the data from Go slice as *C.SQLHDBC. +func copyPSQLHDBCBytes(slice *sliceHeader) (*C.SQLHDBC, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLHDBCValue) * slice.Len, + Cap: int(sizeOfSQLHDBCValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLHDBC)(mem0), allocs +} + +// allocSQLHDBCMemory allocates memory for type C.SQLHDBC in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLHDBCMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLHDBCValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLHDBCValue = unsafe.Sizeof([1]C.SQLHDBC{}) + +// copyPSQLHENVBytes copies the data from Go slice as *C.SQLHENV. +func copyPSQLHENVBytes(slice *sliceHeader) (*C.SQLHENV, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLHENVValue) * slice.Len, + Cap: int(sizeOfSQLHENVValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLHENV)(mem0), allocs +} + +// allocSQLHENVMemory allocates memory for type C.SQLHENV in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLHENVMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLHENVValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLHENVValue = unsafe.Sizeof([1]C.SQLHENV{}) + +// copyPSQLHSTMTBytes copies the data from Go slice as *C.SQLHSTMT. +func copyPSQLHSTMTBytes(slice *sliceHeader) (*C.SQLHSTMT, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLHSTMTValue) * slice.Len, + Cap: int(sizeOfSQLHSTMTValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLHSTMT)(mem0), allocs +} + +// allocSQLHSTMTMemory allocates memory for type C.SQLHSTMT in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLHSTMTMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLHSTMTValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLHSTMTValue = unsafe.Sizeof([1]C.SQLHSTMT{}) + +// copyPSQLLENBytes copies the data from Go slice as *C.SQLLEN. +func copyPSQLLENBytes(slice *sliceHeader) (*C.SQLLEN, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLLENValue) * slice.Len, + Cap: int(sizeOfSQLLENValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLLEN)(mem0), allocs +} + +// allocSQLLENMemory allocates memory for type C.SQLLEN in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLLENMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLLENValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLLENValue = unsafe.Sizeof([1]C.SQLLEN{}) + +// copyPSQLSMALLINTBytes copies the data from Go slice as *C.SQLSMALLINT. +func copyPSQLSMALLINTBytes(slice *sliceHeader) (*C.SQLSMALLINT, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLSMALLINTValue) * slice.Len, + Cap: int(sizeOfSQLSMALLINTValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLSMALLINT)(mem0), allocs +} + +// allocSQLSMALLINTMemory allocates memory for type C.SQLSMALLINT in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLSMALLINTMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLSMALLINTValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLSMALLINTValue = unsafe.Sizeof([1]C.SQLSMALLINT{}) + +// copyPSQLCHARBytes copies the data from Go slice as *C.SQLCHAR. +func copyPSQLCHARBytes(slice *sliceHeader) (*C.SQLCHAR, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLCHARValue) * slice.Len, + Cap: int(sizeOfSQLCHARValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLCHAR)(mem0), allocs +} + +// allocSQLCHARMemory allocates memory for type C.SQLCHAR in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLCHARMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLCHARValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLCHARValue = unsafe.Sizeof([1]C.SQLCHAR{}) + +// copyPSQLINTEGERBytes copies the data from Go slice as *C.SQLINTEGER. +func copyPSQLINTEGERBytes(slice *sliceHeader) (*C.SQLINTEGER, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLINTEGERValue) * slice.Len, + Cap: int(sizeOfSQLINTEGERValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLINTEGER)(mem0), allocs +} + +// allocSQLINTEGERMemory allocates memory for type C.SQLINTEGER in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLINTEGERMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLINTEGERValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLINTEGERValue = unsafe.Sizeof([1]C.SQLINTEGER{}) + +// copyPSQLUSMALLINTBytes copies the data from Go slice as *C.SQLUSMALLINT. +func copyPSQLUSMALLINTBytes(slice *sliceHeader) (*C.SQLUSMALLINT, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLUSMALLINTValue) * slice.Len, + Cap: int(sizeOfSQLUSMALLINTValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLUSMALLINT)(mem0), allocs +} + +// allocSQLUSMALLINTMemory allocates memory for type C.SQLUSMALLINT in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLUSMALLINTMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLUSMALLINTValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLUSMALLINTValue = unsafe.Sizeof([1]C.SQLUSMALLINT{}) + +// copyPSQLPOINTERBytes copies the data from Go slice as *C.SQLPOINTER. +func copyPSQLPOINTERBytes(slice *sliceHeader) (*C.SQLPOINTER, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLPOINTERValue) * slice.Len, + Cap: int(sizeOfSQLPOINTERValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLPOINTER)(mem0), allocs +} + +// allocSQLPOINTERMemory allocates memory for type C.SQLPOINTER in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLPOINTERMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLPOINTERValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLPOINTERValue = unsafe.Sizeof([1]C.SQLPOINTER{}) + +// copyPSQLULENBytes copies the data from Go slice as *C.SQLULEN. +func copyPSQLULENBytes(slice *sliceHeader) (*C.SQLULEN, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLULENValue) * slice.Len, + Cap: int(sizeOfSQLULENValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLULEN)(mem0), allocs +} + +// allocSQLULENMemory allocates memory for type C.SQLULEN in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLULENMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLULENValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLULENValue = unsafe.Sizeof([1]C.SQLULEN{}) + +// copyPSQLWCHARBytes copies the data from Go slice as *C.SQLWCHAR. +func copyPSQLWCHARBytes(slice *sliceHeader) (*C.SQLWCHAR, *cgoAllocMap) { + allocs := new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + mem0 := unsafe.Pointer(C.CBytes(*(*[]byte)(unsafe.Pointer(&sliceHeader{ + Data: slice.Data, + Len: int(sizeOfSQLWCHARValue) * slice.Len, + Cap: int(sizeOfSQLWCHARValue) * slice.Len, + })))) + allocs.Add(mem0) + + return (*C.SQLWCHAR)(mem0), allocs +} + +// allocSQLWCHARMemory allocates memory for type C.SQLWCHAR in C. +// The caller is responsible for freeing the this memory via C.free. +func allocSQLWCHARMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfSQLWCHARValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfSQLWCHARValue = unsafe.Sizeof([1]C.SQLWCHAR{}) diff --git a/internal/api/cgo_helpers.h b/internal/api/cgo_helpers.h index 7fd8b50..f2453b6 100644 --- a/internal/api/cgo_helpers.h +++ b/internal/api/cgo_helpers.h @@ -1,6 +1,6 @@ // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. -// WARNING: This file has automatically been generated on Tue, 10 Oct 2023 12:49:57 MDT. +// WARNING: This file has automatically been generated on Wed, 22 May 2024 15:11:09 MDT. // Code generated by https://git.io/c-for-go. DO NOT EDIT. #include "sql.h" diff --git a/internal/api/const.go b/internal/api/const.go index fb91624..605dd7c 100644 --- a/internal/api/const.go +++ b/internal/api/const.go @@ -1,6 +1,6 @@ // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. -// WARNING: This file has automatically been generated on Tue, 10 Oct 2023 12:49:57 MDT. +// WARNING: This file has automatically been generated on Wed, 22 May 2024 15:11:09 MDT. // Code generated by https://git.io/c-for-go. DO NOT EDIT. package api diff --git a/internal/api/doc.go b/internal/api/doc.go index 7ae221e..01f85e5 100644 --- a/internal/api/doc.go +++ b/internal/api/doc.go @@ -1,6 +1,6 @@ // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. -// WARNING: This file has automatically been generated on Tue, 10 Oct 2023 12:49:57 MDT. +// WARNING: This file has automatically been generated on Wed, 22 May 2024 15:11:09 MDT. // Code generated by https://git.io/c-for-go. DO NOT EDIT. /* diff --git a/internal/api/helpers.go b/internal/api/helpers.go new file mode 100644 index 0000000..840acba --- /dev/null +++ b/internal/api/helpers.go @@ -0,0 +1,23 @@ +package api + +/* +#cgo linux LDFLAGS: -lodbc +#include "sql.h" +#include "sqlext.h" +#include "sqlucode.h" +#include "sqlspi.h" +#include +#include + +SQLPOINTER* constValue(ulong ConstValue){ + return (SQLPOINTER*)ConstValue; +} + +*/ +import "C" + +//go:generate c-for-go -out ../ ./api.yml + +func Const(value uint64) *SQLPOINTER { + return (*SQLPOINTER)(C.constValue(C.ulong(value))) +} diff --git a/internal/api/types.go b/internal/api/types.go index 5aa2a04..0306673 100644 --- a/internal/api/types.go +++ b/internal/api/types.go @@ -1,6 +1,6 @@ // THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS. -// WARNING: This file has automatically been generated on Tue, 10 Oct 2023 12:49:57 MDT. +// WARNING: This file has automatically been generated on Wed, 22 May 2024 15:11:09 MDT. // Code generated by https://git.io/c-for-go. DO NOT EDIT. package api diff --git a/internal/api/wrapper.go b/internal/api/wrapper.go deleted file mode 100644 index 51d8e30..0000000 --- a/internal/api/wrapper.go +++ /dev/null @@ -1,241 +0,0 @@ -package api - -/* -#cgo linux LDFLAGS: -lodbc -#include "sql.h" -#include "sqlext.h" -#include "sqlucode.h" -#include "sqlspi.h" -#include -#include - -SQLPOINTER sqlLenDataAtExec(SQLLEN length) { - return (SQLPOINTER)SQL_LEN_DATA_AT_EXEC(length); -} - -SQLRETURN allocHandleNullInput( - SQLSMALLINT HandleType, - SQLHANDLE * OutputHandlePtr){ - return SQLAllocHandle(HandleType,SQL_NULL_HANDLE,OutputHandlePtr); -} - -SQLPOINTER constValue(ulong ConstValue){ - return (SQLPOINTER)ConstValue; -} - -*/ -import "C" -import ( - "unsafe" -) - -//go:generate c-for-go -out ../ ./api.yml -type API struct{} - -func (a *API) SQLEndTran(handleType SQLSMALLINT, handle SQLHANDLE, completionType SQLSMALLINT) SQLRETURN { - return SQLRETURN(C.SQLEndTran( - C.SQLSMALLINT(handleType), - C.SQLHANDLE(handle), - C.SQLSMALLINT(completionType))) -} - -func (a *API) SQLExecute(statementHandle SQLHSTMT) SQLRETURN { - return SQLRETURN(C.SQLExecute(C.SQLHSTMT(statementHandle))) -} - -func (a *API) SQLExecDirect(statementHandle SQLHSTMT, statementText []uint16, textLength SQLINTEGER) SQLRETURN { - return SQLRETURN(C.SQLExecDirectW( - C.SQLHSTMT(statementHandle), - (*C.SQLWCHAR)(unsafe.Pointer(&statementText[0])), - C.SQLINTEGER(textLength), - )) -} - -func (a *API) SQLGetData(statementHandle SQLHSTMT, colOrParamNum SQLUSMALLINT, targetType SQLSMALLINT, targetValuePtr SQLPOINTER, bufferLength SQLLEN, strLenOrIndPtr *SQLLEN) SQLRETURN { - return SQLRETURN(C.SQLGetData( - C.SQLHSTMT(statementHandle), - C.SQLUSMALLINT(colOrParamNum), - C.SQLSMALLINT(targetType), - C.SQLPOINTER(targetValuePtr), - C.SQLLEN(bufferLength), - (*C.SQLLEN)(unsafe.Pointer(strLenOrIndPtr)), - )) -} - -func (a *API) SQLGetTypeInfo(statementHandle SQLHSTMT, dataType SQLSMALLINT) SQLRETURN { - return SQLRETURN(C.SQLGetTypeInfo( - C.SQLHSTMT(statementHandle), - C.SQLSMALLINT(dataType), - )) -} - -func (a *API) SQLCancelHandle(handleType SQLSMALLINT, inputHandle SQLHANDLE) SQLRETURN { - return SQLRETURN(C.SQLCancelHandle( - C.SQLSMALLINT(handleType), - C.SQLHANDLE(inputHandle), - )) -} - -func (a *API) SQLBindParameter(statementHandle SQLHSTMT, parameterNumber SQLUSMALLINT, inputOutputType SQLSMALLINT, valueType SQLSMALLINT, parameterType SQLSMALLINT, columnSize SQLULEN, decimalDigits SQLSMALLINT, parameterValuePtr SQLPOINTER, bufferLength SQLLEN, strLenOrIndPtr *SQLLEN) SQLRETURN { - return SQLRETURN(C.SQLBindParameter( - C.SQLHSTMT(statementHandle), - C.SQLUSMALLINT(parameterNumber), - C.SQLSMALLINT(inputOutputType), - C.SQLSMALLINT(valueType), - C.SQLSMALLINT(parameterType), - C.SQLULEN(columnSize), - C.SQLSMALLINT(decimalDigits), - C.SQLPOINTER(parameterValuePtr), - C.SQLLEN(bufferLength), - (*C.SQLLEN)(unsafe.Pointer(strLenOrIndPtr)), - )) -} - -func (a *API) SQLDescribeCol(statementHandle SQLHSTMT, columnNumber SQLUSMALLINT, columnName *[]uint16, bufferLength SQLSMALLINT, nameLengthPtr *SQLSMALLINT, dataTypePtr *SQLSMALLINT, columnSizePtr *SQLULEN, decimalDigitsPtr *SQLSMALLINT, nullablePtr *SQLSMALLINT) SQLRETURN { - return SQLRETURN(C.SQLDescribeColW( - C.SQLHSTMT(statementHandle), - C.SQLUSMALLINT(columnNumber), - (*C.SQLWCHAR)(unsafe.Pointer(&(*columnName)[0])), //TODO unicode - C.SQLSMALLINT(bufferLength), - (*C.SQLSMALLINT)(unsafe.Pointer(nameLengthPtr)), - (*C.SQLSMALLINT)(unsafe.Pointer(dataTypePtr)), - (*C.SQLULEN)(unsafe.Pointer(columnSizePtr)), - (*C.SQLSMALLINT)(unsafe.Pointer(decimalDigitsPtr)), - (*C.SQLSMALLINT)(unsafe.Pointer(nullablePtr)), - )) -} - -func (a *API) SQLSetEnvAttrConst(environmentHandle SQLHENV, attribute SQLINTEGER, value uint64) SQLRETURN { - return SQLRETURN(C.SQLSetEnvAttr(C.SQLHENV(environmentHandle), C.SQLINTEGER(attribute), C.constValue(C.ulong(value)), SQL_IS_UINTEGER)) -} - -func (a *API) SQLSetEnvAttrStr(environmentHandle SQLHENV, attribute SQLINTEGER, value SQLPOINTER, stringLength SQLINTEGER) SQLRETURN { - return SQLRETURN(C.SQLSetEnvAttr(C.SQLHENV(environmentHandle), C.SQLINTEGER(attribute), C.SQLPOINTER(value), C.SQLINTEGER(stringLength))) -} - -func (a *API) SQLSetConnectAttrStr(connHandle SQLHDBC, attribute SQLINTEGER, value SQLPOINTER, stringLength SQLINTEGER) SQLRETURN { - return SQLRETURN(C.SQLSetConnectAttr(C.SQLHDBC(connHandle), C.SQLINTEGER(attribute), C.SQLPOINTER(value), C.SQLINTEGER(stringLength))) -} - -func (a *API) SQLSetConnectAttrConst(connHandle SQLHDBC, attribute SQLINTEGER, value uint64) SQLRETURN { - return SQLRETURN(C.SQLSetConnectAttr(C.SQLHDBC(connHandle), C.SQLINTEGER(attribute), C.constValue(C.ulong(value)), SQL_IS_UINTEGER)) -} - -func (a *API) SQLSetStmtAttrConst(stmtHandle SQLHSTMT, attribute SQLINTEGER, value uint64) SQLRETURN { - return SQLRETURN(C.SQLSetStmtAttr(C.SQLHSTMT(stmtHandle), C.SQLINTEGER(attribute), C.constValue(C.ulong(value)), 0)) -} - -func (a *API) SQLSetStmtAttrPointer(stmtHandle SQLHSTMT, attribute SQLINTEGER, pointer SQLPOINTER) SQLRETURN { - return SQLRETURN(C.SQLSetStmtAttr(C.SQLHSTMT(stmtHandle), C.SQLINTEGER(attribute), C.SQLPOINTER(pointer), SQL_IS_POINTER)) -} - -func (a *API) SQLDriverConnectW(connectionHandle SQLHDBC, windowHandle SQLHWND, inConnectionString []uint16, stringLength1 SQLSMALLINT, outConnectionString *[]uint16, bufferLength SQLSMALLINT, stringLength2Ptr *SQLSMALLINT, driverCompletion SQLUSMALLINT) SQLRETURN { - var outStrPtr *uint16 = nil - if outConnectionString != nil { - outStrPtr = &(*outConnectionString)[0] - } - return SQLRETURN(C.SQLDriverConnectW( - C.SQLHDBC(connectionHandle), - C.SQLHWND(windowHandle), - (*C.SQLWCHAR)(unsafe.Pointer(&inConnectionString[0])), - C.SQLSMALLINT(stringLength1), - (*C.SQLWCHAR)(unsafe.Pointer(outStrPtr)), - C.SQLSMALLINT(bufferLength), - (*C.SQLSMALLINT)(unsafe.Pointer(stringLength2Ptr)), - C.SQLUSMALLINT(driverCompletion), - )) -} - -func (a *API) SQLNumParams(statementHandle SQLHSTMT, parameterCountPtr *SQLSMALLINT) SQLRETURN { - return SQLRETURN(C.SQLNumParams( - C.SQLHSTMT(statementHandle), - (*C.SQLSMALLINT)(unsafe.Pointer(parameterCountPtr)), - )) -} - -func (a *API) SQLNumResultCols(statementHandle SQLHSTMT, columnCountPtr *SQLSMALLINT) SQLRETURN { - return SQLRETURN(C.SQLNumResultCols( - C.SQLHSTMT(statementHandle), - (*C.SQLSMALLINT)(unsafe.Pointer(columnCountPtr)), - )) -} - -func (a *API) SQLGetInfo( - connectionHandle SQLHDBC, - infoType SQLUSMALLINT, - infoValuePtr SQLPOINTER, - bufferLength SQLSMALLINT, - stringLengthPtr *SQLSMALLINT) SQLRETURN { - return SQLRETURN(C.SQLGetInfo( - C.SQLHDBC(connectionHandle), - C.SQLUSMALLINT(infoType), - C.SQLPOINTER(infoValuePtr), - C.SQLSMALLINT(bufferLength), - (*C.SQLSMALLINT)(stringLengthPtr), - )) -} - -func (a *API) SQLGetConnectAttr(connectionHandle SQLHDBC, attribute SQLINTEGER, valuePtr SQLPOINTER, bufferLength SQLINTEGER, stringLengthPtr *SQLINTEGER) SQLRETURN { - return SQLRETURN(C.SQLGetConnectAttr( - C.SQLHDBC(connectionHandle), - C.SQLINTEGER(attribute), - C.SQLPOINTER(valuePtr), - C.SQLINTEGER(bufferLength), - (*C.SQLINTEGER)(unsafe.Pointer(stringLengthPtr)), - )) -} - -func (a *API) SQLPrepare(statementHandle SQLHSTMT, statementText []uint16, textLength SQLINTEGER) SQLRETURN { - return SQLRETURN(C.SQLPrepareW( - C.SQLHSTMT(statementHandle), - (*C.SQLWCHAR)(unsafe.Pointer(&statementText[0])), - C.SQLINTEGER(textLength), - )) -} - -func (a *API) SQLFreeStmt(statementHandle SQLHSTMT, option SQLUSMALLINT) SQLRETURN { - return SQLRETURN(C.SQLFreeStmt( - C.SQLHSTMT(statementHandle), - C.SQLUSMALLINT(option), - )) -} - -func (a *API) SQLFetch(statementHandle SQLHSTMT) SQLRETURN { - return SQLRETURN(C.SQLFetch(C.SQLHSTMT(statementHandle))) -} - -func (a *API) SQLGetDiagRecW(handleType SQLSMALLINT, handle SQLHANDLE, recNumber SQLSMALLINT, sqlState *[]uint16, nativeErrorPtr *SQLINTEGER, messageText *[]uint16, bufferLength SQLSMALLINT, textLengthPtr *SQLSMALLINT) SQLRETURN { - return SQLRETURN(C.SQLGetDiagRecW( - C.SQLSMALLINT(handleType), - C.SQLHANDLE(handle), - C.SQLSMALLINT(recNumber), - (*C.SQLWCHAR)(unsafe.Pointer(&(*sqlState)[0])), - (*C.SQLINTEGER)(unsafe.Pointer(nativeErrorPtr)), - (*C.SQLWCHAR)(unsafe.Pointer(&(*messageText)[0])), - C.SQLSMALLINT(bufferLength), - (*C.SQLSMALLINT)(unsafe.Pointer(textLengthPtr)))) -} - -func (a *API) SQLDisconnect(connectionHandle SQLHDBC) SQLRETURN { - return SQLRETURN(C.SQLDisconnect(C.SQLHDBC(connectionHandle))) -} - -func (a *API) SQLFreeHandle(handleType SQLSMALLINT, handle SQLHANDLE) SQLRETURN { - return SQLRETURN(C.SQLFreeHandle(C.SQLSMALLINT(handleType), C.SQLHANDLE(handle))) -} - -func (a *API) SQLCloseCursor(statementHandle SQLHSTMT) SQLRETURN { - return SQLRETURN(C.SQLCloseCursor(C.SQLHSTMT(statementHandle))) -} - -func (a *API) SQL_LEN_DATA_AT_EXEC(length SQLLEN) SQLPOINTER { - return SQLPOINTER(C.sqlLenDataAtExec(C.SQLLEN(length))) -} - -// SQLAllocHandle allocates an environment, connection, statement, or descriptor handle. -func (a *API) SQLAllocHandle(handleType SQLSMALLINT, inputHandle SQLHANDLE, outputHandle *SQLHANDLE) SQLRETURN { - if inputHandle == nil { - return SQLRETURN(C.allocHandleNullInput((C.SQLSMALLINT)(handleType), (*C.SQLHANDLE)(outputHandle))) - } - return SQLRETURN(C.SQLAllocHandle((C.SQLSMALLINT)(handleType), C.SQLHANDLE(inputHandle), (*C.SQLHANDLE)(outputHandle))) -} diff --git a/internal/cache/lru.go b/internal/cache/lru.go index acb43ca..ad95824 100644 --- a/internal/cache/lru.go +++ b/internal/cache/lru.go @@ -39,6 +39,10 @@ func (l *LRU[T]) evictLRU() error { return nil } +func (l *LRU[T]) Capacity() int { + return l.capacity +} + func (l *LRU[T]) Put(key string, value *T) error { if l.capacity == 0 { if l.onEvict != nil { diff --git a/internal/cache/lru_test.go b/internal/cache/lru_test.go index eeb2c45..5617cbc 100644 --- a/internal/cache/lru_test.go +++ b/internal/cache/lru_test.go @@ -42,7 +42,7 @@ func TestLRU_Put_Empty_Eviction(t *testing.T) { lru := cache.NewLRU[MyStruct](0, onEvict) - if gotErr := lru.Put("A", &wantValue); gotErr != wantErr { + if gotErr := lru.Put("A", &wantValue); !errors.Is(gotErr, wantErr) { t.Fatalf("expected error %v but received: %v", wantErr, gotErr) } } @@ -68,7 +68,7 @@ func TestLRU_Put_Evict_Error(t *testing.T) { t.Fatalf("expected no error but received: %v", gotErr) } - if gotErr := lru.Put("B", new(MyStruct)); gotErr != wantErr { + if gotErr := lru.Put("B", new(MyStruct)); !errors.Is(gotErr, wantErr) { t.Fatalf("expected error %v but received %v", wantErr, gotErr) } } @@ -126,7 +126,7 @@ func TestLRU_Purge_Error(t *testing.T) { t.Fatalf("expected no error but received: %v", gotErr) } - if gotErr := lru.Purge(); gotErr != wantErr { + if gotErr := lru.Purge(); !errors.Is(gotErr, wantErr) { t.Fatalf("expected %v but received %v", wantErr, gotErr) } } diff --git a/internal/odbc/column_mock_test.go b/internal/mocks/column.go similarity index 98% rename from internal/odbc/column_mock_test.go rename to internal/mocks/column.go index 9c21728..57df77f 100644 --- a/internal/odbc/column_mock_test.go +++ b/internal/mocks/column.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: column.go -// Package odbc is a generated GoMock package. -package odbc +// Package mocks is a generated GoMock package. +package mocks import ( driver "database/sql/driver" diff --git a/internal/mocks/connection.go b/internal/mocks/connection.go new file mode 100644 index 0000000..cb43e30 --- /dev/null +++ b/internal/mocks/connection.go @@ -0,0 +1,148 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: connection.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + odbc "github.com/ninthclowd/unixodbc/internal/odbc" +) + +// MockConnection is a mock of Connection interface. +type MockConnection struct { + ctrl *gomock.Controller + recorder *MockConnectionMockRecorder +} + +// MockConnectionMockRecorder is the mock recorder for MockConnection. +type MockConnectionMockRecorder struct { + mock *MockConnection +} + +// NewMockConnection creates a new mock instance. +func NewMockConnection(ctrl *gomock.Controller) *MockConnection { + mock := &MockConnection{ctrl: ctrl} + mock.recorder = &MockConnectionMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockConnection) EXPECT() *MockConnectionMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockConnection) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockConnectionMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockConnection)(nil).Close)) +} + +// Commit mocks base method. +func (m *MockConnection) Commit() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Commit") + ret0, _ := ret[0].(error) + return ret0 +} + +// Commit indicates an expected call of Commit. +func (mr *MockConnectionMockRecorder) Commit() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Commit", reflect.TypeOf((*MockConnection)(nil).Commit)) +} + +// Ping mocks base method. +func (m *MockConnection) Ping() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Ping") + ret0, _ := ret[0].(error) + return ret0 +} + +// Ping indicates an expected call of Ping. +func (mr *MockConnectionMockRecorder) Ping() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ping", reflect.TypeOf((*MockConnection)(nil).Ping)) +} + +// Rollback mocks base method. +func (m *MockConnection) Rollback() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Rollback") + ret0, _ := ret[0].(error) + return ret0 +} + +// Rollback indicates an expected call of Rollback. +func (mr *MockConnectionMockRecorder) Rollback() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Rollback", reflect.TypeOf((*MockConnection)(nil).Rollback)) +} + +// SetAutoCommit mocks base method. +func (m *MockConnection) SetAutoCommit(autoCommit bool) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetAutoCommit", autoCommit) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetAutoCommit indicates an expected call of SetAutoCommit. +func (mr *MockConnectionMockRecorder) SetAutoCommit(autoCommit interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAutoCommit", reflect.TypeOf((*MockConnection)(nil).SetAutoCommit), autoCommit) +} + +// SetIsolationLevel mocks base method. +func (m *MockConnection) SetIsolationLevel(level odbc.IsolationLevel) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetIsolationLevel", level) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetIsolationLevel indicates an expected call of SetIsolationLevel. +func (mr *MockConnectionMockRecorder) SetIsolationLevel(level interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetIsolationLevel", reflect.TypeOf((*MockConnection)(nil).SetIsolationLevel), level) +} + +// SetReadOnlyMode mocks base method. +func (m *MockConnection) SetReadOnlyMode(readOnly odbc.ReadOnlyMode) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetReadOnlyMode", readOnly) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetReadOnlyMode indicates an expected call of SetReadOnlyMode. +func (mr *MockConnectionMockRecorder) SetReadOnlyMode(readOnly interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetReadOnlyMode", reflect.TypeOf((*MockConnection)(nil).SetReadOnlyMode), readOnly) +} + +// Statement mocks base method. +func (m *MockConnection) Statement() (odbc.Statement, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Statement") + ret0, _ := ret[0].(odbc.Statement) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Statement indicates an expected call of Statement. +func (mr *MockConnectionMockRecorder) Statement() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Statement", reflect.TypeOf((*MockConnection)(nil).Statement)) +} diff --git a/internal/mocks/environment.go b/internal/mocks/environment.go new file mode 100644 index 0000000..83977f3 --- /dev/null +++ b/internal/mocks/environment.go @@ -0,0 +1,93 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: environment.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + odbc "github.com/ninthclowd/unixodbc/internal/odbc" +) + +// MockEnvironment is a mock of Environment interface. +type MockEnvironment struct { + ctrl *gomock.Controller + recorder *MockEnvironmentMockRecorder +} + +// MockEnvironmentMockRecorder is the mock recorder for MockEnvironment. +type MockEnvironmentMockRecorder struct { + mock *MockEnvironment +} + +// NewMockEnvironment creates a new mock instance. +func NewMockEnvironment(ctrl *gomock.Controller) *MockEnvironment { + mock := &MockEnvironment{ctrl: ctrl} + mock.recorder = &MockEnvironmentMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockEnvironment) EXPECT() *MockEnvironmentMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockEnvironment) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockEnvironmentMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockEnvironment)(nil).Close)) +} + +// Connect mocks base method. +func (m *MockEnvironment) Connect(ctx context.Context, connStr string) (odbc.Connection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Connect", ctx, connStr) + ret0, _ := ret[0].(odbc.Connection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Connect indicates an expected call of Connect. +func (mr *MockEnvironmentMockRecorder) Connect(ctx, connStr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Connect", reflect.TypeOf((*MockEnvironment)(nil).Connect), ctx, connStr) +} + +// SetPoolOption mocks base method. +func (m *MockEnvironment) SetPoolOption(option odbc.PoolOption) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetPoolOption", option) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetPoolOption indicates an expected call of SetPoolOption. +func (mr *MockEnvironmentMockRecorder) SetPoolOption(option interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPoolOption", reflect.TypeOf((*MockEnvironment)(nil).SetPoolOption), option) +} + +// SetVersion mocks base method. +func (m *MockEnvironment) SetVersion(version odbc.Version) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetVersion", version) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetVersion indicates an expected call of SetVersion. +func (mr *MockEnvironmentMockRecorder) SetVersion(version interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVersion", reflect.TypeOf((*MockEnvironment)(nil).SetVersion), version) +} diff --git a/internal/mocks/recordset.go b/internal/mocks/recordset.go new file mode 100644 index 0000000..f4dc137 --- /dev/null +++ b/internal/mocks/recordset.go @@ -0,0 +1,134 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: recordset.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + odbc "github.com/ninthclowd/unixodbc/internal/odbc" +) + +// MockRecordSet is a mock of RecordSet interface. +type MockRecordSet struct { + ctrl *gomock.Controller + recorder *MockRecordSetMockRecorder +} + +// MockRecordSetMockRecorder is the mock recorder for MockRecordSet. +type MockRecordSetMockRecorder struct { + mock *MockRecordSet +} + +// NewMockRecordSet creates a new mock instance. +func NewMockRecordSet(ctrl *gomock.Controller) *MockRecordSet { + mock := &MockRecordSet{ctrl: ctrl} + mock.recorder = &MockRecordSetMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRecordSet) EXPECT() *MockRecordSetMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockRecordSet) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockRecordSetMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockRecordSet)(nil).Close)) +} + +// Column mocks base method. +func (m *MockRecordSet) Column(index int) odbc.Column { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Column", index) + ret0, _ := ret[0].(odbc.Column) + return ret0 +} + +// Column indicates an expected call of Column. +func (mr *MockRecordSetMockRecorder) Column(index interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Column", reflect.TypeOf((*MockRecordSet)(nil).Column), index) +} + +// ColumnNames mocks base method. +func (m *MockRecordSet) ColumnNames() []string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ColumnNames") + ret0, _ := ret[0].([]string) + return ret0 +} + +// ColumnNames indicates an expected call of ColumnNames. +func (mr *MockRecordSetMockRecorder) ColumnNames() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ColumnNames", reflect.TypeOf((*MockRecordSet)(nil).ColumnNames)) +} + +// ColumnWithName mocks base method. +func (m *MockRecordSet) ColumnWithName(name string) odbc.Column { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ColumnWithName", name) + ret0, _ := ret[0].(odbc.Column) + return ret0 +} + +// ColumnWithName indicates an expected call of ColumnWithName. +func (mr *MockRecordSetMockRecorder) ColumnWithName(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ColumnWithName", reflect.TypeOf((*MockRecordSet)(nil).ColumnWithName), name) +} + +// Fetch mocks base method. +func (m *MockRecordSet) Fetch() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Fetch") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Fetch indicates an expected call of Fetch. +func (mr *MockRecordSetMockRecorder) Fetch() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Fetch", reflect.TypeOf((*MockRecordSet)(nil).Fetch)) +} + +// Statement mocks base method. +func (m *MockRecordSet) Statement() odbc.Statement { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Statement") + ret0, _ := ret[0].(odbc.Statement) + return ret0 +} + +// Statement indicates an expected call of Statement. +func (mr *MockRecordSetMockRecorder) Statement() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Statement", reflect.TypeOf((*MockRecordSet)(nil).Statement)) +} + +// Unmarshal mocks base method. +func (m *MockRecordSet) Unmarshal(out interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Unmarshal", out) + ret0, _ := ret[0].(error) + return ret0 +} + +// Unmarshal indicates an expected call of Unmarshal. +func (mr *MockRecordSetMockRecorder) Unmarshal(out interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unmarshal", reflect.TypeOf((*MockRecordSet)(nil).Unmarshal), out) +} diff --git a/internal/mocks/statement.go b/internal/mocks/statement.go new file mode 100644 index 0000000..0994135 --- /dev/null +++ b/internal/mocks/statement.go @@ -0,0 +1,182 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: statement.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + odbc "github.com/ninthclowd/unixodbc/internal/odbc" +) + +// MockStatement is a mock of Statement interface. +type MockStatement struct { + ctrl *gomock.Controller + recorder *MockStatementMockRecorder +} + +// MockStatementMockRecorder is the mock recorder for MockStatement. +type MockStatementMockRecorder struct { + mock *MockStatement +} + +// NewMockStatement creates a new mock instance. +func NewMockStatement(ctrl *gomock.Controller) *MockStatement { + mock := &MockStatement{ctrl: ctrl} + mock.recorder = &MockStatementMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStatement) EXPECT() *MockStatementMockRecorder { + return m.recorder +} + +// BindParams mocks base method. +func (m *MockStatement) BindParams(params ...interface{}) error { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range params { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "BindParams", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// BindParams indicates an expected call of BindParams. +func (mr *MockStatementMockRecorder) BindParams(params ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindParams", reflect.TypeOf((*MockStatement)(nil).BindParams), params...) +} + +// Close mocks base method. +func (m *MockStatement) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockStatementMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockStatement)(nil).Close)) +} + +// ExecDirect mocks base method. +func (m *MockStatement) ExecDirect(ctx context.Context, sql string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExecDirect", ctx, sql) + ret0, _ := ret[0].(error) + return ret0 +} + +// ExecDirect indicates an expected call of ExecDirect. +func (mr *MockStatementMockRecorder) ExecDirect(ctx, sql interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExecDirect", reflect.TypeOf((*MockStatement)(nil).ExecDirect), ctx, sql) +} + +// Execute mocks base method. +func (m *MockStatement) Execute(ctx context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Execute", ctx) + ret0, _ := ret[0].(error) + return ret0 +} + +// Execute indicates an expected call of Execute. +func (mr *MockStatementMockRecorder) Execute(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Execute", reflect.TypeOf((*MockStatement)(nil).Execute), ctx) +} + +// NumParams mocks base method. +func (m *MockStatement) NumParams() (int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NumParams") + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// NumParams indicates an expected call of NumParams. +func (mr *MockStatementMockRecorder) NumParams() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NumParams", reflect.TypeOf((*MockStatement)(nil).NumParams)) +} + +// Prepare mocks base method. +func (m *MockStatement) Prepare(ctx context.Context, sql string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Prepare", ctx, sql) + ret0, _ := ret[0].(error) + return ret0 +} + +// Prepare indicates an expected call of Prepare. +func (mr *MockStatementMockRecorder) Prepare(ctx, sql interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockStatement)(nil).Prepare), ctx, sql) +} + +// RecordSet mocks base method. +func (m *MockStatement) RecordSet() (odbc.RecordSet, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecordSet") + ret0, _ := ret[0].(odbc.RecordSet) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RecordSet indicates an expected call of RecordSet. +func (mr *MockStatementMockRecorder) RecordSet() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecordSet", reflect.TypeOf((*MockStatement)(nil).RecordSet)) +} + +// ResetParams mocks base method. +func (m *MockStatement) ResetParams() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ResetParams") + ret0, _ := ret[0].(error) + return ret0 +} + +// ResetParams indicates an expected call of ResetParams. +func (mr *MockStatementMockRecorder) ResetParams() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResetParams", reflect.TypeOf((*MockStatement)(nil).ResetParams)) +} + +// SetConcurrency mocks base method. +func (m *MockStatement) SetConcurrency(concurrency odbc.Concurrency) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetConcurrency", concurrency) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetConcurrency indicates an expected call of SetConcurrency. +func (mr *MockStatementMockRecorder) SetConcurrency(concurrency interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetConcurrency", reflect.TypeOf((*MockStatement)(nil).SetConcurrency), concurrency) +} + +// SetCursorSensitivity mocks base method. +func (m *MockStatement) SetCursorSensitivity(sensitivity odbc.CursorSensitivity) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetCursorSensitivity", sensitivity) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetCursorSensitivity indicates an expected call of SetCursorSensitivity. +func (mr *MockStatementMockRecorder) SetCursorSensitivity(sensitivity interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCursorSensitivity", reflect.TypeOf((*MockStatement)(nil).SetCursorSensitivity), sensitivity) +} diff --git a/internal/odbc/binary.go b/internal/odbc/binary.go index ec4d301..96ad18a 100644 --- a/internal/odbc/binary.go +++ b/internal/odbc/binary.go @@ -4,6 +4,7 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) const ( @@ -18,12 +19,12 @@ func init() { ) } -func newBinaryColumn(info *columnInfo, hnd handle) Column { +func newBinaryColumn(info *columnInfo, hnd *handle) Column { return &columnBinary{hnd, info} } type columnBinary struct { - handle + *handle *columnInfo } @@ -39,6 +40,7 @@ func (c *columnBinary) Decimal() (precision int64, scale int64, ok bool) { return } +//go:nocheckptr func (c *columnBinary) Value() (driver.Value, error) { size := c.columnSize if size == 0 { @@ -46,7 +48,12 @@ func (c *columnBinary) Value() (driver.Value, error) { } value := make([]byte, size) var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_BINARY, api.SQLPOINTER(&value[0]), api.SQLLEN(len(value)), &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_BINARY, + (*api.SQLPOINTER)(unsafe.Pointer(&value[0])), + api.SQLLEN(len(value)), + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { @@ -55,12 +62,18 @@ func (c *columnBinary) Value() (driver.Value, error) { return value[:valueLength], nil } -func (s *Statement) bindBinary(index int, src []byte) error { +//go:nocheckptr +func (s *statement) bindBinary(index int, src []byte) error { execSize := api.SQLLEN(len(src)) - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_BINARY, api.SQL_BINARY, - api.SQLULEN(len(src)), 0, - api.SQLPOINTER(&src[0]), - 0, &execSize)) + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_BINARY, + api.SQL_BINARY, + api.SQLULEN(len(src)), + 0, + (*api.SQLPOINTER)(unsafe.Pointer(&src[0])), + 0, + &execSize)) return err } diff --git a/internal/odbc/bool.go b/internal/odbc/bool.go index d673d97..ecfc337 100644 --- a/internal/odbc/bool.go +++ b/internal/odbc/bool.go @@ -4,18 +4,19 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) func init() { registerColumnFactoryForType(newBoolColumn, api.SQL_BIT) } -func newBoolColumn(info *columnInfo, hnd handle) Column { +func newBoolColumn(info *columnInfo, hnd *handle) Column { return &columnBool{hnd, info} } type columnBool struct { - handle + *handle *columnInfo } @@ -34,7 +35,12 @@ func (c *columnBool) Decimal() (precision int64, scale int64, ok bool) { func (c *columnBool) Value() (driver.Value, error) { var value api.SQLCHAR var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_BIT, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_BIT, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { @@ -43,15 +49,21 @@ func (c *columnBool) Value() (driver.Value, error) { return value == 1, nil } -func (s *Statement) bindBool(index int, value bool) error { +//go:nocheckptr +func (s *statement) bindBool(index int, value bool) error { var data byte if value { data = 1 } - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_BIT, api.SQL_BIT, - 1, 0, - api.SQLPOINTER(&data), - 0, nil)) + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_BIT, + api.SQL_BIT, + 1, + 0, + (*api.SQLPOINTER)(unsafe.Pointer(&data)), + 0, + nil)) return err } diff --git a/internal/odbc/capi.go b/internal/odbc/capi.go deleted file mode 100644 index 83b01d3..0000000 --- a/internal/odbc/capi.go +++ /dev/null @@ -1,34 +0,0 @@ -package odbc - -import "C" -import "github.com/ninthclowd/unixodbc/internal/api" - -//go:generate mockgen -source=capi.go -package odbc -destination capi_mock_test.go -mock_names odbcAPI=MockAPI -type odbcAPI interface { - SQLCancelHandle(handleType api.SQLSMALLINT, inputHandle api.SQLHANDLE) api.SQLRETURN - SQLGetTypeInfo(statementHandle api.SQLHSTMT, dataType api.SQLSMALLINT) api.SQLRETURN - SQLBindParameter(statementHandle api.SQLHSTMT, parameterNumber api.SQLUSMALLINT, inputOutputType api.SQLSMALLINT, valueType api.SQLSMALLINT, parameterType api.SQLSMALLINT, columnSize api.SQLULEN, decimalDigits api.SQLSMALLINT, parameterValuePtr api.SQLPOINTER, bufferLength api.SQLLEN, strLenOrIndPtr *api.SQLLEN) api.SQLRETURN - SQLDescribeCol(statementHandle api.SQLHSTMT, columnNumber api.SQLUSMALLINT, columnName *[]uint16, bufferLength api.SQLSMALLINT, nameLengthPtr *api.SQLSMALLINT, dataTypePtr *api.SQLSMALLINT, columnSizePtr *api.SQLULEN, decimalDigitsPtr *api.SQLSMALLINT, nullablePtr *api.SQLSMALLINT) api.SQLRETURN - SQLSetEnvAttrConst(environmentHandle api.SQLHENV, attribute api.SQLINTEGER, value uint64) api.SQLRETURN - SQLSetStmtAttrConst(stmtHandle api.SQLHSTMT, attribute api.SQLINTEGER, value uint64) api.SQLRETURN - SQLSetStmtAttrPointer(stmtHandle api.SQLHSTMT, attribute api.SQLINTEGER, pointer api.SQLPOINTER) api.SQLRETURN - SQLSetConnectAttrConst(connectionHandle api.SQLHDBC, attribute api.SQLINTEGER, value uint64) api.SQLRETURN - SQLDriverConnectW(connectionHandle api.SQLHDBC, windowHandle api.SQLHWND, inConnectionString []uint16, stringLength1 api.SQLSMALLINT, outConnectionString *[]uint16, bufferLength api.SQLSMALLINT, stringLength2Ptr *api.SQLSMALLINT, driverCompletion api.SQLUSMALLINT) api.SQLRETURN - SQLPrepare(statementHandle api.SQLHSTMT, statementText []uint16, textLength api.SQLINTEGER) api.SQLRETURN - SQLNumParams(statementHandle api.SQLHSTMT, parameterCountPtr *api.SQLSMALLINT) api.SQLRETURN - SQLGetData(statementHandle api.SQLHSTMT, colOrParamNum api.SQLUSMALLINT, targetType api.SQLSMALLINT, targetValuePtr api.SQLPOINTER, bufferLength api.SQLLEN, strLenOrIndPtr *api.SQLLEN) api.SQLRETURN - SQLNumResultCols(statementHandle api.SQLHSTMT, columnCountPtr *api.SQLSMALLINT) api.SQLRETURN - SQLGetConnectAttr(connectionHandle api.SQLHDBC, attribute api.SQLINTEGER, valuePtr api.SQLPOINTER, bufferLength api.SQLINTEGER, stringLengthPtr *api.SQLINTEGER) api.SQLRETURN - SQLFreeStmt(statementHandle api.SQLHSTMT, option api.SQLUSMALLINT) api.SQLRETURN - SQLFetch(statementHandle api.SQLHSTMT) api.SQLRETURN - SQLAllocHandle(handleType api.SQLSMALLINT, inputHandle api.SQLHANDLE, outputHandle *api.SQLHANDLE) api.SQLRETURN - SQLGetDiagRecW(handleType api.SQLSMALLINT, handle api.SQLHANDLE, recNumber api.SQLSMALLINT, sqlState *[]uint16, nativeErrorPtr *api.SQLINTEGER, messageText *[]uint16, bufferLength api.SQLSMALLINT, textLengthPtr *api.SQLSMALLINT) api.SQLRETURN - SQLDisconnect(connectionHandle api.SQLHDBC) api.SQLRETURN - SQLFreeHandle(handleType api.SQLSMALLINT, handle api.SQLHANDLE) api.SQLRETURN - SQLExecute(statementHandle api.SQLHSTMT) api.SQLRETURN - SQLExecDirect(statementHandle api.SQLHSTMT, statementText []uint16, textLength api.SQLINTEGER) api.SQLRETURN - SQLCloseCursor(statementHandle api.SQLHSTMT) api.SQLRETURN - SQLSetEnvAttrStr(environmentHandle api.SQLHENV, attribute api.SQLINTEGER, value api.SQLPOINTER, stringLength api.SQLINTEGER) api.SQLRETURN - SQLEndTran(handleType api.SQLSMALLINT, handle api.SQLHANDLE, completionType api.SQLSMALLINT) api.SQLRETURN - SQLGetInfo(connectionHandle api.SQLHDBC, infoType api.SQLUSMALLINT, infoValuePtr api.SQLPOINTER, bufferLength api.SQLSMALLINT, stringLengthPtr *api.SQLSMALLINT) api.SQLRETURN -} diff --git a/internal/odbc/capi_mock_test.go b/internal/odbc/capi_mock_test.go deleted file mode 100644 index 4d7a564..0000000 --- a/internal/odbc/capi_mock_test.go +++ /dev/null @@ -1,399 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: capi.go - -// Package odbc is a generated GoMock package. -package odbc - -import ( - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - api "github.com/ninthclowd/unixodbc/internal/api" -) - -// MockAPI is a mock of odbcAPI interface. -type MockAPI struct { - ctrl *gomock.Controller - recorder *MockAPIMockRecorder -} - -// MockAPIMockRecorder is the mock recorder for MockAPI. -type MockAPIMockRecorder struct { - mock *MockAPI -} - -// NewMockAPI creates a new mock instance. -func NewMockAPI(ctrl *gomock.Controller) *MockAPI { - mock := &MockAPI{ctrl: ctrl} - mock.recorder = &MockAPIMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockAPI) EXPECT() *MockAPIMockRecorder { - return m.recorder -} - -// SQLAllocHandle mocks base method. -func (m *MockAPI) SQLAllocHandle(handleType api.SQLSMALLINT, inputHandle api.SQLHANDLE, outputHandle *api.SQLHANDLE) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLAllocHandle", handleType, inputHandle, outputHandle) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLAllocHandle indicates an expected call of SQLAllocHandle. -func (mr *MockAPIMockRecorder) SQLAllocHandle(handleType, inputHandle, outputHandle interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLAllocHandle", reflect.TypeOf((*MockAPI)(nil).SQLAllocHandle), handleType, inputHandle, outputHandle) -} - -// SQLBindParameter mocks base method. -func (m *MockAPI) SQLBindParameter(statementHandle api.SQLHSTMT, parameterNumber api.SQLUSMALLINT, inputOutputType, valueType, parameterType api.SQLSMALLINT, columnSize api.SQLULEN, decimalDigits api.SQLSMALLINT, parameterValuePtr api.SQLPOINTER, bufferLength api.SQLLEN, strLenOrIndPtr *api.SQLLEN) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLBindParameter", statementHandle, parameterNumber, inputOutputType, valueType, parameterType, columnSize, decimalDigits, parameterValuePtr, bufferLength, strLenOrIndPtr) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLBindParameter indicates an expected call of SQLBindParameter. -func (mr *MockAPIMockRecorder) SQLBindParameter(statementHandle, parameterNumber, inputOutputType, valueType, parameterType, columnSize, decimalDigits, parameterValuePtr, bufferLength, strLenOrIndPtr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLBindParameter", reflect.TypeOf((*MockAPI)(nil).SQLBindParameter), statementHandle, parameterNumber, inputOutputType, valueType, parameterType, columnSize, decimalDigits, parameterValuePtr, bufferLength, strLenOrIndPtr) -} - -// SQLCancelHandle mocks base method. -func (m *MockAPI) SQLCancelHandle(handleType api.SQLSMALLINT, inputHandle api.SQLHANDLE) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLCancelHandle", handleType, inputHandle) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLCancelHandle indicates an expected call of SQLCancelHandle. -func (mr *MockAPIMockRecorder) SQLCancelHandle(handleType, inputHandle interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLCancelHandle", reflect.TypeOf((*MockAPI)(nil).SQLCancelHandle), handleType, inputHandle) -} - -// SQLCloseCursor mocks base method. -func (m *MockAPI) SQLCloseCursor(statementHandle api.SQLHSTMT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLCloseCursor", statementHandle) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLCloseCursor indicates an expected call of SQLCloseCursor. -func (mr *MockAPIMockRecorder) SQLCloseCursor(statementHandle interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLCloseCursor", reflect.TypeOf((*MockAPI)(nil).SQLCloseCursor), statementHandle) -} - -// SQLDescribeCol mocks base method. -func (m *MockAPI) SQLDescribeCol(statementHandle api.SQLHSTMT, columnNumber api.SQLUSMALLINT, columnName *[]uint16, bufferLength api.SQLSMALLINT, nameLengthPtr, dataTypePtr *api.SQLSMALLINT, columnSizePtr *api.SQLULEN, decimalDigitsPtr, nullablePtr *api.SQLSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLDescribeCol", statementHandle, columnNumber, columnName, bufferLength, nameLengthPtr, dataTypePtr, columnSizePtr, decimalDigitsPtr, nullablePtr) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLDescribeCol indicates an expected call of SQLDescribeCol. -func (mr *MockAPIMockRecorder) SQLDescribeCol(statementHandle, columnNumber, columnName, bufferLength, nameLengthPtr, dataTypePtr, columnSizePtr, decimalDigitsPtr, nullablePtr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLDescribeCol", reflect.TypeOf((*MockAPI)(nil).SQLDescribeCol), statementHandle, columnNumber, columnName, bufferLength, nameLengthPtr, dataTypePtr, columnSizePtr, decimalDigitsPtr, nullablePtr) -} - -// SQLDisconnect mocks base method. -func (m *MockAPI) SQLDisconnect(connectionHandle api.SQLHDBC) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLDisconnect", connectionHandle) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLDisconnect indicates an expected call of SQLDisconnect. -func (mr *MockAPIMockRecorder) SQLDisconnect(connectionHandle interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLDisconnect", reflect.TypeOf((*MockAPI)(nil).SQLDisconnect), connectionHandle) -} - -// SQLDriverConnectW mocks base method. -func (m *MockAPI) SQLDriverConnectW(connectionHandle api.SQLHDBC, windowHandle api.SQLHWND, inConnectionString []uint16, stringLength1 api.SQLSMALLINT, outConnectionString *[]uint16, bufferLength api.SQLSMALLINT, stringLength2Ptr *api.SQLSMALLINT, driverCompletion api.SQLUSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLDriverConnectW", connectionHandle, windowHandle, inConnectionString, stringLength1, outConnectionString, bufferLength, stringLength2Ptr, driverCompletion) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLDriverConnectW indicates an expected call of SQLDriverConnectW. -func (mr *MockAPIMockRecorder) SQLDriverConnectW(connectionHandle, windowHandle, inConnectionString, stringLength1, outConnectionString, bufferLength, stringLength2Ptr, driverCompletion interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLDriverConnectW", reflect.TypeOf((*MockAPI)(nil).SQLDriverConnectW), connectionHandle, windowHandle, inConnectionString, stringLength1, outConnectionString, bufferLength, stringLength2Ptr, driverCompletion) -} - -// SQLEndTran mocks base method. -func (m *MockAPI) SQLEndTran(handleType api.SQLSMALLINT, handle api.SQLHANDLE, completionType api.SQLSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLEndTran", handleType, handle, completionType) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLEndTran indicates an expected call of SQLEndTran. -func (mr *MockAPIMockRecorder) SQLEndTran(handleType, handle, completionType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLEndTran", reflect.TypeOf((*MockAPI)(nil).SQLEndTran), handleType, handle, completionType) -} - -// SQLExecDirect mocks base method. -func (m *MockAPI) SQLExecDirect(statementHandle api.SQLHSTMT, statementText []uint16, textLength api.SQLINTEGER) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLExecDirect", statementHandle, statementText, textLength) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLExecDirect indicates an expected call of SQLExecDirect. -func (mr *MockAPIMockRecorder) SQLExecDirect(statementHandle, statementText, textLength interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLExecDirect", reflect.TypeOf((*MockAPI)(nil).SQLExecDirect), statementHandle, statementText, textLength) -} - -// SQLExecute mocks base method. -func (m *MockAPI) SQLExecute(statementHandle api.SQLHSTMT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLExecute", statementHandle) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLExecute indicates an expected call of SQLExecute. -func (mr *MockAPIMockRecorder) SQLExecute(statementHandle interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLExecute", reflect.TypeOf((*MockAPI)(nil).SQLExecute), statementHandle) -} - -// SQLFetch mocks base method. -func (m *MockAPI) SQLFetch(statementHandle api.SQLHSTMT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLFetch", statementHandle) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLFetch indicates an expected call of SQLFetch. -func (mr *MockAPIMockRecorder) SQLFetch(statementHandle interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLFetch", reflect.TypeOf((*MockAPI)(nil).SQLFetch), statementHandle) -} - -// SQLFreeHandle mocks base method. -func (m *MockAPI) SQLFreeHandle(handleType api.SQLSMALLINT, handle api.SQLHANDLE) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLFreeHandle", handleType, handle) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLFreeHandle indicates an expected call of SQLFreeHandle. -func (mr *MockAPIMockRecorder) SQLFreeHandle(handleType, handle interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLFreeHandle", reflect.TypeOf((*MockAPI)(nil).SQLFreeHandle), handleType, handle) -} - -// SQLFreeStmt mocks base method. -func (m *MockAPI) SQLFreeStmt(statementHandle api.SQLHSTMT, option api.SQLUSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLFreeStmt", statementHandle, option) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLFreeStmt indicates an expected call of SQLFreeStmt. -func (mr *MockAPIMockRecorder) SQLFreeStmt(statementHandle, option interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLFreeStmt", reflect.TypeOf((*MockAPI)(nil).SQLFreeStmt), statementHandle, option) -} - -// SQLGetConnectAttr mocks base method. -func (m *MockAPI) SQLGetConnectAttr(connectionHandle api.SQLHDBC, attribute api.SQLINTEGER, valuePtr api.SQLPOINTER, bufferLength api.SQLINTEGER, stringLengthPtr *api.SQLINTEGER) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLGetConnectAttr", connectionHandle, attribute, valuePtr, bufferLength, stringLengthPtr) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLGetConnectAttr indicates an expected call of SQLGetConnectAttr. -func (mr *MockAPIMockRecorder) SQLGetConnectAttr(connectionHandle, attribute, valuePtr, bufferLength, stringLengthPtr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLGetConnectAttr", reflect.TypeOf((*MockAPI)(nil).SQLGetConnectAttr), connectionHandle, attribute, valuePtr, bufferLength, stringLengthPtr) -} - -// SQLGetData mocks base method. -func (m *MockAPI) SQLGetData(statementHandle api.SQLHSTMT, colOrParamNum api.SQLUSMALLINT, targetType api.SQLSMALLINT, targetValuePtr api.SQLPOINTER, bufferLength api.SQLLEN, strLenOrIndPtr *api.SQLLEN) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLGetData", statementHandle, colOrParamNum, targetType, targetValuePtr, bufferLength, strLenOrIndPtr) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLGetData indicates an expected call of SQLGetData. -func (mr *MockAPIMockRecorder) SQLGetData(statementHandle, colOrParamNum, targetType, targetValuePtr, bufferLength, strLenOrIndPtr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLGetData", reflect.TypeOf((*MockAPI)(nil).SQLGetData), statementHandle, colOrParamNum, targetType, targetValuePtr, bufferLength, strLenOrIndPtr) -} - -// SQLGetDiagRecW mocks base method. -func (m *MockAPI) SQLGetDiagRecW(handleType api.SQLSMALLINT, handle api.SQLHANDLE, recNumber api.SQLSMALLINT, sqlState *[]uint16, nativeErrorPtr *api.SQLINTEGER, messageText *[]uint16, bufferLength api.SQLSMALLINT, textLengthPtr *api.SQLSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLGetDiagRecW", handleType, handle, recNumber, sqlState, nativeErrorPtr, messageText, bufferLength, textLengthPtr) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLGetDiagRecW indicates an expected call of SQLGetDiagRecW. -func (mr *MockAPIMockRecorder) SQLGetDiagRecW(handleType, handle, recNumber, sqlState, nativeErrorPtr, messageText, bufferLength, textLengthPtr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLGetDiagRecW", reflect.TypeOf((*MockAPI)(nil).SQLGetDiagRecW), handleType, handle, recNumber, sqlState, nativeErrorPtr, messageText, bufferLength, textLengthPtr) -} - -// SQLGetInfo mocks base method. -func (m *MockAPI) SQLGetInfo(connectionHandle api.SQLHDBC, infoType api.SQLUSMALLINT, infoValuePtr api.SQLPOINTER, bufferLength api.SQLSMALLINT, stringLengthPtr *api.SQLSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLGetInfo", connectionHandle, infoType, infoValuePtr, bufferLength, stringLengthPtr) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLGetInfo indicates an expected call of SQLGetInfo. -func (mr *MockAPIMockRecorder) SQLGetInfo(connectionHandle, infoType, infoValuePtr, bufferLength, stringLengthPtr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLGetInfo", reflect.TypeOf((*MockAPI)(nil).SQLGetInfo), connectionHandle, infoType, infoValuePtr, bufferLength, stringLengthPtr) -} - -// SQLGetTypeInfo mocks base method. -func (m *MockAPI) SQLGetTypeInfo(statementHandle api.SQLHSTMT, dataType api.SQLSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLGetTypeInfo", statementHandle, dataType) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLGetTypeInfo indicates an expected call of SQLGetTypeInfo. -func (mr *MockAPIMockRecorder) SQLGetTypeInfo(statementHandle, dataType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLGetTypeInfo", reflect.TypeOf((*MockAPI)(nil).SQLGetTypeInfo), statementHandle, dataType) -} - -// SQLNumParams mocks base method. -func (m *MockAPI) SQLNumParams(statementHandle api.SQLHSTMT, parameterCountPtr *api.SQLSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLNumParams", statementHandle, parameterCountPtr) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLNumParams indicates an expected call of SQLNumParams. -func (mr *MockAPIMockRecorder) SQLNumParams(statementHandle, parameterCountPtr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLNumParams", reflect.TypeOf((*MockAPI)(nil).SQLNumParams), statementHandle, parameterCountPtr) -} - -// SQLNumResultCols mocks base method. -func (m *MockAPI) SQLNumResultCols(statementHandle api.SQLHSTMT, columnCountPtr *api.SQLSMALLINT) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLNumResultCols", statementHandle, columnCountPtr) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLNumResultCols indicates an expected call of SQLNumResultCols. -func (mr *MockAPIMockRecorder) SQLNumResultCols(statementHandle, columnCountPtr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLNumResultCols", reflect.TypeOf((*MockAPI)(nil).SQLNumResultCols), statementHandle, columnCountPtr) -} - -// SQLPrepare mocks base method. -func (m *MockAPI) SQLPrepare(statementHandle api.SQLHSTMT, statementText []uint16, textLength api.SQLINTEGER) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLPrepare", statementHandle, statementText, textLength) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLPrepare indicates an expected call of SQLPrepare. -func (mr *MockAPIMockRecorder) SQLPrepare(statementHandle, statementText, textLength interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLPrepare", reflect.TypeOf((*MockAPI)(nil).SQLPrepare), statementHandle, statementText, textLength) -} - -// SQLSetConnectAttrConst mocks base method. -func (m *MockAPI) SQLSetConnectAttrConst(connectionHandle api.SQLHDBC, attribute api.SQLINTEGER, value uint64) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLSetConnectAttrConst", connectionHandle, attribute, value) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLSetConnectAttrConst indicates an expected call of SQLSetConnectAttrConst. -func (mr *MockAPIMockRecorder) SQLSetConnectAttrConst(connectionHandle, attribute, value interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLSetConnectAttrConst", reflect.TypeOf((*MockAPI)(nil).SQLSetConnectAttrConst), connectionHandle, attribute, value) -} - -// SQLSetEnvAttrConst mocks base method. -func (m *MockAPI) SQLSetEnvAttrConst(environmentHandle api.SQLHENV, attribute api.SQLINTEGER, value uint64) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLSetEnvAttrConst", environmentHandle, attribute, value) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLSetEnvAttrConst indicates an expected call of SQLSetEnvAttrConst. -func (mr *MockAPIMockRecorder) SQLSetEnvAttrConst(environmentHandle, attribute, value interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLSetEnvAttrConst", reflect.TypeOf((*MockAPI)(nil).SQLSetEnvAttrConst), environmentHandle, attribute, value) -} - -// SQLSetEnvAttrStr mocks base method. -func (m *MockAPI) SQLSetEnvAttrStr(environmentHandle api.SQLHENV, attribute api.SQLINTEGER, value api.SQLPOINTER, stringLength api.SQLINTEGER) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLSetEnvAttrStr", environmentHandle, attribute, value, stringLength) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLSetEnvAttrStr indicates an expected call of SQLSetEnvAttrStr. -func (mr *MockAPIMockRecorder) SQLSetEnvAttrStr(environmentHandle, attribute, value, stringLength interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLSetEnvAttrStr", reflect.TypeOf((*MockAPI)(nil).SQLSetEnvAttrStr), environmentHandle, attribute, value, stringLength) -} - -// SQLSetStmtAttrConst mocks base method. -func (m *MockAPI) SQLSetStmtAttrConst(stmtHandle api.SQLHSTMT, attribute api.SQLINTEGER, value uint64) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLSetStmtAttrConst", stmtHandle, attribute, value) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLSetStmtAttrConst indicates an expected call of SQLSetStmtAttrConst. -func (mr *MockAPIMockRecorder) SQLSetStmtAttrConst(stmtHandle, attribute, value interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLSetStmtAttrConst", reflect.TypeOf((*MockAPI)(nil).SQLSetStmtAttrConst), stmtHandle, attribute, value) -} - -// SQLSetStmtAttrPointer mocks base method. -func (m *MockAPI) SQLSetStmtAttrPointer(stmtHandle api.SQLHSTMT, attribute api.SQLINTEGER, pointer api.SQLPOINTER) api.SQLRETURN { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SQLSetStmtAttrPointer", stmtHandle, attribute, pointer) - ret0, _ := ret[0].(api.SQLRETURN) - return ret0 -} - -// SQLSetStmtAttrPointer indicates an expected call of SQLSetStmtAttrPointer. -func (mr *MockAPIMockRecorder) SQLSetStmtAttrPointer(stmtHandle, attribute, pointer interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SQLSetStmtAttrPointer", reflect.TypeOf((*MockAPI)(nil).SQLSetStmtAttrPointer), stmtHandle, attribute, pointer) -} diff --git a/internal/odbc/column.go b/internal/odbc/column.go index cf0d301..4a1feba 100644 --- a/internal/odbc/column.go +++ b/internal/odbc/column.go @@ -8,7 +8,7 @@ import ( "unicode/utf16" ) -//go:generate mockgen -source=column.go -package odbc -destination column_mock_test.go +//go:generate mockgen -source=column.go -package mocks -destination ../mocks/column.go type Column interface { driver.Valuer Name() string @@ -34,7 +34,7 @@ func (i *columnInfo) Nullable() (nullable bool, ok bool) { return i.nullable == api.SQL_NULLABLE, i.nullable != api.SQL_NULLABLE_UNKNOWN } -type columnFactory func(info *columnInfo, hnd handle) Column +type columnFactory func(info *columnInfo, hnd *handle) Column var registeredColumnFactory = map[api.SQLSMALLINT]columnFactory{} @@ -48,9 +48,9 @@ func registerColumnFactoryForType(column columnFactory, types ...api.SQLSMALLINT } } -func columnsForStatement(h handle, loadColumn columnLoaderFN) (*columnsDetails, error) { +func columnsForStatement(h *handle, loadColumn columnLoaderFN) (*columnsDetails, error) { var columnCount api.SQLSMALLINT - if _, err := h.result(h.api().SQLNumResultCols((api.SQLHSTMT)(h.hnd()), &columnCount)); err != nil { + if _, err := h.result(api.SQLNumResultCols((*api.SQLHSTMT)(h.hnd()), &columnCount)); err != nil { return nil, fmt.Errorf("getting column count: %w", err) } details := &columnsDetails{ @@ -73,14 +73,14 @@ func columnsForStatement(h handle, loadColumn columnLoaderFN) (*columnsDetails, type columnLoaderFN func(i int) (Column, error) -func newColumnLoader(h handle) columnLoaderFN { +func newColumnLoader(h *handle) columnLoaderFN { return func(i int) (Column, error) { info := &columnInfo{columnNumber: api.SQLUSMALLINT(i + 1)} name := make([]uint16, 100) var nameLength api.SQLSMALLINT - _, err := h.result(h.api().SQLDescribeCol((api.SQLHSTMT)(h.hnd()), + _, err := h.result(api.SQLDescribeColW((*api.SQLHSTMT)(h.hnd()), info.columnNumber, - &name, + (*api.SQLWCHAR)(&name[0]), api.SQLSMALLINT(len(name)), &nameLength, &info.dataType, diff --git a/internal/odbc/config.go b/internal/odbc/config.go deleted file mode 100644 index 4244287..0000000 --- a/internal/odbc/config.go +++ /dev/null @@ -1,5 +0,0 @@ -package odbc - -type Config struct { - api odbcAPI -} diff --git a/internal/odbc/connection.go b/internal/odbc/connection.go index f05b67f..d509149 100644 --- a/internal/odbc/connection.go +++ b/internal/odbc/connection.go @@ -1,9 +1,11 @@ package odbc +import "C" import ( "errors" "fmt" "github.com/ninthclowd/unixodbc/internal/api" + "unsafe" ) var ( @@ -28,14 +30,32 @@ const ( ModeDefault = ReadOnlyMode(api.SQL_MODE_DEFAULT) ) -type Connection struct { - handle - env *Environment +//go:generate mockgen -source=connection.go -package mocks -destination ../mocks/connection.go +type Connection interface { + Ping() error + Close() error + SetAutoCommit(autoCommit bool) error + SetReadOnlyMode(readOnly ReadOnlyMode) error + SetIsolationLevel(level IsolationLevel) error + Commit() error + Rollback() error + Statement() (Statement, error) } -func (c *Connection) Ping() error { - var dead api.SQLINTEGER - _, err := c.result(c.api().SQLGetConnectAttr((api.SQLHDBC)(c.hnd()), api.SQL_ATTR_CONNECTION_DEAD, api.SQLPOINTER(&dead), 0, nil)) +var _ Connection = (*connection)(nil) + +type connection struct { + *handle + env *environment +} + +func (c *connection) Ping() error { + var dead api.SQLBIGINT + _, err := c.result(api.SQLGetConnectAttr((*api.SQLHDBC)(c.hnd()), + api.SQL_ATTR_CONNECTION_DEAD, + (*api.SQLPOINTER)(unsafe.Pointer(&dead)), + 0, + nil)) if err != nil { return err } @@ -45,20 +65,20 @@ func (c *Connection) Ping() error { return nil } -func (c *Connection) Close() error { - if _, err := c.result(c.api().SQLDisconnect((api.SQLHDBC)(c.hnd()))); err != nil { +func (c *connection) Close() error { + if _, err := c.result(api.SQLDisconnect((*api.SQLHDBC)(c.hnd()))); err != nil { return fmt.Errorf("disconnecting: %w", err) } return c.free() } -func (c *Connection) Statement() (*Statement, error) { +func (c *connection) Statement() (Statement, error) { hnd, err := c.child(api.SQL_HANDLE_STMT) if err != nil { return nil, fmt.Errorf("unable to alloc new statement: %w", err) } - stmt := &Statement{ + stmt := &statement{ handle: hnd, conn: c, } @@ -70,31 +90,40 @@ func (c *Connection) Statement() (*Statement, error) { return stmt, nil } -func (c *Connection) SetAutoCommit(autoCommit bool) error { +func (c *connection) SetAutoCommit(autoCommit bool) error { val := api.SQL_AUTOCOMMIT_ON if !autoCommit { val = api.SQL_AUTOCOMMIT_OFF } - _, err := c.result(c.api().SQLSetConnectAttrConst((api.SQLHDBC)(c.hnd()), api.SQL_ATTR_AUTOCOMMIT, val)) + _, err := c.result(api.SQLSetConnectAttr((*api.SQLHDBC)(c.hnd()), + api.SQL_ATTR_AUTOCOMMIT, + api.Const(val), + api.SQL_IS_UINTEGER)) return err } -func (c *Connection) SetReadOnlyMode(readOnly ReadOnlyMode) error { - _, err := c.result(c.api().SQLSetConnectAttrConst((api.SQLHDBC)(c.hnd()), api.SQL_ATTR_ACCESS_MODE, uint64(readOnly))) +func (c *connection) SetReadOnlyMode(readOnly ReadOnlyMode) error { + _, err := c.result(api.SQLSetConnectAttr((*api.SQLHDBC)(c.hnd()), + api.SQL_ATTR_ACCESS_MODE, + api.Const(uint64(readOnly)), + api.SQL_IS_UINTEGER)) return err } -func (c *Connection) SetIsolationLevel(level IsolationLevel) error { - _, err := c.result(c.api().SQLSetConnectAttrConst((api.SQLHDBC)(c.hnd()), api.SQL_ATTR_TXN_ISOLATION, uint64(level))) +func (c *connection) SetIsolationLevel(level IsolationLevel) error { + _, err := c.result(api.SQLSetConnectAttr((*api.SQLHDBC)(c.hnd()), + api.SQL_ATTR_TXN_ISOLATION, + api.Const(uint64(level)), + api.SQL_IS_UINTEGER)) return err } -func (c *Connection) Commit() error { - _, err := c.result(c.api().SQLEndTran(api.SQL_HANDLE_DBC, c.hnd(), api.SQL_COMMIT)) +func (c *connection) Commit() error { + _, err := c.result(api.SQLEndTran(api.SQL_HANDLE_DBC, c.hnd(), api.SQL_COMMIT)) return err } -func (c *Connection) Rollback() error { - _, err := c.result(c.api().SQLEndTran(api.SQL_HANDLE_DBC, c.hnd(), api.SQL_ROLLBACK)) +func (c *connection) Rollback() error { + _, err := c.result(api.SQLEndTran(api.SQL_HANDLE_DBC, c.hnd(), api.SQL_ROLLBACK)) return err } diff --git a/internal/odbc/date.go b/internal/odbc/date.go index c6cc4d6..afb3540 100644 --- a/internal/odbc/date.go +++ b/internal/odbc/date.go @@ -5,18 +5,19 @@ import ( "github.com/ninthclowd/unixodbc/internal/api" "reflect" "time" + "unsafe" ) func init() { registerColumnFactoryForType(newDateColumn, api.SQL_TYPE_DATE) } -func newDateColumn(info *columnInfo, hnd handle) Column { +func newDateColumn(info *columnInfo, hnd *handle) Column { return &columnDate{hnd, info} } type columnDate struct { - handle + *handle *columnInfo } @@ -34,8 +35,14 @@ func (c *columnDate) Decimal() (precision int64, scale int64, ok bool) { func (c *columnDate) Value() (driver.Value, error) { var value api.SQL_DATE_STRUCT + defer value.Free() var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_DATE, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_DATE, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { diff --git a/internal/odbc/environment.go b/internal/odbc/environment.go index 865643e..22428df 100644 --- a/internal/odbc/environment.go +++ b/internal/odbc/environment.go @@ -1,5 +1,6 @@ package odbc +import "C" import ( "context" "fmt" @@ -18,60 +19,54 @@ const ( type Version uint64 const ( - Version3_80 = Version(api.SQL_OV_ODBC3_80) - Version3 = Version(api.SQL_OV_ODBC3) - Version2 = Version(api.SQL_OV_ODBC2) + Version380 = Version(api.SQL_OV_ODBC3_80) + Version3 = Version(api.SQL_OV_ODBC3) + Version2 = Version(api.SQL_OV_ODBC2) ) -func NewEnvironment(config *Config) (*Environment, error) { - var capi odbcAPI - if config != nil && config.api != nil { - capi = config.api - } else { - capi = new(api.API) - } - hnd, err := newEnvHandle(capi) +//go:generate mockgen -source=environment.go -package mocks -destination ../mocks/environment.go +type Environment interface { + SetVersion(version Version) error + SetPoolOption(option PoolOption) error + Connect(ctx context.Context, connStr string) (Connection, error) + Close() error +} + +func NewEnvironment() (Environment, error) { + hnd, err := newEnvHandle() if err != nil { return nil, err } - e := &Environment{handle: hnd} + e := &environment{handle: hnd} return e, nil } -type Environment struct { - handle -} +var _ Environment = (*environment)(nil) -func (e *Environment) SetVersion(version Version) error { - _, err := e.result(e.api().SQLSetEnvAttrConst((api.SQLHENV)(e.hnd()), api.SQL_ATTR_ODBC_VERSION, uint64(version))) - return err +type environment struct { + *handle } -func (e *Environment) SetPoolOption(option PoolOption) error { - _, err := e.result(e.api().SQLSetEnvAttrConst((api.SQLHENV)(e.hnd()), api.SQL_ATTR_CONNECTION_POOLING, uint64(option))) +func (e *environment) SetVersion(version Version) error { + + _, err := e.result(api.SQLSetEnvAttr((*api.SQLHENV)(e.hnd()), + api.SQL_ATTR_ODBC_VERSION, + api.Const(uint64(version)), + api.SQL_IS_UINTEGER)) return err } -// SetTraceFile enables unixodbc trace output to the specified file, or disables tracing if the filePath is empty -func (e *Environment) SetTraceFile(filePath string) error { - val := api.SQL_OPT_TRACE_OFF - - if filePath != "" { - val = api.SQL_OPT_TRACE_ON - connStrBytes := []byte(filePath) - _, err := e.result(e.api().SQLSetEnvAttrStr((api.SQLHENV)(e.hnd()), api.SQL_ATTR_TRACEFILE, api.SQLPOINTER(&connStrBytes), api.SQLINTEGER(len(connStrBytes)))) - if err != nil { - return err - } - } - - _, err := e.result(e.api().SQLSetEnvAttrConst((api.SQLHENV)(e.hnd()), api.SQL_ATTR_TRACE, val)) +func (e *environment) SetPoolOption(option PoolOption) error { + _, err := e.result(api.SQLSetEnvAttr((*api.SQLHENV)(e.hnd()), + api.SQL_ATTR_CONNECTION_POOLING, + api.Const(uint64(option)), + api.SQL_IS_UINTEGER)) return err } -func (e *Environment) Connect(ctx context.Context, connStr string) (*Connection, error) { +func (e *environment) Connect(ctx context.Context, connStr string) (Connection, error) { hnd, err := e.child(api.SQL_HANDLE_DBC) if err != nil { return nil, fmt.Errorf("unable to alloc new connection: %w", err) @@ -81,10 +76,10 @@ func (e *Environment) Connect(ctx context.Context, connStr string) (*Connection, connStrBytes := utf16.Encode([]rune(connStr)) - _, err = hnd.result(hnd.api().SQLDriverConnectW( - (api.SQLHDBC)(hnd.hnd()), + _, err = hnd.result(api.SQLDriverConnectW( + (*api.SQLHDBC)(hnd.hnd()), nil, - connStrBytes, + (*api.SQLWCHAR)(&connStrBytes[0]), api.SQLSMALLINT(len(connStrBytes)), nil, 0, @@ -101,10 +96,10 @@ func (e *Environment) Connect(ctx context.Context, connStr string) (*Connection, return nil, err } - return &Connection{handle: hnd, env: e}, nil + return &connection{handle: hnd, env: e}, nil } -func (e *Environment) Close() error { +func (e *environment) Close() error { return e.free() } diff --git a/internal/odbc/environment_test.go b/internal/odbc/environment_test.go deleted file mode 100644 index fee4e3c..0000000 --- a/internal/odbc/environment_test.go +++ /dev/null @@ -1,116 +0,0 @@ -package odbc - -import ( - "context" - "github.com/golang/mock/gomock" - "github.com/ninthclowd/unixodbc/internal/api" - "strings" - "testing" - "time" - "unicode/utf16" -) - -func newTestEnvironment(t *testing.T) (env *Environment, ctrl *gomock.Controller, mockAPI *MockAPI, mockHnd *MockHandle) { - ctrl = gomock.NewController(t) - mockAPI = NewMockAPI(ctrl) - mockHnd = newTestHandle(ctrl, mockAPI) - env = &Environment{handle: mockHnd} - return -} - -func TestEnvironment_Connect_Cancel(t *testing.T) { - env, ctrl, mockAPI, mockHnd := newTestEnvironment(t) - defer ctrl.Finish() - - mockChild := newTestHandle(ctrl, mockAPI) - - mockHnd. - EXPECT(). - child(api.SQLSMALLINT(api.SQL_HANDLE_DBC)). - Return(mockChild, nil) - - wantConnStr := "connection string" - - mockAPI. - EXPECT(). - SQLDriverConnectW( - (api.SQLHDBC)(mockChild.hnd()), - api.SQLHWND(nil), - utf16.Encode([]rune(wantConnStr)), - api.SQLSMALLINT(len(wantConnStr)), - nil, - api.SQLSMALLINT(0), - nil, - api.SQLUSMALLINT(api.SQL_DRIVER_NOPROMPT), - ). - DoAndReturn(func(connectionHandle api.SQLHDBC, windowHandle api.SQLHWND, inConnectionString []uint16, stringLength1 api.SQLSMALLINT, outConnectionString *[]uint16, bufferLength api.SQLSMALLINT, stringLength2Ptr *api.SQLSMALLINT, driverCompletion api.SQLUSMALLINT) api.SQLRETURN { - time.Sleep(10 * time.Millisecond) - return api.SQL_SUCCESS - }) - - mockChild. - EXPECT(). - cancel(). - Return(nil). - Times(1) - - mockChild. - EXPECT(). - free(). - Return(nil). - Times(1) - - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond) - defer cancel() - - if _, gotErr := env.Connect(ctx, wantConnStr); !strings.Contains(gotErr.Error(), context.DeadlineExceeded.Error()) { - t.Fatalf("expected context cancellation but received: %v", gotErr) - } - -} - -func TestEnvironment_Connect(t *testing.T) { - env, ctrl, mockAPI, mockHnd := newTestEnvironment(t) - defer ctrl.Finish() - - mockChild := newTestHandle(ctrl, mockAPI) - - mockHnd. - EXPECT(). - child(api.SQLSMALLINT(api.SQL_HANDLE_DBC)). - Return(mockChild, nil) - - wantConnStr := "connection string" - - mockAPI. - EXPECT(). - SQLDriverConnectW( - (api.SQLHDBC)(mockChild.hnd()), - api.SQLHWND(nil), - utf16.Encode([]rune(wantConnStr)), - api.SQLSMALLINT(len(wantConnStr)), - nil, - api.SQLSMALLINT(0), - nil, - api.SQLUSMALLINT(api.SQL_DRIVER_NOPROMPT), - ). - Return(api.SQLRETURN(api.SQL_SUCCESS)) - - if gotConnection, gotErr := env.Connect(context.Background(), wantConnStr); gotErr != nil { - t.Errorf("expected no error, got: %s", gotErr.Error()) - } else if gotConnection == nil { - t.Errorf("connection was nil") - } -} - -func TestEnvironment_Close(t *testing.T) { - env, ctrl, _, mockHnd := newTestEnvironment(t) - defer ctrl.Finish() - - mockHnd.EXPECT().free().Times(1) - - if gotErr := env.Close(); gotErr != nil { - t.Errorf("expected no error, got: %s", gotErr) - } - -} diff --git a/internal/odbc/errors.go b/internal/odbc/errors.go index 42e2045..46fe045 100644 --- a/internal/odbc/errors.go +++ b/internal/odbc/errors.go @@ -7,10 +7,6 @@ import ( var ( ErrNotImplemented = errors.New("not implemented") - // ErrHandledAllocated = errors.New("handle previously allocated") - - // ErrHandleFreed = errors.New("attempt to double free") - //ErrConnectionDead = errors.New("Connection dead") ) type ErrorMap map[string]error diff --git a/internal/odbc/float32.go b/internal/odbc/float32.go index e11d91e..c390cd2 100644 --- a/internal/odbc/float32.go +++ b/internal/odbc/float32.go @@ -4,18 +4,19 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) func init() { registerColumnFactoryForType(newFloat32Column, api.SQL_REAL) } -func newFloat32Column(info *columnInfo, hnd handle) Column { +func newFloat32Column(info *columnInfo, hnd *handle) Column { return &columnFloat32{hnd, info} } type columnFloat32 struct { - handle + *handle *columnInfo } @@ -31,10 +32,16 @@ func (c *columnFloat32) Decimal() (precision int64, scale int64, ok bool) { return int64(c.columnSize), int64(c.decimalDigits), true } +//go:nocheckptr func (c *columnFloat32) Value() (driver.Value, error) { var value api.SQLREAL var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_FLOAT, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_FLOAT, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { diff --git a/internal/odbc/float64.go b/internal/odbc/float64.go index a2921df..ef946ec 100644 --- a/internal/odbc/float64.go +++ b/internal/odbc/float64.go @@ -4,6 +4,7 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) func init() { @@ -15,12 +16,12 @@ func init() { ) } -func newFloat64Column(info *columnInfo, hnd handle) Column { +func newFloat64Column(info *columnInfo, hnd *handle) Column { return &columnFloat64{hnd, info} } type columnFloat64 struct { - handle + *handle *columnInfo } @@ -39,7 +40,12 @@ func (c *columnFloat64) Decimal() (precision int64, scale int64, ok bool) { func (c *columnFloat64) Value() (driver.Value, error) { var value api.SQLDOUBLE var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_DOUBLE, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_DOUBLE, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { @@ -48,11 +54,16 @@ func (c *columnFloat64) Value() (driver.Value, error) { return float64(value), nil } -func (s *Statement) bindFloat64(index int, value float64) error { - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_DOUBLE, api.SQL_DOUBLE, - 0, 0, - api.SQLPOINTER(&value), - 0, nil)) +func (s *statement) bindFloat64(index int, value float64) error { + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_DOUBLE, + api.SQL_DOUBLE, + 0, + 0, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + nil)) return err } diff --git a/internal/odbc/handle.go b/internal/odbc/handle.go index 5713c6c..14908b5 100644 --- a/internal/odbc/handle.go +++ b/internal/odbc/handle.go @@ -27,7 +27,7 @@ func OpenHandles() int64 { return openHandleCount.Load() } -func cancelHandleOnContext(ctx context.Context, h handle) (done func()) { +func cancelHandleOnContext(ctx context.Context, h *handle) (done func()) { var wg sync.WaitGroup closer := make(chan struct{}, 1) @@ -56,64 +56,48 @@ var errorMap = map[api.SQLRETURN]error{ api.SQL_INVALID_HANDLE: ErrInvalidHandle, } -type handle interface { - result(r api.SQLRETURN) (api.SQLRETURN, error) - hnd() api.SQLHANDLE - hndType() api.SQLSMALLINT - cancel() error - free() error - api() odbcAPI - child(handleType api.SQLSMALLINT) (handle, error) -} - -type handleImpl struct { - cAPI odbcAPI - ptr api.SQLHANDLE +type handle struct { + ptr *api.SQLHANDLE ptrType api.SQLSMALLINT ptrMux sync.RWMutex } -func newEnvHandle(cAPI odbcAPI) (handle, error) { - hnd := &handleImpl{ - cAPI: cAPI, +func newEnvHandle() (*handle, error) { + hnd := &handle{ ptrType: api.SQL_HANDLE_ENV, } - if r := cAPI.SQLAllocHandle(api.SQL_HANDLE_ENV, nil, &hnd.ptr); r == api.SQL_ERROR { + if r := api.SQLAllocHandle(api.SQL_HANDLE_ENV, nil, &hnd.ptr); r == api.SQL_ERROR { return nil, fmt.Errorf("unable to alloc env handle: %d", (int)(r)) } openHandleCount.Add(1) return hnd, nil } -func (h *handleImpl) api() odbcAPI { - return h.cAPI -} - -func (h *handleImpl) hnd() api.SQLHANDLE { +func (h *handle) hnd() *api.SQLHANDLE { h.ptrMux.RLock() defer h.ptrMux.RUnlock() return h.ptr } -func (h *handleImpl) hndType() api.SQLSMALLINT { +func (h *handle) hndType() api.SQLSMALLINT { return h.ptrType } -func (h *handleImpl) cancel() error { - if code := h.cAPI.SQLCancelHandle(h.ptrType, h.hnd()); code != api.SQL_SUCCESS { +func (h *handle) cancel() error { + if code := api.SQLCancelHandle(h.ptrType, h.hnd()); code != api.SQL_SUCCESS { return fmt.Errorf("received code %d when cancelling handle", code) } return nil } -func (h *handleImpl) free() error { +func (h *handle) free() error { h.ptrMux.Lock() defer h.ptrMux.Unlock() if h.ptr == nil { return ErrHandleFreed } - if code := h.cAPI.SQLFreeHandle(h.ptrType, h.ptr); code != api.SQL_SUCCESS { + if code := api.SQLFreeHandle(h.ptrType, h.ptr); code != api.SQL_SUCCESS { return fmt.Errorf("received code %d when freeing handle", code) } openHandleCount.Add(-1) @@ -121,9 +105,9 @@ func (h *handleImpl) free() error { return nil } -func (h *handleImpl) child(handleType api.SQLSMALLINT) (handle, error) { - hnd := &handleImpl{cAPI: h.cAPI, ptrType: handleType} - if _, err := h.result(h.cAPI.SQLAllocHandle(handleType, h.hnd(), &hnd.ptr)); err != nil { +func (h *handle) child(handleType api.SQLSMALLINT) (*handle, error) { + hnd := &handle{ptrType: handleType} + if _, err := h.result(api.SQLAllocHandle(handleType, h.hnd(), &hnd.ptr)); err != nil { return nil, err } openHandleCount.Add(1) @@ -131,7 +115,7 @@ func (h *handleImpl) child(handleType api.SQLSMALLINT) (handle, error) { return hnd, nil } -func (h *handleImpl) result(r api.SQLRETURN) (api.SQLRETURN, error) { +func (h *handle) result(r api.SQLRETURN) (api.SQLRETURN, error) { if err, found := errorMap[r]; found { return r, err } @@ -142,7 +126,7 @@ func (h *handleImpl) result(r api.SQLRETURN) (api.SQLRETURN, error) { } } -func (h *handleImpl) getDiagRecs() ([]*DiagRec, error) { +func (h *handle) getDiagRecs() ([]*DiagRec, error) { records := make([]*DiagRec, 0) for i := 1; ; i++ { var nativeError api.SQLINTEGER @@ -152,11 +136,11 @@ func (h *handleImpl) getDiagRecs() ([]*DiagRec, error) { var msgSize api.SQLSMALLINT recordNumber := api.SQLSMALLINT(i) - ret := h.cAPI.SQLGetDiagRecW(h.ptrType, h.hnd(), + ret := api.SQLGetDiagRecW(h.ptrType, h.hnd(), recordNumber, - &sqlState, + (*api.SQLWCHAR)(&sqlState[0]), &nativeError, - &messageText, + (*api.SQLWCHAR)(&messageText[0]), api.SQLSMALLINT(len(messageText)), &msgSize, ) diff --git a/internal/odbc/handle_mock_test.go b/internal/odbc/handle_mock_test.go deleted file mode 100644 index 01eb432..0000000 --- a/internal/odbc/handle_mock_test.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: handle.go - -// Package odbc is a generated GoMock package. -package odbc - -import ( - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - api "github.com/ninthclowd/unixodbc/internal/api" -) - -// MockHandle is a mock of handle interface. -type MockHandle struct { - ctrl *gomock.Controller - recorder *MockHandleMockRecorder -} - -// MockHandleMockRecorder is the mock recorder for MockHandle. -type MockHandleMockRecorder struct { - mock *MockHandle -} - -// NewMockHandle creates a new mock instance. -func NewMockHandle(ctrl *gomock.Controller) *MockHandle { - mock := &MockHandle{ctrl: ctrl} - mock.recorder = &MockHandleMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockHandle) EXPECT() *MockHandleMockRecorder { - return m.recorder -} - -// api mocks base method. -func (m *MockHandle) api() odbcAPI { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "api") - ret0, _ := ret[0].(odbcAPI) - return ret0 -} - -// api indicates an expected call of api. -func (mr *MockHandleMockRecorder) api() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "api", reflect.TypeOf((*MockHandle)(nil).api)) -} - -// cancel mocks base method. -func (m *MockHandle) cancel() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "cancel") - ret0, _ := ret[0].(error) - return ret0 -} - -// cancel indicates an expected call of cancel. -func (mr *MockHandleMockRecorder) cancel() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "cancel", reflect.TypeOf((*MockHandle)(nil).cancel)) -} - -// child mocks base method. -func (m *MockHandle) child(handleType api.SQLSMALLINT) (handle, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "child", handleType) - ret0, _ := ret[0].(handle) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// child indicates an expected call of child. -func (mr *MockHandleMockRecorder) child(handleType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "child", reflect.TypeOf((*MockHandle)(nil).child), handleType) -} - -// free mocks base method. -func (m *MockHandle) free() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "free") - ret0, _ := ret[0].(error) - return ret0 -} - -// free indicates an expected call of free. -func (mr *MockHandleMockRecorder) free() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "free", reflect.TypeOf((*MockHandle)(nil).free)) -} - -// hnd mocks base method. -func (m *MockHandle) hnd() api.SQLHANDLE { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "hnd") - ret0, _ := ret[0].(api.SQLHANDLE) - return ret0 -} - -// hnd indicates an expected call of hnd. -func (mr *MockHandleMockRecorder) hnd() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "hnd", reflect.TypeOf((*MockHandle)(nil).hnd)) -} - -// hndType mocks base method. -func (m *MockHandle) hndType() api.SQLSMALLINT { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "hndType") - ret0, _ := ret[0].(api.SQLSMALLINT) - return ret0 -} - -// hndType indicates an expected call of hndType. -func (mr *MockHandleMockRecorder) hndType() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "hndType", reflect.TypeOf((*MockHandle)(nil).hndType)) -} - -// result mocks base method. -func (m *MockHandle) result(r api.SQLRETURN) (api.SQLRETURN, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "result", r) - ret0, _ := ret[0].(api.SQLRETURN) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// result indicates an expected call of result. -func (mr *MockHandleMockRecorder) result(r interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "result", reflect.TypeOf((*MockHandle)(nil).result), r) -} diff --git a/internal/odbc/handle_test.go b/internal/odbc/handle_test.go deleted file mode 100644 index a174e4a..0000000 --- a/internal/odbc/handle_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package odbc - -import ( - "errors" - "github.com/golang/mock/gomock" - "github.com/ninthclowd/unixodbc/internal/api" -) - -func newTestHandle(ctrl *gomock.Controller, mockAPI *MockAPI) (mockHnd *MockHandle) { - var hnd = api.SQLHANDLE(new(string)) - mockHnd = NewMockHandle(ctrl) - mockHnd.EXPECT().api().Return(mockAPI).AnyTimes() - mockHnd.EXPECT().result(api.SQLRETURN(api.SQL_SUCCESS)).Return(api.SQLRETURN(api.SQL_SUCCESS), nil).AnyTimes() - mockHnd.EXPECT().result(api.SQLRETURN(api.SQL_ERROR)).Return(api.SQLRETURN(api.SQL_ERROR), errors.New("mock error")).AnyTimes() - mockHnd.EXPECT().hnd().Return(hnd).AnyTimes() - return -} diff --git a/internal/odbc/int16.go b/internal/odbc/int16.go index 82ea369..302be5e 100644 --- a/internal/odbc/int16.go +++ b/internal/odbc/int16.go @@ -4,18 +4,19 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) func init() { registerColumnFactoryForType(newInt16Column, api.SQL_SMALLINT) } -func newInt16Column(info *columnInfo, hnd handle) Column { +func newInt16Column(info *columnInfo, hnd *handle) Column { return &columnInt16{hnd, info} } type columnInt16 struct { - handle + *handle *columnInfo } @@ -34,7 +35,12 @@ func (c *columnInt16) Decimal() (precision int64, scale int64, ok bool) { func (c *columnInt16) Value() (driver.Value, error) { var value api.SQLSMALLINT var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_SSHORT, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_SSHORT, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { @@ -43,11 +49,17 @@ func (c *columnInt16) Value() (driver.Value, error) { return int16(value), nil } -func (s *Statement) bindInt16(index int, value int16) error { - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_SSHORT, api.SQL_SMALLINT, - 0, 0, - api.SQLPOINTER(&value), - 0, nil)) +//go:nocheckptr +func (s *statement) bindInt16(index int, value int16) error { + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_SSHORT, + api.SQL_SMALLINT, + 0, + 0, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + nil)) return err } diff --git a/internal/odbc/int32.go b/internal/odbc/int32.go index 5d208ec..c58f2e2 100644 --- a/internal/odbc/int32.go +++ b/internal/odbc/int32.go @@ -4,18 +4,19 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) func init() { registerColumnFactoryForType(newInt32Column, api.SQL_INTEGER) } -func newInt32Column(info *columnInfo, hnd handle) Column { +func newInt32Column(info *columnInfo, hnd *handle) Column { return &columnInt32{hnd, info} } type columnInt32 struct { - handle + *handle *columnInfo } @@ -32,22 +33,30 @@ func (c *columnInt32) Decimal() (precision int64, scale int64, ok bool) { } func (c *columnInt32) Value() (driver.Value, error) { - var value api.SQLINTEGER + var value api.SQLBIGINT var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_SLONG, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_SLONG, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { return nil, nil } - return int32(value), nil + return value, nil } -func (s *Statement) bindInt32(index int, value int32) error { - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, +//go:nocheckptr +func (s *statement) bindInt32(index int, value int32) error { + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, api.SQL_C_SLONG, api.SQL_INTEGER, 0, 0, - api.SQLPOINTER(&value), + (*api.SQLPOINTER)(unsafe.Pointer(&value)), 0, nil)) return err } diff --git a/internal/odbc/int64.go b/internal/odbc/int64.go index 3f3ac33..9398550 100644 --- a/internal/odbc/int64.go +++ b/internal/odbc/int64.go @@ -4,18 +4,19 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) func init() { registerColumnFactoryForType(newInt64Column, api.SQL_BIGINT) } -func newInt64Column(info *columnInfo, hnd handle) Column { +func newInt64Column(info *columnInfo, hnd *handle) Column { return &columnInt64{hnd, info} } type columnInt64 struct { - handle + *handle *columnInfo } @@ -34,7 +35,10 @@ func (c *columnInt64) Decimal() (precision int64, scale int64, ok bool) { func (c *columnInt64) Value() (driver.Value, error) { var value api.SQLBIGINT var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_SBIGINT, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), c.columnNumber, api.SQL_C_SBIGINT, + + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { @@ -43,11 +47,16 @@ func (c *columnInt64) Value() (driver.Value, error) { return int64(value), nil } -func (s *Statement) bindInt64(index int, value int64) error { - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_SBIGINT, api.SQL_BIGINT, - 0, 0, - api.SQLPOINTER(&value), - 0, nil)) +func (s *statement) bindInt64(index int, value int64) error { + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_SBIGINT, + api.SQL_BIGINT, + 0, + 0, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + nil)) return err } diff --git a/internal/odbc/int8.go b/internal/odbc/int8.go index 0aaa6fe..04aae99 100644 --- a/internal/odbc/int8.go +++ b/internal/odbc/int8.go @@ -4,18 +4,19 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) func init() { registerColumnFactoryForType(newInt8Column, api.SQL_TINYINT) } -func newInt8Column(info *columnInfo, hnd handle) Column { +func newInt8Column(info *columnInfo, hnd *handle) Column { return &columnInt8{hnd, info} } type columnInt8 struct { - handle + *handle *columnInfo } @@ -34,7 +35,12 @@ func (c *columnInt8) Decimal() (precision int64, scale int64, ok bool) { func (c *columnInt8) Value() (driver.Value, error) { var value api.SQLSCHAR var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_STINYINT, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_STINYINT, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { @@ -43,11 +49,17 @@ func (c *columnInt8) Value() (driver.Value, error) { return int8(value), nil } -func (s *Statement) bindInt8(index int, value int8) error { - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_STINYINT, api.SQL_TINYINT, - 0, 0, - api.SQLPOINTER(&value), - 0, nil)) +//go:nocheckptr +func (s *statement) bindInt8(index int, value int8) error { + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_STINYINT, + api.SQL_TINYINT, + 0, + 0, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + nil)) return err } diff --git a/internal/odbc/recordset.go b/internal/odbc/recordset.go index 99a943f..e634d58 100644 --- a/internal/odbc/recordset.go +++ b/internal/odbc/recordset.go @@ -5,12 +5,25 @@ import ( "reflect" ) -type RecordSet struct { - stmt *Statement +//go:generate mockgen -source=recordset.go -package mocks -destination ../mocks/recordset.go +type RecordSet interface { + Close() error + Statement() Statement + Fetch() (more bool, err error) + Unmarshal(out interface{}) error + ColumnWithName(name string) Column + Column(index int) Column + ColumnNames() []string +} + +var _ RecordSet = (*recordSet)(nil) + +type recordSet struct { + stmt *statement columns *columnsDetails } -func (rs *RecordSet) Close() error { +func (rs *recordSet) Close() error { if err := rs.stmt.closeCursor(); err != nil { return fmt.Errorf("closing cursor: %w", err) } @@ -19,15 +32,15 @@ func (rs *RecordSet) Close() error { return nil } -func (rs *RecordSet) Statement() *Statement { +func (rs *recordSet) Statement() Statement { return rs.stmt } -func (rs *RecordSet) Fetch() (more bool, err error) { +func (rs *recordSet) Fetch() (more bool, err error) { return rs.stmt.fetch() } -func (rs *RecordSet) Unmarshal(out interface{}) error { +func (rs *recordSet) Unmarshal(out interface{}) error { configStruct, ok := out.(reflect.Value) if !ok { configStruct = reflect.ValueOf(out).Elem() @@ -59,7 +72,10 @@ func (rs *RecordSet) Unmarshal(out interface{}) error { if dbVal.CanConvert(propType) { dbVal = dbVal.Convert(propType) } else { - return fmt.Errorf("mapping [%s]: cannot convert database type [%s] to [%s]", property.Name, dbVal.Type().Name(), propType.Name()) + return fmt.Errorf("mapping [%s]: cannot convert database type [%s] to [%s]", + property.Name, + dbVal.Type().Name(), + propType.Name()) } } propVal.Set(dbVal) @@ -68,17 +84,17 @@ func (rs *RecordSet) Unmarshal(out interface{}) error { return nil } -func (rs *RecordSet) ColumnWithName(name string) Column { +func (rs *recordSet) ColumnWithName(name string) Column { if col, ok := rs.columns.byName[name]; ok { return col } return nil } -func (rs *RecordSet) Column(index int) Column { +func (rs *recordSet) Column(index int) Column { return rs.columns.byIndex[index] } -func (rs *RecordSet) ColumnNames() []string { +func (rs *recordSet) ColumnNames() []string { return rs.columns.names } diff --git a/internal/odbc/statement.go b/internal/odbc/statement.go index 222abed..c1c75f9 100644 --- a/internal/odbc/statement.go +++ b/internal/odbc/statement.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "github.com/ninthclowd/unixodbc/internal/api" - "math" "reflect" "time" @@ -29,47 +28,71 @@ const ( ConcurrencyLock = Concurrency(api.SQL_CONCUR_LOCK) ) -type Statement struct { - handle - conn *Connection - rs *RecordSet -} - -func (s *Statement) SetCursorSensitivity(sensitivity CursorSensitivity) error { - _, err := s.result(s.api().SQLSetStmtAttrConst(api.SQLHSTMT(s.hnd()), api.SQL_ATTR_CURSOR_SENSITIVITY, uint64(sensitivity))) +//go:generate mockgen -source=statement.go -package mocks -destination ../mocks/statement.go +type Statement interface { + SetCursorSensitivity(sensitivity CursorSensitivity) error + SetConcurrency(concurrency Concurrency) error + NumParams() (int, error) + ResetParams() error + Close() error + ExecDirect(ctx context.Context, sql string) error + Execute(ctx context.Context) error + Prepare(ctx context.Context, sql string) error + BindParams(params ...interface{}) error + RecordSet() (RecordSet, error) +} + +var _ Statement = (*statement)(nil) + +type statement struct { + *handle + conn *connection + rs *recordSet +} + +func (s *statement) SetCursorSensitivity(sensitivity CursorSensitivity) error { + _, err := s.result(api.SQLSetStmtAttr((*api.SQLHSTMT)(s.hnd()), + api.SQL_ATTR_CURSOR_SENSITIVITY, + api.Const(uint64(sensitivity)), + api.SQL_IS_UINTEGER)) return err } -func (s *Statement) SetConcurrency(concurrency Concurrency) error { - _, err := s.result(s.api().SQLSetStmtAttrConst(api.SQLHSTMT(s.hnd()), api.SQL_ATTR_CONCURRENCY, uint64(concurrency))) +func (s *statement) SetConcurrency(concurrency Concurrency) error { + _, err := s.result(api.SQLSetStmtAttr((*api.SQLHSTMT)(s.hnd()), + api.SQL_ATTR_CONCURRENCY, + api.Const(uint64(concurrency)), + api.SQL_IS_UINTEGER)) return err } -func (s *Statement) NumParams() (int, error) { +func (s *statement) NumParams() (int, error) { var paramCount api.SQLSMALLINT - if _, err := s.result(s.api().SQLNumParams((api.SQLHSTMT)(s.hnd()), ¶mCount)); err != nil { + if _, err := s.result(api.SQLNumParams((*api.SQLHSTMT)(s.hnd()), ¶mCount)); err != nil { return 0, fmt.Errorf("getting Parameter count: %w", err) } return int(paramCount), nil } -func (s *Statement) ResetParams() error { - _, err := s.result(s.api().SQLFreeStmt((api.SQLHSTMT)(s.hnd()), api.SQL_RESET_PARAMS)) +func (s *statement) ResetParams() error { + _, err := s.result(api.SQLFreeStmt((*api.SQLHSTMT)(s.hnd()), api.SQL_RESET_PARAMS)) return err } -func (s *Statement) Close() error { - if _, err := s.result(s.api().SQLFreeStmt((api.SQLHSTMT)(s.hnd()), api.SQL_CLOSE)); err != nil { - return fmt.Errorf("freeing Statement: %w", err) +func (s *statement) Close() error { + if _, err := s.result(api.SQLFreeStmt((*api.SQLHSTMT)(s.hnd()), api.SQL_CLOSE)); err != nil { + return fmt.Errorf("freeing statement: %w", err) } return s.free() } -func (s *Statement) ExecDirect(ctx context.Context, sql string) error { - done := cancelHandleOnContext(ctx, s) +func (s *statement) ExecDirect(ctx context.Context, sql string) error { + done := cancelHandleOnContext(ctx, s.handle) statementBytes := utf16.Encode([]rune(sql)) - _, err := s.result(s.api().SQLExecDirect(api.SQLHSTMT(s.hnd()), statementBytes, api.SQLINTEGER(len(statementBytes)))) + _, err := s.result(api.SQLExecDirectW((*api.SQLHSTMT)(s.hnd()), + (*api.SQLWCHAR)(&statementBytes[0]), + api.SQLINTEGER(len(statementBytes)))) done() if err == nil { err = ctx.Err() @@ -77,9 +100,9 @@ func (s *Statement) ExecDirect(ctx context.Context, sql string) error { return err } -func (s *Statement) Execute(ctx context.Context) error { - done := cancelHandleOnContext(ctx, s) - _, err := s.result(s.api().SQLExecute(api.SQLHSTMT(s.hnd()))) +func (s *statement) Execute(ctx context.Context) error { + done := cancelHandleOnContext(ctx, s.handle) + _, err := s.result(api.SQLExecute((*api.SQLHSTMT)(s.hnd()))) done() if err == nil { err = ctx.Err() @@ -87,11 +110,13 @@ func (s *Statement) Execute(ctx context.Context) error { return err } -func (s *Statement) Prepare(ctx context.Context, sql string) error { - done := cancelHandleOnContext(ctx, s) +func (s *statement) Prepare(ctx context.Context, sql string) error { + done := cancelHandleOnContext(ctx, s.handle) statementBytes := utf16.Encode([]rune(sql)) - _, err := s.result(s.api().SQLPrepare(api.SQLHSTMT(s.hnd()), statementBytes, api.SQLINTEGER(len(statementBytes)))) + _, err := s.result(api.SQLPrepareW((*api.SQLHSTMT)(s.hnd()), + (*api.SQLWCHAR)(&statementBytes[0]), + api.SQLINTEGER(len(statementBytes)))) done() if err == nil { err = ctx.Err() @@ -99,7 +124,7 @@ func (s *Statement) Prepare(ctx context.Context, sql string) error { return err } -func (s *Statement) RecordSet() (*RecordSet, error) { +func (s *statement) RecordSet() (RecordSet, error) { if s.rs != nil { return nil, ErrRecordSetOpen } @@ -108,20 +133,20 @@ func (s *Statement) RecordSet() (*RecordSet, error) { return nil, err } - s.rs = &RecordSet{stmt: s, columns: col} + s.rs = &recordSet{stmt: s, columns: col} return s.rs, nil } -func (s *Statement) closeCursor() error { - if _, err := s.result(s.api().SQLCloseCursor((api.SQLHSTMT)(s.hnd()))); err != nil { +func (s *statement) closeCursor() error { + if _, err := s.result(api.SQLCloseCursor((*api.SQLHSTMT)(s.hnd()))); err != nil { return fmt.Errorf("closing cursor: %w", err) } s.rs = nil return nil } -func (s *Statement) fetch() (more bool, err error) { - if code, err := s.result(s.api().SQLFetch((api.SQLHSTMT)(s.hnd()))); err != nil { +func (s *statement) fetch() (more bool, err error) { + if code, err := s.result(api.SQLFetch((*api.SQLHSTMT)(s.hnd()))); err != nil { return false, err } else if code == api.SQL_NO_DATA { return false, nil @@ -129,7 +154,7 @@ func (s *Statement) fetch() (more bool, err error) { return true, nil } -func (s *Statement) BindParams(params ...interface{}) error { +func (s *statement) BindParams(params ...interface{}) error { for i, param := range params { if err := s.bindParam(i, param); err != nil { return err @@ -138,7 +163,7 @@ func (s *Statement) BindParams(params ...interface{}) error { return nil } -func (s *Statement) bindParam(index int, value interface{}) error { +func (s *statement) bindParam(index int, value interface{}) error { value = compressInt(value) //TODO, benchmark don't switch on non int types switch value.(type) { case nil: @@ -167,13 +192,18 @@ func (s *Statement) bindParam(index int, value interface{}) error { } } -func (s *Statement) bindNil(index int) error { +func (s *statement) bindNil(index int) error { strLenOrIndPtr := api.SQLLEN(api.SQL_NULL_DATA) - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_CHAR, api.SQL_CHAR, - 1, 0, + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_CHAR, + api.SQL_CHAR, + 1, + 0, nil, - 0, &strLenOrIndPtr)) + 0, + &strLenOrIndPtr)) return err } diff --git a/internal/odbc/statement_test.go b/internal/odbc/statement_test.go deleted file mode 100644 index 2e18e41..0000000 --- a/internal/odbc/statement_test.go +++ /dev/null @@ -1,205 +0,0 @@ -package odbc - -import ( - "context" - "errors" - "github.com/golang/mock/gomock" - "github.com/ninthclowd/unixodbc/internal/api" - "strings" - "testing" - "time" - "unicode/utf16" -) - -func newTestStatement(t *testing.T) (stmt *Statement, ctrl *gomock.Controller, mockAPI *MockAPI, mockHnd *MockHandle) { - ctrl = gomock.NewController(t) - mockAPI = NewMockAPI(ctrl) - mockHnd = newTestHandle(ctrl, mockAPI) - stmt = &Statement{ - handle: mockHnd, - conn: nil, - rs: nil, - } - return -} - -func TestStatement_Close(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - mockAPI.EXPECT().SQLFreeStmt(api.SQLHSTMT(mockHnd.hnd()), api.SQLUSMALLINT(api.SQL_CLOSE)).Return(api.SQLRETURN(api.SQL_SUCCESS)) - mockHnd.EXPECT().free().Return(nil) - - if gotErr := stmt.Close(); gotErr != nil { - t.Fatalf("expected no error but got: %v", gotErr) - } -} - -func TestStatement_Close_Err(t *testing.T) { - stmt, ctrl, mockAPI, _ := newTestStatement(t) - defer ctrl.Finish() - - mockAPI.EXPECT().SQLFreeStmt(gomock.Any(), gomock.Any()).Return(api.SQLRETURN(api.SQL_ERROR)) - - if gotErr := stmt.Close(); gotErr == nil { - t.Fatal("expected an error but received none") - } -} - -func TestStatement_ResetParams(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - mockAPI.EXPECT().SQLFreeStmt(api.SQLHSTMT(mockHnd.hnd()), api.SQLUSMALLINT(api.SQL_RESET_PARAMS)).Return(api.SQLRETURN(api.SQL_SUCCESS)) - - if gotErr := stmt.ResetParams(); gotErr != nil { - t.Fatalf("expected no error but got: %v", gotErr) - } -} - -func TestStatement_ResetParams_Err(t *testing.T) { - stmt, ctrl, mockAPI, _ := newTestStatement(t) - defer ctrl.Finish() - - mockAPI.EXPECT().SQLFreeStmt(gomock.Any(), gomock.Any()).Return(api.SQLRETURN(api.SQL_ERROR)) - - if gotErr := stmt.ResetParams(); gotErr == nil { - t.Fatal("expected an error but received none") - } -} - -func TestStatement_NumParams(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - wantNum := 2 - - mockAPI.EXPECT().SQLNumParams(api.SQLHSTMT(mockHnd.hnd()), gomock.Any()).DoAndReturn(func(hnd api.SQLHSTMT, paramCountPtr *api.SQLSMALLINT) api.SQLRETURN { - *paramCountPtr = api.SQLSMALLINT(wantNum) - return api.SQL_SUCCESS - }) - - if gotNum, gotErr := stmt.NumParams(); gotErr != nil { - t.Fatalf("expected no error but got: %v", gotErr) - } else if gotNum != wantNum { - t.Fatalf("expected params to be %d but got %d", wantNum, gotNum) - } -} - -func TestStatement_NumParams_Err(t *testing.T) { - stmt, ctrl, mockAPI, _ := newTestStatement(t) - defer ctrl.Finish() - - mockAPI.EXPECT().SQLNumParams(gomock.Any(), gomock.Any()).Return(api.SQLRETURN(api.SQL_ERROR)) - if _, gotErr := stmt.NumParams(); gotErr == nil { - t.Fatal("expected an error but received none") - } -} - -func TestStatement_Execute(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond) - defer cancel() - - mockAPI.EXPECT().SQLExecute(api.SQLHSTMT(mockHnd.hnd())).Return(api.SQLRETURN(api.SQL_SUCCESS)) - - if gotErr := stmt.Execute(ctx); gotErr != nil { - t.Fatalf("expected no error but got: %v", gotErr) - } -} - -func TestStatement_Execute_Cancel(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - mockAPI.EXPECT().SQLExecute(api.SQLHSTMT(mockHnd.hnd())).DoAndReturn(func(hnd api.SQLHSTMT) api.SQLRETURN { - time.Sleep(10 * time.Millisecond) - return api.SQL_SUCCESS - }) - - mockHnd.EXPECT().cancel().Return(nil).Times(1) - - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond) - defer cancel() - - if gotErr := stmt.Execute(ctx); !errors.Is(gotErr, context.DeadlineExceeded) { - t.Fatalf("expected context cancellation but received: %v", gotErr) - } -} - -func TestStatement_ExecDirect(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - sql := "SELECT 1" - unicodeSQL := utf16.Encode([]rune(sql)) - - mockAPI.EXPECT().SQLExecDirect(api.SQLHSTMT(mockHnd.hnd()), unicodeSQL, api.SQLINTEGER(len(sql))).Return(api.SQLRETURN(api.SQL_SUCCESS)) - - if gotErr := stmt.ExecDirect(context.Background(), sql); gotErr != nil { - t.Fatalf("expected no error but got: %v", gotErr) - } -} - -func TestStatement_ExecDirect_Cancel(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - sql := "SELECT 1" - - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond) - defer cancel() - - mockAPI.EXPECT().SQLExecDirect(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(hnd api.SQLHSTMT, sql []uint16, l api.SQLINTEGER) api.SQLRETURN { - time.Sleep(10 * time.Millisecond) - return api.SQL_SUCCESS - }) - - mockHnd.EXPECT().cancel().Return(nil).Times(1) - - if gotErr := stmt.ExecDirect(ctx, sql); !strings.Contains(gotErr.Error(), context.DeadlineExceeded.Error()) { - t.Fatalf("expected context cancellation but received: %v", gotErr) - } - -} - -func TestStatement_Prepare(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - sql := "SELECT 1" - unicodeSQL := utf16.Encode([]rune(sql)) - - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond) - defer cancel() - - mockAPI.EXPECT().SQLPrepare(api.SQLHSTMT(mockHnd.hnd()), unicodeSQL, api.SQLINTEGER(len(sql))).Return(api.SQLRETURN(api.SQL_SUCCESS)) - - if gotErr := stmt.Prepare(ctx, sql); gotErr != nil { - t.Fatalf("expected no error but got: %v", gotErr) - } -} - -func TestStatement_Prepare_Cancel(t *testing.T) { - stmt, ctrl, mockAPI, mockHnd := newTestStatement(t) - defer ctrl.Finish() - - sql := "SELECT 1" - - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond) - defer cancel() - - mockAPI.EXPECT().SQLPrepare(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(hnd api.SQLHSTMT, sql []uint16, l api.SQLINTEGER) api.SQLRETURN { - time.Sleep(10 * time.Millisecond) - return api.SQL_SUCCESS - }) - - mockHnd.EXPECT().cancel().Return(nil) - - if gotErr := stmt.Prepare(ctx, sql); !strings.Contains(gotErr.Error(), context.DeadlineExceeded.Error()) { - t.Fatalf("expected context cancellation but received: %v", gotErr) - } - -} diff --git a/internal/odbc/testdata/column.golden b/internal/odbc/testdata/column.golden deleted file mode 100644 index 0fe1641..0000000 --- a/internal/odbc/testdata/column.golden +++ /dev/null @@ -1,11 +0,0 @@ -# Generated by goldga. DO NOT EDIT. -[snapshots] -"Column Tests newColumnLoader should return an error if no column factory is registered for the data type" = ''' -"no factory registered for column [foo] type [555]" -''' -"Columns loadColumn should return an error if no column factory is registered for the data type" = ''' -"no factory registered for column [foo] type [555]" -''' -"Columns newColumnLoader should return an error if no column factory is registered for the data type" = ''' -"no factory registered for column [foo] type [555]" -''' diff --git a/internal/odbc/testdata/statement.golden b/internal/odbc/testdata/statement.golden deleted file mode 100644 index adabded..0000000 --- a/internal/odbc/testdata/statement.golden +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by goldga. DO NOT EDIT. -[snapshots] -"Statement loadColumn should return an error if no column factory is registered for the data type" = ''' -"no factory registered for column [foo] type [555]" -''' -"Statement newColumn should return an error if no column factory is registered for the data type" = ''' -"no factory registered for column [foo] type [555]" -''' diff --git a/internal/odbc/time.go b/internal/odbc/time.go index ac30efa..1f00e2a 100644 --- a/internal/odbc/time.go +++ b/internal/odbc/time.go @@ -5,6 +5,7 @@ import ( "github.com/ninthclowd/unixodbc/internal/api" "reflect" "time" + "unsafe" ) func init() { @@ -14,12 +15,12 @@ func init() { ) } -func newTimeColumn(info *columnInfo, hnd handle) Column { +func newTimeColumn(info *columnInfo, hnd *handle) Column { return &columnTime{hnd, info} } type columnTime struct { - handle + *handle *columnInfo } @@ -37,8 +38,14 @@ func (c *columnTime) Decimal() (precision int64, scale int64, ok bool) { func (c *columnTime) Value() (driver.Value, error) { var value api.SQL_TIME_STRUCT + defer value.Free() var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_TIME, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_TIME, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { diff --git a/internal/odbc/timestamp.go b/internal/odbc/timestamp.go index b6cf7c9..0f98cd5 100644 --- a/internal/odbc/timestamp.go +++ b/internal/odbc/timestamp.go @@ -12,12 +12,12 @@ func init() { registerColumnFactoryForType(newTimestampColumn, api.SQL_TYPE_TIMESTAMP) } -func newTimestampColumn(info *columnInfo, hnd handle) Column { +func newTimestampColumn(info *columnInfo, hnd *handle) Column { return &columnTimestamp{hnd, info} } type columnTimestamp struct { - handle + *handle *columnInfo } @@ -35,8 +35,14 @@ func (c *columnTimestamp) Decimal() (precision int64, scale int64, ok bool) { func (c *columnTimestamp) Value() (driver.Value, error) { var value api.SQL_TIMESTAMP_STRUCT + defer value.Free() var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_TIMESTAMP, api.SQLPOINTER(&value), 0, &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_TIMESTAMP, + (*api.SQLPOINTER)(unsafe.Pointer(&value)), + 0, + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { @@ -45,7 +51,7 @@ func (c *columnTimestamp) Value() (driver.Value, error) { return time.Date(int(value.Year), time.Month(value.Month), int(value.Day), int(value.Hour), int(value.Minute), int(value.Second), int(value.Fraction), time.UTC), nil } -func (s *Statement) bindTimestamp(index int, value *time.Time) error { +func (s *statement) bindTimestamp(index int, value *time.Time) error { ts := api.SQL_TIMESTAMP_STRUCT{ Year: api.SQLSMALLINT(value.Year()), Month: api.SQLUSMALLINT(value.Month()), @@ -55,12 +61,19 @@ func (s *Statement) bindTimestamp(index int, value *time.Time) error { Second: api.SQLUSMALLINT(value.Second()), Fraction: api.SQLUINTEGER(value.Nanosecond()), } + defer ts.Free() sz := unsafe.Sizeof(ts) - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_TIMESTAMP, api.SQL_TYPE_TIMESTAMP, - api.SQLULEN(sz), 0, - api.SQLPOINTER(&ts), - 0, nil)) + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_TIMESTAMP, + api.SQL_TYPE_TIMESTAMP, + api.SQLULEN(sz), + 0, + (*api.SQLPOINTER)(unsafe.Pointer(&ts)), + 0, + nil)) + return err } diff --git a/internal/odbc/typeinfo.go b/internal/odbc/typeinfo.go deleted file mode 100644 index 561f49f..0000000 --- a/internal/odbc/typeinfo.go +++ /dev/null @@ -1,45 +0,0 @@ -package odbc - -import "github.com/ninthclowd/unixodbc/internal/api" - -type TypeInfo struct { - DataType api.SQLINTEGER `col_name:"DATA_TYPE"` - ColumnSize api.SQLULEN `col_name:"COLUMN_SIZE"` - //TypeName string `col_name:"TYPE_NAME"` - //LiteralPrefix string `col_name:"LITERAL_PREFIX"` - //LiteralSuffix string `col_name:"LITERAL_SUFFIX"` - //CreateParams string `col_name:"CREATE_PARAMS"` - //Nullable api.SQLSMALLINT `col_name:"NULLABLE"` - //IsCaseSensitive api.SQLUINTEGER `col_name:"CASE_SENSITIVE"` - //Searchable api.SQLSMALLINT `col_name:"SEARCHABLE"` - //IsUnsigned api.SQLUINTEGER `col_name:"UNSIGNED_ATTRIBUTE"` - //FixedPrecisionAndScale api.SQLUINTEGER `col_name:"FIXED_PREC_SCALE"` - //IsAutoIncrementing api.SQLUINTEGER `col_name:"AUTO_UNIQUE_VALUE"` - //LocalTypeName string `col_name:"LOCAL_TYPE_NAME"` - //MinimumScale api.SQLSMALLINT `col_name:"MINIMUM_SCALE"` - //MaximumScale api.SQLSMALLINT `col_name:"MAXIMUM_SCALE"` - //SqlDataType api.SQLINTEGER `col_name:"SQL_DATA_TYPE"` - //DateTimeSubCode api.SQLSMALLINT `col_name:"SQL_DATETIME_SUB"` - //NumPrecRadix api.SQLINTEGER `col_name:"NUM_PREC_RADIX"` - //IntervalPrecision api.SQLSMALLINT `col_name:"INTERVAL_PRECISION"` -} - -type TableType string - -var ( - TypeTable TableType = "TABLE" - TypeView TableType = "VIEW" - TypeSysTable TableType = "SYSTEM TABLE" - TypeGlobalTemp TableType = "GLOBAL TEMPORARY" - TypeLocalTemp TableType = "LOCAL TEMPORARY" - TypeAlias TableType = "ALIAS" - TypeSynonym TableType = "SYNONYM" -) - -type TableInfo struct { - Catalog *string `col_name:"TABLE_CAT"` - Schema *string `col_name:"TABLE_SCHEM"` - Name string `col_name:"TABLE_NAME"` - Type TableType `col_name:"TABLE_TYPE"` - Remarks string `col_name:"REMARKS"` -} diff --git a/internal/odbc/utf16.go b/internal/odbc/utf16.go index 6b1ee3b..42b30da 100644 --- a/internal/odbc/utf16.go +++ b/internal/odbc/utf16.go @@ -1,5 +1,6 @@ package odbc +import "C" import ( "database/sql/driver" "encoding/binary" @@ -17,12 +18,12 @@ func init() { ) } -func newUTF16Column(info *columnInfo, hnd handle) Column { +func newUTF16Column(info *columnInfo, hnd *handle) Column { return &columnUTF16{hnd, info} } type columnUTF16 struct { - handle + *handle *columnInfo } @@ -38,11 +39,17 @@ func (c *columnUTF16) Decimal() (precision int64, scale int64, ok bool) { return } +//go:nocheckptr func (c *columnUTF16) Value() (driver.Value, error) { utfLength := c.columnSize * 2 value := make([]byte, utfLength+1) var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_WCHAR, api.SQLPOINTER(&value[0]), api.SQLLEN(len(value)), &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_WCHAR, + (*api.SQLPOINTER)(unsafe.Pointer(&value[0])), + api.SQLLEN(len(value)), + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { @@ -53,7 +60,8 @@ func (c *columnUTF16) Value() (driver.Value, error) { return str, nil } -func (s *Statement) bindUTF16(index int, src string) error { +//go:nocheckptr +func (s *statement) bindUTF16(index int, src string) error { nts := make([]rune, len(src)+1) for i, r := range src { nts[i] = r @@ -61,11 +69,16 @@ func (s *Statement) bindUTF16(index int, src string) error { val := utf16.Encode(nts) sz := unsafe.Sizeof(val) - _, err := s.result(s.api().SQLBindParameter((api.SQLHSTMT)(s.hnd()), api.SQLUSMALLINT(index+1), api.SQL_PARAM_INPUT, - api.SQL_C_WCHAR, api.SQLSMALLINT(api.SQL_WVARCHAR), - api.SQLULEN(sz), 0, - api.SQLPOINTER(&val[0]), - 0, nil)) + _, err := s.result(api.SQLBindParameter((*api.SQLHSTMT)(s.hnd()), + api.SQLUSMALLINT(index+1), + api.SQL_PARAM_INPUT, + api.SQL_C_WCHAR, + api.SQLSMALLINT(api.SQL_WVARCHAR), + api.SQLULEN(sz), + 0, + (*api.SQLPOINTER)(unsafe.Pointer(&val[0])), + 0, + nil)) return err } diff --git a/internal/odbc/utf8.go b/internal/odbc/utf8.go index b8a360d..844c21b 100644 --- a/internal/odbc/utf8.go +++ b/internal/odbc/utf8.go @@ -4,6 +4,7 @@ import ( "database/sql/driver" "github.com/ninthclowd/unixodbc/internal/api" "reflect" + "unsafe" ) func init() { @@ -14,12 +15,12 @@ func init() { ) } -func newUTF8Column(info *columnInfo, hnd handle) Column { +func newUTF8Column(info *columnInfo, hnd *handle) Column { return &columnUTF8{hnd, info} } type columnUTF8 struct { - handle + *handle *columnInfo } @@ -35,10 +36,16 @@ func (c *columnUTF8) Decimal() (precision int64, scale int64, ok bool) { return } +//go:nocheckptr func (c *columnUTF8) Value() (driver.Value, error) { - value := make([]byte, c.columnSize+1) + value := make([]uint8, c.columnSize+1) var valueLength api.SQLLEN - if _, err := c.result(c.api().SQLGetData(api.SQLHSTMT(c.hnd()), c.columnNumber, api.SQL_C_CHAR, api.SQLPOINTER(&value[0]), api.SQLLEN(len(value)), &valueLength)); err != nil { + if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()), + c.columnNumber, + api.SQL_C_CHAR, + (*api.SQLPOINTER)(unsafe.Pointer(&value[0])), + api.SQLLEN(len(value)), + &valueLength)); err != nil { return nil, err } if valueLength == api.SQL_NULL_DATA { diff --git a/result_test.go b/result_test.go new file mode 100644 index 0000000..e86f15f --- /dev/null +++ b/result_test.go @@ -0,0 +1,16 @@ +package unixodbc + +import "testing" + +func TestResult(t *testing.T) { + r := result{ + lastInsertId: 0, + rowsAffected: 0, + } + if got, _ := r.LastInsertId(); got != r.lastInsertId { + t.Errorf("r.LastInsertId() = %v, want %v", got, r.lastInsertId) + } + if got, _ := r.RowsAffected(); got != r.rowsAffected { + t.Errorf("r.RowsAffected() = %v, want %v", got, r.rowsAffected) + } +} diff --git a/rows.go b/rows.go index 5c41abf..e29fada 100644 --- a/rows.go +++ b/rows.go @@ -19,8 +19,8 @@ var _ driver.RowsColumnTypePrecisionScale = (*Rows)(nil) type Rows struct { ctx context.Context - odbcRecordset *odbc.RecordSet - closeStmtOnRSClose *odbc.Statement + odbcRecordset odbc.RecordSet + closeStmtOnRSClose odbc.Statement } // ColumnTypePrecisionScale implements driver.RowsColumnTypePrecisionScale @@ -29,12 +29,6 @@ func (r *Rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok b } -//// ColumnTypeDatabaseTypeName implements RowsColumnTypeDatabaseTypeName -//func (r *Rows) ColumnTypeDatabaseTypeName(index int) string { -// col := r.odbcRecordset.Column(index) -// return col.TypeName -//} - // ColumnTypeScanType implements driver.RowsColumnTypeScanType func (r *Rows) ColumnTypeScanType(index int) reflect.Type { return r.odbcRecordset.Column(index).ScanType() @@ -84,7 +78,7 @@ func (r *Rows) Next(dest []driver.Value) error { } errs := make(MultipleErrors) - for i, _ := range dest { + for i := range dest { col := r.odbcRecordset.Column(i) Tracer.WithRegion(r.ctx, "Scanning column "+col.Name(), func() { dest[i], errs[col.Name()] = col.Value() @@ -93,4 +87,4 @@ func (r *Rows) Next(dest []driver.Value) error { return errs.Error() } -//TODO: is it possible to paginate with SQLExtendedFetch and the go sql driver +//TODO(ninthclowd): is it possible to paginate with SQLExtendedFetch and the go sql driver diff --git a/rows_test.go b/rows_test.go new file mode 100644 index 0000000..056c2e8 --- /dev/null +++ b/rows_test.go @@ -0,0 +1,169 @@ +package unixodbc + +import ( + "context" + "database/sql/driver" + "errors" + "github.com/golang/mock/gomock" + "github.com/ninthclowd/unixodbc/internal/mocks" + "io" + "reflect" + "testing" +) + +func testRows(t *testing.T) (ctrl *gomock.Controller, rows *Rows, mockRS *mocks.MockRecordSet, mockStmt *mocks.MockStatement, ctx context.Context) { + ctrl = gomock.NewController(t) + + ctx = context.Background() + mockRS = mocks.NewMockRecordSet(ctrl) + mockStmt = mocks.NewMockStatement(ctrl) + rows = &Rows{ + ctx: ctx, + odbcRecordset: mockRS, + closeStmtOnRSClose: mockStmt, + } + return +} + +func TestRows_ColumnTypePrecisionScale(t *testing.T) { + ctrl, rows, mockRS, _, _ := testRows(t) + defer ctrl.Finish() + + wantPrecision := int64(1) + wantOk := true + wantScale := int64(10) + + mockCol := mocks.NewMockColumn(ctrl) + mockCol.EXPECT().Decimal().Return(wantPrecision, wantScale, wantOk).Times(1) + mockRS.EXPECT().Column(1).Return(mockCol) + gotPrecision, gotScale, gotOk := rows.ColumnTypePrecisionScale(1) + if gotPrecision != wantPrecision { + t.Errorf("got precision %v, want %v", gotPrecision, wantPrecision) + } + if gotOk != wantOk { + t.Errorf("got ok %v, want %v", gotOk, wantOk) + } + if gotScale != wantScale { + t.Errorf("got scale %v, want %v", gotScale, wantScale) + } + +} + +func TestRows_ColumnTypeScanType(t *testing.T) { + ctrl, rows, mockRS, _, _ := testRows(t) + defer ctrl.Finish() + + wantScanType := reflect.TypeOf("string") + + mockCol := mocks.NewMockColumn(ctrl) + mockCol.EXPECT().ScanType().Return(wantScanType).Times(1) + mockRS.EXPECT().Column(1).Return(mockCol) + gotScanType := rows.ColumnTypeScanType(1) + if gotScanType != wantScanType { + t.Errorf("got scanType %v, want %v", gotScanType, wantScanType) + } +} + +func TestRows_ColumnTypeNullable(t *testing.T) { + ctrl, rows, mockRS, _, _ := testRows(t) + defer ctrl.Finish() + + wantNullable := true + wantNullableOk := true + + mockCol := mocks.NewMockColumn(ctrl) + mockCol.EXPECT().Nullable().Return(wantNullable, wantNullableOk).Times(1) + mockRS.EXPECT().Column(1).Return(mockCol) + gotNullable, gotNullableOk := rows.ColumnTypeNullable(1) + if gotNullable != wantNullable { + t.Errorf("got nullable %v, want %v", gotNullable, wantNullable) + } + if gotNullableOk != wantNullableOk { + t.Errorf("got nullable ok %v, want %v", gotNullableOk, wantNullableOk) + } +} + +func TestRows_ColumnTypeLength(t *testing.T) { + ctrl, rows, mockRS, _, _ := testRows(t) + defer ctrl.Finish() + + wantLength := int64(10) + wantLengthOk := true + + mockCol := mocks.NewMockColumn(ctrl) + mockCol.EXPECT().VariableLength().Return(wantLength, wantLengthOk).Times(1) + mockRS.EXPECT().Column(1).Return(mockCol) + gotLength, gotLengthOk := rows.ColumnTypeLength(1) + if gotLength != wantLength { + t.Errorf("got length %v, want %v", gotLength, wantLength) + } + if gotLengthOk != wantLengthOk { + t.Errorf("got length ok %v, want %v", gotLengthOk, wantLengthOk) + } +} + +func TestRows_Columns(t *testing.T) { + ctrl, rows, mockRS, _, _ := testRows(t) + defer ctrl.Finish() + + wantColumns := []string{"one", "two"} + + mockRS.EXPECT().ColumnNames().Return(wantColumns) + gotColumns := rows.Columns() + if !reflect.DeepEqual(gotColumns, wantColumns) { + t.Errorf("got columns %v, want %v", gotColumns, wantColumns) + } +} + +func TestRows_Close(t *testing.T) { + ctrl, rows, mockRS, mockStmt, _ := testRows(t) + defer ctrl.Finish() + + mockRS.EXPECT().Close().Return(nil).Times(1) + mockStmt.EXPECT().Close().Return(nil).Times(1) + gotErr := rows.Close() + if gotErr != nil { + t.Errorf("expected no error, got %v", gotErr) + } +} + +func TestRows_Next(t *testing.T) { + ctrl, rows, mockRS, _, _ := testRows(t) + defer ctrl.Finish() + + cols := []string{"col1", "col2"} + wantVal1 := int64(10) + wantVal2 := "stringVal" + + mockCol1 := mocks.NewMockColumn(ctrl) + mockCol1.EXPECT().Name().Return(cols[0]).AnyTimes() + mockCol1.EXPECT().Value().Return(wantVal1, nil).AnyTimes() + mockRS.EXPECT().Column(0).Return(mockCol1).AnyTimes() + + mockCol2 := mocks.NewMockColumn(ctrl) + mockCol2.EXPECT().Name().Return(cols[1]).AnyTimes() + mockCol2.EXPECT().Value().Return(wantVal2, nil).AnyTimes() + mockRS.EXPECT().Column(1).Return(mockCol2).AnyTimes() + + mockRS.EXPECT().Fetch().Return(true, nil).Times(1) + + gotRow1 := make([]driver.Value, 2) + gotRow1Err := rows.Next(gotRow1) + if gotRow1Err != nil { + t.Fatalf("expected no error, got %v", gotRow1Err) + } + if gotRow1[0] != wantVal1 { + t.Errorf("got value 1 %v, want %v", gotRow1[0], wantVal1) + } + if gotRow1[1] != wantVal2 { + t.Errorf("got value 2 %v, want %v", gotRow1[1], wantVal2) + } + + mockRS.EXPECT().Fetch().Return(false, nil).Times(1) + + gotRow2Err := rows.Next([]driver.Value{}) + if !errors.Is(gotRow2Err, io.EOF) { + t.Fatalf("expected EOF on second fetch got %v", gotRow2Err) + } + +} diff --git a/statement.go b/statement.go index f3c8729..f66bca8 100644 --- a/statement.go +++ b/statement.go @@ -13,20 +13,15 @@ var ( ) type PreparedStatement struct { - odbcStatement *odbc.Statement + odbcStatement odbc.Statement query string conn *Connection - rows *Rows numInput int } // Close implements driver.Stmt func (s *PreparedStatement) Close() error { errs := make(MultipleErrors) - if s.rows != nil { //TODO is this check needed? will the driver always close rows before the statement - errs["closing recordset"] = s.rows.Close() - s.rows = nil - } errs["cache"] = s.conn.cachedStatements.Put(s.query, s) return errs.Error() } @@ -43,7 +38,7 @@ func (s *PreparedStatement) Exec(args []driver.Value) (driver.Result, error) { // ExecContext implements driver.StmtExecContext func (s *PreparedStatement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) { - ctx, trace := Tracer.NewTask(ctx, "Statement::ExecContext") + ctx, trace := Tracer.NewTask(ctx, "statement::ExecContext") defer trace.End() var err error Tracer.WithRegion(ctx, "BindParams", func() { @@ -68,7 +63,7 @@ func (s *PreparedStatement) Query(args []driver.Value) (driver.Rows, error) { // QueryContext implements driver.StmtQueryContext func (s *PreparedStatement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) { - ctx, trace := Tracer.NewTask(ctx, "Statement::QueryContext") + ctx, trace := Tracer.NewTask(ctx, "statement::QueryContext") defer trace.End() var err error Tracer.WithRegion(ctx, "BindParams", func() { @@ -84,8 +79,8 @@ func (s *PreparedStatement) QueryContext(ctx context.Context, args []driver.Name return nil, err } - var rs *odbc.RecordSet - Tracer.WithRegion(ctx, "RecordSet", func() { + var rs odbc.RecordSet + Tracer.WithRegion(ctx, "recordSet", func() { rs, err = s.odbcStatement.RecordSet() }) if err != nil { diff --git a/statement_test.go b/statement_test.go new file mode 100644 index 0000000..9fc1fe6 --- /dev/null +++ b/statement_test.go @@ -0,0 +1,91 @@ +package unixodbc + +import ( + "context" + "database/sql/driver" + "github.com/golang/mock/gomock" + "github.com/ninthclowd/unixodbc/internal/cache" + "github.com/ninthclowd/unixodbc/internal/mocks" + "reflect" + "testing" +) + +func testStatement(t *testing.T) (ctrl *gomock.Controller, stmt *PreparedStatement, mockStmt *mocks.MockStatement) { + ctrl = gomock.NewController(t) + mockStmt = mocks.NewMockStatement(ctrl) + mockConn := mocks.NewMockConnection(ctrl) + conn := &Connection{ + odbcConnection: mockConn, + cachedStatements: cache.NewLRU[PreparedStatement](1, onCachePurged), + } + stmt = &PreparedStatement{ + odbcStatement: mockStmt, + query: "SELECT * FROM foo WHERE bar = ?", + conn: conn, + numInput: 1, + } + return +} + +func TestPreparedStatement_QueryContext(t *testing.T) { + ctrl, stmt, mockStmt := testStatement(t) + defer ctrl.Finish() + + ctx := context.Background() + + mockRS := mocks.NewMockRecordSet(ctrl) + mockStmt.EXPECT().NumParams().Return(1, nil).AnyTimes() + mockStmt.EXPECT().BindParams("value").Return(nil).AnyTimes() + mockStmt.EXPECT().Execute(gomock.Any()).Return(nil) + mockStmt.EXPECT().RecordSet().Return(mockRS, nil) + + rs, err := stmt.QueryContext(ctx, []driver.NamedValue{{ + Name: "", + Ordinal: 1, + Value: "value", + }}) + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + rows, ok := rs.(*Rows) + if !ok { + t.Fatalf("expected Rows, got %v", reflect.TypeOf(rs)) + } + if rows.odbcRecordset != mockRS { + t.Errorf("expected recordset to be set on Rows, got %v", rows.odbcRecordset) + } + if gotNumInput := stmt.NumInput(); gotNumInput != 1 { + t.Errorf("expected 1 input, got %v", gotNumInput) + } + if err := stmt.Close(); err != nil { + t.Errorf("expected no error closing rows, got %v", rows.Close()) + } + +} + +func TestPreparedStatement_ExecContext(t *testing.T) { + ctrl, stmt, mockStmt := testStatement(t) + defer ctrl.Finish() + + ctx := context.Background() + + mockStmt.EXPECT().NumParams().Return(1, nil).AnyTimes() + mockStmt.EXPECT().BindParams("value").Return(nil).AnyTimes() + mockStmt.EXPECT().Execute(gomock.Any()).Return(nil) + + res, err := stmt.ExecContext(ctx, []driver.NamedValue{{ + Name: "", + Ordinal: 1, + Value: "value", + }}) + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + if lastInsertId, _ := res.LastInsertId(); lastInsertId != 0 { + t.Errorf("expected LastInsertId to be 0, got %v", lastInsertId) + } + if rowsAffected, _ := res.RowsAffected(); rowsAffected != 0 { + t.Errorf("expected RowsAffected to be 0, got %v", rowsAffected) + } + +} diff --git a/test/acceptance/mariadb/connection_test.go b/test/acceptance/mariadb/connection_test.go index bfdee29..eb5f5fa 100644 --- a/test/acceptance/mariadb/connection_test.go +++ b/test/acceptance/mariadb/connection_test.go @@ -30,8 +30,8 @@ func newTestConnection(t *testing.T) (db *sql.DB, conn *sql.Conn, ctx context.Co finish = func() { cancel() - conn.Close() - db.Close() + _ = conn.Close() + _ = db.Close() if count := unixodbc.OpenHandles(); count > 0 { t.Fatalf("%d open ODBC handles", count) } diff --git a/test/acceptance/mariadb/container/Dockerfile b/test/acceptance/mariadb/container/Dockerfile index 806f452..1fafd64 100644 --- a/test/acceptance/mariadb/container/Dockerfile +++ b/test/acceptance/mariadb/container/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20-bookworm as base +FROM golang:1.21-bookworm as base RUN apt update RUN apt-get install -y libssl-dev unixodbc-dev unixodbc odbcinst odbc-mariadb diff --git a/test/acceptance/mariadb/statement_test.go b/test/acceptance/mariadb/statement_test.go index 01bee16..3a10d12 100644 --- a/test/acceptance/mariadb/statement_test.go +++ b/test/acceptance/mariadb/statement_test.go @@ -17,7 +17,7 @@ func newTestStatement(t *testing.T) (stmt *sql.Stmt, ctx context.Context, finish t.Fatalf("expected no error from PrepareContext, got: %s", err.Error()) } finish = func() { - stmt.Close() + _ = stmt.Close() done() } return diff --git a/test/acceptance/mssql/connection_test.go b/test/acceptance/mssql/connection_test.go index 743fb43..54af215 100644 --- a/test/acceptance/mssql/connection_test.go +++ b/test/acceptance/mssql/connection_test.go @@ -30,8 +30,8 @@ func newTestConnection(t *testing.T) (db *sql.DB, conn *sql.Conn, ctx context.Co finish = func() { cancel() - conn.Close() - db.Close() + _ = conn.Close() + _ = db.Close() if count := unixodbc.OpenHandles(); count > 0 { t.Fatalf("%d open ODBC handles", count) } diff --git a/test/acceptance/mssql/statement_test.go b/test/acceptance/mssql/statement_test.go index 01bee16..3a10d12 100644 --- a/test/acceptance/mssql/statement_test.go +++ b/test/acceptance/mssql/statement_test.go @@ -17,7 +17,7 @@ func newTestStatement(t *testing.T) (stmt *sql.Stmt, ctx context.Context, finish t.Fatalf("expected no error from PrepareContext, got: %s", err.Error()) } finish = func() { - stmt.Close() + _ = stmt.Close() done() } return diff --git a/test/acceptance/postgres/connection_test.go b/test/acceptance/postgres/connection_test.go index 924189e..6bd3d60 100644 --- a/test/acceptance/postgres/connection_test.go +++ b/test/acceptance/postgres/connection_test.go @@ -30,8 +30,8 @@ func newTestConnection(t *testing.T) (db *sql.DB, conn *sql.Conn, ctx context.Co finish = func() { cancel() - conn.Close() - db.Close() + _ = conn.Close() + _ = db.Close() if count := unixodbc.OpenHandles(); count > 0 { t.Fatalf("%d open ODBC handles", count) } diff --git a/test/acceptance/postgres/statement_test.go b/test/acceptance/postgres/statement_test.go index b7148d7..fd60948 100644 --- a/test/acceptance/postgres/statement_test.go +++ b/test/acceptance/postgres/statement_test.go @@ -17,7 +17,7 @@ func newTestStatement(t *testing.T) (stmt *sql.Stmt, ctx context.Context, finish t.Fatalf("expected no error from PrepareContext, got: %s", err.Error()) } finish = func() { - stmt.Close() + _ = stmt.Close() done() } return diff --git a/tx_test.go b/tx_test.go new file mode 100644 index 0000000..a8e9b35 --- /dev/null +++ b/tx_test.go @@ -0,0 +1,63 @@ +package unixodbc + +import ( + "context" + "database/sql" + "github.com/ninthclowd/unixodbc/internal/odbc" + "testing" +) + +func TestTX_Commit(t *testing.T) { + ctrl, conn, mockConn := testDBConnection(t, 0) + defer ctrl.Finish() + + ctx := context.Background() + + mockConn.EXPECT().SetIsolationLevel(odbc.LevelReadCommitted).Return(nil).Times(1) + mockConn.EXPECT().SetReadOnlyMode(odbc.ModeReadOnly).Return(nil).Times(1) + mockConn.EXPECT().SetAutoCommit(false).Return(nil).Times(1) + + tx, err := conn.BeginTx(ctx, &sql.TxOptions{ + Isolation: sql.LevelReadCommitted, + ReadOnly: true, + }) + if err != nil { + t.Fatalf("expected no error preparing statement, got %v", err) + } + + mockConn.EXPECT().Commit().Return(nil).Times(1) + mockConn.EXPECT().SetAutoCommit(true).Return(nil).Times(1) + + gotErr := tx.Commit() + if gotErr != nil { + t.Fatalf("expected no error, got %v", gotErr) + } + +} + +func TestTX_Rollback(t *testing.T) { + ctrl, conn, mockConn := testDBConnection(t, 0) + defer ctrl.Finish() + + ctx := context.Background() + + mockConn.EXPECT().SetIsolationLevel(odbc.LevelReadCommitted).Return(nil).Times(1) + mockConn.EXPECT().SetReadOnlyMode(odbc.ModeReadOnly).Return(nil).Times(1) + mockConn.EXPECT().SetAutoCommit(false).Return(nil).Times(1) + + tx, err := conn.BeginTx(ctx, &sql.TxOptions{ + Isolation: sql.LevelReadCommitted, + ReadOnly: true, + }) + if err != nil { + t.Fatalf("expected no error preparing statement, got %v", err) + } + + mockConn.EXPECT().SetAutoCommit(true).Return(nil).Times(1) + mockConn.EXPECT().Rollback().Return(nil).Times(1) + gotErr := tx.Rollback() + if gotErr != nil { + t.Fatalf("expected no error, got %v", gotErr) + } + +}