1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

pg_type has a typnamespace column; system now supports creating types

in different namespaces.  Also, cleanup work on relation namespace
support: drop, alter, rename commands work for tables in non-default
namespaces.
This commit is contained in:
Tom Lane
2002-03-29 19:06:29 +00:00
parent 7c1ff35410
commit d5e99ab4d6
68 changed files with 2074 additions and 2266 deletions

View File

@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.39 2002/03/26 19:17:02 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.40 2002/03/29 19:06:27 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -47,14 +47,15 @@
#include "access/heapam.h"
#include "catalog/catname.h"
#include "catalog/namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "catalog/pg_class.h"
#include "catalog/pg_attribute.h"
#include "catalog/pg_attrdef.h"
#include "catalog/pg_class.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h"
#include "executor/spi.h"
#include "fmgr.h"
#include "nodes/makefuncs.h"
#include "parser/gramparse.h"
#include "parser/parse_type.h"
#include "tcop/tcopprot.h"
@@ -851,10 +852,8 @@ plpgsql_parse_wordtype(char *word)
{
PLpgSQL_nsitem *nse;
char *cp;
HeapTuple typeTup;
Form_pg_type typeStruct;
char *typeXlated;
bool old_nsstate;
Oid typeOid;
/*
* We do our lookups case insensitive
@@ -887,39 +886,46 @@ plpgsql_parse_wordtype(char *word)
/*
* Word wasn't found on the namestack. Try to find a data type with
* that name, but ignore pg_type entries that are in fact class types.
*
* XXX this should be improved to handle qualified-type-name references.
*/
typeXlated = xlateSqlType(cp);
typeTup = SearchSysCache(TYPENAME,
PointerGetDatum(typeXlated),
0, 0, 0);
if (HeapTupleIsValid(typeTup))
typeOid = LookupTypeName(makeTypeName(xlateSqlType(cp)));
if (OidIsValid(typeOid))
{
PLpgSQL_type *typ;
HeapTuple typeTup;
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
if (typeStruct->typrelid != InvalidOid)
typeTup = SearchSysCache(TYPEOID,
ObjectIdGetDatum(typeOid),
0, 0, 0);
if (HeapTupleIsValid(typeTup))
{
Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
PLpgSQL_type *typ;
if (!typeStruct->typisdefined ||
typeStruct->typrelid != InvalidOid)
{
ReleaseSysCache(typeTup);
pfree(cp);
return T_ERROR;
}
typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type));
typ->typname = strdup(NameStr(typeStruct->typname));
typ->typoid = typeOid;
perm_fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->typelem = typeStruct->typelem;
typ->typbyval = typeStruct->typbyval;
typ->typlen = typeStruct->typlen;
typ->atttypmod = -1;
plpgsql_yylval.dtype = typ;
ReleaseSysCache(typeTup);
pfree(cp);
return T_ERROR;
return T_DTYPE;
}
typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type));
typ->typname = strdup(NameStr(typeStruct->typname));
typ->typoid = typeTup->t_data->t_oid;
perm_fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->typelem = typeStruct->typelem;
typ->typbyval = typeStruct->typbyval;
typ->typlen = typeStruct->typlen;
typ->atttypmod = -1;
plpgsql_yylval.dtype = typ;
ReleaseSysCache(typeTup);
pfree(cp);
return T_DTYPE;
}
/*

View File

@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.16 2002/03/06 18:50:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.17 2002/03/29 19:06:27 tgl Exp $
*
*********************************************************************
*/
@@ -49,16 +49,16 @@
/* postgreSQL stuff
*/
#include "executor/spi.h"
#include "commands/trigger.h"
#include "utils/elog.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "tcop/tcopprot.h"
#include "utils/syscache.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h"
#include "executor/spi.h"
#include "fmgr.h"
#include "nodes/makefuncs.h"
#include "parser/parse_type.h"
#include "tcop/tcopprot.h"
#include "utils/syscache.h"
#include <Python.h>
#include "plpython.h"
@@ -2086,16 +2086,8 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
RAISE_EXC(1);
}
sptr = PyString_AsString(optr);
typeTup = SearchSysCache(TYPENAME, PointerGetDatum(sptr),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
PLy_exception_set(PLy_exc_spi_error,
"Cache lookup for type `%s' failed.",
sptr);
RAISE_EXC(1);
}
/* XXX should extend this to allow qualified type names */
typeTup = typenameType(makeTypeName(sptr));
Py_DECREF(optr);
optr = NULL; /* this is important */

View File

@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.52 2002/03/06 18:50:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.53 2002/03/29 19:06:28 tgl Exp $
*
**********************************************************************/
@@ -47,17 +47,18 @@
#include <string.h>
#include <setjmp.h>
#include "executor/spi.h"
#include "commands/trigger.h"
#include "utils/builtins.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "tcop/tcopprot.h"
#include "utils/syscache.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_language.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h"
#include "executor/spi.h"
#include "fmgr.h"
#include "nodes/makefuncs.h"
#include "parser/parse_type.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/syscache.h"
#if defined(UNICODE_CONVERSION) && TCL_MAJOR_VERSION == 8 \
&& TCL_MINOR_VERSION > 0
@@ -1750,11 +1751,8 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
************************************************************/
for (i = 0; i < nargs; i++)
{
typeTup = SearchSysCache(TYPENAME,
PointerGetDatum(args[i]),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "pltcl: Cache lookup of type %s failed", args[i]);
/* XXX should extend this to allow qualified type names */
typeTup = typenameType(makeTypeName(args[i]));
qdesc->argtypes[i] = typeTup->t_data->t_oid;
perm_fmgr_info(((Form_pg_type) GETSTRUCT(typeTup))->typinput,
&(qdesc->arginfuncs[i]));