SPI_getnspname
SPI_getnspname
От:
Neil Conway <neilc@samurai.com>
Дата:
I noticed there is an SPI API function to get the name of a specified
Relation, but no similar function to get the Relation's namespace.
Attached is a patch that implements SPI_getnspname().
I wasn't sure if I should refer to the relation's "schema" or its
"namespace"; my feeling was that SPI is sufficiently close to the
internals that we should use the internal term, which is namespace.
Barring any objections, I'll apply this later today.
-Neil
Index: doc/src/sgml/spi.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql/doc/src/sgml/spi.sgml,v
retrieving revision 1.39
diff -c -r1.39 spi.sgml
*** doc/src/sgml/spi.sgml 22 Jan 2005 22:56:36 -0000 1.39
--- doc/src/sgml/spi.sgml 24 Mar 2005 01:52:11 -0000
***************
*** 2153,2158 ****
--- 2153,2212 ----
+
+
+ SPI_getnspname
+
+
+
+ SPI_getnspname
+ return the namespace of the specified relation
+
+
+ SPI_getnspname
+
+
+
+ char * SPI_getnspname(Relation rel)
+
+
+
+
+ Description
+
+
+ SPI_getnspname returns a copy of the name of
+ the namespace that the specified Relation
+ belongs to. This is equivalent to the relation's schema. You should
+ pfree the return value of this function when
+ you are finished with it.
+
+
+
+
+ Arguments
+
+
+
+ Relation rel
+
+
+ input relation
+
+
+
+
+
+
+
+ Return Value
+
+
+ The name of the specified relation's namespace.
+
+
+
+
Index: src/backend/executor/spi.c
===================================================================
RCS file: /var/lib/cvs/pgsql/src/backend/executor/spi.c,v
retrieving revision 1.135
diff -c -r1.135 spi.c
*** src/backend/executor/spi.c 16 Mar 2005 21:38:08 -0000 1.135
--- src/backend/executor/spi.c 23 Mar 2005 09:08:42 -0000
***************
*** 760,765 ****
--- 760,771 ----
return pstrdup(RelationGetRelationName(rel));
}
+ char *
+ SPI_getnspname(Relation rel)
+ {
+ return get_namespace_name(RelationGetNamespace(rel));
+ }
+
void *
SPI_palloc(Size size)
{
Index: src/include/executor/spi.h
===================================================================
RCS file: /var/lib/cvs/pgsql/src/include/executor/spi.h,v
retrieving revision 1.50
diff -c -r1.50 spi.h
*** src/include/executor/spi.h 16 Nov 2004 18:10:13 -0000 1.50
--- src/include/executor/spi.h 23 Mar 2005 09:09:50 -0000
***************
*** 113,118 ****
--- 113,119 ----
extern char *SPI_gettype(TupleDesc tupdesc, int fnumber);
extern Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber);
extern char *SPI_getrelname(Relation rel);
+ extern char *SPI_getnspname(Relation rel);
extern void *SPI_palloc(Size size);
extern void *SPI_repalloc(void *pointer, Size size);
extern void SPI_pfree(void *pointer);