|
@@ -7,6 +7,7 @@
|
|
|
unit mysql4dyn;
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
+{$MACRO on}
|
|
|
|
|
|
interface
|
|
|
|
|
@@ -40,97 +41,108 @@ uses dynlibs, classes, sysutils, mysql4_comdyn;
|
|
|
along with this program; if not, write to the Free Software
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA }
|
|
|
|
|
|
-{$PACKRECORDS C}
|
|
|
|
|
|
-const
|
|
|
- Mysqllib = 'libmysqlclient.so';
|
|
|
+{$IFDEF Unix}
|
|
|
+ {$DEFINE extdecl:=cdecl}
|
|
|
+ const
|
|
|
+ Mysqllib = 'libmysqlclient.so';
|
|
|
+{$ENDIF}
|
|
|
+{$IFDEF Win32}
|
|
|
+ {$DEFINE extdecl:=stdcall}
|
|
|
+ const
|
|
|
+ Mysqllib = 'libmysql.dll';
|
|
|
+{$ENDIF}
|
|
|
+
|
|
|
+{$PACKRECORDS C}
|
|
|
|
|
|
{$i mysql4types.inc}
|
|
|
|
|
|
+type tpcharfunction = function : pchar; extdecl;
|
|
|
+
|
|
|
var
|
|
|
- mysql_server_init : function (argc:longint; argv:PPchar; groups:PPchar):longint;cdecl;
|
|
|
- mysql_server_end : procedure;cdecl;
|
|
|
- mysql_thread_init : function :my_bool;cdecl;
|
|
|
- mysql_thread_end : procedure;cdecl;
|
|
|
- mysql_num_rows : function (res:PMYSQL_RES):my_ulonglong;cdecl;
|
|
|
- mysql_num_fields : function (res:PMYSQL_RES):dword;cdecl;
|
|
|
- mysql_eof : function (res:PMYSQL_RES):my_bool;cdecl;
|
|
|
- mysql_fetch_field_direct : function (res:PMYSQL_RES; fieldnr:dword):PMYSQL_FIELD;cdecl;
|
|
|
- mysql_fetch_fields : function (res:PMYSQL_RES):PMYSQL_FIELD;cdecl;
|
|
|
- mysql_row_tell : function (res:PMYSQL_RES):PMYSQL_ROWS;cdecl;
|
|
|
- mysql_field_tell : function (res:PMYSQL_RES):dword;cdecl;
|
|
|
- mysql_field_count : function (mysql:PMYSQL):dword;cdecl;
|
|
|
- mysql_affected_rows : function (mysql:PMYSQL):my_ulonglong;cdecl;
|
|
|
- mysql_insert_id : function (mysql:PMYSQL):my_ulonglong;cdecl;
|
|
|
- mysql_errno : function (mysql:PMYSQL):dword;cdecl;
|
|
|
- mysql_error : function (mysql:PMYSQL):Pchar;cdecl;
|
|
|
- mysql_info : function (mysql:PMYSQL):Pchar;cdecl;
|
|
|
- mysql_thread_id : function (mysql:PMYSQL):dword;cdecl;
|
|
|
- mysql_character_set_name : function (mysql:PMYSQL):Pchar;cdecl;
|
|
|
- mysql_init : function (mysql:PMYSQL):PMYSQL;cdecl;
|
|
|
- mysql_ssl_set : function (mysql:PMYSQL; key:Pchar; cert:Pchar; ca:Pchar; capath:Pchar;cipher:Pchar):longint;cdecl;
|
|
|
- mysql_ssl_clear : function (mysql:PMYSQL):longint;cdecl;
|
|
|
- mysql_change_user : function (mysql:PMYSQL; user:Pchar; passwd:Pchar; db:Pchar):my_bool;cdecl;
|
|
|
- mysql_real_connect : function (mysql:PMYSQL; host:Pchar; user:Pchar; passwd:Pchar; db:Pchar;port:dword; unix_socket:Pchar; clientflag:dword):PMYSQL;cdecl;
|
|
|
- mysql_close : procedure (sock:PMYSQL);cdecl;
|
|
|
- mysql_select_db : function (mysql:PMYSQL; db:Pchar):longint;cdecl;
|
|
|
- mysql_query : function (mysql:PMYSQL; q:Pchar):longint;cdecl;
|
|
|
- mysql_send_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;cdecl;
|
|
|
- mysql_read_query_result : function (mysql:PMYSQL):longint;cdecl;
|
|
|
- mysql_real_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;cdecl;
|
|
|
- mysql_master_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;cdecl;
|
|
|
- mysql_master_send_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;cdecl;
|
|
|
- mysql_slave_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;cdecl;
|
|
|
- mysql_slave_send_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;cdecl;
|
|
|
- mysql_enable_rpl_parse : procedure (mysql:PMYSQL);cdecl;
|
|
|
- mysql_disable_rpl_parse : procedure (mysql:PMYSQL);cdecl;
|
|
|
- mysql_rpl_parse_enabled : function (mysql:PMYSQL):longint;cdecl;
|
|
|
- mysql_enable_reads_from_master : procedure (mysql:PMYSQL);cdecl;
|
|
|
- mysql_disable_reads_from_master : procedure (mysql:PMYSQL);cdecl;
|
|
|
- mysql_reads_from_master_enabled : function (mysql:PMYSQL):longint;cdecl;
|
|
|
+ mysql_server_init : function (argc:longint; argv:PPchar; groups:PPchar):longint;extdecl;
|
|
|
+ mysql_server_end : procedure;extdecl;
|
|
|
+ mysql_thread_init : function :my_bool;extdecl;
|
|
|
+ mysql_thread_end : procedure;extdecl;
|
|
|
+ mysql_num_rows : function (res:PMYSQL_RES):my_ulonglong;extdecl;
|
|
|
+ mysql_num_fields : function (res:PMYSQL_RES):dword;extdecl;
|
|
|
+ mysql_eof : function (res:PMYSQL_RES):my_bool;extdecl;
|
|
|
+ mysql_fetch_field_direct : function (res:PMYSQL_RES; fieldnr:dword):PMYSQL_FIELD;extdecl;
|
|
|
+ mysql_fetch_fields : function (res:PMYSQL_RES):PMYSQL_FIELD;extdecl;
|
|
|
+ mysql_row_tell : function (res:PMYSQL_RES):PMYSQL_ROWS;extdecl;
|
|
|
+ mysql_field_tell : function (res:PMYSQL_RES):dword;extdecl;
|
|
|
+ mysql_field_count : function (mysql:PMYSQL):dword;extdecl;
|
|
|
+ mysql_affected_rows : function (mysql:PMYSQL):my_ulonglong;extdecl;
|
|
|
+ mysql_insert_id : function (mysql:PMYSQL):my_ulonglong;extdecl;
|
|
|
+ mysql_errno : function (mysql:PMYSQL):dword;extdecl;
|
|
|
+ mysql_error : function (mysql:PMYSQL):Pchar;extdecl;
|
|
|
+ mysql_info : function (mysql:PMYSQL):Pchar;extdecl;
|
|
|
+ mysql_thread_id : function (mysql:PMYSQL):dword;extdecl;
|
|
|
+ mysql_character_set_name : function (mysql:PMYSQL):Pchar;extdecl;
|
|
|
+ mysql_init : function (mysql:PMYSQL):PMYSQL;extdecl;
|
|
|
+ mysql_ssl_set : function (mysql:PMYSQL; key:Pchar; cert:Pchar; ca:Pchar; capath:Pchar;cipher:Pchar):longint;extdecl;
|
|
|
+ mysql_ssl_clear : function (mysql:PMYSQL):longint;extdecl;
|
|
|
+ mysql_change_user : function (mysql:PMYSQL; user:Pchar; passwd:Pchar; db:Pchar):my_bool;extdecl;
|
|
|
+ mysql_real_connect : function (mysql:PMYSQL; host:Pchar; user:Pchar; passwd:Pchar; db:Pchar;port:dword; unix_socket:Pchar; clientflag:dword):PMYSQL;extdecl;
|
|
|
+ mysql_close : procedure (sock:PMYSQL);extdecl;
|
|
|
+ mysql_select_db : function (mysql:PMYSQL; db:Pchar):longint;extdecl;
|
|
|
+ mysql_query : function (mysql:PMYSQL; q:Pchar):longint;extdecl;
|
|
|
+ mysql_send_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;extdecl;
|
|
|
+ mysql_read_query_result : function (mysql:PMYSQL):longint;extdecl;
|
|
|
+ mysql_real_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;extdecl;
|
|
|
+ mysql_master_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;extdecl;
|
|
|
+ mysql_master_send_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;extdecl;
|
|
|
+ mysql_slave_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;extdecl;
|
|
|
+ mysql_slave_send_query : function (mysql:PMYSQL; q:Pchar; length:dword):longint;extdecl;
|
|
|
+ mysql_enable_rpl_parse : procedure (mysql:PMYSQL);extdecl;
|
|
|
+ mysql_disable_rpl_parse : procedure (mysql:PMYSQL);extdecl;
|
|
|
+ mysql_rpl_parse_enabled : function (mysql:PMYSQL):longint;extdecl;
|
|
|
+ mysql_enable_reads_from_master : procedure (mysql:PMYSQL);extdecl;
|
|
|
+ mysql_disable_reads_from_master : procedure (mysql:PMYSQL);extdecl;
|
|
|
+ mysql_reads_from_master_enabled : function (mysql:PMYSQL):longint;extdecl;
|
|
|
(* error
|
|
|
enum mysql_rpl_type mysql_rpl_query_type(const char* q, int len);
|
|
|
in declaration at line 291 *)
|
|
|
- mysql_rpl_probe : function (mysql:PMYSQL):longint;cdecl;
|
|
|
- mysql_set_master : function (mysql:PMYSQL; host:Pchar; port:dword; user:Pchar; passwd:Pchar):longint;cdecl;
|
|
|
- mysql_add_slave : function (mysql:PMYSQL; host:Pchar; port:dword; user:Pchar; passwd:Pchar):longint;cdecl;
|
|
|
- mysql_shutdown : function (mysql:PMYSQL):longint;cdecl;
|
|
|
- mysql_dump_debug_info : function (mysql:PMYSQL):longint;cdecl;
|
|
|
- mysql_refresh : function (mysql:PMYSQL; refresh_options:dword):longint;cdecl;
|
|
|
- mysql_kill : function (mysql:PMYSQL; pid:dword):longint;cdecl;
|
|
|
- mysql_ping : function (mysql:PMYSQL):longint;cdecl;
|
|
|
- mysql_stat : function (mysql:PMYSQL):Pchar;cdecl;
|
|
|
- mysql_get_server_info : function (mysql:PMYSQL):Pchar;cdecl;
|
|
|
- mysql_get_client_info : function:Pchar; cdecl;
|
|
|
- mysql_get_host_info : function (mysql:PMYSQL):Pchar;cdecl;
|
|
|
- mysql_get_proto_info : function (mysql:PMYSQL):dword;cdecl;
|
|
|
- mysql_list_dbs : function (mysql:PMYSQL; wild:Pchar):PMYSQL_RES;cdecl;
|
|
|
- mysql_list_tables : function (mysql:PMYSQL; wild:Pchar):PMYSQL_RES;cdecl;
|
|
|
- mysql_list_fields : function (mysql:PMYSQL; table:Pchar; wild:Pchar):PMYSQL_RES;cdecl;
|
|
|
- mysql_list_processes : function (mysql:PMYSQL):PMYSQL_RES;cdecl;
|
|
|
- mysql_store_result : function (mysql:PMYSQL):PMYSQL_RES;cdecl;
|
|
|
- mysql_use_result : function (mysql:PMYSQL):PMYSQL_RES;cdecl;
|
|
|
- mysql_options : function (mysql:PMYSQL; option:mysql_option; arg:Pchar):longint;cdecl;
|
|
|
- mysql_free_result : procedure (result:PMYSQL_RES);cdecl;
|
|
|
- mysql_data_seek : procedure (result:PMYSQL_RES; offset:my_ulonglong);cdecl;
|
|
|
- mysql_row_seek : function (result:PMYSQL_RES; _para2:MYSQL_ROW_OFFSET):MYSQL_ROW_OFFSET;cdecl;
|
|
|
- mysql_field_seek : function (result:PMYSQL_RES; offset:MYSQL_FIELD_OFFSET):MYSQL_FIELD_OFFSET;cdecl;
|
|
|
- mysql_fetch_row : function (result:PMYSQL_RES):MYSQL_ROW;cdecl;
|
|
|
- mysql_fetch_lengths : function (result:PMYSQL_RES):Pdword;cdecl;
|
|
|
- mysql_fetch_field : function (result:PMYSQL_RES):PMYSQL_FIELD;cdecl;
|
|
|
- mysql_escape_string : function (_to:Pchar; from:Pchar; from_length:dword):dword;cdecl;
|
|
|
- mysql_real_escape_string : function (mysql:PMYSQL; _to:Pchar; from:Pchar; length:dword):dword;cdecl;
|
|
|
- mysql_debug : procedure (debug:Pchar);cdecl;
|
|
|
- mysql_odbc_escape_string : function (mysql:PMYSQL; _to:Pchar; to_length:dword; from:Pchar; from_length:dword;param:pointer; extend_buffer: TExdendBuffer):Pchar;cdecl;
|
|
|
- myodbc_remove_escape : procedure (mysql:PMYSQL; name:Pchar);cdecl;
|
|
|
- mysql_thread_safe : function :dword;cdecl;
|
|
|
- mysql_manager_init : function (con:PMYSQL_MANAGER):PMYSQL_MANAGER;cdecl;
|
|
|
- mysql_manager_connect : function (con:PMYSQL_MANAGER; host:Pchar; user:Pchar; passwd:Pchar; port:dword):PMYSQL_MANAGER;cdecl;
|
|
|
- mysql_manager_close : procedure (con:PMYSQL_MANAGER);cdecl;
|
|
|
- mysql_manager_command : function (con:PMYSQL_MANAGER; cmd:Pchar; cmd_len:longint):longint;cdecl;
|
|
|
- mysql_manager_fetch_line : function (con:PMYSQL_MANAGER; res_buf:Pchar; res_buf_size:longint):longint;cdecl;
|
|
|
- simple_command : function (mysql:PMYSQL; command:enum_server_command; arg:Pchar; length:dword; skipp_check:my_bool):longint;cdecl;
|
|
|
- net_safe_read : function (mysql:PMYSQL):dword;cdecl;
|
|
|
+ mysql_rpl_probe : function (mysql:PMYSQL):longint;extdecl;
|
|
|
+ mysql_set_master : function (mysql:PMYSQL; host:Pchar; port:dword; user:Pchar; passwd:Pchar):longint;extdecl;
|
|
|
+ mysql_add_slave : function (mysql:PMYSQL; host:Pchar; port:dword; user:Pchar; passwd:Pchar):longint;extdecl;
|
|
|
+ mysql_shutdown : function (mysql:PMYSQL):longint;extdecl;
|
|
|
+ mysql_dump_debug_info : function (mysql:PMYSQL):longint;extdecl;
|
|
|
+ mysql_refresh : function (mysql:PMYSQL; refresh_options:dword):longint;extdecl;
|
|
|
+ mysql_kill : function (mysql:PMYSQL; pid:dword):longint;extdecl;
|
|
|
+ mysql_ping : function (mysql:PMYSQL):longint;extdecl;
|
|
|
+ mysql_stat : function (mysql:PMYSQL):Pchar;extdecl;
|
|
|
+ mysql_get_server_info : function (mysql:PMYSQL):Pchar;extdecl;
|
|
|
+ mysql_get_client_info : tpcharfunction; //function:Pchar; extdecl;
|
|
|
+ mysql_get_host_info : function (mysql:PMYSQL):Pchar;extdecl;
|
|
|
+ mysql_get_proto_info : function (mysql:PMYSQL):dword;extdecl;
|
|
|
+ mysql_list_dbs : function (mysql:PMYSQL; wild:Pchar):PMYSQL_RES;extdecl;
|
|
|
+ mysql_list_tables : function (mysql:PMYSQL; wild:Pchar):PMYSQL_RES;extdecl;
|
|
|
+ mysql_list_fields : function (mysql:PMYSQL; table:Pchar; wild:Pchar):PMYSQL_RES;extdecl;
|
|
|
+ mysql_list_processes : function (mysql:PMYSQL):PMYSQL_RES;extdecl;
|
|
|
+ mysql_store_result : function (mysql:PMYSQL):PMYSQL_RES;extdecl;
|
|
|
+ mysql_use_result : function (mysql:PMYSQL):PMYSQL_RES;extdecl;
|
|
|
+ mysql_options : function (mysql:PMYSQL; option:mysql_option; arg:Pchar):longint;extdecl;
|
|
|
+ mysql_free_result : procedure (result:PMYSQL_RES);extdecl;
|
|
|
+ mysql_data_seek : procedure (result:PMYSQL_RES; offset:my_ulonglong);extdecl;
|
|
|
+ mysql_row_seek : function (result:PMYSQL_RES; _para2:MYSQL_ROW_OFFSET):MYSQL_ROW_OFFSET;extdecl;
|
|
|
+ mysql_field_seek : function (result:PMYSQL_RES; offset:MYSQL_FIELD_OFFSET):MYSQL_FIELD_OFFSET;extdecl;
|
|
|
+ mysql_fetch_row : function (result:PMYSQL_RES):MYSQL_ROW;extdecl;
|
|
|
+ mysql_fetch_lengths : function (result:PMYSQL_RES):Pdword;extdecl;
|
|
|
+ mysql_fetch_field : function (result:PMYSQL_RES):PMYSQL_FIELD;extdecl;
|
|
|
+ mysql_escape_string : function (_to:Pchar; from:Pchar; from_length:dword):dword;extdecl;
|
|
|
+ mysql_real_escape_string : function (mysql:PMYSQL; _to:Pchar; from:Pchar; length:dword):dword;extdecl;
|
|
|
+ mysql_debug : procedure (debug:Pchar);extdecl;
|
|
|
+ mysql_odbc_escape_string : function (mysql:PMYSQL; _to:Pchar; to_length:dword; from:Pchar; from_length:dword;param:pointer; extend_buffer: TExdendBuffer):Pchar;extdecl;
|
|
|
+ myodbc_remove_escape : procedure (mysql:PMYSQL; name:Pchar);extdecl;
|
|
|
+ mysql_thread_safe : function :dword;extdecl;
|
|
|
+ mysql_manager_init : function (con:PMYSQL_MANAGER):PMYSQL_MANAGER;extdecl;
|
|
|
+ mysql_manager_connect : function (con:PMYSQL_MANAGER; host:Pchar; user:Pchar; passwd:Pchar; port:dword):PMYSQL_MANAGER;extdecl;
|
|
|
+ mysql_manager_close : procedure (con:PMYSQL_MANAGER);extdecl;
|
|
|
+ mysql_manager_command : function (con:PMYSQL_MANAGER; cmd:Pchar; cmd_len:longint):longint;extdecl;
|
|
|
+ mysql_manager_fetch_line : function (con:PMYSQL_MANAGER; res_buf:Pchar; res_buf_size:longint):longint;extdecl;
|
|
|
+ simple_command : function (mysql:PMYSQL; command:enum_server_command; arg:Pchar; length:dword; skipp_check:my_bool):longint;extdecl;
|
|
|
+ net_safe_read : function (mysql:PMYSQL):dword;extdecl;
|
|
|
|
|
|
|
|
|
function IS_PRI_KEY(n : longint) : Boolean;
|
|
@@ -161,6 +173,12 @@ begin
|
|
|
RefCount := 0;
|
|
|
Raise EInOutError.Create('Can not load MySQL client. Is it installed? ('+Mysqllib+')');
|
|
|
end;
|
|
|
+ pointer(mysql_get_client_info) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_get_client_info');
|
|
|
+
|
|
|
+ // To avoid the strangest problems for ppl using other client-libs
|
|
|
+ if copy(strpas(mysql_get_client_info()),1,3) <> '4.0' then
|
|
|
+ Raise EInOutError.Create('This program can only work with the MySQL client version 4.0.x. Please use the right version of '+Mysqllib+'.');
|
|
|
+
|
|
|
pointer(mysql_server_init) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_server_init');
|
|
|
pointer(mysql_server_end) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_server_end');
|
|
|
pointer(mysql_thread_init) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_thread_init');
|
|
@@ -211,7 +229,6 @@ begin
|
|
|
pointer(mysql_ping) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_ping');
|
|
|
pointer(mysql_stat) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_stat');
|
|
|
pointer(mysql_get_server_info) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_get_server_info');
|
|
|
- pointer(mysql_get_client_info) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_get_client_info');
|
|
|
pointer(mysql_get_host_info) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_get_host_info');
|
|
|
pointer(mysql_get_proto_info) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_get_proto_info');
|
|
|
pointer(mysql_list_dbs) := GetProcedureAddress(Mysql4LibraryHandle,'mysql_list_dbs');
|