On 2021-Jan-20, Alexey Kondratov wrote: > On 2021-01-20 21:08, Alexey Kondratov wrote: > > > > I did a refactoring of ATExecSetTableSpaceNoStorage() in the 0001. New > > function SetRelTablesapce() is placed into the tablecmds.c. Following > > 0002 gets use of it. Is it close to what you and Michael suggested? > > Ugh, forgot to attach the patches. Here they are.
Yeah, looks reasonable. > + /* No work if no change in tablespace. */ > + oldTablespaceOid = rd_rel->reltablespace; > + if (tablespaceOid != oldTablespaceOid || > + (tablespaceOid == MyDatabaseTableSpace && > OidIsValid(oldTablespaceOid))) > + { > + /* Update the pg_class row. */ > + rd_rel->reltablespace = (tablespaceOid == MyDatabaseTableSpace) > ? > + InvalidOid : tablespaceOid; > + CatalogTupleUpdate(pg_class, &tuple->t_self, tuple); > + > + changed = true; > + } > + > + if (changed) > + /* Record dependency on tablespace */ > + changeDependencyOnTablespace(RelationRelationId, > + > reloid, rd_rel->reltablespace); Why have a separate "if (changed)" block here instead of merging with the above? -- Álvaro Herrera 39°49'30"S 73°17'W