fcl-db: cosmetic change due to new variable names too similar to existing ones in r22988

git-svn-id: trunk@22993 -
This commit is contained in:
reiniero 2012-11-16 11:17:21 +00:00
parent 4ecfde31e1
commit 02bccda89e
3 changed files with 64 additions and 65 deletions
packages/fcl-db

View File

@ -76,7 +76,7 @@ type
procedure FreeFldBuffers(cursor : TSQLCursor); override;
function LoadField(cursor : TSQLCursor;FieldDef : TfieldDef;buffer : pointer; out CreateBlob : boolean) : boolean; override;
//if bufsize < 0 -> buffer was to small, should be -bufsize
//if bufsize < 0 -> buffer was too small, should be -bufsize
function GetTransactionHandle(trans : TSQLHandle): pointer; override;
function Commit(trans : TSQLHandle) : boolean; override;
function RollBack(trans : TSQLHandle) : boolean; override;

View File

@ -20,11 +20,11 @@ uses
;
type
TSQLDBType = (mysql40,mysql41,mysql50,mysql51,mysql55,postgresql,interbase,odbc,oracle,sqlite3,mssql,sybase);
TSQLConnType = (mysql40,mysql41,mysql50,mysql51,mysql55,postgresql,interbase,odbc,oracle,sqlite3,mssql,sybase);
TSQLServerType = (ssFirebird, ssInterbase, ssMSSQL, ssMySQL, ssOracle, ssPostgreSQL, ssSQLite, ssSybase, ssUnknown);
const MySQLdbTypes = [mysql40,mysql41,mysql50,mysql51,mysql55];
DBTypesNames : Array [TSQLDBType] of String[19] =
const MySQLConnTypes = [mysql40,mysql41,mysql50,mysql51,mysql55];
SQLConnTypesNames : Array [TSQLConnType] of String[19] =
('MYSQL40','MYSQL41','MYSQL50','MYSQL51','MYSQL55','POSTGRESQL','INTERBASE','ODBC','ORACLE','SQLITE3','MSSQL','SYBASE');
FieldtypeDefinitionsConst : Array [TFieldType] of String[20] =
@ -101,7 +101,7 @@ type
property Query : TSQLQuery read FQuery;
end;
var SQLDbType : TSQLDBType;
var SQLConnType : TSQLConnType;
SQLServerType : TSQLServerType;
FieldtypeDefinitions : Array [TFieldType] of String[20];
@ -128,35 +128,35 @@ const
(s: 'ASE'; t: ssSybase)
);
// fall back mapping
SQLDBTypeToServerTypeMap : array[TSQLDbType] of TSQLServerType =
(ssMySQL,ssMySQL,ssMySQL,ssMySQL,ssMySQL,ssPostgreSQL,ssInterbase,ssUnknown,ssOracle,ssSQLite,ssMSSQL,ssSybase);
// fall back mapping (e.g. in case GetConnectionInfo(citServerType) is not implemented)
SQLConnTypeToServerTypeMap : array[TSQLConnType] of TSQLServerType =
(ssMySQL,ssMySQL,ssMySQL,ssMySQL,ssMySQL,ssPostgreSQL,ssFirebird,ssUnknown,ssOracle,ssSQLite,ssMSSQL,ssSybase);
{ TSQLDBConnector }
procedure TSQLDBConnector.CreateFConnection;
var t : TSQLDBType;
var t : TSQLConnType;
i : integer;
s : string;
begin
for t := low(DBTypesNames) to high(DBTypesNames) do
if UpperCase(dbconnectorparams) = DBTypesNames[t] then SQLDbType := t;
for t := low(SQLConnTypesNames) to high(SQLConnTypesNames) do
if UpperCase(dbconnectorparams) = SQLConnTypesNames[t] then SQLConnType := t;
if SQLDbType = MYSQL40 then Fconnection := TMySQL40Connection.Create(nil);
if SQLDbType = MYSQL41 then Fconnection := TMySQL41Connection.Create(nil);
if SQLDbType = MYSQL50 then Fconnection := TMySQL50Connection.Create(nil);
if SQLDbType = MYSQL51 then Fconnection := TMySQL51Connection.Create(nil);
if SQLDbType = MYSQL55 then Fconnection := TMySQL55Connection.Create(nil);
if SQLDbType = SQLITE3 then Fconnection := TSQLite3Connection.Create(nil);
if SQLDbType = POSTGRESQL then Fconnection := TPQConnection.Create(nil);
if SQLDbType = INTERBASE then Fconnection := TIBConnection.Create(nil);
if SQLDbType = ODBC then Fconnection := TODBCConnection.Create(nil);
if SQLConnType = MYSQL40 then Fconnection := TMySQL40Connection.Create(nil);
if SQLConnType = MYSQL41 then Fconnection := TMySQL41Connection.Create(nil);
if SQLConnType = MYSQL50 then Fconnection := TMySQL50Connection.Create(nil);
if SQLConnType = MYSQL51 then Fconnection := TMySQL51Connection.Create(nil);
if SQLConnType = MYSQL55 then Fconnection := TMySQL55Connection.Create(nil);
if SQLConnType = SQLITE3 then Fconnection := TSQLite3Connection.Create(nil);
if SQLConnType = POSTGRESQL then Fconnection := TPQConnection.Create(nil);
if SQLConnType = INTERBASE then Fconnection := TIBConnection.Create(nil);
if SQLConnType = ODBC then Fconnection := TODBCConnection.Create(nil);
{$IFNDEF Win64}
if SQLDbType = ORACLE then Fconnection := TOracleConnection.Create(nil);
{$ENDIF Win64}
if SQLDbType = MSSQL then Fconnection := TMSSQLConnection.Create(nil);
if SQLDbType = SYBASE then Fconnection := TSybaseConnection.Create(nil);
if SQLConnType = MSSQL then Fconnection := TMSSQLConnection.Create(nil);
if SQLConnType = SYBASE then Fconnection := TSybaseConnection.Create(nil);
if not assigned(Fconnection) then writeln('Invalid database type, check if a valid database type for your achitecture was provided in the file ''database.ini''');
@ -166,7 +166,7 @@ begin
UserName := dbuser;
Password := dbpassword;
HostName := dbhostname;
if (dbhostname='') and (SQLDbType=interbase) then
if (dbhostname='') and (SQLConnType=interbase) then
begin
// Firebird embedded: create database file if it doesn't yet exist
// Note: pagesize parameter has influence on behavior. We're using
@ -186,7 +186,7 @@ begin
// determine remote SQL Server to which we are connected
s := Fconnection.GetConnectionInfo(citServerType);
if s = '' then
SQLServerType := SQLDbTypeToServerTypeMap[SQLDbType] // if citServerType isn't implemented
SQLServerType := SQLConnTypeToServerTypeMap[SQLConnType] // if citServerType isn't implemented
else
for i := low(SQLServerTypesMap) to high(SQLServerTypesMap) do
if SQLServerTypesMap[i].s = s then
@ -249,7 +249,7 @@ begin
end;
end;
if SQLDbType in [mysql40,mysql41] then
if SQLConnType in [mysql40,mysql41] then
begin
// Mysql versions prior to 5.0.3 removes the trailing spaces on varchar
// fields on insertion. So to test properly, we have to do the same
@ -461,14 +461,14 @@ begin
// exists. And while this exeption is in a try..except statement, the debugger
// always shows the exception, which is pretty annoying.
try
if SQLDbType = INTERBASE then
if SQLConnType = INTERBASE then
begin
// This only works with Firebird 2+
FConnection.ExecuteDirect('execute block as begin if (exists (select 1 from rdb$relations where rdb$relation_name=''' + ATableName + ''')) '+
'then execute statement ''drop table ' + ATAbleName + ';'';end');
FTransaction.CommitRetaining;
end;
if SQLDBType = mssql then
if SQLConnType = mssql then
begin
// Checking is needed here to avoid getting "auto rollback" of a subsequent CREATE TABLE statement
// which leads to the rollback not referring to the right transaction=>SQL error
@ -480,7 +480,7 @@ begin
'end');
FTransaction.CommitRetaining;
end;
if SQLDbType = sybase then
if SQLConnType = sybase then
begin
// Checking is needed here to avoid getting "auto rollback" of a subsequent CREATE TABLE statement
// which leads to the rollback not referring to the right transaction=>SQL error

View File

@ -218,14 +218,13 @@ begin
script.append('create table b (id int);');
ExecuteScript;
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
if SQLDbType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
if SQLConnType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
end;
finally
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('drop table a');
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('drop table b');
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
if SQLDbType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
if SQLConnType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
end;
end;
@ -293,7 +292,7 @@ var
begin
with TSQLDBConnector(DBConnector) do begin
if SQLDbType = INTERBASE then
if SQLConnType = INTERBASE then
begin
//Interbase internal storage of exact numeric data types based on precision:
// 1-4 (smallint), 5-9 (integer), 10-18 (int64)
@ -436,7 +435,7 @@ var
i : byte;
begin
if SQLDbType<>postgresql then Ignore('This test does only apply to Postgres, since others don''t support varchars without length given');
if SQLConnType<>postgresql then Ignore('This test does only apply to Postgres, since others don''t support varchars without length given');
CreateTableWithFieldType(ftString,'VARCHAR');
TestFieldDeclaration(ftString,dsMaxStringSize+1);
@ -466,7 +465,7 @@ begin
TestFieldDeclaration(ftDate,8);
for i := 0 to testDateValuesCount-1 do
if SQLDbType=oracle then
if SQLConnType=oracle then
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (to_date (''' + testDateValues[i] + ''',''YYYY-MM-DD''))')
else
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (''' + testDateValues[i] + ''')');
@ -641,7 +640,7 @@ begin
TestFieldDeclaration(ftDateTime,8);
for i := 0 to testValuesCount-1 do
if SQLDbType=oracle then
if SQLConnType=oracle then
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (to_date (''' + testValues[i] + ''',''YYYY-MM-DD HH24:MI:SS''))')
else
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (''' + testValues[i] + ''')');
@ -825,7 +824,7 @@ end;
procedure TTestFieldTypes.TestVarBytesParamQuery;
begin
TestXXParamQuery(ftVarBytes, FieldtypeDefinitions[ftVarBytes], testVarBytesValuesCount, SQLDbType<>mssql);
TestXXParamQuery(ftVarBytes, FieldtypeDefinitions[ftVarBytes], testVarBytesValuesCount, SQLConnType<>mssql);
end;
procedure TTestFieldTypes.TestBooleanParamQuery;
@ -856,7 +855,7 @@ begin
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (ID INT, FIELD1 '+ASQLTypeDecl+')');
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
if SQLDbType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
if SQLConnType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
with TSQLDBConnector(DBConnector).Query do
begin
@ -1036,7 +1035,7 @@ end;
procedure TTestFieldTypes.RunTest;
begin
// if (SQLDbType in TSQLDBType) then
// if (SQLConnType in TSQLConnType) then
inherited RunTest;
end;
@ -1221,7 +1220,7 @@ end;
procedure TTestFieldTypes.TestInsertReturningQuery;
begin
if not(SQLDbType in [postgresql,interbase,oracle]) then Ignore(STestNotApplicable);
if not(SQLConnType in [postgresql,interbase,oracle]) then Ignore(STestNotApplicable);
with TSQLDBConnector(DBConnector) do
begin
// This only works with databases that supports 'insert into .. returning'
@ -1239,17 +1238,17 @@ procedure TTestFieldTypes.TestOpenStoredProc;
begin
with TSQLDBConnector(DBConnector) do
begin
if SQLDbType in MySQLdbTypes then
if SQLConnType in MySQLConnTypes then
begin
Connection.ExecuteDirect('create procedure FPDEV_PROC() select 1 union select 2;');
Query.SQL.Text:='call FPDEV_PROC';
end
else if SQLDbType = interbase then
else if SQLConnType = interbase then
begin
Connection.ExecuteDirect('create procedure FPDEV_PROC returns (r integer) as begin r=1; end');
Query.SQL.Text:='execute procedure FPDEV_PROC';
end
else if SQLDbType = mssql then
else if SQLConnType = mssql then
begin
Connection.ExecuteDirect('create procedure FPDEV_PROC as select 1 union select 2;');
Query.SQL.Text:='execute FPDEV_PROC';
@ -1265,7 +1264,7 @@ begin
Query.Open;
AssertEquals(1, Query.Fields[0].AsInteger);
Query.Next;
if not(SQLDbType in [interbase]) then
if not(SQLConnType in [interbase]) then
begin
AssertFalse('Eof after 1st row', Query.Eof);
AssertEquals(2, Query.Fields[0].AsInteger);
@ -1290,7 +1289,7 @@ begin
// at least one row must be returned
with TSQLDBConnector(DBConnector) do
begin
case SQLDbType of
case SQLConnType of
sqlite3:
statements := TTestStatements.Create('pragma table_info(FPDEV)');
interbase:
@ -1303,7 +1302,7 @@ begin
mssql:
statements := TTestStatements.Create(CTE_SELECT (*MS SQL 2005*));
else
if SQLdbType in MySQLdbTypes then
if SQLConnType in MySQLConnTypes then
statements := TTestStatements.Create(
'check table FPDEV', // bug 14519
'show tables from '+Connection.DatabaseName // bug 16842
@ -1328,7 +1327,7 @@ procedure TTestFieldTypes.TestClearUpdateableStatus;
// Test if CanModify is correctly disabled in case of a select query without
// a from-statement.
begin
if not (SQLDbType in MySQLdbTypes) then Ignore('This test does only apply to MySQL because the used SQL-statement is MySQL only.');
if not (SQLConnType in MySQLConnTypes) then Ignore('This test does only apply to MySQL because the used SQL-statement is MySQL only.');
with TSQLDBConnector(DBConnector) do
begin
with (GetNDataset(false,5) as TSQLQuery) do
@ -1621,7 +1620,7 @@ begin
Close;
// tests parsing of WHERE ... LIMIT
case sqlDBtype of
case SQLConnType of
interbase : SQL.Text:='select first 1 NAME from FPDEV where NAME=''TestName21''';
mssql : SQL.Text:='select top 1 NAME from FPDEV where NAME=''TestName21''';
else SQL.Text:='select NAME from FPDEV where NAME=''TestName21'' limit 1';
@ -1639,7 +1638,7 @@ begin
// tests parsing SELECT with quoted identifiers (MySQL requires sql-mode=ANSI_QUOTES)
SQL.Text:='SELECT"ID"FROM"FPDEV"ORDER BY"ID"';
if sqlDBtype in [postgresql] then SQL.Text:=lowercase(SQL.Text); // The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard
if SQLConnType in [postgresql] then SQL.Text:=lowercase(SQL.Text); // The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard
Open;
CheckTrue(CanModify, SQL.Text);
Close;
@ -1672,7 +1671,7 @@ begin
AssertTrue(query.RowsAffected<>0); // It should return -1 or the number of selected rows.
query.Close;
AssertTrue(query.RowsAffected<>0); // It should return -1 or the same as the last time it was called.
if (SQLDbType = sqlite3) then // sqlite doesn't count the rowsaffected if there is no where-clause
if (SQLConnType = sqlite3) then // sqlite doesn't count the rowsaffected if there is no where-clause
Query.SQL.Text := 'delete from FPDEV2 where 1'
else
Query.SQL.Text := 'delete from FPDEV2';
@ -1756,7 +1755,7 @@ end;
procedure TTestFieldTypes.TestBug9744;
var i : integer;
begin
if SQLDbType in [interbase,postgresql,mssql] then Ignore('This test does not apply to this db-engine, since it has no double field-type');
if SQLConnType in [interbase,postgresql,mssql] then Ignore('This test does not apply to this db-engine, since it has no double field-type');
with TSQLDBConnector(DBConnector) do
begin
@ -1802,7 +1801,7 @@ begin
begin
FieldNames := TStringList.Create;
try
if SQLDbType in MySQLdbTypes then
if SQLConnType in MySQLConnTypes then
Connection.GetFieldNames('FPDEV',FieldNames)
else
Connection.GetFieldNames('fpDEv',FieldNames);
@ -1871,7 +1870,7 @@ procedure TTestFieldTypes.TestSQLClob;
end;
var datatype: string;
begin
if sqlDBType=sqlite3 then
if SQLConnType=sqlite3 then
datatype:='CLOB'
else
datatype:=FieldtypeDefinitions[ftMemo];
@ -1891,7 +1890,7 @@ procedure TTestFieldTypes.TestSQLLargeint;
end;
var datatype: string;
begin
if sqlDBType=sqlite3 then
if SQLConnType=sqlite3 then
datatype:='LARGEINT'
else
datatype:='BIGINT';
@ -1918,7 +1917,7 @@ procedure TTestFieldTypes.TestSQLInterval;
end;
var datatype: string;
begin
if sqlDBType = postgresql then
if SQLConnType = postgresql then
begin
datatype:='INTERVAL';
testIntervalValuesCount := 5;
@ -1928,9 +1927,9 @@ begin
datatype:=FieldtypeDefinitions[ftTime];
if datatype = '' then
Ignore(STestNotApplicable);
if sqlDBType = sqlite3 then
if SQLConnType = sqlite3 then
testIntervalValuesCount := 5
else if sqlDBType in MySQLdbTypes then
else if SQLConnType in MySQLConnTypes then
testIntervalValuesCount := 4
else
testIntervalValuesCount := 3;
@ -1944,28 +1943,28 @@ var datatype, values: string;
i: integer;
updatable: boolean;
begin
if sqlDBType in MySQLdbTypes then
if SQLConnType in MySQLConnTypes then
begin
datatype:='INT AUTO_INCREMENT PRIMARY KEY';
values:='VALUES(DEFAULT)';
fieldtype:=ftAutoInc;
updatable:=true;
end
else if sqlDBType = sqlite3 then
else if SQLConnType = sqlite3 then
begin
datatype:='INTEGER PRIMARY KEY';
values:='DEFAULT VALUES';
fieldtype:=ftInteger;
updatable:=true;
end
else if sqlDBType = postgresql then
else if SQLConnType = postgresql then
begin
datatype:='SERIAL';
values:='DEFAULT VALUES';
fieldtype:=ftInteger;
updatable:=true;
end
else if sqlDBType = mssql then
else if SQLConnType = mssql then
begin
datatype:='INTEGER IDENTITY';
values:='DEFAULT VALUES';
@ -2041,7 +2040,7 @@ begin
') ');
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
if SQLDbType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
if SQLConnType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
ds := TSQLDBConnector(DBConnector).Query;
ds.sql.Text:='select * from FPDEV2';
@ -2065,12 +2064,12 @@ end;
procedure TTestFieldTypes.TestTemporaryTable;
begin
if SQLDbType in [mssql] then Ignore('This test does not apply to this sqldb-connection type, since it doesn''t support temporary tables');
if SQLConnType in [mssql] then Ignore('This test does not apply to this sqldb-connection type, since it doesn''t support temporary tables');
with TSQLDBConnector(DBConnector).Query do
begin
SQL.Clear;
if SQLDbType=interbase then
if SQLConnType=interbase then
// Global temporary table: introduced in Firebird 2.1
// has persistent metadata; data is per transaction (default) or per connection
SQL.Add('CREATE GLOBAL TEMPORARY TABLE FPDEV_TEMP (id int)')
@ -2089,7 +2088,7 @@ begin
Close;
finally
// For Firebird/Interbase, we need to explicitly delete the table as well (it's active within the transaction)
if SQLDbType=interbase then
if SQLConnType=interbase then
begin
SQL.Text := 'DROP TABLE FPDEV_TEMP';
ExecSQL;
@ -2140,7 +2139,7 @@ procedure TTestFieldTypes.TestParametersAndDates;
// See bug 7205
var ADateStr : String;
begin
if not(SQLDbType in [postgresql,odbc,oracle]) then
if not(SQLConnType in [postgresql,odbc,oracle]) then
Ignore('This test does not apply to this sqldb-connection type, since it doesn''t use semicolons for casts');
with TSQLDBConnector(DBConnector).Query do