%% %% Copyright (C) 2010-2014 by krasnop@bellsouth.net (Alexei Krasnopolski) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. %% You may obtain a copy of the License at %% %% http://www.apache.org/licenses/LICENSE-2.0 %% %% Unless required by applicable law or agreed to in writing, software %% distributed under the License is distributed on an "AS IS" BASIS, %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %% See the License for the specific language governing permissions and %% limitations under the License. %% %% @type server_status() = #server_status{}. The server_status() record contains information about status of SQL server after query.
%% -record(server_status, { %%
%%
inTransaction = false::boolean()
- Transaction has started.
%%
autocommit = false::boolean()
- Server in auto_commit mode.
%%
moreResultExists = false::boolean()
- Multi query - next query exists.
%%
queryNoGoodIndexUsed = false::boolean()
- .
%%
queryNoIndexUsed = false::boolean()
- .
%%
cursorExists = false::boolean()
- read-only non-scrollable cursor for a query was opened.
%%
lastRowSent = false::boolean()
- read-only cursor is exhausted.
%%
noBackSlashEscapes = true::boolean()
- .
%%
queryWasSlow = false::boolean()
- this query was logged to the slow query log.
%%
psOutParams = false::boolean()
- To mark ResultSet containing output parameter values.
%%
%% }). -record(server_status, { inTransaction = false::boolean(), % Transaction has started autocommit = false::boolean(), % Server in auto_commit mode moreResultExists = false::boolean(), % Multi query - next query exists queryNoGoodIndexUsed = false::boolean(), queryNoIndexUsed = false::boolean(), cursorExists = false::boolean(), % read-only non-scrollable cursor for a query was opened lastRowSent = false::boolean(), % read-only cursor is exhausted dbDropped = false::boolean(), % A database was dropped noBackSlashEscapes = true::boolean(), metadataChanged = false::boolean(), % queryWasSlow = false::boolean(), % this query was logged to the slow query log psOutParams = false::boolean() % To mark ResultSet containing output parameter values } ). %% @type client_options() = #client_options{}. The record keeps client options that server is capable to support for this client and this connection.
%% -record(client_options, { %%
%%
charset_number = 33::0..255
- Character set number: default utf-8 (code= 33).
%%
long_password = 1::0|1
- new more secure passwords.
%%
found_rows = 0::0|1
- Found instead of affected rows.
%%
long_flag = 1::0|1
- Get all column flags.
%%
connect_with_db = 1::0|1
- One can specify db on connect.
%%
no_schema = 0::0|1
- Don't allow database.table.column.
%%
compress = 0::0|1
- Can use compression protocol.
%%
odbc = 0::0|1
- Odbc client.
%%
local_files = 0::0|1
- Can use LOAD DATA LOCAL.
%%
ignore_space = 0::0|1
- Ignore spaces before '('.
%%
protocol_41 = 1::0|1
- New 4.1 protocol.
%%
interactive = 1::0|1
- This is an interactive client.
%%
ssl = 0::0|1
- Switch to SSL after handshake.
%%
ignore_sigpipe = 0::0|1
- IGNORE sigpipes.
%%
transactions = 1::0|1
- Client knows about transactions.
%%
reserved = 0::0|1
- Old flag for 4.1 protocol.
%%
secure_connection = 1::0|1
- New 4.1 authentication.
%%
multi_statements = 1::0|1
- Enable/disable multi-stmt support.
%%
multi_results = 1::0|1
- Enable/disable multi-results.
%%
trans_isolation_level = default::read_uncommitted | read_committed | repeatable_read | serializable
%%
- transaction isolation level. %% %%
%%
%% }). -record(client_options, { charset_number = 33::0..255, % Character set number: default utf-8 (code= 33) long_password = 1::0|1, % new more secure passwords found_rows = 0::0|1, % Found instead of affected rows long_flag = 1::0|1, % Get all column flags connect_with_db = 1::0|1, % One can specify db on connect no_schema = 0::0|1, % Don't allow database.table.column compress = 0::0|1, % Can use compression protocol odbc = 0::0|1, % Odbc client local_files = 0::0|1, % Can use LOAD DATA LOCAL ignore_space = 0::0|1, % Ignore spaces before '(' protocol_41 = 1::0|1, % New 4.1 protocol interactive = 1::0|1, % This is an interactive client ssl = 0::0|1, % Switch to SSL after handshake ignore_sigpipe = 0::0|1, % IGNORE sigpipes transactions = 1::0|1, % Client knows about transactions reserved = 0::0|1, % Old flag for 4.1 protocol secure_connection = 1::0|1, % New 4.1 authentication multi_statements = 1::0|1, % Enable/disable multi-stmt support multi_results = 1::0|1, % Enable/disable multi-results trans_isolation_level = default % transaction isolation level :: default | % default isolation level read_uncommitted | % given session can read uncommitted updates of other session read_committed | % given session can read only committed updates of other session repeatable_read | % given session can read only snapshot of committed updates of other session serializable % the same as repeatable read but given session blocks own reads } ). %% @type server_info() = #server_info{}. The server_info() contains information that SQL server sent during handshake about itself. %% -record(server_info, { %%
%%
protocol_version::integer()
- protocol version.
%%
server_version::string()
- server version.
%%
thread_Id::integer()
- current connection thread ID.
%%
server_capabilities::#client_options{}
- server capabilities.
%%
server_status::#server_status{}
- server status.
%%
scramble_buff::binary()
- scrumble buffer for password encryption.
%%
%% }). -record(server_info, { protocol_version::integer(), server_version::string(), thread_Id::integer(), server_capabilities::#client_options{}, server_status::#server_status{}, scramble_buff::binary() } ). %% @type datasource() = #datasource{}. datasource record information describes connections pool. %% The information is using for creating connections of the pool.
%% -record(datasource, { %%
%%
name :: atom()
- datasource name.
%%
host = "localhost" :: string()
- server host name or IP.
%%
port = 3306 :: integer()
- host port number.
%%
database = "" :: string()
- database name.
%%
user :: string()
- user logon name.
%%
password :: string()
- password.
%%
flags = #client_options{} :: #client_options{}
- client options for connections of the datasource.
%%
%% }). -record(datasource, { name :: atom(), host = "localhost" :: string(), port = 3306 :: integer(), database = "" :: string(), user :: string(), password :: string(), flags = #client_options{} :: #client_options{} } ). %% @type connection() = #connection{}. The record keeps information that helps connection server runs.
%% -record(connection, { %%
%%
socket :: port()
- tcp socket linked to MySQL server.
%%
owner :: pid()
- pid of process that borrows this connection from connection pool. undefined if the connection is idle.
%%
ds_def :: #datasource{}
- datasource record.
%%
server_info :: #server_info{}
- server info record.
%%
%% }). -record(connection, { socket :: port(), owner :: pid(), ds_def :: #datasource{}, server_info :: #server_info{} } ). %% @type packet() = #packet{}. represents binary packet for low level network connection.
%% -record(packet, { %%
%%
continue = false::boolean()
- indicates it is not last packet in sequence.
%%
seq_number = 0::integer()
- number of the packet in sequence.
%%
uncompressed_size = 0::integer()
- size of packet before compression.
%%
body = `<<>>'::binary()
- binary body of the packet.
%%
%% }). -record(packet, { continue = false::boolean(), seq_number = 0::integer(), uncompressed_size = 0::integer(), body = <<>>::binary() } ). %% @type ok_packet() = #ok_packet{}. represents OK packet received from server after generic query or command.
%% -record(ok_packet, { %%
%%
affected_rows::integer()
- number affected rows in table(s) during processing query.
%%
insert_id::integer()
- insert query returns generated id for new row.
%%
server_status::#server_status{}
- server status after query.
%%
warning_count::integer()
- number of warnings.
%%
message::string()
- warn/error message.
%%
%% }). -record(ok_packet, { affected_rows::integer(), insert_id::integer(), server_status::#server_status{}, warning_count::integer(), message::string() } ). %% @type ok_stmt_packet() = #ok_stmt_packet{}. represents OK packet received from server after statement prepare command.
%% -record(ok_stmt_packet, { %%
%%
stmt_handle::integer()
- prepared statement handle for using with following commands.
%%
columns_number::integer()
- number of columns in prepared statement.
%%
params_number::integer()
- number of parameters in prepared statement.
%%
warn_count::integer()
- number of warnings.
%%
%% }). -record(ok_stmt_packet, { stmt_handle::integer(), columns_number::integer(), params_number::integer(), warn_count::integer() } ). %% @type error_packet() = #error_packet{}. represents ERROR packet received from server after generic query or command.
%% -record(error_packet, { %%
%%
errno::integer()
- MySQL error number.
%%
sqlstate::string()
- MySQL state identifire.
%%
message::string()
- error message.
%%
%% }). -record(error_packet, { errno::integer(), sqlstate::string(), message::string() } ). %% @type eof_packet() = #eof_packet{}. represents end of file (EOF) packet received from server after generic query or command.
%% -record(eof_packet, { %%
%%
warning_count::integer()
- number of warnings.
%%
server_status::#server_status{}
- server status after query.
%%
%% }). -record(eof_packet, { warning_count::integer(), server_status::#server_status{} } ). %% @type rs_header() = #rs_header{}. represents a header of record set.
%% -record(rs_header, { %%
%%
field_count::integer()
- number of fields in record set.
%%
extra::any()
- extra information.
%%
%% }). -record(rs_header, { field_count::integer(), extra::any() %% TODO is it any, not integer ? } ). %% @type field_metadata() = #field_metadata{}. represents field metadata of record set.
%% -record(field_metadata, { %%
%%
catalog::string()
- catalog name (unused in recent versions).
%%
schema::string()
- schema (database) name.
%%
table::string()
- table name from sql query (after AS).
%%
origtable::string()
- original table name from schema.
%%
name::string()
- field name from sql query (after AS).
%%
origname::string()
- original field name from schema.
%%
charsetnr::integer()
- code of character set.
%%
length::integer()
- length of the field.
%%
type::0..255
- type of the field (see mysql_types.hrl).
%%
flags::bitstring()
- flags (see mysql_types.hrl).
%%
scale::0..255
- scale.
%%
default::binary()
- default value.
%%
%% }). -record(field_metadata, { catalog::string(), schema::string(), table::string(), origtable::string(), name::string(), origname::string(), charsetnr::integer(), length::integer(), type::0..255, flags::bitstring(), scale::0..255, default::binary() } ). %% @type metadata() = #metadata{}. represents metadata of record set.
%% -record(metadata, { %%
%%
field_count=0::integer()
- field count in the query.
%%
param_count=0::integer()
- parameter count in prepared statement.
%%
server_status::#server_status{}
- server status after query.
%%
field_metadata = []::list(#field_metadata{})
- field metadata is a list of metadata %% for each field in the query.
%%
param_metadata = []::list(#field_metadata{})
- parameter metadata is a list of metadata %% for each parameter in the prepared statement..
%%
%% }). -record(metadata, { field_count=0::integer(), param_count=0::integer(), server_status::#server_status{}, field_metadata = []::list(#field_metadata{}), param_metadata = []::list(#field_metadata{}) } ). %% @type mysql_time() = #mysql_time{}. represents value of time/date field.
%% -record(mysql_time, { %%
%%
neg = false::boolean()
- sign of the field.
%%
year = 0::integer()
- year.
%%
month = 0::0..12
- month.
%%
day = 0::0..31
- day of month.
%%
hour = 0::0..23
- hour.
%%
minute = 0::0..59
- minute.
%%
second = 0::0..59
- second.
%%
second_part = 0
- second part.
%%
%% }). -record(mysql_time, { neg = false::boolean(), year = 0::integer(), month = 0::0..12, day = 0::0..31, hour = 0::0..23, minute = 0::0..59, second = 0::0..59, second_part = 0 } ). %% @type mysql_decimal() = #mysql_decimal{}. represents value of decimal field.
%% -record(mysql_decimal, { %%
%%
int = ""::string()
- integer part.
%%
fraction = ""::string()
- fraction part.
%%
%% }). -record(mysql_decimal, { int = []::string(), fraction = []::string() } ). %% @type mysql_error() = #mysql_error{}. Record represents an exception that is thrown by a client's module.
%% -record(mysql_error, { %%
%%
type:: tcp | connection | sqlquery | statement | transaction
- .
%%
errno = none:: none | integer()
- .
%%
sqlstate = []::string()
- .
%%
source = []::string()
- .
%%
message = []::string()
- .
%%
%% }). -record(mysql_error, { type:: tcp | connection | sqlquery | statement | transaction | pooling | datasource, errno = none:: none | integer(), sqlstate = []::string(), source = []::string(), message = []::string() } ).