From 9ba606cd247db7398e4d178865a2d9e02b2a310b Mon Sep 17 00:00:00 2001
From: "Vadim B. Mikheev" <vadim4o@yahoo.com>
Date: Thu, 4 Sep 1997 13:26:19 +0000
Subject: [PATCH] Prototypes, definitions...

---
 src/include/commands/trigger.h | 56 ++++++++++++++++++++++------------
 src/include/executor/spi.h     | 49 +++++++++++++++++++++--------
 2 files changed, 74 insertions(+), 31 deletions(-)

diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
index e603a3f8dc4..8cbfe0c5a1b 100644
--- a/src/include/commands/trigger.h
+++ b/src/include/commands/trigger.h
@@ -13,35 +13,53 @@
 #include "access/htup.h"
 #include "utils/rel.h"
 
-typedef uint32 TriggerAction;
+typedef uint32 TriggerEvent;
 
-#define TRIGGER_ACTION_INSERT		0x00000000  
-#define TRIGGER_ACTION_DELETE		0x00000001   
-#define TRIGGER_ACTION_UPDATE		0x00000010
-#define TRIGGER_ACTION_OPMASK		0x00000011
-#define TRIGGER_ACTION_ROW		4
+typedef struct TriggerData {
+    TriggerEvent	tg_event;
+    Relation		tg_relation;
+    HeapTuple		tg_trigtuple;
+    HeapTuple		tg_newtuple;
+    Trigger		*tg_trigger;
+} TriggerData;
 
-#define TRIGGER_FIRED_BY_INSERT (action)	\
-	(((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \
-						TRIGGER_ACTION_INSERT)
+extern TriggerData *CurrentTriggerData;
 
-#define TRIGGER_FIRED_BY_DELETE (action)	\
-	(((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \
-						TRIGGER_ACTION_DELETE)
+#define TRIGGER_EVENT_INSERT		0x00000000  
+#define TRIGGER_EVENT_DELETE		0x00000001   
+#define TRIGGER_EVENT_UPDATE		0x00000002
+#define TRIGGER_EVENT_OPMASK		0x00000003
+#define TRIGGER_EVENT_ROW		0x00000004
+#define TRIGGER_EVENT_BEFORE		0x00000008
 
-#define TRIGGER_FIRED_BY_UPDATE (action)	\
-	(((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \
-						TRIGGER_ACTION_UPDATE)
+#define TRIGGER_FIRED_BY_INSERT(event)	\
+	(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
+						TRIGGER_EVENT_INSERT)
 
-#define TRIGGER_FIRED_FOR_ROW (action)		\
-	((TriggerAction) action & TRIGGER_ACTION_ROW)
+#define TRIGGER_FIRED_BY_DELETE(event)	\
+	(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
+						TRIGGER_EVENT_DELETE)
 
-#define TRIGGER_FIRED_FOR_STATEMENT (action)	\
-	(!TRIGGER_FIRED_FOR_ROW (action))
+#define TRIGGER_FIRED_BY_UPDATE(event)	\
+	(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
+						TRIGGER_EVENT_UPDATE)
+
+#define TRIGGER_FIRED_FOR_ROW(event)		\
+	((TriggerEvent) (event) & TRIGGER_EVENT_ROW)
+
+#define TRIGGER_FIRED_FOR_STATEMENT(event)	\
+	(!TRIGGER_FIRED_FOR_ROW (event))
+
+#define TRIGGER_FIRED_BEFORE(event)		\
+	((TriggerEvent) (event) & TRIGGER_EVENT_BEFORE)
+
+#define TRIGGER_FIRED_AFTER(event)		\
+	(!TRIGGER_FIRED_BEFORE (event))
 
 
 extern void CreateTrigger (CreateTrigStmt *stmt);
 extern void DropTrigger (DropTrigStmt *stmt);
+extern void RelationRemoveTriggers (Relation rel);
 
 extern HeapTuple ExecBRInsertTriggers (Relation rel, HeapTuple tuple);
 extern void ExecARInsertTriggers (Relation rel, HeapTuple tuple);
diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h
index 0070c3147d7..31d9ecc8e27 100644
--- a/src/include/executor/spi.h
+++ b/src/include/executor/spi.h
@@ -46,24 +46,49 @@ typedef struct {
 #define SPI_ERROR_OPUNKNOWN	-3
 #define SPI_ERROR_UNCONNECTED	-4
 #define SPI_ERROR_CURSOR	-5
-#define SPI_ERROR_TRANSACTION	-6
+#define SPI_ERROR_ARGUMENT	-6
+#define SPI_ERROR_PARAM		-7
+#define SPI_ERROR_TRANSACTION	-8
+#define SPI_ERROR_NOATTRIBUTE	-9
+#define SPI_ERROR_NOOUTFUNC	-10
+#define SPI_ERROR_TYPUNKNOWN	-11
+#define SPI_ERROR_NOENTRY	-12
 
-#define SPI_OK_CONNECT		0
-#define SPI_OK_FINISH		1
-#define SPI_OK_FETCH		2
-#define SPI_OK_UTILITY		3
-#define SPI_OK_SELECT		4
-#define SPI_OK_SELINTO		5
-#define SPI_OK_INSERT		6
-#define SPI_OK_DELETE		7
-#define SPI_OK_UPDATE		8
-#define SPI_OK_CURSOR		9
+#define SPI_OK_CONNECT		1
+#define SPI_OK_FINISH		2
+#define SPI_OK_FETCH		3
+#define SPI_OK_UTILITY		4
+#define SPI_OK_SELECT		5
+#define SPI_OK_SELINTO		6
+#define SPI_OK_INSERT		7
+#define SPI_OK_DELETE		8
+#define SPI_OK_UPDATE		9
+#define SPI_OK_CURSOR		10
+
+#define SPI_DSPACE_LOCAL	0
+#define SPI_DSPACE_XACT		1
+#define SPI_DSPACE_SESSION	2
 
 extern uint32 SPI_processed;
 extern SPITupleTable *SPI_tuptable;
+extern int SPI_error;
 
-extern int SPI_connect (void);
+extern int SPI_connect (char *ident);
 extern int SPI_finish (void);
 extern int SPI_exec (char *src);
+extern int SPI_execn (char *src, int tcount);
+extern int SPI_execp (int pid, char **values, char *Nulls);
+extern int SPI_prepare (char *src, int nargs, Oid *argtypes);
+extern int SPI_expplan (int dspace, int start, int count);
+extern int SPI_impplan (int dspace, int start, int count);
+extern int SPI_expdata (int dspace, int count, void **data, int *len);
+extern int SPI_impdata (int dspace, int start, int count, void **data, int **len);
+
+extern int SPI_fnumber (TupleDesc tupdesc, char *fname);
+extern char *SPI_getvalue (HeapTuple tuple, TupleDesc tupdesc, int fnumber);
+extern char *SPI_getbinval (HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull);
+extern char *SPI_gettype (TupleDesc tupdesc, int fnumber);
+extern Oid SPI_gettypeid (TupleDesc tupdesc, int fnumber);
+extern char *SPI_getrelname (Relation rel);
 
 #endif /* SPI_H */
-- 
GitLab