]> granicus.if.org Git - postgresql/blob - contrib/tsearch2/query_util.h
Reduce WAL activity for page splits:
[postgresql] / contrib / tsearch2 / query_util.h
1 #ifndef __QUERY_UTIL_H__
2 #define __QUERY_UTIL_H__
3
4 #include "postgres.h"
5 #include "utils/memutils.h"
6
7 #include "query.h"
8 #include "executor/spi.h"
9
10 typedef struct QTNode
11 {
12         ITEM       *valnode;
13         uint32          flags;
14         int4            nchild;
15         char       *word;
16         uint32          sign;
17         struct QTNode **child;
18 }       QTNode;
19
20 #define QTN_NEEDFREE    0x01
21 #define QTN_NOCHANGE    0x02
22 #define QTN_WORDFREE    0x04
23
24 typedef enum
25 {
26         PlainMemory,
27         SPIMemory,
28         AggMemory
29 }       MemoryType;
30
31 QTNode     *QT2QTN(ITEM * in, char *operand);
32 QUERYTYPE  *QTN2QT(QTNode * in, MemoryType memtype);
33 void            QTNFree(QTNode * in);
34 void            QTNSort(QTNode * in);
35 void            QTNTernary(QTNode * in);
36 void            QTNBinary(QTNode * in);
37 int                     QTNodeCompare(QTNode * an, QTNode * bn);
38 QTNode     *QTNCopy(QTNode * in, MemoryType memtype);
39 bool            QTNEq(QTNode * a, QTNode * b);
40
41
42 extern MemoryContext AggregateContext;
43
44 #define MEMALLOC(us, s)                 ( ((us)==SPIMemory) ? SPI_palloc(s) : ( ( (us)==PlainMemory ) ? palloc(s) : MemoryContextAlloc(AggregateContext, (s)) ) )
45 #define MEMFREE(us, p)                  ( ((us)==SPIMemory) ? SPI_pfree(p) : pfree(p) )
46
47 #endif