@@ -174,14 +174,15 @@ class jrd_req : public pool_alloc<type_req>
174
174
void invalidate ()
175
175
{
176
176
gmtTimeStamp.invalidate ();
177
+ localTimeStampValid = localTimeValid = false ;
177
178
}
178
179
179
180
ISC_TIMESTAMP getLocalTimeStamp (USHORT currentTimeZone) const
180
181
{
181
182
fb_assert (!gmtTimeStamp.isEmpty ());
182
183
183
- if (timeZone != currentTimeZone)
184
- update (currentTimeZone);
184
+ if (!localTimeStampValid || timeZone != currentTimeZone)
185
+ update (currentTimeZone, true );
185
186
186
187
return localTimeStamp;
187
188
}
@@ -195,7 +196,7 @@ class jrd_req : public pool_alloc<type_req>
195
196
void setGmtTimeStamp (USHORT currentTimeZone, ISC_TIMESTAMP ts)
196
197
{
197
198
gmtTimeStamp = ts;
198
- update (currentTimeZone);
199
+ update (currentTimeZone, false );
199
200
}
200
201
201
202
ISC_TIMESTAMP_TZ getTimeStampTz (USHORT currentTimeZone) const
@@ -215,7 +216,7 @@ class jrd_req : public pool_alloc<type_req>
215
216
ISC_TIME_TZ timeTz;
216
217
217
218
if (timeZone != currentTimeZone)
218
- update (currentTimeZone);
219
+ update (currentTimeZone, false );
219
220
220
221
if (localTimeValid)
221
222
{
@@ -242,27 +243,33 @@ class jrd_req : public pool_alloc<type_req>
242
243
if (gmtTimeStamp.isEmpty ())
243
244
{
244
245
Firebird::TimeZoneUtil::validateGmtTimeStamp (gmtTimeStamp);
245
- update (currentTimeZone);
246
+ update (currentTimeZone, false );
246
247
}
247
248
}
248
249
249
250
private:
250
- void update (USHORT currentTimeZone) const
251
+ void update (USHORT currentTimeZone, bool updateLocalTimeStamp ) const
251
252
{
252
- localTimeStamp = Firebird::TimeZoneUtil::timeStampTzToTimeStamp (
253
- getTimeStampTz (currentTimeZone), currentTimeZone);
253
+ if (updateLocalTimeStamp)
254
+ {
255
+ localTimeStamp = Firebird::TimeZoneUtil::timeStampTzToTimeStamp (
256
+ getTimeStampTz (currentTimeZone), currentTimeZone);
257
+ }
258
+
259
+ localTimeStampValid = updateLocalTimeStamp;
254
260
timeZone = currentTimeZone;
255
261
localTimeValid = false ;
256
262
}
257
263
258
264
private:
259
265
Firebird::TimeStamp gmtTimeStamp; // Start time of request in GMT time zone
260
266
267
+ mutable bool localTimeStampValid; // localTimeStamp calculation is expensive. So is it valid (calculated)?
268
+ mutable bool localTimeValid; // localTime calculation is expensive. So is it valid (calculated)?
261
269
// These are valid only when !gmtTimeStamp.isEmpty(), so no initialization is necessary.
262
270
mutable ISC_TIMESTAMP localTimeStamp; // Timestamp in timeZone's zone
263
271
mutable ISC_USHORT timeZone; // Timezone borrowed from the attachment when updated
264
272
mutable ISC_TIME localTime; // gmtTimeStamp converted to local time (WITH TZ)
265
- mutable bool localTimeValid; // localTime calculation is expensive. So is it valid (calculated)?
266
273
};
267
274
268
275
// Fields to support read consistency in READ COMMITTED transactions
0 commit comments