--- parser3/src/sql/mysql/Attic/parser3mysql.C 2001/04/17 15:13:42 1.13.2.4 +++ parser3/src/sql/mysql/Attic/parser3mysql.C 2001/05/17 08:42:22 1.16 @@ -1,11 +1,11 @@ /** @file - Parser: MySQL driver. + Parser MySQL driver. Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: parser3mysql.C,v 1.13.2.4 2001/04/17 15:13:42 paf Exp $ + $Id: parser3mysql.C,v 1.16 2001/05/17 08:42:22 parser Exp $ */ #include "config_includes.h" @@ -53,14 +53,18 @@ public: const char *initialize(const char *dlopen_file_spec) { return dlink(dlopen_file_spec); } - /// connect + /** connect + @param used_only_to_connect_url + format: @b user:pass@host[:port]/database/charset + 3.23.22b + Currently the only option for @b character_set_name is cp1251_koi8. + WARNING: must be used only to connect, for buffer doesn't live long + */ void connect( - char *url, /**< @b user:pass@host[:port]/database/charset - 3.23.22b - Currently the only option for character_set_name is cp1251_koi8 */ + char *used_only_to_connect_url, void **connection ///< output: MYSQL * ) { - char *user=url; + char *user=used_only_to_connect_url; char *host=lsplit(user, '@'); char *db=lsplit(host, '/'); char *pwd=lsplit(user, ':'); @@ -144,6 +148,9 @@ public: } *column_count=mysql_num_fields(res); + if(!*column_count) // old client + *column_count=mysql_field_count(mysql); + *columns=(Cell *)services->malloc(sizeof(Cell)*(*column_count)); *row_count=(unsigned long)mysql_num_rows(res); @@ -175,23 +182,14 @@ public: private: // mysql client library funcs -#ifndef STDCALL -# if !defined(WIN32) -# define STDCALL -# else -# define STDCALL __stdcall -# endif -#endif - typedef MYSQL* (STDCALL *t_mysql_init)(MYSQL *); t_mysql_init mysql_init; + typedef MYSQL_RES* (STDCALL *t_mysql_store_result)(MYSQL *); t_mysql_store_result mysql_store_result; + typedef int (STDCALL *t_mysql_query)(MYSQL *, const char *q); t_mysql_query mysql_query; + typedef char * (STDCALL *t_mysql_error)(MYSQL *); t_mysql_error mysql_error; -#ifndef mysql_error - static char* STDCALL subst_mysql_error(MYSQL *mysql) { - return (mysql)->net.last_error; - } -#endif + static char* STDCALL subst_mysql_error(MYSQL *mysql) { return (mysql)->net.last_error; } typedef MYSQL* (STDCALL *t_mysql_real_connect)(MYSQL *, const char *host, const char *user, @@ -202,32 +200,28 @@ private: // mysql client library funcs unsigned int clientflag); t_mysql_real_connect mysql_real_connect; typedef void (STDCALL *t_mysql_close)(MYSQL *); t_mysql_close mysql_close; + typedef int (STDCALL *t_mysql_ping)(MYSQL *); t_mysql_ping mysql_ping; + typedef unsigned long (STDCALL *t_mysql_escape_string)(char *to,const char *from, unsigned long from_length); t_mysql_escape_string mysql_escape_string; + typedef void (STDCALL *t_mysql_free_result)(MYSQL_RES *result); t_mysql_free_result mysql_free_result; + typedef unsigned long* (STDCALL *t_mysql_fetch_lengths)(MYSQL_RES *result); t_mysql_fetch_lengths mysql_fetch_lengths; + typedef MYSQL_ROW (STDCALL *t_mysql_fetch_row)(MYSQL_RES *result); t_mysql_fetch_row mysql_fetch_row; + typedef MYSQL_FIELD* (STDCALL *t_mysql_fetch_field)(MYSQL_RES *result); t_mysql_fetch_field mysql_fetch_field; + typedef my_ulonglong (STDCALL *t_mysql_num_rows)(MYSQL_RES *); t_mysql_num_rows mysql_num_rows; -#ifndef mysql_num_rows - static my_ulonglong STDCALL subst_mysql_num_rows(MYSQL_RES *res) { - return res->row_count; - } -#endif + static my_ulonglong STDCALL subst_mysql_num_rows(MYSQL_RES *res) { return res->row_count; } + typedef unsigned int (STDCALL *t_mysql_num_fields)(MYSQL_RES *); t_mysql_num_fields mysql_num_fields; -#ifndef mysql_num_fields - static unsigned int STDCALL subst_mysql_num_fields(MYSQL_RES *res) { - return res->field_count; - } -#endif + static unsigned int STDCALL subst_mysql_num_fields(MYSQL_RES *res) { return res->field_count; } typedef unsigned int (STDCALL *t_mysql_field_count)(MYSQL *); t_mysql_field_count mysql_field_count; -#ifndef mysql_field_count - static unsigned int STDCALL subst_mysql_field_count(MYSQL *mysql) { - return mysql->field_count; - } -#endif + static unsigned int STDCALL subst_mysql_field_count(MYSQL *mysql) { return mysql->field_count; } private: // mysql client library funcs linking