View Source Tds.Protocol (Tds v2.3.1)

Implements DBConnection behaviour for TDS protocol.

Link to this section Summary

Link to this section Types

Specs

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

Specs

packet_data() :: binary()

Specs

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

Specs

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

Specs

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()
}

Specs

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

Link to this section Functions

Specs

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

Specs

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

Callback implementation for DBConnection.checkout/1.

Specs

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

Callback implementation for DBConnection.connect/1.

Specs

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

Callback implementation for DBConnection.disconnect/2.

Specs

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

Specs

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.

Specs

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

Specs

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

Specs

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

Specs

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

Specs

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

Specs

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

Specs

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.

Specs

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

Callback implementation for DBConnection.handle_status/2.

Specs

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