Re: Bug in pg_dump/restore -o - Mailing list pgsql-hackers
From | Bruce Momjian |
---|---|
Subject | Re: Bug in pg_dump/restore -o |
Date | |
Msg-id | 200201172343.g0HNhPs15949@candle.pha.pa.us Whole thread Raw |
In response to | Re: Bug in pg_dump/restore -o (Tom Lane <tgl@sss.pgh.pa.us>) |
Responses |
Re: Bug in pg_dump/restore -o
|
List | pgsql-hackers |
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > I think I see the cause. I created a simple table and then generated > > the dump. I found this that the normal table had its COPY data in > > binary format while the max oid dump was pure ASCII. My guess is that > > the max oid dump code isn't calling the right routine to dump its data. > > Indeed, the max oid dump code doesn't look like it's been clued at all > about interoperating with the new pg_dump output code. It can't just > intermix commands and data into one string and expect pg_restore to cope. > Compare what happens in dumpClasses/dumpClasses_nodumpData to what's > being done in setMaxOid. > > Philip, you're probably the best-qualified to fix this, but if you don't > have time today then I can work on it. I don't want to delay RC1 for > this... I am told this was broken in 7.1 too. Attached is a diff that shows a possible direction for a solution. What I did was instead of doing the COPY myself, I am keeping the temp table I just created and passing that table name to the standard dump routines to do the COPY. One problem is that there is no TableInfo for the table, but I can call getTables() with the temp table name. Also, it is a temp table and I am not sure if it is going to like that. Anyway, this is not completed code but just a possible solution. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 Index: src/bin/pg_dump/pg_dump.c =================================================================== RCS file: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.237 diff -c -r1.237 pg_dump.c *** src/bin/pg_dump/pg_dump.c 2002/01/11 23:21:55 1.237 --- src/bin/pg_dump/pg_dump.c 2002/01/17 23:35:46 *************** *** 4545,4551 **** setMaxOid(Archive *fout) { PGresult *res; - Oid max_oid; char sql[1024]; res = PQexec(g_conn, "CREATE TEMPORARY TABLE pgdump_oid (dummy int4)"); --- 4542,4547 ---- *************** *** 4563,4575 **** write_msg(NULL, "could not insert into pgdump_oid table: %s", PQerrorMessage(g_conn)); exit_nicely(); } - max_oid = PQoidValue(res); - if (max_oid == 0) - { - write_msg(NULL, "inserted invalid oid\n"); - exit_nicely(); - } PQclear(res); res = PQexec(g_conn, "DROP TABLE pgdump_oid;"); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) --- 4559,4577 ---- write_msg(NULL, "could not insert into pgdump_oid table: %s", PQerrorMessage(g_conn)); exit_nicely(); } PQclear(res); + strcpy(sql, "COPY pgdump_oid WITH OIDS FROM stdin;\n"); + + dumpCtx = (DumpContext *) malloc(sizeof(DumpContext)); + dumpCtx->tblinfo = (TableInfo *) tblinfo; + dumpCtx->tblidx = 0; + dumpCtx->oids = true; + + dumpFn = dumpClasses_nodumpData; + + ArchiveEntry(fout, "0", "Max OID", "<Init>", NULL, sql, "", "", "", + dumpCtx, dumpFn); + res = PQexec(g_conn, "DROP TABLE pgdump_oid;"); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) *************** *** 4578,4594 **** exit_nicely(); } PQclear(res); - if (g_verbose) - write_msg(NULL, "maximum system oid is %u\n", max_oid); - snprintf(sql, 1024, - "CREATE TEMPORARY TABLE pgdump_oid (dummy int4);\n" - "COPY pgdump_oid WITH OIDS FROM stdin;\n" - "%u\t0\n" - "\\.\n" - "DROP TABLE pgdump_oid;\n", - max_oid); - - ArchiveEntry(fout, "0", "Max OID", "<Init>", NULL, sql, "", "", "", NULL, NULL); } /* --- 4580,4585 ----
pgsql-hackers by date: