Fix various infelicities that have snuck into usage of errdetail() and

friends.  Avoid double translation of some messages, ensure other messages
are exposed for translation (and make them follow the style guidelines),
avoid unsafe passing of an unpredictable message text as a format string.
This commit is contained in:
Tom Lane 2008-03-24 19:12:49 +00:00
parent 3da2a4b899
commit 32b58d0220
4 changed files with 25 additions and 26 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.143 2008/01/01 19:45:48 momjian Exp $
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.144 2008/03/24 19:12:49 tgl Exp $
*
* NOTES
* See acl.h.
@ -246,7 +246,7 @@ ExecuteGrantStmt(GrantStmt *stmt)
{
InternalGrant istmt;
ListCell *cell;
char *errormsg;
const char *errormsg;
AclMode all_privileges;
/*
@ -294,31 +294,31 @@ ExecuteGrantStmt(GrantStmt *stmt)
*/
case ACL_OBJECT_RELATION:
all_privileges = ACL_ALL_RIGHTS_RELATION | ACL_ALL_RIGHTS_SEQUENCE;
errormsg = _("invalid privilege type %s for relation");
errormsg = gettext_noop("invalid privilege type %s for relation");
break;
case ACL_OBJECT_SEQUENCE:
all_privileges = ACL_ALL_RIGHTS_SEQUENCE;
errormsg = _("invalid privilege type %s for sequence");
errormsg = gettext_noop("invalid privilege type %s for sequence");
break;
case ACL_OBJECT_DATABASE:
all_privileges = ACL_ALL_RIGHTS_DATABASE;
errormsg = _("invalid privilege type %s for database");
errormsg = gettext_noop("invalid privilege type %s for database");
break;
case ACL_OBJECT_FUNCTION:
all_privileges = ACL_ALL_RIGHTS_FUNCTION;
errormsg = _("invalid privilege type %s for function");
errormsg = gettext_noop("invalid privilege type %s for function");
break;
case ACL_OBJECT_LANGUAGE:
all_privileges = ACL_ALL_RIGHTS_LANGUAGE;
errormsg = _("invalid privilege type %s for language");
errormsg = gettext_noop("invalid privilege type %s for language");
break;
case ACL_OBJECT_NAMESPACE:
all_privileges = ACL_ALL_RIGHTS_NAMESPACE;
errormsg = _("invalid privilege type %s for schema");
errormsg = gettext_noop("invalid privilege type %s for schema");
break;
case ACL_OBJECT_TABLESPACE:
all_privileges = ACL_ALL_RIGHTS_TABLESPACE;
errormsg = _("invalid privilege type %s for tablespace");
errormsg = gettext_noop("invalid privilege type %s for tablespace");
break;
default:
/* keep compiler quiet */
@ -351,8 +351,7 @@ ExecuteGrantStmt(GrantStmt *stmt)
if (priv & ~((AclMode) all_privileges))
ereport(ERROR,
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
errmsg(errormsg,
privilege_to_string(priv))));
errmsg(errormsg, privilege_to_string(priv))));
istmt.privileges |= priv;
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.23 2008/01/23 15:36:38 alvherre Exp $
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.24 2008/03/24 19:12:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -670,7 +670,7 @@ checkSharedDependencies(Oid classId, Oid objectId)
ereport(LOG,
(errmsg("there are objects dependent on %s",
getObjectDescription(&obj)),
errdetail(alldescs.data)));
errdetail("%s", alldescs.data)));
}
pfree(alldescs.data);

View File

@ -38,7 +38,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.104 2008/03/10 02:04:09 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.105 2008/03/24 19:12:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -212,10 +212,10 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
(errmsg("relation \"%s.%s\" contains more than \"max_fsm_pages\" pages with useful free space",
get_namespace_name(RelationGetNamespace(onerel)),
RelationGetRelationName(onerel)),
errhint((vacrelstats->tot_free_pages > vacrelstats->rel_pages * 0.20 ?
/* Only suggest VACUUM FULL if 20% free */
"Consider using VACUUM FULL on this relation or increasing the configuration parameter \"max_fsm_pages\"." :
"Consider increasing the configuration parameter \"max_fsm_pages\"."))));
/* Only suggest VACUUM FULL if > 20% free */
(vacrelstats->tot_free_pages > vacrelstats->rel_pages * 0.20) ?
errhint("Consider using VACUUM FULL on this relation or increasing the configuration parameter \"max_fsm_pages\".") :
errhint("Consider increasing the configuration parameter \"max_fsm_pages\".")));
/* Update statistics in pg_class */
vac_update_relstats(RelationGetRelid(onerel),

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.69 2008/03/01 02:46:49 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.70 2008/03/24 19:12:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1401,25 +1401,25 @@ xml_ereport_by_code(int level, int sqlcode,
switch (code)
{
case XML_ERR_INVALID_CHAR:
det = "Invalid character value";
det = gettext_noop("Invalid character value.");
break;
case XML_ERR_SPACE_REQUIRED:
det = "Space required";
det = gettext_noop("Space required.");
break;
case XML_ERR_STANDALONE_VALUE:
det = "standalone accepts only 'yes' or 'no'";
det = gettext_noop("standalone accepts only 'yes' or 'no'.");
break;
case XML_ERR_VERSION_MISSING:
det = "Malformed declaration expecting version";
det = gettext_noop("Malformed declaration: missing version.");
break;
case XML_ERR_MISSING_ENCODING:
det = "Missing encoding in text declaration";
det = gettext_noop("Missing encoding in text declaration.");
break;
case XML_ERR_XMLDECL_NOT_FINISHED:
det = "Parsing XML declaration: '?>' expected";
det = gettext_noop("Parsing XML declaration: '?>' expected.");
break;
default:
det = "Unrecognized libxml error code: %d";
det = gettext_noop("Unrecognized libxml error code: %d.");
break;
}