瀏覽代碼

+ Upgraded to 3.23

michael 23 年之前
父節點
當前提交
9ce6bc64ac
共有 3 個文件被更改,包括 698 次插入584 次删除
  1. 383 339
      packages/base/mysql/mysql.pp
  2. 297 240
      packages/base/mysql/mysql_com.pp
  3. 18 5
      packages/base/mysql/mysql_version.pp

+ 383 - 339
packages/base/mysql/mysql.pp

@@ -1,340 +1,384 @@
-{ $Id$ }
-
-unit mysql;
-
-{
-  Import unit for the mysql header files.
-  Translated form the original mysql.h by Michael Van Canneyt
-  ([email protected])
-  
-}
-
-interface
-
-uses mysql_com;
-{$ifdef win32}
-Const mysqllib = 'libmysql';
-{$else}
-Const mysqllib = 'mysqlclient';
-{$endif}
-
-{$ifndef win32}
-{$linklib c}
-{$linklib m}
-{$endif}
-
-{ All is 4-byte aligned on my machine. }
-{$packrecords 4}
-
-type 
-   my_bool = byte;
-   gptr   = pchar;
-   Socket = Longint;
-   PCardinal = ^Cardinal;    
-
-{$ifdef Unix}    
-Var
-  mysql_port : cardinal; external name 'mysql_port';
-  mysql_unix_port : pchar; external name 'mysql_unix_port';
-{$endif}
-
-{
-#define IS_PRI_KEY(n)	((n) & PRI_KEY_FLAG)
-#define IS_NOT_NULL(n)	((n) & NOT_NULL_FLAG)
-#define IS_BLOB(n)	((n) & BLOB_FLAG)
-#define IS_NUM(t)	((t) <= FIELD_TYPE_INT24)
-}
-Type
-st_mysql_field = record 
-  name : Pchar;			{ Name of column }
-  table : pchar;		{ Table of column if column was a field }
-  def: pchar;			{ Default value (set by mysql_list_fields) }
-  ftype : enum_field_types;	{ Type of field. See mysql_com.h for types }
-  length : cardinal;		{ Width of column }
-  max_length : cardinal;	{ Max width of selected set }
-  flags : cardinal;		{ Div flags }
-  decimals : cardinal;	{ Number of decimals in field }
-end;
-TMYSQL_FIELD = st_mysql_field;
-PMYSQL_FIELD = ^TMYSQL_FIELD;
-
-TMYSQL_ROW = PPchar;		 { return data as array of strings }
-TMYSQL_FIELD_OFFSET = cardinal;  { offset to current field }
-
-{$ifndef oldmysql}
-  my_ulonglong=qword;
-{$else}
-  my_longlong=cardinal;
-{$endif}
-
-PST_MYSQL_Rows = ^st_mysql_rows;
-st_mysql_rows = Record
-  next : pst_mysql_rows;		{ list of rows }
-  Data : TMYSQL_ROW;
-end;
-TMYSQL_ROWS = st_mysql_rows;
-PMYSQL_ROWS = ^TMYSQL_ROWS;
-
-
-TMYSQL_ROW_OFFSET = PMYSQL_ROWS;	{ offset to current row }
-
-st_mysql_data  = record
-  rows   : my_ulonglong; 
-  fields : cardinal;
-  data : PMYSQL_ROWS;
-  alloc : TMEM_ROOT;
-end;
-
-TMYSQL_DATA = st_mysql_data;
-PMYSQL_DATA = ^TMYSQL_DATA;
-
-st_mysql_options = record 
-  connect_timeout,client_flag : cardinal;
-  compress,named_pipe : my_bool;
-  port : cardinal;
-  host,init_command,user,password,unix_socket,db : pchar;
-  my_cnf_file,my_cnf_group : pchar;
-end;  
-
-mysql_status = (MYSQL_STATUS_READY,
-                MYSQL_STATUS_GET_RESULT,
-                MYSQL_STATUS_USE_RESULT);
-
-
-st_mysql = Record
-  NET : TNET;			{ Communication parameters }
-  host,user,passwd,unix_socket,server_version,host_info,
-  info,db : pchar;
-  port,client_flag,server_capabilities : cardinal;
-  protocol_version : cardinal;
-  field_count : cardinal;
-  thread_id : cardinal;		{ Id for connection in server }
-  affected_rows : my_ulonglong;
-  insert_id : my_ulonglong;		{ id if insert on table with NEXTNR }
-  extra_info : my_ulonglong;    	{ Used by mysqlshow }
-  packet_length : cardinal; 
-  status : mysql_status;
-  fields : PMYSQL_FIELD;
-  field_alloc : TMEM_ROOT;
-  free_me : my_bool;		{ If free in mysql_close }
-  reconnect : my_bool;		{ set to 1 if automatic reconnect }
-  options : st_mysql_options;   
-end;
-TMYSQL = st_mysql;
-PMYSQL = ^TMYSQL;
-
-
-st_mysql_res = record
-  row_count : my_ulonglong; 
-  field_count, current_field : cardinal;
-  fields :         PMYSQL_FIELD;
-  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 :        pcardinal;		{ column lengths of current row }
-  handle :         PMYSQL;		{ for unbuffered reads }
-  eof :            my_bool;			{ Used my mysql_fetch_row }
-end;
-TMYSQL_RES  = st_mysql_res;
-PMYSQL_RES  = ^TMYSQL_RES;
-
-
-{ Translated Macros }
-
-Function mysql_num_rows (res : PMYSQL_RES) : my_ulonglong;
-Function mysql_num_fields(res : PMYSQL_RES) : Cardinal;
-Function mysql_eof(res : PMYSQL_RES) : my_bool; 
-Function mysql_fetch_field_direct(res : PMYSQL_RES; fieldnr : Cardinal) : TMYSQL_FIELD; 
-Function mysql_fetch_fields(res : PMYSQL_RES) : PMYSQL_FIELD; 
-Function mysql_row_tell(res : PMYSQL_RES) : PMYSQL_ROWS;
-Function mysql_field_tell(res : PMYSQL_RES) : Cardinal;
-Function mysql_affected_rows(mysql : PMYSQL): my_ulonglong;  
-Function mysql_insert_id(mysql : PMYSQL): my_ulonglong;  
-Function mysql_errno(mysql : PMYSQL) : Cardinal;
-Function mysql_info(mysql : PMYSQL): Pchar;
-Function mysql_reload(mysql : PMYSQL) : Longint; 
-Function mysql_thread_id(mysql : PMYSQL) : Cardinal; 
-Function mysql_error(mysql : PMYSQL) : pchar; 
-
-{ Original functions }
-
-Function mysql_connect (mysql : PMYSQL; host,user,passwd: pchar) : PMYSQL; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_real_connect (mysql : PMYSQL; const host,user,passwd : pchar;
-				   port : cardinal;
-				   unix_socket : pchar;
-				   clientflag : cardinal) : PMYSQL;{$ifdef win32} stdcall {$else} cdecl {$endif};
-				   
-Function mysql_close(sock : PMYSQL) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_select_db(MYSQL : PMYSQL; db : Pchar) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_query(mysql : PMYSQL; q : pchar) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_real_query(mysql : PMYSQL; q : Pchar; length : longint) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_create_db(mysql : PMYSQL; db : pchar) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_drop_db(mysql : PMYSQL; DB : Pchar) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_shutdown(mysql : PMYSQL) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_dump_debug_info(mysql : PMYSQL) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_refresh(mysql : PMYSQL; refresh_options : cardinal) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_kill(mysql : PMYSQL; pid : Cardinal) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_stat(mysql : PMYSQL) : Pchar; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_get_server_info(mysql : PMYSQL) : pchar; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_get_client_info : pchar; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_get_host_info(mysql : PMYSQL) : pchar; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_get_proto_info(mysql : PMYSQL) : Cardinal; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_list_dbs(mysql : PMYSQL;wild : Pchar) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  mysql_list_tables(mysql : PMYSQL;Wild : Pchar) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  mysql_list_fields(mysql : PMYSQL; table,wild : pchar) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  mysql_list_processes(mysql : PMYSQL) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  mysql_store_result(mysql : PMYSQL) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  mysql_use_result(mysql : PMYSQL) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Procedure mysql_free_result(res : PMYSQL_RES);{$ifdef win32} stdcall {$else} cdecl {$endif};
-Procedure mysql_data_seek(mysql : PMYSQL_RES; offs : cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_row_seek(mysql : PMYSQL_RES; Offs: TMYSQL_ROW_OFFSET): TMYSQL_ROW_OFFSET; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_field_seek(musql : PMYSQL_RES;offs : TMYSQL_FIELD_OFFSET): TMYSQL_FIELD_OFFSET; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_fetch_row(mysql : PMYSQL_RES) : TMYSQL_ROW; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_fetch_lengths(mysql : PMYSQL_RES) : PCardinal; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_fetch_field(handle : PMYSQL_RES) : PMYSQL_FIELD; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Function mysql_escape_string(escto,escfrom : pchar; length : Cardinal) : cardinal; {$ifdef win32} stdcall {$else} cdecl {$endif};
-Procedure mysql_debug(debug : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};
-
-implementation
-
-
-function mysql_connect (mysql : PMYSQL; host,user,passwd: pchar) : PMYSQL;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_connect';
-function mysql_real_connect (mysql : PMYSQL; const host,user,passwd : pchar;
-				   port : cardinal;
-				   unix_socket : pchar;
-				   clientflag : cardinal) : PMYSQL;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib;
-				   
-function mysql_close(sock : PMYSQL) : longint ;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_close';
-function mysql_select_db(MYSQL : PMYSQL; db : Pchar) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_select_db';
-function mysql_query(mysql : PMYSQL; q : pchar) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_query';
-function mysql_real_query(mysql : PMYSQL; q : Pchar; length : longint) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_real_query';
-function mysql_create_db(mysql : PMYSQL; db : pchar) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_create_db';
-Function mysql_drop_db(mysql : PMYSQL; DB : Pchar) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_drop_db';
-Function mysql_shutdown(mysql : PMYSQL) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_shutdown';
-Function mysql_dump_debug_info(mysql : PMYSQL) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_dump_debug_info';
-Function mysql_refresh(mysql : PMYSQL; refresh_options : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_refresh';
-Function mysql_kill(mysql : PMYSQL; pid : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_kill';
-Function mysql_stat(mysql : PMYSQL) : Pchar;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_stat';
-Function mysql_get_server_info(mysql : PMYSQL) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_get_server_info';
-Function mysql_get_client_info : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib;
-Function mysql_get_host_info(mysql : PMYSQL) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_get_host_info';
-Function mysql_get_proto_info(mysql : PMYSQL) : Cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_get_proto_info';
-Function mysql_list_dbs(mysql : PMYSQL;wild : Pchar) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_list_dbs';
-Function mysql_list_tables(mysql : PMYSQL;Wild : Pchar) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_list_tables';
-Function mysql_list_fields(mysql : PMYSQL; table,wild : pchar) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_list_fields';
-Function mysql_list_processes(mysql : PMYSQL) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_list_processes';
-Function mysql_store_result(mysql : PMYSQL) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_store_result';
-Function mysql_use_result(mysql : PMYSQL) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_use_result';
-Procedure mysql_free_result(res : PMYSQL_RES);{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_free_result';
-Procedure mysql_data_seek(mysql : PMYSQL_RES; offs : cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_data_seek';
-Function mysql_row_seek(mysql : PMYSQL_RES; Offs: TMYSQL_ROW_OFFSET): TMYSQL_ROW_OFFSET;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_row_seek';
-Function mysql_field_seek(musql : PMYSQL_RES;offs : TMYSQL_FIELD_OFFSET): TMYSQL_FIELD_OFFSET;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_field_seek';
-function mysql_fetch_row(mysql : PMYSQL_RES) : TMYSQL_ROW;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_fetch_row';
-function mysql_fetch_lengths(mysql : PMYSQL_RES) : PCardinal;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_fetch_lengths';
-function mysql_fetch_field(handle : PMYSQL_RES) : PMYSQL_FIELD;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_fetch_field';
-Function mysql_escape_string(escto,escfrom : pchar; length : Cardinal) : cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_escape_string';
-Procedure mysql_debug(debug : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_debug';
-
-Function  mysql_error(mysql : PMYSQL) : pchar;
-
-begin
- mysql_error:=mysql^.net.last_error
-end;
-
-Function mysql_num_rows (res : PMYSQL_RES) : my_ulonglong;  
-
-begin
-  mysql_num_rows:=res^.row_count
-end;
-
-Function mysql_num_fields(res : PMYSQL_RES) : Cardinal;
-
-begin
-  mysql_num_fields:=res^.field_count
-end;
-
-Function mysql_eof(res : PMYSQL_RES) : my_bool;
-
-begin
-  mysql_eof:=res^.eof
-end;
-
-Function mysql_fetch_field_direct(res : PMYSQL_RES; fieldnr : Cardinal) : TMYSQL_FIELD;
-
-begin
-  mysql_fetch_field_direct:=res^.fields[fieldnr];
-end;
-
-Function mysql_fetch_fields(res : PMYSQL_RES) : PMYSQL_FIELD;
-
-begin
- mysql_fetch_fields:=res^.fields
-end;
-
-Function mysql_row_tell(res : PMYSQL_RES) : PMYSQL_ROWS;
-
-begin
-  mysql_row_tell:=res^.data_cursor
-end;
-
-Function mysql_field_tell(res : PMYSQL_RES) : Cardinal;
-
-begin
-  mysql_field_tell:=res^.current_field
-end;
-
-Function mysql_affected_rows(mysql : PMYSQL): my_ulonglong; 
-
-begin
-  mysql_affected_rows:=mysql^.affected_rows
-end;
-
-Function mysql_insert_id(mysql : PMYSQL): my_ulonglong; 
-
-begin
-  mysql_insert_id:=mysql^.insert_id
-end;
-
-Function mysql_errno(mysql : PMYSQL) : Cardinal;
-
-begin
-  mysql_errno:=mysql^.net.last_errno
-end;
-
-Function mysql_info(mysql : PMYSQL): Pchar;
-
-begin
-  mysql_info:=mysql^.info
-end;
-
-Function mysql_reload(mysql : PMYSQL) : Longint;
-
-begin
-   mysql_reload:=mysql_refresh(mysql,REFRESH_GRANT)
-end;
-
-Function mysql_thread_id(mysql : PMysql) : Cardinal;
-
-begin
-  mysql_thread_id:=mysql^.thread_id
-end;
-
-end.
-
-{
+{ $Id$ }
+
+unit mysql;
+
+{$undef use_mysql_321} { if undefined, use mysql 3.23 interface }
+
+{
+  Import unit for the mysql header files.
+
+  Translated form the original mysql.h by Michael Van Canneyt
+  ([email protected])
+
+  updated to mysql version 3.23 header files by Bernhard Steffen
+  ([email protected])
+  }
+{$r+,i+,o+}
+
+interface
+
+uses mysql_com, mysql_version;
+{$ifdef win32}
+Const mysqllib = 'libmysql';
+{$else}
+Const mysqllib = 'mysqlclient';
+{$endif}
+
+{$ifndef win32}
+{$linklib c}
+{$linklib m}
+{$endif}
+
+{ All is 4-byte aligned on my machine. }
+{$packrecords 4}
+
+type 
+   my_bool = byte;
+   gptr   = pchar;
+   Socket = Longint;
+   PCardinal = ^Cardinal;    
+
+{$ifdef linux}    
+Var
+  mysql_port : cardinal; external name 'mysql_port';
+  mysql_unix_port : pchar; external name 'mysql_unix_port';
+{$endif}
+
+{
+#define IS_PRI_KEY(n)	((n) & PRI_KEY_FLAG)
+#define IS_NOT_NULL(n)	((n) & NOT_NULL_FLAG)
+#define IS_BLOB(n)	((n) & BLOB_FLAG)
+#define IS_NUM(t)	((t) <= FIELD_TYPE_INT24)
+}
+Type
+st_mysql_field = record 
+  name : Pchar;			{ Name of column }
+  table : pchar;		{ Table of column if column was a field }
+  def: pchar;			{ Default value (set by mysql_list_fields) }
+  ftype : enum_field_types;	{ Type of field. See mysql_com.h for types }
+  length : cardinal;		{ Width of column }
+  max_length : cardinal;	{ Max width of selected set }
+  flags : cardinal;		{ Div flags }
+  decimals : cardinal;	{ Number of decimals in field }
+end;
+TMYSQL_FIELD = st_mysql_field;
+PMYSQL_FIELD = ^TMYSQL_FIELD;
+
+TMYSQL_ROW = PPchar;		 { return data as array of strings }
+TMYSQL_FIELD_OFFSET = cardinal;  { offset to current field }
+
+{$ifndef oldmysql}
+  my_ulonglong=qword;
+{$else}
+  my_longlong=cardinal;
+{$endif}
+
+PST_MYSQL_Rows = ^st_mysql_rows;
+st_mysql_rows = Record
+  next : pst_mysql_rows;		{ list of rows }
+  Data : TMYSQL_ROW;
+end;
+TMYSQL_ROWS = st_mysql_rows;
+PMYSQL_ROWS = ^TMYSQL_ROWS;
+
+
+TMYSQL_ROW_OFFSET = PMYSQL_ROWS;	{ offset to current row }
+
+st_mysql_data  = record
+  rows   : my_ulonglong; 
+  fields : cardinal;
+  data : PMYSQL_ROWS;
+  alloc : TMEM_ROOT;
+end;
+
+TMYSQL_DATA = st_mysql_data;
+PMYSQL_DATA = ^TMYSQL_DATA;
+
+st_mysql_options = record 
+  connect_timeout,client_flag : cardinal;
+  compress,named_pipe : my_bool;
+  port : cardinal;
+  host,init_command,user,password,unix_socket,db : pchar;
+  my_cnf_file,my_cnf_group : pchar;
+{$ifndef use_mysql_321}
+  charset_dir, charset_name : pchar;
+  use_ssl : my_bool;
+  ssl_key, ssl_cert, ssl_ca, ssl_capath : pchar;
+{$endif}
+end;  
+
+{$ifndef use_mysql_321}
+mysql_option = (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);
+{$endif}
+
+mysql_status = (MYSQL_STATUS_READY,
+                MYSQL_STATUS_GET_RESULT,
+                MYSQL_STATUS_USE_RESULT);
+
+{$ifndef use_mysql_321}
+(*
+charset_info_st = Record
+	number : cardinal;
+	name : pchar;
+	ctype : pointer {uchar*};
+	to_lower : pointer {uchar*};
+	to_upper : pointer {uchar*};
+	sort_order : pointer {uchar*};
+	strxfrm_multiply : cardinal;
+
+	{ einige nicht näher definierte Felder }
+	a, strxfrm, strnncoll, strnxfrm, like_range : pointer;
+	mbmaxlen : cardinal;
+	ismbchar, ismbhead, mbcharlen : pointer;
+end;
+*)
+{$endif}
+
+st_mysql = Record
+  NET : TNET;			{ Communication parameters }
+{$ifndef use_mysql_321}
+  connector_fd : gptr;
+{$endif}
+  host,user,passwd,unix_socket,server_version,host_info,
+  info,db : pchar;
+  port,client_flag,server_capabilities : cardinal;
+  protocol_version : cardinal;
+  field_count : cardinal;
+{$ifndef use_mysql_321}
+  server_status : cardinal;
+{$endif}
+  thread_id : cardinal;		{ Id for connection in server }
+  affected_rows : my_ulonglong;
+  insert_id : my_ulonglong;		{ id if insert on table with NEXTNR }
+  extra_info : my_ulonglong;    	{ Used by mysqlshow }
+  packet_length : cardinal; 
+  status : mysql_status;
+  fields : PMYSQL_FIELD;
+  field_alloc : TMEM_ROOT;
+  free_me : my_bool;		{ If free in mysql_close }
+  reconnect : my_bool;		{ set to 1 if automatic reconnect }
+  options : st_mysql_options;
+{$ifndef use_mysql_321}
+  scramble_buf : array[0..8] of char;
+  charset : pointer { struct charset_info_st};
+  server_language : cardinal;
+{$endif}
+end;
+TMYSQL = st_mysql;
+PMYSQL = ^TMYSQL;
+
+
+st_mysql_res = record
+  row_count : my_ulonglong; 
+  field_count, current_field : cardinal;
+  fields :         PMYSQL_FIELD;
+  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 :        pcardinal;		{ column lengths of current row }
+  handle :         PMYSQL;		{ for unbuffered reads }
+  eof :            my_bool;			{ Used my mysql_fetch_row }
+end;
+TMYSQL_RES  = st_mysql_res;
+PMYSQL_RES  = ^TMYSQL_RES;
+
+
+{ Translated Macros }
+
+Function mysql_num_rows (res : PMYSQL_RES) : my_ulonglong;
+Function mysql_num_fields(res : PMYSQL_RES) : Cardinal;
+Function mysql_eof(res : PMYSQL_RES) : my_bool; 
+Function mysql_fetch_field_direct(res : PMYSQL_RES; fieldnr : Cardinal) : TMYSQL_FIELD; 
+Function mysql_fetch_fields(res : PMYSQL_RES) : PMYSQL_FIELD; 
+Function mysql_row_tell(res : PMYSQL_RES) : PMYSQL_ROWS;
+Function mysql_field_tell(res : PMYSQL_RES) : Cardinal;
+Function mysql_affected_rows(mysql : PMYSQL): my_ulonglong;  
+Function mysql_insert_id(mysql : PMYSQL): my_ulonglong;  
+Function mysql_errno(mysql : PMYSQL) : Cardinal;
+Function mysql_info(mysql : PMYSQL): Pchar;
+Function mysql_reload(mysql : PMYSQL) : Longint; 
+Function mysql_thread_id(mysql : PMYSQL) : Cardinal; 
+Function mysql_error(mysql : PMYSQL) : pchar; 
+
+{ Original functions }
+
+Function mysql_connect (mysql : PMYSQL; host,user,passwd: pchar) : PMYSQL; stdcall;
+Function mysql_real_connect (mysql : PMYSQL; const host,user,passwd : pchar;
+				   port : cardinal;
+				   unix_socket : pchar;
+				   clientflag : cardinal) : PMYSQL;stdcall;
+				   
+Function mysql_close(sock : PMYSQL) : longint; stdcall;
+Function mysql_select_db(MYSQL : PMYSQL; db : Pchar) : longint; stdcall;
+Function mysql_query(mysql : PMYSQL; q : pchar) : longint; stdcall;
+Function mysql_real_query(mysql : PMYSQL; q : Pchar; length : longint) : longint; stdcall;
+Function mysql_create_db(mysql : PMYSQL; db : pchar) : longint; stdcall;
+Function mysql_drop_db(mysql : PMYSQL; DB : Pchar) : longint; stdcall;
+Function mysql_shutdown(mysql : PMYSQL) : longint; stdcall;
+Function mysql_dump_debug_info(mysql : PMYSQL) : longint; stdcall;
+Function mysql_refresh(mysql : PMYSQL; refresh_options : cardinal) : longint; stdcall;
+Function mysql_kill(mysql : PMYSQL; pid : Cardinal) : longint; stdcall;
+Function mysql_stat(mysql : PMYSQL) : Pchar; stdcall;
+Function mysql_get_server_info(mysql : PMYSQL) : pchar; stdcall;
+Function mysql_get_client_info : pchar; stdcall;
+Function mysql_get_host_info(mysql : PMYSQL) : pchar; stdcall;
+Function mysql_get_proto_info(mysql : PMYSQL) : Cardinal; stdcall;
+Function mysql_list_dbs(mysql : PMYSQL;wild : Pchar) : PMYSQL_RES; stdcall;
+Function  mysql_list_tables(mysql : PMYSQL;Wild : Pchar) : PMYSQL_RES; stdcall;
+Function  mysql_list_fields(mysql : PMYSQL; table,wild : pchar) : PMYSQL_RES; stdcall;
+Function  mysql_list_processes(mysql : PMYSQL) : PMYSQL_RES; stdcall;
+Function  mysql_store_result(mysql : PMYSQL) : PMYSQL_RES; stdcall;
+Function  mysql_use_result(mysql : PMYSQL) : PMYSQL_RES; stdcall;
+Procedure mysql_free_result(res : PMYSQL_RES);stdcall;
+Procedure mysql_data_seek(mysql : PMYSQL_RES; offs : cardinal);stdcall;
+Function mysql_row_seek(mysql : PMYSQL_RES; Offs: TMYSQL_ROW_OFFSET): TMYSQL_ROW_OFFSET; stdcall;
+Function mysql_field_seek(musql : PMYSQL_RES;offs : TMYSQL_FIELD_OFFSET): TMYSQL_FIELD_OFFSET; stdcall;
+Function mysql_fetch_row(mysql : PMYSQL_RES) : TMYSQL_ROW; stdcall;
+Function mysql_fetch_lengths(mysql : PMYSQL_RES) : PCardinal; stdcall;
+Function mysql_fetch_field(handle : PMYSQL_RES) : PMYSQL_FIELD; stdcall;
+Function mysql_escape_string(escto,escfrom : pchar; length : Cardinal) : cardinal; stdcall;
+Procedure mysql_debug(debug : pchar);stdcall;
+
+implementation
+
+
+function mysql_connect (mysql : PMYSQL; host,user,passwd: pchar) : PMYSQL;stdcall; external mysqllib name 'mysql_connect';
+function mysql_real_connect (mysql : PMYSQL; const host,user,passwd : pchar;
+				   port : cardinal;
+				   unix_socket : pchar;
+				   clientflag : cardinal) : PMYSQL;stdcall; external mysqllib;
+				   
+function mysql_close(sock : PMYSQL) : longint ;stdcall; external mysqllib name 'mysql_close';
+function mysql_select_db(MYSQL : PMYSQL; db : Pchar) : longint;stdcall; external mysqllib name 'mysql_select_db';
+function mysql_query(mysql : PMYSQL; q : pchar) : longint;stdcall; external mysqllib name 'mysql_query';
+function mysql_real_query(mysql : PMYSQL; q : Pchar; length : longint) : longint;stdcall; external mysqllib name 'mysql_real_query';
+function mysql_create_db(mysql : PMYSQL; db : pchar) : longint;stdcall; external mysqllib name 'mysql_create_db';
+Function mysql_drop_db(mysql : PMYSQL; DB : Pchar) : longint;stdcall; external mysqllib name 'mysql_drop_db';
+Function mysql_shutdown(mysql : PMYSQL) : longint;stdcall; external mysqllib name 'mysql_shutdown';
+Function mysql_dump_debug_info(mysql : PMYSQL) : longint;stdcall; external mysqllib name 'mysql_dump_debug_info';
+Function mysql_refresh(mysql : PMYSQL; refresh_options : cardinal) : longint;stdcall; external mysqllib name 'mysql_refresh';
+Function mysql_kill(mysql : PMYSQL; pid : Cardinal) : longint;stdcall; external mysqllib name 'mysql_kill';
+Function mysql_stat(mysql : PMYSQL) : Pchar;stdcall; external mysqllib name 'mysql_stat';
+Function mysql_get_server_info(mysql : PMYSQL) : pchar;stdcall; external mysqllib name 'mysql_get_server_info';
+Function mysql_get_client_info : pchar;stdcall; external mysqllib;
+Function mysql_get_host_info(mysql : PMYSQL) : pchar;stdcall; external mysqllib name 'mysql_get_host_info';
+Function mysql_get_proto_info(mysql : PMYSQL) : Cardinal;stdcall; external mysqllib name 'mysql_get_proto_info';
+Function mysql_list_dbs(mysql : PMYSQL;wild : Pchar) : PMYSQL_RES;stdcall; external mysqllib name 'mysql_list_dbs';
+Function mysql_list_tables(mysql : PMYSQL;Wild : Pchar) : PMYSQL_RES;stdcall; external mysqllib name 'mysql_list_tables';
+Function mysql_list_fields(mysql : PMYSQL; table,wild : pchar) : PMYSQL_RES;stdcall; external mysqllib name 'mysql_list_fields';
+Function mysql_list_processes(mysql : PMYSQL) : PMYSQL_RES;stdcall; external mysqllib name 'mysql_list_processes';
+Function mysql_store_result(mysql : PMYSQL) : PMYSQL_RES;stdcall; external mysqllib name 'mysql_store_result';
+Function mysql_use_result(mysql : PMYSQL) : PMYSQL_RES;stdcall; external mysqllib name 'mysql_use_result';
+Procedure mysql_free_result(res : PMYSQL_RES);stdcall; external mysqllib name 'mysql_free_result';
+Procedure mysql_data_seek(mysql : PMYSQL_RES; offs : cardinal);stdcall; external mysqllib name 'mysql_data_seek';
+Function mysql_row_seek(mysql : PMYSQL_RES; Offs: TMYSQL_ROW_OFFSET): TMYSQL_ROW_OFFSET;stdcall; external mysqllib name 'mysql_row_seek';
+Function mysql_field_seek(musql : PMYSQL_RES;offs : TMYSQL_FIELD_OFFSET): TMYSQL_FIELD_OFFSET;stdcall; external mysqllib name 'mysql_field_seek';
+function mysql_fetch_row(mysql : PMYSQL_RES) : TMYSQL_ROW;stdcall; external mysqllib name 'mysql_fetch_row';
+function mysql_fetch_lengths(mysql : PMYSQL_RES) : PCardinal;stdcall; external mysqllib name 'mysql_fetch_lengths';
+function mysql_fetch_field(handle : PMYSQL_RES) : PMYSQL_FIELD;stdcall; external mysqllib name 'mysql_fetch_field';
+Function mysql_escape_string(escto,escfrom : pchar; length : Cardinal) : cardinal;stdcall; external mysqllib name 'mysql_escape_string';
+Procedure mysql_debug(debug : pchar);stdcall; external mysqllib name 'mysql_debug';
+
+Function  mysql_error(mysql : PMYSQL) : pchar;
+
+begin
+ mysql_error:=mysql^.net.last_error
+end;
+
+Function mysql_num_rows (res : PMYSQL_RES) : my_ulonglong;  
+
+begin
+  mysql_num_rows:=res^.row_count
+end;
+
+Function mysql_num_fields(res : PMYSQL_RES) : Cardinal;
+
+begin
+  mysql_num_fields:=res^.field_count
+end;
+
+Function mysql_eof(res : PMYSQL_RES) : my_bool;
+
+begin
+  mysql_eof:=res^.eof
+end;
+
+Function mysql_fetch_field_direct(res : PMYSQL_RES; fieldnr : Cardinal) : TMYSQL_FIELD;
+
+begin
+  mysql_fetch_field_direct:=res^.fields[fieldnr];
+end;
+
+Function mysql_fetch_fields(res : PMYSQL_RES) : PMYSQL_FIELD;
+
+begin
+ mysql_fetch_fields:=res^.fields
+end;
+
+Function mysql_row_tell(res : PMYSQL_RES) : PMYSQL_ROWS;
+
+begin
+  mysql_row_tell:=res^.data_cursor
+end;
+
+Function mysql_field_tell(res : PMYSQL_RES) : Cardinal;
+
+begin
+  mysql_field_tell:=res^.current_field
+end;
+
+Function mysql_affected_rows(mysql : PMYSQL): my_ulonglong; 
+
+begin
+  mysql_affected_rows:=mysql^.affected_rows
+end;
+
+Function mysql_insert_id(mysql : PMYSQL): my_ulonglong; 
+
+begin
+  mysql_insert_id:=mysql^.insert_id
+end;
+
+Function mysql_errno(mysql : PMYSQL) : Cardinal;
+
+begin
+  mysql_errno:=mysql^.net.last_errno
+end;
+
+Function mysql_info(mysql : PMYSQL): Pchar;
+
+begin
+  mysql_info:=mysql^.info
+end;
+
+Function mysql_reload(mysql : PMYSQL) : Longint;
+
+begin
+   mysql_reload:=mysql_refresh(mysql,REFRESH_GRANT)
+end;
+
+Function mysql_thread_id(mysql : PMysql) : Cardinal;
+
+begin
+  mysql_thread_id:=mysql^.thread_id
+end;
+
+end.
+
+{
   $Log$
-  Revision 1.1  2002-01-29 17:54:53  peter
-    * splitted to base and extra
-
-  Revision 1.5  2001/03/13 08:50:38  michael
-  + merged Fixed calling convention for win32
-
-  Revision 1.4  2000/12/03 13:41:39  sg
-  * Fixed small merging bug by Michael
-
-  Revision 1.3  2000/12/02 15:24:37  michael
-  + Merged changes from fixbranch
-
-}
+  Revision 1.2  2002-08-26 17:52:31  michael
+  + Upgraded to 3.23
+
+  Revision 1.4  2000/12/03 13:41:39  sg
+  * Fixed small merging bug by Michael
+
+  Revision 1.3  2000/12/02 15:24:37  michael
+  + Merged changes from fixbranch
+
+}

+ 297 - 240
packages/base/mysql/mysql_com.pp

@@ -1,241 +1,298 @@
-unit mysql_com;
-
-interface
-
-{$ifndef win32}
-  {$linklib mysqlclient}
-  {$linklib m}
-  {$linklib c}
-{$endif}
-
-{
- Common definition between mysql server & client
-}
-
-{$packrecords 4}
-{ Extra types introduced for pascal }
-Type
-  pbyte = ^byte;
-  pcardinal = ^cardinal;
-  Socket = longint;
-  my_bool = byte;
-
-Const
- NAME_LEN  = 64 ;               { Field/table name length }
- LOCAL_HOST : pchar = 'localhost' ;
-
- MYSQL_PORT = 3306;             { Alloced by ISI for MySQL }
- MYSQL_UNIX_ADDR  : pchar = '/tmp/mysql.sock';
-
-Type
- enum_server_command = ( COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
-                          COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
-                          COM_SHUTDOWN,COM_STATISTICS,
-                          COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
-                          COM_DEBUG);
-
-Const
- NOT_NULL_FLAG       = 1;               { Field can't be NULL }
- PRI_KEY_FLAG        = 2;               { Field is part of a primary key }
- UNIQUE_KEY_FLAG     = 4;               { Field is part of a unique key }
- MULTIPLE_KEY_FLAG   = 8;               { Field is part of a key }
- BLOB_FLAG           = 16;              { Field is a blob }
- UNSIGNED_FLAG       = 32;              { Field is unsigned }
- ZEROFILL_FLAG       = 64;              { Field is zerofill }
- BINARY_FLAG         = 128;
-{ The following are only sent to new clients }
- ENUM_FLAG           = 256;             { field is an enum }
- AUTO_INCREMENT_FLAG = 512;             { field is a autoincrement field }
- TIMESTAMP_FLAG      = 1024;            { Field is a timestamp }
- PART_KEY_FLAG       = 16384;           { Intern; Part of some key }
- GROUP_FLAG          = 32768;           { Intern group field }
-
- REFRESH_GRANT          = 1;    { Refresh grant tables }
- REFRESH_LOG            = 2;    { Start on new log file }
- REFRESH_TABLES         = 4;    { close all tables }
-
- CLIENT_LONG_PASSWORD   = 1;    { new more secure passwords }
- CLIENT_FOUND_ROWS      = 2;    { Found instead of affected rows }
- CLIENT_LONG_FLAG       = 4;    { Get all column flags }
-
-Type
-pst_used_mem = ^st_used_mem;
-st_used_mem  = record                           { struct for once_alloc }
-  next : pst_used_mem;                          { Next block in use }
-  left : cardinal;                              { memory left in block  }
-  size : cardinal;                              { size of block }
-end;
-
-TUSED_MEM = st_used_mem;
-PUSED_MEM = ^TUSED_MEM;
-
-TError_handler = Procedure;
-
-st_mem_root =  record
-  free : PUSED_MEM;
-  used : PUSED_MEM;
-  min_malloc : cardinal;
-  block_size : cardinal;
-  error_handler : TERROR_Handler;
-end;
-TMEM_ROOT = st_mem_root;
-PMEM_ROOT = ^TMEM_ROOT;
-
-Const
- MYSQL_ERRMSG_SIZE = 200;
-
-Type
-net_type = (NET_TYPE_TCPIP, NET_TYPE_SOCKET, NETTYPE_NAMEDPIPE);
-st_net  = record
-  nettype : net_type; //DT
-  fd : Socket;
-  fcntl : Longint;
-  buff,buff_end,write_pos,read_pos : Pchar;//DT
-  last_error : array [0..MYSQL_ERRMSG_SIZE-1] of char;
-  last_errno,max_packet,timeout,pkt_nr : Cardinal;
-  error,return_errno : my_bool;
-  compress : my_bool; //DT
-
-  remain_in_buf,r_length, buf_length, where_b : cardinal; //DT
-  more : my_bool;//DT
-  save_char : char; //DT
-end;
-TNET = st_net;
-PNET = ^TNET;
-
-Const
-  packet_error : longint = -1;
-
-Type
- enum_field_types = ( FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
-                        FIELD_TYPE_SHORT,  FIELD_TYPE_LONG,
-                        FIELD_TYPE_FLOAT,  FIELD_TYPE_DOUBLE,
-                        FIELD_TYPE_NULL,   FIELD_TYPE_TIMESTAMP,
-                        FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
-                        FIELD_TYPE_DATE,   FIELD_TYPE_TIME,
-                        FIELD_TYPE_DATETIME,
-                        FIELD_TYPE_ENUM := 247,
-                        FIELD_TYPE_SET := 248,
-                        FIELD_TYPE_TINY_BLOB := 249,
-                        FIELD_TYPE_MEDIUM_BLOB := 250,
-                        FIELD_TYPE_LONG_BLOB :=251,
-                        FIELD_TYPE_BLOB :=252,
-                        FIELD_TYPE_VAR_STRING :=253,
-                        FIELD_TYPE_STRING:=254);
-
-Const
-FIELD_TYPE_CHAR = FIELD_TYPE_TINY;              { For compability }
-FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM;          { For compability }
-
-Procedure sql_free (root : PMEM_ROOT);{$ifdef win32} stdcall {$else} cdecl {$endif};
-Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal): longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
-
-{
-extern unsigned long max_allowed_packet;
-extern unsigned long net_buffer_length;
-}
-
-{
-#define net_new_transaction(net) ((net)->pkt_nr=0)
-}
-
-Function  my_net_init(net :PNET; fd : Socket) : Longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
-procedure net_end(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};
-Procedure net_clear(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  net_flush(net : PNET) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  my_net_read(net : PNET) : Cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif};
-
-Type
-TRand_struct  = record
-  seed,seed2,max_value : Cardinal;
-  max_value_dbl : double;
-end;
-PRand_struct = ^TRand_struct;
-
-{ The following is for user defined functions }
-
-Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT);
-
-st_udf_args = record
-  arg_count : cardinal;                 { Number of arguments }
-  arg_type : ^Item_result;              { Pointer to item_results }
-  args : ppchar;                        { Pointer to argument }
-  lengths : PCardinal;                  { Length of string arguments }
-end;
-TUDF_ARGS = st_udf_args;
-PUDPF_ARGS = ^TUDF_ARGS;
-
-  { This holds information about the result }
-
-st_udf_init = record
-  maybe_null : my_bool;                 { 1 if function can return NULL }
-  decimals : cardinal;                  { for real functions }
-  max_length : Cardinal;                { For string functions }
-  ptr : PChar;                          { free pointer for function data }
-end;
-TUDF_INIT = st_udf_init;
-PUDF_INIT = TUDF_INIT;
-
-  { Prototypes to password functions }
-
-procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};
-Function  rnd(rand : Prand_struct) : double;{$ifdef win32} stdcall {$else} cdecl {$endif};
-procedure make_scrambled_password(toarg, passwd : Pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};
-procedure get_salt_from_password(res : pcardinal; password : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};
-procedure scramble(toarg,message,password : pchar; old_ver : my_bool);{$ifdef win32} stdcall {$else} cdecl {$endif};
-function  check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};
-function  get_tty_password(opt_message:  pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};
-
-{
-#define NULL_LENGTH ((unsigned long) ~0) { For net_store_length }
-}
-
-implementation
-
-Procedure sql_free (root : PMEM_ROOT);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function  my_net_init(net :PNET; fd : Socket) : Longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-procedure net_end(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Procedure net_clear(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function  net_flush(net : PNET) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function  my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function  net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function  net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function  my_net_read(net : PNET) : Cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-Function  rnd(rand : Prand_struct) : double;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-procedure make_scrambled_password(toarg, passwd : Pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-procedure get_salt_from_password(res : pcardinal; password : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-procedure scramble(toarg,message,password : pchar; old_ver : my_bool);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-function  check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-function  get_tty_password(opt_message:  pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
-
-end.
+unit mysql_com;
+
+{$undef use_mysql_321} { if undefined, use mysql 3.23 interface }
+
+{ updated to match version 3.23 header files of mysql by Bernhard Steffen
+  ([email protected])
+}
+
+interface
+
+uses
+  mysql_version;
+
+{$ifdef win32}
+Const mysqllib = 'libmysql';
+{$else}
+Const mysqllib = 'mysqlclient';
+{$endif}
+
+{$ifndef win32}
+{$linklib c}
+{$linklib m}
+{$endif}
+{$r+,i+,o+}
+
+
+{
+ Common definition between mysql server & client
+}
+
+{$packrecords 4}
+{ Extra types introduced for pascal }
+Type 
+  pbyte = ^byte;
+  pcardinal = ^cardinal;
+  Socket = longint;
+  my_bool = byte;
+
+Const
+ NAME_LEN  = 64 ;		{ Field/table name length }
+ LOCAL_HOST : pchar = 'localhost' ;
+
+ MYSQL_PORT = 3306;		{ Alloced by ISI for MySQL }
+ MYSQL_UNIX_ADDR  : pchar = '/tmp/mysql.sock';
+
+Type
+ enum_server_command = ( COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
+			  COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
+			  COM_SHUTDOWN,COM_STATISTICS,
+			  COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
+			  COM_DEBUG);
+
+Const
+ NOT_NULL_FLAG	     = 1;		{ Field can't be NULL }
+ PRI_KEY_FLAG	     = 2;		{ Field is part of a primary key }
+ UNIQUE_KEY_FLAG     = 4;		{ Field is part of a unique key }
+ MULTIPLE_KEY_FLAG   = 8;		{ Field is part of a key }
+ BLOB_FLAG	     = 16;		{ Field is a blob }
+ UNSIGNED_FLAG       = 32;		{ Field is unsigned }
+ ZEROFILL_FLAG	     = 64;		{ Field is zerofill }
+ BINARY_FLAG	     = 128;
+{ The following are only sent to new clients }
+ ENUM_FLAG	     = 256;		{ field is an enum }
+ AUTO_INCREMENT_FLAG = 512;		{ field is a autoincrement field }
+ TIMESTAMP_FLAG	     = 1024;		{ Field is a timestamp }
+ PART_KEY_FLAG	     = 16384;		{ Intern; Part of some key }
+ GROUP_FLAG	     = 32768;		{ Intern group field }
+{$ifndef use_mysql_321}
+ UNIQUE_FLAG         = 65536;           { Intern: Used by sql_yacc }
+{$endif}
+
+ REFRESH_GRANT		= 1;	{ Refresh grant tables }
+ REFRESH_LOG		= 2;	{ Start on new log file }
+ REFRESH_TABLES		= 4;	{ close all tables }
+{$ifndef use_mysql_321}
+ REFRESH_HOSTS		= 8;	{ Flush host cache }
+ REFRESH_STATUS		= 16;	{ Flush status variables }
+ REFRESH_THREADS	= 32;	{ Flush status variables }
+ REFRESH_SLAVE          = 64;      { Reset master info and restart slave
+					   thread }
+ REFRESH_MASTER          = 128;     { Remove all bin logs in the index
+					   and truncate the index }
+{$endif}
+
+{$ifndef use_mysql_321}
+{ The following can't be set with mysql_refresh() }
+ REFRESH_READ_LOCK	= 16384;	{ Lock tables for read }
+ REFRESH_FAST		= 32768;	{ Intern flag }
+{$endif}
+
+ CLIENT_LONG_PASSWORD	= 1;	{ new more secure passwords }
+ CLIENT_FOUND_ROWS	= 2;	{ Found instead of affected rows }
+ CLIENT_LONG_FLAG	= 4;	{ Get all column flags }
+{$ifndef use_mysql_321}
+ CLIENT_CONNECT_WITH_DB	= 8;	{ One can specify db on connect }
+ CLIENT_NO_SCHEMA	= 16;	{ Don't allow database.table.column }
+ CLIENT_COMPRESS	= 32;	{ Can use compression protocol }
+ CLIENT_ODBC		= 64;	{ Odbc client }
+ CLIENT_LOCAL_FILES	= 128;	{ Can use LOAD DATA LOCAL }
+ CLIENT_IGNORE_SPACE	= 256;	{ Ignore spaces before '(' }
+ CLIENT_CHANGE_USER	= 512;	{ Support the mysql_change_user() }
+ CLIENT_INTERACTIVE	= 1024;	{ This is an interactive client }
+ CLIENT_SSL             = 2048;     { Switch to SSL after handshake }
+ CLIENT_IGNORE_SIGPIPE  = 4096;     { IGNORE sigpipes }
+ CLIENT_TRANSACTIONS	= 8192;	{ Client knows about transactions }
+
+ SERVER_STATUS_IN_TRANS  = 1;	{ Transaction has started }
+ SERVER_STATUS_AUTOCOMMIT = 2;	{ Server in auto_commit mode }
+{$endif}
+
+ MYSQL_ERRMSG_SIZE	= 200;
+ NET_READ_TIMEOUT	= 30;		{ Timeout on read }
+ NET_WRITE_TIMEOUT	= 60;		{ Timeout on write }
+ NET_WAIT_TIMEOUT	= 8*60*60;	{ Wait for new query }
+
+Type
+pst_used_mem = ^st_used_mem;
+st_used_mem  = record    			{ struct for once_alloc }
+  next : pst_used_mem;				{ Next block in use }
+  left : cardinal;				{ memory left in block  }
+  size : cardinal;				{ size of block }
+end;
+
+TUSED_MEM = st_used_mem;
+PUSED_MEM = ^TUSED_MEM;
+
+TError_handler = Procedure;
+
+st_mem_root =  record
+  free : PUSED_MEM;
+  used : PUSED_MEM;
+  min_malloc : cardinal;
+  block_size : cardinal;
+  error_handler : TERROR_Handler;
+end;
+TMEM_ROOT = st_mem_root;
+PMEM_ROOT = ^TMEM_ROOT;
+
+Type
+net_type = (NET_TYPE_TCPIP, NET_TYPE_SOCKET, NETTYPE_NAMEDPIPE);
+st_net  = record
+  nettype : net_type; //DT
+  fd : Socket;
+  fcntl : Longint;
+  buff,buff_end,write_pos,read_pos : Pchar;//DT
+  last_error : array [0..MYSQL_ERRMSG_SIZE-1] of char;
+  last_errno,max_packet,timeout,pkt_nr : Cardinal;
+  error,return_errno : my_bool;
+  compress : my_bool; //DT
+{$ifndef use_mysql_321}
+  no_send_ok : my_bool;
+{$endif}
+  remain_in_buf,r_length, buf_length, where_b : cardinal; //DT
+{$ifndef use_mysql_321}
+  return_status : ^Cardinal;
+  reading_or_writing : my_bool;
+{$else}
+  more : my_bool;//DT
+{$endif}
+  save_char : char; //DT
+end;
+TNET = st_net;
+PNET = ^TNET;
+
+Const
+  packet_error : longint = -1;
+
+Type
+ enum_field_types = ( FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
+			FIELD_TYPE_SHORT,  FIELD_TYPE_LONG,
+			FIELD_TYPE_FLOAT,  FIELD_TYPE_DOUBLE,
+			FIELD_TYPE_NULL,   FIELD_TYPE_TIMESTAMP,
+			FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
+			FIELD_TYPE_DATE,   FIELD_TYPE_TIME,
+			FIELD_TYPE_DATETIME,
+{$ifndef use_mysql_321}
+			FIELD_TYPE_YEAR,
+			FIELD_TYPE_NEWDATE,
+{$endif}
+			FIELD_TYPE_ENUM := 247,
+			FIELD_TYPE_SET := 248,
+			FIELD_TYPE_TINY_BLOB := 249,
+			FIELD_TYPE_MEDIUM_BLOB := 250,
+			FIELD_TYPE_LONG_BLOB :=251,
+			FIELD_TYPE_BLOB :=252,
+			FIELD_TYPE_VAR_STRING :=253,
+			FIELD_TYPE_STRING:=254);
+
+Const
+FIELD_TYPE_CHAR = FIELD_TYPE_TINY;		{ For compability }
+FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM;  	{ For compability }
+
+Procedure sql_free (root : PMEM_ROOT);stdcall;
+Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);stdcall;
+Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;stdcall;
+Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;stdcall;
+Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;stdcall;
+Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal): longint;stdcall;
+
+{
+extern unsigned long max_allowed_packet;
+extern unsigned long net_buffer_length;
+}
+
+{
+#define net_new_transaction(net) ((net)->pkt_nr=0)
+}
+
+Function  my_net_init(net :PNET; fd : Socket) : Longint;stdcall;
+procedure net_end(net : PNET);stdcall;
+Procedure net_clear(net : PNET);stdcall;
+Function  net_flush(net : PNET) : longint;stdcall;
+Function  my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;stdcall;
+Function  net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;stdcall;
+Function  net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;stdcall;
+Function  my_net_read(net : PNET) : Cardinal;stdcall;
+
+Type
+TRand_struct  = record
+  seed,seed2,max_value : Cardinal;
+  max_value_dbl : double;
+end;
+PRand_struct = ^TRand_struct;
+
+{ The following is for user defined functions }
+
+Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT);
+
+st_udf_args = record
+  arg_count : cardinal; 		{ Number of arguments }
+  arg_type : ^Item_result;		{ Pointer to item_results }
+  args : ppchar;			{ Pointer to argument }
+  lengths : PCardinal;	        	{ Length of string arguments }
+end;
+TUDF_ARGS = st_udf_args;
+PUDPF_ARGS = ^TUDF_ARGS;
+
+  { This holds information about the result }
+
+st_udf_init = record
+  maybe_null : my_bool;			{ 1 if function can return NULL }
+  decimals : cardinal;  		{ for real functions }
+  max_length : Cardinal;		{ For string functions }
+  ptr : PChar;				{ free pointer for function data }
+end;
+TUDF_INIT = st_udf_init;
+PUDF_INIT = TUDF_INIT;
+
+  { Prototypes to password functions }
+
+procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);stdcall;
+Function  rnd(rand : Prand_struct) : double;stdcall;
+procedure make_scrambled_password(toarg, passwd : Pchar);stdcall;
+procedure get_salt_from_password(res : pcardinal; password : pchar);stdcall;
+procedure scramble(toarg,message,password : pchar; old_ver : my_bool);stdcall;
+function  check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;stdcall;
+function  get_tty_password(opt_message:  pchar) : pchar;stdcall;
+
+{
+#define NULL_LENGTH ((unsigned long) ~0) { For net_store_length }
+}
+
+implementation
+
+Procedure sql_free (root : PMEM_ROOT);stdcall;external;
+Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);stdcall;external;
+Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;stdcall;external;
+Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;stdcall;external;
+Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;stdcall;external;
+Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal) : longint;stdcall;external;
+Function  my_net_init(net :PNET; fd : Socket) : Longint;stdcall;external;
+procedure net_end(net : PNET);stdcall;external;
+Procedure net_clear(net : PNET);stdcall;external;
+Function  net_flush(net : PNET) : longint;stdcall;external;
+Function  my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;stdcall;external;
+Function  net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;stdcall;external;
+Function  net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;stdcall;external;
+Function  my_net_read(net : PNET) : Cardinal;stdcall;external;
+procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);stdcall;external;
+Function  rnd(rand : Prand_struct) : double;stdcall;external;
+procedure make_scrambled_password(toarg, passwd : Pchar);stdcall;external;
+procedure get_salt_from_password(res : pcardinal; password : pchar);stdcall;external;
+procedure scramble(toarg,message,password : pchar; old_ver : my_bool);stdcall;external;
+function  check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;stdcall;external;
+function  get_tty_password(opt_message:  pchar) : pchar;stdcall;external;
+
+end.
   $Log$
-  Revision 1.1  2002-01-29 17:54:53  peter
-    * splitted to base and extra
-
-  Revision 1.5  2001/04/13 18:04:56  peter
-    * added missing $ifndef win32
-
-  Revision 1.4  2001/03/13 08:50:38  michael
-  + merged Fixed calling convention for win32
-
-  Revision 1.3  2000/12/02 15:24:37  michael
-  + Merged changes from fixbranch
-
-  Revision 1.2  2000/07/13 11:33:26  michael
-  + removed logs
-
-}
+  Revision 1.2  2002-08-26 17:52:31  michael
+  + Upgraded to 3.23
+
+  Revision 1.3  2000/12/02 15:24:37  michael
+  + Merged changes from fixbranch
+
+  Revision 1.2  2000/07/13 11:33:26  michael
+  + removed logs
+ 
+}

+ 18 - 5
packages/base/mysql/mysql_version.pp

@@ -1,25 +1,38 @@
 unit mysql_version;
 
+{$undef use_mysql_321} { if undefined, use mysql 3.23 interface }
+
+
 {
   Translated from mysql_version.h by Michael Van Canneyt
   ([email protected])
+
+  updated to match version 3.23 header files of mysql by Bernhard Steffen
+  ([email protected])
 }
 
 interface
 
+
 { Version numbers for protocol & mysqld }
 Const
 
- MYSQL_SERVER_VERSION : pchar ='3.21.28-gamma';
- FRM_VER = 6;
- MYSQL_VERSION_ID =32128;
+{$ifdef use_mysql_321}
+  MYSQL_SERVER_VERSION : pchar ='3.21.28-gamma';
+  FRM_VER = 6;
+  MYSQL_VERSION_ID =32128;
+{$else}
+  MYSQL_SERVER_VERSION : pchar ='3.23.34';
+  FRM_VER = 6; { ??? }
+  MYSQL_VERSION_ID =32334;
+{$endif}
 
 implementation
 
 end.
   $Log$
-  Revision 1.1  2002-01-29 17:54:53  peter
-    * splitted to base and extra
+  Revision 1.2  2002-08-26 17:52:31  michael
+  + Upgraded to 3.23
 
   Revision 1.2  2000/07/13 11:33:26  michael
   + removed logs