diff --git a/connection.go b/connection.go index 93de20e8..398e557a 100644 --- a/connection.go +++ b/connection.go @@ -26,10 +26,16 @@ import ( ) type conn struct { - id string - cfg *config.Config - client cli_service.TCLIService - session *cli_service.TOpenSessionResp + id string + cfg *config.Config + client cli_service.TCLIService + session *cli_service.TOpenSessionResp + autoCommit bool // Cache autocommit state client-side (default: true) +} + +// tx implements driver.Tx for transaction support +type tx struct { + conn *conn } // Prepare prepares a statement with the query bound to this connection. diff --git a/connector.go b/connector.go index 53908b4c..c0ef12b3 100644 --- a/connector.go +++ b/connector.go @@ -67,10 +67,11 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) { } conn := &conn{ - id: client.SprintGuid(session.SessionHandle.GetSessionId().GUID), - cfg: c.cfg, - client: tclient, - session: session, + id: client.SprintGuid(session.SessionHandle.GetSessionId().GUID), + cfg: c.cfg, + client: tclient, + session: session, + autoCommit: true, // Initialize autocommit cache to true (default state) } log := logger.WithContext(conn.id, driverctx.CorrelationIdFromContext(ctx), "") diff --git a/errors/errors.go b/errors/errors.go index d6a19158..3a41dd09 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -17,6 +17,13 @@ const ( ErrParametersNotSupported = "query parameters are not supported by this server" ErrMixedNamedAndPositionalParameters = "named and positional parameters cannot be used simultaneously" + // Transaction errors + ErrTransactionBegin = "failed to begin transaction" + ErrTransactionCommit = "failed to commit transaction" + ErrTransactionRollback = "failed to rollback transaction" + ErrTransactionNested = "transaction already in progress" + ErrUnsupportedIsolation = "unsupported transaction isolation level" + // Request error messages (connection, authentication, network error) ErrCloseConnection = "failed to close connection" ErrThriftClient = "error initializing thrift client"