Neil Conway wrote:
> On Mon, 2007-01-15 at 17:07 +0000, Dave Page wrote:
>> You're thinking the user might expect it dump all of that database? Not
>> sure I agree with that, but I'm not wedded to the syntax. Any other
>> opinions?
> 
> I agree with Peter: specifying the database name as implemented seems
> like it would be prone to confusion.

OK, updated patch attached. This has

-E <dbname> or --default-database=<dbname>

Regards, Dave.
diff -c -r pgsql.orig/doc/src/sgml/ref/pg_dumpall.sgml 
pgsql/doc/src/sgml/ref/pg_dumpall.sgml
*** pgsql.orig/doc/src/sgml/ref/pg_dumpall.sgml Mon Jan 15 13:26:07 2007
--- pgsql/doc/src/sgml/ref/pg_dumpall.sgml      Mon Jan 15 21:06:23 2007
***************
*** 312,318 ****
--- 312,332 ----
  
     <variablelist>
       <varlistentry>
+       <term>-E <replaceable>dbname</replaceable></term>
+       <term>--default-database=<replaceable>dbname</replaceable></term>
+       <listitem>
+        <para>
+          Specifies the name of the database to connect to to dump global
+          objects and discover what other databases should be dumped. If
+          not specified, the <quote>postgres</quote> database will be used,
+          and if that does not exist, <quote>template1</quote> will be used.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
        <term>-h <replaceable>host</replaceable></term>
+       <term>--host=<replaceable>host</replaceable></term>
        <listitem>
         <para>
          Specifies the host name of the machine on which the database
***************
*** 326,331 ****
--- 340,346 ----
  
       <varlistentry>
        <term>-p <replaceable>port</replaceable></term>
+       <term>--port=<replaceable>port</replaceable></term>
        <listitem>
         <para>
          Specifies the TCP port or local Unix domain socket file
***************
*** 338,343 ****
--- 353,359 ----
  
       <varlistentry>
        <term>-U <replaceable>username</replaceable></term>
+       <term>--username=<replaceable>username</replaceable></term>
        <listitem>
         <para>
          Connect as the given user.
***************
*** 347,352 ****
--- 363,369 ----
  
       <varlistentry>
        <term>-W</term>
+           <term>--password</term>
        <listitem>
         <para>
          Force a password prompt.  This should happen automatically if
diff -c -r pgsql.orig/src/bin/pg_dump/pg_dumpall.c 
pgsql/src/bin/pg_dump/pg_dumpall.c
*** pgsql.orig/src/bin/pg_dump/pg_dumpall.c     Mon Jan 15 13:26:07 2007
--- pgsql/src/bin/pg_dump/pg_dumpall.c  Mon Jan 15 20:58:25 2007
***************
*** 75,80 ****
--- 75,81 ----
        char       *pghost = NULL;
        char       *pgport = NULL;
        char       *pguser = NULL;
+       char       *pgdb = NULL;
        bool            force_password = false;
        bool            data_only = false;
        bool            globals_only = false;
***************
*** 93,98 ****
--- 94,100 ----
                {"inserts", no_argument, NULL, 'd'},
                {"attribute-inserts", no_argument, NULL, 'D'},
                {"column-inserts", no_argument, NULL, 'D'},
+               {"default-database", required_argument, NULL, 'E'},
                {"globals-only", no_argument, NULL, 'g'},
                {"host", required_argument, NULL, 'h'},
                {"ignore-version", no_argument, NULL, 'i'},
***************
*** 165,171 ****
  
        pgdumpopts = createPQExpBuffer();
  
!       while ((c = getopt_long(argc, argv, "acdDgh:ioOp:rsS:tU:vWxX:", 
long_options, &optindex)) != -1)
        {
                switch (c)
                {
--- 167,173 ----
  
        pgdumpopts = createPQExpBuffer();
  
!       while ((c = getopt_long(argc, argv, "acdDE:gh:ioOp:rsS:tU:vWxX:", 
long_options, &optindex)) != -1)
        {
                switch (c)
                {
***************
*** 182,187 ****
--- 184,193 ----
                        case 'D':
                                appendPQExpBuffer(pgdumpopts, " -%c", c);
                                break;
+                               
+                       case 'E':
+                               pgdb = optarg;
+                               break;
  
                        case 'g':
                                globals_only = true;
***************
*** 337,351 ****
        }
  
        /*
!        * First try to connect to database "postgres", and failing that
         * "template1".  "postgres" is the preferred choice for 8.1 and later
         * servers, but it usually will not exist on older ones.
         */
!       conn = connectDatabase("postgres", pghost, pgport, pguser,
                                                   force_password, false);
!       if (!conn)
!               conn = connectDatabase("template1", pghost, pgport, pguser,
!                                                          force_password, 
true);
  
        /*
         * Get the active encoding and the standard_conforming_strings setting, 
so
--- 343,382 ----
        }
  
        /*
!        * If there was a database specified on the command line, use that,
!        * otherwise try to connect to database "postgres", and failing that
         * "template1".  "postgres" is the preferred choice for 8.1 and later
         * servers, but it usually will not exist on older ones.
         */
!       if (pgdb)
!       {
!               conn = connectDatabase(pgdb, pghost, pgport, pguser,
!                                                               force_password, 
false);
!                                                               
!               if (!conn)
!               {
!                       fprintf(stderr, _("%s: could not connect to database 
\"%s\"\n"),
!                                       progname, pgdb);
!                       exit(1);
!               }
!       }
!       else
!       {
!               conn = connectDatabase("postgres", pghost, pgport, pguser,
                                                   force_password, false);
!               if (!conn)
!                       conn = connectDatabase("template1", pghost, pgport, 
pguser,
!                                                                       
force_password, true);
!                               
!               if (!conn)
!               {
!                       fprintf(stderr, _("%s: could not connect to databases 
\"postgres\" or \"template1\". Please specify an alternative database\n"),
!                                       progname);
!                       fprintf(stderr, _("Try \"%s --help\" for more 
information.\n"),
!                                       progname);
!                       exit(1);
!               }
!       }
  
        /*
         * Get the active encoding and the standard_conforming_strings setting, 
so
***************
*** 443,448 ****
--- 474,481 ----
                         "                           OWNER TO commands\n"));
  
        printf(_("\nConnection options:\n"));
+       printf(_("  -E,--default-database=dbname\n"
+                        "                                                      
 specify an alternate default database\n"));
        printf(_("  -h, --host=HOSTNAME      database server host or socket 
directory\n"));
        printf(_("  -p, --port=PORT          database server port number\n"));
        printf(_("  -U, --username=NAME      connect as specified database 
user\n"));
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to