From 0dd738148cd43d41f6dd8456eabc073ffaffbd3b Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Thu, 30 Oct 1997 16:48:03 +0000 Subject: Support SQL92 delimited identifiers by checking some attribute names for mixed-case and surrounding with double quotes. --- src/bin/pg_dump/common.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/bin/pg_dump/common.c') 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 #include #include +#include #include /* for MAXHOSTNAMELEN on most */ #ifdef sparc_solaris #include /* 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() */ -- cgit v1.2.1