diff options
| author | Tom Lane | 2007-08-26 23:59:50 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-08-26 23:59:50 +0000 |
| commit | 38c75ecf8345bd338112ad2a3221dfc47929fb7e (patch) | |
| tree | 0f276f68263c40607ba2eb14d8612e8c6066cea4 /contrib/pgstattuple/pgstattuple.c | |
| parent | 0effa088f5a5b55ab5b963159d18cc26dc7ccc4e (diff) | |
Restrict pgstattuple functions to superusers. (This might be too strict,
but no permissions check at all is certainly no good.) Clean up usage
of some deprecated APIs.
Diffstat (limited to 'contrib/pgstattuple/pgstattuple.c')
| -rw-r--r-- | contrib/pgstattuple/pgstattuple.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index 64e7f982fba..9072a37aa91 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.27 2007/05/03 16:45:58 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.28 2007/08/26 23:59:50 tgl Exp $ * * Copyright (c) 2001,2002 Tatsuo Ishii * @@ -24,14 +24,13 @@ #include "postgres.h" -#include "fmgr.h" -#include "funcapi.h" #include "access/gist_private.h" #include "access/hash.h" #include "access/heapam.h" #include "access/nbtree.h" -#include "access/transam.h" #include "catalog/namespace.h" +#include "funcapi.h" +#include "miscadmin.h" #include "utils/builtins.h" @@ -99,9 +98,6 @@ build_pgstattuple_type(pgstattuple_type * stat, FunctionCallInfo fcinfo) if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) elog(ERROR, "return type must be a row type"); - /* make sure we have a persistent copy of the tupdesc */ - tupdesc = CreateTupleDescCopy(tupdesc); - /* * Generate attribute metadata needed later to produce tuples from raw C * strings @@ -163,6 +159,11 @@ pgstattuple(PG_FUNCTION_ARGS) RangeVar *relrv; Relation rel; + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errmsg("must be superuser to use pgstattuple functions")))); + /* open relation */ relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname)); rel = relation_openrv(relrv, AccessShareLock); @@ -176,6 +177,11 @@ pgstattuplebyid(PG_FUNCTION_ARGS) Oid relid = PG_GETARG_OID(0); Relation rel; + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errmsg("must be superuser to use pgstattuple functions")))); + /* open relation */ rel = relation_open(relid, AccessShareLock); |
