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

Commit0966516

Browse files
committed
Tighten short-circuit tests for deciding whether we need to invoke
tuptoaster.c --- fields that are compressed in-line are not a reasonto invoke the toaster. Along the way, add a couple more htup.h macrosto eliminate confusing negated tests, and get rid of the alreadyvestigial TUPLE_TOASTER_ACTIVE symbol.
1 parentb897441 commit0966516

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.88 2003/11/29 19:51:39 pgsql Exp $
12+
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.89 2004/01/16 20:51:30 tgl Exp $
1313
*
1414
* NOTES
1515
* The old interface functions have been converted to macros
@@ -303,7 +303,7 @@ nocachegetattr(HeapTuple tuple,
303303
returnfetchatt(att[attnum],
304304
tp+att[attnum]->attcacheoff);
305305
}
306-
elseif (!HeapTupleAllFixed(tuple))
306+
elseif (HeapTupleHasVarWidth(tuple))
307307
{
308308
intj;
309309

@@ -378,13 +378,10 @@ nocachegetattr(HeapTuple tuple,
378378

379379
for (i=0;i<attnum;i++)
380380
{
381-
if (!HeapTupleNoNulls(tuple))
381+
if (HeapTupleHasNulls(tuple)&&att_isnull(i,bp))
382382
{
383-
if (att_isnull(i,bp))
384-
{
385-
usecache= false;
386-
continue;
387-
}
383+
usecache= false;
384+
continue;
388385
}
389386

390387
/* If we know the next offset, we can skip the rest */

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

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.161 2004/01/07 18:56:24 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.162 2004/01/16 20:51:30 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1091,16 +1091,13 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
10911091
HeapTupleHeaderSetCmin(tup->t_data,cid);
10921092
tup->t_tableOid=relation->rd_id;
10931093

1094-
#ifdefTUPLE_TOASTER_ACTIVE
1095-
10961094
/*
10971095
* If the new tuple is too big for storage or contains already toasted
1098-
* attributes from some other relation, invoke the toaster.
1096+
*out-of-lineattributes from some other relation, invoke the toaster.
10991097
*/
1100-
if (HeapTupleHasExtended(tup)||
1098+
if (HeapTupleHasExternal(tup)||
11011099
(MAXALIGN(tup->t_len)>TOAST_TUPLE_THRESHOLD))
11021100
heap_tuple_toast_attrs(relation,tup,NULL);
1103-
#endif
11041101

11051102
/* Find buffer to insert this tuple into */
11061103
buffer=RelationGetBufferForTuple(relation,tup->t_len,InvalidBuffer);
@@ -1352,17 +1349,14 @@ heap_delete(Relation relation, ItemPointer tid,
13521349

13531350
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
13541351

1355-
#ifdefTUPLE_TOASTER_ACTIVE
1356-
13571352
/*
1358-
* If therelation hastoastableattributes, we need to delete no
1359-
*longer neededitemstheretoo. We have to do this before
1360-
*WriteBuffer because we needto look at the contents of the tuple,
1361-
*but it's OK to release thecontext lock on the buffer first.
1353+
* If thetuple hastoasted out-of-lineattributes, we need to delete
1354+
*thoseitems too. We have to do this before WriteBuffer because we need
1355+
* to look at the contents of the tuple, but it's OK to release the
1356+
* context lock on the buffer first.
13621357
*/
1363-
if (HeapTupleHasExtended(&tp))
1364-
heap_tuple_toast_attrs(relation,NULL,&(tp));
1365-
#endif
1358+
if (HeapTupleHasExternal(&tp))
1359+
heap_tuple_toast_attrs(relation,NULL,&tp);
13661360

13671361
pgstat_count_heap_delete(&relation->pgstat_info);
13681362

@@ -1572,11 +1566,11 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
15721566
* implement UNDO and will re-use transaction IDs after postmaster
15731567
* startup.
15741568
*
1575-
* We need to invoke the toaster if there are already anytoasted values
1576-
* present, or if the new tuple is over-threshold.
1569+
* We need to invoke the toaster if there are already anyout-of-line
1570+
*toasted valuespresent, or if the new tuple is over-threshold.
15771571
*/
1578-
need_toast= (HeapTupleHasExtended(&oldtup)||
1579-
HeapTupleHasExtended(newtup)||
1572+
need_toast= (HeapTupleHasExternal(&oldtup)||
1573+
HeapTupleHasExternal(newtup)||
15801574
(MAXALIGN(newtup->t_len)>TOAST_TUPLE_THRESHOLD));
15811575

15821576
newtupsize=MAXALIGN(newtup->t_len);

‎src/include/access/htup.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.63 2003/11/29 22:40:55 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.64 2004/01/16 20:51:30 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -436,9 +436,15 @@ typedef HeapTupleData *HeapTuple;
436436
*/
437437
#defineHeapTupleIsValid(tuple) PointerIsValid(tuple)
438438

439+
#defineHeapTupleHasNulls(tuple) \
440+
(((tuple)->t_data->t_infomask & HEAP_HASNULL) != 0)
441+
439442
#defineHeapTupleNoNulls(tuple) \
440443
(!((tuple)->t_data->t_infomask & HEAP_HASNULL))
441444

445+
#defineHeapTupleHasVarWidth(tuple) \
446+
(((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH) != 0)
447+
442448
#defineHeapTupleAllFixed(tuple) \
443449
(!((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH))
444450

‎src/include/postgres.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
1111
* Portions Copyright (c) 1995, Regents of the University of California
1212
*
13-
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.67 2004/01/04 05:57:21 tgl Exp $
13+
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.68 2004/01/16 20:51:30 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -59,8 +59,6 @@
5959
* TOASTed.
6060
* ----------------
6161
*/
62-
#defineTUPLE_TOASTER_ACTIVE
63-
6462
typedefstructvarattrib
6563
{
6664
int32va_header;/* External/compressed storage */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp