@@ -4089,11 +4089,13 @@ copytup_rumkey(Tuplesortstate *state, SortTuple *stup, void *tup)
4089
4089
static void
4090
4090
writetup_rumkey (Tuplesortstate * state , int tapenum , SortTuple * stup )
4091
4091
{
4092
- RumKey * item = (RumKey * ) stup -> tuple ;
4093
- unsigned int writtenlen = sizeof (* item );
4092
+ RumKey * item = (RumKey * ) stup -> tuple ;
4093
+ unsigned int writtenlen = sizeof (* item ) + sizeof ( unsigned int ) ;
4094
4094
4095
4095
LogicalTapeWrite (state -> tapeset , tapenum ,
4096
- (void * ) item , writtenlen );
4096
+ (void * ) & writtenlen , sizeof (writtenlen ));
4097
+ LogicalTapeWrite (state -> tapeset , tapenum ,
4098
+ (void * ) item , sizeof (* item ));
4097
4099
if (state -> randomAccess ) /* need trailing length word? */
4098
4100
LogicalTapeWrite (state -> tapeset , tapenum ,
4099
4101
(void * ) & writtenlen , sizeof (writtenlen ));
@@ -4106,18 +4108,19 @@ static void
4106
4108
readtup_rumkey (Tuplesortstate * state , SortTuple * stup ,
4107
4109
int tapenum , unsigned int len )
4108
4110
{
4109
- RumKey * item = (RumKey * ) palloc (sizeof (RumKey ));
4111
+ unsigned int tuplen = len - sizeof (unsigned int );
4112
+ RumKey * item = (RumKey * ) palloc (sizeof (RumKey ));
4110
4113
4111
- Assert (len == sizeof (RumKey ));
4114
+ Assert (tuplen == sizeof (RumKey ));
4112
4115
4113
4116
USEMEM (state , GetMemoryChunkSpace (item ));
4114
4117
LogicalTapeReadExact (state -> tapeset , tapenum ,
4115
- (void * ) item , len );
4118
+ (void * ) item , tuplen );
4116
4119
stup -> isnull1 = true;
4117
4120
stup -> tuple = item ;
4118
4121
4119
4122
if (state -> randomAccess ) /* need trailing length word? */
4120
4123
LogicalTapeReadExact (state -> tapeset , tapenum ,
4121
- & len , sizeof (len ));
4124
+ & tuplen , sizeof (tuplen ));
4122
4125
}
4123
4126
0 commit comments