---------------- * try_table_open - open a table relation by relation OID * * Same as table_open, except return NULL instead of failing * if the relation does not exist. * ---------------- */
| 71 | * ---------------- |
| 72 | */ |
| 73 | Relation |
| 74 | try_table_open(Oid relationId, LOCKMODE lockmode, bool noWait) |
| 75 | { |
| 76 | Relation r; |
| 77 | |
| 78 | r = try_relation_open(relationId, lockmode, noWait); |
| 79 | |
| 80 | /* leave if table does not exist */ |
| 81 | if (!r) |
| 82 | return NULL; |
| 83 | |
| 84 | if (r->rd_rel->relkind == RELKIND_INDEX || |
| 85 | r->rd_rel->relkind == RELKIND_PARTITIONED_INDEX) |
| 86 | ereport(ERROR, |
| 87 | (errcode(ERRCODE_WRONG_OBJECT_TYPE), |
| 88 | errmsg("\"%s\" is an index", |
| 89 | RelationGetRelationName(r)))); |
| 90 | else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE) |
| 91 | ereport(ERROR, |
| 92 | (errcode(ERRCODE_WRONG_OBJECT_TYPE), |
| 93 | errmsg("\"%s\" is a composite type", |
| 94 | RelationGetRelationName(r)))); |
| 95 | |
| 96 | return r; |
| 97 | } |
| 98 | |
| 99 | /* ---------------- |
| 100 | * table_openrv - open a table relation specified |
no test coverage detected