PostgreSQL Source Code  git master
ts_type.h File Reference
#include "fmgr.h"
#include "utils/memutils.h"
Include dependency graph for ts_type.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  WordEntry
 
struct  WordEntryPosVector
 
struct  WordEntryPosVector1
 
struct  TSVectorData
 
struct  QueryOperand
 
struct  QueryOperator
 
union  QueryItem
 
struct  TSQueryData
 

Macros

#define MAXSTRLEN   ( (1<<11) - 1)
 
#define MAXSTRPOS   ( (1<<20) - 1)
 
#define WEP_GETWEIGHT(x)   ( (x) >> 14 )
 
#define WEP_GETPOS(x)   ( (x) & 0x3fff )
 
#define WEP_SETWEIGHT(x, v)   ( (x) = ( (v) << 14 ) | ( (x) & 0x3fff ) )
 
#define WEP_SETPOS(x, v)   ( (x) = ( (x) & 0xc000 ) | ( (v) & 0x3fff ) )
 
#define MAXENTRYPOS   (1<<14)
 
#define MAXNUMPOS   (256)
 
#define LIMITPOS(x)   ( ( (x) >= MAXENTRYPOS ) ? (MAXENTRYPOS-1) : (x) )
 
#define DATAHDRSIZE   (offsetof(TSVectorData, entries))
 
#define CALCDATASIZE(nentries, lenstr)   (DATAHDRSIZE + (nentries) * sizeof(WordEntry) + (lenstr) )
 
#define ARRPTR(x)   ( (x)->entries )
 
#define STRPTR(x)   ( (char *) &(x)->entries[(x)->size] )
 
#define _POSVECPTR(x, e)   ((WordEntryPosVector *)(STRPTR(x) + SHORTALIGN((e)->pos + (e)->len)))
 
#define POSDATALEN(x, e)   ( ( (e)->haspos ) ? (_POSVECPTR(x,e)->npos) : 0 )
 
#define POSDATAPTR(x, e)   (_POSVECPTR(x,e)->pos)
 
#define DatumGetTSVector(X)   ((TSVector) PG_DETOAST_DATUM(X))
 
#define DatumGetTSVectorCopy(X)   ((TSVector) PG_DETOAST_DATUM_COPY(X))
 
#define TSVectorGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_TSVECTOR(n)   DatumGetTSVector(PG_GETARG_DATUM(n))
 
#define PG_GETARG_TSVECTOR_COPY(n)   DatumGetTSVectorCopy(PG_GETARG_DATUM(n))
 
#define PG_RETURN_TSVECTOR(x)   return TSVectorGetDatum(x)
 
#define QI_VAL   1
 
#define QI_OPR   2
 
#define QI_VALSTOP
 
#define OP_NOT   1
 
#define OP_AND   2
 
#define OP_OR   3
 
#define OP_PHRASE   4 /* highest code, tsquery_cleanup.c */
 
#define OP_COUNT   4
 
#define OP_PRIORITY(x)   ( tsearch_op_priority[(x) - 1] )
 
#define QO_PRIORITY(x)   OP_PRIORITY(((QueryOperator *) (x))->oper)
 
#define HDRSIZETQ   ( VARHDRSZ + sizeof(int32) )
 
#define COMPUTESIZE(size, lenofoperand)   ( HDRSIZETQ + (size) * sizeof(QueryItem) + (lenofoperand) )
 
#define TSQUERY_TOO_BIG(size, lenofoperand)    ((size) > (MaxAllocSize - HDRSIZETQ - (lenofoperand)) / sizeof(QueryItem))
 
#define GETQUERY(x)   ((QueryItem*)( (char*)(x)+HDRSIZETQ ))
 
#define GETOPERAND(x)   ( (char*)GETQUERY(x) + ((TSQuery)(x))->size * sizeof(QueryItem) )
 
#define DatumGetTSQuery(X)   ((TSQuery) DatumGetPointer(X))
 
#define DatumGetTSQueryCopy(X)   ((TSQuery) PG_DETOAST_DATUM_COPY(X))
 
#define TSQueryGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_TSQUERY(n)   DatumGetTSQuery(PG_GETARG_DATUM(n))
 
#define PG_GETARG_TSQUERY_COPY(n)   DatumGetTSQueryCopy(PG_GETARG_DATUM(n))
 
#define PG_RETURN_TSQUERY(x)   return TSQueryGetDatum(x)
 

Typedefs

typedef uint16 WordEntryPos
 
typedef TSVectorDataTSVector
 
typedef int8 QueryItemType
 
typedef TSQueryDataTSQuery
 

Functions

int compareWordEntryPos (const void *a, const void *b)
 

Variables

const int tsearch_op_priority [OP_COUNT]
 

Macro Definition Documentation

◆ _POSVECPTR

#define _POSVECPTR (   x,
  e 
)    ((WordEntryPosVector *)(STRPTR(x) + SHORTALIGN((e)->pos + (e)->len)))

Definition at line 109 of file ts_type.h.

◆ ARRPTR

#define ARRPTR (   x)    ( (x)->entries )

Definition at line 104 of file ts_type.h.

◆ CALCDATASIZE

#define CALCDATASIZE (   nentries,
  lenstr 
)    (DATAHDRSIZE + (nentries) * sizeof(WordEntry) + (lenstr) )

Definition at line 101 of file ts_type.h.

◆ COMPUTESIZE

#define COMPUTESIZE (   size,
  lenofoperand 
)    ( HDRSIZETQ + (size) * sizeof(QueryItem) + (lenofoperand) )

Definition at line 217 of file ts_type.h.

◆ DATAHDRSIZE

#define DATAHDRSIZE   (offsetof(TSVectorData, entries))

Definition at line 100 of file ts_type.h.

◆ DatumGetTSQuery

#define DatumGetTSQuery (   X)    ((TSQuery) DatumGetPointer(X))

Definition at line 233 of file ts_type.h.

◆ DatumGetTSQueryCopy

#define DatumGetTSQueryCopy (   X)    ((TSQuery) PG_DETOAST_DATUM_COPY(X))

Definition at line 234 of file ts_type.h.

◆ DatumGetTSVector

#define DatumGetTSVector (   X)    ((TSVector) PG_DETOAST_DATUM(X))

Definition at line 117 of file ts_type.h.

◆ DatumGetTSVectorCopy

#define DatumGetTSVectorCopy (   X)    ((TSVector) PG_DETOAST_DATUM_COPY(X))

Definition at line 118 of file ts_type.h.

◆ GETOPERAND

#define GETOPERAND (   x)    ( (char*)GETQUERY(x) + ((TSQuery)(x))->size * sizeof(QueryItem) )

Definition at line 225 of file ts_type.h.

◆ GETQUERY

#define GETQUERY (   x)    ((QueryItem*)( (char*)(x)+HDRSIZETQ ))

Definition at line 222 of file ts_type.h.

◆ HDRSIZETQ

#define HDRSIZETQ   ( VARHDRSZ + sizeof(int32) )

Definition at line 212 of file ts_type.h.

◆ LIMITPOS

#define LIMITPOS (   x)    ( ( (x) >= MAXENTRYPOS ) ? (MAXENTRYPOS-1) : (x) )

Definition at line 87 of file ts_type.h.

◆ MAXENTRYPOS

#define MAXENTRYPOS   (1<<14)

Definition at line 85 of file ts_type.h.

◆ MAXNUMPOS

#define MAXNUMPOS   (256)

Definition at line 86 of file ts_type.h.

◆ MAXSTRLEN

#define MAXSTRLEN   ( (1<<11) - 1)

Definition at line 49 of file ts_type.h.

◆ MAXSTRPOS

#define MAXSTRPOS   ( (1<<20) - 1)

Definition at line 50 of file ts_type.h.

◆ OP_AND

#define OP_AND   2

Definition at line 165 of file ts_type.h.

◆ OP_COUNT

#define OP_COUNT   4

Definition at line 168 of file ts_type.h.

◆ OP_NOT

#define OP_NOT   1

Definition at line 164 of file ts_type.h.

◆ OP_OR

#define OP_OR   3

Definition at line 166 of file ts_type.h.

◆ OP_PHRASE

#define OP_PHRASE   4 /* highest code, tsquery_cleanup.c */

Definition at line 167 of file ts_type.h.

◆ OP_PRIORITY

#define OP_PRIORITY (   x)    ( tsearch_op_priority[(x) - 1] )

Definition at line 173 of file ts_type.h.

◆ PG_GETARG_TSQUERY

#define PG_GETARG_TSQUERY (   n)    DatumGetTSQuery(PG_GETARG_DATUM(n))

Definition at line 236 of file ts_type.h.

◆ PG_GETARG_TSQUERY_COPY

#define PG_GETARG_TSQUERY_COPY (   n)    DatumGetTSQueryCopy(PG_GETARG_DATUM(n))

Definition at line 237 of file ts_type.h.

◆ PG_GETARG_TSVECTOR

#define PG_GETARG_TSVECTOR (   n)    DatumGetTSVector(PG_GETARG_DATUM(n))

Definition at line 120 of file ts_type.h.

◆ PG_GETARG_TSVECTOR_COPY

#define PG_GETARG_TSVECTOR_COPY (   n)    DatumGetTSVectorCopy(PG_GETARG_DATUM(n))

Definition at line 121 of file ts_type.h.

◆ PG_RETURN_TSQUERY

#define PG_RETURN_TSQUERY (   x)    return TSQueryGetDatum(x)

Definition at line 238 of file ts_type.h.

◆ PG_RETURN_TSVECTOR

#define PG_RETURN_TSVECTOR (   x)    return TSVectorGetDatum(x)

Definition at line 122 of file ts_type.h.

◆ POSDATALEN

#define POSDATALEN (   x,
  e 
)    ( ( (e)->haspos ) ? (_POSVECPTR(x,e)->npos) : 0 )

Definition at line 110 of file ts_type.h.

◆ POSDATAPTR

#define POSDATAPTR (   x,
  e 
)    (_POSVECPTR(x,e)->pos)

Definition at line 111 of file ts_type.h.

◆ QI_OPR

#define QI_OPR   2

Definition at line 135 of file ts_type.h.

◆ QI_VAL

#define QI_VAL   1

Definition at line 134 of file ts_type.h.

◆ QI_VALSTOP

#define QI_VALSTOP
Value:
3 /* This is only used in an intermediate stack
* representation in parse_tsquery. It's not a
* legal type elsewhere. */

Definition at line 136 of file ts_type.h.

◆ QO_PRIORITY

#define QO_PRIORITY (   x)    OP_PRIORITY(((QueryOperator *) (x))->oper)

Definition at line 175 of file ts_type.h.

◆ STRPTR

#define STRPTR (   x)    ( (char *) &(x)->entries[(x)->size] )

Definition at line 107 of file ts_type.h.

◆ TSQUERY_TOO_BIG

#define TSQUERY_TOO_BIG (   size,
  lenofoperand 
)     ((size) > (MaxAllocSize - HDRSIZETQ - (lenofoperand)) / sizeof(QueryItem))

Definition at line 218 of file ts_type.h.

◆ TSQueryGetDatum

#define TSQueryGetDatum (   X)    PointerGetDatum(X)

Definition at line 235 of file ts_type.h.

◆ TSVectorGetDatum

#define TSVectorGetDatum (   X)    PointerGetDatum(X)

Definition at line 119 of file ts_type.h.

◆ WEP_GETPOS

#define WEP_GETPOS (   x)    ( (x) & 0x3fff )

Definition at line 80 of file ts_type.h.

◆ WEP_GETWEIGHT

#define WEP_GETWEIGHT (   x)    ( (x) >> 14 )

Definition at line 79 of file ts_type.h.

◆ WEP_SETPOS

#define WEP_SETPOS (   x,
 
)    ( (x) = ( (x) & 0xc000 ) | ( (v) & 0x3fff ) )

Definition at line 83 of file ts_type.h.

◆ WEP_SETWEIGHT

#define WEP_SETWEIGHT (   x,
 
)    ( (x) = ( (v) << 14 ) | ( (x) & 0x3fff ) )

Definition at line 82 of file ts_type.h.

Typedef Documentation

◆ QueryItemType

Definition at line 131 of file ts_type.h.

◆ TSQuery

typedef TSQueryData* TSQuery

Definition at line 210 of file ts_type.h.

◆ TSVector

Definition at line 98 of file ts_type.h.

◆ WordEntryPos

Definition at line 63 of file ts_type.h.

Function Documentation

◆ compareWordEntryPos()

int compareWordEntryPos ( const void *  a,
const void *  b 
)

Definition at line 33 of file tsvector.c.

34 {
35  int apos = WEP_GETPOS(*(const WordEntryPos *) a);
36  int bpos = WEP_GETPOS(*(const WordEntryPos *) b);
37 
38  if (apos == bpos)
39  return 0;
40  return (apos > bpos) ? 1 : -1;
41 }
int b
Definition: isn.c:70
int a
Definition: isn.c:69
#define WEP_GETPOS(x)
Definition: ts_type.h:80
uint16 WordEntryPos
Definition: ts_type.h:63

References a, b, and WEP_GETPOS.

Referenced by checkcondition_str(), and uniquePos().

Variable Documentation

◆ tsearch_op_priority

const int tsearch_op_priority[OP_COUNT]
extern

Definition at line 27 of file tsquery.c.