| Line | Hits | Source | Commit |
| 1050 |
- |
CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation, |
- |
| 1051 |
- |
OnConflictAction onConflictAction, List *mergeActions) |
- |
| 1052 |
- |
{ |
- |
| 1053 |
- |
Relation resultRel = resultRelInfo->ri_RelationDesc; |
- |
| 1054 |
- |
FdwRoutine *fdwroutine; |
- |
| 1055 |
- |
|
- |
| 1056 |
- |
/* Expect a fully-formed ResultRelInfo from InitResultRelInfo(). */ |
- |
| 1057 |
- |
Assert(resultRelInfo->ri_needLockTagTuple == |
- |
| 1058 |
- |
IsInplaceUpdateRelation(resultRel)); |
- |
| 1059 |
- |
|
- |
| 1060 |
- |
switch (resultRel->rd_rel->relkind) |
- |
| 1061 |
- |
{ |
- |
| 1062 |
- |
case RELKIND_RELATION: |
- |
| 1063 |
- |
case RELKIND_PARTITIONED_TABLE: |
- |
| 1064 |
- |
|
- |
| 1065 |
- |
/* |
- |
| 1066 |
- |
* For MERGE, check that the target relation supports each action. |
- |
| 1067 |
- |
* For other operations, just check the operation itself. |
- |
| 1068 |
- |
*/ |
- |
| 1069 |
- |
if (operation == CMD_MERGE) |
- |
| 1070 |
- |
foreach_node(MergeAction, action, mergeActions) |
- |
| 1071 |
- |
CheckCmdReplicaIdentity(resultRel, action->commandType); |
- |
| 1072 |
- |
else |
- |
| 1073 |
- |
CheckCmdReplicaIdentity(resultRel, operation); |
- |
| 1074 |
- |
|
- |
| 1075 |
- |
/* |
- |
| 1076 |
- |
* For INSERT ON CONFLICT DO UPDATE, additionally check that the |
- |
| 1077 |
- |
* target relation supports UPDATE. |
- |
| 1078 |
- |
*/ |
- |
| 1079 |
- |
if (onConflictAction == ONCONFLICT_UPDATE) |
- |
| 1080 |
- |
CheckCmdReplicaIdentity(resultRel, CMD_UPDATE); |
- |
| 1081 |
- |
break; |
- |
| 1082 |
- |
case RELKIND_SEQUENCE: |
- |
| 1083 |
- |
ereport(ERROR, |
- |
| 1084 |
- |
(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
- |
| 1085 |
- |
errmsg("cannot change sequence \"%s\"", |
- |
| 1086 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1087 |
- |
break; |
- |
| 1088 |
- |
case RELKIND_TOASTVALUE: |
- |
| 1089 |
- |
ereport(ERROR, |
- |
| 1090 |
- |
(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
- |
| 1091 |
- |
errmsg("cannot change TOAST relation \"%s\"", |
- |
| 1092 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1093 |
- |
break; |
- |
| 1094 |
- |
case RELKIND_VIEW: |
- |
| 1095 |
- |
|
- |
| 1096 |
- |
/* |
- |
| 1097 |
- |
* Okay only if there's a suitable INSTEAD OF trigger. Otherwise, |
- |
| 1098 |
- |
* complain, but omit errdetail because we haven't got the |
- |
| 1099 |
- |
* information handy (and given that it really shouldn't happen, |
- |
| 1100 |
- |
* it's not worth great exertion to get). |
- |
| 1101 |
- |
*/ |
- |
| 1102 |
- |
if (!view_has_instead_trigger(resultRel, operation, mergeActions)) |
- |
| 1103 |
- |
error_view_not_updatable(resultRel, operation, mergeActions, |
- |
| 1104 |
- |
NULL); |
- |
| 1105 |
- |
break; |
- |
| 1106 |
- |
case RELKIND_MATVIEW: |
- |
| 1107 |
- |
if (!MatViewIncrementalMaintenanceIsEnabled()) |
- |
| 1108 |
- |
ereport(ERROR, |
- |
| 1109 |
- |
(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
- |
| 1110 |
- |
errmsg("cannot change materialized view \"%s\"", |
- |
| 1111 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1112 |
- |
break; |
- |
| 1113 |
- |
case RELKIND_FOREIGN_TABLE: |
- |
| 1114 |
- |
/* Okay only if the FDW supports it */ |
- |
| 1115 |
- |
fdwroutine = resultRelInfo->ri_FdwRoutine; |
- |
| 1116 |
- |
switch (operation) |
- |
| 1117 |
- |
{ |
- |
| 1118 |
- |
case CMD_INSERT: |
- |
| 1119 |
- |
if (fdwroutine->ExecForeignInsert == NULL) |
- |
| 1120 |
- |
ereport(ERROR, |
- |
| 1121 |
- |
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
- |
| 1122 |
- |
errmsg("cannot insert into foreign table \"%s\"", |
- |
| 1123 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1124 |
- |
if (fdwroutine->IsForeignRelUpdatable != NULL && |
- |
| 1125 |
- |
(fdwroutine->IsForeignRelUpdatable(resultRel) & (1 << CMD_INSERT)) == 0) |
- |
| 1126 |
- |
ereport(ERROR, |
- |
| 1127 |
- |
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), |
- |
| 1128 |
- |
errmsg("foreign table \"%s\" does not allow inserts", |
- |
| 1129 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1130 |
- |
break; |
- |
| 1131 |
- |
case CMD_UPDATE: |
- |
| 1132 |
- |
if (fdwroutine->ExecForeignUpdate == NULL) |
- |
| 1133 |
- |
ereport(ERROR, |
- |
| 1134 |
- |
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
- |
| 1135 |
- |
errmsg("cannot update foreign table \"%s\"", |
- |
| 1136 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1137 |
- |
if (fdwroutine->IsForeignRelUpdatable != NULL && |
- |
| 1138 |
- |
(fdwroutine->IsForeignRelUpdatable(resultRel) & (1 << CMD_UPDATE)) == 0) |
- |
| 1139 |
- |
ereport(ERROR, |
- |
| 1140 |
- |
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), |
- |
| 1141 |
- |
errmsg("foreign table \"%s\" does not allow updates", |
- |
| 1142 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1143 |
- |
break; |
- |
| 1144 |
- |
case CMD_DELETE: |
- |
| 1145 |
- |
if (fdwroutine->ExecForeignDelete == NULL) |
- |
| 1146 |
- |
ereport(ERROR, |
- |
| 1147 |
- |
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
- |
| 1148 |
- |
errmsg("cannot delete from foreign table \"%s\"", |
- |
| 1149 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1150 |
- |
if (fdwroutine->IsForeignRelUpdatable != NULL && |
- |
| 1151 |
- |
(fdwroutine->IsForeignRelUpdatable(resultRel) & (1 << CMD_DELETE)) == 0) |
- |
| 1152 |
- |
ereport(ERROR, |
- |
| 1153 |
- |
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), |
- |
| 1154 |
- |
errmsg("foreign table \"%s\" does not allow deletes", |
- |
| 1155 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1156 |
- |
break; |
- |
| 1157 |
- |
default: |
- |
| 1158 |
- |
elog(ERROR, "unrecognized CmdType: %d", (int) operation); |
- |
| 1159 |
- |
break; |
- |
| 1160 |
- |
} |
- |
| 1161 |
- |
break; |
- |
| 1162 |
0 |
case RELKIND_PROPGRAPH: |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1163 |
0 |
ereport(ERROR, |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1164 |
- |
(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1165 |
- |
errmsg("cannot change property graph \"%s\"", |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1166 |
- |
RelationGetRelationName(resultRel)))); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1167 |
- |
break; |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1168 |
- |
default: |
- |
| 1169 |
- |
ereport(ERROR, |
- |
| 1170 |
- |
(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
- |
| 1171 |
- |
errmsg("cannot change relation \"%s\"", |
- |
| 1172 |
- |
RelationGetRelationName(resultRel)))); |
- |
| 1173 |
- |
break; |
- |
| 1174 |
- |
} |
- |
| 1175 |
- |
} |
- |