Browse Source

+ Merged changes from fixbranch

michael 25 years ago
parent
commit
6019317548
4 changed files with 145 additions and 102 deletions
  1. 42 22
      packages/mysql/mysql.pp
  2. 69 56
      packages/mysql/mysql_com.pp
  3. 27 21
      packages/mysql/mysqls.c
  4. 7 3
      packages/mysql/mysqls.pp

+ 42 - 22
packages/mysql/mysql.pp

@@ -19,12 +19,8 @@ Const mysqllib = 'mysqlclient';
 {$ifndef win32}
 {$linklib c}
 {$linklib m}
-{ You need to specify the path to libgcc on the command line. }
-{ On my machine this is '-k-L/usr/lib/gcc-lib/i486-linux/2.7.2.1' }
-{$linklib gcc}
 {$endif}
 
-
 { All is 4-byte aligned on my machine. }
 {$packrecords 4}
 
@@ -40,7 +36,6 @@ Var
   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)
@@ -64,6 +59,12 @@ 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 }
@@ -76,7 +77,8 @@ PMYSQL_ROWS = ^TMYSQL_ROWS;
 TMYSQL_ROW_OFFSET = PMYSQL_ROWS;	{ offset to current row }
 
 st_mysql_data  = record
-  rows, fields : cardinal;
+  rows   : my_ulonglong; 
+  fields : cardinal;
   data : PMYSQL_ROWS;
   alloc : TMEM_ROOT;
 end;
@@ -84,33 +86,44 @@ 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;
+  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 : cardinal;
-  insert_id : cardinal;		{ id if insert on table with NEXTNR }
-  extra_info : cardinal;		{ Used by mysqlshow }
+  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 : cardinal;
+  row_count : my_ulonglong; 
   field_count, current_field : cardinal;
   fields :         PMYSQL_FIELD;
   data :           PMYSQL_DATA;
@@ -128,15 +141,15 @@ PMYSQL_RES  = ^TMYSQL_RES;
 
 { Translated Macros }
 
-Function mysql_num_rows (res : PMYSQL_RES) : Cardinal;
+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): Cardinal; 
-Function mysql_insert_id(mysql : PMYSQL): 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; 
@@ -228,7 +241,7 @@ begin
  mysql_error:=mysql^.net.last_error
 end;
 
-Function mysql_num_rows (res : PMYSQL_RES) : Cardinal;
+Function mysql_num_rows (res : PMYSQL_RES) : my_ulonglong;  
 
 begin
   mysql_num_rows:=res^.row_count
@@ -272,11 +285,15 @@ end;
 
 Function mysql_affected_rows(mysql : PMYSQL): Cardinal;
 
+<<<<<<< mysql.pp
+=======
+Function mysql_affected_rows(mysql : PMYSQL): my_ulonglong; 
+>>>>>>> 1.1.2.1
 begin
   mysql_affected_rows:=mysql^.affected_rows
 end;
 
-Function mysql_insert_id(mysql : PMYSQL): Cardinal;
+Function mysql_insert_id(mysql : PMYSQL): my_ulonglong; 
 
 begin
   mysql_insert_id:=mysql^.insert_id
@@ -306,8 +323,11 @@ begin
   mysql_thread_id:=mysql^.thread_id
 end;
 
-end.  $Log$
-end.  Revision 1.2  2000-07-13 11:33:26  michael
-end.  + removed logs
-end. 
-}
+end.
+
+{
+  $Log$
+  Revision 1.3  2000-12-02 15:24:37  michael
+  + Merged changes from fixbranch
+
+}

+ 69 - 56
packages/mysql/mysql_com.pp

@@ -12,56 +12,56 @@ interface
 
 {$packrecords 4}
 { Extra types introduced for pascal }
-Type
+Type 
   pbyte = ^byte;
   pcardinal = ^cardinal;
   Socket = longint;
   my_bool = byte;
 
 Const
- NAME_LEN  = 64 ;               { Field/table name length }
+ NAME_LEN  = 64 ;		{ Field/table name length }
  LOCAL_HOST : pchar = 'localhost' ;
 
- MYSQL_PORT = 3306;             { Alloced by ISI for MySQL }
+ 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);
+			  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;
+ 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 }
+ 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 }
+ 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 }
+ 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 }
+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;
@@ -83,13 +83,20 @@ 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 : Pchar;
+  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;
@@ -99,24 +106,24 @@ Const
 
 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);
+			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 }
+FIELD_TYPE_CHAR = FIELD_TYPE_TINY;		{ For compability }
+FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM;  	{ For compability }
 
 Procedure sql_free (root : PMEM_ROOT);cdecl;
 Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);cdecl;
@@ -155,10 +162,10 @@ PRand_struct = ^TRand_struct;
 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 }
+  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;
@@ -166,10 +173,10 @@ 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 }
+  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;
@@ -184,6 +191,9 @@ procedure scramble(toarg,message,password : pchar; old_ver : my_bool);cdecl;
 function  check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;cdecl;
 function  get_tty_password(opt_message:  pchar) : pchar;cdecl;
 
+{
+#define NULL_LENGTH ((unsigned long) ~0) { For net_store_length }
+}
 
 implementation
 
@@ -211,7 +221,10 @@ function  get_tty_password(opt_message:  pchar) : pchar;cdecl;external;
 
 end.
   $Log$
-  Revision 1.2  2000-07-13 11:33:26  michael
+  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
  
 }

+ 27 - 21
packages/mysql/mysqls.c

@@ -1,21 +1,27 @@
-#include <mysql.h>
-#include <stdio.h>
-
-main ()
-{
-  my_bool i;
-  NET n;
-  printf ("MYSQL : %d\n",sizeof(MYSQL));
-  printf ("MYSQL_DATA : %d\n",sizeof(MYSQL_DATA));
-  printf ("MYSQL_ROWS : %d\n",sizeof(MYSQL_ROWS));
-  printf ("MYSQL_ROW : %d\n",sizeof(MYSQL_ROW));
-  printf ("MYSQL_FIELD : %d\n",sizeof(MYSQL_FIELD));
-  printf ("MYSQL_RES : %d\n",sizeof(MYSQL_RES));
-  printf ("MEM_ROOT : %d\n",sizeof(MEM_ROOT));
-  printf ("my_bool : %d\n",sizeof(my_bool));
-  printf ("NET : %d\n",sizeof(NET));
-  printf ("USED_MEM : %d\n",sizeof(USED_MEM));
-  printf ("new: %d\n",sizeof(char [MYSQL_ERRMSG_SIZE]));
-  i=n.error;
-}
-
+#include <mysql.h>
+#include <mysql_com.h>
+#include <stdio.h>
+
+main ()
+{
+  my_bool i;
+  NET n;
+  enum enum_net_type nettype;
+  struct st_mysql_options options;
+  my_ulonglong llong;
+  
+  printf ("MYSQL : %d options : %d\n",sizeof(MYSQL),sizeof(options));
+  printf ("MYSQL_DATA : %d\n",sizeof(MYSQL_DATA));
+  printf ("MYSQL_ROWS : %d\n",sizeof(MYSQL_ROWS));
+  printf ("MYSQL_ROW : %d\n",sizeof(MYSQL_ROW));
+  printf ("MYSQL_FIELD : %d\n",sizeof(MYSQL_FIELD));
+  printf ("MYSQL_RES : %d\n",sizeof(MYSQL_RES));
+  printf ("MEM_ROOT : %d\n",sizeof(MEM_ROOT));
+  printf ("my_bool : %d\n",sizeof(my_bool));
+  printf ("NET : %d NET.nettype : %d\n",sizeof(NET),sizeof(nettype));
+  printf ("USED_MEM : %d\n",sizeof(USED_MEM));
+  printf ("new: %d\n",sizeof(char [MYSQL_ERRMSG_SIZE]));
+  printf ("longlong: %d\n",sizeof(llong));
+  i=n.error;
+}
+

+ 7 - 3
packages/mysql/mysqls.pp

@@ -4,7 +4,8 @@ uses mysql,mysql_com;
 
 
 begin
-  Writeln ('MYSQL : ',sizeof(TMYSQL));
+  Writeln('PASCAL');
+  Writeln ('MYSQL : ',sizeof(TMYSQL),' options : ',sizeof(st_mysql_options));
   writeln ('MYSQL_DATA : ',sizeof(TMYSQL_DATA));
   writeln ('MYSQL_ROWS : ',sizeof(TMYSQL_ROWS));
   writeln ('MYSQL_ROW : ',sizeof(TMYSQL_ROW));
@@ -12,11 +13,14 @@ begin
   writeln ('MYSQL_RES : ',sizeof(TMYSQL_RES));
   writeln ('MEM_ROOT : ',sizeof(TMEM_ROOT));
   writeln ('my_bool : ',sizeof(my_bool));
-  writeln ('TNET : ',sizeof(TNET));
+  writeln ('TNET : ',sizeof(TNET),' TNET.nettype : ',SizeOf(net_type));
   writeln ('USED_MEM : ',sizeof(TUSED_MEM));
 end.
   $Log$
-  Revision 1.2  2000-07-13 11:33:26  michael
+  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
  
 }