8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.9 2007/09/20 17:56:30 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.10 2007/10/29 13:49:21 teodor Exp $
12
12
*-------------------------------------------------------------------------
13
13
*/
14
14
@@ -403,6 +403,31 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd
403
403
btree -> entry = NULL ;
404
404
}
405
405
406
+ /*
407
+ * Returns new tuple with copied value from source tuple.
408
+ * New tuple will not store posting list
409
+ */
410
+ static IndexTuple
411
+ copyIndexTuple (IndexTuple itup , Page page )
412
+ {
413
+ IndexTuple nitup ;
414
+
415
+ if (GinPageIsLeaf (page ) && !GinIsPostingTree (itup ))
416
+ {
417
+ nitup = (IndexTuple ) palloc (MAXALIGN (GinGetOrigSizePosting (itup )));
418
+ memcpy (nitup , itup , GinGetOrigSizePosting (itup ));
419
+ nitup -> t_info &= ~INDEX_SIZE_MASK ;
420
+ nitup -> t_info |= GinGetOrigSizePosting (itup );
421
+ }
422
+ else
423
+ {
424
+ nitup = (IndexTuple ) palloc (MAXALIGN (IndexTupleSize (itup )));
425
+ memcpy (nitup , itup , IndexTupleSize (itup ));
426
+ }
427
+
428
+ return nitup ;
429
+ }
430
+
406
431
/*
407
432
* Place tuple and split page, original buffer(lbuf) leaves untouched,
408
433
* returns shadow page of lbuf filled new data.
@@ -424,8 +449,6 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
424
449
IndexTuple itup ,
425
450
leftrightmost = NULL ;
426
451
static ginxlogSplit data ;
427
- Datum value ;
428
- bool isnull ;
429
452
Page page ;
430
453
Page lpage = GinPageGetCopyPage (BufferGetPage (lbuf ));
431
454
Page rpage = BufferGetPage (rbuf );
@@ -494,9 +517,9 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
494
517
ptr += MAXALIGN (IndexTupleSize (itup ));
495
518
}
496
519
497
- value = index_getattr (leftrightmost , FirstOffsetNumber , btree -> ginstate -> tupdesc , & isnull );
498
- btree -> entry = GinFormTuple (btree -> ginstate , value , NULL , 0 );
520
+ btree -> entry = copyIndexTuple (leftrightmost , lpage );
499
521
ItemPointerSet (& (btree -> entry )-> t_tid , BufferGetBlockNumber (lbuf ), InvalidOffsetNumber );
522
+
500
523
btree -> rightblkno = BufferGetBlockNumber (rbuf );
501
524
502
525
data .node = btree -> index -> rd_node ;
@@ -533,20 +556,9 @@ ginPageGetLinkItup(Buffer buf)
533
556
Page page = BufferGetPage (buf );
534
557
535
558
itup = getRightMostTuple (page );
536
- if (GinPageIsLeaf (page ) && !GinIsPostingTree (itup ))
537
- {
538
- nitup = (IndexTuple ) palloc (MAXALIGN (GinGetOrigSizePosting (itup )));
539
- memcpy (nitup , itup , GinGetOrigSizePosting (itup ));
540
- nitup -> t_info &= ~INDEX_SIZE_MASK ;
541
- nitup -> t_info |= GinGetOrigSizePosting (itup );
542
- }
543
- else
544
- {
545
- nitup = (IndexTuple ) palloc (MAXALIGN (IndexTupleSize (itup )));
546
- memcpy (nitup , itup , IndexTupleSize (itup ));
547
- }
548
-
559
+ nitup = copyIndexTuple (itup , page );
549
560
ItemPointerSet (& nitup -> t_tid , BufferGetBlockNumber (buf ), InvalidOffsetNumber );
561
+
550
562
return nitup ;
551
563
}
552
564
0 commit comments