Enable ALTER TABLE ADD PRIMARY KEY for pg_dump, for performance reasons
so index is not on table during COPY. > > AFAICT, the patch I posted to -patches a little while to enable the > > usage of ALTER TABLE ADD PRIMARY KEY by pg_dump hasn't been applied, nor > > is it in the unapplied patches list. I was under the impression that > > this was in the queue for application -- did it just get lost? Neil Conway <neilconway@rogers.com>
This commit is contained in:
parent
62e6eb9bf7
commit
5b5cef9abd
@ -22,7 +22,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.242 2002/02/27 20:59:05 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.243 2002/03/06 20:48:42 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -4259,7 +4259,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* put the CONSTRAINTS inside the table def */
|
/* Put the CONSTRAINTS inside the table def */
|
||||||
for (k = 0; k < tblinfo[i].ncheck; k++)
|
for (k = 0; k < tblinfo[i].ncheck; k++)
|
||||||
{
|
{
|
||||||
if (actual_atts + k > 0)
|
if (actual_atts + k > 0)
|
||||||
@ -4269,36 +4269,15 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
|
|||||||
tblinfo[i].check_expr[k]);
|
tblinfo[i].check_expr[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Primary Key */
|
/*
|
||||||
if (tblinfo[i].pkIndexOid != NULL)
|
* Primary Key: In versions of PostgreSQL prior to 7.2, we
|
||||||
{
|
* needed to include the primary key in the table definition.
|
||||||
PQExpBuffer consDef;
|
* However, this is not ideal because it creates an index
|
||||||
|
* on the table, which makes COPY slower. As of release 7.2,
|
||||||
/* Find the corresponding index */
|
* we can add primary keys to a table after is has been created,
|
||||||
for (k = 0; k < numIndexes; k++)
|
* using ALTER TABLE ; see dumpIndexes() for more information.
|
||||||
{
|
* Therefore, we ignore primary keys in this function.
|
||||||
if (strcmp(indinfo[k].indexreloid,
|
*/
|
||||||
tblinfo[i].pkIndexOid) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (k >= numIndexes)
|
|
||||||
{
|
|
||||||
write_msg(NULL, "dumpTables(): failed sanity check, could not find index (%s) for primary key constraint\n",
|
|
||||||
tblinfo[i].pkIndexOid);
|
|
||||||
exit_nicely();
|
|
||||||
}
|
|
||||||
|
|
||||||
consDef = getPKconstraint(&tblinfo[i], &indinfo[k]);
|
|
||||||
|
|
||||||
if ((actual_atts + tblinfo[i].ncheck) > 0)
|
|
||||||
appendPQExpBuffer(q, ",\n\t");
|
|
||||||
|
|
||||||
appendPQExpBuffer(q, "%s", consDef->data);
|
|
||||||
|
|
||||||
destroyPQExpBuffer(consDef);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
appendPQExpBuffer(q, "\n)");
|
appendPQExpBuffer(q, "\n)");
|
||||||
|
|
||||||
@ -4454,13 +4433,6 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
|
|||||||
/* Handle PK indexes */
|
/* Handle PK indexes */
|
||||||
if (strcmp(indinfo[i].indisprimary, "t") == 0)
|
if (strcmp(indinfo[i].indisprimary, "t") == 0)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PK: Enable this code when ALTER TABLE supports PK
|
|
||||||
* constraints.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PQExpBuffer consDef = getPKconstraint(&tblinfo[tableInd], &indinfo[i]);
|
PQExpBuffer consDef = getPKconstraint(&tblinfo[tableInd], &indinfo[i]);
|
||||||
|
|
||||||
resetPQExpBuffer(q);
|
resetPQExpBuffer(q);
|
||||||
@ -4469,12 +4441,11 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
|
|||||||
fmtId(tblinfo[tableInd].relname, force_quotes),
|
fmtId(tblinfo[tableInd].relname, force_quotes),
|
||||||
consDef->data);
|
consDef->data);
|
||||||
|
|
||||||
ArchiveEntry(fout, indinfo[i].oid, tblinfo[tableInd].primary_key_name,
|
ArchiveEntry(fout, indinfo[i].indexreloid, tblinfo[tableInd].primary_key_name,
|
||||||
"CONSTRAINT", NULL, q->data, "",
|
"CONSTRAINT", NULL, q->data, "",
|
||||||
"", tblinfo[tableInd].usename, NULL, NULL);
|
"", tblinfo[tableInd].usename, NULL, NULL);
|
||||||
|
|
||||||
destroyPQExpBuffer(consDef);
|
destroyPQExpBuffer(consDef);
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't need to do anything else for this system-generated
|
* Don't need to do anything else for this system-generated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user