diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/parser/scansup.c | 16 | ||||
-rw-r--r-- | src/backend/utils/error/elog.c | 6 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c index b4d8612d6c9..7aa406ff7c0 100644 --- a/src/backend/parser/scansup.c +++ b/src/backend/parser/scansup.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.37 2009/01/01 17:23:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.37.2.1 2010/05/08 16:40:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -176,10 +176,20 @@ truncate_identifier(char *ident, int len, bool warn) { 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, len, ident))); + errmsg("identifier \"%s\" will be truncated to \"%s\"", + ident, buf))); + } ident[len] = '\0'; } } diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index db334824347..7b9a62b00c9 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -42,7 +42,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.216 2009/06/25 23:07:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.216.2.1 2010/05/08 16:40:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1782,7 +1782,7 @@ log_line_prefix(StringInfo buf) int displen; psdisp = get_ps_display(&displen); - appendStringInfo(buf, "%.*s", displen, psdisp); + appendBinaryStringInfo(buf, psdisp, displen); } break; case 'r': @@ -1937,7 +1937,7 @@ write_csvlog(ErrorData *edata) initStringInfo(&msgbuf); psdisp = get_ps_display(&displen); - appendStringInfo(&msgbuf, "%.*s", displen, psdisp); + appendBinaryStringInfo(&msgbuf, psdisp, displen); appendCSVLiteral(&buf, msgbuf.data); pfree(msgbuf.data); |