📄 sdmysql.pas
字号:
TMYSQL_ROWS = record
next: PMYSQL_ROWS; // list of rows
data: TMYSQL_ROW;
end;
TMYSQL_ROW_OFFSET = PMYSQL_ROWS; // offset to current row
TMYSQL_DATA = record
Rows: TMyInt64;
Fields: UInt;
Data: PMYSQL_ROWS;
Alloc: TMEM_ROOT;
end;
TMYSQL_OPTIONS_V3 = record
connect_timeout, client_flag: UInt;
compress, named_pipe: TMyBool;
port: Integer;
host, init_command, user, password,
unix_socket, db,
my_cnf_file, my_cnf_group,
charset_dir, charset_name: TSDCharPtr;
use_ssl: TMyBool; // if to use SSL or not
ssl_key, // PEM key file
ssl_cert, // PEM cert file
ssl_ca, // PEM CA file
ssl_capath: TSDCharPtr; // PEM directory of CA-s?
end;
PMYSQL_OPTIONS_V3 = ^TMYSQL_OPTIONS_V3;
TMYSQL_OPTIONS_V4 = record
connect_timeout, client_flag, port: UInt;
host, init_command, user, password,
unix_socket, db,
my_cnf_file, my_cnf_group,
charset_dir, charset_name: TSDCharPtr;
ssl_key, // PEM key file
ssl_cert, // PEM cert file
ssl_ca, // PEM CA file
ssl_capath, // PEM directory of CA-s?
ssl_cipher: TSDCharPtr; // cipher to use
use_ssl: TMyBool; // if to use SSL or not
compress, named_pipe: TMyBool;
rpl_probe, // On connect, find out the replication role of the server, and establish connections to all the peers
rpl_parse, // Each call to mysql_real_query() will parse it to tell if it is a read or a write, and direct it to the slave or the master
no_master_reads: TMyBool; // If set, never read from a master,only from slave, when doing a read that is replication-aware
end;
PMYSQL_OPTIONS_V4 = ^TMYSQL_OPTIONS_V4;
PMYSQL_OPTIONS = Pointer;
TMySqlOption = (
MYSQL_OPT_CONNECT_TIMEOUT,
MYSQL_OPT_COMPRESS,
MYSQL_OPT_NAMED_PIPE,
MYSQL_INIT_COMMAND,
MYSQL_READ_DEFAULT_FILE,
MYSQL_READ_DEFAULT_GROUP,
MYSQL_SET_CHARSET_DIR,
MYSQL_SET_CHARSET_NAME,
MYSQL_OPT_LOCAL_INFILE
);
TMySqlStatus = (
MYSQL_STATUS_READY,
MYSQL_STATUS_GET_RESULT,
MYSQL_STATUS_USE_RESULT
);
{ There are three types of queries - the ones that have to go to
the master, the ones that go to a slave, and the adminstrative
type which must happen on the pivot connectioin }
TMySqlRplType = (
MYSQL_RPL_MASTER,
MYSQL_RPL_SLAVE,
MYSQL_RPL_ADMIN
);
TMYSQL_V3 = record
net: TNET; // Communication parameters
connector_fd: TGPtr; // ConnectorFd for SSL
host,
user,
passwd,
unix_socket,
server_version,
host_info,
info,
db: TSDCharPtr;
port,
client_flag,
server_capabilities:Integer;
protocol_version: Integer;
field_count: Integer;
server_status: Integer;
thread_id: LongInt; // Id for connection in server
affected_rows,
insert_id, // id if insert on table with NEXTNR
extra_info: TMyInt64; // Used by mysqlshow
packet_length: LongInt;
status: TMySqlStatus;
fields: PMYSQL_FIELD_V3;
field_alloc: TMEM_ROOT;
free_me, // If free in mysql_close
reconnect: TMyBool; // set to 1 if automatic reconnect
options: TMYSQL_OPTIONS_V3;
scramble_buff: array[0..8] of Char;
charset: PCHARSET_INFO;
server_language: Integer;
end;
TMYSQL_V4 = record
net: TNET; // Communication parameters
connector_fd: TGPtr; // ConnectorFd for SSL
host, user, passwd,
unix_socket,
server_version,
host_info, info, db:TSDCharPtr;
charset: PCHARSET_INFO;
fields: PMYSQL_FIELD_V4;
field_alloc: TMEM_ROOT;
affected_rows,
insert_id, // id if insert on table with NEXTNR
extra_info: TMyInt64; // Used by mysqlshow
thread_id: ULong; // Id for connection in server
packet_length: ULong;
port,
client_flag,
server_capabilities:UInt;
protocol_version: UInt;
field_count: UInt;
server_status: UInt;
server_language: UInt;
options: TMYSQL_OPTIONS_V4;
status: TMySqlStatus;
free_me, // If free in mysql_close
reconnect: TMyBool; // set to 1 if automatic reconnect
scramble_buff: array[0..8] of Char;
rpl_pivot: TMyBool; // Set if this is the original connection, not a master or a slave we have added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()
master, next_slave: PMYSQL_V4; // Pointers to the master, and the next slave connections, points to itself if lone connection
last_used_slave: PMYSQL_V4; // needed for round-robin slave pick
last_used_con: PMYSQL_V4; // needed for send/read/store/use result to work correctly with replication
end;
PMYSQL = TSDPtr;
TMYSQL_RES_V3 = packed record
row_count: TMyInt64;
field_count,
current_field: Integer;
fields: PMYSQL_FIELD_V3;
data: PMYSQL_DATA;
data_cursor: PMYSQL_ROWS;
field_alloc: TMEM_ROOT;
row: TMYSQL_ROW; // If unbuffered read
current_row: TMYSQL_ROW; // buffer to current row
lengths: PLongInt; // column lengths of current row
handle: PMYSQL; // for unbuffered reads
eof: TMyBool; // Used my mysql_fetch_row
end;
PMYSQL_RES_V3 = ^TMYSQL_RES_V3;
TMYSQL_RES_V4 = packed record
row_count: TMyInt64;
fields: PMYSQL_FIELD_V4;
data: PMYSQL_DATA;
data_cursor: PMYSQL_ROWS;
lengths: PULong; // column lengths of current row
handle: PMYSQL_V4; // for unbuffered reads
field_alloc: TMEM_ROOT;
field_count,
current_field: UInt;
row: TMYSQL_ROW; // If unbuffered read
current_row: TMYSQL_ROW; // buffer to current row
eof: TMyBool; // Used my mysql_fetch_row
end;
PMYSQL_RES_V4 = ^TMYSQL_RES_V4;
PMYSQL_RES = TSDPtr;
{
Functions to get information from the MYSQL and MYSQL_RES structures
Should definitely be used if one uses shared libraries
}
{$IFNDEF SD_CLR}
var
mysql_num_rows:
function(res: PMYSQL_RES): TMyInt64; stdcall;
mysql_num_fields:
function(res: PMYSQL_RES): Integer; stdcall;
mysql_eof:
function(res: PMYSQL_RES): TMyBool; stdcall;
mysql_fetch_field_direct:
function(res: PMYSQL_RES; fieldnr: Integer): PMYSQL_FIELD; stdcall;
mysql_fetch_fields:
function(res: PMYSQL_RES): PMYSQL_FIELD; stdcall;
mysql_row_tell:
function(res: PMYSQL_RES): PMYSQL_ROWS; stdcall;
mysql_field_tell:
function(res: PMYSQL_RES): Integer; stdcall;
mysql_field_count:
function(mysql: PMYSQL): Integer; stdcall;
mysql_affected_rows:
function(mysql: PMYSQL): TMyInt64; stdcall;
mysql_insert_id:
function(mysql: PMYSQL): TMyInt64; stdcall;
mysql_errno:
function(mysql: PMYSQL): Integer; stdcall;
mysql_error:
function(mysql: PMYSQL): TSDCharPtr; stdcall;
mysql_info:
function(mysql: PMYSQL): TSDCharPtr; stdcall;
mysql_thread_id:
function(mysql: PMYSQL): LongInt; stdcall;
mysql_character_set_name:
function(mysql: PMYSQL): TSDCharPtr; stdcall;
mysql_init:
function(mysql: PMYSQL): PMYSQL; stdcall;
mysql_ssl_set:
function(mysql: PMYSQL;
const key, cert, ca, capath: TSDCharPtr): Integer; stdcall;
mysql_ssl_cipher:
function(mysql: PMYSQL): TSDCharPtr; stdcall;
mysql_ssl_clear:
function(mysql: PMYSQL): Integer; stdcall;
mysql_connect:
function(mysql: PMYSQL; const host, user, passwd: TSDCharPtr): PMYSQL; stdcall;
mysql_change_user:
function(mysql: PMYSQL; const user, passwd, db: TSDCharPtr): TMyBool; stdcall;
mysql_real_connect:
function(mysql: PMYSQL; const host, user, passwd, db: TSDCharPtr;
port: Integer; const unix_socket: TSDCharPtr;
clientflag: Integer): PMYSQL; stdcall;
mysql_close:
procedure(sock: PMYSQL); stdcall;
mysql_select_db:
function(mysql: PMYSQL; const db: TSDCharPtr): Integer; stdcall;
mysql_query:
function(mysql: PMYSQL; const q: TSDCharPtr): Integer; stdcall;
mysql_send_query:
function(mysql: PMYSQL; const q: TSDCharPtr; length: Integer): Integer; stdcall;
mysql_read_query_result:
function(mysql: PMYSQL): Integer; stdcall;
mysql_real_query:
function(mysql: PMYSQL; const q: TSDCharPtr; length: Integer): Integer; stdcall;
mysql_create_db:
function(mysql: PMYSQL; const DB: TSDCharPtr): Integer; stdcall;
mysql_drop_db:
function(mysql: PMYSQL; const DB: TSDCharPtr): Integer; stdcall;
mysql_shutdown:
function(mysql: PMYSQL): Integer; stdcall;
mysql_dump_debug_info:
function(mysql: PMYSQL): Integer; stdcall;
mysql_refresh:
function(mysql: PMYSQL; refresh_options: Integer): Integer; stdcall;
mysql_kill:
function(mysql: PMYSQL; pid: Integer): Integer; stdcall;
mysql_ping:
function(mysql: PMYSQL): Integer; stdcall;
mysql_stat:
function(mysql: PMYSQL): TSDCharPtr; stdcall;
mysql_get_server_info:
function(mysql: PMYSQL): TSDCharPtr; stdcall;
mysql_get_client_info:
function: TSDCharPtr; stdcall;
mysql_get_host_info:
function(mysql: PMYSQL): TSDCharPtr; stdcall;
mysql_get_proto_info:
function(mysql: PMYSQL): Integer; stdcall;
mysql_list_dbs:
function(mysql: PMYSQL; const wild: TSDCharPtr): PMYSQL_RES; stdcall;
mysql_list_tables:
function(mysql: PMYSQL; const wild: TSDCharPtr): PMYSQL_RES; stdcall;
mysql_list_fields:
function(mysql: PMYSQL; const table, wild: TSDCharPtr): PMYSQL_RES; stdcall;
mysql_list_processes:
function(mysql: PMYSQL): PMYSQL_RES; stdcall;
mysql_store_result:
function(mysql: PMYSQL): PMYSQL_RES; stdcall;
mysql_use_result:
function(mysql: PMYSQL): PMYSQL_RES; stdcall;
mysql_options:
function(mysql: PMYSQL; option: TMySqlOption; const arg: TSDCharPtr): Integer; stdcall;
mysql_free_result:
procedure(res: PMYSQL_RES); stdcall;
mysql_data_seek:
procedure(res: PMYSQL_RES; offset: TMyInt64); stdcall;
mysql_row_seek:
function(res: PMYSQL_RES; Row: TMYSQL_ROW_OFFSET): TMYSQL_ROW_OFFSET; stdcall;
mysql_field_seek:
function(res: PMYSQL_RES; offset: TMYSQL_FIELD_OFFSET): TMYSQL_FIELD_OFFSET; stdcall;
mysql_fetch_row:
function(res: PMYSQL_RES): PMYSQL_ROW; stdcall;
mysql_fetch_lengths:
function(res: PMYSQL_RES): PLongInt; stdcall;
mysql_fetch_field:
function(res: PMYSQL_RES): PMYSQL_FIELD_V3; stdcall;
mysql_escape_string:
function(szTo: TSDCharPtr; const szFrom: TSDCharPtr; from_length: LongInt): LongInt; stdcall;
mysql_real_escape_string:
function(mysql: PMYSQL; szTo: TSDCharPtr; const szFrom: TSDCharPtr;
length: LongInt): LongInt; stdcall;
mysql_debug:
procedure(const debug: TSDCharPtr); stdcall;
{
mysql_odbc_escape_string:
function(MYSQL *mysql, char *to, unsigned long to_length,
const char *from, unsigned long from_length,
void *param,
char *(*extend_buffer) (void *, char *to, unsigned long *length)
): TSDCharPtr; stdcall;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -