mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Make VACUUM handle schema-qualified relation names properly.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* Portions Copyright (c) 2000-2001, PostgreSQL Global Development Group
|
||||
* Copyright 1999 Jan Wieck
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.35 2002/04/01 22:36:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.36 2002/04/02 01:03:07 tgl Exp $
|
||||
*
|
||||
* ----------
|
||||
*/
|
||||
@@ -33,11 +33,10 @@
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "commands/trigger.h"
|
||||
#include "executor/spi_priv.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "miscadmin.h"
|
||||
|
||||
|
||||
@@ -2954,18 +2953,7 @@ quoteOneName(char *buffer, const char *name)
|
||||
static void
|
||||
quoteRelationName(char *buffer, Relation rel)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
char *nsname;
|
||||
|
||||
tuple = SearchSysCache(NAMESPACEOID,
|
||||
ObjectIdGetDatum(RelationGetNamespace(rel)),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "Failed to lookup namespace %u of relation %s",
|
||||
RelationGetNamespace(rel), RelationGetRelationName(rel));
|
||||
nsname = NameStr(((Form_pg_namespace) GETSTRUCT(tuple))->nspname);
|
||||
quoteOneName(buffer, nsname);
|
||||
ReleaseSysCache(tuple);
|
||||
quoteOneName(buffer, get_namespace_name(RelationGetNamespace(rel)));
|
||||
buffer += strlen(buffer);
|
||||
*buffer++ = '.';
|
||||
quoteOneName(buffer, RelationGetRelationName(rel));
|
||||
|
||||
32
src/backend/utils/cache/lsyscache.c
vendored
32
src/backend/utils/cache/lsyscache.c
vendored
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.67 2002/03/29 19:06:15 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.68 2002/04/02 01:03:07 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "access/tupmacs.h"
|
||||
#include "catalog/pg_amop.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
@@ -1279,6 +1280,35 @@ free_attstatsslot(Oid atttype,
|
||||
pfree(numbers);
|
||||
}
|
||||
|
||||
/* ---------- PG_NAMESPACE CACHE ---------- */
|
||||
|
||||
/*
|
||||
* get_namespace_name
|
||||
* Returns the name of a given namespace
|
||||
*
|
||||
* Returns a palloc'd copy of the string, or NULL if no such namespace.
|
||||
*/
|
||||
char *
|
||||
get_namespace_name(Oid nspid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache(NAMESPACEOID,
|
||||
ObjectIdGetDatum(nspid),
|
||||
0, 0, 0);
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_namespace nsptup = (Form_pg_namespace) GETSTRUCT(tp);
|
||||
char *result;
|
||||
|
||||
result = pstrdup(NameStr(nsptup->nspname));
|
||||
ReleaseSysCache(tp);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ---------- PG_SHADOW CACHE ---------- */
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user