Commit 9ba606cd authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

Prototypes, definitions...

parent 989ab6b1
...@@ -13,35 +13,53 @@ ...@@ -13,35 +13,53 @@
#include "access/htup.h" #include "access/htup.h"
#include "utils/rel.h" #include "utils/rel.h"
typedef uint32 TriggerAction; typedef uint32 TriggerEvent;
#define TRIGGER_ACTION_INSERT 0x00000000 typedef struct TriggerData {
#define TRIGGER_ACTION_DELETE 0x00000001 TriggerEvent tg_event;
#define TRIGGER_ACTION_UPDATE 0x00000010 Relation tg_relation;
#define TRIGGER_ACTION_OPMASK 0x00000011 HeapTuple tg_trigtuple;
#define TRIGGER_ACTION_ROW 4 HeapTuple tg_newtuple;
Trigger *tg_trigger;
} TriggerData;
#define TRIGGER_FIRED_BY_INSERT (action) \ extern TriggerData *CurrentTriggerData;
(((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \
TRIGGER_ACTION_INSERT)
#define TRIGGER_FIRED_BY_DELETE (action) \ #define TRIGGER_EVENT_INSERT 0x00000000
(((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \ #define TRIGGER_EVENT_DELETE 0x00000001
TRIGGER_ACTION_DELETE) #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) \ #define TRIGGER_FIRED_BY_INSERT(event) \
(((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \ (((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
TRIGGER_ACTION_UPDATE) TRIGGER_EVENT_INSERT)
#define TRIGGER_FIRED_FOR_ROW (action) \ #define TRIGGER_FIRED_BY_DELETE(event) \
((TriggerAction) action & TRIGGER_ACTION_ROW) (((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
TRIGGER_EVENT_DELETE)
#define TRIGGER_FIRED_FOR_STATEMENT (action) \ #define TRIGGER_FIRED_BY_UPDATE(event) \
(!TRIGGER_FIRED_FOR_ROW (action)) (((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 CreateTrigger (CreateTrigStmt *stmt);
extern void DropTrigger (DropTrigStmt *stmt); extern void DropTrigger (DropTrigStmt *stmt);
extern void RelationRemoveTriggers (Relation rel);
extern HeapTuple ExecBRInsertTriggers (Relation rel, HeapTuple tuple); extern HeapTuple ExecBRInsertTriggers (Relation rel, HeapTuple tuple);
extern void ExecARInsertTriggers (Relation rel, HeapTuple tuple); extern void ExecARInsertTriggers (Relation rel, HeapTuple tuple);
......
...@@ -46,24 +46,49 @@ typedef struct { ...@@ -46,24 +46,49 @@ typedef struct {
#define SPI_ERROR_OPUNKNOWN -3 #define SPI_ERROR_OPUNKNOWN -3
#define SPI_ERROR_UNCONNECTED -4 #define SPI_ERROR_UNCONNECTED -4
#define SPI_ERROR_CURSOR -5 #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_CONNECT 1
#define SPI_OK_FINISH 1 #define SPI_OK_FINISH 2
#define SPI_OK_FETCH 2 #define SPI_OK_FETCH 3
#define SPI_OK_UTILITY 3 #define SPI_OK_UTILITY 4
#define SPI_OK_SELECT 4 #define SPI_OK_SELECT 5
#define SPI_OK_SELINTO 5 #define SPI_OK_SELINTO 6
#define SPI_OK_INSERT 6 #define SPI_OK_INSERT 7
#define SPI_OK_DELETE 7 #define SPI_OK_DELETE 8
#define SPI_OK_UPDATE 8 #define SPI_OK_UPDATE 9
#define SPI_OK_CURSOR 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 uint32 SPI_processed;
extern SPITupleTable *SPI_tuptable; 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_finish (void);
extern int SPI_exec (char *src); 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 */ #endif /* SPI_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment