Hi, On 2019-01-12 01:35:06 +0100, Dmitry Dolgov wrote: > > On Sat, Dec 15, 2018 at 8:37 PM Andres Freund <and...@anarazel.de> wrote: > > > > We need to dump the table access method at dump time, otherwise we loose > > that information. > > As a result of the discussion in [1] (btw, thanks for starting it), here is > proposed solution with tracking current default_table_access_method. Next I'll > tackle similar issue for psql and probably add some tests for both patches.
Thanks! > +/* > + * Set the proper default_table_access_method value for the table. > + */ > +static void > +_selectTableAccessMethod(ArchiveHandle *AH, const char *tableam) > +{ > + PQExpBuffer cmd = createPQExpBuffer(); > + const char *want, *have; > + > + have = AH->currTableAm; > + want = tableam; > + > + if (!want) > + return; > + > + if (have && strcmp(want, have) == 0) > + return; > + > + > + appendPQExpBuffer(cmd, "SET default_table_access_method = %s;", > tableam); This needs escaping, at the very least with "", but better with proper routines for dealing with identifiers. > @@ -5914,7 +5922,7 @@ getTables(Archive *fout, int *numTables) > "tc.relfrozenxid AS > tfrozenxid, " > "tc.relminmxid AS tminmxid, " > "c.relpersistence, > c.relispopulated, " > - "c.relreplident, c.relpages, " > + "c.relreplident, c.relpages, > am.amname AS amname, " That AS doesn't do anything, does it? > /* other fields were zeroed above */ > > @@ -9355,7 +9370,7 @@ dumpComment(Archive *fout, const char *type, const char > *name, > * post-data. > */ > ArchiveEntry(fout, nilCatalogId, createDumpId(), > - tag->data, namespace, NULL, owner, > + tag->data, namespace, NULL, owner, > NULL, > "COMMENT", SECTION_NONE, > query->data, "", NULL, > &(dumpId), 1, We really ought to move the arguments to a struct, so we don't generate quite as much useless diffs whenever we do a change around one of these... Greetings, Andres Freund