* GetTableAmRoutineByAmId - look up the handler of the table access method * with the given OID, and get its TableAmRoutine struct. * * If the given OID isn't a valid index access method, throws error. */
| 117 | * If the given OID isn't a valid index access method, throws error. |
| 118 | */ |
| 119 | const TableAmRoutine * |
| 120 | GetTableAmRoutineByAmId(Oid amoid) |
| 121 | { |
| 122 | HeapTuple tuple; |
| 123 | Form_pg_am amform; |
| 124 | regproc amhandler; |
| 125 | |
| 126 | if (amoid == HEAP_TABLE_AM_OID) |
| 127 | return GetHeapamTableAmRoutine(); |
| 128 | |
| 129 | tuple = SearchSysCache1(AMOID, ObjectIdGetDatum(amoid)); |
| 130 | if (!HeapTupleIsValid(tuple)) |
| 131 | ereport(ERROR, (errmsg("cache lookup failed for access method %u", amoid))); |
| 132 | |
| 133 | amform = (Form_pg_am) GETSTRUCT(tuple); |
| 134 | if (amform->amtype != AMTYPE_TABLE) |
| 135 | ereport(ERROR, |
| 136 | (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), |
| 137 | errmsg("access method \"%s\" is not of type TABLE", |
| 138 | NameStr(amform->amname)))); |
| 139 | |
| 140 | amhandler = amform->amhandler; |
| 141 | ReleaseSysCache(tuple); |
| 142 | |
| 143 | return GetTableAmRoutine(amhandler); |
| 144 | } |
| 145 | |
| 146 | /* check_hook: validate new default_table_access_method */ |
| 147 | bool |
no test coverage detected