@@ -114,8 +114,13 @@ INSERT INTO t values (1), (10), (100);
114
114
` )
115
115
116
116
backupAsOfTimes := make ([]time.Time , 0 )
117
- th .cfg .TestingKnobs .(* jobs.TestingKnobs ).OverrideAsOfClause = func (clause * tree.AsOfClause , _ time.Time ) {
117
+ th .cfg .TestingKnobs .(* jobs.TestingKnobs ).OverrideAsOfClause = func (clause * tree.AsOfClause , statementTime time.Time ) {
118
118
backupAsOfTime := th .cfg .DB .KV ().Clock ().PhysicalTime ()
119
+ if backupAsOfTime .After (statementTime ) {
120
+ // If the backupAsOfTime is after the statement time, then we use the
121
+ // statement time to avoid "AOST in the future" errors.
122
+ backupAsOfTime = statementTime
123
+ }
119
124
expr , err := tree .MakeDTimestampTZ (backupAsOfTime , time .Microsecond )
120
125
require .NoError (t , err )
121
126
clause .Expr = expr
@@ -241,8 +246,13 @@ INSERT INTO t values (1), (10), (100);
241
246
` )
242
247
243
248
backupAsOfTimes := make ([]time.Time , 0 )
244
- th .cfg .TestingKnobs .(* jobs.TestingKnobs ).OverrideAsOfClause = func (clause * tree.AsOfClause , _ time.Time ) {
249
+ th .cfg .TestingKnobs .(* jobs.TestingKnobs ).OverrideAsOfClause = func (clause * tree.AsOfClause , statementTime time.Time ) {
245
250
backupAsOfTime := th .cfg .DB .KV ().Clock ().PhysicalTime ()
251
+ if backupAsOfTime .After (statementTime ) {
252
+ // If the backupAsOfTime is after the statement time, then we use the
253
+ // statement time to avoid "AOST in the future" errors.
254
+ backupAsOfTime = statementTime
255
+ }
246
256
expr , err := tree .MakeDTimestampTZ (backupAsOfTime , time .Microsecond )
247
257
require .NoError (t , err )
248
258
clause .Expr = expr
@@ -336,8 +346,13 @@ INSERT INTO t values (1), (10), (100);
336
346
` )
337
347
338
348
backupAsOfTimes := make ([]time.Time , 0 )
339
- th .cfg .TestingKnobs .(* jobs.TestingKnobs ).OverrideAsOfClause = func (clause * tree.AsOfClause , _ time.Time ) {
349
+ th .cfg .TestingKnobs .(* jobs.TestingKnobs ).OverrideAsOfClause = func (clause * tree.AsOfClause , statementTime time.Time ) {
340
350
backupAsOfTime := th .cfg .DB .KV ().Clock ().PhysicalTime ()
351
+ if backupAsOfTime .After (statementTime ) {
352
+ // If the backupAsOfTime is after the statement time, then we use the
353
+ // statement time to avoid "AOST in the future" errors.
354
+ backupAsOfTime = statementTime
355
+ }
341
356
expr , err := tree .MakeDTimestampTZ (backupAsOfTime , time .Microsecond )
342
357
require .NoError (t , err )
343
358
clause .Expr = expr
0 commit comments