@@ -252,11 +252,7 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
252
252
{
253
253
ssize_t readsz ;
254
254
WALKeyCacheRec * keys = pg_tde_get_wal_cache_keys ();
255
- XLogRecPtr write_key_lsn = 0 ;
256
- WALKeyCacheRec * curr_key = NULL ;
257
- off_t dec_off = 0 ;
258
- off_t dec_end = 0 ;
259
- size_t dec_sz = 0 ;
255
+ XLogRecPtr write_key_lsn ;
260
256
XLogRecPtr data_start ;
261
257
XLogRecPtr data_end ;
262
258
@@ -278,7 +274,6 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
278
274
279
275
#ifndef FRONTEND
280
276
write_key_lsn = pg_atomic_read_u64 (& EncryptionState -> enc_key_lsn );
281
- #endif
282
277
283
278
if (write_key_lsn != 0 )
284
279
{
@@ -295,6 +290,7 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
295
290
keys = pg_tde_get_wal_cache_keys ();
296
291
}
297
292
}
293
+ #endif
298
294
299
295
XLogSegNoOffsetToRecPtr (segno , offset , segSize , data_start );
300
296
XLogSegNoOffsetToRecPtr (segno , offset + count , segSize , data_end );
@@ -303,8 +299,7 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
303
299
* TODO: this is higly ineffective. We should get rid of linked list and
304
300
* search from the last key as this is what the walsender is useing.
305
301
*/
306
- curr_key = keys ;
307
- while (curr_key )
302
+ for (WALKeyCacheRec * curr_key = keys ; curr_key != NULL ; curr_key = curr_key -> next )
308
303
{
309
304
#ifdef TDE_XLOG_DEBUG
310
305
elog (DEBUG1 , "WAL key %X/%X-%X/%X, encrypted: %s" ,
@@ -323,12 +318,12 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
323
318
if (data_start < curr_key -> end_lsn && data_end > curr_key -> start_lsn )
324
319
{
325
320
char iv_prefix [16 ];
321
+ off_t dec_off = XLogSegmentOffset (Max (data_start , curr_key -> start_lsn ), segSize );
322
+ off_t dec_end = XLogSegmentOffset (Min (data_end , curr_key -> end_lsn ), segSize );
323
+ size_t dec_sz ;
326
324
327
325
CalcXLogPageIVPrefix (tli , segno , curr_key -> key -> base_iv , iv_prefix );
328
326
329
- dec_off = XLogSegmentOffset (Max (data_start , curr_key -> start_lsn ), segSize );
330
- dec_end = XLogSegmentOffset (Min (data_end , curr_key -> end_lsn ), segSize );
331
-
332
327
/* We have reached the end of the segment */
333
328
if (dec_end == 0 )
334
329
{
@@ -352,8 +347,6 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
352
347
}
353
348
}
354
349
}
355
-
356
- curr_key = curr_key -> next ;
357
350
}
358
351
359
352
return readsz ;
0 commit comments