File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2170,7 +2170,7 @@ constructor TDBConnection.Create(AOwner: TComponent);
21702170 FQuoteChar := ' "' ;
21712171 FQuoteChars := ' "[]' ;
21722172 FNamedEnums := TStringList.Create;
2173- FHexPrefix := ' ' ;
2173+ FHexPrefix := ' 0x ' ; // MySQL and MSSQL. Override if required.
21742174 FHexPostfix := ' ' ;
21752175end ;
21762176
@@ -2181,8 +2181,6 @@ constructor TMySQLConnection.Create(AOwner: TComponent);
21812181begin
21822182 inherited ;
21832183 FQuoteChar := ' `' ;
2184- FHexPrefix := ' 0x' ;
2185- FHexPostfix := ' ' ;
21862184 FQuoteChars := ' `"' ;
21872185 FStatementNum := 0 ;
21882186 // The compiler complains that dynamic and static arrays are incompatible, so this does not work:
@@ -2211,6 +2209,8 @@ constructor TPgConnection.Create(AOwner: TComponent);
22112209 i: Integer;
22122210begin
22132211 inherited ;
2212+ FHexPrefix := ' \x' ;
2213+ FHexPostfix := ' ' ;
22142214 FQuoteChars := ' "' ;
22152215 SetLength(FDatatypes, Length(PostGreSQLDatatypes));
22162216 for i:=0 to High(PostGreSQLDatatypes) do
@@ -6778,13 +6778,22 @@ function TDBConnection.IsHex(Text: String): Boolean;
67786778var
67796779 i, BodyLen: Integer;
67806780 HexBody: String;
6781+ AllowOddHexLen: Boolean;
67816782const
67826783 HexChars: TSysCharSet = [' 0' ..' 9' ,' a' ..' f' , ' A' ..' F' ];
67836784begin
67846785 // Check first kilobyte of passed text whether it's a hex encoded string. Hopefully faster than a regex.
67856786 Result := False;
67866787 BodyLen := Length(Text) - Length(FHexPrefix) - Length(FHexPostfix);
6787- if (BodyLen >= 0 ) and (not Odd(BodyLen)) then begin
6788+ AllowOddHexLen := FParameters.IsAnyMySQL;
6789+
6790+ if BodyLen < 0 then begin
6791+ Result := False;
6792+ end
6793+ else if (not AllowOddHexLen) and Odd(BodyLen) then begin
6794+ Result := False;
6795+ end
6796+ else begin
67886797 Result := (FHexPrefix.IsEmpty or Text.StartsWith(FHexPrefix)) and
67896798 (FHexPostfix.IsEmpty or Text.EndsWith(FHexPostfix));
67906799 if Result then begin
You can’t perform that action at this time.
0 commit comments