Index: doc/src/sgml/ref/pg_dump.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v retrieving revision 1.80 diff -c -r1.80 pg_dump.sgml *** doc/src/sgml/ref/pg_dump.sgml 25 Jul 2005 22:12:31 -0000 1.80 --- doc/src/sgml/ref/pg_dump.sgml 20 Sep 2005 15:49:33 -0000 *************** *** 388,406 **** Dump data for table ! only. It is possible for there to be ! multiple tables with the same name in different schemas; if that ! is the case, all matching tables will be dumped. Specify both ! ! In this mode, pg_dump makes no ! attempt to dump any other database objects that the selected table ! may depend upon. Therefore, there is no guarantee ! that the results of a single-table dump can be successfully ! restored by themselves into a clean database. --- 388,408 ---- Dump data for table ! only. This option can be repeated to get more than one table. ! It is possible for there to be multiple tables with the same name in ! different schemas. If that is the case, pg_dump will dump all ! matching tables. Specify both ! In this mode, pg_dump makes no ! attempt to dump any other database objects that the selected ! tables may depend upon. Therefore, there is no guarantee that ! the results of a selected-table dump can be successfully ! restored by themselves into a clean database. Index: src/bin/pg_dump/pg_dump.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.420 diff -c -r1.420 pg_dump.c *** src/bin/pg_dump/pg_dump.c 5 Sep 2005 23:50:48 -0000 1.420 --- src/bin/pg_dump/pg_dump.c 20 Sep 2005 15:49:40 -0000 *************** *** 93,100 **** /* obsolete as of 7.3: */ static Oid g_last_builtin_oid; /* value of the last builtin oid */ ! static char *selectTableName = NULL; /* name of a single table to dump */ ! static char *selectSchemaName = NULL; /* name of a single schema to dump */ char g_opaque_type[10]; /* name for the opaque type */ --- 93,102 ---- /* obsolete as of 7.3: */ static Oid g_last_builtin_oid; /* value of the last builtin oid */ ! static char **selectTableNames = NULL; /* name(s) of specified table(s) to dump */ ! int tab_max = 0, tab_idx = 0; ! static char *selectSchemaName = NULL; /* name(s) of specified schema(ta) to dump */ ! int schem_max = 0, schem_idx = 0; char g_opaque_type[10]; /* name for the opaque type */ *************** *** 362,369 **** outputSuperuser = strdup(optarg); break; ! case 't': /* Dump data for this table only */ ! selectTableName = strdup(optarg); break; case 'u': --- 364,376 ---- outputSuperuser = strdup(optarg); break; ! case 't': /* Dump data for th(is|ese) table(s) only */ ! if (tab_idx == tab_max) { ! tab_max += 32; ! if ( (selectTableNames = realloc(selectTableNames, tab_max*sizeof(char *))) == 0) ! exit(-1); ! } ! selectTableNames[tab_idx++] = strdup(optarg); break; case 'u': *************** *** 450,456 **** exit(1); } ! if (selectTableName != NULL || selectSchemaName != NULL) outputBlobs = false; if (dumpInserts == true && oids == true) --- 457,463 ---- exit(1); } ! if (selectTableNames != NULL || selectSchemaName != NULL) outputBlobs = false; if (dumpInserts == true && oids == true) *************** *** 733,739 **** * namespaces. If a specific namespace is being dumped, dump just * that namespace. Otherwise, dump all non-system namespaces. */ ! if (selectTableName != NULL) nsinfo->dump = false; else if (selectSchemaName != NULL) { --- 740,746 ---- * namespaces. If a specific namespace is being dumped, dump just * that namespace. Otherwise, dump all non-system namespaces. */ ! if (selectTableNames != NULL) nsinfo->dump = false; else if (selectSchemaName != NULL) { *************** *** 764,777 **** tbinfo->dump = false; if (tbinfo->dobj.namespace->dump) tbinfo->dump = true; ! else if (selectTableName != NULL && ! strcmp(tbinfo->dobj.name, selectTableName) == 0) { ! /* If both -s and -t specified, must match both to dump */ ! if (selectSchemaName == NULL) ! tbinfo->dump = true; ! else if (strcmp(tbinfo->dobj.namespace->dobj.name, selectSchemaName) == 0) ! tbinfo->dump = true; } } --- 771,790 ---- tbinfo->dump = false; if (tbinfo->dobj.namespace->dump) tbinfo->dump = true; ! else if (selectTableNames != NULL) { ! int i = 0; ! while(i < tab_idx) { ! if (strcmp(tbinfo->dobj.name, selectTableNames[i]) == 0) ! { ! /* If both -s and -t specified, must match both to dump */ ! if (selectSchemaName == NULL) ! tbinfo->dump = true; ! else if (strcmp(tbinfo->dobj.namespace->dobj.name, selectSchemaName) == 0) ! tbinfo->dump = true; ! } ! i++; ! } } } *************** *** 2414,2420 **** { PGresult *res; int ntups; ! int i; PQExpBuffer query = createPQExpBuffer(); PQExpBuffer delqry = createPQExpBuffer(); PQExpBuffer lockquery = createPQExpBuffer(); --- 2427,2433 ---- { PGresult *res; int ntups; ! int i,j; PQExpBuffer query = createPQExpBuffer(); PQExpBuffer delqry = createPQExpBuffer(); PQExpBuffer lockquery = createPQExpBuffer(); *************** *** 2693,2709 **** * simplistic since we don't fully check the combination of -n and -t * switches.) */ ! if (selectTableName) { ! for (i = 0; i < ntups; i++) ! if (strcmp(tblinfo[i].dobj.name, selectTableName) == 0) ! break; ! /* Didn't find a match */ ! if (i == ntups) { write_msg(NULL, "specified table \"%s\" does not exist\n", ! selectTableName); exit_nicely(); } } --- 2706,2724 ---- * simplistic since we don't fully check the combination of -n and -t * switches.) */ ! if (selectTableNames != NULL) { ! for (i = 0; i < ntups; i++) { ! for (j = 0; j < tab_idx; j++) { ! if (strcmp(tblinfo[i].dobj.name, selectTableNames[j]) == 0) ! goto check_match; ! } ! } /* Didn't find a match */ ! check_match: if (i == ntups) { write_msg(NULL, "specified table \"%s\" does not exist\n", ! selectTableNames[j]); exit_nicely(); } } *************** *** 5089,5095 **** static bool shouldDumpProcLangs(void) { ! if (selectTableName != NULL || selectSchemaName != NULL) return false; /* And they're schema not data */ if (dataOnly) --- 5104,5110 ---- static bool shouldDumpProcLangs(void) { ! if (selectTableNames != NULL || selectSchemaName != NULL) return false; /* And they're schema not data */ if (dataOnly)