* Merged Andrew Brunners and Lacak2's patches from Mantis #19736 that

implement mysql 5.5 header + sqldb connection support.

git-svn-id: trunk@20534 -
This commit is contained in:
marco 2012-03-17 17:17:40 +00:00
parent e27f910070
commit 2d8dbeca54
10 changed files with 471 additions and 528 deletions

3
.gitattributes vendored
View File

@ -1977,6 +1977,7 @@ packages/fcl-db/src/sqldb/mysql/mysql41conn.pas svneol=native#text/plain
packages/fcl-db/src/sqldb/mysql/mysql4conn.pas svneol=native#text/plain
packages/fcl-db/src/sqldb/mysql/mysql50conn.pas svneol=native#text/plain
packages/fcl-db/src/sqldb/mysql/mysql51conn.pas svneol=native#text/plain
packages/fcl-db/src/sqldb/mysql/mysql55conn.pas svneol=native#text/plain
packages/fcl-db/src/sqldb/mysql/mysqlconn.inc svneol=native#text/plain
packages/fcl-db/src/sqldb/odbc/Makefile svneol=native#text/plain
packages/fcl-db/src/sqldb/odbc/Makefile.fpc svneol=native#text/plain
@ -5129,6 +5130,8 @@ packages/mysql/src/mysql50dyn.pp svneol=native#text/plain
packages/mysql/src/mysql51.pp svneol=native#text/plain
packages/mysql/src/mysql51dyn.pp svneol=native#text/plain
packages/mysql/src/mysql51emb.pp svneol=native#text/plain
packages/mysql/src/mysql55.pp svneol=native#text/plain
packages/mysql/src/mysql55dyn.pp svneol=native#text/plain
packages/ncurses/Makefile svneol=native#text/plain
packages/ncurses/Makefile.fpc svneol=native#text/plain
packages/ncurses/Makefile.fpc.fpcmake svneol=native#text/plain

View File

@ -596,6 +596,17 @@ begin
AddUnit('dbconst');
end;
T:=P.Targets.AddUnit('mysql55conn.pas', SqldbConnectionOSes);
T.ResourceStrings:=true;
with T.Dependencies do
begin
AddInclude('mysqlconn.inc');
AddUnit('bufdataset');
AddUnit('sqldb');
AddUnit('db');
AddUnit('dbconst');
end;
T:=P.Targets.AddUnit('odbcconn.pas', SqldbConnectionOSes);
with T.Dependencies do
begin

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,8 @@
main=fcl-db
[target]
units=mysql40conn mysql41conn mysql50conn mysql4conn mysql51conn
rsts=mysql40conn mysql41conn mysql50conn mysql4conn mysql51conn
units=mysql40conn mysql41conn mysql50conn mysql4conn mysql51conn mysql55conn
rsts=mysql40conn mysql41conn mysql50conn mysql4conn mysql51conn mysql55conn
[require]
packages=fcl-xml mysql

View File

@ -0,0 +1,13 @@
{
Contains the TMysqlConnection for MySQL 5.5
}
unit mysql55conn;
{$DEFINE MYSQL50_UP}
{$DEFINE MYSQL51_UP}
{$DEFINE MYSQL55}
{$i mysqlconn.inc}
end.

View File

@ -5,8 +5,11 @@ interface
uses
Classes, SysUtils,bufdataset,sqldb,db,dynlibs,ctypes,
{$IFDEF Mysql51}
mysql51dyn;
{$IFDEF mysql55}
mysql55dyn;
{$ELSE}
{$IFDEF mysql51}
mysql51dyn;
{$ELSE}
{$IfDef mysql50}
mysql50dyn;
@ -22,9 +25,13 @@ uses
{$EndIf}
{$EndIf}
{$endif}
{$endif}
Const
{$IFDEF Mysql51}
{$IFDEF mysql55}
MySQLVersion = '5.5';
{$else}
{$IFDEF mysql51}
MySQLVersion = '5.1';
{$else}
{$IfDef mysql50}
@ -41,7 +48,7 @@ Const
{$EndIf}
{$EndIf}
{$endif}
{$endif}
Type
TTransactionName = Class(TSQLHandle)
protected
@ -140,39 +147,45 @@ Type
EMySQLError = Class(Exception);
{$IfDef mysql51}
TMySQL51Connection = Class(TConnectionName);
TMySQL51ConnectionDef = Class(TMySQLConnectionDef);
TMySQL51Transaction = Class(TTransactionName);
TMySQL51Cursor = Class(TCursorName);
{$ELSE}
{$IfDef mysql50}
TMySQL50Connection = Class(TConnectionName);
TMySQL50ConnectionDef = Class(TMySQLConnectionDef);
TMySQL50Transaction = Class(TTransactionName);
TMySQL50Cursor = Class(TCursorName);
{$ELSE}
{$IfDef mysql41}
TMySQL41Connection = Class(TConnectionName);
TMySQL41ConnectionDef = Class(TMySQLConnectionDef);
TMySQL41Transaction = Class(TTransactionName);
TMySQL41Cursor = Class(TCursorName);
{$ifdef mysql55}
TMySQL55Connection = Class(TConnectionName);
TMySQL55ConnectionDef = Class(TMySQLConnectionDef);
TMySQL55Transaction = Class(TTransactionName);
TMySQL55Cursor = Class(TCursorName);
{$else}
{$IfDef mysql51}
TMySQL51Connection = Class(TConnectionName);
TMySQL51ConnectionDef = Class(TMySQLConnectionDef);
TMySQL51Transaction = Class(TTransactionName);
TMySQL51Cursor = Class(TCursorName);
{$ELSE}
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
TMySQLConnection = Class(TConnectionName);
TMySQL40ConnectionDef = Class(TMySQLConnectionDef);
TMySQLTransaction = Class(TTransactionName);
TMySQLCursor = Class(TCursorName);
{$IfDef mysql50}
TMySQL50Connection = Class(TConnectionName);
TMySQL50ConnectionDef = Class(TMySQLConnectionDef);
TMySQL50Transaction = Class(TTransactionName);
TMySQL50Cursor = Class(TCursorName);
{$ELSE}
TMySQL40Connection = Class(TConnectionName);
TMySQL40ConnectionDef = Class(TMySQLConnectionDef);
TMySQL40Transaction = Class(TTransactionName);
TMySQL40Cursor = Class(TCursorName);
{$EndIf}
{$IfDef mysql41}
TMySQL41Connection = Class(TConnectionName);
TMySQL41ConnectionDef = Class(TMySQLConnectionDef);
TMySQL41Transaction = Class(TTransactionName);
TMySQL41Cursor = Class(TCursorName);
{$ELSE}
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
TMySQLConnection = Class(TConnectionName);
TMySQL40ConnectionDef = Class(TMySQLConnectionDef);
TMySQLTransaction = Class(TTransactionName);
TMySQLCursor = Class(TCursorName);
{$ELSE}
TMySQL40Connection = Class(TConnectionName);
TMySQL40ConnectionDef = Class(TMySQLConnectionDef);
TMySQL40Transaction = Class(TTransactionName);
TMySQL40Cursor = Class(TCursorName);
{$EndIf}
{$EndIf}
{$endif}
{$EndIf}
{$EndIf}
{$ENDIF}
{$ENDIF}
implementation
@ -195,6 +208,12 @@ const
'MYSQL_SECURE_AUTH'
{$IFDEF MYSQL50_UP}
,'MYSQL_REPORT_DATA_TRUNCATION', 'MYSQL_OPT_RECONNECT'
{$IFDEF mysql51_UP}
,'MYSQL_OPT_SSL_VERIFY_SERVER_CERT'
{$IFDEF mysql55}
,'MYSQL_PLUGIN_DIR', 'MYSQL_DEFAULT_AUTH'
{$ENDIF}
{$ENDIF}
{$ENDIF}
);
@ -436,23 +455,27 @@ end;
function TConnectionName.AllocateCursorHandle: TSQLCursor;
begin
{$IfDef mysql51}
Result:=TMySQL51Cursor.Create;
{$IfDef mysql55}
Result:=TMySQL55Cursor.Create;
{$ELSE}
{$IfDef mysql50}
Result:=TMySQL50Cursor.Create;
{$IfDef mysql51}
Result:=TMySQL51Cursor.Create;
{$ELSE}
{$IfDef mysql41}
Result:=TMySQL41Cursor.Create;
{$IfDef mysql50}
Result:=TMySQL50Cursor.Create;
{$ELSE}
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
Result:=TMySQLCursor.Create;
{$IfDef mysql41}
Result:=TMySQL41Cursor.Create;
{$ELSE}
Result:=TMySQL40Cursor.Create;
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
Result:=TMySQLCursor.Create;
{$ELSE}
Result:=TMySQL40Cursor.Create;
{$EndIf}
{$EndIf}
{$EndIf}
{$EndIf}
{$EndIf}
{$endif}
end;
Procedure TConnectionName.DeAllocateCursorHandle(var cursor : TSQLCursor);
@ -1115,22 +1138,26 @@ end;
class function TMySQLConnectionDef.ConnectionClass: TSQLConnectionClass;
begin
{$IfDef mysql51}
Result:=TMySQL51Connection;
{$IfDef mysql55}
Result:=TMySQL55Connection;
{$ELSE}
{$IfDef mysql50}
Result:=TMySQL50Connection;
{$IfDef mysql51}
Result:=TMySQL51Connection;
{$ELSE}
{$IfDef mysql41}
Result:=TMySQL41Connection;
{$IfDef mysql50}
Result:=TMySQL50Connection;
{$ELSE}
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
Result:=TMySQLConnection;
{$IfDef mysql41}
Result:=TMySQL41Connection;
{$ELSE}
Result:=TMySQL40Connection;
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
Result:=TMySQLConnection;
{$ELSE}
Result:=TMySQL40Connection;
{$EndIf}
{$EndIf}
{$EndIf}
{$EndIf}
{$endif}
{$endif}
end;
@ -1139,37 +1166,44 @@ begin
Result:='Connect to a MySQL '+MySQLVersion+'database directly via the client library';
end;
{$IfDef mysql51}
{$IfDef mysql55}
initialization
RegisterConnection(TMySQL51ConnectionDef);
RegisterConnection(TMySQL55ConnectionDef);
finalization
UnRegisterConnection(TMySQL51ConnectionDef);
{$ELSE}
{$IfDef mysql50}
UnRegisterConnection(TMySQL55ConnectionDef);
{$else}
{$IfDef mysql51}
initialization
RegisterConnection(TMySQL50ConnectionDef);
RegisterConnection(TMySQL51ConnectionDef);
finalization
UnRegisterConnection(TMySQL50ConnectionDef);
UnRegisterConnection(TMySQL51ConnectionDef);
{$ELSE}
{$IfDef mysql41}
{$IfDef mysql50}
initialization
RegisterConnection(TMySQL41ConnectionDef);
RegisterConnection(TMySQL50ConnectionDef);
finalization
UnRegisterConnection(TMySQL41ConnectionDef);
UnRegisterConnection(TMySQL50ConnectionDef);
{$ELSE}
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
{$IfDef mysql41}
initialization
RegisterConnection(TMySQL40ConnectionDef);
RegisterConnection(TMySQL41ConnectionDef);
finalization
UnRegisterConnection(TMySQL40ConnectionDef);
UnRegisterConnection(TMySQL41ConnectionDef);
{$ELSE}
initialization
RegisterConnection(TMySQL40ConnectionDef);
finalization
UnRegisterConnection(TMySQL40ConnectionDef);
{$IFDEF mysql4} // temporary backwards compatibility for Lazarus
initialization
RegisterConnection(TMySQL40ConnectionDef);
finalization
UnRegisterConnection(TMySQL40ConnectionDef);
{$ELSE}
initialization
RegisterConnection(TMySQL40ConnectionDef);
finalization
UnRegisterConnection(TMySQL40ConnectionDef);
{$EndIf}
{$EndIf}
{$EndIf}
{$EndIf}
{$ENDIF}
{$ENDIF}
{$endif}
end.

View File

@ -121,6 +121,16 @@ begin
begin
AddInclude('mysql.inc');
end;
T:=P.Targets.AddUnit('mysql55.pp');
with T.Dependencies do
begin
AddInclude('mysql.inc');
end;
T:=P.Targets.AddUnit('mysql55dyn.pp');
with T.Dependencies do
begin
AddInclude('mysql.inc');
end;
T.ResourceStrings := True;
P.ExamplePath.Add('examples');

View File

@ -31,7 +31,9 @@ uses
{$DEFINE extdecl:=cdecl}
const
mysqllib = 'libmysqlclient.'+sharedsuffix;
{$IF DEFINED(mysql51)}
{$IF DEFINED(mysql55)}
mysqlvlib = mysqllib+'.18';
{$ELSEIF DEFINED(mysql51)}
mysqlvlib = mysqllib+'.16';
{$ELSEIF DEFINED(mysql50)}
mysqlvlib = mysqllib+'.15';
@ -48,6 +50,10 @@ uses
mysqlvlib = 'libmysql.dll';
{$ENDIF}
{$IFDEF mysql55}
{$DEFINE mysql51}
{$ENDIF mysql55}
{$IFDEF mysql51}
{$DEFINE mysql50}
{$ENDIF mysql51}
@ -100,6 +106,7 @@ uses
NAME_LEN = 64;
HOSTNAME_LENGTH = 60;
USERNAME_LENGTH = 16;
MYSQL_AUTODETECT_CHARSET_NAME = 'auto';
SERVER_VERSION_LENGTH = 60;
SQLSTATE_LENGTH = 5;
LOCAL_HOST = 'localhost';
@ -180,6 +187,12 @@ uses
REFRESH_THREADS = 32; // Flush thread cache
REFRESH_SLAVE = 64; // Reset master info and restart slave thread
REFRESH_MASTER = 128; // Remove all bin logs in the index and truncate the index
REFRESH_ERROR_LOG = 256; // Rotate only the erorr log
REFRESH_ENGINE_LOG = 512; // Flush all storage engine logs
REFRESH_BINARY_LOG = 1024; // Flush the binary log
REFRESH_RELAY_LOG = 2048; // Flush the relay log
REFRESH_GENERAL_LOG = 4096; // Flush the general log
REFRESH_SLOW_LOG = 8192; // Flush the slow query log
{ The following can't be set with mysql_refresh() }
REFRESH_READ_LOCK = 16384; // Lock tables for read
@ -208,10 +221,16 @@ uses
CLIENT_SECURE_CONNECTION = 32768; // New 4.1 authentication
CLIENT_MULTI_STATEMENTS = 65536; // Enable/disable multi-stmt support
CLIENT_MULTI_RESULTS = 131072; // Enable/disable multi-results
CLIENT_PS_MULTI_RESULTS : cardinal = 1 shl 18; // Multi-results in PS-protocol
CLIENT_PLUGIN_AUTH : cardinal = 1 shl 19; // Client supports plugin authentication
CLIENT_SSL_VERIFY_SERVER_CERT : cardinal = 1 shl 30;
CLIENT_REMEMBER_OPTIONS : cardinal = 1 shl 31;
SERVER_STATUS_IN_TRANS = 1; // Transaction has started
SERVER_STATUS_IN_TRANS = 1; // Is raised when a multi-statement transaction
// has been started, either explicitly, by means
// of BEGIN or COMMIT AND CHAIN, or implicitly, by the first transactional
// statement, when autocommit=off
SERVER_STATUS_AUTOCOMMIT = 2; // Server in auto_commit mode
SERVER_STATUS_MORE_RESULTS = 4; // More results on server
SERVER_MORE_RESULTS_EXISTS = 8; // Multi query - next query exists
@ -238,6 +257,10 @@ uses
}
SERVER_STATUS_METADATA_CHANGED = 1024;
{$ENDIF}
{$IFDEF mysql55}
SERVER_QUERY_WAS_SLOW = 2048;
SERVER_PS_OUT_PARAMS = 4096; // To mark ResultSet containing output parameter values.
{$ENDIF}
{$IFDEF mysql41}
MYSQL_ERRMSG_SIZE = 512;
@ -549,8 +572,9 @@ uses
NULL_LENGTH : culong = culong(not(0)); // For net_store_length
const
MYSQL_STMT_HEADER = 4;
MYSQL_STMT_HEADER = 4;
MYSQL_LONG_DATA_HEADER = 6;
NOT_FIXED_DEC = 31;
{ ------------ Stop of declaration in "mysql_com.h" ----------------------- }
@ -742,6 +766,12 @@ uses
MYSQL_SECURE_AUTH
{$IFDEF MYSQL50}
,MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT
{$IFDEF mysql51}
,MYSQL_OPT_SSL_VERIFY_SERVER_CERT
{$IFDEF mysql55}
,MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH
{$ENDIF}
{$ENDIF}
{$ENDIF}
);
@ -765,6 +795,8 @@ uses
DYNAMIC_ARRAY = st_dynamic_array;
Pst_dynamic_array = ^st_dynamic_array;
st_mysql_options_extention = record end;
Pst_mysql_options = ^st_mysql_options;
st_mysql_options = record
connect_timeout : cuint;
@ -832,6 +864,9 @@ uses
local_infile_end : procedure (_para1:pointer);
local_infile_error : function (_para1:pointer; _para2:Pchar; _para3:cuint):cint;
local_infile_userdata : pointer;
{$IFDEF mysql51}
extension : ^st_mysql_options_extention;
{$ENDIF}
{$ENDIF}
end;
@ -1173,6 +1208,8 @@ uses
PMYSQL_BIND = ^MYSQL_BIND;
{ statement handler }
st_mysql_stmt_extension = record end;
st_mysql_stmt = record
mem_root : MEM_ROOT; // root allocations
// list : LIST; // list to keep track of all stmts
@ -1212,6 +1249,9 @@ uses
{ Is set to true if we need to calculate field->max_length for
metadata fields when doing mysql_stmt_store_result. }
update_max_length : my_bool;
{$IFDEF mysql51}
extension: ^st_mysql_stmt_extension;
{$ENDIF}
end;
MYSQL_STMT = st_mysql_stmt;
{ When doing mysql_stmt_store_result calculate max_length attribute
@ -1450,6 +1490,7 @@ uses
function mysql_autocommit(mysql:PMYSQL; auto_mode:my_bool):my_bool;extdecl;external mysqllib name 'mysql_autocommit';
function mysql_more_results(mysql:PMYSQL):my_bool;extdecl;external mysqllib name 'mysql_more_results';
function mysql_next_result(mysql:PMYSQL):cint;extdecl;external mysqllib name 'mysql_next_result';
function mysql_stmt_next_result(stmt:PMYSQL_STMT):cint;extdecl;external mysqllib name 'mysql_stmt_next_result';
procedure mysql_close(sock:PMYSQL);extdecl;external mysqllib name 'mysql_close';
{$ELSE}
@ -1519,6 +1560,7 @@ uses
mysql_stmt_affected_rows: function (stmt:PMYSQL_STMT):my_ulonglong;extdecl;
mysql_stmt_insert_id: function (stmt:PMYSQL_STMT):my_ulonglong;extdecl;
mysql_stmt_field_count: function (stmt:PMYSQL_STMT):cuint;extdecl;
mysql_stmt_next_result: function (stmt:PMYSQL_STMT):cint;extdecl;
{$ENDIF}
@ -1686,6 +1728,7 @@ begin
pointer(mysql_stmt_affected_rows) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_affected_rows');
pointer(mysql_stmt_insert_id) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_insert_id');
pointer(mysql_stmt_field_count) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_field_count');
pointer(mysql_stmt_next_result) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_next_result');
if mysql_library_init(argc, argv, groups) <> 0 then
Exit;
@ -1768,7 +1811,9 @@ end;
function IS_NUM(t : enum_field_types) : boolean;
begin
{$IF DEFINED(mysql50) or DEFINED(mysql51)}
{$IF DEFINED(mysql55)}
IS_NUM := ((t <= FIELD_TYPE_INT24) and (t<>FIELD_TYPE_TIMESTAMP)) or (t=FIELD_TYPE_YEAR) or (t=FIELD_TYPE_NEWDECIMAL);
{$ELSEIF DEFINED(mysql50) or DEFINED(mysql51)}
IS_NUM := (t <= FIELD_TYPE_INT24) or (t=FIELD_TYPE_YEAR) or (t=FIELD_TYPE_NEWDECIMAL);
{$ELSE}
IS_NUM := (t <= FIELD_TYPE_INT24) or (t=FIELD_TYPE_YEAR);

View File

@ -0,0 +1,12 @@
{
Contains the mysql calls for MySQL 5.5
}
unit mysql55;
{$UNDEF LinkDynamically}
{$DEFINE MYSQL55}
{$i mysql.inc}
end.

View File

@ -0,0 +1,12 @@
{
Contains the mysql calls for MySQL 5.5
}
unit mysql55dyn;
{$DEFINE LinkDynamically}
{$DEFINE MYSQL55}
{$i mysql.inc}
end.