ParamCheck = False
原因:
function TParameters.ParseSQL(SQL: string
DoCreate: Boolean): string;
const
Literals = ['''', '"', '`'];
var
Value, CurPos, StartPos: PChar;
CurChar: Char;
Literal: Boolean;
EmbeddedLiteral: Boolean;
Name: string;
function NameDelimiter: Boolean;
begin
Result := CurChar in [' ', ',', ';', ')', #13, #10];
end;
function IsLiteral: Boolean;
begin
Result := CurChar in Literals;
end;
function StripLiterals(Buffer: PChar): string;
var
Len: Word;
TempBuf: PChar;
procedure StripChar;
begin
if TempBuf^ in Literals then
StrMove(TempBuf, TempBuf + 1, Len - 1);
if TempBuf[StrLen(TempBuf) - 1] in Literals then
TempBuf[StrLen(TempBuf) - 1] := #0;
end;
begin
Len := StrLen(Buffer) + 1;
TempBuf := AllocMem(Len);
Result := '';
try
StrCopy(TempBuf, Buffer);
StripChar;
Result := StrPas(TempBuf);
finally
FreeMem(TempBuf, Len);
end;
end;
begin
Result := SQL;
Value := PChar(Result);
if DoCreate then Clear;
CurPos := Value;
Literal := False;
EmbeddedLiteral := False;
repeat
while (CurPos^ in LeadBytes) do Inc(CurPos, 2);
CurChar := CurPos^;
if (CurChar = ':') and not Literal and ((CurPos + 1)^ <> ':') then
begin
StartPos := CurPos;
while (CurChar <> #0) and (Literal or not NameDelimiter) do
begin
Inc(CurPos);
while (CurPos^ in LeadBytes) do Inc(CurPos, 2);
CurChar := CurPos^;
if IsLiteral then
begin
Literal := Literal xor True;
if CurPos = StartPos + 1 then EmbeddedLiteral := True;
end;
end;
CurPos^ := #0;
if EmbeddedLiteral then
begin
Name := StripLiterals(StartPos + 1);
EmbeddedLiteral := False;
end
else Name := StrPas(StartPos + 1);
if DoCreate then
AddParameter.Name := Name;
CurPos^ := CurChar;
StartPos^ := '?';
Inc(StartPos);
StrMove(StartPos, CurPos, StrLen(CurPos) + 1);
CurPos := StartPos;
end
else if (CurChar = ':') and not Literal and ((CurPos + 1)^ = ':') then
StrMove(CurPos, CurPos + 1, StrLen(CurPos) + 1)
else if IsLiteral then Literal := Literal xor True;
Inc(CurPos);
until CurChar = #0;
end;