Commit c42b959f authored by Jan Wieck's avatar Jan Wieck

Partial support for mixed case in PL/pgSQL.

Left are identifiers that contain non-alnum/_ chars.
So e.g. whitespaces in identifiers are still not
supported.

Jan
parent b946244c
......@@ -4,7 +4,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.1 1998/08/24 19:14:47 momjian Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.2 1999/01/28 11:48:30 wieck Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -344,7 +344,7 @@ decl_aliasitem : T_WORD
char *name;
plpgsql_ns_setlocal(false);
name = plpgsql_tolower(pstrdup(yytext));
name = plpgsql_tolower(yytext);
if (name[0] != '$') {
elog(ERROR, "can only alias positional parameters");
}
......@@ -374,7 +374,7 @@ decl_varname : T_WORD
decl_renname : T_WORD
{
$$ = plpgsql_tolower(pstrdup(yytext));
$$ = plpgsql_tolower(yytext);
}
;
......
......@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.4 1998/11/27 20:07:22 vadim Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.5 1999/01/28 11:48:31 wieck Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -537,7 +537,7 @@ plpgsql_parse_word(char *word)
* We do our lookups case insensitive
* ----------
*/
cp = plpgsql_tolower(pstrdup(word));
cp = plpgsql_tolower(word);
/* ----------
* Special handling when compiling triggers
......@@ -657,7 +657,7 @@ plpgsql_parse_dblword(char *string)
* Convert to lower case and separate the words
* ----------
*/
word1 = plpgsql_tolower(pstrdup(string));
word1 = plpgsql_tolower(string);
word2 = strchr(word1, '.');
*word2++ = '\0';
......@@ -783,7 +783,7 @@ plpgsql_parse_tripword(char *string)
* Convert to lower case and separate the words
* ----------
*/
word1 = plpgsql_tolower(pstrdup(string));
word1 = plpgsql_tolower(string);
word2 = strchr(word1, '.');
*word2++ = '\0';
word3 = strchr(word2, '.');
......@@ -893,7 +893,7 @@ plpgsql_parse_wordtype(char *word)
* We do our lookups case insensitive
* ----------
*/
cp = plpgsql_tolower(pstrdup(word));
cp = plpgsql_tolower(word);
*(strchr(cp, '%')) = '\0';
/* ----------
......@@ -988,7 +988,7 @@ plpgsql_parse_dblwordtype(char *string)
* Convert to lower case and separate the words
* ----------
*/
word1 = plpgsql_tolower(pstrdup(string));
word1 = plpgsql_tolower(string);
word2 = strchr(word1, '.');
*word2++ = '\0';
*(strchr(word2, '%')) = '\0';
......@@ -1123,7 +1123,7 @@ plpgsql_parse_wordrowtype(char *string)
* Get the word in lower case and fetch the pg_class tuple.
* ----------
*/
word1 = plpgsql_tolower(pstrdup(string));
word1 = plpgsql_tolower(string);
cp = strchr(word1, '%');
*cp = '\0';
......
......@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.2 1998/09/01 04:40:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.3 1999/01/28 11:48:31 wieck Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -189,6 +189,7 @@ plpgsql_ns_additem(int itemtype, int itemno, char *name)
if (name == NULL)
name = "";
name = plpgsql_tolower(name);
if (ns->items_used == ns->items_alloc)
{
......@@ -320,22 +321,48 @@ plpgsql_ns_rename(char *oldname, char *newname)
/* ----------
* plpgsql_tolower Translate a string in place to
* lower case
* plpgsql_tolower Translate a string to lower case
* but honor "" escaping.
* ----------
*/
char *
plpgsql_tolower(char *s)
{
char *cp;
char *ret;
char *cp;
for (cp = s; *cp; cp++)
ret = palloc(strlen(s) + 1);
cp = ret;
while (*s)
{
if (isupper(*cp))
*cp = tolower(*cp);
if (*s == '"')
{
s++;
while (*s)
{
if (*s == '"')
break;
*cp++ = *s++;
}
if (*s != '"')
{
plpgsql_comperrinfo();
elog(ERROR, "unterminated \"");
}
s++;
}
else
{
if (isupper(*s))
*cp++ = tolower(*s++);
else
*cp++ = *s++;
}
}
*cp = '\0';
return s;
return ret;
}
......
......@@ -4,7 +4,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.1 1998/08/24 19:14:49 momjian Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.2 1999/01/28 11:48:31 wieck Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -46,8 +46,8 @@ static void plpgsql_input(char *buf, int *result, int max);
#define YY_INPUT(buf,res,max) plpgsql_input(buf, &res, max)
%}
WS [[:alpha:]_]
WC [[:alnum:]_]
WS [[:alpha:]_"]
WC [[:alnum:]_"]
%x IN_STRING IN_COMMENT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment