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

Function getNotify

src/interfaces/libpq/fe-protocol3.c:1610–1658  ·  view source on GitHub ↗

* Attempt to read a Notify response message. * This is possible in several places, so we break it out as a subroutine. * Entry: 'A' message type and length have already been consumed. * Exit: returns 0 if successfully consumed Notify message. * returns EOF if not enough data. */

Source from the content-addressed store, hash-verified

1608 * returns EOF if not enough data.
1609 */
1610static int
1611getNotify(PGconn *conn)
1612{
1613 int be_pid;
1614 char *svname;
1615 int nmlen;
1616 int extralen;
1617 PGnotify *newNotify;
1618
1619 if (pqGetInt(&be_pid, 4, conn))
1620 return EOF;
1621 if (pqGets(&conn->workBuffer, conn))
1622 return EOF;
1623 /* must save name while getting extra string */
1624 svname = strdup(conn->workBuffer.data);
1625 if (!svname)
1626 return EOF;
1627 if (pqGets(&conn->workBuffer, conn))
1628 {
1629 free(svname);
1630 return EOF;
1631 }
1632
1633 /*
1634 * Store the strings right after the PQnotify structure so it can all be
1635 * freed at once. We don't use NAMEDATALEN because we don't want to tie
1636 * this interface to a specific server name length.
1637 */
1638 nmlen = strlen(svname);
1639 extralen = strlen(conn->workBuffer.data);
1640 newNotify = (PGnotify *) malloc(sizeof(PGnotify) + nmlen + extralen + 2);
1641 if (newNotify)
1642 {
1643 newNotify->relname = (char *) newNotify + sizeof(PGnotify);
1644 strcpy(newNotify->relname, svname);
1645 newNotify->extra = newNotify->relname + nmlen + 1;
1646 strcpy(newNotify->extra, conn->workBuffer.data);
1647 newNotify->be_pid = be_pid;
1648 newNotify->next = NULL;
1649 if (conn->notifyTail)
1650 conn->notifyTail->next = newNotify;
1651 else
1652 conn->notifyHead = newNotify;
1653 conn->notifyTail = newNotify;
1654 }
1655
1656 free(svname);
1657 return 0;
1658}
1659
1660/*
1661 * getCopyStart - process CopyInResponse, CopyOutResponse or

Callers 3

pqParseInput3Function · 0.85
getCopyDataMessageFunction · 0.85
pqFunctionCall3Function · 0.85

Calls 2

pqGetIntFunction · 0.85
pqGetsFunction · 0.85

Tested by

no test coverage detected