View Source Tds.Protocol (Tds v2.3.5)

Implements DBConnection behaviour for TDS protocol.

Summary

Types

@type env() :: %{
  trans: <<_::8>>,
  savepoint: non_neg_integer(),
  collation: Tds.Protocol.Collation.t(),
  packetsize: integer()
}
@type packet_data() :: binary()
@type sock() :: {:gen_tcp | :ssl, :gen_tcp.socket() | :ssl.sslsocket()}
@type state() :: :ready | :prelogin | :login | :prepare | :executing
@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()
}
@type transaction() :: nil | :started | :successful | :failed

Functions

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

Callback implementation for DBConnection.checkout/1.

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

Callback implementation for DBConnection.connect/1.

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

Callback implementation for DBConnection.disconnect/2.

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

Link to this function

handle_close(query, opts, s)

View Source
@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.

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

Link to this function

handle_deallocate(query, cursor, opts, state)

View Source
@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.

Link to this function

handle_declare(query, params, opts, state)

View Source
@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.

Link to this function

handle_execute(query, params, opts, s)

View Source
@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.

Link to this function

handle_fetch(query, cursor, opts, state)

View Source
@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.

Link to this function

handle_prepare(query, opts, s)

View Source
@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.

Link to this function

handle_rollback(opts, s)

View Source
@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.

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

Callback implementation for DBConnection.handle_status/2.

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

Callback implementation for DBConnection.ping/1.

Link to this function

send_close(query, params, s)

View Source
Link to this function

send_prepare(statement, params, s)

View Source
Link to this function

send_transaction(command, payload, s)

View Source