* Check that a proposed result relation is a legal target for the operation * * Generally the parser and/or planner should have noticed any such mistake * already, but let's make sure. * * Note: when changing this function, you probably also need to look at * CheckValidRowMarkRel. */
| 2085 | * CheckValidRowMarkRel. |
| 2086 | */ |
| 2087 | void |
| 2088 | CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation, ModifyTableState *mtstate) |
| 2089 | { |
| 2090 | Relation resultRel = resultRelInfo->ri_RelationDesc; |
| 2091 | TriggerDesc *trigDesc = resultRel->trigdesc; |
| 2092 | FdwRoutine *fdwroutine; |
| 2093 | ModifyTable *node; |
| 2094 | int whichrel; |
| 2095 | List *updateColnos; |
| 2096 | ListCell *lc; |
| 2097 | |
| 2098 | switch (resultRel->rd_rel->relkind) |
| 2099 | { |
| 2100 | case RELKIND_RELATION: |
| 2101 | case RELKIND_PARTITIONED_TABLE: |
| 2102 | CheckCmdReplicaIdentity(resultRel, operation); |
| 2103 | break; |
| 2104 | case RELKIND_SEQUENCE: |
| 2105 | ereport(ERROR, |
| 2106 | (errcode(ERRCODE_WRONG_OBJECT_TYPE), |
| 2107 | errmsg("cannot change sequence \"%s\"", |
| 2108 | RelationGetRelationName(resultRel)))); |
| 2109 | break; |
| 2110 | case RELKIND_TOASTVALUE: |
| 2111 | ereport(ERROR, |
| 2112 | (errcode(ERRCODE_WRONG_OBJECT_TYPE), |
| 2113 | errmsg("cannot change TOAST relation \"%s\"", |
| 2114 | RelationGetRelationName(resultRel)))); |
| 2115 | break; |
| 2116 | case RELKIND_VIEW: |
| 2117 | |
| 2118 | /* |
| 2119 | * Okay only if there's a suitable INSTEAD OF trigger. Messages |
| 2120 | * here should match rewriteHandler.c's rewriteTargetView and |
| 2121 | * RewriteQuery, except that we omit errdetail because we haven't |
| 2122 | * got the information handy (and given that we really shouldn't |
| 2123 | * get here anyway, it's not worth great exertion to get). |
| 2124 | */ |
| 2125 | /* |
| 2126 | * GPDB_91_MERGE_FIXME: In Cloudberry, views are treated as non |
| 2127 | * partitioned relations, gp_distribution_policy contains no entry |
| 2128 | * for views. Consequently, flow of a ModifyTable node for a view |
| 2129 | * is determined such that it is not dispatched to segments. |
| 2130 | * Things get confused if the DML statement has a where clause that |
| 2131 | * results in a direct dispatch to one segment. Underlying scan |
| 2132 | * nodes have direct dispatch set but when it's time to commit, the |
| 2133 | * direct dispatch information is not passed on to the DTM and it |
| 2134 | * sends PREPARE to all segments, causing "Distributed transaction |
| 2135 | * ... not found" error. Until this is fixed, INSTEAD OF triggers |
| 2136 | * and DML on views need to be disabled. |
| 2137 | */ |
| 2138 | ereport(ERROR, |
| 2139 | (errcode(ERRCODE_GP_FEATURE_NOT_YET), |
| 2140 | errmsg("cannot change view \"%s\"", |
| 2141 | RelationGetRelationName(resultRel)), |
| 2142 | errhint("changing views is not supported in Cloudberry"))); |
| 2143 | |
| 2144 | switch (operation) |
no test coverage detected