* postgresIsForeignRelUpdatable * Determine whether a foreign table supports INSERT, UPDATE and/or * DELETE. */
| 2287 | * DELETE. |
| 2288 | */ |
| 2289 | static int |
| 2290 | postgresIsForeignRelUpdatable(Relation rel) |
| 2291 | { |
| 2292 | bool updatable; |
| 2293 | ForeignTable *table; |
| 2294 | ForeignServer *server; |
| 2295 | ListCell *lc; |
| 2296 | |
| 2297 | /* |
| 2298 | * By default, all postgres_fdw foreign tables are assumed updatable. This |
| 2299 | * can be overridden by a per-server setting, which in turn can be |
| 2300 | * overridden by a per-table setting. |
| 2301 | */ |
| 2302 | updatable = true; |
| 2303 | |
| 2304 | table = GetForeignTable(RelationGetRelid(rel)); |
| 2305 | server = GetForeignServer(table->serverid); |
| 2306 | |
| 2307 | foreach(lc, server->options) |
| 2308 | { |
| 2309 | DefElem *def = (DefElem *) lfirst(lc); |
| 2310 | |
| 2311 | if (strcmp(def->defname, "updatable") == 0) |
| 2312 | updatable = defGetBoolean(def); |
| 2313 | } |
| 2314 | foreach(lc, table->options) |
| 2315 | { |
| 2316 | DefElem *def = (DefElem *) lfirst(lc); |
| 2317 | |
| 2318 | if (strcmp(def->defname, "updatable") == 0) |
| 2319 | updatable = defGetBoolean(def); |
| 2320 | } |
| 2321 | |
| 2322 | /* |
| 2323 | * Currently "updatable" means support for INSERT, UPDATE and DELETE. |
| 2324 | */ |
| 2325 | if (!updatable) |
| 2326 | return 0; |
| 2327 | |
| 2328 | /* |
| 2329 | * Cloudberry only supports INSERT, because UPDATE/DELETE SELECT requires |
| 2330 | * the hidden column gp_segment_id and the other "ModifyTable mixes |
| 2331 | * distributed and entry-only tables" issue. |
| 2332 | */ |
| 2333 | UserMapping *user = GetUserMapping(rel->rd_rel->relowner, table->serverid); |
| 2334 | if (greenplumCheckIsCloudberry(user)) |
| 2335 | return (1 << CMD_INSERT); |
| 2336 | else |
| 2337 | return (1 << CMD_INSERT) | (1 << CMD_UPDATE) | (1 << CMD_DELETE); |
| 2338 | } |
| 2339 | |
| 2340 | /* |
| 2341 | * postgresRecheckForeignScan |
nothing calls this directly
no test coverage detected