* support routines for the lex/flex scanner, used by both the normal
* backend as well as the bootstrap backend
*
- * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.35 2007/01/05 22:19:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.42 2010/07/06 19:18:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
len = pg_mbcliplen(ident, len, NAMEDATALEN - 1);
if (warn)
+ {
+ /*
+ * We avoid using %.*s here because it can misbehave if the data
+ * is not valid in what libc thinks is the prevailing encoding.
+ */
+ char buf[NAMEDATALEN];
+
+ memcpy(buf, ident, len);
+ buf[len] = '\0';
ereport(NOTICE,
(errcode(ERRCODE_NAME_TOO_LONG),
- errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
- ident, len, ident)));
+ errmsg("identifier \"%s\" will be truncated to \"%s\"",
+ ident, buf)));
+ }
ident[len] = '\0';
}
}
scanner_isspace(char ch)
{
/* This must match scan.l's list of {space} characters */
- /* and plpgsql's scan.l as well */
if (ch == ' ' ||
ch == '\t' ||
ch == '\n' ||