From: Bruce Momjian Date: Tue, 30 Jul 2002 16:20:03 +0000 (+0000) Subject: Here are two patches. The guc_and_tablefunc patch addresses the two X-Git-Tag: REL7_3~1083 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23a8b77d42463437f1dd52c601bcfeb858aef7b3;p=postgresql Here are two patches. The guc_and_tablefunc patch addresses the two changes mentioned above, and also adds a new function to the tablefunc API. The tablefunc API change adds the following function: * Oid foidGetTypeId(Oid foid) - Get a function's typeid given the * function Oid. Use this together with TypeGetTupleDesc() to get a * TupleDesc which is derived from the function's declared return type. In the next post I'll send the contrib/tablefunc patch, which illustrates the usage of this new function. Also attached is a doc patch for this change. The doc patch also adds a function that I failed to document previously. Joe Conway --- diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index bb7f742f69..91d1849d52 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -1,5 +1,5 @@ @@ -1556,6 +1556,14 @@ HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) should be set to NULL. + + In order to get an attribute "in" function and typelem value given the + typeid, use + +void get_type_metadata(Oid typeid, Oid *attinfuncid, Oid *attelem) + + + Finally, in order to return a tuple using the SRF portion of the API (described below), the tuple must be converted into a Datum. Use diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index c90c52e8cc..4a03c95277 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -5,7 +5,7 @@ * command, configuration file, and command line options. * See src/backend/utils/misc/README for more information. * - * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.75 2002/07/20 15:12:55 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.76 2002/07/30 16:20:03 momjian Exp $ * * Copyright 2000 by PostgreSQL Global Development Group * Written by Peter Eisentraut . @@ -2347,13 +2347,21 @@ GetConfigOptionByName(const char *name, const char **varname) * form of name. Return value is palloc'd. */ char * -GetConfigOptionByNum(int varnum, const char **varname) +GetConfigOptionByNum(int varnum, const char **varname, bool *noshow) { - struct config_generic *conf = guc_variables[varnum]; + struct config_generic *conf; + + /* check requested variable number valid */ + Assert((varnum >= 0) && (varnum < num_guc_variables)); + + conf = guc_variables[varnum]; if (varname) *varname = conf->name; + if (noshow) + *noshow = (conf->flags & GUC_NO_SHOW_ALL) ? true : false; + return _ShowOption(conf); } diff --git a/src/include/funcapi.h b/src/include/funcapi.h index f00b93b865..2941475382 100644 --- a/src/include/funcapi.h +++ b/src/include/funcapi.h @@ -139,6 +139,8 @@ typedef struct * HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) - * build a HeapTuple given user data in C string form. values is an array * of C strings, one for each attribute of the return tuple. + * void get_type_metadata(Oid typeid, Oid *attinfuncid, Oid *attelem) - Get + * an attribute "in" function and typelem value given the typeid. * * Macro declarations: * TupleGetDatum(TupleTableSlot *slot, HeapTuple tuple) - get a Datum diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 17e4f3d652..b6d1421ec4 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -4,7 +4,7 @@ * External declarations pertaining to backend/utils/misc/guc.c and * backend/utils/misc/guc-file.l * - * $Id: guc.h,v 1.19 2002/07/20 15:12:56 tgl Exp $ + * $Id: guc.h,v 1.20 2002/07/30 16:20:03 momjian Exp $ */ #ifndef GUC_H #define GUC_H @@ -87,7 +87,7 @@ extern bool set_config_option(const char *name, const char *value, extern void ShowGUCConfigOption(const char *name); extern void ShowAllGUCConfig(void); extern char *GetConfigOptionByName(const char *name, const char **varname); -extern char *GetConfigOptionByNum(int varnum, const char **varname); +extern char *GetConfigOptionByNum(int varnum, const char **varname, bool *noshow); extern int GetNumConfigOptions(void); extern void SetPGVariable(const char *name, List *args, bool is_local);