Mssqlex v2.0.0-beta.0 Mssqlex.Protocol View Source
Implementation of DBConnection
behaviour for Mssqlex.ODBC
.
Handles translation of concepts to what ODBC expects and holds state for a connection.
This module is not called directly, but rather through
other Mssqlex
modules or DBConnection
functions.
Link to this section Summary
Functions
Deallocate a cursor declared by c:handle_declare/4
with the database. Return
{:ok, result, state}
on success and to continue,
{:error, exception, state}
to return an error and continue, or
{:disconnect, exception, state}
to return an error and disconnect.
Declare a cursor using a query prepared by c:handle_prepare/3
. Return
{:ok, query, cursor, state}
to return altered query query
and cursor
cursor
for a stream and continue, {:error, exception, state}
to return an
error and continue or {:disconnect, exception, state}
to return an error
and disconnect.
Fetch the next result from a cursor declared by c:handle_declare/4
. Return
{:cont, result, state}
to return the result result
and continue using
cursor, {:halt, result, state}
to return the result result
and close the
cursor, {:error, exception, state}
to return an error and close the
cursor, {:disconnect, exception, state}
to return an error and disconnect.
Handle getting the transaction status. Return {:idle, state}
if outside a
transaction, {:transaction, state}
if inside a transaction,
{:error, state}
if inside an aborted transaction, or
{:disconnect, exception, state}
to error and disconnect.
Called when the connection has been idle for a period of time. Return
{:ok, state}
to continue or {:disconnect, exception, state}
to
disconnect.
Link to this section Types
Process state.
Includes:
:pid
: the pid of the ODBC process:mssql
: the transaction state. Can be:idle
(not in a transaction),:transaction
(in a transaction) or:auto_commit
(connection in autocommit mode):conn_opts
: the options used to set up the connection.
Link to this section Functions
Deallocate a cursor declared by c:handle_declare/4
with the database. Return
{:ok, result, state}
on success and to continue,
{:error, exception, state}
to return an error and continue, or
{:disconnect, exception, state}
to return an error and disconnect.
This callback is called in the client process.
Callback implementation for DBConnection.handle_deallocate/4
.
Declare a cursor using a query prepared by c:handle_prepare/3
. Return
{:ok, query, cursor, state}
to return altered query query
and cursor
cursor
for a stream and continue, {:error, exception, state}
to return an
error and continue or {:disconnect, exception, state}
to return an error
and disconnect.
This callback is called in the client process.
Callback implementation for DBConnection.handle_declare/4
.
Fetch the next result from a cursor declared by c:handle_declare/4
. Return
{:cont, result, state}
to return the result result
and continue using
cursor, {:halt, result, state}
to return the result result
and close the
cursor, {:error, exception, state}
to return an error and close the
cursor, {:disconnect, exception, state}
to return an error and disconnect.
This callback is called in the client process.
Callback implementation for DBConnection.handle_fetch/4
.
handle_status(_, s)
View Sourcehandle_status(opts(), state()) :: {DBConnection.status(), state()}
Handle getting the transaction status. Return {:idle, state}
if outside a
transaction, {:transaction, state}
if inside a transaction,
{:error, state}
if inside an aborted transaction, or
{:disconnect, exception, state}
to error and disconnect.
If the callback returns a :disconnect
tuples then status/2
will return
:error
.
Callback implementation for DBConnection.handle_status/2
.
ping(state)
View Sourceping(state :: any()) :: {:ok, new_state :: any()} | {:disconnect, Exception.t(), new_state :: any()}
Called when the connection has been idle for a period of time. Return
{:ok, state}
to continue or {:disconnect, exception, state}
to
disconnect.
This callback is called if no callbacks have been called after the
idle timeout and a client process is not using the state. The idle
timeout can be configured by the :idle_interval
option. This function
can be called whether the connection is checked in or checked out.
This callback is called in the connection process.
Callback implementation for DBConnection.ping/1
.