diff options
| author | Tom Lane | 1999-01-27 00:36:28 +0000 |
|---|---|---|
| committer | Tom Lane | 1999-01-27 00:36:28 +0000 |
| commit | 422221c90de5d65213e8e697ac0da77098ba22a9 (patch) | |
| tree | 2248f8bc5a5afcf67abb052be918a32d17360dad /src/include | |
| parent | 36693c05257c7a34be8f1dd1e6b4a7ce45980fa5 (diff) | |
Another SELECT speedup: extract OIDs of column print functions
only once per SELECT, not once per tuple. 10% here, 10% there,
pretty soon you're talking about real speedups ...
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/printtup.h | 20 | ||||
| -rw-r--r-- | src/include/libpq/libpq.h | 8 | ||||
| -rw-r--r-- | src/include/tcop/dest.h | 62 |
3 files changed, 64 insertions, 26 deletions
diff --git a/src/include/access/printtup.h b/src/include/access/printtup.h index 0b4f7b0f042..c1b1c51ef89 100644 --- a/src/include/access/printtup.h +++ b/src/include/access/printtup.h @@ -6,20 +6,26 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: printtup.h,v 1.6 1999/01/24 05:40:46 tgl Exp $ + * $Id: printtup.h,v 1.7 1999/01/27 00:36:10 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef PRINTTUP_H #define PRINTTUP_H -#include <access/htup.h> -#include <access/tupdesc.h> +#include <tcop/dest.h> -extern int getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem); -extern void printtup(HeapTuple tuple, TupleDesc typeinfo); +extern DestReceiver* printtup_create_DR(void); extern void showatts(char *name, TupleDesc attinfo); -extern void debugtup(HeapTuple tuple, TupleDesc typeinfo); -extern void printtup_internal(HeapTuple tuple, TupleDesc typeinfo); +extern void debugtup(HeapTuple tuple, TupleDesc typeinfo, + DestReceiver* self); +extern void printtup_internal(HeapTuple tuple, TupleDesc typeinfo, + DestReceiver* self); + +/* XXX this one is really in executor/spi.c */ +extern void spi_printtup(HeapTuple tuple, TupleDesc tupdesc, + DestReceiver* self); + +extern int getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem); #endif /* PRINTTUP_H */ diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h index cd036ca67f5..e654899909c 100644 --- a/src/include/libpq/libpq.h +++ b/src/include/libpq/libpq.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq.h,v 1.25 1999/01/24 02:47:15 tgl Exp $ + * $Id: libpq.h,v 1.26 1999/01/27 00:36:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,8 +18,7 @@ #include <netinet/in.h> #include "libpq/libpq-be.h" -#include "access/htup.h" -#include "access/tupdesc.h" +#include "tcop/dest.h" /* ---------------- @@ -236,7 +235,8 @@ extern PortalEntry *be_currentportal(void); extern PortalEntry *be_newportal(void); extern void be_typeinit(PortalEntry *entry, TupleDesc attrs, int natts); -extern void be_printtup(HeapTuple tuple, TupleDesc typeinfo); +extern void be_printtup(HeapTuple tuple, TupleDesc typeinfo, + DestReceiver* self); /* in be-pqexec.c */ diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h index 9a0322e7260..0b5a80908be 100644 --- a/src/include/tcop/dest.h +++ b/src/include/tcop/dest.h @@ -1,7 +1,7 @@ /*------------------------------------------------------------------------- * * dest.h-- - * Whenever the backend is submitted a query, the results + * Whenever the backend executes a query, the results * have to go someplace - either to the standard output, * to a local portal buffer or to a remote portal buffer. * @@ -23,21 +23,40 @@ * a query internally. This is not used now but it may be * useful for the parallel optimiser/executor. * + * dest.c defines three functions that implement destination management: + * + * BeginCommand: initialize the destination. + * DestToFunction: return a pointer to a struct of destination-specific + * receiver functions. + * EndCommand: clean up the destination when output is complete. + * + * The DestReceiver object returned by DestToFunction may be a statically + * allocated object (for destination types that require no local state) + * or can be a palloc'd object that has DestReceiver as its first field + * and contains additional fields (see printtup.c for an example). These + * additional fields are then accessible to the DestReceiver functions + * by casting the DestReceiver* pointer passed to them. + * The palloc'd object is pfree'd by the DestReceiver's cleanup function. + * + * XXX FIXME: the initialization and cleanup code that currently appears + * in-line in BeginCommand and EndCommand probably should be moved out + * to routines associated with each destination receiver type. * * Copyright (c) 1994, Regents of the University of California * - * $Id: dest.h,v 1.16 1998/09/01 04:38:39 momjian Exp $ + * $Id: dest.h,v 1.17 1999/01/27 00:36:08 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef DEST_H #define DEST_H +#include <access/htup.h> #include <access/tupdesc.h> /* ---------------- - * CommandDest is used to allow the results of calling - * pg_eval() to go to the right place. + * CommandDest is a simplistic means of identifying the desired + * destination. Someday this will probably need to be improved. * ---------------- */ typedef enum @@ -51,25 +70,38 @@ typedef enum SPI /* results sent to SPI manager */ } CommandDest; +/* ---------------- + * DestReceiver is a base type for destination-specific local state. + * In the simplest cases, there is no state info, just the function + * pointers that the executor must call. + * ---------------- + */ +typedef struct _DestReceiver DestReceiver; -/* AttrInfo* replaced with TupleDesc, now that TupleDesc also has within it - the number of attributes +struct _DestReceiver { + /* Called for each tuple to be output: */ + void (*receiveTuple) (HeapTuple tuple, TupleDesc typeinfo, + DestReceiver* self); + /* Initialization and teardown: */ + void (*setup) (DestReceiver* self, TupleDesc typeinfo); + void (*cleanup) (DestReceiver* self); + /* Private fields might appear beyond this point... */ +}; -typedef struct AttrInfo { - int numAttr; - Form_pg_attribute *attrs; -} AttrInfo; -*/ +/* The primary destination management functions */ -extern void (*DestToFunction(CommandDest dest)) (); +extern void BeginCommand(char *pname, int operation, TupleDesc attinfo, + bool isIntoRel, bool isIntoPortal, char *tag, + CommandDest dest); +extern DestReceiver* DestToFunction(CommandDest dest); extern void EndCommand(char *commandTag, CommandDest dest); + +/* Additional functions that go with destination management, more or less. */ + extern void SendCopyBegin(void); extern void ReceiveCopyBegin(void); extern void NullCommand(CommandDest dest); extern void ReadyForQuery(CommandDest dest); -extern void BeginCommand(char *pname, int operation, TupleDesc attinfo, - bool isIntoRel, bool isIntoPortal, char *tag, - CommandDest dest); extern void UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples); #endif /* DEST_H */ |
