diff options
author | Thomas G. Lockhart <lockhart@fourpalms.org> | 1997-10-30 16:48:03 +0000 |
---|---|---|
committer | Thomas G. Lockhart <lockhart@fourpalms.org> | 1997-10-30 16:48:03 +0000 |
commit | 0dd738148cd43d41f6dd8456eabc073ffaffbd3b (patch) | |
tree | 88dd5b3b590f2d301a70a107df7fdf610201a468 /src/bin/pg_dump/common.c | |
parent | cc1b420cfdd5066bc2c80c01971f567950c894e4 (diff) | |
download | postgresql-0dd738148cd43d41f6dd8456eabc073ffaffbd3b.tar.gz |
Support SQL92 delimited identifiers by checking some attribute names
for mixed-case and surrounding with double quotes.
Diffstat (limited to 'src/bin/pg_dump/common.c')
-rw-r--r-- | src/bin/pg_dump/common.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 8e1a7709cc..5f4dc96a8e 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.17 1997/10/02 13:57:03 vadim Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.18 1997/10/30 16:47:57 thomas Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <ctype.h> #include <sys/param.h> /* for MAXHOSTNAMELEN on most */ #ifdef sparc_solaris #include <netdb.h> /* for MAXHOSTNAMELEN on some */ @@ -478,3 +479,29 @@ isArchiveName(const char *relname) { return (strlen(relname) > 1 && relname[1] == ','); } + +/* + * fmtId + * + * checks input string for non-lowercase characters + * returns pointer to input string or string surrounded by double quotes + */ +const char * +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 (*cp != '\0') { + strcpy(id, "\""); + strcat(id, rawid); + strcat(id, "\""); + cp = id; + } else { + cp = rawid; + } + return(cp); +} /* fmtId() */ |