Hi, After much distractions I've at least been able to do something about that bug report.
Marko Kreen <mark...@gmail.com> writes: > 1) Dumpable sequences are not supported - if sequence is tagged > with pg_catalog.pg_extension_config_dump(), the pg_dump tries > to run COPY on it. I can only reproduce that in 9.1. I first tried in HEAD where pg_dump will just entirely skip the sequence, which is not the right answer either, but at least does not spit out that message. > pg_dump: Error message from server: ERROR: cannot copy from sequence > "batch_id_seq" > pg_dump: The command was: COPY pgq.batch_id_seq TO stdout; Please find attached a patch that fixes it in 9.1, in all classic pg_dump, --data-only and --schema-only. git diff --stat src/bin/pg_dump/pg_dump.c | 68 +++++++++++++++++++++++++++++++++++--------- 1 files changed, 54 insertions(+), 14 deletions(-) Once that's ok for 9.1, I'll get to work on a fix for master, oh and look at what the situation is in 9.2, which I guess is the same as in master actually. > 2) If there is schema with functions, but nothing else, > create extension pgq_coop from 'unpackaged'; > drop extension pgq_coop; > create extension pgq_coop; > ERROR: schema "pgq_coop" already exists >From reading the scripts, it's not clear to me, but it appears that the schema existed before the create from unpackaged then got added to the extension by way of ALTER EXTENSION pgq_coop ADD SCHEMA pgq_coop; Is that true? Can we work out a minimal example to reproduce the bug? (The Makefile in skytools/sql/pgq_coop fails on my OS) Regards, -- Dimitri Fontaine http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
*** a/src/bin/pg_dump/pg_dump.c --- b/src/bin/pg_dump/pg_dump.c *************** *** 181,187 **** static void dumpTrigger(Archive *fout, TriggerInfo *tginfo); static void dumpTable(Archive *fout, TableInfo *tbinfo); static void dumpTableSchema(Archive *fout, TableInfo *tbinfo); static void dumpAttrDef(Archive *fout, AttrDefInfo *adinfo); ! static void dumpSequence(Archive *fout, TableInfo *tbinfo); static void dumpIndex(Archive *fout, IndxInfo *indxinfo); static void dumpConstraint(Archive *fout, ConstraintInfo *coninfo); static void dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo); --- 181,187 ---- static void dumpTable(Archive *fout, TableInfo *tbinfo); static void dumpTableSchema(Archive *fout, TableInfo *tbinfo); static void dumpAttrDef(Archive *fout, AttrDefInfo *adinfo); ! static void dumpSequence(Archive *fout, TableInfo *tbinfo, bool extMember); static void dumpIndex(Archive *fout, IndxInfo *indxinfo); static void dumpConstraint(Archive *fout, ConstraintInfo *coninfo); static void dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo); *************** *** 1536,1541 **** dumpTableData(Archive *fout, TableDataInfo *tdinfo) --- 1536,1547 ---- DataDumperPtr dumpFn; char *copyStmt; + if (tbinfo->relkind == RELKIND_SEQUENCE) + { + dumpSequence(fout, tbinfo, true); + return; + } + if (!dump_inserts) { /* Dump/restore using COPY */ *************** *** 1604,1609 **** makeTableDataInfo(TableInfo *tbinfo, bool oids) --- 1610,1630 ---- { TableDataInfo *tdinfo; + /* + * Nothing to do if we already decided to dump the table. This will + * happen for "config" tables. + */ + if (tbinfo->dataObj != NULL) + return; + + /* Skip VIEWs (no data to dump) */ + if (tbinfo->relkind == RELKIND_VIEW) + return; + /* Skip FOREIGN TABLEs (no data to dump) */ + if (tbinfo->relkind == RELKIND_FOREIGN_TABLE) + return; + + /* OK, let's dump it */ tdinfo = (TableDataInfo *) malloc(sizeof(TableDataInfo)); tdinfo->dobj.objType = DO_TABLE_DATA; *************** *** 11975,11981 **** dumpTable(Archive *fout, TableInfo *tbinfo) char *namecopy; if (tbinfo->relkind == RELKIND_SEQUENCE) ! dumpSequence(fout, tbinfo); else if (!dataOnly) dumpTableSchema(fout, tbinfo); --- 11996,12002 ---- char *namecopy; if (tbinfo->relkind == RELKIND_SEQUENCE) ! dumpSequence(fout, tbinfo, false); else if (!dataOnly) dumpTableSchema(fout, tbinfo); *************** *** 13118,13124 **** findLastBuiltinOid_V70(void) } static void ! dumpSequence(Archive *fout, TableInfo *tbinfo) { PGresult *res; char *startv, --- 13139,13145 ---- } static void ! dumpSequence(Archive *fout, TableInfo *tbinfo, bool extMember) { PGresult *res; char *startv, *************** *** 13219,13225 **** dumpSequence(Archive *fout, TableInfo *tbinfo) * * Add a 'SETVAL(seq, last_val, iscalled)' as part of a "data" dump. */ ! if (!dataOnly) { /* * DROP must be fully qualified in case same name appears in --- 13240,13246 ---- * * Add a 'SETVAL(seq, last_val, iscalled)' as part of a "data" dump. */ ! if (!extMember && !dataOnly) { /* * DROP must be fully qualified in case same name appears in *************** *** 13338,13344 **** dumpSequence(Archive *fout, TableInfo *tbinfo) tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); } ! if (!schemaOnly) { resetPQExpBuffer(query); appendPQExpBuffer(query, "SELECT pg_catalog.setval("); --- 13359,13365 ---- tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); } ! if (extMember || !schemaOnly) { resetPQExpBuffer(query); appendPQExpBuffer(query, "SELECT pg_catalog.setval("); *************** *** 13837,13852 **** getExtensionMembership(ExtensionInfo extinfo[], int numExtensions) TableInfo *configtbl; configtbl = findTableByOid(atooid(extconfigarray[j])); ! if (configtbl && configtbl->dataObj == NULL) { ! /* ! * Note: config tables are dumped without OIDs regardless ! * of the --oids setting. This is because row filtering ! * conditions aren't compatible with dumping OIDs. ! */ ! makeTableDataInfo(configtbl, false); ! if (strlen(extconditionarray[j]) > 0) ! configtbl->dataObj->filtercond = strdup(extconditionarray[j]); } } } --- 13858,13892 ---- TableInfo *configtbl; configtbl = findTableByOid(atooid(extconfigarray[j])); ! if (configtbl == NULL) ! continue; ! ! /* ! * Note: config tables are dumped without OIDs regardless of ! * the --oids setting. This is because row filtering conditions ! * aren't compatible with dumping OIDs. ! */ ! switch (configtbl->relkind) { ! case RELKIND_SEQUENCE: ! makeTableDataInfo(configtbl, false); ! break; ! ! case RELKIND_RELATION: ! case RELKIND_VIEW: ! makeTableDataInfo(configtbl, false); ! if (configtbl->dataObj != NULL) ! configtbl->dataObj->filtercond = ! pg_strdup(extconditionarray[j]); ! break; ! ! case RELKIND_INDEX: ! case RELKIND_TOASTVALUE: ! case RELKIND_COMPOSITE_TYPE: ! case RELKIND_FOREIGN_TABLE: ! case RELKIND_UNCATALOGED: ! /* not supported as an extension config dump target */ ! break; } } }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers