2222 *
2323 *
2424 * IDENTIFICATION
25- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.242 2002/02/27 20:59:05 tgl Exp $
25+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.243 2002/03/06 20:48:42 momjian Exp $
2626 *
2727 *-------------------------------------------------------------------------
2828 */
@@ -4259,7 +4259,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
42594259
42604260
42614261
4262- /*put the CONSTRAINTS inside the table def */
4262+ /*Put the CONSTRAINTS inside the table def */
42634263for (k = 0 ;k < tblinfo [i ].ncheck ;k ++ )
42644264{
42654265if (actual_atts + k > 0 )
@@ -4269,36 +4269,15 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
42694269tblinfo [i ].check_expr [k ]);
42704270}
42714271
4272- /* Primary Key */
4273- if (tblinfo [i ].pkIndexOid != NULL )
4274- {
4275- PQExpBuffer consDef ;
4276-
4277- /* Find the corresponding index */
4278- for (k = 0 ;k < numIndexes ;k ++ )
4279- {
4280- if (strcmp (indinfo [k ].indexreloid ,
4281- tblinfo [i ].pkIndexOid )== 0 )
4282- break ;
4283- }
4284-
4285- if (k >=numIndexes )
4286- {
4287- write_msg (NULL ,"dumpTables(): failed sanity check, could not find index (%s) for primary key constraint\n" ,
4288- tblinfo [i ].pkIndexOid );
4289- exit_nicely ();
4290- }
4291-
4292- consDef = getPKconstraint (& tblinfo [i ],& indinfo [k ]);
4293-
4294- if ((actual_atts + tblinfo [i ].ncheck )> 0 )
4295- appendPQExpBuffer (q ,",\n\t" );
4296-
4297- appendPQExpBuffer (q ,"%s" ,consDef -> data );
4298-
4299- destroyPQExpBuffer (consDef );
4300- }
4301-
4272+ /*
4273+ * Primary Key: In versions of PostgreSQL prior to 7.2, we
4274+ * needed to include the primary key in the table definition.
4275+ * However, this is not ideal because it creates an index
4276+ * on the table, which makes COPY slower. As of release 7.2,
4277+ * we can add primary keys to a table after is has been created,
4278+ * using ALTER TABLE ; see dumpIndexes() for more information.
4279+ * Therefore, we ignore primary keys in this function.
4280+ */
43024281
43034282appendPQExpBuffer (q ,"\n)" );
43044283
@@ -4454,27 +4433,19 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
44544433/* Handle PK indexes */
44554434if (strcmp (indinfo [i ].indisprimary ,"t" )== 0 )
44564435{
4457- #if 0
4458-
4459- /*
4460- * PK: Enable this code when ALTER TABLE supports PK
4461- * constraints.
4462- */
4463-
44644436PQExpBuffer consDef = getPKconstraint (& tblinfo [tableInd ],& indinfo [i ]);
44654437
44664438resetPQExpBuffer (q );
44674439
44684440appendPQExpBuffer (q ,"Alter Table %s Add %s;" ,
4469- fmtId (tblinfo [tableInd ].relname ,force_quotes ),
4441+ fmtId (tblinfo [tableInd ].relname ,force_quotes ),
44704442consDef -> data );
44714443
4472- ArchiveEntry (fout ,indinfo [i ].oid ,tblinfo [tableInd ].primary_key_name ,
4444+ ArchiveEntry (fout ,indinfo [i ].indexreloid ,tblinfo [tableInd ].primary_key_name ,
44734445"CONSTRAINT" ,NULL ,q -> data ,"" ,
44744446"" ,tblinfo [tableInd ].usename ,NULL ,NULL );
44754447
44764448destroyPQExpBuffer (consDef );
4477- #endif
44784449
44794450/*
44804451 * Don't need to do anything else for this system-generated