* Implement Pos2, which takes a start parameter.

* Mask USING {BTREE,HASH,RTREE} from older servers. I wonder why mysqld doesn't do this by itself. Fixes issue #1779065.
This commit is contained in:
rosenfield
2007-08-29 00:49:40 +00:00
parent 80a64fff0b
commit bf401df253
2 changed files with 22 additions and 0 deletions

View File

@ -421,6 +421,7 @@ procedure TExportSQLForm.btnExportClick(Sender: TObject);
var var
f : TFileStream; f : TFileStream;
i,j,k,m : Integer; i,j,k,m : Integer;
spos, epos : Integer;
exportdb,exporttables : boolean; exportdb,exporttables : boolean;
exportdata : boolean; exportdata : boolean;
dropquery,createquery,insertquery, dropquery,createquery,insertquery,
@ -716,6 +717,16 @@ begin
Insert('/*!40100 ', sql, Pos('DEFAULT CHARSET', sql)); Insert('/*!40100 ', sql, Pos('DEFAULT CHARSET', sql));
sql := sql + '*/'; sql := sql + '*/';
end; end;
// Mask USING {BTREE,HASH,RTREE} from older servers.
spos := 1;
while true do begin
spos := Pos2('USING', sql, spos);
if spos = 0 then break;
epos := min(Pos2(',', sql, spos), Pos2(')', sql, spos));
Insert('*/', sql, epos);
Insert('/*!50100 ', sql, spos);
spos := epos + 11;
end;
if target_version = SQL_VERSION_ANSI then if target_version = SQL_VERSION_ANSI then
begin begin
sql := StringReplace(sql, '`', '"', [rfReplaceAll]); sql := StringReplace(sql, '`', '"', [rfReplaceAll]);

View File

@ -85,6 +85,7 @@ type
function FormatTimeNumber( Seconds: Cardinal ): String; function FormatTimeNumber( Seconds: Cardinal ): String;
function TColorToHex( Color : TColor ): string; function TColorToHex( Color : TColor ): string;
function GetVTCaptions( VT: TVirtualStringTree; OnlySelected: Boolean = False; Column: Integer = 0 ): TStringList; function GetVTCaptions( VT: TVirtualStringTree; OnlySelected: Boolean = False; Column: Integer = 0 ): TStringList;
function Pos2(const Needle, HayStack: string; const StartPos: Integer) : Integer;
var var
MYSQL_KEYWORDS : TStringList; MYSQL_KEYWORDS : TStringList;
@ -2025,6 +2026,16 @@ begin
end; end;
end; end;
function Pos2(const Needle, HayStack: string; const StartPos: Integer) : Integer;
var
NewHayStack: string;
begin
NewHayStack := Copy(HayStack, StartPos, Length(HayStack));
Result := Pos(Needle, NewHayStack);
if Result > 0 then Result := Result + StartPos - 1;
end;
initialization initialization