Issue #1800: attempt to distinguish text values from function expressions in a column's default value, for MySQL 8.0.13+ which seems to allow just all functions as default value.

This commit is contained in:
Ansgar Becker
2023-04-28 14:44:54 +02:00
parent 8e256f20b8
commit 8f2e761828

View File

@@ -5589,11 +5589,21 @@ begin
// Inexact fallback detection, wrong if MariaDB allows "0+1" as expression at some point
Result := Result or Value.IsEmpty or IsInt(Value[1]);
end else if FParameters.IsAnyMySQL then begin
// Only MySQL case with expression in default value is as follows:
if (Tp.Category = dtcTemporal) and Value.StartsWith('CURRENT_TIMESTAMP', True) then begin
Result := False;
end else begin
Result := True;
if ServerVersionInt <= 80013 then begin
// Only MySQL case with expression in default value is as follows:
if (Tp.Category = dtcTemporal) and Value.StartsWith('CURRENT_TIMESTAMP', True) then begin
Result := False;
end else begin
Result := True;
end;
end
else begin
// https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html#data-type-defaults-explicit
// MySQL 8.0.13+ expect expressions to be wrapped in (..) when you create a table.
// But checking if first char is an opening parenthesis does not work here, as we get the expression
// from IS.COLUMNS, not from SHOW CREATE TABLE. So here's a workaround for distinguishing text
// from an expression:
Result := not Value.Contains('(');
end;
end else begin
// MS SQL, PG and SQLite: