aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-08-29 00:17:06 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-08-29 00:17:06 +0000
commit64505ed58ba71df3221e2467dc458af2e1912895 (patch)
tree3c110a6d9e3badd87d741976871028760b8f55b5 /src/backend/utils
parent7483749d8207c0cbcce5ce69161400ace31a6856 (diff)
downloadpostgresql-64505ed58ba71df3221e2467dc458af2e1912895.tar.gz
postgresql-64505ed58ba71df3221e2467dc458af2e1912895.zip
Code review for standalone composite types, query-specified composite
types, SRFs. Not happy with memory management yet, but I'll commit these other changes.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/lockfuncs.c8
-rw-r--r--src/backend/utils/adt/tid.c8
-rw-r--r--src/backend/utils/cache/lsyscache.c29
-rw-r--r--src/backend/utils/fmgr/funcapi.c31
-rw-r--r--src/backend/utils/misc/guc.c19
5 files changed, 47 insertions, 48 deletions
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
index 38e540e3c85..83d0d1051df 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -5,22 +5,22 @@
* Copyright (c) 2002, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.2 2002/08/27 04:00:28 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.3 2002/08/29 00:17:05 tgl Exp $
*/
-
#include "postgres.h"
-#include "fmgr.h"
+
#include "funcapi.h"
#include "catalog/pg_type.h"
#include "storage/lmgr.h"
#include "storage/lock.h"
#include "storage/lwlock.h"
#include "storage/proc.h"
+#include "utils/builtins.h"
-Datum pg_lock_status(PG_FUNCTION_ARGS);
static int next_lock(int locks[]);
+
Datum
pg_lock_status(PG_FUNCTION_ARGS)
{
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index bd642a26e97..d90c20adf98 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.34 2002/08/28 20:46:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.35 2002/08/29 00:17:05 tgl Exp $
*
* NOTES
* input routine largely stolen from boxin().
@@ -226,9 +226,6 @@ currtid_byreloid(PG_FUNCTION_ARGS)
if (rel->rd_rel->relkind == RELKIND_VIEW)
return currtid_for_view(rel, tid);
- if (rel->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
- elog(ERROR, "currtid can't handle type relations");
-
ItemPointerCopy(tid, result);
heap_get_latest_tid(rel, SnapshotNow, result);
@@ -252,9 +249,6 @@ currtid_byrelname(PG_FUNCTION_ARGS)
if (rel->rd_rel->relkind == RELKIND_VIEW)
return currtid_for_view(rel, tid);
- if (rel->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
- elog(ERROR, "currtid can't handle type relations");
-
result = (ItemPointer) palloc(sizeof(ItemPointerData));
ItemPointerCopy(tid, result);
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 079ba2152a7..66dc58d6c4b 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -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.80 2002/08/26 17:53:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.81 2002/08/29 00:17:05 tgl Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -1191,6 +1191,33 @@ get_typtype(Oid typid)
}
/*
+ * getTypeInputInfo
+ *
+ * Get info needed for converting values of a type to internal form
+ */
+void
+getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem)
+{
+ HeapTuple typeTuple;
+ Form_pg_type pt;
+
+ typeTuple = SearchSysCache(TYPEOID,
+ ObjectIdGetDatum(type),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(typeTuple))
+ elog(ERROR, "getTypeInputInfo: Cache lookup of type %u failed", type);
+ pt = (Form_pg_type) GETSTRUCT(typeTuple);
+
+ if (!pt->typisdefined)
+ elog(ERROR, "Type \"%s\" is only a shell", NameStr(pt->typname));
+
+ *typInput = pt->typinput;
+ *typElem = pt->typelem;
+
+ ReleaseSysCache(typeTuple);
+}
+
+/*
* getTypeOutputInfo
*
* Get info needed for printing values of a type
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index a8d4e4fb5f5..28311c26b7b 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -6,13 +6,18 @@
*
* Copyright (c) 2002, PostgreSQL Global Development Group
*
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/funcapi.c,v 1.3 2002/08/29 00:17:05 tgl Exp $
+ *
*-------------------------------------------------------------------------
*/
+#include "postgres.h"
#include "funcapi.h"
#include "catalog/pg_type.h"
#include "utils/syscache.h"
+
/*
* init_MultiFuncCall
* Create an empty FuncCallContext data structure
@@ -99,8 +104,6 @@ per_MultiFuncCall(PG_FUNCTION_ARGS)
void
end_MultiFuncCall(PG_FUNCTION_ARGS, FuncCallContext *funcctx)
{
- MemoryContext oldcontext;
-
/* unbind from fcinfo */
fcinfo->flinfo->fn_extra = NULL;
@@ -108,32 +111,8 @@ end_MultiFuncCall(PG_FUNCTION_ARGS, FuncCallContext *funcctx)
* Caller is responsible to free up memory for individual
* struct elements other than att_in_funcinfo and elements.
*/
- oldcontext = MemoryContextSwitchTo(funcctx->fmctx);
-
if (funcctx->attinmeta != NULL)
pfree(funcctx->attinmeta);
pfree(funcctx);
-
- MemoryContextSwitchTo(oldcontext);
-}
-
-void
-get_type_metadata(Oid typeid, Oid *attinfuncid, Oid *attelem)
-{
- HeapTuple typeTuple;
- Form_pg_type typtup;
-
- typeTuple = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(typeid),
- 0, 0, 0);
- if (!HeapTupleIsValid(typeTuple))
- elog(ERROR, "get_type_metadata: Cache lookup of type %u failed", typeid);
-
- typtup = (Form_pg_type) GETSTRUCT(typeTuple);
-
- *attinfuncid = typtup->typinput;
- *attelem = typtup->typelem;
-
- ReleaseSysCache(typeTuple);
}
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index b73118289fc..660cd124ba9 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.84 2002/08/26 17:53:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.85 2002/08/29 00:17:05 tgl Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -2284,7 +2284,7 @@ ShowGUCConfigOption(const char *name)
tstate = begin_tup_output_tupdesc(dest, tupdesc);
/* Send it */
- PROJECT_LINE_OF_TEXT(tstate, value);
+ do_text_output_oneline(tstate, value);
end_tup_output(tstate);
}
@@ -2462,7 +2462,7 @@ show_all_settings(PG_FUNCTION_ARGS)
if (call_cntr < max_calls) /* do when there is more left to send */
{
- char **values;
+ char *values[2];
char *varname;
char *varval;
bool noshow;
@@ -2474,7 +2474,9 @@ show_all_settings(PG_FUNCTION_ARGS)
*/
do
{
- varval = GetConfigOptionByNum(call_cntr, (const char **) &varname, &noshow);
+ varval = GetConfigOptionByNum(call_cntr,
+ (const char **) &varname,
+ &noshow);
if (noshow)
{
/* varval is a palloc'd copy, so free it */
@@ -2495,9 +2497,8 @@ show_all_settings(PG_FUNCTION_ARGS)
* This should be an array of C strings which will
* be processed later by the appropriate "in" functions.
*/
- values = (char **) palloc(2 * sizeof(char *));
- values[0] = pstrdup(varname);
- values[1] = varval; /* varval is already a palloc'd copy */
+ values[0] = varname;
+ values[1] = varval;
/* build a tuple */
tuple = BuildTupleFromCStrings(attinmeta, values);
@@ -2506,10 +2507,8 @@ show_all_settings(PG_FUNCTION_ARGS)
result = TupleGetDatum(slot, tuple);
/* Clean up */
- pfree(values[0]);
if (varval != NULL)
- pfree(values[1]);
- pfree(values);
+ pfree(varval);
SRF_RETURN_NEXT(funcctx, result);
}