Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7971539

Browse files
committed
heap_fetch requires buffer pointer, must be released; heap_getnext
no longer returns buffer pointer, can be gotten from scan; descriptor; bootstrap can create multi-key indexes; pg_procname index now is multi-key index; oidint2, oidint4, oidname are gone (must be removed from regression tests); use System Cache rather than sequential scan in many places; heap_modifytuple no longer takes buffer parameter; remove unused buffer parameter in a few other functions; oid8 is not index-able; remove some use of single-character variable names; cleanup Buffer variables usage and scan descriptor looping; cleaned up allocation and freeing of tuples; 18k lines of diff;
1 parent 31de2c9 commit 7971539

Some content is hidden

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

123 files changed

+2135
-3130
lines changed

src/backend/access/common/heaptuple.c

Lines changed: 5 additions & 41 deletions
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.38 1998/06/15 19:27:44 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.39 1998/08/19 02:00:53 momjian Exp $
1212
*
1313
* NOTES
1414
* The old interface functions have been converted to macros
@@ -736,13 +736,6 @@ heap_copytuple(HeapTuple tuple)
736736
if (!HeapTupleIsValid(tuple))
737737
return (NULL);
738738

739-
/* XXX For now, just prevent an undetectable executor related error */
740-
if (tuple->t_len > MAXTUPLEN)
741-
{
742-
elog(ERROR, "palloctup: cannot handle length %d tuples",
743-
tuple->t_len);
744-
}
745-
746739
newTuple = (HeapTuple) palloc(tuple->t_len);
747740
memmove((char *) newTuple, (char *) tuple, (int) tuple->t_len);
748741
return (newTuple);
@@ -863,11 +856,11 @@ heap_formtuple(TupleDesc tupleDescriptor,
863856
* heap_modifytuple
864857
*
865858
* forms a new tuple from an old tuple and a set of replacement values.
859+
* returns a new palloc'ed tuple.
866860
* ----------------
867861
*/
868862
HeapTuple
869863
heap_modifytuple(HeapTuple tuple,
870-
Buffer buffer,
871864
Relation relation,
872865
Datum replValue[],
873866
char replNull[],
@@ -879,34 +872,18 @@ heap_modifytuple(HeapTuple tuple,
879872
char *nulls;
880873
bool isNull;
881874
HeapTuple newTuple;
882-
int madecopy;
883875
uint8 infomask;
884876

885877
/* ----------------
886878
* sanity checks
887879
* ----------------
888880
*/
889881
Assert(HeapTupleIsValid(tuple));
890-
Assert(BufferIsValid(buffer) || RelationIsValid(relation));
891-
Assert(HeapTupleIsValid(tuple));
882+
Assert(RelationIsValid(relation));
892883
Assert(PointerIsValid(replValue));
893884
Assert(PointerIsValid(replNull));
894885
Assert(PointerIsValid(repl));
895886

896-
/* ----------------
897-
* if we're pointing to a disk page, then first
898-
* make a copy of our tuple so that all the attributes
899-
* are available. XXX this is inefficient -cim
900-
* ----------------
901-
*/
902-
madecopy = 0;
903-
if (BufferIsValid(buffer) == true)
904-
{
905-
relation = (Relation) BufferGetRelation(buffer);
906-
tuple = heap_copytuple(tuple);
907-
madecopy = 1;
908-
}
909-
910887
numberOfAttributes = RelationGetRelationTupleForm(relation)->relnatts;
911888

912889
/* ----------------
@@ -933,10 +910,7 @@ heap_modifytuple(HeapTuple tuple,
933910

934911
}
935912
else if (repl[attoff] != 'r')
936-
{
937913
elog(ERROR, "heap_modifytuple: repl is \\%3d", repl[attoff]);
938-
939-
}
940914
else
941915
{ /* == 'r' */
942916
value[attoff] = replValue[attoff];
@@ -961,18 +935,8 @@ heap_modifytuple(HeapTuple tuple,
961935
(char *) &tuple->t_oid,
962936
((char *) &tuple->t_hoff - (char *) &tuple->t_oid)); /* XXX */
963937
newTuple->t_infomask = infomask;
964-
newTuple->t_natts = numberOfAttributes; /* fix t_natts just in
965-
* case */
966-
967-
/* ----------------
968-
* if we made a copy of the tuple, then free it.
969-
* ----------------
970-
*/
971-
if (madecopy)
972-
pfree(tuple);
973-
974-
return
975-
newTuple;
938+
newTuple->t_natts = numberOfAttributes; /* fix t_natts just in case */
939+
return newTuple;
976940
}
977941

978942
/* ----------------------------------------------------------------

src/backend/access/common/printtup.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.31 1998/07/26 04:30:16 scrappy Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.32 1998/08/19 02:00:54 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -46,8 +46,7 @@ typtoout(Oid type)
4646
0, 0, 0);
4747

4848
if (HeapTupleIsValid(typeTuple))
49-
return ((Oid)
50-
((TypeTupleForm) GETSTRUCT(typeTuple))->typoutput);
49+
return ((Oid) ((TypeTupleForm) GETSTRUCT(typeTuple))->typoutput);
5150

5251
elog(ERROR, "typtoout: Cache lookup of type %d failed", type);
5352
return (InvalidOid);
@@ -63,8 +62,7 @@ gettypelem(Oid type)
6362
0, 0, 0);
6463

6564
if (HeapTupleIsValid(typeTuple))
66-
return ((Oid)
67-
((TypeTupleForm) GETSTRUCT(typeTuple))->typelem);
65+
return ((Oid) ((TypeTupleForm) GETSTRUCT(typeTuple))->typelem);
6866

6967
elog(ERROR, "typtoout: Cache lookup of type %d failed", type);
7068
return (InvalidOid);

src/backend/access/common/tupdesc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.41 1998/07/12 21:29:13 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.42 1998/08/19 02:00:56 momjian Exp $
1111
*
1212
* NOTES
1313
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -327,7 +327,8 @@ TupleDescInitEntry(TupleDesc desc,
327327
* -cim 6/14/90
328328
* ----------------
329329
*/
330-
tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(typeid),
330+
tuple = SearchSysCacheTuple(TYPOID,
331+
ObjectIdGetDatum(typeid),
331332
0, 0, 0);
332333
if (!HeapTupleIsValid(tuple))
333334
{

src/backend/access/gist/gist.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ gistbuild(Relation heap,
8787
PredInfo *predInfo)
8888
{
8989
HeapScanDesc scan;
90-
Buffer buffer;
9190
AttrNumber i;
9291
HeapTuple htup;
9392
IndexTuple itup;
@@ -112,14 +111,15 @@ gistbuild(Relation heap,
112111
*oldPred;
113112
GISTSTATE giststate;
114113
GISTENTRY tmpcentry;
114+
Buffer buffer = InvalidBuffer;
115115
bool *compvec;
116116

117117
/* GiSTs only know how to do stupid locking now */
118118
RelationSetLockForWrite(index);
119119

120-
setheapoverride(TRUE); /* so we can see the new pg_index tuple */
120+
setheapoverride(true); /* so we can see the new pg_index tuple */
121121
initGISTstate(&giststate, index);
122-
setheapoverride(FALSE);
122+
setheapoverride(false);
123123

124124
pred = predInfo->pred;
125125
oldPred = predInfo->oldPred;
@@ -170,15 +170,13 @@ gistbuild(Relation heap,
170170
econtext = NULL;
171171
}
172172
#endif /* OMIT_PARTIAL_INDEX */
173-
scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
174-
htup = heap_getnext(scan, 0, &buffer);
175-
176173
/* int the tuples as we insert them */
177174
nh = ni = 0;
178175

179-
for (; HeapTupleIsValid(htup); htup = heap_getnext(scan, 0, &buffer))
180-
{
176+
scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
181177

178+
while (HeapTupleIsValid(htup = heap_getnext(scan, 0)))
179+
{
182180
nh++;
183181

184182
/*
@@ -240,8 +238,7 @@ gistbuild(Relation heap,
240238
attoff,
241239
attnum,
242240
finfo,
243-
&attnull,
244-
buffer);
241+
&attnull);
245242
nulls[attoff] = (attnull ? 'n' : ' ');
246243
}
247244

@@ -302,8 +299,8 @@ gistbuild(Relation heap,
302299
* flushed. We close them to guarantee that they will be.
303300
*/
304301

305-
hrelid = heap->rd_id;
306-
irelid = index->rd_id;
302+
hrelid = RelationGetRelid(heap);
303+
irelid = RelationGetRelid(index);
307304
heap_close(heap);
308305
index_close(index);
309306

@@ -1165,11 +1162,13 @@ initGISTstate(GISTSTATE *giststate, Relation index)
11651162
fmgr_info(equal_proc, &giststate->equalFn);
11661163

11671164
/* see if key type is different from type of attribute being indexed */
1168-
htup = SearchSysCacheTuple(INDEXRELID, ObjectIdGetDatum(index->rd_id),
1165+
htup = SearchSysCacheTuple(INDEXRELID,
1166+
ObjectIdGetDatum(RelationGetRelid(index)),
11691167
0, 0, 0);
11701168
itupform = (IndexTupleForm) GETSTRUCT(htup);
11711169
if (!HeapTupleIsValid(htup))
1172-
elog(ERROR, "initGISTstate: index %d not found", index->rd_id);
1170+
elog(ERROR, "initGISTstate: index %d not found",
1171+
RelationGetRelid(index));
11731172
giststate->haskeytype = itupform->indhaskeytype;
11741173
if (giststate->haskeytype)
11751174
{

src/backend/access/gist/gistscan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,12 @@ gistdropscan(IndexScanDesc s)
284284
}
285285

286286
void
287-
gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
287+
gistadjscans(Relation rel, int op, BlockNumber blkno, OffsetNumber offnum)
288288
{
289289
GISTScanList l;
290290
Oid relid;
291291

292-
relid = r->rd_id;
292+
relid = RelationGetRelid(rel);
293293
for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next)
294294
{
295295
if (l->gsl_scan->relation->rd_id == relid)

src/backend/access/hash/hash.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.19 1998/07/27 19:37:35 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.20 1998/08/19 02:01:00 momjian Exp $
1111
*
1212
* NOTES
1313
* This file contains only the public interface routines.
@@ -53,7 +53,6 @@ hashbuild(Relation heap,
5353
PredInfo *predInfo)
5454
{
5555
HeapScanDesc hscan;
56-
Buffer buffer;
5756
HeapTuple htup;
5857
IndexTuple itup;
5958
TupleDesc htupdesc,
@@ -65,6 +64,7 @@ hashbuild(Relation heap,
6564
nitups;
6665
int i;
6766
HashItem hitem;
67+
Buffer buffer = InvalidBuffer;
6868

6969
#ifndef OMIT_PARTIAL_INDEX
7070
ExprContext *econtext;
@@ -120,14 +120,13 @@ hashbuild(Relation heap,
120120
}
121121
#endif /* OMIT_PARTIAL_INDEX */
122122

123-
/* start a heap scan */
124-
hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
125-
htup = heap_getnext(hscan, 0, &buffer);
126-
127123
/* build the index */
128124
nhtups = nitups = 0;
129125

130-
for (; HeapTupleIsValid(htup); htup = heap_getnext(hscan, 0, &buffer))
126+
/* start a heap scan */
127+
hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
128+
129+
while (HeapTupleIsValid(htup = heap_getnext(hscan, 0)))
131130
{
132131

133132
nhtups++;
@@ -193,8 +192,7 @@ hashbuild(Relation heap,
193192
attoff,
194193
attnum,
195194
finfo,
196-
&attnull,
197-
buffer);
195+
&attnull);
198196
nulls[attoff] = (attnull ? 'n' : ' ');
199197
}
200198

@@ -248,8 +246,8 @@ hashbuild(Relation heap,
248246
*/
249247
if (IsNormalProcessingMode())
250248
{
251-
hrelid = heap->rd_id;
252-
irelid = index->rd_id;
249+
hrelid = RelationGetRelid(heap);
250+
irelid = RelationGetRelid(index);
253251
heap_close(heap);
254252
index_close(index);
255253
UpdateStats(hrelid, nhtups, true);

src/backend/access/hash/hashfunc.c

Lines changed: 13 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/hash/hashfunc.c,v 1.9 1998/04/26 04:05:08 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.10 1998/08/19 02:01:02 momjian Exp $
1111
*
1212
* NOTES
1313
* These functions are stored in pg_amproc. For each operator class
@@ -133,6 +133,18 @@ hashoid(Oid key)
133133
return ((uint32) ~key);
134134
}
135135

136+
uint32
137+
hashoid8(Oid key[])
138+
{
139+
int i;
140+
uint32 result = 0;
141+
142+
for (i=0; i < 8; i++)
143+
result = result ^ (~(uint32)key[i]);
144+
return result;
145+
}
146+
147+
136148
#define PRIME1 37
137149
#define PRIME2 1048583
138150

src/backend/access/hash/hashscan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.14 1998/06/15 19:27:50 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.15 1998/08/19 02:01:04 momjian Exp $
1111
*
1212
* NOTES
1313
* Because we can be doing an index scan on a relation while we
@@ -90,7 +90,7 @@ _hash_adjscans(Relation rel, ItemPointer tid)
9090
HashScanList l;
9191
Oid relid;
9292

93-
relid = rel->rd_id;
93+
relid = RelationGetRelid(rel);
9494
for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next)
9595
{
9696
if (relid == l->hashsl_scan->relation->rd_id)

0 commit comments

Comments
 (0)