* Set, reset, or replace reloptions. * * GPDB specific arguments: * aoopt_changed: whether any AO storage options have been changed in this function. * newam: the new AM if we will change the table AM. It's InvalidOid if no change is needed. */
| 16123 | * newam: the new AM if we will change the table AM. It's InvalidOid if no change is needed. |
| 16124 | */ |
| 16125 | static void |
| 16126 | ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation, |
| 16127 | bool *aoopt_changed, Oid newAccessMethod, LOCKMODE lockmode) |
| 16128 | { |
| 16129 | Oid relid; |
| 16130 | Relation pgclass; |
| 16131 | HeapTuple tuple; |
| 16132 | HeapTuple newtuple; |
| 16133 | Datum datum; |
| 16134 | bool isnull; |
| 16135 | Datum newOptions; |
| 16136 | Datum repl_val[Natts_pg_class]; |
| 16137 | bool repl_null[Natts_pg_class]; |
| 16138 | bool repl_repl[Natts_pg_class]; |
| 16139 | const TableAmRoutine * newAM; |
| 16140 | static char *validnsps[] = HEAP_RELOPT_NAMESPACES; |
| 16141 | |
| 16142 | if (defList == NIL && operation != AT_ReplaceRelOptions) |
| 16143 | return; /* nothing to do */ |
| 16144 | |
| 16145 | |
| 16146 | /* If we are changing access method, simply remove all the existing ones. */ |
| 16147 | if (OidIsValid(newAccessMethod)) |
| 16148 | { |
| 16149 | newAM = GetTableAmRoutineByAmId(newAccessMethod); |
| 16150 | clear_rel_opts(rel); |
| 16151 | } else |
| 16152 | newAM = NULL; |
| 16153 | |
| 16154 | pgclass = table_open(RelationRelationId, RowExclusiveLock); |
| 16155 | |
| 16156 | /* Fetch heap tuple */ |
| 16157 | relid = RelationGetRelid(rel); |
| 16158 | tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); |
| 16159 | if (!HeapTupleIsValid(tuple)) |
| 16160 | elog(ERROR, "cache lookup failed for relation %u", relid); |
| 16161 | |
| 16162 | if (operation == AT_ReplaceRelOptions) |
| 16163 | { |
| 16164 | /* |
| 16165 | * If we're supposed to replace the reloptions list, we just |
| 16166 | * pretend there were none before. |
| 16167 | */ |
| 16168 | datum = (Datum) 0; |
| 16169 | isnull = true; |
| 16170 | } |
| 16171 | else |
| 16172 | { |
| 16173 | /* Get the old reloptions */ |
| 16174 | datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions, |
| 16175 | &isnull); |
| 16176 | } |
| 16177 | |
| 16178 | if (defList != NIL) |
| 16179 | { |
| 16180 | ListCell *cell; |
| 16181 | |
| 16182 | foreach(cell, defList) |
no test coverage detected