If PostgreSQL failed to compile on your computer or you found a bug that
is likely to be specific to one platform then please fill out this form
and e-mail it to [EMAIL PROTECTED]
To report any other bug, fill out the form below and e-mail it to
[EMAIL PROTECTED]
If you not only found the problem but solved it and generated a patch
then e-mail it to [EMAIL PROTECTED] instead. Please use the
command "diff -c" to generate the patch.
You may also enter a bug report at http://www.postgresql.org/ instead of
e-mail-ing this form.
============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================
Your name : Russell Smith
Your email address : As From address
System Configuration
---------------------
Architecture (example: Intel Pentium) : AMD 2000XP
Operating System (example: Linux 2.4.18) : Gentoo Linux 2.4.20-r9
PostgreSQL version (example: PostgreSQL-8.0): PostgreSQL-8.0-beta4
Compiler used (example: gcc 2.95.2) : gcc (GCC) 3.3.3 20040412 (Gentoo
Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)
Please enter a FULL description of your problem:
------------------------------------------------
pg_dump -i -h '10.0.0.5' -p '5432' -s 'test' -t '"Test"'
pg_dump does not fold case, and quote table and schema names correctly.
the above line will dump the table named "Test"
pg_dump -i -h '10.0.0.5' -p '5432' -s 'test' -t 'Test'
the above will dump the table named Test
I believe the correct output from 1 should be to dump the table named Test.
and correct output from 2 should dump the table named test
Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------
Reproduction from commands in description.
If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------
Attempted patches attached. Most code taken from libpq and modified for
pg_dump.
Index: pg_dump.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.392
diff -c -r1.392 pg_dump.c
*** pg_dump.c 6 Nov 2004 19:36:02 -0000 1.392
--- pg_dump.c 13 Nov 2004 03:29:17 -0000
***************
*** 112,117 ****
--- 112,118 ----
static int disable_dollar_quoting = 0;
+ static char* caseCastedQuotedName(const char *ident);
static void help(const char *progname);
static NamespaceInfo *findNamespace(Oid nsoid, Oid objoid);
static void dumpTableData(Archive *fout, TableDataInfo *tdinfo);
***************
*** 326,332 ****
break;
case 'n': /* Dump data for this schema only */
! selectSchemaName = strdup(optarg);
break;
case 'o': /* Dump oids */
--- 327,333 ----
break;
case 'n': /* Dump data for this schema only */
! selectSchemaName = caseCastedQuotedName(optarg);
break;
case 'o': /* Dump oids */
***************
*** 355,361 ****
break;
case 't': /* Dump data for this table only */
! selectTableName = strdup(optarg);
break;
case 'u':
--- 356,362 ----
break;
case 't': /* Dump data for this table only */
! selectTableName = caseCastedQuotedName(optarg);
break;
case 'u':
***************
*** 655,660 ****
--- 656,731 ----
exit(0);
}
+ /*
+ * caseCastedQuotedName: fold the case of a column unless "'d
+ *
+ * The column name is parsed as if it were in a SQL statement, including
+ * case-folding and double-quote processing. But note a possible gotcha:
+ * downcasing in the frontend might follow different locale rules than
+ * downcasing in the backend...
+ *
+ * Returns NULL on failure.
+ */
+ static char*
+ caseCastedQuotedName(const char *ident)
+ {
+ char *ident_case;
+ bool in_quotes;
+ char *iptr;
+ char *optr;
+
+ /*
+ * Note: it is correct to reject a zero-length input string; the
+ * proper input to match a zero-length field name would be "".
+ */
+ if (ident == NULL ||
+ ident[0] == '\0')
+ return NULL;
+
+ /*
+ * Note: this code will not reject partially quoted strings, eg
+ * foo"BAR"foo will become fooBARfoo when it probably ought to be an
+ * error condition.
+ */
+ ident_case = strdup(ident);
+ if (ident_case == NULL)
+ return NULL; /* grotty */
+
+ in_quotes = false;
+ optr = ident_case;
+ for (iptr = ident_case; *iptr; iptr++)
+ {
+ char c = *iptr;
+
+ if (in_quotes)
+ {
+ if (c == '"')
+ {
+ if (iptr[1] == '"')
+ {
+ /* doubled quotes become a single quote */
+ *optr++ = '"';
+ iptr++;
+ }
+ else
+ in_quotes = false;
+ }
+ else
+ *optr++ = c;
+ }
+ else if (c == '"')
+ in_quotes = true;
+ else
+ {
+ c = pg_tolower((unsigned char) c);
+ *optr++ = c;
+ }
+ }
+ *optr = '\0';
+
+ return ident_case;
+ }
+
static void
help(const char *progname)
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster