Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 1AA89B5DC4B for ; Fri, 9 Sep 2011 20:48:33 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 48595-03 for ; Fri, 9 Sep 2011 23:48:26 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id 2406EB5DBF0 for ; Fri, 9 Sep 2011 20:48:26 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p89NmMu12417; Fri, 9 Sep 2011 19:48:22 -0400 (EDT) From: Bruce Momjian Message-Id: <201109092348.p89NmMu12417@momjian.us> Subject: Re: createuser/dropuser username In-Reply-To: <26024.1315507064@sss.pgh.pa.us> To: Tom Lane Date: Fri, 9 Sep 2011 19:48:22 -0400 (EDT) CC: Alvaro Herrera , Susanne Ebrecht , Robert Haas , Grzegorz Szpetkowski , pgsql-docs X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ELM1315612102-7636-0_" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/36 X-Sequence-Number: 6957 --ELM1315612102-7636-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" Tom Lane wrote: > Bruce Momjian writes: > > Alvaro Herrera wrote: > >> Excerpts from Bruce Momjian's message of jue sep 08 11:52:04 -0300 2011: > >>> I started going in that direction and stopped because of this example > >>> in our docs: > >>> vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy > > >> Maybe do it unless there are parens. > > > OK, let me give that a try. > > I've been thinking more about this, and realized that there is one > killer argument in favor of not auto-quoting, at least for arguments > that represent table names: if we quote, there is no way to specify > a schema-qualified name. > > I'm too lazy to troll the archives to verify this, but I am moderately > sure that this point never came up in the original discussions where > we concluded that auto-quoting command-line arguments was a good policy, > because that was before we'd implemented schemas. > > So what I'm thinking right now is that we indeed should not auto-quote > table- or index-name arguments. However, usernames and database names > taken from the command line are still going to be auto-quoted, because > that's how things work in connection requests. Is it going to be > confusing that some things are quoted and some not? > > (Of course, any such change would be non-backwards-compatible and would > have to be suitably documented and release-noted.) > > The backwards-compatible alternative would be to invent additional > schema option arguments so that you could write something like > "reindexdb --schema foo --table bar", but that seems pretty darn ugly. I have implemented what you suggested above, with improved wording. Patch attached. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --ELM1315612102-7636-0_ Content-Transfer-Encoding: 7bit Content-Type: text/x-diff Content-Disposition: inline; filename="/rtmp/quote" diff --git a/doc/src/sgml/ref/createdb.sgml b/doc/src/sgml/ref/createdb.sgml new file mode 100644 index 3e50173..1516f33 *** a/doc/src/sgml/ref/createdb.sgml --- b/doc/src/sgml/ref/createdb.sgml *************** PostgreSQL documentation *** 90,96 **** ! Specifies the default tablespace for the database. --- 90,97 ---- ! Specifies the default tablespace for the database. (This name ! is processed as a double-quoted identifier.) *************** PostgreSQL documentation *** 154,159 **** --- 155,161 ---- Specifies the database user who will own the new database. + (This name is processed as a double-quoted identifier.) *************** PostgreSQL documentation *** 163,169 **** ! Specifies the template database from which to build this database. --- 165,172 ---- ! Specifies the template database from which to build this ! database. (This name is processed as a double-quoted identifier.) diff --git a/doc/src/sgml/ref/createlang.sgml b/doc/src/sgml/ref/createlang.sgml new file mode 100644 index f01f298..d28cfb7 *** a/doc/src/sgml/ref/createlang.sgml --- b/doc/src/sgml/ref/createlang.sgml *************** PostgreSQL documentation *** 70,76 **** langname ! Specifies the name of the procedural language to be installed. --- 70,77 ---- langname ! Specifies the name of the procedural language to be ! installed. (This name is lower-cased.) diff --git a/doc/src/sgml/ref/droplang.sgml b/doc/src/sgml/ref/droplang.sgml new file mode 100644 index 04c3a60..e5d02aa *** a/doc/src/sgml/ref/droplang.sgml --- b/doc/src/sgml/ref/droplang.sgml *************** PostgreSQL documentation *** 73,78 **** --- 73,79 ---- Specifies the name of the procedural language to be removed. + (This name is lower-cased.) diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml new file mode 100644 index 9ae8000..5fd6410 *** a/doc/src/sgml/reference.sgml --- b/doc/src/sgml/reference.sgml *************** *** 198,203 **** --- 198,211 ---- applications is that they can be run on any host, independent of where the database server resides. + + + When specified on the command line, user and databases names have + their case preserved — the presence of spaces or special + characters might require quoting. Table names and other identifiers + do not have their case preserved, except where documented, and + might require quoting. + &clusterdb; diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c new file mode 100644 index f4c317a..3742091 *** a/src/bin/scripts/clusterdb.c --- b/src/bin/scripts/clusterdb.c *************** cluster_one_database(const char *dbname, *** 177,183 **** if (verbose) appendPQExpBuffer(&sql, " VERBOSE"); if (table) ! appendPQExpBuffer(&sql, " %s", fmtId(table)); appendPQExpBuffer(&sql, ";\n"); conn = connectDatabase(dbname, host, port, username, prompt_password, progname); --- 177,183 ---- if (verbose) appendPQExpBuffer(&sql, " VERBOSE"); if (table) ! appendPQExpBuffer(&sql, " %s", table); appendPQExpBuffer(&sql, ";\n"); conn = connectDatabase(dbname, host, port, username, prompt_password, progname); diff --git a/src/bin/scripts/createlang.c b/src/bin/scripts/createlang.c new file mode 100644 index c2153db..2f667e8 *** a/src/bin/scripts/createlang.c --- b/src/bin/scripts/createlang.c *************** main(int argc, char *argv[]) *** 164,169 **** --- 164,170 ---- exit(1); } + /* lower case language name */ for (p = langname; *p; p++) if (*p >= 'A' && *p <= 'Z') *p += ('a' - 'A'); diff --git a/src/bin/scripts/droplang.c b/src/bin/scripts/droplang.c new file mode 100644 index 7fadee0..f136a76 *** a/src/bin/scripts/droplang.c --- b/src/bin/scripts/droplang.c *************** main(int argc, char *argv[]) *** 165,170 **** --- 165,171 ---- exit(1); } + /* lower case language name */ for (p = langname; *p; p++) if (*p >= 'A' && *p <= 'Z') *p += ('a' - 'A'); diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c new file mode 100644 index 53fff01..caeed75 *** a/src/bin/scripts/reindexdb.c --- b/src/bin/scripts/reindexdb.c *************** reindex_one_database(const char *name, c *** 223,231 **** appendPQExpBuffer(&sql, "REINDEX"); if (strcmp(type, "TABLE") == 0) ! appendPQExpBuffer(&sql, " TABLE %s", fmtId(name)); else if (strcmp(type, "INDEX") == 0) ! appendPQExpBuffer(&sql, " INDEX %s", fmtId(name)); else if (strcmp(type, "DATABASE") == 0) appendPQExpBuffer(&sql, " DATABASE %s", fmtId(name)); appendPQExpBuffer(&sql, ";\n"); --- 223,231 ---- appendPQExpBuffer(&sql, "REINDEX"); if (strcmp(type, "TABLE") == 0) ! appendPQExpBuffer(&sql, " TABLE %s", name); else if (strcmp(type, "INDEX") == 0) ! appendPQExpBuffer(&sql, " INDEX %s", name); else if (strcmp(type, "DATABASE") == 0) appendPQExpBuffer(&sql, " DATABASE %s", fmtId(name)); appendPQExpBuffer(&sql, ";\n"); --ELM1315612102-7636-0_--