1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Clean up th ecompile process by centralizing the include files

- code compile tested, but due to a yet unresolved problem with
          parse.h's creation, compile not completed...
This commit is contained in:
Marc G. Fournier
1996-08-28 07:27:54 +00:00
parent 907c884fe8
commit 870be9fa8e
195 changed files with 97 additions and 13583 deletions

View File

@@ -0,0 +1,78 @@
/*-------------------------------------------------------------------------
*
* bootstrap.h--
* include file for the bootstrapping code
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: bootstrap.h,v 1.1 1996/08/28 07:21:31 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef BOOTSTRAP_H
#define BOOTSTRAP_H
#include <sys/file.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <ctype.h>
#include "access/htup.h"
#include "access/itup.h"
#include "access/relscan.h"
#include "access/skey.h"
#include "utils/tqual.h"
#include "storage/buf.h"
#include "storage/bufmgr.h" /* for BufferManagerFlush */
#include "utils/portal.h"
#include "utils/elog.h"
#include "utils/rel.h"
#define MAXATTR 40 /* max. number of attributes in a relation */
typedef struct hashnode {
int strnum; /* Index into string table */
struct hashnode *next;
} hashnode;
#define EMITPROMPT printf("> ")
extern Relation reldesc;
extern AttributeTupleForm attrtypes[MAXATTR];
extern int numattr;
extern int DebugMode;
extern int BootstrapMain(int ac, char *av[]);
extern void index_register(char *heap,
char *ind,
int natts,
AttrNumber *attnos,
uint16 nparams,
Datum *params,
FuncIndexInfo *finfo,
PredInfo *predInfo);
extern void err_out(void);
extern void InsertOneTuple(Oid objectid);
extern void closerel(char *name);
extern void boot_openrel(char *name);
extern char *LexIDStr(int ident_num);
extern void DefineAttr(char *name, char *type, int attnum);
extern void InsertOneValue(Oid objectid, char *value, int i);
extern void InsertOneNull(int i);
extern bool BootstrapAlreadySeen(Oid id);
extern void cleanup(void);
extern int gettype(char *type);
extern AttributeTupleForm AllocateAttribute(void);
extern char* MapArrayTypeName(char *s);
extern char* CleanUpStr(char *s);
extern int EnterString (char *str);
extern int CompHash (char *str, int len);
extern hashnode *FindStr (char *str, int length, hashnode *mderef);
extern hashnode *AddStr(char *str, int strlength, int mderef);
extern void build_indices(void);
#endif /* BOOTSTRAP_H */

View File

@@ -0,0 +1,33 @@
/*-------------------------------------------------------------------------
*
* async.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: async.h,v 1.1 1996/08/28 07:21:41 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef ASYNC_H
#define ASYNC_H
#include "nodes/memnodes.h"
#if defined(PORTNAME_linux)
extern void Async_NotifyHandler(int);
#else
extern void Async_NotifyHandler(void);
#endif
extern void Async_Notify(char *relname);
extern void Async_NotifyAtCommit(void);
extern void Async_NotifyAtAbort(void);
extern void Async_Listen(char *relname, int pid);
extern void Async_Unlisten(char *relname, int pid);
extern void Async_UnlistenOnExit(int code, char *relname);
extern GlobalMemory notifyContext;
extern void Async_NotifyFrontEnd(void);
#endif /* ASYNC_H */

View File

@@ -0,0 +1,30 @@
/*-------------------------------------------------------------------------
*
* cluster.h--
* header file for postgres cluster command stuff
*
* Copyright (c) 1994-5, Regents of the University of California
*
* $Id: cluster.h,v 1.1 1996/08/28 07:21:42 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef CLUSTER_H
#define CLUSTER_H
/*
* defines for contant stuff
*/
#define _TEMP_RELATION_KEY_ "clXXXXXXXX"
#define _SIZE_OF_TEMP_RELATION_KEY_ 11
/*
* functions
*/
extern void cluster(char oldrelname[], char oldindexname[]);
extern Relation copy_heap(Oid OIDOldHeap);
extern void copy_index(Oid OIDOldIndex, Oid OIDNewHeap);
extern void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex);
#endif /* CLUSTER_H */

View File

@@ -0,0 +1,56 @@
/*-------------------------------------------------------------------------
*
* command.h--
* prototypes for command.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: command.h,v 1.1 1996/08/28 07:21:43 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef COMMAND_H
#define COMMAND_H
#include "utils/portal.h"
#include "tcop/dest.h"
extern MemoryContext PortalExecutorHeapMemory;
/*
* PortalCleanup --
* Cleans up the query state of the portal.
*
* Exceptions:
* BadArg if portal invalid.
*/
extern void PortalCleanup(Portal portal);
/*
* PerformPortalFetch --
* Performs the POSTQUEL function FETCH. Fetches count (or all if 0)
* tuples in portal with name in the forward direction iff goForward.
*
* Exceptions:
* BadArg if forward invalid.
* "WARN" if portal not found.
*/
extern void PerformPortalFetch(char *name, bool forward, int count,
char *tag, CommandDest dest);
/*
* PerformPortalClose --
* Performs the POSTQUEL function CLOSE.
*/
extern void PerformPortalClose(char *name, CommandDest dest);
/*
* PerformAddAttribute --
* Performs the POSTQUEL function ADD.
*/
extern void PerformAddAttribute(char *relationName, char *userName,
bool inh, ColumnDef *colDef);
#endif /* COMMAND_H */

View File

@@ -0,0 +1,21 @@
/*-------------------------------------------------------------------------
*
* copy.h--
* Definitions for using the POSTGRES copy command.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: copy.h,v 1.1 1996/08/28 07:21:44 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef COPY_H
#define COPY_H
#include "postgres.h"
void DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, char *filename,
char *delim);
#endif /* COPY_H */

View File

@@ -0,0 +1,20 @@
/*-------------------------------------------------------------------------
*
* creatinh.h--
* prototypes for creatinh.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: creatinh.h,v 1.1 1996/08/28 07:21:45 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef CREATINH_H
#define CREATINH_H
extern void DefineRelation(CreateStmt *stmt);
extern void RemoveRelation(char *name);
extern char* MakeArchiveName(Oid relid);
#endif /* CREATINH_H */

View File

@@ -0,0 +1,53 @@
/*-------------------------------------------------------------------------
*
* defrem.h--
* POSTGRES define and remove utility definitions.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: defrem.h,v 1.1 1996/08/28 07:21:46 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef DEFREM_H
#define DEFREM_H
#include "postgres.h"
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
#include "nodes/parsenodes.h"
#include "tcop/dest.h"
/*
* prototypes in defind.c
*/
extern void DefineIndex(char *heapRelationName,
char *indexRelationName,
char *accessMethodName,
List *attributeList,
List *parameterList, Expr *predicate,
List *rangetable);
extern void ExtendIndex(char *indexRelationName,
Expr *predicate,
List *rangetable);
extern void RemoveIndex(char *name);
/*
* prototypes in define.c
*/
extern void DefineFunction(ProcedureStmt *nameargsexe, CommandDest dest);
extern void DefineOperator(char *name, List *parameters);
extern void DefineAggregate(char *name, List *parameters);
extern void DefineType(char *name, List *parameters);
/*
* prototypes in remove.c
*/
extern void RemoveFunction(char *functionName, int nargs, List *argNameList);
extern void RemoveOperator(char *operatorName,
char *typeName1, char *typeName2);
extern void RemoveType(char *typeName);
extern void RemoveAggregate(char *aggName);
#endif /* DEFREM_H */

View File

@@ -0,0 +1,17 @@
/*-------------------------------------------------------------------------
*
* explain.h--
* prototypes for explain.c
*
* Copyright (c) 1994-5, Regents of the University of California
*
* $Id: explain.h,v 1.1 1996/08/28 07:21:47 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef EXPLAIN_H
#define EXPLAIN_H
extern void ExplainQuery(Query *query, List *options, CommandDest dest);
#endif /* EXPLAIN_H*/

View File

@@ -0,0 +1,20 @@
/*-------------------------------------------------------------------------
*
* purge.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: purge.h,v 1.1 1996/08/28 07:21:48 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PURGE_H
#define PURGE_H
extern int32 RelationPurge(char *relationName,
char *absoluteTimeString,
char *relativeTimeString);
#endif /* PURGE_H */

View File

@@ -0,0 +1,17 @@
/*-------------------------------------------------------------------------
*
* recipe.h--
* recipe handling routines
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: recipe.h,v 1.1 1996/08/28 07:21:50 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef RECIPE_H
#define RECIPE_H
extern void beginRecipe(RecipeStmt* stmt);
#endif /* RECIPE_H */

View File

@@ -0,0 +1,24 @@
/*-------------------------------------------------------------------------
*
* rename.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rename.h,v 1.1 1996/08/28 07:21:51 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef RENAME_H
#define RENAME_H
extern void renameatt(char *relname,
char *oldattname,
char *newattname,
char *userName, int recurse);
extern void renamerel(char *oldrelname,
char *newrelname);
#endif /* RENAME_H */

View File

@@ -0,0 +1,48 @@
/*-------------------------------------------------------------------------
*
* vacuum.h--
* header file for postgres vacuum cleaner
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: vacuum.h,v 1.1 1996/08/28 07:21:52 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VACUUM_H
#define VACUUM_H
typedef struct VAttListData {
int val_dummy;
struct VAttListData *val_next;
} VAttListData;
typedef VAttListData *VAttList;
typedef struct VTidListData {
ItemPointerData vtl_tid;
struct VTidListData *vtl_next;
} VTidListData;
typedef VTidListData *VTidList;
typedef struct VRelListData {
Oid vrl_relid;
VAttList vrl_attlist;
VTidList vrl_tidlist;
int vrl_ntups;
int vrl_npages;
bool vrl_hasindex;
struct VRelListData *vrl_next;
} VRelListData;
typedef VRelListData *VRelList;
extern bool VacuumRunning;
extern void vc_abort(void);
extern void vacuum(char *vacrel);
#endif /* VACUUM_H */

View File

@@ -0,0 +1,26 @@
/*-------------------------------------------------------------------------
*
* version.h--
* Header file for versions.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: version.h,v 1.1 1996/08/28 07:21:53 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VERSION_H
#define VERSION_H
#include "postgres.h"
#include "nodes/pg_list.h"
extern void DefineVersion(char *name, char *fromRelname, char *date);
extern void VersionCreate(char *vname, char *bname);
extern void VersionAppend(char *vname, char *bname);
extern void VersionRetrieve(char *vname, char *bname, char *snapshot);
extern void VersionDelete(char *vname, char *bname, char *snapshot);
extern void VersionReplace(char *vname, char *bname, char *snapshot);
#endif /* VERSION_H */

View File

@@ -0,0 +1,20 @@
/*-------------------------------------------------------------------------
*
* view.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: view.h,v 1.1 1996/08/28 07:21:54 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VIEW_H
#define VIEW_H
extern char *MakeRetrieveViewRuleName(char *view_name);
extern void DefineView(char *view_name, Query *view_parse);
extern void RemoveView(char *view_name);
#endif /* VIEW_H */

View File

@@ -0,0 +1,26 @@
/*-------------------------------------------------------------------------
*
* execFlatten.h--
* prototypes for execFlatten.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: execFlatten.h,v 1.1 1996/08/28 07:22:04 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef EXECFLATTEN_H
#define EXECFLATTEN_H
extern Datum ExecEvalIter(Iter *iterNode, ExprContext *econtext, bool *resultIsNull, bool *iterIsDone);
extern void ExecEvalFjoin(TargetEntry *tlist, ExprContext *econtext, bool *isNullVect, bool *fj_isDone);
extern bool FjoinBumpOuterNodes(TargetEntry *tlist, ExprContext *econtext, DatumPtr results, char *nulls);
#endif /* EXECFLATTEN_H */

View File

@@ -0,0 +1,377 @@
/*-------------------------------------------------------------------------
*
* execdebug.h--
* #defines governing debugging behaviour in the executor
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: execdebug.h,v 1.1 1996/08/28 07:22:06 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef EXECDEBUG_H
#define EXECDEBUG_H
/* ----------------------------------------------------------------
* debugging defines.
*
* If you want certain debugging behaviour, then #define
* the variable to 1, else #undef it. -cim 10/26/89
* ----------------------------------------------------------------
*/
/* ----------------
* EXEC_DEBUGSTORETUP is for tuple table debugging - this
* will print a message every time we call ExecStoreTuple.
* -cim 3/20/91
* ----------------
*/
#undef EXEC_DEBUGSTORETUP
/* ----------------
* EXEC_TUPLECOUNT is a #define which causes the
* executor keep track of tuple counts. This might be
* causing some problems with the decstation stuff so
* you might want to undefine this if you are doing work
* on the decs - cim 10/20/89
* ----------------
*/
#undef EXEC_TUPLECOUNT
/* ----------------
* EXEC_SHOWBUFSTATS controls whether or not buffer statistics
* are shown for each query. -cim 2/9/89
* ----------------
*/
#undef EXEC_SHOWBUFSTATS
/* ----------------
* EXEC_CONTEXTDEBUG turns on the printing of debugging information
* by CXT_printf() calls regarding which memory context is the
* CurrentMemoryContext for palloc() calls.
* ----------------
*/
#undef EXEC_CONTEXTDEBUG
/* ----------------
* EXEC_RETURNSIZE is a compile flag governing the
* behaviour of lispFmgr.. See ExecMakeFunctionResult().
* Undefining this avoids a problem in the system cache.
*
* Note: undefining this means that there is incorrect
* information in the const nodes corresponding
* to function (or operator) results. The thing is,
* 99% of the time this is fine because when you do
* something like x = emp.sal + 1, you already know
* the type and size of x so the fact that + didn't
* return the correct size doesn't matter.
* With variable length stuff the size is stored in
* the first few bytes of the data so again, it's
* not likely to matter.
* ----------------
*/
#undef EXEC_RETURNSIZE
/* ----------------
* EXEC_UTILSDEBUG is a flag which turns on debugging of the
* executor utilities by EU_printf() in eutils.c
* ----------------
*/
#undef EXEC_UTILSDEBUG
/* ----------------
* EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
* nest loop node by NL_printf() and ENL_printf() in nestloop.c
* ----------------
*/
#undef EXEC_NESTLOOPDEBUG
/* ----------------
* EXEC_PROCDEBUG is a flag which turns on debugging of
* ExecProcNode() by PN_printf() in procnode.c
* ----------------
*/
#undef EXEC_PROCDEBUG
/* ----------------
* EXEC_EVALDEBUG is a flag which turns on debugging of
* ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
* ----------------
*/
#undef EXEC_EVALDEBUG
/* ----------------
* EXEC_SCANDEBUG is a flag which turns on debugging of
* the ExecSeqScan() stuff by S_printf() in seqscan.c
* ----------------
*/
#undef EXEC_SCANDEBUG
/* ----------------
* EXEC_SORTDEBUG is a flag which turns on debugging of
* the ExecSort() stuff by SO_printf() in sort.c
* ----------------
*/
#undef EXEC_SORTDEBUG
/* ----------------
* EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
* the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
* ----------------
*/
#undef EXEC_MERGEJOINDEBUG
/* ----------------
* EXEC_MERGEJOINPFREE is a flag which causes merge joins
* to pfree intermittant tuples (which is the proper thing)
* Not defining this means we avoid menory management problems
* at the cost of doing deallocation of stuff only at the
* end of the transaction
* ----------------
*/
#undef EXEC_MERGEJOINPFREE
/* ----------------
* EXEC_DEBUGINTERACTIVE is a flag which enables the
* user to issue "DEBUG" commands from an interactive
* backend.
* ----------------
*/
#undef EXEC_DEBUGINTERACTIVE
/* ----------------
* EXEC_DEBUGVARIABLEFILE is string, which if defined will
* be loaded when the executor is initialized. If this
* string is not defined then nothing will be loaded..
*
* Example:
*
* #define EXEC_DEBUGVARIABLEFILE "/a/postgres/cimarron/.pg_debugvars"
#
* Note: since these variables are read at execution time,
* they can't affect the first query.. this hack should be
* replaced by something better sometime. -cim 11/2/89
* ----------------
*/
#undef EXEC_DEBUGVARIABLEFILE
/* ----------------------------------------------------------------
* #defines controlled by above definitions
*
* Note: most of these are "incomplete" because I didn't
* need the ones not defined. More should be added
* only as necessary -cim 10/26/89
* ----------------------------------------------------------------
*/
#define T_OR_F(b) (b ? "true" : "false")
#define NULL_OR_TUPLE(slot) (TupIsNull(slot) ? "null" : "a tuple")
/* #define EXEC_TUPLECOUNT - XXX take out for now for executor stubbing -- jolly*/
/* ----------------
* tuple count debugging defines
* ----------------
*/
#ifdef EXEC_TUPLECOUNT
extern int NTupleProcessed;
extern int NTupleRetrieved;
extern int NTupleReplaced;
extern int NTupleAppended;
extern int NTupleDeleted;
extern int NIndexTupleProcessed;
extern int NIndexTupleInserted;
#define IncrRetrieved() NTupleRetrieved++
#define IncrAppended() NTupleAppended++
#define IncrDeleted() NTupleDeleted++
#define IncrReplaced() NTupleReplaced++
#define IncrInserted() NTupleInserted++
#define IncrProcessed() NTupleProcessed++
#define IncrIndexProcessed() NIndexTupleProcessed++
#define IncrIndexInserted() NIndexTupleInserted++
#else
#define IncrRetrieved()
#define IncrAppended()
#define IncrDeleted()
#define IncrReplaced()
#define IncrInserted()
#define IncrProcessed()
#define IncrIndexProcessed()
#define IncrIndexInserted()
#endif /* EXEC_TUPLECOUNT */
/* ----------------
* memory context debugging defines
* ----------------
*/
#ifdef EXEC_CONTEXTDEBUG
#define CXT_printf(s) printf(s)
#define CXT1_printf(s, a) printf(s, a)
#else
#define CXT_printf(s)
#define CXT1_printf(s, a)
#endif /* EXEC_CONTEXTDEBUG */
/* ----------------
* eutils debugging defines
* ----------------
*/
#ifdef EXEC_UTILSDEBUG
#define EU_nodeDisplay(l) nodeDisplay(l, 0)
#define EU_printf(s) printf(s)
#define EU1_printf(s, a) printf(s, a)
#define EU4_printf(s, a, b, c, d) printf(s, a, b, c, d)
#else
#define EU_nodeDisplay(l)
#define EU_printf(s)
#define EU1_printf(s, a)
#define EU4_printf(s, a, b, c, d)
#endif /* EXEC_UTILSDEBUG */
/* ----------------
* nest loop debugging defines
* ----------------
*/
#ifdef EXEC_NESTLOOPDEBUG
#define NL_nodeDisplay(l) nodeDisplay(l, 0)
#define NL_printf(s) printf(s)
#define NL1_printf(s, a) printf(s, a)
#define NL4_printf(s, a, b, c, d) printf(s, a, b, c, d)
#define ENL1_printf(message) printf("ExecNestLoop: %s\n", message)
#else
#define NL_nodeDisplay(l)
#define NL_printf(s)
#define NL1_printf(s, a)
#define NL4_printf(s, a, b, c, d)
#define ENL1_printf(message)
#endif /* EXEC_NESTLOOPDEBUG */
/* ----------------
* proc node debugging defines
* ----------------
*/
#ifdef EXEC_PROCDEBUG
#define PN_printf(s) printf(s)
#define PN1_printf(s, p) printf(s, p)
#else
#define PN_printf(s)
#define PN1_printf(s, p)
#endif /* EXEC_PROCDEBUG */
/* ----------------
* exec eval / target list debugging defines
* ----------------
*/
#ifdef EXEC_EVALDEBUG
#define EV_nodeDisplay(l) nodeDisplay(l, 0)
#define EV_printf(s) printf(s)
#define EV1_printf(s, a) printf(s, a)
#define EV5_printf(s, a, b, c, d, e) printf(s, a, b, c, d, e)
#else
#define EV_nodeDisplay(l)
#define EV_printf(s)
#define EV1_printf(s, a)
#define EV5_printf(s, a, b, c, d, e)
#endif /* EXEC_EVALDEBUG */
/* ----------------
* scan debugging defines
* ----------------
*/
#ifdef EXEC_SCANDEBUG
#define S_nodeDisplay(l) nodeDisplay(l, 0)
#define S_printf(s) printf(s)
#define S1_printf(s, p) printf(s, p)
#else
#define S_nodeDisplay(l)
#define S_printf(s)
#define S1_printf(s, p)
#endif /* EXEC_SCANDEBUG */
/* ----------------
* sort node debugging defines
* ----------------
*/
#ifdef EXEC_SORTDEBUG
#define SO_nodeDisplay(l) nodeDisplay(l, 0)
#define SO_printf(s) printf(s)
#define SO1_printf(s, p) printf(s, p)
#else
#define SO_nodeDisplay(l)
#define SO_printf(s)
#define SO1_printf(s, p)
#endif /* EXEC_SORTDEBUG */
/* ----------------
* merge join debugging defines
* ----------------
*/
#ifdef EXEC_MERGEJOINDEBUG
#define MJ_nodeDisplay(l) nodeDisplay(l, 0)
#define MJ_printf(s) printf(s)
#define MJ1_printf(s, p) printf(s, p)
#define MJ2_printf(s, p1, p2) printf(s, p1, p2)
#define MJ_debugtup(tuple, type) debugtup(tuple, type)
#define MJ_dump(context, state) ExecMergeTupleDump(econtext, state)
#define MJ_DEBUG_QUAL(clause, res) \
MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
CppAsString(clause), T_OR_F(res));
#define MJ_DEBUG_MERGE_COMPARE(qual, res) \
MJ2_printf(" MergeCompare(mergeclauses, %s, ..) returns %s\n", \
CppAsString(qual), T_OR_F(res));
#define MJ_DEBUG_PROC_NODE(slot) \
MJ2_printf(" %s = ExecProcNode(innerPlan) returns %s\n", \
CppAsString(slot), NULL_OR_TUPLE(slot));
#else
#define MJ_nodeDisplay(l)
#define MJ_printf(s)
#define MJ1_printf(s, p)
#define MJ2_printf(s, p1, p2)
#define MJ_debugtup(tuple, type)
#define MJ_dump(context, state)
#define MJ_DEBUG_QUAL(clause, res)
#define MJ_DEBUG_MERGE_COMPARE(qual, res)
#define MJ_DEBUG_PROC_NODE(slot)
#endif /* EXEC_MERGEJOINDEBUG */
/* ----------------------------------------------------------------
* DO NOT DEFINE THESE EVER OR YOU WILL BURN!
* ----------------------------------------------------------------
*/
/* ----------------
* DOESNOTWORK is currently placed around memory manager
* code that is known to cause problems. Code in between
* is likely not converted and probably won't work anyways.
* ----------------
*/
#undef DOESNOTWORK
/* ----------------
* PERHAPSNEVER is placed around the "scan attribute"
* support code for the rule manager because for now we
* do things inefficiently. The correct solution to our
* problem is to add code to the parser/planner to save
* attribute information for the rule manager rather than
* have the executor have to grope through the entire plan
* for it so if we ever decide to make things better,
* we should probably delete the stuff in between PERHAPSNEVER..
* ----------------
*/
#undef PERHAPSNEVER
/* ----------------
* NOTYET is placed around any code not yet implemented
* in the executor. Only remove these when actually implementing
* said code.
* ----------------
*/
#undef NOTYET
extern long NDirectFileRead;
extern long NDirectFileWrite;
#endif /* ExecDebugIncluded */

View File

@@ -0,0 +1,47 @@
/*-------------------------------------------------------------------------
*
* execdefs.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: execdefs.h,v 1.1 1996/08/28 07:22:07 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef EXECDEFS_H
#define EXECDEFS_H
/* ----------------
* ExecutePlan() tuplecount definitions
* ----------------
*/
#define ALL_TUPLES 0 /* return all tuples */
#define ONE_TUPLE 1 /* return only one tuple */
/* ----------------
* constants used by ExecMain
* ----------------
*/
#define EXEC_RUN 3
#define EXEC_FOR 4
#define EXEC_BACK 5
#define EXEC_RETONE 6
#define EXEC_RESULT 7
/* ----------------
* Merge Join states
* ----------------
*/
#define EXEC_MJ_INITIALIZE 1
#define EXEC_MJ_JOINMARK 2
#define EXEC_MJ_JOINTEST 3
#define EXEC_MJ_JOINTUPLES 4
#define EXEC_MJ_NEXTOUTER 5
#define EXEC_MJ_TESTOUTER 6
#define EXEC_MJ_NEXTINNER 7
#define EXEC_MJ_SKIPINNER 8
#define EXEC_MJ_SKIPOUTER 9
#endif /* EXECDEFS_H */

View File

@@ -0,0 +1,38 @@
/*-------------------------------------------------------------------------
*
* execdesc.h--
* plan and query descriptor accessor macros used by the executor
* and related modules.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: execdesc.h,v 1.1 1996/08/28 07:22:08 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef EXECDESC_H
#define EXECDESC_H
#include "nodes/parsenodes.h"
#include "nodes/plannodes.h"
#include "tcop/dest.h"
/* ----------------
* query descriptor:
* a QueryDesc encapsulates everything that the executor
* needs to execute the query
* ---------------------
*/
typedef struct QueryDesc {
CmdType operation; /* CMD_SELECT, CMD_UPDATE, etc. */
Query *parsetree;
Plan *plantree;
CommandDest dest; /* the destination output of the execution */
} QueryDesc;
/* in pquery.c */
extern QueryDesc *CreateQueryDesc(Query *parsetree, Plan *plantree,
CommandDest dest);
#endif /* EXECDESC_H */

View File

@@ -0,0 +1,229 @@
/*-------------------------------------------------------------------------
*
* executor.h--
* support for the POSTGRES executor module
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: executor.h,v 1.1 1996/08/28 07:22:09 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef EXECUTOR_H
#define EXECUTOR_H
/* ----------------------------------------------------------------
* #includes
* ----------------------------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#include "postgres.h"
#include "nodes/pg_list.h"
/* ----------------
* executor debugging definitions are kept in a separate file
* so people can customize what debugging they want to see and not
* have this information clobbered every time a new version of
* executor.h is checked in -cim 10/26/89
* ----------------
*/
#include "executor/execdebug.h"
#include "access/heapam.h"
#include "access/htup.h"
#include "access/istrat.h"
#include "access/itup.h"
#include "access/skey.h"
#include "utils/tqual.h"
#include "catalog/catname.h"
#include "utils/syscache.h"
#include "executor/execdefs.h"
#include "executor/tuptable.h"
#include "nodes/parsenodes.h"
#include "storage/buf.h"
#include "miscadmin.h"
#include "fmgr.h"
#include "utils/elog.h"
#include "utils/mcxt.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "catalog/pg_index.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "catalog/pg_aggregate.h"
#include "access/printtup.h"
#include "nodes/primnodes.h"
#include "nodes/plannodes.h"
#include "nodes/execnodes.h"
#include "tcop/dest.h"
#include "storage/smgr.h"
#include "access/genam.h"
#include "executor/execdesc.h"
/*
* prototypes from functions in execAmi.c
*/
extern void ExecOpenScanR(Oid relOid, int nkeys, ScanKey skeys, bool isindex,
ScanDirection dir, TimeQual timeRange,
Relation *returnRelation, Pointer *returnScanDesc);
extern Relation ExecOpenR(Oid relationOid, bool isindex);
extern Pointer ExecBeginScan(Relation relation, int nkeys, ScanKey skeys,
bool isindex, ScanDirection dir, TimeQual time_range);
extern void ExecCloseR(Plan *node);
extern void ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent);
extern HeapScanDesc ExecReScanR(Relation relDesc, HeapScanDesc scanDesc,
ScanDirection direction, int nkeys, ScanKey skeys);
extern void ExecMarkPos(Plan *node);
extern void ExecRestrPos(Plan *node);
extern Relation ExecCreatR(TupleDesc tupType, Oid relationOid);
/*
* prototypes from functions in execJunk.c
*/
extern JunkFilter *ExecInitJunkFilter(List *targetList);
extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot,
char *attrName, Datum *value, bool *isNull);
extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
/*
* prototypes from functions in execMain.c
*/
extern TupleDesc ExecutorStart(QueryDesc *queryDesc, EState *estate);
extern TupleTableSlot* ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count);
extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate);
/*
* prototypes from functions in execProcnode.c
*/
extern bool ExecInitNode(Plan *node, EState *estate, Plan *parent);
extern TupleTableSlot *ExecProcNode(Plan *node, Plan *parent);
extern int ExecCountSlotsNode(Plan *node);
extern void ExecEndNode(Plan *node, Plan *parent);
/*
* prototypes from functions in execQual.c
*/
extern bool execConstByVal;
extern int execConstLen;
extern Datum ExecExtractResult(TupleTableSlot *slot, AttrNumber attnum,
bool *isNull);
extern Datum ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull);
extern Datum ExecEvalParam(Param *expression, ExprContext *econtext,
bool *isNull);
extern char *GetAttributeByNum(TupleTableSlot *slot, AttrNumber attrno,
bool *isNull);
extern char *att_by_num(TupleTableSlot *slot, AttrNumber attrno,
bool *isNull);
/* stop here */
extern char *GetAttributeByName(TupleTableSlot *slot, char *attname,
bool *isNull);
extern char *att_by_name(TupleTableSlot *slot, char *attname, bool *isNull);
extern void ExecEvalFuncArgs(FunctionCachePtr fcache, ExprContext *econtext,
List *argList, Datum argV[], bool *argIsDone);
extern Datum ExecMakeFunctionResult(Node *node, List *arguments,
ExprContext *econtext, bool *isNull, bool *isDone);
extern Datum ExecEvalOper(Expr *opClause, ExprContext *econtext,
bool *isNull);
extern Datum ExecEvalFunc(Expr *funcClause, ExprContext *econtext,
bool *isNull, bool *isDone);
extern Datum ExecEvalNot(Expr *notclause, ExprContext *econtext, bool *isNull);
extern Datum ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull);
extern Datum ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull);
extern Datum ExecEvalExpr(Node *expression, ExprContext *econtext, bool *isNull,
bool *isDone);
extern bool ExecQualClause(Node *clause, ExprContext *econtext);
extern bool ExecQual(List *qual, ExprContext *econtext);
extern int ExecTargetListLength(List *targetlist);
extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo, bool *isDone);
/*
* prototypes from functions in execScan.c
*/
extern TupleTableSlot *ExecScan(Scan *node, TupleTableSlot* (*accessMtd)());
/*
* prototypes from functions in execTuples.c
*/
extern TupleTable ExecCreateTupleTable(int initialSize);
extern void ExecDestroyTupleTable(TupleTable table, bool shouldFree);
extern TupleTableSlot* ExecAllocTableSlot(TupleTable table);
extern TupleTableSlot* ExecStoreTuple(HeapTuple tuple,
TupleTableSlot *slot,
Buffer buffer,
bool shouldFree);
extern TupleTableSlot* ExecClearTuple(TupleTableSlot* slot);
extern bool ExecSlotPolicy(TupleTableSlot *slot);
extern bool ExecSetSlotPolicy(TupleTableSlot *slot, bool shouldFree);
extern TupleDesc ExecSetSlotDescriptor(TupleTableSlot *slot,
TupleDesc tupdesc);
extern void ExecSetSlotDescriptorIsNew(TupleTableSlot *slot, bool isNew);
extern TupleDesc ExecSetNewSlotDescriptor(TupleTableSlot *slot,
TupleDesc tupdesc);
extern Buffer ExecSetSlotBuffer(TupleTableSlot *slot, Buffer b);
extern void ExecIncrSlotBufferRefcnt(TupleTableSlot *slot);
extern bool TupIsNull(TupleTableSlot* slot);
extern bool ExecSlotDescriptorIsNew(TupleTableSlot *slot);
extern void ExecInitResultTupleSlot(EState *estate, CommonState *commonstate);
extern void ExecInitScanTupleSlot(EState *estate,
CommonScanState *commonscanstate);
extern void ExecInitMarkedTupleSlot(EState *estate, MergeJoinState *mergestate);
extern void ExecInitOuterTupleSlot(EState *estate, HashJoinState *hashstate);
extern void ExecInitHashTupleSlot(EState *estate, HashJoinState *hashstate);
extern TupleTableSlot *NodeGetResultTupleSlot(Plan *node);
extern TupleDesc ExecGetTupType(Plan *node);
extern TupleDesc ExecTypeFromTL(List *targetList);
/*
* prototypes from functions in execTuples.c
*/
extern void ResetTupleCount();
extern void DisplayTupleCount(FILE *statfp);
extern void ExecAssignNodeBaseInfo(EState *estate, CommonState *basenode,
Plan *parent);
extern void ExecAssignExprContext(EState *estate, CommonState *commonstate);
extern void ExecAssignResultType(CommonState *commonstate,
TupleDesc tupDesc);
extern void ExecAssignResultTypeFromOuterPlan(Plan *node,
CommonState *commonstate);
extern void ExecAssignResultTypeFromTL(Plan *node, CommonState *commonstate);
extern TupleDesc ExecGetResultType(CommonState *commonstate);
extern void ExecFreeResultType(CommonState *commonstate);
extern void ExecAssignProjectionInfo(Plan *node, CommonState *commonstate);
extern void ExecFreeProjectionInfo(CommonState *commonstate);
extern TupleDesc ExecGetScanType(CommonScanState *csstate);
extern void ExecFreeScanType(CommonScanState *csstate);
extern void ExecAssignScanType(CommonScanState *csstate,
TupleDesc tupDesc);
extern void ExecAssignScanTypeFromOuterPlan(Plan *node,
CommonScanState *csstate);
extern AttributeTupleForm ExecGetTypeInfo(Relation relDesc);
extern void ExecGetIndexKeyInfo(IndexTupleForm indexTuple, int *numAttsOutP,
AttrNumber **attsOutP, FuncIndexInfoPtr fInfoP);
extern void ExecOpenIndices(Oid resultRelationOid,
RelationInfo *resultRelationInfo);
extern void ExecCloseIndices(RelationInfo *resultRelationInfo);
extern IndexTuple ExecFormIndexTuple(HeapTuple heapTuple,
Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo);
extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
EState *estate);
/* ----------------------------------------------------------------
* the end
* ----------------------------------------------------------------
*/
#endif /* EXECUTOR_H */

View File

@@ -0,0 +1,22 @@
/*-------------------------------------------------------------------------
*
* functions.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: functions.h,v 1.1 1996/08/28 07:22:12 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
extern Datum ProjectAttribute(TupleDesc TD, TargetEntry *tlist,
HeapTuple tup, bool *isnullP);
extern Datum postquel_function(Func *funcNode, char **args,
bool *isNull, bool *isDone);
#endif /* FUNCTIONS_H */

View File

@@ -0,0 +1,82 @@
/*-------------------------------------------------------------------------
*
* hashjoin.h--
* internal structures for hash table and buckets
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: hashjoin.h,v 1.1 1996/08/28 07:22:13 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef HASHJOIN_H
#define HASHJOIN_H
#include "access/htup.h"
#include "storage/ipc.h"
/* -----------------
* have to use relative address as pointers in the hashtable
* because the hashtable may reallocate in difference processes
* -----------------
*/
typedef int RelativeAddr;
/* ------------------
* the relative addresses are always relative to the head of the
* hashtable, the following macro converts them to absolute address.
* ------------------
*/
#define ABSADDR(X) ((X) < 0 ? NULL: (char*)hashtable + X)
#define RELADDR(X) (RelativeAddr)((char*)(X) - (char*)hashtable)
typedef char **charPP;
typedef int *intP;
/* ----------------------------------------------------------------
* hash-join hash table structures
* ----------------------------------------------------------------
*/
typedef struct HashTableData {
int nbuckets;
int totalbuckets;
int bucketsize;
IpcMemoryId shmid;
RelativeAddr top; /* char* */
RelativeAddr bottom; /* char* */
RelativeAddr overflownext; /* char* */
RelativeAddr batch; /* char* */
RelativeAddr readbuf; /* char* */
int nbatch;
RelativeAddr outerbatchNames; /* RelativeAddr* */
RelativeAddr outerbatchPos; /* RelativeAddr* */
RelativeAddr innerbatchNames; /* RelativeAddr* */
RelativeAddr innerbatchPos; /* RelativeAddr* */
RelativeAddr innerbatchSizes; /* int* */
int curbatch;
int nprocess;
int pcount;
} HashTableData; /* real hash table follows here */
typedef HashTableData *HashJoinTable;
typedef struct OverflowTupleData {
RelativeAddr tuple; /* HeapTuple */
RelativeAddr next; /* struct OverflowTupleData * */
} OverflowTupleData; /* real tuple follows here */
typedef OverflowTupleData *OverflowTuple;
typedef struct HashBucketData {
RelativeAddr top; /* HeapTuple */
RelativeAddr bottom; /* HeapTuple */
RelativeAddr firstotuple; /* OverflowTuple */
RelativeAddr lastotuple; /* OverflowTuple */
} HashBucketData; /* real bucket follows here */
typedef HashBucketData *HashBucket;
#define HASH_PERMISSION 0700
#endif /* HASHJOIN_H */

View File

@@ -0,0 +1,21 @@
/*-------------------------------------------------------------------------
*
* nodeAgg.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeAgg.h,v 1.1 1996/08/28 07:22:14 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEAGG_H
#define NODEAGG_H
extern TupleTableSlot *ExecAgg(Agg *node);
extern bool ExecInitAgg(Agg *node, EState *estate, Plan *parent);
extern int ExecCountSlotsAgg(Agg *node);
extern void ExecEndAgg(Agg *node);
#endif /* NODEAGG_H */

View File

@@ -0,0 +1,22 @@
/*-------------------------------------------------------------------------
*
* nodeAppend.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeAppend.h,v 1.1 1996/08/28 07:22:15 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEAPPEND_H
#define NODEAPPEND_H
extern bool exec_append_initialize_next(Append *node);
extern bool ExecInitAppend(Append *node, EState *estate, Plan *parent);
extern int ExecCountSlotsAppend(Append *node);
extern TupleTableSlot *ExecProcAppend(Append *node);
extern void ExecEndAppend(Append *node);
#endif /* NODEAPPEND_H */

View File

@@ -0,0 +1,21 @@
/*-------------------------------------------------------------------------
*
* nodeGroup.h--
* prototypes for nodeGroup.c
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeGroup.h,v 1.1 1996/08/28 07:22:17 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEGROUP_H
#define NODEGROUP_H
extern TupleTableSlot *ExecGroup(Group *node);
extern bool ExecInitGroup(Group *node, EState *estate, Plan *parent);
extern int ExecCountSlotsGroup(Group *node);
extern void ExecEndGroup(Group *node);
#endif /* NODEGROUP_H */

View File

@@ -0,0 +1,35 @@
/*-------------------------------------------------------------------------
*
* nodeHash.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeHash.h,v 1.1 1996/08/28 07:22:18 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEHASH_H
#define NODEHASH_H
extern TupleTableSlot *ExecHash(Hash *node);
extern bool ExecInitHash(Hash *node, EState *estate, Plan *parent);
extern int ExecCountSlotsHash(Hash *node);
extern void ExecEndHash(Hash *node);
extern RelativeAddr hashTableAlloc(int size, HashJoinTable hashtable);
extern HashJoinTable ExecHashTableCreate(Hash *node);
extern void ExecHashTableInsert(HashJoinTable hashtable, ExprContext *econtext,
Var *hashkey, File *batches);
extern void ExecHashTableDestroy(HashJoinTable hashtable);
extern int ExecHashGetBucket(HashJoinTable hashtable, ExprContext *econtext,
Var *hashkey);
extern void ExecHashOverflowInsert(HashJoinTable hashtable, HashBucket bucket,
HeapTuple heapTuple);
extern HeapTuple ExecScanHashBucket(HashJoinState *hjstate, HashBucket bucket,
HeapTuple curtuple, List *hjclauses,
ExprContext *econtext);
extern int ExecHashPartition(Hash *node);
extern void ExecHashTableReset(HashJoinTable hashtable, int ntuples);
#endif /* NODEHASH_H */

View File

@@ -0,0 +1,33 @@
/*-------------------------------------------------------------------------
*
* nodeHashjoin.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeHashjoin.h,v 1.1 1996/08/28 07:22:19 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEHASHJOIN_H
#define NODEHASHJOIN_H
extern TupleTableSlot *ExecHashJoin(HashJoin *node);
extern bool ExecInitHashJoin(HashJoin *node, EState *estate, Plan *parent);
extern int ExecCountSlotsHashJoin(HashJoin *node);
extern void ExecEndHashJoin(HashJoin *node);
extern int ExecHashJoinNewBatch(HashJoinState *hjstate);
extern char *ExecHashJoinSaveTuple(HeapTuple heapTuple, char *buffer,
File file, char *position);
extern int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable,
int nbatch);
#endif /* NODEHASHJOIN_H */

View File

@@ -0,0 +1,32 @@
/*-------------------------------------------------------------------------
*
* nodeIndexscan.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeIndexscan.h,v 1.1 1996/08/28 07:22:20 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEINDEXSCAN_H
#define NODEINDEXSCAN_H
extern TupleTableSlot *ExecIndexScan(IndexScan *node);
extern void ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent);
extern void ExecEndIndexScan(IndexScan *node);
extern void ExecIndexMarkPos(IndexScan *node);
extern void ExecIndexRestrPos(IndexScan *node);
extern void ExecUpdateIndexScanKeys(IndexScan *node, ExprContext *econtext);
extern bool ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent);
extern int ExecCountSlotsIndexScan(IndexScan *node);
#endif /* NODEINDEXSCAN_H */

View File

@@ -0,0 +1,23 @@
/*-------------------------------------------------------------------------
*
* nodeMaterial.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeMaterial.h,v 1.1 1996/08/28 07:22:21 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEMATERIAL_H
#define NODEMATERIAL_H
extern TupleTableSlot *ExecMaterial(Material *node);
extern bool ExecInitMaterial(Material *node, EState *estate, Plan *parent);
extern int ExecCountSlotsMaterial(Material *node);
extern void ExecEndMaterial(Material *node);
extern List ExecMaterialMarkPos(Material *node);
extern void ExecMaterialRestrPos(Material *node);
#endif /* NODEMATERIAL_H */

View File

@@ -0,0 +1,40 @@
/*-------------------------------------------------------------------------
*
* nodeMergejoin.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeMergejoin.h,v 1.1 1996/08/28 07:22:22 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEMERGEJOIN_H
#define NODEMERGEJOIN_H
#if 0 /* aren't these static? */
extern List MJFormOSortopI(List qualList, Oid sortOp);
extern List MJFormISortopO(List qualList, Oid sortOp);
#endif
extern bool MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext);
extern void ExecMergeTupleDumpInner(ExprContext *econtext);
extern void ExecMergeTupleDumpOuter(ExprContext *econtext);
extern void ExecMergeTupleDumpMarked(ExprContext *econtext,
MergeJoinState *mergestate);
extern void ExecMergeTupleDump(ExprContext *econtext,
MergeJoinState *mergestate);
extern TupleTableSlot *ExecMergeJoin(MergeJoin *node);
extern bool ExecInitMergeJoin(MergeJoin *node, EState *estate, Plan *parent);
extern int ExecCountSlotsMergeJoin(MergeJoin *node);
extern void ExecEndMergeJoin(MergeJoin *node);
#endif /* NODEMERGEJOIN_H; */

View File

@@ -0,0 +1,21 @@
/*-------------------------------------------------------------------------
*
* nodeNestloop.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeNestloop.h,v 1.1 1996/08/28 07:22:23 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODENESTLOOP_H
#define NODENESTLOOP_H
extern TupleTableSlot *ExecNestLoop(NestLoop *node, Plan *parent);
extern bool ExecInitNestLoop(NestLoop *node, EState *estate, Plan *parent);
extern int ExecCountSlotsNestLoop(NestLoop *node);
extern void ExecEndNestLoop(NestLoop *node);
#endif /* NODENESTLOOP_H */

View File

@@ -0,0 +1,21 @@
/*-------------------------------------------------------------------------
*
* nodeResult.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeResult.h,v 1.1 1996/08/28 07:22:24 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODERESULT_H
#define NODERESULT_H
extern TupleTableSlot *ExecResult(Result *node);
extern bool ExecInitResult(Result *node, EState *estate, Plan *parent);
extern int ExecCountSlotsResult(Result *node);
extern void ExecEndResult(Result *node);
#endif /* NODERESULT_H */

View File

@@ -0,0 +1,27 @@
/*-------------------------------------------------------------------------
*
* nodeSeqscan.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeSeqscan.h,v 1.1 1996/08/28 07:22:24 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODESEQSCAN_H
#define NODESEQSCAN_H
extern TupleTableSlot *SeqNext(SeqScan *node);
extern TupleTableSlot *ExecSeqScan(SeqScan *node);
extern Oid InitScanRelation(SeqScan *node, EState *estate,
CommonScanState *scanstate, Plan *outerPlan);
extern bool ExecInitSeqScan(SeqScan *node, EState *estate, Plan *parent);
extern int ExecCountSlotsSeqScan(SeqScan *node);
extern void ExecEndSeqScan(SeqScan *node);
extern void ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan* parent);
extern void ExecSeqMarkPos(SeqScan *node);
extern void ExecSeqRestrPos(SeqScan *node);
#endif /* NODESEQSCAN_H */

View File

@@ -0,0 +1,23 @@
/*-------------------------------------------------------------------------
*
* nodeSort.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeSort.h,v 1.1 1996/08/28 07:22:25 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODESORT_H
#define NODESORT_H
extern TupleTableSlot *ExecSort(Sort *node);
extern bool ExecInitSort(Sort *node, EState *estate, Plan *parent);
extern int ExecCountSlotsSort(Sort *node);
extern void ExecEndSort(Sort *node);
extern void ExecSortMarkPos(Sort *node);
extern void ExecSortRestrPos(Sort *node);
#endif /* NODESORT_H */

View File

@@ -0,0 +1,22 @@
/*-------------------------------------------------------------------------
*
* nodeTee.h--
* support functions for a Tee executor node
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeTee.h,v 1.1 1996/08/28 07:22:26 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODETEE_H
#define NODETEE_H
extern TupleTableSlot* ExecTee(Tee* node, Plan* parent);
extern bool ExecInitTee(Tee* node, EState* estate, Plan* parent);
extern void ExecTeeReScan(Tee *node, ExprContext *exprCtxt, Plan *parent);
extern void ExecEndTee(Tee* node, Plan* parent);
extern int ExecCountSlotsTee(Tee* node);
#endif /* NODETEE_H */

View File

@@ -0,0 +1,21 @@
/*-------------------------------------------------------------------------
*
* nodeUnique.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeUnique.h,v 1.1 1996/08/28 07:22:27 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef NODEUNIQUE_H
#define NODEUNIQUE_H
extern TupleTableSlot *ExecUnique(Unique *node);
extern bool ExecInitUnique(Unique *node, EState *estate, Plan *parent);
extern int ExecCountSlotsUnique(Unique *node);
extern void ExecEndUnique(Unique *node);
#endif /* NODEUNIQUE_H */

View File

@@ -0,0 +1,72 @@
/*-------------------------------------------------------------------------
*
* tuptable.h--
* tuple table support stuff
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: tuptable.h,v 1.1 1996/08/28 07:22:28 scrappy Exp $
*
* NOTES
* The tuple table interface is getting pretty ugly.
* It should be redesigned soon.
*
*-------------------------------------------------------------------------
*/
#ifndef TUPTABLE_H
#define TUPTABLE_H
/* ----------------
* Note: the executor tuple table is managed and manipulated by special
* code and macros in executor/execTuples.c and tupTable.h
*
* TupleTableSlot information
*
* shouldFree boolean - should we call pfree() on tuple
* descIsNew boolean - true when tupleDescriptor changes
* tupleDescriptor type information kept regarding the tuple data
* buffer the buffer for tuples pointing to disk pages
*
* The executor stores pointers to tuples in a ``tuple table''
* which is composed of TupleTableSlot's. Some of the tuples
* are pointers to buffer pages and others are pointers to
* palloc'ed memory and the shouldFree variable tells us when
* we may call pfree() on a tuple. -cim 9/23/90
*
* In the implementation of nested-dot queries such as
* "retrieve (EMP.hobbies.all)", a single scan may return tuples
* of many types, so now we return pointers to tuple descriptors
* along with tuples returned via the tuple table. -cim 1/18/90
* ----------------
*/
typedef struct TupleTableSlot {
NodeTag type;
HeapTuple val;
bool ttc_shouldFree;
bool ttc_descIsNew;
TupleDesc ttc_tupleDescriptor;
Buffer ttc_buffer;
int ttc_whichplan;
} TupleTableSlot;
/* ----------------
* tuple table data structure
* ----------------
*/
typedef struct TupleTableData {
int size; /* size of the table */
int next; /* next available slot number */
TupleTableSlot *array; /* array of TupleTableSlot's */
} TupleTableData;
typedef TupleTableData *TupleTable;
/*
tuple table macros are all excised from the system now
see executor.h for decls of functions defined in execTuples.c
- jolly
*/
#endif /* TUPTABLE_H */

72
src/include/lib/dllist.h Normal file
View File

@@ -0,0 +1,72 @@
/*-------------------------------------------------------------------------
*
* dllist.h--
* simple doubly linked list primitives
* the elements of the list are void* so the lists can contain
* anything
* Dlelem can only be in one list at a time
*
*
* Here's a small example of how to use Dllist's :
*
* Dllist *lst;
* Dlelem *elt;
* void *in_stuff; -- stuff to stick in the list
* void *out_stuff
*
* lst = DLNewList(); -- make a new dllist
* DLAddHead(lst, DLNewElem(in_stuff)); -- add a new element to the list
* with in_stuff as the value
* ...
* elt = DLGetHead(lst); -- retrieve the head element
* out_stuff = (void*)DLE_VAL(elt); -- get the stuff out
* DLRemove(elt); -- removes the element from its list
* DLFreeElem(elt); -- free the element since we don't
* use it anymore
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: dllist.h,v 1.1 1996/08/28 07:22:36 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef DLLIST_H
#define DLLIST_H
#include "c.h"
struct Dllist;
struct Dlelem;
typedef struct Dlelem {
struct Dlelem *dle_next; /* next element */
struct Dlelem *dle_prev; /* previous element */
void *dle_val; /* value of the element */
struct Dllist *dle_list; /* what list this element is in */
} Dlelem;
typedef struct Dllist {
Dlelem *dll_head;
Dlelem *dll_tail;
} Dllist;
extern Dllist* DLNewList(); /* initialize a new list */
extern void DLFreeList(Dllist*); /* free up a list and all the nodes in it*/
extern Dlelem* DLNewElem(void* val);
extern void DLFreeElem(Dlelem*);
extern Dlelem* DLGetHead(Dllist*);
extern Dlelem* DLGetTail(Dllist*);
extern void* DLGetHeadVal(Dllist*);
extern void* DLGetTailVal(Dllist*);
extern Dlelem* DLGetPred(Dlelem*); /* get predecessor */
extern Dlelem* DLGetSucc(Dlelem*); /* get successor */
extern void DLRemove(Dlelem*); /* removes node from list*/
extern void DLAddHead(Dllist* list, Dlelem* node);
extern void DLAddTail(Dllist* list, Dlelem* node);
extern Dlelem* DLRemHead(Dllist* list); /* remove and return the head */
extern Dlelem* DLRemTail(Dllist* list); /* remove and return the tail */
#define DLE_VAL(x) (x->dle_val)
#endif /* DLLIST_H */

113
src/include/lib/fstack.h Normal file
View File

@@ -0,0 +1,113 @@
/*-------------------------------------------------------------------------
*
* fstack.h--
* Fixed format stack definitions.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: fstack.h,v 1.1 1996/08/28 07:22:37 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Note:
* Fixed format stacks assist in the construction of FIFO stacks of
* fixed format structures. Structures which are to be stackable
* should contain a FixedItemData component. A stack is initilized
* with the offset of the FixedItemData component of the structure
* it will hold. By doing so, push and pop operations are simplified
* for the callers. All references to stackable items are pointers
* to the base of the structure instead of pointers to the
* FixedItemData component.
*
*/
#ifndef FSTACK_H
#define FSTACK_H
#include "c.h"
/*
* FixedItem --
* Fixed format stackable item chain component.
*
* Note:
* Structures must contain one FixedItemData component per stack in
* which it will be an item.
*/
typedef struct FixedItemData FixedItemData;
typedef FixedItemData *FixedItem;
struct FixedItemData {
FixedItem next; /* next item or NULL */
};
/*
* FixedStack --
* Fixed format stack.
*/
typedef struct FixedStackData {
FixedItem top; /* Top item on the stack or NULL */
Offset offset; /* Offset from struct base to item */
/* this could be signed short int! */
} FixedStackData;
typedef FixedStackData *FixedStack;
/*
* FixedStackInit --
* Iniitializes stack for structures with given fixed component offset.
*
* Exceptions:
* BadArg if stack is invalid pointer.
*/
extern void FixedStackInit(FixedStack stack, Offset offset);
/*
* FixedStackPop --
* Returns pointer to top structure on stack or NULL if empty stack.
*
* Exceptions:
* BadArg if stack is invalid.
*/
Pointer FixedStackPop(FixedStack stack);
/*
* FixedStackPush --
* Places structure associated with pointer onto top of stack.
*
* Exceptions:
* BadArg if stack is invalid.
* BadArg if pointer is invalid.
*/
extern void FixedStackPush(FixedStack stack, Pointer pointer);
/*
* FixedStackGetTop --
* Returns pointer to top structure of a stack. This item is not poped.
*
* Note:
* This is not part of the normal stack interface. It is intended for
* debugging use only.
*
* Exceptions:
* BadArg if stack is invalid.
*/
extern Pointer FixedStackGetTop(FixedStack stack);
/*
* FixedStackGetNext --
* Returns pointer to next structure after pointer of a stack.
*
* Note:
* This is not part of the normal stack interface. It is intended for
* debugging use only.
*
* Exceptions:
* BadArg if stack is invalid.
* BadArg if pointer is invalid.
* BadArg if stack does not contain pointer.
*/
extern Pointer FixedStackGetNext(FixedStack stack, Pointer pointer);
#endif /* FSTACK_H */

23
src/include/lib/hasht.h Normal file
View File

@@ -0,0 +1,23 @@
/*-------------------------------------------------------------------------
*
* hasht.h--
* hash table related functions that are not directly supported
* under utils/hash.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: hasht.h,v 1.1 1996/08/28 07:22:38 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef HASHT_H
#define HASHT_H
#include "utils/hsearch.h"
typedef void (*HashtFunc)();
extern void HashTableWalk(HTAB *hashtable, HashtFunc function, int arg);
#endif /* HASHT_H */

View File

@@ -0,0 +1,18 @@
/*-------------------------------------------------------------------------
*
* lispsort.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: lispsort.h,v 1.1 1996/08/28 07:22:39 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef LISPSORT_H
#define LISPSORT_H
extern List *lisp_qsort(List *the_list, int (*compare)());
#endif /* LISPSORT_H */

24
src/include/lib/qsort.h Normal file
View File

@@ -0,0 +1,24 @@
/*-------------------------------------------------------------------------
*
* qsort.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: qsort.h,v 1.1 1996/08/28 07:22:40 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef QSORT_H
#define QSORT_H
#include <sys/types.h>
extern void pg_qsort(void *bot,
size_t nmemb,
size_t size,
int (*compar)(void *, void *));
#endif /* QSORT_H */

View File

@@ -0,0 +1,47 @@
/*-------------------------------------------------------------------------
*
* stringinfo.h--
* Declarations/definitons for "string" functions.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: stringinfo.h,v 1.1 1996/08/28 07:22:41 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef STRINGINFO_H
#define STRINGINFO_H
/*#include "c.h" */ /* for 'String' */
/*-------------------------
* StringInfoData holds information about a string.
* 'data' is the string.
* 'len' is the current string length (as returned by 'strlen')
* 'maxlen' is the size in bytes of 'data', i.e. the maximum string
* size (includeing the terminating '\0' char) that we can
* currently store in 'data' without having to reallocate
* more space.
*/
typedef struct StringInfoData {
char *data;
int maxlen;
int len;
} StringInfoData;
typedef StringInfoData *StringInfo;
/*------------------------
* makeStringInfo
* create a 'StringInfoData' & return a pointer to it.
*/
extern StringInfo makeStringInfo(void);
/*------------------------
* appendStringInfo
* similar to 'strcat' but reallocates more space if necessary...
*/
extern void appendStringInfo(StringInfo str, char *buffer);
#endif /* STRINGINFO_H */

49
src/include/libpq/auth.h Normal file
View File

@@ -0,0 +1,49 @@
/*-------------------------------------------------------------------------
*
* auth.h--
* Definitions for network authentication routines
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: auth.h,v 1.1 1996/08/28 07:22:50 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef AUTH_H
#define AUTH_H
#include "c.h"
#include "libpq/pqcomm.h"
/*----------------------------------------------------------------
* Common routines and definitions
*----------------------------------------------------------------
*/
/* what we call "no authentication system" */
#define UNAUTHNAME "unauth"
/* what a frontend uses by default */
#if !defined(KRB4) && !defined(KRB5)
#define DEFAULT_CLIENT_AUTHSVC UNAUTHNAME
#else /* KRB4 || KRB5 */
#define DEFAULT_CLIENT_AUTHSVC "kerberos"
#endif /* KRB4 || KRB5 */
extern int fe_sendauth(MsgType msgtype, Port *port, char *hostname);
extern void fe_setauthsvc(char *name);
extern MsgType fe_getauthsvc();
extern char *fe_getauthname(void);
extern int be_recvauth(MsgType msgtype, Port *port, char *username, StartupInfo* sp);
extern void be_setauthsvc(char *name);
extern int be_getauthsvc(MsgType msgtype);
/* the value that matches any dbName value when doing
host based authentication*/
#define ALL_DBNAME "*"
#define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */
#define PG_KRB5_VERSION "PGVER5.1"
#endif /* AUTH_H */

View File

@@ -0,0 +1,32 @@
/*-------------------------------------------------------------------------
*
* be-fsstubs.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: be-fsstubs.h,v 1.1 1996/08/28 07:22:56 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef BE_FSSTUBS_H
#define BE_FSSTUBS_H
extern Oid lo_import(text *filename);
extern int4 lo_export(Oid lobjId, text *filename);
extern Oid lo_creat(int mode);
extern int lo_open(Oid lobjId, int mode);
extern int lo_close(int fd);
extern int lo_read(int fd, char *buf, int len);
extern int lo_write(int fd, char *buf, int len);
extern int lo_lseek(int fd, int offset, int whence);
extern int lo_tell(int fd);
extern int lo_unlink(Oid lobjId);
extern struct varlena *LOread(int fd, int len);
extern int LOwrite(int fd, struct varlena *wbuf);
#endif /* BE_FSSTUBS_H */

View File

@@ -0,0 +1,51 @@
/*-------------------------------------------------------------------------
*
* libpq-be.h--
* This file contains definitions for structures and
* externs for functions used by the POSTGRES backend.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-be.h,v 1.1 1996/08/28 07:22:59 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef LIBPQ_BE_H
#define LIBPQ_BE_H
/* ----------------
* include stuff common to fe and be
* ----------------
*/
#include "libpq/libpq.h"
#include "access/htup.h"
#include "access/tupdesc.h"
/* ----------------
* declarations for backend libpq support routines
* ----------------
*/
/* in be-dumpdata.c */
extern void be_portalinit(void);
extern void be_portalpush(PortalEntry *entry);
extern PortalEntry *be_portalpop(void);
extern PortalEntry *be_currentportal();
extern PortalEntry *be_newportal(void);
extern void be_typeinit(PortalEntry *entry, TupleDesc attrs,
int natts);
extern void be_printtup(HeapTuple tuple, TupleDesc typeinfo);
/* in be-pqexec.c */
extern char *PQfn(int fnid, int *result_buf, int result_len, int result_is_int,
PQArgBlock *args, int nargs);
extern char *PQexec(char *query);
extern int pqtest_PQexec(char *q);
extern char *strmake(char *str, int len);
extern int pqtest_PQfn(char *q);
extern int32 pqtest(struct varlena *vlena);
#endif /* LIBPQ_BE_H */

View File

@@ -0,0 +1,119 @@
/*-------------------------------------------------------------------------
*
* libpq-fs.h--
* definitions for using Inversion file system routines
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-fs.h,v 1.1 1996/08/28 07:23:00 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef LIBPQ_FS_H
#define LIBPQ_FS_H
#include "lib/dllist.h"
#include <sys/file.h>
#include <sys/stat.h>
#include <fcntl.h> /* for O_ on some */
#ifndef WIN32
#include <unistd.h> /* for SEEK_ on most */
#endif /* WIN32 */
#ifndef SEEK_SET
#include <stdio.h> /* for SEEK_ on others */
#endif /* SEEK_SET */
/* UNIX compatibility junk. This should be in all systems' include files,
but this is not always the case. */
#ifndef MAXNAMLEN
#define MAXNAMLEN 255
#endif /* MAXNAMLEN */
struct pgdirent {
unsigned long d_ino;
unsigned short d_namlen;
char d_name[MAXNAMLEN+1];
};
/*
* SysV struct dirent doesn't have d_namlen.
* This counts on d_name being last, which is moderately safe (ha) since
* it's the variable-length part of the structure.
*/
#ifdef SYSV_DIRENT
#define D_NAMLEN(dp) \
((dp)->d_reclen - offsetof(struct dirent, d_name[0]))
#else /* SYSV_DIRENT */
#define D_NAMLEN(dp) \
((dp)->d_namlen)
#endif /* SYSV_DIRENT */
/* for stat(2) */
#ifndef S_IRUSR
/* file modes */
#define S_IRWXU 00700 /* read, write, execute: owner */
#define S_IRUSR 00400 /* read permission: owner */
#define S_IWUSR 00200 /* write permission: owner */
#define S_IXUSR 00100 /* execute permission: owner */
#define S_IRWXG 00070 /* read, write, execute: group */
#define S_IRGRP 00040 /* read permission: group */
#define S_IWGRP 00020 /* write permission: group */
#define S_IXGRP 00010 /* execute permission: group */
#define S_IRWXO 00007 /* read, write, execute: other */
#define S_IROTH 00004 /* read permission: other */
#define S_IWOTH 00002 /* write permission: other */
#define S_IXOTH 00001 /* execute permission: other */
#define _S_IFMT 0170000 /* type of file; sync with S_IFMT */
#define _S_IFBLK 0060000 /* block special; sync with S_IFBLK */
#define _S_IFCHR 0020000 /* character special sync with S_IFCHR */
#define _S_IFDIR 0040000 /* directory; sync with S_IFDIR */
#define _S_IFIFO 0010000 /* FIFO - named pipe; sync with S_IFIFO */
#define _S_IFREG 0100000 /* regular; sync with S_IFREG */
#define S_IFDIR _S_IFDIR
#define S_IFREG _S_IFREG
#define S_ISDIR( mode ) (((mode) & _S_IFMT) == _S_IFDIR)
#endif /* S_IRUSR */
/*
* Inversion doesn't have links.
*/
#ifndef S_ISLNK
#define S_ISLNK(x) 0
#endif
/*
* Flags for inversion file system large objects. Normally, creat()
* takes mode arguments, but we don't use them in inversion, since
* you get postgres protections. Instead, we use the low sixteen bits
* of the integer mode argument to store the number of the storage
* manager to be used, and the high sixteen bits for flags.
*/
#define INV_SMGRMASK 0x0000ffff
#define INV_ARCHIVE 0x00010000
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
/* Error values for p_errno */
#define PEPERM 1 /* Not owner */
#define PENOENT 2 /* No such file or directory */
#define PEACCES 13 /* Permission denied */
#define PEEXIST 17 /* File exists */
#define PENOTDIR 20 /* Not a directory*/
#define PEISDIR 21 /* Is a directory */
#define PEINVAL 22 /* Invalid argument */
#define PENAMETOOLONG 63 /* File name too long */
#define PENOTEMPTY 66 /* Directory not empty */
#define PEPGIO 99 /* postgres backend had problems */
#endif /* LIBPQ_FS_H */

261
src/include/libpq/libpq.h Normal file
View File

@@ -0,0 +1,261 @@
/*-------------------------------------------------------------------------
*
* libpq.h--
* POSTGRES LIBPQ buffer structure definitions.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq.h,v 1.1 1996/08/28 07:23:01 scrappy Exp $
*
* NOTES
* This file contains definitions for structures and
* externs for functions used by both frontend applications
* and the POSTGRES backend. See the files libpq-fe.h and
* libpq-be.h for frontend/backend specific information
*
*-------------------------------------------------------------------------
*/
#ifndef LIBPQ_H
#define LIBPQ_H
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifdef WIN32
#include <winsock.h>
#else
#include <netinet/in.h>
#endif /* WIN32 */
#include "lib/dllist.h"
#include "utils/exc.h"
#include "postgres.h"
#include "libpq/pqcomm.h"
/* ----------------
* PQArgBlock --
* Information (pointer to array of this structure) required
* for the PQfn() call.
* ----------------
*/
typedef struct {
int len;
int isint;
union {
int *ptr; /* can't use void (dec compiler barfs) */
int integer;
} u;
} PQArgBlock;
/* ----------------
* TypeBlock --
* Information about an attribute.
* ----------------
*/
#define NameLength 16
typedef struct TypeBlock {
char name[NAMEDATALEN]; /* name of the attribute */
int adtid; /* adtid of the type */
int adtsize; /* adtsize of the type */
} TypeBlock;
/* ----------------
* TupleBlock --
* Data of a tuple.
* ----------------
*/
#define TupleBlockSize 100
typedef struct TupleBlock {
char **values[TupleBlockSize]; /* an array of tuples */
int *lengths[TupleBlockSize]; /* an array of length vec. foreach
tuple */
struct TupleBlock *next; /* next tuple block */
int tuple_index; /* current tuple index */
} TupleBlock;
/* ----------------
* GroupBuffer --
* A group of tuples with the same attributes.
* ----------------
*/
typedef struct GroupBuffer {
int no_tuples; /* number of tuples in this group */
int no_fields; /* number of attributes */
TypeBlock *types; /* types of the attributes */
TupleBlock *tuples; /* tuples in this group */
struct GroupBuffer *next; /* next group */
} GroupBuffer;
/* ----------------
* PortalBuffer --
* Data structure of a portal buffer.
* ----------------
*/
typedef struct PortalBuffer {
int rule_p; /* 1 if this is an asynchronized portal. */
int no_tuples; /* number of tuples in this portal buffer */
int no_groups; /* number of tuple groups */
GroupBuffer *groups; /* linked list of tuple groups */
} PortalBuffer;
/* ----------------
* PortalEntry --
* an entry in the global portal table
*
* Note: the portalcxt is only meaningful for PQcalls made from
* within a postgres backend. frontend apps should ignore it.
* ----------------
*/
#define PortalNameLength 32
typedef struct PortalEntry {
char name[PortalNameLength]; /* name of this portal */
PortalBuffer *portal; /* tuples contained in this portal */
Pointer portalcxt; /* memory context (for backend) */
Pointer result; /* result for PQexec */
} PortalEntry;
#define PORTALS_INITIAL_SIZE 32
#define PORTALS_GROW_BY 32
/* in portalbuf.c */
extern PortalEntry** portals;
extern size_t portals_array_size;
/*
* Asynchronous notification
*/
typedef struct PQNotifyList {
char relname[NAMEDATALEN]; /* name of relation containing data */
int be_pid; /* process id of backend */
int valid; /* has this already been handled by user. */
/* SLNode Node; */
} PQNotifyList;
/*
* Exceptions.
*/
#define libpq_raise(X, Y) ExcRaise((Exception *)(X), (ExcDetail) (Y),\
(ExcData)0, (ExcMessage) 0)
/* in portal.c */
extern Exception MemoryError, PortalError, PostquelError, ProtocolError;
/*
* POSTGRES backend dependent Constants.
*/
/* ERROR_MSG_LENGTH should really be the same as ELOG_MAXLEN in utils/elog.h*/
#define ERROR_MSG_LENGTH 4096
#define COMMAND_LENGTH 20
#define REMARK_LENGTH 80
extern char PQerrormsg[ERROR_MSG_LENGTH]; /* in portal.c */
/*
* External functions.
*/
/*
* prototypes for functions in portal.c
*/
extern void pqdebug(char *target, char *msg);
extern void pqdebug2(char *target, char *msg1, char *msg2);
extern void PQtrace(void);
extern void PQuntrace(void);
extern int PQnportals(int rule_p);
extern void PQpnames(char **pnames, int rule_p);
extern PortalBuffer *PQparray(char *pname);
extern int PQrulep(PortalBuffer *portal);
extern int PQntuples(PortalBuffer *portal);
extern int PQninstances(PortalBuffer *portal);
extern int PQngroups(PortalBuffer *portal);
extern int PQntuplesGroup(PortalBuffer *portal, int group_index);
extern int PQninstancesGroup(PortalBuffer *portal, int group_index);
extern int PQnfieldsGroup(PortalBuffer *portal, int group_index);
extern int PQfnumberGroup(PortalBuffer *portal, int group_index, char *field_name);
extern char *PQfnameGroup(PortalBuffer *portal, int group_index, int field_number);
extern int PQftypeGroup(PortalBuffer *portal, int group_index,
int field_number);
extern int PQfsizeGroup(PortalBuffer *portal, int group_index,
int field_number);
extern GroupBuffer *PQgroup(PortalBuffer *portal, int tuple_index);
extern int PQgetgroup(PortalBuffer *portal, int tuple_index);
extern int PQnfields(PortalBuffer *portal, int tuple_index);
extern int PQfnumber(PortalBuffer *portal, int tuple_index, char *field_name);
extern char *PQfname(PortalBuffer *portal, int tuple_index, int field_number);
extern int PQftype(PortalBuffer *portal, int tuple_index, int field_number);
extern int PQfsize(PortalBuffer *portal, int tuple_index, int field_number);
extern int PQsametype(PortalBuffer *portal, int tuple_index1, int tuple_index2);
extern char *PQgetvalue(PortalBuffer *portal, int tuple_index, int field_number);
extern char *PQgetAttr(PortalBuffer *portal, int tuple_index, int field_number);
extern int PQgetlength(PortalBuffer *portal, int tuple_index, int field_number);
extern void PQclear(char *pname);
extern void PQcleanNotify(void);
extern void PQnotifies_init(void);
extern PQNotifyList *PQnotifies(void);
extern void PQremoveNotify(PQNotifyList *nPtr);
extern void PQappendNotify(char *relname, int pid);
/*
* prototypes for functions in portalbuf.c
*/
extern caddr_t pbuf_alloc(size_t size);
extern void pbuf_free(caddr_t pointer);
extern PortalBuffer *pbuf_addPortal(void);
extern GroupBuffer *pbuf_addGroup(PortalBuffer *portal);
extern TypeBlock *pbuf_addTypes(int n);
extern TupleBlock *pbuf_addTuples(void);
extern char **pbuf_addTuple(int n);
extern int *pbuf_addTupleValueLengths(int n);
extern char *pbuf_addValues(int n);
extern PortalEntry *pbuf_addEntry(void);
extern void pbuf_freeEntry(int i);
extern void pbuf_freeTypes(TypeBlock *types);
extern void pbuf_freeTuples(TupleBlock *tuples, int no_tuples, int no_fields);
extern void pbuf_freeGroup(GroupBuffer *group);
extern void pbuf_freePortal(PortalBuffer *portal);
extern int pbuf_getIndex(char *pname);
extern void pbuf_setportalinfo(PortalEntry *entry, char *pname);
extern PortalEntry *pbuf_setup(char *pname);
extern void pbuf_close(char *pname);
extern GroupBuffer *pbuf_findGroup(PortalBuffer *portal, int group_index);
extern int pbuf_findFnumber(GroupBuffer *group, char *field_name);
extern void pbuf_checkFnumber(GroupBuffer *group, int field_number);
extern char *pbuf_findFname(GroupBuffer *group, int field_number);
/*
* prototypes for functions in pqcomm.c
*/
extern void pq_init(int fd);
extern void pq_gettty(char *tp);
extern int pq_getport(void);
extern void pq_close(void);
extern void pq_flush(void);
extern int pq_getstr(char *s, int maxlen);
extern int PQgetline(char *s, int maxlen);
extern int PQputline(char *s);
extern int pq_getnchar(char *s, int off, int maxlen);
extern int pq_getint(int b);
extern void pq_putstr(char *s);
extern void pq_putnchar(char *s, int n);
extern void pq_putint(int i, int b);
extern int pq_sendoob(char *msg, int len);
extern int pq_recvoob(char *msgPtr, int *lenPtr);
extern int pq_getinaddr(struct sockaddr_in *sin, char *host, int port);
extern int pq_getinserv(struct sockaddr_in *sin, char *host, char *serv);
extern int pq_connect(char *dbname, char *user, char *args, char *hostName,
char *debugTty, char *execFile, short portName);
extern int StreamOpen(char *hostName, short portName, Port *port);
extern void pq_regoob(void (*fptr)());
extern void pq_unregoob(void);
extern void pq_async_notify(void);
extern int StreamServerPort(char *hostName, short portName, int *fdP);
extern int StreamConnection(int server_fd, Port *port);
extern void StreamClose(int sock);
#endif /* LIBPQ_H */

124
src/include/libpq/pqcomm.h Normal file
View File

@@ -0,0 +1,124 @@
/*-------------------------------------------------------------------------
*
* pqcomm.h--
* Parameters for the communication module
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqcomm.h,v 1.1 1996/08/28 07:23:02 scrappy Exp $
*
* NOTES
* Some of this should move to libpq.h
*
*-------------------------------------------------------------------------
*/
#ifndef PQCOMM_H
#define PQCOMM_H
#include <sys/types.h>
#ifdef WIN32
#include <winsock.h>
#else
#include <netinet/in.h>
#endif /* WIN32 */
#include "postgres.h"
/*
* startup msg parameters: path length, argument string length
*/
#define PATH_SIZE 64
#define ARGV_SIZE 64
typedef enum _MsgType {
ACK_MSG = 0, /* acknowledge a message */
ERROR_MSG=1, /* error response to client from server */
RESET_MSG=2, /* client must reset connection */
PRINT_MSG=3, /* tuples for client from server */
NET_ERROR=4, /* error in net system call */
FUNCTION_MSG=5, /* fastpath call (unused) */
QUERY_MSG=6, /* client query to server */
STARTUP_MSG=7, /* initialize a connection with a backend */
DUPLICATE_MSG=8, /* duplicate msg arrived (errors msg only) */
INVALID_MSG=9, /* for some control functions */
STARTUP_KRB4_MSG=10, /* krb4 session follows startup packet */
STARTUP_KRB5_MSG=11, /* krb5 session follows startup packet */
STARTUP_HBA_MSG=12 /* use host-based authentication */
/* insert new values here -- DO NOT REORDER OR DELETE ENTRIES */
} MsgType;
typedef char *Addr;
typedef int PacketLen; /* packet length */
typedef struct StartupInfo {
/* PacketHdr hdr; */
char database[PATH_SIZE]; /* database name */
char user[NAMEDATALEN]; /* user name */
char options[ARGV_SIZE]; /* possible additional args */
char execFile[ARGV_SIZE]; /* possible backend to use */
char tty[PATH_SIZE]; /* possible tty for debug output*/
} StartupInfo;
/* amount of available data in a packet buffer */
#define MESSAGE_SIZE sizeof(StartupInfo) + 5
/* I/O can be blocking or non-blocking */
#define BLOCKING (FALSE)
#define NON_BLOCKING (TRUE)
/* a PacketBuf gets shipped from client to server so be careful
of differences in representation.
Be sure to use htonl() and ntohl() on the len and msgtype fields! */
typedef struct PacketBuf {
int len;
MsgType msgtype;
char data[MESSAGE_SIZE];
} PacketBuf;
/* update the conversion routines
StartupInfo2PacketBuf() and PacketBuf2StartupInfo() (decl. below)
if StartupInfo or PacketBuf structs ever change */
/*
* socket descriptor port
* we need addresses of both sides to do authentication calls
*/
typedef struct Port {
int sock; /* file descriptor */
int mask; /* select mask */
int nBytes; /* nBytes read in so far */
struct sockaddr_in laddr; /* local addr (us) */
struct sockaddr_in raddr; /* remote addr (them) */
/* PacketBufId id;*/ /* id of packet buf currently in use */
PacketBuf buf; /* stream implementation (curr pack buf) */
} Port;
/* invalid socket descriptor */
#define INVALID_SOCK (-1)
#define INVALID_ID (-1)
#define MAX_CONNECTIONS 10
#define N_PACK_BUFS 20
/* no multi-packet messages yet */
#define MAX_PACKET_BACKLOG 1
#define DEFAULT_STRING ""
extern FILE *Pfout, *Pfin;
extern int PQAsyncNotifyWaiting;
/*
* prototypes for functions in pqpacket.c
*/
extern int PacketReceive(Port *port, PacketBuf *buf, bool nonBlocking);
extern int PacketSend(Port *port, PacketBuf *buf,
PacketLen len, bool nonBlocking);
/* extern PacketBuf* StartupInfo2PacketBuf(StartupInfo*); */
/* extern StartupInfo* PacketBuf2StartupInfo(PacketBuf*); */
#endif /* PQCOMM_H */

View File

@@ -0,0 +1,32 @@
/*-------------------------------------------------------------------------
*
* pqsignal.h--
* prototypes for the reliable BSD-style signal(2) routine.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqsignal.h,v 1.1 1996/08/28 07:23:03 scrappy Exp $
*
* NOTES
* This shouldn't be in libpq, but the monitor and some other
* things need it...
*
*-------------------------------------------------------------------------
*/
#ifndef PQSIGNAL_H
#define PQSIGNAL_H
#include <signal.h>
#include "c.h"
typedef void (*pqsigfunc)(int);
extern pqsigfunc pqsignal(int signo, pqsigfunc func);
#if defined(USE_POSIX_SIGNALS)
#define signal(signo, handler) pqsignal(signo, (pqsigfunc)(handler))
#endif /* USE_POSIX_SIGNALS */
#endif /* PQSIGNAL_H */

View File

@@ -0,0 +1,24 @@
/*-------------------------------------------------------------------------
*
* clauseinfo.h--
* prototypes for clauseinfo.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: clauseinfo.h,v 1.1 1996/08/28 07:23:10 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef CLAUSEINFO_H
#define CLAUSEINFO_H
extern bool valid_or_clause(CInfo *clauseinfo);
extern List *get_actual_clauses(List *clauseinfo_list);
extern void get_relattvals(List *clauseinfo_list, List **attnos,
List **values, List **flags);
extern void get_joinvars(Oid relid, List *clauseinfo_list,
List **attnos, List **values, List **flags);
extern List *get_opnos(List *clauseinfo_list);
#endif /* CLAUSEINFO_H */

View File

@@ -0,0 +1,54 @@
/*-------------------------------------------------------------------------
*
* clauses.h--
* prototypes for clauses.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: clauses.h,v 1.1 1996/08/28 07:23:11 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef CLAUSES_H
#define CLAUSES_H
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
extern Expr *make_clause(int type, Node *oper, List *args);
extern bool is_opclause(Node *clause);
extern Expr *make_opclause(Oper *op, Var *leftop, Var *rightop);
extern Var *get_leftop(Expr *clause);
extern Var *get_rightop(Expr *clause);
extern bool agg_clause(Node *clause);
extern bool is_funcclause(Node *clause);
extern Expr *make_funcclause(Func *func, List *funcargs);
extern bool or_clause(Node *clause);
extern Expr *make_orclause(List *orclauses);
extern bool not_clause(Node *clause);
extern Expr *make_notclause(Expr *notclause);
extern Expr *get_notclausearg(Expr *notclause);
extern bool and_clause(Node *clause);
extern Expr *make_andclause(List *andclauses);
extern List *pull_constant_clauses(List *quals, List **constantQual);
extern void clause_relids_vars(Node *clause, List **relids, List **vars);
extern int NumRelids(Node *clause);
extern bool contains_not(Node *clause);
extern bool join_clause_p(Node *clause);
extern bool qual_clause_p(Node *clause);
extern void fix_opid(Node *clause);
extern List *fix_opids(List *clauses);
extern void get_relattval(Node *clause, int *relid,
AttrNumber *attno, Datum *constval, int *flag);
extern void get_rels_atts(Node *clause, int *relid1,
AttrNumber *attno1, int *relid2, AttrNumber *attno2);
extern void CommuteClause(Node *clause);
#endif /* CLAUSES_H */

View File

@@ -0,0 +1,59 @@
/*-------------------------------------------------------------------------
*
* cost.h--
* prototypes for costsize.c and clausesel.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: cost.h,v 1.1 1996/08/28 07:23:12 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef COST_H
#define COST_H
/*
* prototypes for costsize.c--
* routines to compute costs and sizes
*/
extern bool _enable_seqscan_;
extern bool _enable_indexscan_;
extern bool _enable_sort_;
extern bool _enable_hash_;
extern bool _enable_nestloop_;
extern bool _enable_mergesort_;
extern bool _enable_hashjoin_;
extern Cost cost_seqscan(int relid, int relpages, int reltuples);
extern Cost cost_index(Oid indexid, int expected_indexpages, Cost selec,
int relpages, int reltuples, int indexpages,
int indextuples, bool is_injoin);
extern Cost cost_sort(List *keys, int tuples, int width, bool noread);
extern Cost cost_result(int tuples, int width);
extern Cost cost_nestloop(Cost outercost, Cost innercost, int outertuples,
int innertuples, int outerpages, bool is_indexjoin);
extern Cost cost_mergesort(Cost outercost, Cost innercost,
List *outersortkeys, List *innersortkeys,
int outersize, int innersize, int outerwidth, int innerwidth);
extern Cost cost_hashjoin(Cost outercost, Cost innercost, List *outerkeys,
List *innerkeys, int outersize, int innersize,
int outerwidth, int innerwidth);
extern int compute_rel_size(Rel *rel);
extern int compute_rel_width(Rel *rel);
extern int compute_targetlist_width(List *targetlist);
extern int compute_joinrel_size(JoinPath *joinpath);
extern int page_size(int tuples, int width);
/*
* prototypes for fuctions in clausesel.h--
* routines to compute clause selectivities
*/
extern void set_clause_selectivities(List *clauseinfo_list, Cost new_selectivity);
extern Cost product_selec(List *clauseinfo_list);
extern void set_rest_relselec(Query *root, List *rel_list);
extern void set_rest_selec(Query *root,List *clauseinfo_list);
extern Cost compute_clause_selec(Query *root,
Node *clause, List *or_selectivities);
#endif /* COST_H */

View File

@@ -0,0 +1,92 @@
/*-------------------------------------------------------------------------
*
* internal.h--
* Definitions required throughout the query optimizer.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: internal.h,v 1.1 1996/08/28 07:23:12 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef INTERNAL_H
#define INTERNAL_H
/*
* ---------- SHARED MACROS
*
* Macros common to modules for creating, accessing, and modifying
* query tree and query plan components.
* Shared with the executor.
*
*/
#include "nodes/nodes.h"
#include "nodes/primnodes.h"
#include "nodes/plannodes.h"
#include "parser/parsetree.h"
#include "nodes/relation.h"
#include "catalog/pg_index.h" /* for INDEX_MAX_KEYS */
#include "utils/syscache.h" /* for SearchSysCacheGetAttribute, etc. */
/*
* System-dependent tuning constants
*
*/
#define _CPU_PAGE_WEIGHT_ 0.065 /* CPU-to-page cost weighting factor */
#define _PAGE_SIZE_ 8192 /* BLCKSZ (from ../h/bufmgr.h) */
#define _MAX_KEYS_ INDEX_MAX_KEYS /* maximum number of keys in an index */
#define _TID_SIZE_ 6 /* sizeof(itemid) (from ../h/itemid.h) */
/*
* Size estimates
*
*/
/* The cost of sequentially scanning a materialized temporary relation
*/
#define _TEMP_SCAN_COST_ 10
/* The number of pages and tuples in a materialized relation
*/
#define _TEMP_RELATION_PAGES_ 1
#define _TEMP_RELATION_TUPLES_ 10
/* The length of a variable-length field in bytes
*/
#define _DEFAULT_ATTRIBUTE_WIDTH_ (2 * _TID_SIZE_)
/*
* Flags and identifiers
*
*/
/* Identifier for (sort) temp relations */
/* used to be -1 */
#define _TEMP_RELATION_ID_ InvalidOid
/* Identifier for invalid relation OIDs and attribute numbers for use by
* selectivity functions
*/
#define _SELEC_VALUE_UNKNOWN_ -1
/* Flag indicating that a clause constant is really a parameter (or other
* non-constant?), a non-parameter, or a constant on the right side
* of the clause.
*/
#define _SELEC_NOT_CONSTANT_ 0
#define _SELEC_IS_CONSTANT_ 1
#define _SELEC_CONSTANT_LEFT_ 0
#define _SELEC_CONSTANT_RIGHT_ 2
#define TOLERANCE 0.000001
#define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE)
#define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0))
extern int BushyPlanFlag;
/* #define deactivate_joininfo(joininfo) joininfo->inactive=true*/
/*#define joininfo_inactive(joininfo) joininfo->inactive */
#endif /* INTERNAL_H */

View File

@@ -0,0 +1,20 @@
/*-------------------------------------------------------------------------
*
* joininfo.h--
* prototypes for joininfo.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: joininfo.h,v 1.1 1996/08/28 07:23:14 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef JOININFO_H
#define JOININFO_H
extern JInfo *joininfo_member(List *join_relids, List *joininfo_list);
extern JInfo *find_joininfo_node(Rel *this_rel, List *join_relids);
extern Var *other_join_clause_var(Var *var, Expr *clause);
#endif /* JOININFO_H */

View File

@@ -0,0 +1,22 @@
/*-------------------------------------------------------------------------
*
* keys.h--
* prototypes for keys.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: keys.h,v 1.1 1996/08/28 07:23:16 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef KEYS_H
#define KEYS_H
extern bool match_indexkey_operand(int indexkey, Var *operand, Rel *rel);
extern bool equal_indexkey_var(int index_key, Var *var);
extern Var *extract_subkey(JoinKey *jk, int which_subkey);
extern bool samekeys(List *keys1, List *keys2);
extern List *collect_index_pathkeys(int *index_keys, List *tlist);
#endif /* KEYS_H */

View File

@@ -0,0 +1,24 @@
/*-------------------------------------------------------------------------
*
* ordering.h--
* prototypes for ordering.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: ordering.h,v 1.1 1996/08/28 07:23:17 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef ORDERING_H
#define ORDERING_H
extern bool equal_path_path_ordering(PathOrder *path_ordering1,
PathOrder *path_ordering2);
extern bool equal_path_merge_ordering(Oid *path_ordering,
MergeOrder *merge_ordering);
extern bool equal_merge_merge_ordering(MergeOrder *merge_ordering1,
MergeOrder *merge_ordering2);
extern bool equal_sortops_order(Oid *ordering1, Oid *ordering2);
#endif /* ORDERING_H */

View File

@@ -0,0 +1,50 @@
/*-------------------------------------------------------------------------
*
* pathnode.h--
* prototypes for pathnode.c, indexnode.c, relnode.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pathnode.h,v 1.1 1996/08/28 07:23:18 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PATHNODE_H
#define PATHNODE_H
/*
* prototypes for pathnode.c
*/
extern bool path_is_cheaper(Path *path1, Path *path2);
extern Path *set_cheapest(Rel *parent_rel, List *pathlist);
extern List *add_pathlist(Rel *parent_rel, List *unique_paths,
List *new_paths);
extern Path *create_seqscan_path(Rel *rel);
extern IndexPath *create_index_path(Query *root, Rel *rel, Rel *index,
List *restriction_clauses, bool is_join_scan);
extern JoinPath *create_nestloop_path(Rel *joinrel, Rel *outer_rel,
Path *outer_path, Path *inner_path, List *keys);
extern MergePath *create_mergesort_path(Rel *joinrel, int outersize,
int innersize, int outerwidth, int innerwidth, Path *outer_path,
Path *inner_path, List *keys, MergeOrder *order,
List *mergeclauses, List *outersortkeys, List *innersortkeys);
extern HashPath *create_hashjoin_path(Rel *joinrel, int outersize,
int innersize, int outerwidth, int innerwidth, Path *outer_path,
Path *inner_path, List *keys, Oid operator, List *hashclauses,
List *outerkeys, List *innerkeys);
/*
* prototypes for rel.c
*/
extern Rel *rel_member(List *relid, List *rels);
extern Rel *get_base_rel(Query* root, int relid);
extern Rel *get_join_rel(Query* root, List *relid);
/*
* prototypes for indexnode.h
*/
extern List *find_relation_indices(Query *root,Rel *rel);
#endif /* PATHNODE_H */

View File

@@ -0,0 +1,89 @@
/*-------------------------------------------------------------------------
*
* paths.h--
* prototypes for various files in optimizer/paths (were separate
* header files
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: paths.h,v 1.1 1996/08/28 07:23:19 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PATHS_H
#define PATHS_H
/*
* allpaths.h
*/
extern List *find_paths(Query *root, List *rels);
/*
* indxpath.h
* routines to generate index paths
*/
extern List *find_index_paths(Query *root, Rel *rel, List *indices,
List *clauseinfo_list,
List *joininfo_list);
/*
* joinpath.h
* routines to create join paths
*/
extern void find_all_join_paths(Query *root, List *joinrels);
/*
* orindxpath.h
*/
extern List *create_or_index_paths(Query *root, Rel *rel, List *clauses);
/*
* hashutils.h
* routines to deal with hash keys and clauses
*/
extern List *group_clauses_by_hashop(List *clauseinfo_list,
int inner_relid);
/*
* joinutils.h
* generic join method key/clause routines
*/
extern List *match_pathkeys_joinkeys(List *pathkeys,
List *joinkeys, List *joinclauses, int which_subkey,
List **matchedJoinClausesPtr);
extern List *extract_path_keys(List *joinkeys, List *tlist,
int which_subkey);
extern Path *match_paths_joinkeys(List *joinkeys, PathOrder *ordering,
List *paths, int which_subkey);
extern List *new_join_pathkeys(List *outer_pathkeys,
List *join_rel_tlist, List *joinclauses);
/*
* mergeutils.h
* routines to deal with merge keys and clauses
*/
extern List *group_clauses_by_order(List *clauseinfo_list,
int inner_relid);
extern MInfo *match_order_mergeinfo(PathOrder *ordering,
List *mergeinfo_list);
/*
* joinrels.h
* routines to determine which relations to join
*/
extern List *find_join_rels(Query *root, List *outer_rels);
extern void add_new_joininfos(Query *root, List *joinrels, List *outerrels);
extern List *final_join_rels(List *join_rel_list);
/*
* prototypes for path/prune.c
*/
extern List *prune_joinrels(List *rel_list);
extern void prune_rel_paths(List *rel_list);
extern Path *prune_rel_path(Rel *rel, Path *unorderedpath);
extern List *merge_joinrels(List *rel_list1, List *rel_list2);
extern List *prune_oldrels(List *old_rels);
#endif /* PATHS_H */

View File

@@ -0,0 +1,65 @@
/*-------------------------------------------------------------------------
*
* plancat.h--
* prototypes for plancat.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: plancat.h,v 1.1 1996/08/28 07:23:20 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PLANCAT_H
#define PLANCAT_H
#include "c.h"
/*
* transient data structure to hold return value of index_info. Note that
* indexkeys, orderOprs and classlist is "null-terminated".
*/
typedef struct IdxInfoRetval {
Oid relid; /* OID of the index relation (not the OID
* of the relation being indexed)
*/
Oid relam; /* OID of the pg_am of this index */
int pages; /* number of pages in the index relation */
int tuples; /* number of tuples in the index relation */
int *indexkeys; /* keys over which we're indexing */
Oid *orderOprs; /* operators used for ordering purposes */
Oid *classlist; /* classes of AM operators */
Oid indproc;
Node *indpred;
} IdxInfoRetval;
extern void relation_info(Query *root,
Oid relid,
bool *hashindex, int *pages,
int *tuples);
extern bool index_info(Query *root,
bool first, int relid, IdxInfoRetval *info);
extern Cost
restriction_selectivity(Oid functionObjectId,
Oid operatorObjectId,
Oid relationObjectId,
AttrNumber attributeNumber,
char *constValue,
int32 constFlag);
extern void
index_selectivity(Oid indid, Oid *classes, List *opnos,
Oid relid, List *attnos, List *values, List *flags,
int32 nkeys, float *idxPages, float *idxSelec);
extern Cost join_selectivity(Oid functionObjectId, Oid operatorObjectId,
Oid relationObjectId1, AttrNumber attributeNumber1,
Oid relationObjectId2, AttrNumber attributeNumber2);
extern List *find_inheritance_children(Oid inhparent);
extern List *VersionGetParents(Oid verrelid);
#endif /* PLANCAT_H */

View File

@@ -0,0 +1,60 @@
/*-------------------------------------------------------------------------
*
* planmain.h--
* prototypes for various files in optimizer/plan
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: planmain.h,v 1.1 1996/08/28 07:23:23 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PLANMAIN_H
#define PLANMAIN_H
/*
* prototypes for plan/planmain.c
*/
extern Plan *query_planner(Query *root,
int command_type, List *tlist, List *qual);
/*
* prototypes for plan/createplan.c
*/
extern Plan *create_plan(Path *best_path);
extern SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid,
Plan *lefttree);
extern Sort *make_sort(List *tlist, Oid tempid, Plan *lefttree,
int keycount);
extern Agg *make_agg(List *tlist, int nagg, Aggreg **aggs);
extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp,
AttrNumber *grpColIdx, Sort *lefttree);
extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr);
extern List *generate_fjoin(List *tlist);
/*
* prototypes for plan/initsplan.c
*/
extern void initialize_base_rels_list(Query *root, List *tlist);
extern void initialize_base_rels_jinfo(Query *root, List *clauses);
extern void initialize_join_clause_info(List *rel_list);
extern void add_missing_vars_to_base_rels(Query *root, List *tlist);
/*
* prototypes for plan/setrefs.c
*/
extern void set_tlist_references(Plan *plan);
extern List *join_references(List *clauses, List *outer_tlist,
List *inner_tlist);
extern List *index_outerjoin_references(List *inner_indxqual,
List *outer_tlist, Index inner_relid);
extern void set_result_tlist_references(Result *resultNode);
extern void set_agg_tlist_references(Agg *aggNode);
extern void set_agg_agglist_references(Agg *aggNode);
#endif /* PLANMAIN_H */

View File

@@ -0,0 +1,24 @@
/*-------------------------------------------------------------------------
*
* planner.h--
* prototypes for planner.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: planner.h,v 1.1 1996/08/28 07:23:26 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PLANNER_H
#define PLANNER_H
/*
#include "optimizer/internal.h"
#include "parser/parse_query.h"
*/
extern Plan *planner(Query *parse);
extern void pg_checkretval(Oid rettype, QueryTreeList *querytree_list);
#endif /* PLANNER_H */

View File

@@ -0,0 +1,51 @@
/*-------------------------------------------------------------------------
*
* prep.h--
* prototypes for files in prep.c
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: prep.h,v 1.1 1996/08/28 07:23:27 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PREP_H
#define PREP_H
#include "nodes/primnodes.h"
#include "nodes/plannodes.h"
/*
* prototypes for archive.h
*/
extern void plan_archive(List *rt);
extern List *find_archive_rels(Oid relid);
/*
* prototypes for prepqual.h
*/
extern List *preprocess_qualification(Expr *qual, List *tlist,
List **existentialQualPtr);
extern List *cnfify(Expr *qual, bool removeAndFlag);
/*
* prototypes for preptlist.h
*/
extern List *preprocess_targetlist(List *tlist, int command_type,
Index result_relation, List *range_table);
/*
* prototypes for prepunion.h
*/
typedef enum UnionFlag {
INHERITS_FLAG, ARCHIVE_FLAG, VERSION_FLAG
} UnionFlag;
extern List *find_all_inheritors(List *unexamined_relids,
List *examined_relids);
extern int first_matching_rt_entry(List *rangetable, UnionFlag flag);
extern Append *plan_union_queries(Index rt_index, Query *parse,
UnionFlag flag);
#endif /* PREP_H */

View File

@@ -0,0 +1,36 @@
/*-------------------------------------------------------------------------
*
* tlist.h--
* prototypes for tlist.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: tlist.h,v 1.1 1996/08/28 07:23:28 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef TLIST_H
#define TLIST_H
extern int exec_tlist_length(List *targelist);
extern TargetEntry *tlistentry_member(Var *var, List *targetlist);
extern Expr *matching_tlvar(Var *var, List *targetlist);
extern void add_tl_element(Rel *rel, Var *var);
extern TargetEntry *create_tl_element(Var *var, int resdomno);
extern List *get_actual_tlist(List *tlist);
extern Resdom *tlist_member(Var *var, List *tlist);
extern Resdom *tlist_resdom(List *tlist, Resdom *resnode);
extern TargetEntry *MakeTLE(Resdom *resdom, Node *expr);
extern Var *get_expr(TargetEntry *tle);
extern TargetEntry *match_varid(Var *test_var, List *tlist);
extern List *new_unsorted_tlist(List *targetlist);
extern List *copy_vars(List *target, List *source);
extern List *flatten_tlist(List *tlist);
extern List *flatten_tlist_vars(List *full_tlist,
List *flat_tlist);
extern void AddGroupAttrToTlist(List *tlist, List *grpCl);
#endif /* TLIST_H */

View File

@@ -0,0 +1,21 @@
/*-------------------------------------------------------------------------
*
* var.h--
* prototypes for var.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: var.h,v 1.1 1996/08/28 07:23:29 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VAR_H
#define VAR_H
extern List *pull_varnos(Node *me);
extern bool contain_var_clause(Node *clause);
extern List *pull_var_clause(Node *clause);
extern bool var_equal(Var *var1, Var *var2);
#endif /* VAR_H */

View File

@@ -0,0 +1,84 @@
/*-------------------------------------------------------------------------
*
* xfunc.h--
* prototypes for xfunc.c and predmig.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: xfunc.h,v 1.1 1996/08/28 07:23:30 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef XFUNC_H
#define XFUNC_H
#include "nodes/relation.h"
/* command line arg flags */
#define XFUNC_OFF -1 /* do no optimization of expensive preds */
#define XFUNC_NOR 2 /* do no optimization of OR clauses */
#define XFUNC_NOPULL 4 /* never pull restrictions above joins */
#define XFUNC_NOPM 8 /* don't do predicate migration */
#define XFUNC_WAIT 16 /* don't do pullup until predicate migration */
#define XFUNC_PULLALL 32 /* pull all expensive restrictions up, always */
/* constants for local and join predicates */
#define XFUNC_LOCPRD 1
#define XFUNC_JOINPRD 2
#define XFUNC_UNKNOWN 0
extern int XfuncMode; /* defined in tcop/postgres.c */
/* defaults for function attributes used for expensive function calculations */
#define BYTE_PCT 100
#define PERBYTE_CPU 0
#define PERCALL_CPU 0
#define OUTIN_RATIO 100
/* default width assumed for variable length attributes */
#define VARLEN_DEFAULT 128;
/* Macro to get group rank out of group cost and group sel */
#define get_grouprank(a) ((get_groupsel(a) - 1) / get_groupcost(a))
/* Macro to see if a path node is actually a Join */
#define is_join(pathnode) (length(get_relids(get_parent(pathnode))) > 1 ? 1 : 0)
/* function prototypes from planner/path/xfunc.c */
extern void xfunc_trypullup(Rel *rel);
extern int xfunc_shouldpull(Path *childpath, JoinPath *parentpath,
int whichchild, CInfo *maxcinfopt);
extern CInfo *xfunc_pullup(Path *childpath, JoinPath *parentpath, CInfo *cinfo,
int whichchild, int clausetype);
extern Cost xfunc_rank(Expr *clause);
extern Cost xfunc_expense(Query* queryInfo, Expr *clause);
extern Cost xfunc_join_expense(JoinPath *path, int whichchild);
extern Cost xfunc_local_expense(Expr *clause);
extern Cost xfunc_func_expense(Expr *node, List *args);
extern int xfunc_width(Expr *clause);
/* static, moved to xfunc.c */
/* extern int xfunc_card_unreferenced(Expr *clause, Relid referenced); */
extern int xfunc_card_product(Relid relids);
extern List *xfunc_find_references(List *clause);
extern List *xfunc_primary_join(JoinPath *pathnode);
extern Cost xfunc_get_path_cost(Path *pathnode);
extern Cost xfunc_total_path_cost(JoinPath *pathnode);
extern Cost xfunc_expense_per_tuple(JoinPath *joinnode, int whichchild);
extern void xfunc_fixvars(Expr *clause, Rel *rel, int varno);
extern int xfunc_cinfo_compare(void *arg1, void *arg2);
extern int xfunc_clause_compare(void *arg1, void *arg2);
extern void xfunc_disjunct_sort(List *clause_list);
extern int xfunc_disjunct_compare(void *arg1, void *arg2);
extern int xfunc_func_width(RegProcedure funcid, List *args);
extern int xfunc_tuple_width(Relation rd);
extern int xfunc_num_join_clauses(JoinPath *path);
extern List *xfunc_LispRemove(List *foo, List *bar);
extern bool xfunc_copyrel(Rel *from, Rel **to);
/*
* function prototypes for path/predmig.c
*/
extern bool xfunc_do_predmig(Path root);
#endif /* XFUNC_H */

View File

@@ -0,0 +1,62 @@
/*-------------------------------------------------------------------------
*
* catalog_utils.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: catalog_utils.h,v 1.1 1996/08/28 07:23:51 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef CATALOG_UTILS_H
#define CATALOG_UTILS_H
#include "postgres.h"
#include "access/htup.h"
#include "utils/rel.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "utils/syscache.h"
typedef HeapTuple Type;
typedef HeapTuple Operator;
extern bool check_typeid(long id);
extern Type get_id_type(long id);
extern char *get_id_typname(long id);
extern Type type(char *);
extern Oid att_typeid(Relation rd, int attid);
extern int att_attnelems(Relation rd, int attid);
extern Oid typeid(Type tp);
extern int16 tlen(Type t);
extern bool tbyval(Type t);
extern char *tname(Type t);
extern int tbyvalue(Type t);
extern Oid oprid(Operator op);
extern Operator oper(char *op, int arg1, int arg2);
extern Operator right_oper(char *op, int arg);
extern Operator left_oper(char *op, int arg);
extern int varattno(Relation rd, char *a);
extern bool varisset(Relation rd, char *name);
extern int nf_varattno(Relation rd, char *a);
extern char *getAttrName(Relation rd, int attrno);
extern char *outstr(char *typename, char *value);
extern char *instr2(Type tp, char *string, int typlen);
extern char *instr1(TypeTupleForm tp, char *string, int typlen);
extern Oid GetArrayElementType(Oid typearray);
extern Oid funcid_get_rettype(Oid funcid);
extern bool func_get_detail(char *funcname, int nargs, Oid *oid_array,
Oid *funcid, Oid *rettype, bool *retset, Oid **true_typeids);
extern Oid typeid_get_retinfunc(int type_id);
extern Oid typeid_get_relid(int type_id);
extern Oid get_typrelid(Type typ);
extern Oid get_typelem(Oid type_id);
extern char FindDelimiter(char *typename);
extern void op_error(char *op, int arg1, int arg2);
extern void func_error(char *caller, char *funcname, int nargs, int *argtypes);
#endif /* CATALOG_UTILS_H */

View File

@@ -0,0 +1,28 @@
/*-------------------------------------------------------------------------
*
* dbcommands.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: dbcommands.h,v 1.1 1996/08/28 07:23:53 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef DBCOMMANDS_H
#define DBCOMMANDS_H
/*
* Originally from tmp/daemon.h. The functions declared in daemon.h does not
* exist; hence removed. -- AY 7/29/94
*/
#define SIGKILLDAEMON1 SIGINT
#define SIGKILLDAEMON2 SIGTERM
extern void createdb(char *dbname);
extern void destroydb(char *dbname);
void stop_vacuum(char *dbname);
#endif /* DBCOMMANDS_H */

View File

@@ -0,0 +1,25 @@
/*-------------------------------------------------------------------------
*
* keywords.h--
* string,atom lookup thingy, reduces strcmp traffic greatly
* in the bowels of the system. Look for actual defs in lib/C/atoms.c
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: keywords.h,v 1.1 1996/08/28 07:23:55 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef KEYWORDS_H
#define KEYWORDS_H
typedef struct ScanKeyword {
char *name;
int value;
} ScanKeyword;
extern ScanKeyword *ScanKeywordLookup(char *text);
extern char* AtomValueGetString(int atomval);
#endif /* KEYWORDS_H */

View File

@@ -0,0 +1,72 @@
/*-------------------------------------------------------------------------
*
* parse_query.h--
* prototypes for parse_query.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_query.h,v 1.1 1996/08/28 07:23:55 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PARSE_QUERY_H
#define PARSE_QUERY_H
#include "nodes/pg_list.h"
#include "nodes/parsenodes.h"
#include "parser/catalog_utils.h"
#include "parser/parse_state.h"
typedef struct QueryTreeList {
int len; /* number of queries */
Query** qtrees;
} QueryTreeList;
extern int RangeTablePosn(List *rtable, char *rangevar);
extern char *VarnoGetRelname(ParseState *pstate, int vnum);
extern RangeTblEntry *makeRangeTableEntry(char *relname, bool inh,
TimeRange *timeRange, char *refname);
extern List *expandAll(ParseState *pstate, char *relname, int *this_resno);
extern TimeQual makeTimeRange(char *datestring1, char *datestring2,
int timecode);
extern Expr *make_op(char *opname, Node *ltree, Node *rtree);
extern int find_atttype(Oid relid, char *attrname);
extern Var *make_var(ParseState *pstate,
char *relname, char *attrname, int *type_id);
extern ArrayRef *make_array_ref(Node *array, List *indirection);
extern ArrayRef *make_array_set(Expr *target_expr, List *upperIndexpr,
List *lowerIndexpr, Expr *expr);
extern Const *make_const(Value *value);
extern void param_type_init(Oid* typev, int nargs);
extern Oid param_type(int t);
/* parser.c (was ylib.c) */
extern QueryTreeList *parser(char *str, Oid *typev, int nargs);
extern Node *parser_typecast(Value *expr, TypeName *typename, int typlen);
extern Node *parser_typecast2(Node *expr, int exprType, Type tp, int typlen);
extern Aggreg *ParseAgg(char *aggname, Oid basetype, Node *target);
/*
* analyze.c
*/
#if 0
extern List *p_rtable;
extern int NumLevels;
#endif
Oid exprType(Node *expr);
ParseState* makeParseState();
QueryTreeList *parse_analyze(List *querytree_list);
/* define in parse_query.c, used in gram.y */
extern Oid *param_type_info;
extern int pfunc_num_args;
/* useful macros */
#define ISCOMPLEX(type) (typeid_get_relid((Oid)type) ? true : false)
#endif /* PARSE_QUERY_H */

View File

@@ -0,0 +1,27 @@
/*-------------------------------------------------------------------------
*
* parse_state.h--
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_state.h,v 1.1 1996/08/28 07:23:56 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PARSE_STATE_H
#define PARSE_STATE_H
/* state information used during parse analysis */
typedef struct ParseState {
int p_last_resno;
List *p_target_resnos;
Relation parser_current_rel;
List *p_rtable;
int p_query_is_rule;
int p_numAgg;
List *p_aggs;
} ParseState;
#endif /*PARSE_QUERY_H*/

View File

@@ -0,0 +1,80 @@
/*-------------------------------------------------------------------------
*
* parsetree.h--
* Routines to access various components and subcomponents of
* parse trees.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsetree.h,v 1.1 1996/08/28 07:23:57 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PARSETREE_H
#define PARSETREE_H /* include once only */
/* ----------------
* need pg_list.h for definitions of CAR(), etc. macros
* ----------------
*/
#include "nodes/pg_list.h"
#include "nodes/parsenodes.h"
/* ----------------
* range table macros
*
* parse tree:
* (root targetlist qual)
* ^^^^
* parse root:
* (numlevels cmdtype resrel rangetable priority ruleinfo nestdotinfo)
* ^^^^^^^^^^
* range table:
* (rtentry ...)
*
* rtentry:
* note: this might be wrong, I don't understand how
* rt_time / rt_archive_time work together. anyways it
* looks something like:
*
* (relname ? relid timestuff flags rulelocks)
* or (new/cur relname relid timestuff flags rulelocks)
*
* someone who knows more should correct this -cim 6/9/91
* ----------------
*/
#define rt_relname(rt_entry) \
((!strcmp(((rt_entry)->refname),"*CURRENT*") ||\
!strcmp(((rt_entry)->refname),"*NEW*")) ? ((rt_entry)->refname) : \
((char *)(rt_entry)->relname))
/*
* rt_fetch
* rt_store
*
* Access and (destructively) replace rangetable entries.
*
*/
#define rt_fetch(rangetable_index, rangetable) \
((RangeTblEntry*)nth((rangetable_index)-1, rangetable))
#define rt_store(rangetable_index, rangetable, rt) \
set_nth(rangetable, (rangetable_index)-1, rt)
/*
* getrelid
* getrelname
*
* Given the range index of a relation, return the corresponding
* relation id or relation name.
*/
#define getrelid(rangeindex,rangetable) \
((RangeTblEntry*)nth((rangeindex)-1, rangetable))->relid
#define getrelname(rangeindex, rangetable) \
rt_relname((RangeTblEntry*)nth((rangeindex)-1, rangetable))
#endif /* PARSETREE_H */

View File

@@ -0,0 +1,17 @@
/*-------------------------------------------------------------------------
*
* scansup.h--
* scanner support routines. used by both the bootstrap lexer
* as well as the normal lexer
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: scansup.h,v 1.1 1996/08/28 07:23:58 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
extern char* scanstr(char *s);

View File

@@ -0,0 +1,10 @@
/*-------------------------------------------------------------------------
*
* sysfunc.h--
* support for system functions
*
* -------------------------------------------------------------------------
*/
extern char *SystemFunctionHandler(char *funct);

View File

@@ -0,0 +1,21 @@
/*-------------------------------------------------------------------------
*
* locks.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: locks.h,v 1.1 1996/08/28 07:24:04 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef LOCKS_H
#define LOCKS_H
#include "rewrite/prs2lock.h"
extern List *matchLocks(CmdType event, RuleLock *rulelocks, int varno,
Query *parsetree);
#endif /* LOCKS_H */

View File

@@ -0,0 +1,43 @@
/*-------------------------------------------------------------------------
*
* prs2lock.h--
* data structures for POSTGRES Rule System II (rewrite rules only)
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: prs2lock.h,v 1.1 1996/08/28 07:24:05 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PRS2LOCK_H
#define PRS2LOCK_H
#include "access/attnum.h"
#include "nodes/pg_list.h"
/*
* RewriteRule -
* holds a info for a rewrite rule
*
*/
typedef struct RewriteRule {
Oid ruleId;
CmdType event;
AttrNumber attrno;
Node *qual;
List *actions;
bool isInstead;
} RewriteRule;
/*
* RuleLock -
* all rules that apply to a particular relation. Even though we only
* have the rewrite rule system left and these are not really "locks",
* the name is kept for historical reasons.
*/
typedef struct RuleLock {
int numLocks;
RewriteRule **rules;
} RuleLock;
#endif /* REWRITE_H */

View File

@@ -0,0 +1,18 @@
/*-------------------------------------------------------------------------
*
* rewriteDefine.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rewriteDefine.h,v 1.1 1996/08/28 07:24:06 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef REWRITEDEFINE_H
#define REWRITEDEFINE_H
extern void DefineQueryRewrite(RuleStmt *args);
#endif /* REWRITEDEFINE_H */

View File

@@ -0,0 +1,35 @@
/*-------------------------------------------------------------------------
*
* rewriteHandler.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rewriteHandler.h,v 1.1 1996/08/28 07:24:07 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef REWRITEHANDLER_H
#define REWRITEHANDLER_H
struct _rewrite_meta_knowledge {
List *rt;
int rt_index;
bool instead_flag;
int event;
CmdType action;
int current_varno;
int new_varno;
Query *rule_action;
Node *rule_qual;
bool nothing;
};
typedef struct _rewrite_meta_knowledge RewriteInfo;
extern List *QueryRewrite(Query *parsetree);
#endif /*REWRITEHANDLER_H */

View File

@@ -0,0 +1,31 @@
/*-------------------------------------------------------------------------
*
* rewriteManip.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rewriteManip.h,v 1.1 1996/08/28 07:24:08 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef REWRITEMANIP_H
#define REWRITEMANIP_H
/* RewriteManip.c */
void OffsetVarNodes(Node *node, int offset);
void ChangeVarNodes(Node *node, int old_varno, int new_varno);
void AddQual(Query *parsetree, Node *qual);
void AddNotQual(Query *parsetree, Node *qual);
void FixResdomTypes(List *user_tlist);
void FixNew(RewriteInfo *info, Query *parsetree);
void HandleRIRAttributeRule(Query *parsetree, List *rtable, List *targetlist,
int rt_index, int attr_num, int *modified,
int *badpostquel);
void HandleViewRule(Query *parsetree, List *rtable, List *targetlist,
int rt_index, int *modified);
#endif /* REWRITEMANIP_H */

View File

@@ -0,0 +1,20 @@
/*-------------------------------------------------------------------------
*
* rewriteRemove.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rewriteRemove.h,v 1.1 1996/08/28 07:24:12 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef REWRITEREMOVE_H
#define REWRITEREMOVE_H
extern char *RewriteGetRuleEventRel(char *rulename);
extern void RemoveRewriteRule(char *ruleName);
extern void RelationRemoveRules(Oid relid);
#endif /* REWRITEREMOVE_H */

View File

@@ -0,0 +1,27 @@
/*-------------------------------------------------------------------------
*
* rewriteSupport.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rewriteSupport.h,v 1.1 1996/08/28 07:24:13 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef REWRITESUPPORT_H
#define REWRITESUPPORT_H
#include "nodes/pg_list.h"
extern int IsDefinedRewriteRule(char *ruleName);
extern void prs2_addToRelation(Oid relid, Oid ruleId, CmdType event_type,
AttrNumber attno, bool isInstead, Node *qual,
List *actions);
extern void prs2_deleteFromRelation(Oid relid, Oid ruleId);
#endif /* REWRITESUPPORT_H */

78
src/include/tcop/dest.h Normal file
View File

@@ -0,0 +1,78 @@
/*-------------------------------------------------------------------------
*
* dest.h--
* Whenever the backend is submitted a query, the results
* have to go someplace - either to the standard output,
* to a local portal buffer or to a remote portal buffer.
*
* - stdout is the destination only when we are running a
* backend without a postmaster and are returning results
* back to the user.
*
* - a local portal buffer is the destination when a backend
* executes a user-defined function which calls PQexec() or
* PQfn(). In this case, the results are collected into a
* PortalBuffer which the user's function may diddle with.
*
* - a remote portal buffer is the destination when we are
* running a backend with a frontend and the frontend executes
* PQexec() or PQfn(). In this case, the results are sent
* to the frontend via the pq_ functions.
*
* - None is the destination when the system executes
* a query internally. This is not used now but it may be
* useful for the parallel optimiser/executor.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: dest.h,v 1.1 1996/08/28 07:27:49 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef DEST_H
#define DEST_H
#include "catalog/pg_attribute.h"
#include "access/tupdesc.h"
/* ----------------
* CommandDest is used to allow the results of calling
* pg_eval() to go to the right place.
* ----------------
*/
typedef enum {
None, /* results are discarded */
Debug, /* results go to debugging output */
Local, /* results go in local portal buffer */
Remote, /* results sent to frontend process */
CopyBegin, /* results sent to frontend process but are strings */
CopyEnd, /* results sent to frontend process but are strings */
RemoteInternal /* results sent to frontend process in internal
(binary) form */
} CommandDest;
/* AttrInfo* replaced with TupleDesc, now that TupleDesc also has within it
the number of attributes
typedef struct AttrInfo {
int numAttr;
AttributeTupleForm *attrs;
} AttrInfo;
*/
extern void donothing(List *tuple, List *attrdesc);
extern void (*DestToFunction(CommandDest dest))();
extern void EndCommand(char *commandTag, CommandDest dest);
extern void SendCopyBegin();
extern void ReceiveCopyBegin();
extern void NullCommand(CommandDest dest);
extern void BeginCommand(char *pname, int operation, TupleDesc attinfo,
bool isIntoRel, bool isIntoPortal, char *tag,
CommandDest dest);
extern void ResetAppendOid();
extern void UpdateAppendOid(Oid newoid);
extern Oid GetAppendOid();
#endif /* DEST_H */

View File

@@ -0,0 +1,31 @@
/*-------------------------------------------------------------------------
*
* fastpath.h--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: fastpath.h,v 1.1 1996/08/28 07:27:50 scrappy Exp $
*
* NOTES
* This information pulled out of tcop/fastpath.c and put
* here so that the PQfn() in be-pqexec.c could access it.
* -cim 2/26/91
*
*-------------------------------------------------------------------------
*/
#ifndef FASTPATH_H
#define FASTPATH_H
/* ----------------
* fastpath #defines
* ----------------
*/
#define VAR_LENGTH_RESULT (-1)
#define VAR_LENGTH_ARG (-5)
#define MAX_STRING_LENGTH 256
extern int HandleFunctionRequest(void);
#endif /* FASTPATH_H */

36
src/include/tcop/pquery.h Normal file
View File

@@ -0,0 +1,36 @@
/*-------------------------------------------------------------------------
*
* pquery.h--
* prototypes for pquery.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pquery.h,v 1.1 1996/08/28 07:27:51 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PQUERY_H
#define PQUERY_H
#include "executor/execdesc.h"
#include "tcop/dest.h"
/* moved to execdesc.h
extern QueryDesc *CreateQueryDesc(Query *parsetree, Plan *plantree,
CommandDest dest);
*/
extern EState *CreateExecutorState();
extern void ProcessPortal(char *portalName, Query *parseTree,
Plan *plan, EState *state, TupleDesc attinfo,
CommandDest dest);
extern void ProcessQueryDesc(QueryDesc *queryDesc);
extern void ProcessQuery(Query *parsetree, Plan *plan, char *argv[],
Oid *typev, int nargs, CommandDest dest);
#endif /* pqueryIncluded */

View File

@@ -0,0 +1,43 @@
/*-------------------------------------------------------------------------
*
* tcopdebug.h--
* #defines governing debugging behaviour in the traffic cop
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: tcopdebug.h,v 1.1 1996/08/28 07:27:52 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef TCOPDEBUG_H
#define TCOPDEBUG_H
/* ----------------------------------------------------------------
* debugging defines.
*
* If you want certain debugging behaviour, then #define
* the variable to 1, else #undef it. -cim 10/26/89
* ----------------------------------------------------------------
*/
/* ----------------
* TCOP_SHOWSTATS controls whether or not buffer and
* access method statistics are shown for each query. -cim 2/9/89
* ----------------
*/
#undef TCOP_SHOWSTATS
/* ----------------
* TCOP_DONTUSENEWLINE controls the default setting of
* the UseNewLine variable in postgres.c
* ----------------
*/
#undef TCOP_DONTUSENEWLINE
/* ----------------------------------------------------------------
* #defines controlled by above definitions
* ----------------------------------------------------------------
*/
#endif /* TCOPDEBUG_H */

View File

@@ -0,0 +1,40 @@
/*-------------------------------------------------------------------------
*
* tcopprot.h--
* prototypes for postgres.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: tcopprot.h,v 1.1 1996/08/28 07:27:53 scrappy Exp $
*
* OLD COMMENTS
* This file was created so that other c files could get the two
* function prototypes without having to include tcop.h which single
* handedly includes the whole f*cking tree -- mer 5 Nov. 1991
*
*-------------------------------------------------------------------------
*/
#ifndef TCOPPROT_H
#define TCOPPROT_H
#include "tcop/dest.h"
#include "nodes/pg_list.h"
#include "parser/parse_query.h"
#ifndef BOOTSTRAP_INCLUDE
extern List *pg_plan(char *query_string, Oid *typev, int nargs,
QueryTreeList **queryListP, CommandDest dest);
extern void pg_eval(char *query_string, char **argv, Oid *typev, int nargs);
extern void pg_eval_dest(char *query_string, char **argv, Oid *typev,
int nargs, CommandDest dest);
#endif /* BOOTSTRAP_HEADER */
extern void handle_warn();
extern void quickdie();
extern void die();
extern int PostgresMain(int argc, char *argv[]);
extern void ResetUsage();
extern void ShowUsage();
#endif /* tcopprotIncluded */

View File

@@ -0,0 +1,18 @@
/*-------------------------------------------------------------------------
*
* utility.h--
* prototypes for utility.c.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: utility.h,v 1.1 1996/08/28 07:27:54 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef UTILITY_H
#define UTILITY_H
extern void ProcessUtility(Node *parsetree, CommandDest dest);
#endif /* UTILITY_H */