Module my
This is a main module of Erlang MySQL client.
Copyright © 2010-2014 Alexei Krasnopolski
Version: 1.2.8
Introduced in: 2010-11-05
Behaviours: application, supervisor.
Authors: Alexei Krasnopolski (krasnop@bellsouth.net) [web site: http://krasnopolski.org/].
References
This is a main module of Erlang MySQL client. The module implements application behaviour of the client and
is a supervisor for set of datasource.
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.
- 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.
}).
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.
}).
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.
}).
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.
}).
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.
}).
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.
}).
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..
}).
mysql_decimal() = #mysql_decimal{}
represents value of decimal field.
-record(mysql_decimal, {
- int = ""::string()
- - integer part.
- fraction = ""::string()
- - fraction part.
}).
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()
- - .
}).
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.
}).
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.
}).
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.
}).
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.
}).
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.
}).
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.
}).
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.
}).
start_client/0 | The function loads and starts OTP application named 'mysql_client'. |
stop_client/0 | The function stops and unload 'mysql_client' application. |
new_datasource/3 | the function starts new child process registered as DS_name and implements
datasorce (or connection pool) functionality. |
new_datasource/2 | the function starts new child process registered as DS_name and implements
datasorce (or connection pool) functionality. |
new_datasource/1 | the function starts new child process and implements
datasorce (or connection pool) functionality. |
start_client() -> ok | {error, Reason}
The function loads and starts OTP application named 'mysql_client'
stop_client() -> ok | {error, Reason}
The function stops and unload 'mysql_client' application.
new_datasource(DS_name::atom(), DS_def::#datasource{}, Pool_options::[tuple()]) -> Result
- Result = {ok, Pid} | #mysql_error{}
the function starts new child process registered as DS_name and implements
datasorce (or connection pool) functionality. The datasource process is controlled by
supervisor 'datasource_sup'.
new_datasource(DS_name::atom(), DS_def::#datasource{}) -> Result
- Result = {ok, Pid} | #mysql_error{}
the function starts new child process registered as DS_name and implements
datasorce (or connection pool) functionality. The datasource process is controlled by
supervisor 'datasource_sup'.
new_datasource(DS_def::#datasource{}) -> Result
- Result = {ok, Pid} | #mysql_error{}
the function starts new child process and implements
datasorce (or connection pool) functionality. The datasource process is controlled by
supervisor 'datasource_sup'.
Generated by EDoc