|
80 | 80 | /* |
81 | 81 | * Return the missing value of an attribute, or NULL if there isn't one. |
82 | 82 | */ |
83 | | -static Datum |
| 83 | +Datum |
84 | 84 | getmissingattr(TupleDesc tupleDesc, |
85 | 85 | int attnum, bool *isnull) |
86 | 86 | { |
@@ -111,43 +111,6 @@ getmissingattr(TupleDesc tupleDesc, |
111 | 111 | return PointerGetDatum(NULL); |
112 | 112 | } |
113 | 113 |
|
114 | | -/* |
115 | | - * Fill in missing values for a TupleTableSlot. |
116 | | - * |
117 | | - * This is only exposed because it's needed for JIT compiled tuple |
118 | | - * deforming. That exception aside, there should be no callers outside of this |
119 | | - * file. |
120 | | - */ |
121 | | -void |
122 | | -slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum) |
123 | | -{ |
124 | | - AttrMissing *attrmiss = NULL; |
125 | | - int missattnum; |
126 | | - |
127 | | - if (slot->tts_tupleDescriptor->constr) |
128 | | - attrmiss = slot->tts_tupleDescriptor->constr->missing; |
129 | | - |
130 | | - if (!attrmiss) |
131 | | - { |
132 | | - /* no missing values array at all, so just fill everything in as NULL */ |
133 | | - memset(slot->tts_values + startAttNum, 0, |
134 | | - (lastAttNum - startAttNum) * sizeof(Datum)); |
135 | | - memset(slot->tts_isnull + startAttNum, 1, |
136 | | - (lastAttNum - startAttNum) * sizeof(bool)); |
137 | | - } |
138 | | - else |
139 | | - { |
140 | | - /* if there is a missing values array we must process them one by one */ |
141 | | - for (missattnum = startAttNum; |
142 | | - missattnum < lastAttNum; |
143 | | - missattnum++) |
144 | | - { |
145 | | - slot->tts_values[missattnum] = attrmiss[missattnum].am_value; |
146 | | - slot->tts_isnull[missattnum] = !attrmiss[missattnum].am_present; |
147 | | - } |
148 | | - } |
149 | | -} |
150 | | - |
151 | 114 | /* |
152 | 115 | * heap_compute_data_size |
153 | 116 | * Determine size of the data area of a tuple to be constructed |
@@ -1398,7 +1361,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, |
1398 | 1361 | * re-computing information about previously extracted attributes. |
1399 | 1362 | * slot->tts_nvalid is the number of attributes already extracted. |
1400 | 1363 | */ |
1401 | | -static void |
| 1364 | +void |
1402 | 1365 | slot_deform_tuple(TupleTableSlot *slot, int natts) |
1403 | 1366 | { |
1404 | 1367 | HeapTuple tuple = slot->tts_tuple; |
@@ -1492,153 +1455,6 @@ slot_deform_tuple(TupleTableSlot *slot, int natts) |
1492 | 1455 | slot->tts_slow = slow; |
1493 | 1456 | } |
1494 | 1457 |
|
1495 | | -/* |
1496 | | - * slot_getattr |
1497 | | - * This function fetches an attribute of the slot's current tuple. |
1498 | | - * It is functionally equivalent to heap_getattr, but fetches of |
1499 | | - * multiple attributes of the same tuple will be optimized better, |
1500 | | - * because we avoid O(N^2) behavior from multiple calls of |
1501 | | - * nocachegetattr(), even when attcacheoff isn't usable. |
1502 | | - * |
1503 | | - * A difference from raw heap_getattr is that attnums beyond the |
1504 | | - * slot's tupdesc's last attribute will be considered NULL even |
1505 | | - * when the physical tuple is longer than the tupdesc. |
1506 | | - */ |
1507 | | -Datum |
1508 | | -slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull) |
1509 | | -{ |
1510 | | - HeapTuple tuple = slot->tts_tuple; |
1511 | | - TupleDesc tupleDesc = slot->tts_tupleDescriptor; |
1512 | | - HeapTupleHeader tup; |
1513 | | - |
1514 | | - /* |
1515 | | - * system attributes are handled by heap_getsysattr |
1516 | | - */ |
1517 | | - if (attnum <= 0) |
1518 | | - { |
1519 | | - if (tuple == NULL) /* internal error */ |
1520 | | - elog(ERROR, "cannot extract system attribute from virtual tuple"); |
1521 | | - if (tuple == &(slot->tts_minhdr)) /* internal error */ |
1522 | | - elog(ERROR, "cannot extract system attribute from minimal tuple"); |
1523 | | - return heap_getsysattr(tuple, attnum, tupleDesc, isnull); |
1524 | | - } |
1525 | | - |
1526 | | - /* |
1527 | | - * fast path if desired attribute already cached |
1528 | | - */ |
1529 | | - if (attnum <= slot->tts_nvalid) |
1530 | | - { |
1531 | | - *isnull = slot->tts_isnull[attnum - 1]; |
1532 | | - return slot->tts_values[attnum - 1]; |
1533 | | - } |
1534 | | - |
1535 | | - /* |
1536 | | - * return NULL if attnum is out of range according to the tupdesc |
1537 | | - */ |
1538 | | - if (attnum > tupleDesc->natts) |
1539 | | - { |
1540 | | - *isnull = true; |
1541 | | - return (Datum) 0; |
1542 | | - } |
1543 | | - |
1544 | | - /* |
1545 | | - * otherwise we had better have a physical tuple (tts_nvalid should equal |
1546 | | - * natts in all virtual-tuple cases) |
1547 | | - */ |
1548 | | - if (tuple == NULL) /* internal error */ |
1549 | | - elog(ERROR, "cannot extract attribute from empty tuple slot"); |
1550 | | - |
1551 | | - /* |
1552 | | - * return NULL or missing value if attnum is out of range according to the |
1553 | | - * tuple |
1554 | | - * |
1555 | | - * (We have to check this separately because of various inheritance and |
1556 | | - * table-alteration scenarios: the tuple could be either longer or shorter |
1557 | | - * than the tupdesc.) |
1558 | | - */ |
1559 | | - tup = tuple->t_data; |
1560 | | - if (attnum > HeapTupleHeaderGetNatts(tup)) |
1561 | | - return getmissingattr(slot->tts_tupleDescriptor, attnum, isnull); |
1562 | | - |
1563 | | - /* |
1564 | | - * check if target attribute is null: no point in groveling through tuple |
1565 | | - */ |
1566 | | - if (HeapTupleHasNulls(tuple) && att_isnull(attnum - 1, tup->t_bits)) |
1567 | | - { |
1568 | | - *isnull = true; |
1569 | | - return (Datum) 0; |
1570 | | - } |
1571 | | - |
1572 | | - /* |
1573 | | - * If the attribute's column has been dropped, we force a NULL result. |
1574 | | - * This case should not happen in normal use, but it could happen if we |
1575 | | - * are executing a plan cached before the column was dropped. |
1576 | | - */ |
1577 | | - if (TupleDescAttr(tupleDesc, attnum - 1)->attisdropped) |
1578 | | - { |
1579 | | - *isnull = true; |
1580 | | - return (Datum) 0; |
1581 | | - } |
1582 | | - |
1583 | | - /* |
1584 | | - * Extract the attribute, along with any preceding attributes. |
1585 | | - */ |
1586 | | - slot_deform_tuple(slot, attnum); |
1587 | | - |
1588 | | - /* |
1589 | | - * The result is acquired from tts_values array. |
1590 | | - */ |
1591 | | - *isnull = slot->tts_isnull[attnum - 1]; |
1592 | | - return slot->tts_values[attnum - 1]; |
1593 | | -} |
1594 | | - |
1595 | | -/* |
1596 | | - * slot_getsomeattrs |
1597 | | - * This function forces the entries of the slot's Datum/isnull |
1598 | | - * arrays to be valid at least up through the attnum'th entry. |
1599 | | - */ |
1600 | | -void |
1601 | | -slot_getsomeattrs(TupleTableSlot *slot, int attnum) |
1602 | | -{ |
1603 | | - HeapTuple tuple; |
1604 | | - int attno; |
1605 | | - |
1606 | | - /* Quick out if we have 'em all already */ |
1607 | | - if (slot->tts_nvalid >= attnum) |
1608 | | - return; |
1609 | | - |
1610 | | - /* Check for caller error */ |
1611 | | - if (attnum <= 0 || attnum > slot->tts_tupleDescriptor->natts) |
1612 | | - elog(ERROR, "invalid attribute number %d", attnum); |
1613 | | - |
1614 | | - /* |
1615 | | - * otherwise we had better have a physical tuple (tts_nvalid should equal |
1616 | | - * natts in all virtual-tuple cases) |
1617 | | - */ |
1618 | | - tuple = slot->tts_tuple; |
1619 | | - if (tuple == NULL) /* internal error */ |
1620 | | - elog(ERROR, "cannot extract attribute from empty tuple slot"); |
1621 | | - |
1622 | | - /* |
1623 | | - * load up any slots available from physical tuple |
1624 | | - */ |
1625 | | - attno = HeapTupleHeaderGetNatts(tuple->t_data); |
1626 | | - attno = Min(attno, attnum); |
1627 | | - |
1628 | | - slot_deform_tuple(slot, attno); |
1629 | | - |
1630 | | - attno = slot->tts_nvalid; |
1631 | | - |
1632 | | - /* |
1633 | | - * If tuple doesn't have all the atts indicated by attnum, read the rest |
1634 | | - * as NULLs or missing values |
1635 | | - */ |
1636 | | - if (attno < attnum) |
1637 | | - slot_getmissingattrs(slot, attno, attnum); |
1638 | | - |
1639 | | - slot->tts_nvalid = attnum; |
1640 | | -} |
1641 | | - |
1642 | 1458 | /* |
1643 | 1459 | * slot_attisnull |
1644 | 1460 | * Detect whether an attribute of the slot is null, without |
|
0 commit comments