*** pgsql/src/backend/commands/tablecmds.c 2009/01/22 20:16:02 1.278 --- pgsql/src/backend/commands/tablecmds.c 2009/02/02 19:31:38 1.279 *************** *** 8,14 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.277 2009/01/12 08:54:26 petere Exp $ * *------------------------------------------------------------------------- */ --- 8,14 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.278 2009/01/22 20:16:02 tgl Exp $ * *------------------------------------------------------------------------- */ *************** DefineRelation(CreateStmt *stmt, char re *** 351,356 **** --- 351,357 ---- Datum reloptions; ListCell *listptr; AttrNumber attnum; + static char *validnsps[] = HEAP_RELOPT_NAMESPACES; /* * Truncate relname to appropriate length (probably a waste of time, as *************** DefineRelation(CreateStmt *stmt, char re *** 418,424 **** /* * Parse and validate reloptions, if any. */ ! reloptions = transformRelOptions((Datum) 0, stmt->options, true, false); (void) heap_reloptions(relkind, reloptions, true); --- 419,426 ---- /* * Parse and validate reloptions, if any. */ ! reloptions = transformRelOptions((Datum) 0, stmt->options, NULL, validnsps, ! true, false); (void) heap_reloptions(relkind, reloptions, true); *************** ATRewriteCatalogs(List **wqueue) *** 2572,2578 **** (tab->subcmds[AT_PASS_ADD_COL] || tab->subcmds[AT_PASS_ALTER_TYPE] || tab->subcmds[AT_PASS_COL_ATTRS])) ! AlterTableCreateToastTable(tab->relid); } } --- 2574,2580 ---- (tab->subcmds[AT_PASS_ADD_COL] || tab->subcmds[AT_PASS_ALTER_TYPE] || tab->subcmds[AT_PASS_COL_ATTRS])) ! AlterTableCreateToastTable(tab->relid, (Datum) 0); } } *************** ATExecSetRelOptions(Relation rel, List * *** 6457,6462 **** --- 6459,6465 ---- Datum repl_val[Natts_pg_class]; bool repl_null[Natts_pg_class]; bool repl_repl[Natts_pg_class]; + static char *validnsps[] = HEAP_RELOPT_NAMESPACES; if (defList == NIL) return; /* nothing to do */ *************** ATExecSetRelOptions(Relation rel, List * *** 6475,6481 **** /* Generate new proposed reloptions (text array) */ newOptions = transformRelOptions(isnull ? (Datum) 0 : datum, ! defList, false, isReset); /* Validate */ switch (rel->rd_rel->relkind) --- 6478,6484 ---- /* Generate new proposed reloptions (text array) */ newOptions = transformRelOptions(isnull ? (Datum) 0 : datum, ! defList, NULL, validnsps, false, isReset); /* Validate */ switch (rel->rd_rel->relkind) *************** ATExecSetRelOptions(Relation rel, List * *** 6521,6526 **** --- 6524,6576 ---- ReleaseSysCache(tuple); + /* repeat the whole exercise for the toast table, if there's one */ + if (OidIsValid(rel->rd_rel->reltoastrelid)) + { + Relation toastrel; + Oid toastid = rel->rd_rel->reltoastrelid; + + toastrel = heap_open(toastid, AccessExclusiveLock); + + /* Get the old reloptions */ + tuple = SearchSysCache(RELOID, + ObjectIdGetDatum(toastid), + 0, 0, 0); + if (!HeapTupleIsValid(tuple)) + elog(ERROR, "cache lookup failed for relation %u", toastid); + + datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions, &isnull); + + newOptions = transformRelOptions(isnull ? (Datum) 0 : datum, + defList, "toast", validnsps, false, isReset); + + (void) heap_reloptions(RELKIND_TOASTVALUE, newOptions, true); + + memset(repl_val, 0, sizeof(repl_val)); + memset(repl_null, false, sizeof(repl_null)); + memset(repl_repl, false, sizeof(repl_repl)); + + if (newOptions != (Datum) 0) + repl_val[Anum_pg_class_reloptions - 1] = newOptions; + else + repl_null[Anum_pg_class_reloptions - 1] = true; + + repl_repl[Anum_pg_class_reloptions - 1] = true; + + newtuple = heap_modify_tuple(tuple, RelationGetDescr(pgclass), + repl_val, repl_null, repl_repl); + + simple_heap_update(pgclass, &newtuple->t_self, newtuple); + + CatalogUpdateIndexes(pgclass, newtuple); + + heap_freetuple(newtuple); + + ReleaseSysCache(tuple); + + heap_close(toastrel, NoLock); + } + heap_close(pgclass, RowExclusiveLock); }