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

Commit88ebd62

Browse files
committed
Deduplicate code between slot_getallattrs() and slot_getsomeattrs().
Code in slot_getallattrs() is the same as if slot_getsomeattrs() iscalled with number of attributes specified in the tupledescriptor. Implement it that way instead of duplicating the codebetween those two functions.This is part of a patchseries abstracting TupleTableSlots so they canstore arbitrary forms of tuples, but is a nice enough cleanup on itsown.Author: Ashutosh BapatReviewed-By: Andres FreundDiscussion:https://postgr.es/m/20180220224318.gw4oe5jadhpmcdnm@alap3.anarazel.de
1 parenta40631a commit88ebd62

File tree

2 files changed

+12
-46
lines changed

2 files changed

+12
-46
lines changed

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

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,51 +1601,6 @@ slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
16011601
returnslot->tts_values[attnum-1];
16021602
}
16031603

1604-
/*
1605-
* slot_getallattrs
1606-
*This function forces all the entries of the slot's Datum/isnull
1607-
*arrays to be valid. The caller may then extract data directly
1608-
*from those arrays instead of using slot_getattr.
1609-
*/
1610-
void
1611-
slot_getallattrs(TupleTableSlot*slot)
1612-
{
1613-
inttdesc_natts=slot->tts_tupleDescriptor->natts;
1614-
intattnum;
1615-
HeapTupletuple;
1616-
1617-
/* Quick out if we have 'em all already */
1618-
if (slot->tts_nvalid==tdesc_natts)
1619-
return;
1620-
1621-
/*
1622-
* otherwise we had better have a physical tuple (tts_nvalid should equal
1623-
* natts in all virtual-tuple cases)
1624-
*/
1625-
tuple=slot->tts_tuple;
1626-
if (tuple==NULL)/* internal error */
1627-
elog(ERROR,"cannot extract attribute from empty tuple slot");
1628-
1629-
/*
1630-
* load up any slots available from physical tuple
1631-
*/
1632-
attnum=HeapTupleHeaderGetNatts(tuple->t_data);
1633-
attnum=Min(attnum,tdesc_natts);
1634-
1635-
slot_deform_tuple(slot,attnum);
1636-
1637-
attnum=slot->tts_nvalid;
1638-
1639-
/*
1640-
* If tuple doesn't have all the atts indicated by tupleDesc, read the
1641-
* rest as NULLS or missing values.
1642-
*/
1643-
if (attnum<tdesc_natts)
1644-
slot_getmissingattrs(slot,attnum,tdesc_natts);
1645-
1646-
slot->tts_nvalid=tdesc_natts;
1647-
}
1648-
16491604
/*
16501605
* slot_getsomeattrs
16511606
*This function forces the entries of the slot's Datum/isnull

‎src/include/executor/tuptable.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,22 @@ extern TupleTableSlot *ExecCopySlot(TupleTableSlot *dstslot,
174174

175175
/* in access/common/heaptuple.c */
176176
externDatumslot_getattr(TupleTableSlot*slot,intattnum,bool*isnull);
177-
externvoidslot_getallattrs(TupleTableSlot*slot);
178177
externvoidslot_getsomeattrs(TupleTableSlot*slot,intattnum);
179178
externboolslot_attisnull(TupleTableSlot*slot,intattnum);
180179
externboolslot_getsysattr(TupleTableSlot*slot,intattnum,
181180
Datum*value,bool*isnull);
182181
externvoidslot_getmissingattrs(TupleTableSlot*slot,intstartAttNum,intlastAttNum);
183182

183+
/*
184+
* slot_getallattrs
185+
*This function forces all the entries of the slot's Datum/isnull
186+
*arrays to be valid. The caller may then extract data directly
187+
*from those arrays instead of using slot_getattr.
188+
*/
189+
staticinlinevoid
190+
slot_getallattrs(TupleTableSlot*slot)
191+
{
192+
slot_getsomeattrs(slot,slot->tts_tupleDescriptor->natts);
193+
}
194+
184195
#endif/* TUPTABLE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp