*** pgsql/src/backend/parser/scansup.c 2008/01/01 19:45:51 1.36 --- pgsql/src/backend/parser/scansup.c 2010/05/08 16:40:14 1.36.2.1 *************** *** 9,15 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.35 2007/01/05 22:19:34 momjian Exp $ * *------------------------------------------------------------------------- */ --- 9,15 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.36 2008/01/01 19:45:51 momjian Exp $ * *------------------------------------------------------------------------- */ *************** truncate_identifier(char *ident, int len *** 176,185 **** { len = pg_mbcliplen(ident, len, NAMEDATALEN - 1); if (warn) ereport(NOTICE, (errcode(ERRCODE_NAME_TOO_LONG), ! errmsg("identifier \"%s\" will be truncated to \"%.*s\"", ! ident, len, ident))); ident[len] = '\0'; } } --- 176,195 ---- { len = pg_mbcliplen(ident, len, NAMEDATALEN - 1); if (warn) + { + /* + * Cannot use %.*s here because some machines interpret %s's + * precision in characters, others in bytes. + */ + 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, buf))); ! } ident[len] = '\0'; } }