Mssqlex v0.6.2 Mssqlex.Protocol

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.

Summary

Functions

Deallocate a cursor declared by 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 handle_prepare/3. Return {:ok, cursor, state} to start a 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 first result from a cursor declared by handle_declare/4. Return {:ok, result, state} to return the result result and continue, {:deallocate, result, state} to return the result result and deallocate, {:error, exception, state} to return an error and close the cursor, {:disconnect, exception, state} to return an error and disconnect

Handle a message received by the connection process when checked in. Return {:ok, state} to continue or {:disconnect, exception, state} to disconnect

Fetch the next result from a cursor declared by handle_declare/4. Return {:ok, result, state} to return the result result and continue, {:deallocate, result, state} to return the result result and deallocate, {:error, exception, state} to return an error and close the cursor, {:disconnect, exception, state} to return an 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

Types

cursor()
cursor() :: any
params()
params() :: [{:odbc.odbc_data_type, :odbc.value}]
query()
query() :: Mssqlex.Query.t
result()
result() :: Mssqlex.Result.t
state()
state() :: %Mssqlex.Protocol{conn_opts: Keyword.t, mssql: :idle | :transaction | :auto_commit, pid: pid}

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.

Functions

handle_deallocate(, , , state)

Deallocate a cursor declared by 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`](https://hexdocs.pm/db_connection/1.1.1/DBConnection.html#c:handle_deallocate/4).

handle_declare(, , , state)

Declare a cursor using a query prepared by handle_prepare/3. Return {:ok, cursor, state} to start a 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.

handle_first(, , , state)

Fetch the first result from a cursor declared by handle_declare/4. Return {:ok, result, state} to return the result result and continue, {:deallocate, result, state} to return the result result and deallocate, {: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_first/4.

handle_info(, state)

Handle a message received by the connection process when checked in. Return {:ok, state} to continue or {:disconnect, exception, state} to disconnect.

Messages received by the connection process when checked out will be logged and discared.

This callback is called in the connection process.

Callback implementation for DBConnection.handle_info/2.

handle_next(, , , state)

Fetch the next result from a cursor declared by handle_declare/4. Return {:ok, result, state} to return the result result and continue, {:deallocate, result, state} to return the result result and deallocate, {: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_next/4.

ping(state)

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_timeout 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.