aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/rename.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/rename.c')
-rw-r--r--src/backend/commands/rename.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c
index 2977d9e79d0..41f2cccb50e 100644
--- a/src/backend/commands/rename.c
+++ b/src/backend/commands/rename.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.19 1998/12/15 12:45:58 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.20 1999/02/02 03:44:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,6 +18,7 @@
#include <utils/builtins.h>
#include <catalog/catname.h>
#include <utils/syscache.h>
+#include <catalog/heap.h>
#include <catalog/indexing.h>
#include <catalog/catalog.h>
#include <commands/copy.h>
@@ -106,15 +107,9 @@ renameatt(char *relname,
List *child,
*children;
- reltup = SearchSysCacheTuple(RELNAME,
- PointerGetDatum(relname),
- 0, 0, 0);
-
- if (!HeapTupleIsValid(reltup))
+ if ((myrelid = RelnameFindRelid(relname)) == InvalidOid)
elog(ERROR, "renameatt: unknown relation: \"%s\"", relname);
- myrelid = reltup->t_data->t_oid;
-
/* this routine is actually in the planner */
children = find_all_inheritors(lconsi(myrelid, NIL), NIL);
@@ -147,14 +142,10 @@ renameatt(char *relname,
}
}
- reltup = SearchSysCacheTuple(RELNAME,
- PointerGetDatum(relname),
- 0, 0, 0);
- if (!HeapTupleIsValid(reltup))
+
+ if ((relid = RelnameFindRelid(relname)) == InvalidOid)
elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname);
- relid = reltup->t_data->t_oid;
-
oldatttup = SearchSysCacheTupleCopy(ATTNAME,
ObjectIdGetDatum(relid),
PointerGetDatum(oldattname),
@@ -211,8 +202,7 @@ void
renamerel(char *oldrelname, char *newrelname)
{
Relation relrelation; /* for RELATION relation */
- HeapTuple oldreltup,
- newreltup;
+ HeapTuple oldreltup;
char oldpath[MAXPGPATH],
newpath[MAXPGPATH];
Relation irelations[Num_pg_class_indices];
@@ -231,10 +221,7 @@ renamerel(char *oldrelname, char *newrelname)
if (!HeapTupleIsValid(oldreltup))
elog(ERROR, "renamerel: relation \"%s\" does not exist", oldrelname);
- newreltup = SearchSysCacheTuple(RELNAME,
- PointerGetDatum(newrelname),
- 0, 0, 0);
- if (HeapTupleIsValid(newreltup))
+ if (RelnameFindRelid(newrelname) != InvalidOid)
elog(ERROR, "renamerel: relation \"%s\" exists", newrelname);
/* rename the path first, so if this fails the rename's not done */