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

Function postgresBeginForeignModify

contrib/postgres_fdw/postgres_fdw.c:1902–1953  ·  view source on GitHub ↗

* postgresBeginForeignModify * Begin an insert/update/delete operation on a foreign table */

Source from the content-addressed store, hash-verified

1900 * Begin an insert/update/delete operation on a foreign table
1901 */
1902static void
1903postgresBeginForeignModify(ModifyTableState *mtstate,
1904 ResultRelInfo *resultRelInfo,
1905 List *fdw_private,
1906 int subplan_index,
1907 int eflags)
1908{
1909 PgFdwModifyState *fmstate;
1910 char *query;
1911 List *target_attrs;
1912 bool has_returning;
1913 int values_end_len;
1914 List *retrieved_attrs;
1915 RangeTblEntry *rte;
1916
1917 /*
1918 * Do nothing in EXPLAIN (no ANALYZE) case. resultRelInfo->ri_FdwState
1919 * stays NULL.
1920 */
1921 if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
1922 return;
1923
1924 /* Deconstruct fdw_private data. */
1925 query = strVal(list_nth(fdw_private,
1926 FdwModifyPrivateUpdateSql));
1927 target_attrs = (List *) list_nth(fdw_private,
1928 FdwModifyPrivateTargetAttnums);
1929 values_end_len = intVal(list_nth(fdw_private,
1930 FdwModifyPrivateLen));
1931 has_returning = intVal(list_nth(fdw_private,
1932 FdwModifyPrivateHasReturning));
1933 retrieved_attrs = (List *) list_nth(fdw_private,
1934 FdwModifyPrivateRetrievedAttrs);
1935
1936 /* Find RTE. */
1937 rte = exec_rt_fetch(resultRelInfo->ri_RangeTableIndex,
1938 mtstate->ps.state);
1939
1940 /* Construct an execution state. */
1941 fmstate = create_foreign_modify(mtstate->ps.state,
1942 rte,
1943 resultRelInfo,
1944 mtstate->operation,
1945 outerPlanState(mtstate)->plan,
1946 query,
1947 target_attrs,
1948 values_end_len,
1949 has_returning,
1950 retrieved_attrs);
1951
1952 resultRelInfo->ri_FdwState = fmstate;
1953}
1954
1955/*
1956 * postgresExecForeignInsert

Callers

nothing calls this directly

Calls 3

list_nthFunction · 0.85
exec_rt_fetchFunction · 0.85
create_foreign_modifyFunction · 0.85

Tested by

no test coverage detected