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 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 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)
 
static TSVector DatumGetTSVector (Datum X)
 
static TSVector DatumGetTSVectorCopy (Datum X)
 
static Datum TSVectorGetDatum (const TSVectorData *X)
 
static TSQuery DatumGetTSQuery (Datum X)
 
static TSQuery DatumGetTSQueryCopy (Datum X)
 
static Datum TSQueryGetDatum (const TSQueryData *X)
 

Variables

PGDLLIMPORT 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 232 of file ts_type.h.

◆ DATAHDRSIZE

#define DATAHDRSIZE   (offsetof(TSVectorData, entries))

Definition at line 100 of file ts_type.h.

◆ GETOPERAND

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

Definition at line 240 of file ts_type.h.

◆ GETQUERY

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

Definition at line 237 of file ts_type.h.

◆ HDRSIZETQ

#define HDRSIZETQ   ( VARHDRSZ + sizeof(int32) )

Definition at line 227 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 180 of file ts_type.h.

◆ OP_COUNT

#define OP_COUNT   4

Definition at line 183 of file ts_type.h.

◆ OP_NOT

#define OP_NOT   1

Definition at line 179 of file ts_type.h.

◆ OP_OR

#define OP_OR   3

Definition at line 181 of file ts_type.h.

◆ OP_PHRASE

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

Definition at line 182 of file ts_type.h.

◆ OP_PRIORITY

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

Definition at line 188 of file ts_type.h.

◆ PG_GETARG_TSQUERY

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

Definition at line 266 of file ts_type.h.

◆ PG_GETARG_TSQUERY_COPY

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

Definition at line 267 of file ts_type.h.

◆ PG_GETARG_TSVECTOR

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

Definition at line 135 of file ts_type.h.

◆ PG_GETARG_TSVECTOR_COPY

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

Definition at line 136 of file ts_type.h.

◆ PG_RETURN_TSQUERY

#define PG_RETURN_TSQUERY (   x)    return TSQueryGetDatum(x)

Definition at line 268 of file ts_type.h.

◆ PG_RETURN_TSVECTOR

#define PG_RETURN_TSVECTOR (   x)    return TSVectorGetDatum(x)

Definition at line 137 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 150 of file ts_type.h.

◆ QI_VAL

#define QI_VAL   1

Definition at line 149 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 151 of file ts_type.h.

◆ QO_PRIORITY

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

Definition at line 190 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 233 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 146 of file ts_type.h.

◆ TSQuery

typedef TSQueryData* TSQuery

Definition at line 225 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 36 of file tsvector.c.

37 {
38  int apos = WEP_GETPOS(*(const WordEntryPos *) a);
39  int bpos = WEP_GETPOS(*(const WordEntryPos *) b);
40 
41  return pg_cmp_s32(apos, bpos);
42 }
static int pg_cmp_s32(int32 a, int32 b)
Definition: int.h:483
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, pg_cmp_s32(), and WEP_GETPOS.

Referenced by checkcondition_str(), and uniquePos().

◆ DatumGetTSQuery()

static TSQuery DatumGetTSQuery ( Datum  X)
inlinestatic

Definition at line 249 of file ts_type.h.

252 {

References DatumGetPointer().

Referenced by gtsquery_compress(), ts_match_tt(), tsquery_rewrite_query(), and tsquerysel().

◆ DatumGetTSQueryCopy()

static TSQuery DatumGetTSQueryCopy ( Datum  X)
inlinestatic

Definition at line 255 of file ts_type.h.

258 {

References PG_DETOAST_DATUM_COPY.

◆ DatumGetTSVector()

static TSVector DatumGetTSVector ( Datum  X)
inlinestatic

Definition at line 118 of file ts_type.h.

119 {
120  return (TSVector) PG_DETOAST_DATUM(X);
121 }
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240

References PG_DETOAST_DATUM.

Referenced by compute_tsvector_stats(), gtsvector_compress(), ts_accum(), ts_match_tq(), and ts_match_tt().

◆ DatumGetTSVectorCopy()

static TSVector DatumGetTSVectorCopy ( Datum  X)
inlinestatic

Definition at line 124 of file ts_type.h.

125 {
126  return (TSVector) PG_DETOAST_DATUM_COPY(X);
127 }
#define PG_DETOAST_DATUM_COPY(datum)
Definition: fmgr.h:242

References PG_DETOAST_DATUM_COPY.

◆ TSQueryGetDatum()

static Datum TSQueryGetDatum ( const TSQueryData X)
inlinestatic

Definition at line 261 of file ts_type.h.

264 {

References PointerGetDatum().

Referenced by ts_match_tq(), and ts_match_tt().

◆ TSVectorGetDatum()

static Datum TSVectorGetDatum ( const TSVectorData X)
inlinestatic

Definition at line 130 of file ts_type.h.

131 {
132  return PointerGetDatum(X);
133 }
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322

References PointerGetDatum().

Referenced by compute_tsvector_stats(), ts_match_tq(), ts_match_tt(), and tsvector_update_trigger().

Variable Documentation

◆ tsearch_op_priority

PGDLLIMPORT const int tsearch_op_priority[OP_COUNT]
extern

Definition at line 29 of file tsquery.c.