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

Function notify_modified_relations_to_QD

src/backend/executor/nodeModifyTable.c:3807–3861  ·  view source on GitHub ↗

* notify_modified_relations_to_QD * Send modified relation info back to QD through extend libpq protocol. */

Source from the content-addressed store, hash-verified

3805 * Send modified relation info back to QD through extend libpq protocol.
3806 */
3807static void
3808notify_modified_relations_to_QD(ModifyTableState *node)
3809{
3810 StringInfoData buf;
3811 HASH_SEQ_STATUS scan;
3812 ModifiedLeafRelidsData *r;
3813 List *inserted = NIL;
3814 List *updated = NIL;
3815 List *deleted = NIL;
3816
3817 hash_seq_init(&scan, node->modified_leaf_relids);
3818
3819 pq_beginmessage(&buf, PQExtendProtocol);
3820
3821 while ((r = (ModifiedLeafRelidsData *) hash_seq_search(&scan)) != NULL)
3822 {
3823 switch (r->key.cmd)
3824 {
3825 case CMD_INSERT:
3826 inserted = lappend_oid(inserted, r->key.relid);
3827 break;
3828 case CMD_UPDATE:
3829 updated = lappend_oid(updated, r->key.relid);
3830 break;
3831 case CMD_DELETE:
3832 deleted = lappend_oid(deleted, r->key.relid);
3833 break;
3834 default:
3835 Assert(false);
3836 break;
3837 }
3838 }
3839
3840 if (inserted != NIL)
3841 {
3842 send_subtag(&buf, EP_TAG_I, inserted);
3843 pfree(inserted);
3844 }
3845
3846 if (updated != NIL)
3847 {
3848 send_subtag(&buf, EP_TAG_U, updated);
3849 pfree(updated);
3850 }
3851
3852 if (deleted != NIL)
3853 {
3854 send_subtag(&buf, EP_TAG_D, deleted);
3855 pfree(deleted);
3856 }
3857
3858 pq_sendint32(&buf, EP_TAG_MAX); /* Finish this run. */
3859 pq_endmessage(&buf);
3860 pq_flush(); /* Flush to notify QD in time. */
3861}
3862
3863/*
3864 * send_subtag

Callers 1

ExecEndModifyTableFunction · 0.85

Calls 8

hash_seq_initFunction · 0.85
pq_beginmessageFunction · 0.85
hash_seq_searchFunction · 0.85
lappend_oidFunction · 0.85
send_subtagFunction · 0.85
pq_sendint32Function · 0.85
pq_endmessageFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected