mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Error message editing in backend/libpq, backend/postmaster, backend/tcop.
Along the way, fix some logic problems in pgstat_initstats, notably the bogus assumption that malloc returns zeroed memory.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/alter.c,v 1.2 2003/07/20 21:56:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/alter.c,v 1.3 2003/07/22 19:00:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -29,41 +29,12 @@
|
||||
#include "commands/user.h"
|
||||
#include "miscadmin.h"
|
||||
#include "parser/parse_clause.h"
|
||||
#include "tcop/utility.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
static void
|
||||
CheckOwnership(RangeVar *rel, bool noCatalogs)
|
||||
{
|
||||
Oid relOid;
|
||||
HeapTuple tuple;
|
||||
|
||||
relOid = RangeVarGetRelid(rel, false);
|
||||
tuple = SearchSysCache(RELOID,
|
||||
ObjectIdGetDatum(relOid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tuple)) /* should not happen */
|
||||
elog(ERROR, "cache lookup failed for relation %u", relOid);
|
||||
|
||||
if (!pg_class_ownercheck(relOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, rel->relname);
|
||||
|
||||
if (noCatalogs)
|
||||
{
|
||||
if (!allowSystemTableMods &&
|
||||
IsSystemClass((Form_pg_class) GETSTRUCT(tuple)))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("relation \"%s\" is a system catalog",
|
||||
rel->relname)));
|
||||
}
|
||||
|
||||
ReleaseSysCache(tuple);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ExecRenameStmt(RenameStmt *stmt)
|
||||
{
|
||||
@@ -111,7 +82,7 @@ ExecRenameStmt(RenameStmt *stmt)
|
||||
{
|
||||
Oid relid;
|
||||
|
||||
CheckOwnership(stmt->relation, true);
|
||||
CheckRelationOwnership(stmt->relation, true);
|
||||
|
||||
relid = RangeVarGetRelid(stmt->relation, false);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.203 2003/07/21 17:04:58 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.204 2003/07/22 19:00:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1923,7 +1923,7 @@ CopyReadBinaryAttribute(int column_no, FmgrInfo *flinfo, Oid typelem,
|
||||
/* Trouble if it didn't eat the whole buffer */
|
||||
if (attribute_buf.cursor != attribute_buf.len)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("incorrect binary data format in field %d",
|
||||
column_no)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user