Tds.Protocol (Tds v2.3.6)

View Source

Implements DBConnection behaviour for TDS protocol.

Summary

Types

env()

@type env() :: %{
  trans: <<_::8>>,
  savepoint: non_neg_integer(),
  collation: Tds.Protocol.Collation.t(),
  packetsize: integer()
}

packet_data()

@type packet_data() :: binary()

sock()

@type sock() :: {:gen_tcp | :ssl, :gen_tcp.socket() | :ssl.sslsocket()}

state()

@type state() :: :ready | :prelogin | :login | :prepare | :executing

t()

@type t() :: %Tds.Protocol{
  env: env(),
  itcp: term(),
  opts: nil | Keyword.t(),
  query: nil | String.t(),
  result: nil | list(),
  sock: nil | sock(),
  state: state(),
  transaction: transaction(),
  usock: nil | pid()
}

transaction()

@type transaction() :: nil | :started | :successful | :failed

Functions

checkin(s)

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

checkout(s)

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

Callback implementation for DBConnection.checkout/1.

connect(opts)

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

Callback implementation for DBConnection.connect/1.

disconnect(err, s)

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

Callback implementation for DBConnection.disconnect/2.

handle_begin(opts, s)

@spec handle_begin(Keyword.t(), t()) ::
  {:ok, Tds.Result.t(), new_state :: t()}
  | {DBConnection.status(), new_state :: t()}
  | {:disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_begin/2.

handle_close(query, opts, s)

@spec handle_close(Tds.Query.t(), nil | keyword() | map(), t()) ::
  {:ok, Tds.Result.t(), new_state :: t()}
  | {:error | :disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_close/3.

handle_commit(opts, s)

@spec handle_commit(Keyword.t(), t()) ::
  {:ok, Tds.Result.t(), new_state :: t()}
  | {DBConnection.status(), new_state :: t()}
  | {:disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_commit/2.

handle_deallocate(query, cursor, opts, state)

@spec handle_deallocate(
  query :: Tds.Query.t(),
  cursor :: any(),
  opts :: Keyword.t(),
  state :: t()
) ::
  {:ok, Tds.Result.t(), new_state :: t()}
  | {:error | :disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_deallocate/4.

handle_declare(query, params, opts, state)

@spec handle_declare(
  Tds.Query.t(),
  params :: any(),
  opts :: Keyword.t(),
  state :: t()
) ::
  {:ok, Tds.Query.t(), cursor :: any(), new_state :: t()}
  | {:error | :disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_declare/4.

handle_execute(query, params, opts, s)

@spec handle_execute(Tds.Query.t(), DBConnection.params(), Keyword.t(), t()) ::
  {:ok, Tds.Query.t(), Tds.Result.t(), new_state :: t()}
  | {:error | :disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_execute/4.

handle_fetch(query, cursor, opts, state)

@spec handle_fetch(
  Tds.Query.t(),
  cursor :: any(),
  opts :: Keyword.t(),
  state :: t()
) ::
  {:cont | :halt, Tds.Result.t(), new_state :: t()}
  | {:error | :disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_fetch/4.

handle_info(msg, s)

handle_prepare(query, opts, s)

@spec handle_prepare(Tds.Query.t(), Keyword.t(), t()) ::
  {:ok, Tds.Query.t(), new_state :: t()}
  | {:error | :disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_prepare/3.

handle_rollback(opts, s)

@spec handle_rollback(Keyword.t(), t()) ::
  {:ok, Tds.Result.t(), new_state :: t()}
  | {:idle, new_state :: t()}
  | {:disconnect, Exception.t(), new_state :: t()}

Callback implementation for DBConnection.handle_rollback/2.

handle_status(_, state)

@spec handle_status(Keyword.t(), t()) ::
  {:idle | :transaction | :error, t()} | {:disconnect, Exception.t(), t()}

Callback implementation for DBConnection.handle_status/2.

login(s)

message(arg1, arg2, s)

ping(state)

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

Callback implementation for DBConnection.ping/1.

send_close(query, params, s)

send_prelogin(s)

send_prepare(statement, params, s)

send_transaction(command, payload, s)