summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/common.c
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>1998-10-02 16:43:41 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>1998-10-02 16:43:41 +0000
commit9601964773b78c00f7e18b8dd9d7418e7e0290ad (patch)
treecc8cf1ee0c1e0acd3123f2cf3f0eb21df16acc71 /src/bin/pg_dump/common.c
parentf93b6974f91491a895e875d37b474de48d4b9d8e (diff)
Surround all identifiers with double quotes.
Formerly did so only for those which clearly required it, but that would still miss things like reserved key words which also require it. Implement the "-n" switch to revert the double quote behavior to put DQs only where there is more than lower-case, digits, and underscores.
Diffstat (limited to 'src/bin/pg_dump/common.c')
-rw-r--r--src/bin/pg_dump/common.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index c9a806f10a6..7974a9db6dd 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.25 1998/09/20 03:18:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.26 1998/10/02 16:43:38 thomas Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
@@ -486,6 +486,9 @@ findFuncByName(FuncInfo *finfo, int numFuncs, const char *name)
*
* checks input string for non-lowercase characters
* returns pointer to input string or string surrounded by double quotes
+ *
+ * Note that the returned string should be used immediately since it
+ * uses a static buffer to hold the string. Non-reentrant but fast.
*/
const char *
fmtId(const char *rawid)
@@ -493,11 +496,12 @@ fmtId(const char *rawid)
const char *cp;
static char id[MAXQUERYLEN];
- for (cp = rawid; *cp != '\0'; cp++)
- if (!(islower(*cp) || isdigit(*cp) || (*cp == '_')))
- break;
+ if (! g_force_quotes)
+ for (cp = rawid; *cp != '\0'; cp++)
+ if (!(islower(*cp) || isdigit(*cp) || (*cp == '_')))
+ break;
- if (*cp != '\0')
+ if (g_force_quotes || (*cp != '\0'))
{
strcpy(id, "\"");
strcat(id, rawid);