MCPcopy Create free account
hub / github.com/apache/cloudberry / plpgsql_parse_tripword

Function plpgsql_parse_tripword

src/pl/plpgsql/src/pl_comp.c:1550–1624  ·  view source on GitHub ↗

---------- * plpgsql_parse_tripword Same lookup for three words * separated by dots. * ---------- */

Source from the content-addressed store, hash-verified

1548 * ----------
1549 */
1550bool
1551plpgsql_parse_tripword(char *word1, char *word2, char *word3,
1552 PLwdatum *wdatum, PLcword *cword)
1553{
1554 PLpgSQL_nsitem *ns;
1555 List *idents;
1556 int nnames;
1557
1558 /*
1559 * We should do nothing in DECLARE sections. In SQL expressions, we need
1560 * to make sure that RECFIELD datums are created when needed, and we need
1561 * to be careful about how many names are reported as belonging to the
1562 * T_DATUM: the third word could be a sub-field reference, which we don't
1563 * care about here.
1564 */
1565 if (plpgsql_IdentifierLookup != IDENTIFIER_LOOKUP_DECLARE)
1566 {
1567 /*
1568 * Do a lookup in the current namespace stack. Must find a record
1569 * reference, else ignore.
1570 */
1571 ns = plpgsql_ns_lookup(plpgsql_ns_top(), false,
1572 word1, word2, word3,
1573 &nnames);
1574 if (ns != NULL)
1575 {
1576 switch (ns->itemtype)
1577 {
1578 case PLPGSQL_NSTYPE_REC:
1579 {
1580 PLpgSQL_rec *rec;
1581 PLpgSQL_recfield *new;
1582
1583 rec = (PLpgSQL_rec *) (plpgsql_Datums[ns->itemno]);
1584 if (nnames == 1)
1585 {
1586 /*
1587 * First word is a record name, so second word
1588 * could be a field in this record (and the third,
1589 * a sub-field). We build a RECFIELD datum
1590 * whether it is or not --- any error will be
1591 * detected later.
1592 */
1593 new = plpgsql_build_recfield(rec, word2);
1594 idents = list_make2(makeString(word1),
1595 makeString(word2));
1596 }
1597 else
1598 {
1599 /* Block-qualified reference to record variable. */
1600 new = plpgsql_build_recfield(rec, word3);
1601 idents = list_make3(makeString(word1),
1602 makeString(word2),
1603 makeString(word3));
1604 }
1605 wdatum->datum = (PLpgSQL_datum *) new;
1606 wdatum->ident = NULL;
1607 wdatum->quoted = false; /* not used */

Callers 1

plpgsql_yylexFunction · 0.85

Calls 4

plpgsql_ns_lookupFunction · 0.85
plpgsql_ns_topFunction · 0.85
plpgsql_build_recfieldFunction · 0.85
makeStringFunction · 0.85

Tested by

no test coverage detected