diff options
| author | Tom Lane | 2002-08-29 00:17:06 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-08-29 00:17:06 +0000 |
| commit | 64505ed58ba71df3221e2467dc458af2e1912895 (patch) | |
| tree | 3c110a6d9e3badd87d741976871028760b8f55b5 /src/include | |
| parent | 7483749d8207c0cbcce5ce69161400ace31a6856 (diff) | |
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/include')
| -rw-r--r-- | src/include/catalog/pg_type.h | 3 | ||||
| -rw-r--r-- | src/include/executor/executor.h | 14 | ||||
| -rw-r--r-- | src/include/funcapi.h | 55 | ||||
| -rw-r--r-- | src/include/nodes/execnodes.h | 10 | ||||
| -rw-r--r-- | src/include/utils/builtins.h | 5 | ||||
| -rw-r--r-- | src/include/utils/lsyscache.h | 3 |
6 files changed, 44 insertions, 46 deletions
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 8efb6c07a3d..3708a71bab9 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.130 2002/08/26 17:54:01 tgl Exp $ + * $Id: pg_type.h,v 1.131 2002/08/29 00:17:06 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -542,6 +542,7 @@ extern Oid TypeCreate(const char *typeName, Oid typeNamespace, Oid assignedTypeOid, Oid relationOid, + char relationKind, int16 internalSize, char typeType, char typDelim, diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 2fdb5bc210c..88104565976 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.73 2002/08/02 18:15:09 tgl Exp $ + * $Id: executor.h,v 1.74 2002/08/29 00:17:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -123,7 +123,8 @@ extern void SetChangedParamList(Plan *node, List *newchg); typedef struct TupOutputState { - TupleDesc tupdesc; + /* use "struct" here to allow forward reference */ + struct AttInMetadata *metadata; DestReceiver *destfunc; } TupOutputState; @@ -132,10 +133,15 @@ extern void do_tup_output(TupOutputState *tstate, char **values); extern void do_text_output_multiline(TupOutputState *tstate, char *text); extern void end_tup_output(TupOutputState *tstate); -#define PROJECT_LINE_OF_TEXT(tstate, text_to_project) \ +/* + * Write a single line of text given as a C string. + * + * Should only be used with a single-TEXT-attribute tupdesc. + */ +#define do_text_output_oneline(tstate, text_to_emit) \ do { \ char *values_[1]; \ - values_[0] = (text_to_project); \ + values_[0] = (text_to_emit); \ do_tup_output(tstate, values_); \ } while (0) diff --git a/src/include/funcapi.h b/src/include/funcapi.h index 29414753820..27dbdf20e62 100644 --- a/src/include/funcapi.h +++ b/src/include/funcapi.h @@ -9,26 +9,18 @@ * * Copyright (c) 2002, PostgreSQL Global Development Group * + * $Id: funcapi.h,v 1.5 2002/08/29 00:17:06 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef FUNCAPI_H #define FUNCAPI_H -#include "postgres.h" - #include "fmgr.h" -#include "access/htup.h" #include "access/tupdesc.h" #include "executor/executor.h" #include "executor/tuptable.h" -/* - * All functions that can be called directly by fmgr must have this signature. - * (Other functions can be called by using a handler that does have this - * signature.) - */ - /*------------------------------------------------------------------------- * Support to ease writing Functions returning composite types @@ -40,20 +32,19 @@ * is derived from the TupleDesc, but it is stored here to * avoid redundant cpu cycles on each call to an SRF. */ -typedef struct +typedef struct AttInMetadata { /* full TupleDesc */ TupleDesc tupdesc; - /* pointer to array of attribute "type"in finfo */ + /* array of attribute type input function finfo */ FmgrInfo *attinfuncs; - /* pointer to array of attribute type typelem */ + /* array of attribute type typelem */ Oid *attelems; - /* pointer to array of attribute type typtypmod */ - int4 *atttypmods; - + /* array of attribute typmod */ + int32 *atttypmods; } AttInMetadata; /*------------------------------------------------------------------------- @@ -63,7 +54,7 @@ typedef struct * This struct holds function context for Set Returning Functions. * Use fn_extra to hold a pointer to it across calls */ -typedef struct +typedef struct FuncCallContext { /* * Number of times we've been called before. @@ -120,35 +111,34 @@ typedef struct } FuncCallContext; -/*------------------------------------------------------------------------- +/*---------- * Support to ease writing Functions returning composite types * * External declarations: - * TupleDesc RelationNameGetTupleDesc(char *relname) - Use to get a TupleDesc - * based on the function's return type relation. + * TupleDesc RelationNameGetTupleDesc(const char *relname) - Use to get a + * TupleDesc based on a specified relation. * TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases) - Use to get a - * TupleDesc based on the function's type oid. This can be used to get - * a TupleDesc for a base (scalar), or composite (relation) type. + * TupleDesc based on a type OID. This can be used to get + * a TupleDesc for a base (scalar) or composite (relation) type. * TupleTableSlot *TupleDescGetSlot(TupleDesc tupdesc) - Initialize a slot * given a TupleDesc. - * AttInMetadata *TupleDescGetAttInMetadata(TupleDesc tupdesc) - Get a pointer - * to AttInMetadata based on the function's TupleDesc. AttInMetadata can + * AttInMetadata *TupleDescGetAttInMetadata(TupleDesc tupdesc) - Build an + * AttInMetadata struct based on the given TupleDesc. AttInMetadata can * be used in conjunction with C strings to produce a properly formed * tuple. Store the metadata here for use across calls to avoid redundant * work. * 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 * given a tuple and a slot. + *---------- */ /* from tupdesc.c */ -extern TupleDesc RelationNameGetTupleDesc(char *relname); +extern TupleDesc RelationNameGetTupleDesc(const char *relname); extern TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases); /* from execTuples.c */ @@ -156,13 +146,11 @@ extern TupleTableSlot *TupleDescGetSlot(TupleDesc tupdesc); extern AttInMetadata *TupleDescGetAttInMetadata(TupleDesc tupdesc); extern HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values); -/* from funcapi.c */ -extern void get_type_metadata(Oid typeid, Oid *attinfuncid, Oid *attelem); - #define TupleGetDatum(_slot, _tuple) \ PointerGetDatum(ExecStoreTuple(_tuple, _slot, InvalidBuffer, true)) -/*------------------------------------------------------------------------- + +/*---------- * Support for Set Returning Functions (SRFs) * * The basic API for SRFs looks something like: @@ -200,6 +188,7 @@ extern void get_type_metadata(Oid typeid, Oid *attinfuncid, Oid *attelem); * } * } * + *---------- */ /* from funcapi.c */ @@ -208,12 +197,15 @@ extern FuncCallContext *per_MultiFuncCall(PG_FUNCTION_ARGS); extern void end_MultiFuncCall(PG_FUNCTION_ARGS, FuncCallContext *funcctx); #define SRF_IS_FIRSTCALL() (fcinfo->flinfo->fn_extra == NULL) + #define SRF_FIRSTCALL_INIT() init_MultiFuncCall(fcinfo) + #define SRF_PERCALL_SETUP() per_MultiFuncCall(fcinfo) + #define SRF_RETURN_NEXT(_funcctx, _result) \ do { \ ReturnSetInfo *rsi; \ - _funcctx->call_cntr++; \ + (_funcctx)->call_cntr++; \ rsi = (ReturnSetInfo *) fcinfo->resultinfo; \ rsi->isDone = ExprMultipleResult; \ PG_RETURN_DATUM(_result); \ @@ -225,7 +217,6 @@ extern void end_MultiFuncCall(PG_FUNCTION_ARGS, FuncCallContext *funcctx); end_MultiFuncCall(fcinfo, _funcctx); \ rsi = (ReturnSetInfo *) fcinfo->resultinfo; \ rsi->isDone = ExprEndResult; \ - _funcctx->slot = NULL; \ PG_RETURN_NULL(); \ } while (0) diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index ee25cc62c95..6e146e2ca6d 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.71 2002/08/04 19:48:10 momjian Exp $ + * $Id: execnodes.h,v 1.72 2002/08/29 00:17:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -509,17 +509,13 @@ typedef struct SubqueryScanState * Function nodes are used to scan the results of a * function appearing in FROM (typically a function returning set). * - * functionmode function operating mode: - * - repeated call - * - materialize - * - return query + * functionmode function operating mode * tupdesc function's return tuple description * tuplestorestate private state of tuplestore.c * funcexpr function expression being evaluated * returnsTuple does function return tuples? * fn_typeid OID of function return type - * fn_typtype return Datum type, i.e. 'b'ase, - * 'c'atalog, or 'p'seudo + * fn_typtype return type's typtype * ---------------- */ typedef enum FunctionMode diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index bdee336b002..6f33ee4e42c 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.195 2002/08/22 03:24:01 momjian Exp $ + * $Id: builtins.h,v 1.196 2002/08/29 00:17:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -690,6 +690,9 @@ extern Datum show_config_by_name(PG_FUNCTION_ARGS); extern Datum set_config_by_name(PG_FUNCTION_ARGS); extern Datum show_all_settings(PG_FUNCTION_ARGS); +/* lockfuncs.c */ +extern Datum pg_lock_status(PG_FUNCTION_ARGS); + /* catalog/pg_conversion.c */ extern Datum pg_convert3(PG_FUNCTION_ARGS); diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 78d09908659..2681d67139f 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lsyscache.h,v 1.59 2002/08/26 17:54:02 tgl Exp $ + * $Id: lsyscache.h,v 1.60 2002/08/29 00:17:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -54,6 +54,7 @@ extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, extern char get_typstorage(Oid typid); extern Node *get_typdefault(Oid typid); extern char get_typtype(Oid typid); +extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem); extern bool getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem, bool *typIsVarlena); extern Oid getBaseType(Oid typid); |
