2001-10-29 14:14 GMT+1 Maurilio Longo <maurilio.longo@libero.it>

* contrib/mysql/readme.txt
     * updated
   - contrib/mysql/mysql.h
   - contrib/mysql/mysql_com.h
   - contrib/mysql/mysql_version.h
     - removed OS/2 only include files
This commit is contained in:
Maurilio Longo
2001-10-29 13:16:49 +00:00
parent 4b994e2dc9
commit 6aae98c66e
5 changed files with 71 additions and 408 deletions

View File

@@ -1,3 +1,11 @@
2001-10-29 14:14 GMT+1 Maurilio Longo <maurilio.longo@libero.it>
* contrib/mysql/readme.txt
* updated
- contrib/mysql/mysql.h
- contrib/mysql/mysql_com.h
- contrib/mysql/mysql_version.h
- removed OS/2 only include files
2001-10-27 22:40 GMT -3 Luiz Rafael Culik<culik@sl.conex.net>
* contrib/mysql/mysql.c
* Fixed an small bug on SQLCONNECT
@@ -33,7 +41,7 @@
* Tidied up the indentation of the functions towards the end of the
file. The indentation had somehow got lost at some point in the
past.
2001-10-24 20:08 GMT+7 Andi Jahja <harnour@cbn.net.id>
* source/rdd/dbcmd.c
! Add casts to quite MsVC
@@ -48,7 +56,7 @@
2001-10-23 20:08 GMT-3 Horacio Roldan <harbour_ar@yahoo.com.ar>
* source/rdd/dbcmd.c
! Fixed bug in dbCreate, that affected DBF RDD derived
! Fixed bug in dbCreate, that affected DBF RDD derived
(ntx & cdx) with memo files.
2001-10-23 14:10 GMT+3 Alexander Kresin <alex@belacy.belgorod.su>
@@ -87,7 +95,7 @@
* Added missing continuation character to line 14.
* utils/hbmake/hbmutils.prg
* Adding missing ")" to `if' in line 21.
2001-10-20 20:00 GMT -3 Luiz Rafael Culik<culik@sl.conex.net>
* source/compiler/harbour.c
* Changed some function parameters in the _DECL section
@@ -98,7 +106,7 @@
using the -ex or -elx tells hbmake to use harbour .obj generation capabilities
% many For/Next Loop replaced for an fastern Aeval() function call
* Support for generating output files in other dir
+ utils/hbmake/hbmutils.prg
* All utilities function inside hbmake.prg was moved to this module
* utils/hbmake/pickfile.prg
@@ -137,12 +145,12 @@
2001-10-19 18:42 GMT-3 Horacio Roldan <harbour_ar@yahoo.com.ar>
* source/rdd/dbfcdx/dbfcdx1.c
! fixed ordSetFocus related, if the previos order was 0, it did nothing
! fixed ordSetFocus related, was comparing case sensitive
! fixed ordSetFocus related, was comparing case sensitive
2001-10-19 07:50 GMT -3 Luiz Rafael Culik<culik@sl.conex.net>
*source/compiler/harbour.c
*Fixed some warings reported by Dave Person
2001-10-18 22:10 GMT -3 Luiz Rafael Culik<culik@sl.conex.net>
*source/rtl/profiler.prg
* fixed an small bug: Is was looking for an internel class
@@ -177,9 +185,9 @@
2001-10-10 10:07 GMT Dave Pearson <davep@davep.org>
* source/rtl/tbrowse.prg
* Fixed bug in :insColumn() as reported by Andreas Moroder in
* Fixed bug in :insColumn() as reported by Andreas Moroder in
<URL:news:comp.lang.clipper>.
2001-10-08 21:30 GMT -3 Luiz Rafael Culik<culik@sl.conex.net>
*source/rtl/isprint.c
contrib/libct/files.c
@@ -211,7 +219,7 @@
* doc/gmake.txt
* source/rtl/filesys.c
* source/rtl/idle.c
! Cygwin fixes.
! Cygwin fixes.
2001-10-03 17:30 UTC-0400 David G. Holm <dholm@jsd-llc.com>
@@ -244,19 +252,19 @@
! DBEDIT() - Restored CA-Cl*pper compatibility.
* source/rtl/tbrowse.prg
! Fixed AutoLite/Hilite/DeHilite() support. Now DBEDIT() works
! Fixed AutoLite/Hilite/DeHilite() support. Now DBEDIT() works
as expected.
2001-09-27 01:52 GMT-3 Horacio Roldan <harbour_ar@yahoo.com.ar>
* source/rtl/memofile.c
* Fixed: MemoWrit added an EOF (0x1A) everytime
* Fixed: MemoWrit added an EOF (0x1A) everytime
(under Windows), Reported by Brian Hays.
* Fixed: MemoRead didn't strip the EOF char
(under Windows).
2001-09-26 18:38 GMT-3 Horacio Roldan <harbour_ar@yahoo.com.ar>
* source/rtl/dbedit.prg
* Fixed no-hilighting problem, sent by Wilson Velazquez
* Fixed no-hilighting problem, sent by Wilson Velazquez
2001-09-24 08:45 GMT+1 Antonio Linares <alinares@fivetech.com>
- contrib/hgf/gtk/tform.prg

View File

@@ -1,205 +0,0 @@
/*
* $Id$
*/
/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
This file is public domain and comes with NO WARRANTY of any kind */
/* defines for libmysql */
#ifndef _mysql_h
#define _mysql_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _global_h /* If not standard header */
#include <sys/types.h>
typedef char my_bool;
#if !defined(__WIN32__) && !defined(WIN32)
#define STDCALL
typedef char byte;
#else
#define STDCALL __stdcall
#endif
typedef char * gptr;
#ifndef ST_USED_MEM_DEFINED
#define ST_USED_MEM_DEFINED
typedef struct st_used_mem { /* struct for once_alloc */
struct st_used_mem *next; /* Next block in use */
unsigned int left; /* memory left in block */
unsigned int size; /* size of block */
} USED_MEM;
typedef struct st_mem_root {
USED_MEM *free;
USED_MEM *used;
unsigned int min_malloc;
unsigned int block_size;
void (*error_handler)(void);
} MEM_ROOT;
#endif
#ifndef Socket_defined
#ifdef __WIN32__
#define Socket SOCKET
#else
typedef int Socket;
#endif
#endif
#endif
#include "mysql_com.h"
#include "mysql_version.h"
extern unsigned int mysql_port;
extern char *mysql_unix_port;
#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 || (t) == FIELD_TYPE_YEAR)
typedef struct st_mysql_field {
char *name; /* Name of column */
char *table; /* Table of column if column was a field */
char *def; /* Default value (set by mysql_list_fields) */
enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
unsigned int length; /* Width of column */
unsigned int max_length; /* Max width of selected set */
unsigned int flags; /* Div flags */
unsigned int decimals; /* Number of decimals in field */
} MYSQL_FIELD;
typedef byte **MYSQL_ROW; /* return data as array of strings */
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
typedef struct st_mysql_rows {
struct st_mysql_rows *next; /* list of rows */
MYSQL_ROW data;
} MYSQL_ROWS;
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
typedef struct st_mysql_data {
unsigned int rows;
unsigned int fields;
MYSQL_ROWS *data;
MEM_ROOT alloc;
} MYSQL_DATA;
enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
MYSQL_STATUS_USE_RESULT};
typedef struct st_mysql {
NET net; /* Communication parameters */
char *host,*user,*passwd,*unix_socket,*server_version,*host_info,
*info,*db;
unsigned int port,client_flag,server_capabilities;
unsigned int protocol_version;
unsigned int field_count;
unsigned long thread_id; /* Id for connection in server */
unsigned long affected_rows;
unsigned long insert_id; /* id if insert on table with NEXTNR */
unsigned long extra_info; /* Used by mysqlshow */
enum mysql_status status;
MYSQL_FIELD *fields;
MEM_ROOT field_alloc;
my_bool free_me; /* If free in mysql_close */
my_bool reconnect; /* set to 1 if automatic reconnect */
} MYSQL;
typedef struct st_mysql_res {
unsigned long row_count;
unsigned int field_count, current_field;
MYSQL_FIELD *fields;
MYSQL_DATA *data;
MYSQL_ROWS *data_cursor;
MEM_ROOT field_alloc;
MYSQL_ROW row; /* If unbuffered read */
MYSQL_ROW current_row; /* buffer to current row */
unsigned int *lengths; /* column lengths of current row */
MYSQL *handle; /* for unbuffered reads */
my_bool eof; /* Used my mysql_fetch_row */
} MYSQL_RES;
#define mysql_num_rows(res) (res)->row_count
#define mysql_num_fields(res) (res)->field_count
#define mysql_eof(res) (res)->eof
#define mysql_fetch_field_direct(res,fieldnr) ((res)->fields[fieldnr])
#define mysql_fetch_fields(res) (res)->fields
#define mysql_row_tell(res) (res)->data_cursor
#define mysql_field_tell(res) (res)->current_field
#define mysql_affected_rows(mysql) (mysql)->affected_rows
#define mysql_insert_id(mysql) (mysql)->insert_id
#define mysql_error(mysql) (mysql)->net.last_error
#define mysql_errno(mysql) (mysql)->net.last_errno
#define mysql_info(mysql) (mysql)->info
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
#define mysql_thread_id(mysql) (mysql)->thread_id
/* void STDCALL mysql_init(MYSQL *mysql); */
MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
const char *user, const char *passwd);
#if MYSQL_VERSION_ID >= 32200
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
const char *user,
const char *passwd,
const char *db,
unsigned int port,
const char *unix_socket,
unsigned int clientflag);
#else
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
const char *user,
const char *passwd,
unsigned int port,
const char *unix_socket,
unsigned int clientflag);
#endif
void STDCALL mysql_close(MYSQL *sock);
int STDCALL mysql_select_db(MYSQL *mysql, const char *db);
int STDCALL mysql_query(MYSQL *mysql, const char *q);
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
unsigned int length);
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
int STDCALL mysql_shutdown(MYSQL *mysql);
int STDCALL mysql_dump_debug_info(MYSQL *mysql);
int STDCALL mysql_refresh(MYSQL *mysql,
unsigned int refresh_options);
int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
char * STDCALL mysql_stat(MYSQL *mysql);
char * STDCALL mysql_get_server_info(MYSQL *mysql);
char * STDCALL mysql_get_client_info(void);
char * STDCALL mysql_get_host_info(MYSQL *mysql);
unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql);
MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
const char *wild);
MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql);
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
void STDCALL mysql_free_result(MYSQL_RES *result);
void STDCALL mysql_data_seek(MYSQL_RES *mysql,unsigned int offset);
MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *mysql, MYSQL_ROW_OFFSET);
MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *mysql,
MYSQL_FIELD_OFFSET offset);
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *mysql);
unsigned int * STDCALL mysql_fetch_lengths(MYSQL_RES *mysql);
MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *handle);
unsigned int STDCALL mysql_escape_string(char *to,const char *from,
unsigned int from_length);
void STDCALL mysql_debug(char *debug);
/* new api functions */
#define HAVE_MYSQL_REAL_CONNECT
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,160 +0,0 @@
/*
* $Id$
*/
/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
This file is public domain and comes with NO WARRANTY of any kind */
/*
** Common definition between mysql server & client
*/
#ifndef _mysql_com_h
#define _mysql_com_h
#ifdef __cplusplus
extern "C" {
#endif
#define NAME_LEN 64 /* Field/table name length */
#define LOCAL_HOST "localhost"
#define MYSQL_PORT 3306 /* Alloced by ISI for MySQL */
#define MYSQL_UNIX_ADDR "\\socket\\mysql.sock"
enum 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};
#define NOT_NULL_FLAG 1 /* Field can't be NULL */
#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
#define BLOB_FLAG 16 /* Field is a blob */
#define UNSIGNED_FLAG 32 /* Field is unsigned */
#define ZEROFILL_FLAG 64 /* Field is zerofill */
#define BINARY_FLAG 128
/* The following are only sent to new clients */
#define ENUM_FLAG 256 /* field is an enum */
#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
#define GROUP_FLAG 32768 /* Intern group field */
#define REFRESH_GRANT 1 /* Refresh grant tables */
#define REFRESH_LOG 2 /* Start on new log file */
#define REFRESH_TABLES 4 /* close all tables */
#define REFRESH_HOSTS 8 /* Flush host cache */
#define REFRESH_FAST 32768 /* Intern flag */
#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
#define CLIENT_LONG_FLAG 4 /* Get all column flags */
#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
#define MYSQL_ERRMSG_SIZE 200
#define NET_READ_TIMEOUT 30 /* Timeout on read */
#define NET_WRITE_TIMEOUT 60 /* Timeout on write */
#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
typedef struct st_net {
Socket fd;
int fcntl;
unsigned char *buff,*buff_end,*write_pos;
char last_error[MYSQL_ERRMSG_SIZE];
unsigned int last_errno,max_packet,timeout,pkt_nr;
my_bool error,return_errno;
} NET;
#define packet_error ((unsigned int) -1)
enum 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_YEAR,
FIELD_TYPE_NEWDATE,
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
};
#define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */
#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compability */
extern unsigned long max_allowed_packet;
extern unsigned long net_buffer_length;
#define net_new_transaction(net) ((net)->pkt_nr=0)
int my_net_init(NET *net,Socket fd);
void net_end(NET *net);
void net_clear(NET *net);
int net_flush(NET *net);
int my_net_write(NET *net,const byte *packet,unsigned int len);
int net_write_command(NET *net,unsigned char command,const byte *packet,
unsigned int len);
int net_real_write(NET *net,const byte *packet,unsigned int len);
unsigned int my_net_read(NET *net);
struct rand_struct {
unsigned long seed,seed2,max_value;
double max_value_dbl;
};
/* The following is for user defined functions */
enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT};
typedef struct st_udf_args
{
unsigned int arg_count; /* Number of arguments */
enum Item_result *arg_type; /* Pointer to item_results */
char **args; /* Pointer to argument */
unsigned long *lengths; /* Length of string arguments */
} UDF_ARGS;
/* This holds information about the result */
typedef struct st_udf_init
{
my_bool maybe_null; /* 1 if function can return NULL */
unsigned int decimals; /* for real functions */
unsigned int max_length; /* For string functions */
char *ptr; /* free pointer for function data */
} UDF_INIT;
/* Prototypes to password functions */
void randominit(struct rand_struct *rand,unsigned long seed1,
unsigned long seed2);
double rnd(struct rand_struct *rand);
void make_scrambled_password(char *to,const char *password);
void get_salt_from_password(unsigned long *res,const char *password);
char *scramble(char *to,const char *message,const char *password,
my_bool old_ver);
my_bool check_scramble(const char *scramble,const char *message,
unsigned long *salt,my_bool old_ver);
char *get_tty_password(char *opt_message);
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
#ifdef __WIN32__
#define socket_errno WSAGetLastError()
#else
#define socket_errno errno
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,13 +0,0 @@
/*
* $Id$
*/
/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
This file is public domain and comes with NO WARRANTY of any kind */
/* Version numbers for protocol & mysqld */
#define MYSQL_SERVER_VERSION "3.21.33b"
#define FRM_VER 6
#define MYSQL_VERSION_ID 32133

View File

@@ -2,30 +2,60 @@
* $Id$
*/
24/july/2000 - Harbour MySQL access classes - readme file
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ 29/october/2001 - Harbour MySQL access classes - readme file ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
This is work in progress, so it has to be fully tested and needs a few more methods to cover MySQL possibilities.
This set of files gives you a mean to access a MySQL server, I've developed and tested them on a OS/2 platform,
so changes to Makefile and import library for different platforms are not present.
In their present state MySQL classes are made up of these files:
mysql.c: low level wrapper around MySQL client API. It requires libmysqlclient.a library
mysql.h,
mysql_com.h,
mysql_version.h: from MySQL distribution, type and defines of MySQL client api (under OS/2 with OS/2 port of
MySql you need to use the one from 3.21.33b build which is the only one with a single
threaded libmysqlclient.a client library and works ok even with latest MySQL/2 availble).
mysql.ch: clipper level defines of MySQL types
tmysql.prg: MySQL access classes
test.prg: a little test program which wont work for you :-) since it uses a .dbf file not
provided. Use it as a small tutorial of tmysql.prg provided functions.
Makefile: my makefile for OS/2 gcc, you'll surely need to change it to adapt to your needs/platform.
mysql.c : low level wrapper around MySQL client API. It requires libmysqlclient.a library
mysql.ch : clipper level defines of MySQL types
tmysql.prg : MySQL access classes
test.prg : a little test program which wont work for you :-) since it uses a .dbf file not
provided. Use it as a small tutorial of tmysql.prg provided functions.
Makefile : my makefile for OS/2 gcc, you'll surely need to change it to adapt to your needs/platform.
makefile.bc,
make_b32.bat: batch file and makefile to build tmysql.lib on win32
You will also need all .h files from include subdir of your installed MySQL server, at a bare minimum
they are:
mysql.h, mysql_com.h, mysql_version.h
(under OS/2 with OS/2 port of MySql you need to use the one from 3.21.33b build which is the only one with
a single threaded libmysqlclient.a client library and works ok even with latest MySQL/2 availble).
To build this library on win32 (using freely available Borland C++ compiler) you
need to follow these steps:
1) go to www.mysql.com and download any version you like of mysql. Install
it. Now you have an include subdir with .h files with the same version
number as your mysql.dll.
This is very important. You need to use .h files from the package you
install.
2) Replace inside \contrib\mysql all .h file with the ones from mysql
include subdir.
3) Do a "make install" inside \contrib\mysql to build mysql.lib.
4) Use implib from borland free bcc to create an import library for
mysql.dll and call it mysqldll.lib
5) Link mysql.lib and mysqldll.lib to your harbour program (you can try to
recompile dbf2mysql inside \contrib\mysql just to test everything) and
be sure to have mysql.dll on your path.
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ Available Classes ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
tmysql.prg defines four classes:
@@ -45,11 +75,14 @@ TMySQLTable: It's a descendant of a TMySQLQuery and you'll receive it when you
TMySQLRow: Every row returned by a SELECT is converted to a TMySQLRow object. This object handles
fields and has methods to access fields given a field name or position.
I'm aware that this brief document doesn't explain a lot about MySQL access classes and I'm sorry for that.
I'm aware that this brief document doesn't explain a lot about MySQL access classes and I'm sorry for that
(please read the souce code, it has quite a few comments which can help you understand what's going on)
I'll try to update it as work on these classes goes by and I'll like to receive feedbak and suggestions
from users (if any :-))
Excuse my poor english and happy selecting :-)
Maurilio Longo - maurilio.longo@libero.it
Maurilio Longo - <maurilio.longo@libero.it>