@@ -2091,7 +2091,7 @@ constructor TDBConnection.Create(AOwner: TComponent);
20912091 FQuoteChar := ' "' ;
20922092 FQuoteChars := ' "[]' ;
20932093 FNamedEnums := TStringList.Create;
2094- FHexPrefix := ' ' ;
2094+ FHexPrefix := ' 0x ' ; // MySQL and MSSQL. Override if required.
20952095 FHexPostfix := ' ' ;
20962096end ;
20972097
@@ -2103,8 +2103,6 @@ constructor TMySQLConnection.Create(AOwner: TComponent);
21032103 inherited ;
21042104 FQuoteChar := ' `' ;
21052105 FQuoteChars := ' `"' ;
2106- FHexPrefix := ' 0x' ;
2107- FHexPostfix := ' ' ;
21082106 FStatementNum := 0 ;
21092107 // The compiler complains that dynamic and static arrays are incompatible, so this does not work:
21102108 // FDatatypes := MySQLDatatypes
@@ -2134,6 +2132,8 @@ constructor TPgConnection.Create(AOwner: TComponent);
21342132begin
21352133 inherited ;
21362134 FQuoteChars := ' "' ;
2135+ FHexPrefix := ' \x' ;
2136+ FHexPostfix := ' ' ;
21372137 SetLength(FDatatypes, Length(PostGreSQLDatatypes));
21382138 for i:=0 to High(PostGreSQLDatatypes) do
21392139 FDatatypes[i] := PostGreSQLDatatypes[i];
@@ -6623,14 +6623,21 @@ function TDBConnection.IsHex(Text: String): Boolean;
66236623var
66246624 i, BodyLen: Integer;
66256625 HexBody: String;
6626+ AllowOddHexLen: Boolean;
66266627const
66276628 HexChars: TSysCharSet = [' 0' ..' 9' ,' a' ..' f' , ' A' ..' F' ];
66286629begin
66296630 // Check first kilobyte of passed text whether it's a hex encoded string. Hopefully faster than a regex.
6630- Result := False;
66316631 BodyLen := Length(Text) - Length(FHexPrefix) - Length(FHexPostfix);
6632+ AllowOddHexLen := FParameters.IsAnyMySQL;
66326633
6633- if (BodyLen >= 0 ) and (not Odd(BodyLen)) then begin
6634+ if BodyLen < 0 then begin
6635+ Result := False;
6636+ end
6637+ else if (not AllowOddHexLen) and Odd(BodyLen) then begin
6638+ Result := False;
6639+ end
6640+ else begin
66346641 Result := (FHexPrefix.IsEmpty or Text.StartsWith(FHexPrefix)) and
66356642 (FHexPostfix.IsEmpty or Text.EndsWith(FHexPostfix));
66366643 if Result then begin
0 commit comments