Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit397e9b3

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Some changes to prepare for LONG attributes.
Jan
1 parent5ca971a commit397e9b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+235
-115
lines changed

‎src/backend/access/common/heaptuple.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.58 1999/07/19 07:07:15 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.59 1999/12/16 22:19:34 wieck Exp $
1212
*
1313
* NOTES
1414
* The old interface functions have been converted to macros
@@ -562,6 +562,7 @@ heap_copytuple(HeapTuple tuple)
562562
newTuple= (HeapTuple)palloc(HEAPTUPLESIZE+tuple->t_len);
563563
newTuple->t_len=tuple->t_len;
564564
newTuple->t_self=tuple->t_self;
565+
newTuple->t_datamcxt=CurrentMemoryContext;
565566
newTuple->t_data= (HeapTupleHeader) ((char*)newTuple+HEAPTUPLESIZE);
566567
memmove((char*)newTuple->t_data,
567568
(char*)tuple->t_data, (int)tuple->t_len);
@@ -585,6 +586,7 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
585586

586587
dest->t_len=src->t_len;
587588
dest->t_self=src->t_self;
589+
dest->t_datamcxt=CurrentMemoryContext;
588590
dest->t_data= (HeapTupleHeader)palloc(src->t_len);
589591
memmove((char*)dest->t_data,
590592
(char*)src->t_data, (int)src->t_len);
@@ -682,6 +684,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
682684
len+=ComputeDataSize(tupleDescriptor,value,nulls);
683685

684686
tuple= (HeapTuple)palloc(HEAPTUPLESIZE+len);
687+
tuple->t_datamcxt=CurrentMemoryContext;
685688
td=tuple->t_data= (HeapTupleHeader) ((char*)tuple+HEAPTUPLESIZE);
686689

687690
MemSet((char*)td,0, (int)len);
@@ -792,6 +795,27 @@ heap_modifytuple(HeapTuple tuple,
792795
returnnewTuple;
793796
}
794797

798+
799+
/* ----------------
800+
*heap_freetuple
801+
* ----------------
802+
*/
803+
void
804+
heap_freetuple(HeapTuplehtup)
805+
{
806+
externintgetpid();
807+
808+
if (htup->t_data!=NULL)
809+
if (htup->t_datamcxt!=NULL&& (char*)(htup->t_data)!=
810+
((char*)htup+HEAPTUPLESIZE))
811+
{
812+
elog(NOTICE,"TELL Jan Wieck: heap_freetuple() found separate t_data");
813+
}
814+
815+
pfree(htup);
816+
}
817+
818+
795819
/* ----------------------------------------------------------------
796820
*other misc functions
797821
* ----------------------------------------------------------------
@@ -814,6 +838,7 @@ heap_addheader(uint32 natts,/* max domain index */
814838
hoff=len=MAXALIGN(len);/* be conservative */
815839
len+=structlen;
816840
tuple= (HeapTuple)palloc(HEAPTUPLESIZE+len);
841+
tuple->t_datamcxt=CurrentMemoryContext;
817842
td=tuple->t_data= (HeapTupleHeader) ((char*)tuple+HEAPTUPLESIZE);
818843

819844
MemSet((char*)td,0, (int)len);

‎src/backend/access/heap/heapam.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.60 1999/11/24 00:44:28 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.61 1999/12/16 22:19:36 wieck Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -117,6 +117,8 @@ initscan(HeapScanDesc scan,
117117
*relation is empty
118118
* ----------------
119119
*/
120+
scan->rs_ntup.t_datamcxt=scan->rs_ctup.t_datamcxt=
121+
scan->rs_ptup.t_datamcxt=NULL;
120122
scan->rs_ntup.t_data=scan->rs_ctup.t_data=
121123
scan->rs_ptup.t_data=NULL;
122124
scan->rs_nbuf=scan->rs_cbuf=scan->rs_pbuf=InvalidBuffer;
@@ -127,8 +129,10 @@ initscan(HeapScanDesc scan,
127129
*reverse scan
128130
* ----------------
129131
*/
132+
scan->rs_ntup.t_datamcxt=scan->rs_ctup.t_datamcxt=NULL;
130133
scan->rs_ntup.t_data=scan->rs_ctup.t_data=NULL;
131134
scan->rs_nbuf=scan->rs_cbuf=InvalidBuffer;
135+
scan->rs_ptup.t_datamcxt=NULL;
132136
scan->rs_ptup.t_data=NULL;
133137
scan->rs_pbuf=UnknownBuffer;
134138
}
@@ -138,8 +142,10 @@ initscan(HeapScanDesc scan,
138142
*forward scan
139143
* ----------------
140144
*/
145+
scan->rs_ctup.t_datamcxt=scan->rs_ptup.t_datamcxt=NULL;
141146
scan->rs_ctup.t_data=scan->rs_ptup.t_data=NULL;
142147
scan->rs_cbuf=scan->rs_pbuf=InvalidBuffer;
148+
scan->rs_ntup.t_datamcxt=NULL;
143149
scan->rs_ntup.t_data=NULL;
144150
scan->rs_nbuf=UnknownBuffer;
145151
}/* invalid too */
@@ -272,6 +278,7 @@ heapgettup(Relation relation,
272278
*/
273279
if (!(pages=relation->rd_nblocks))
274280
{
281+
tuple->t_datamcxt=NULL;
275282
tuple->t_data=NULL;
276283
return;
277284
}
@@ -290,6 +297,7 @@ heapgettup(Relation relation,
290297
if (ItemPointerIsValid(tid)== false)
291298
{
292299
*buffer=InvalidBuffer;
300+
tuple->t_datamcxt=NULL;
293301
tuple->t_data=NULL;
294302
return;
295303
}
@@ -306,6 +314,7 @@ heapgettup(Relation relation,
306314
lineoff=ItemPointerGetOffsetNumber(tid);
307315
lpp=PageGetItemId(dp,lineoff);
308316

317+
tuple->t_datamcxt=NULL;
309318
tuple->t_data= (HeapTupleHeader)PageGetItem((Page)dp,lpp);
310319
tuple->t_len=ItemIdGetLength(lpp);
311320
LockBuffer(*buffer,BUFFER_LOCK_UNLOCK);
@@ -376,6 +385,7 @@ heapgettup(Relation relation,
376385
if (page >=pages)
377386
{
378387
*buffer=InvalidBuffer;
388+
tuple->t_datamcxt=NULL;
379389
tuple->t_data=NULL;
380390
return;
381391
}
@@ -415,6 +425,7 @@ heapgettup(Relation relation,
415425
{
416426
if (ItemIdIsUsed(lpp))
417427
{
428+
tuple->t_datamcxt=NULL;
418429
tuple->t_data= (HeapTupleHeader)PageGetItem((Page)dp,lpp);
419430
tuple->t_len=ItemIdGetLength(lpp);
420431
ItemPointerSet(&(tuple->t_self),page,lineoff);
@@ -466,6 +477,7 @@ heapgettup(Relation relation,
466477
if (BufferIsValid(*buffer))
467478
ReleaseBuffer(*buffer);
468479
*buffer=InvalidBuffer;
480+
tuple->t_datamcxt=NULL;
469481
tuple->t_data=NULL;
470482
return;
471483
}
@@ -836,6 +848,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
836848
{
837849
if (BufferIsValid(scan->rs_nbuf))
838850
ReleaseBuffer(scan->rs_nbuf);
851+
scan->rs_ntup.t_datamcxt=NULL;
839852
scan->rs_ntup.t_data=NULL;
840853
scan->rs_nbuf=UnknownBuffer;
841854
returnNULL;
@@ -892,17 +905,20 @@ heap_getnext(HeapScanDesc scandesc, int backw)
892905
{
893906
if (BufferIsValid(scan->rs_pbuf))
894907
ReleaseBuffer(scan->rs_pbuf);
908+
scan->rs_ptup.t_datamcxt=NULL;
895909
scan->rs_ptup.t_data=NULL;
896910
scan->rs_pbuf=InvalidBuffer;
897911
if (BufferIsValid(scan->rs_nbuf))
898912
ReleaseBuffer(scan->rs_nbuf);
913+
scan->rs_ntup.t_datamcxt=NULL;
899914
scan->rs_ntup.t_data=NULL;
900915
scan->rs_nbuf=InvalidBuffer;
901916
returnNULL;
902917
}
903918

904919
if (BufferIsValid(scan->rs_pbuf))
905920
ReleaseBuffer(scan->rs_pbuf);
921+
scan->rs_ptup.t_datamcxt=NULL;
906922
scan->rs_ptup.t_data=NULL;
907923
scan->rs_pbuf=UnknownBuffer;
908924

@@ -918,6 +934,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
918934
{
919935
if (BufferIsValid(scan->rs_pbuf))
920936
ReleaseBuffer(scan->rs_pbuf);
937+
scan->rs_ptup.t_datamcxt=NULL;
921938
scan->rs_ptup.t_data=NULL;
922939
scan->rs_pbuf=UnknownBuffer;
923940
HEAPDEBUG_3;/* heap_getnext returns NULL at end */
@@ -976,10 +993,12 @@ heap_getnext(HeapScanDesc scandesc, int backw)
976993
{
977994
if (BufferIsValid(scan->rs_nbuf))
978995
ReleaseBuffer(scan->rs_nbuf);
996+
scan->rs_ntup.t_datamcxt=NULL;
979997
scan->rs_ntup.t_data=NULL;
980998
scan->rs_nbuf=InvalidBuffer;
981999
if (BufferIsValid(scan->rs_pbuf))
9821000
ReleaseBuffer(scan->rs_pbuf);
1001+
scan->rs_ptup.t_datamcxt=NULL;
9831002
scan->rs_ptup.t_data=NULL;
9841003
scan->rs_pbuf=InvalidBuffer;
9851004
HEAPDEBUG_6;/* heap_getnext returning EOS */
@@ -988,6 +1007,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
9881007

9891008
if (BufferIsValid(scan->rs_nbuf))
9901009
ReleaseBuffer(scan->rs_nbuf);
1010+
scan->rs_ntup.t_datamcxt=NULL;
9911011
scan->rs_ntup.t_data=NULL;
9921012
scan->rs_nbuf=UnknownBuffer;
9931013
}
@@ -1066,10 +1086,12 @@ heap_fetch(Relation relation,
10661086
{
10671087
ReleaseBuffer(buffer);
10681088
*userbuf=InvalidBuffer;
1089+
tuple->t_datamcxt=NULL;
10691090
tuple->t_data=NULL;
10701091
return;
10711092
}
10721093

1094+
tuple->t_datamcxt=NULL;
10731095
tuple->t_data= (HeapTupleHeader)PageGetItem((Page)dp,lp);
10741096
tuple->t_len=ItemIdGetLength(lp);
10751097

@@ -1156,6 +1178,7 @@ heap_get_latest_tid(Relation relation,
11561178
* ----------------
11571179
*/
11581180

1181+
tp.t_datamcxt=NULL;
11591182
t_data=tp.t_data= (HeapTupleHeader)PageGetItem((Page)dp,lp);
11601183
tp.t_len=ItemIdGetLength(lp);
11611184
tp.t_self=*tid;
@@ -1270,6 +1293,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
12701293

12711294
dp= (PageHeader)BufferGetPage(buffer);
12721295
lp=PageGetItemId(dp,ItemPointerGetOffsetNumber(tid));
1296+
tp.t_datamcxt=NULL;
12731297
tp.t_data= (HeapTupleHeader)PageGetItem((Page)dp,lp);
12741298
tp.t_len=ItemIdGetLength(lp);
12751299
tp.t_self=*tid;
@@ -1365,6 +1389,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
13651389
dp= (PageHeader)BufferGetPage(buffer);
13661390
lp=PageGetItemId(dp,ItemPointerGetOffsetNumber(otid));
13671391

1392+
oldtup.t_datamcxt=NULL;
13681393
oldtup.t_data= (HeapTupleHeader)PageGetItem(dp,lp);
13691394
oldtup.t_len=ItemIdGetLength(lp);
13701395
oldtup.t_self=*otid;
@@ -1488,6 +1513,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
14881513

14891514
dp= (PageHeader)BufferGetPage(*buffer);
14901515
lp=PageGetItemId(dp,ItemPointerGetOffsetNumber(tid));
1516+
tuple->t_datamcxt=NULL;
14911517
tuple->t_data= (HeapTupleHeader)PageGetItem((Page)dp,lp);
14921518
tuple->t_len=ItemIdGetLength(lp);
14931519

@@ -1665,10 +1691,14 @@ heap_restrpos(HeapScanDesc scan)
16651691
scan->rs_nbuf=InvalidBuffer;
16661692

16671693
if (!ItemPointerIsValid(&scan->rs_mptid))
1694+
{
1695+
scan->rs_ptup.t_datamcxt=NULL;
16681696
scan->rs_ptup.t_data=NULL;
1697+
}
16691698
else
16701699
{
16711700
scan->rs_ptup.t_self=scan->rs_mptid;
1701+
scan->rs_ptup.t_datamcxt=NULL;
16721702
scan->rs_ptup.t_data= (HeapTupleHeader)0x1;/* for heapgettup */
16731703
heapgettup(scan->rs_rd,
16741704
&(scan->rs_ptup),
@@ -1680,10 +1710,14 @@ heap_restrpos(HeapScanDesc scan)
16801710
}
16811711

16821712
if (!ItemPointerIsValid(&scan->rs_mctid))
1713+
{
1714+
scan->rs_ctup.t_datamcxt=NULL;
16831715
scan->rs_ctup.t_data=NULL;
1716+
}
16841717
else
16851718
{
16861719
scan->rs_ctup.t_self=scan->rs_mctid;
1720+
scan->rs_ctup.t_datamcxt=NULL;
16871721
scan->rs_ctup.t_data= (HeapTupleHeader)0x1;/* for heapgettup */
16881722
heapgettup(scan->rs_rd,
16891723
&(scan->rs_ctup),
@@ -1695,9 +1729,13 @@ heap_restrpos(HeapScanDesc scan)
16951729
}
16961730

16971731
if (!ItemPointerIsValid(&scan->rs_mntid))
1732+
{
1733+
scan->rs_ntup.t_datamcxt=NULL;
16981734
scan->rs_ntup.t_data=NULL;
1735+
}
16991736
else
17001737
{
1738+
scan->rs_ntup.t_datamcxt=NULL;
17011739
scan->rs_ntup.t_self=scan->rs_mntid;
17021740
scan->rs_ntup.t_data= (HeapTupleHeader)0x1;/* for heapgettup */
17031741
heapgettup(scan->rs_rd,

‎src/backend/bootstrap/bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.72 1999/11/24 00:58:48 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.73 1999/12/16 22:19:37 wieck Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -628,7 +628,7 @@ InsertOneTuple(Oid objectid)
628628
if (objectid!= (Oid)0)
629629
tuple->t_data->t_oid=objectid;
630630
heap_insert(reldesc,tuple);
631-
pfree(tuple);
631+
heap_freetuple(tuple);
632632
if (DebugMode)
633633
{
634634
printf("End InsertOneTuple, objectid=%u\n",objectid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp