Re: PostgreSQL timestamp with timezone issue
Posted: 22.03.2021, 18:15
The changes to the timezone stuff for Pg are great! A few issues:
in TZAbstractPostgreSQLPreparedStatementV3.GetRawEncodedSQL
it does:
However FPQResultFormat hasn't been set yet and since it's not initialized it is always zero (ParamFormatStr.) My quick fix is to just remove that check (which isn't optimal in ParamFormatStr mode obviously.)
Also the "set" command for time zones allows the syntax:
SET TIMEZONE = 'UTC';
(besides the normal SET TIME ZONE syntax)
So I added cTimeZone: PChar = 'TIMEZONE'; to the constants and check for it before the check for cTime. Here's my code:
Thanks!
-Mark
in TZAbstractPostgreSQLPreparedStatementV3.GetRawEncodedSQL
it does:
Code: Select all
if (FTokenMatchIndex = -1) and (FPQResultFormat = ParamFormatBin) then
Also the "set" command for time zones allows the syntax:
SET TIMEZONE = 'UTC';
(besides the normal SET TIME ZONE syntax)
So I added cTimeZone: PChar = 'TIMEZONE'; to the constants and check for it before the check for cTime. Here's my code:
Code: Select all
if (NextToken.TokenType = ttWord) and (NextToken.L = 8) and SameText(NextToken.P, cTimeZone, 8) and (Tokens.Count > J+1) then begin
FDoUpdateTimestampOffet := True;
end
else // next line already exists
if (NextToken.TokenType = ttWord) and (NextToken.L = 4) and SameText(NextToken.P, cTime, 4) and (Tokens.Count > J+1) then begin
-Mark