@@ -296,24 +296,25 @@ func (opts *TableDescriptor_SequenceOpts) HasOwner() bool {
296
296
return ! opts .SequenceOwner .Equal (TableDescriptor_SequenceOpts_SequenceOwner {})
297
297
}
298
298
299
- // EffectiveCacheSize returns the CacheSize or NodeCacheSize field of a sequence option with
300
- // the exception that it will return 1 if both fields are set to 0.
301
- // A cache size of 1 indicates that there is no caching. A node cache size of 0 indicates there is no
302
- // node-level caching. The returned value
303
- // will always be greater than or equal to 1.
299
+ // EffectiveCacheSize evaluates the cache size fields of a sequence option.
300
+ // A cache size of 1 indicates that the cache is disabled.
301
+ // The session cache size takes precedence: If set and enabled, it will be the one used.
304
302
//
305
- // Prior to #51259, sequence caching was unimplemented and cache sizes were
306
- // left uninitialized (ie. to have a value of 0). If a sequence has a cache
307
- // size of 0, it should be treated in the same was as sequences with cache
308
- // sizes of 1.
303
+ // Note: An unset cache size is considered disabled.
309
304
func (opts * TableDescriptor_SequenceOpts ) EffectiveCacheSize () int64 {
310
- if opts .CacheSize == 0 && opts .NodeCacheSize == 0 {
311
- return 1
305
+ switch sessionCacheSize := opts .CacheSize ; sessionCacheSize {
306
+ case 0 , 1 :
307
+ default :
308
+ return sessionCacheSize
312
309
}
313
- if opts .CacheSize == 1 && opts .NodeCacheSize != 0 {
314
- return opts .NodeCacheSize
310
+
311
+ switch nodeCacheSize := opts .NodeCacheSize ; nodeCacheSize {
312
+ case 0 , 1 :
313
+ default :
314
+ return nodeCacheSize
315
315
}
316
- return opts .CacheSize
316
+
317
+ return 1 // caches disabled
317
318
}
318
319
319
320
// SafeValue implements the redact.SafeValue interface.
0 commit comments