View Source Snowpack.Protocol (Snowpack v0.7.5)

Implementation of DBConnection behaviour for Snowpack.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 Snowpack modules or DBConnection functions.

Link to this section Summary

Link to this section Types

@type odbc_data_type() ::
  :sql_integer
  | :sql_smallint
  | :sql_tinyint
  | {:sql_decimal, precision(), scale()}
  | {:sql_numeric, precision(), scale()}
  | {:sql_char, size()}
  | {:sql_wchar, size()}
  | {:sql_varchar, size()}
  | {:sql_wvarchar, size()}
  | {:sql_float, precision()}
  | {:sql_wlongvarchar, size()}
  | {:sql_float, precision()}
  | :sql_real
  | :sql_double
  | :sql_bit
  | atom()
@type opts() :: Keyword.t()
@type params() :: [{odbc_data_type(), value()}]
@type precision() :: integer()
@type query() :: Snowpack.Query.t()
@type result() :: Snowpack.Result.t()
@type scale() :: integer()
@type size() :: integer()
@type state() :: %Snowpack.Protocol{
  conn_opts: Keyword.t(),
  pid: pid(),
  snowflake: :idle
}

Process state.

Includes:

  • :pid: the pid of the ODBC process
  • :snowflake: the transaction state. Can be :idle (not in a transaction).
  • :conn_opts: the options used to set up the connection.
@type status() :: :idle | :error
@type value() :: :null | term()

Link to this section Functions

@spec checkout(state()) :: {:ok, state()} | {:disconnect, Exception.t(), state()}

Callback implementation for DBConnection.checkout/1.

@spec connect(opts()) :: {:ok, state()} | {:error, Exception.t()}

Callback implementation for DBConnection.connect/1.

@spec disconnect(err :: String.t() | Exception.t(), state()) :: :ok

Callback implementation for DBConnection.disconnect/2.

Link to this function

handle_begin(opts, state)

View Source
@spec handle_begin(opts(), state()) ::
  {:ok, result(), state()}
  | {status(), state()}
  | {:disconnect, Exception.t(), state()}

Callback implementation for DBConnection.handle_begin/2.

Link to this function

handle_close(query, opts, state)

View Source
@spec handle_close(query(), opts(), state()) :: {:ok, result(), state()}

Callback implementation for DBConnection.handle_close/3.

Link to this function

handle_commit(opts, state)

View Source
@spec handle_commit(opts(), state()) ::
  {:ok, result(), state()}
  | {status(), state()}
  | {:disconnect, Exception.t(), state()}

Callback implementation for DBConnection.handle_commit/2.

Link to this function

handle_deallocate(query, cursor, opts, state)

View Source
@spec handle_deallocate(any(), any(), any(), any()) :: none()

Callback implementation for DBConnection.handle_deallocate/4.

Link to this function

handle_declare(query, params, opts, state)

View Source
@spec handle_declare(any(), any(), any(), any()) :: none()

Callback implementation for DBConnection.handle_declare/4.

Link to this function

handle_execute(query, params, opts, state)

View Source
@spec handle_execute(query(), params(), opts(), state()) ::
  {:ok, query(), result(), state()}
  | {:error | :disconnect, Exception.t(), state()}

Callback implementation for DBConnection.handle_execute/4.

Link to this function

handle_fetch(query, cursor, opts, state)

View Source
@spec handle_fetch(any(), any(), any(), any()) :: none()

Callback implementation for DBConnection.handle_fetch/4.

Link to this function

handle_first(query, cursor, opts, state)

View Source
@spec handle_first(any(), any(), any(), any()) :: none()
Link to this function

handle_next(query, cursor, opts, state)

View Source
@spec handle_next(any(), any(), any(), any()) :: none()
Link to this function

handle_prepare(query, opts, state)

View Source
@spec handle_prepare(query(), opts(), state()) ::
  {:ok, query(), state()} | {:error | :disconnect, Exception.t(), state()}

Callback implementation for DBConnection.handle_prepare/3.

Link to this function

handle_rollback(opts, state)

View Source
@spec handle_rollback(opts(), state()) ::
  {:ok, result(), state()}
  | {status(), state()}
  | {:disconnect, Exception.t(), state()}

Callback implementation for DBConnection.handle_rollback/2.

@spec handle_status(opts(), state()) :: {DBConnection.status(), state()}

Callback implementation for DBConnection.handle_status/2.

@spec ping(state :: any()) ::
  {:ok, new_state :: any()} | {:disconnect, Exception.t(), new_state :: any()}

Callback implementation for DBConnection.ping/1.