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.

Referenced by add_pos(), calc_rank_and(), tsvector_concat(), tsvector_filter(), and tsvector_unnest().

◆ 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 219 of file ts_type.h.

◆ DATAHDRSIZE

#define DATAHDRSIZE   (offsetof(TSVectorData, entries))

Definition at line 100 of file ts_type.h.

Referenced by tsvectorrecv().

◆ DatumGetTSQuery

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

Definition at line 235 of file ts_type.h.

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

◆ DatumGetTSQueryCopy

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

Definition at line 236 of file ts_type.h.

◆ DatumGetTSVector

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

◆ 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 227 of file ts_type.h.

◆ GETQUERY

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

Definition at line 224 of file ts_type.h.

◆ HDRSIZETQ

#define HDRSIZETQ   ( VARHDRSZ + sizeof(int32) )

◆ LIMITPOS

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

Definition at line 87 of file ts_type.h.

Referenced by add_pos(), gettoken_tsvector(), hlfinditem(), parsetext(), and uniqueWORD().

◆ MAXENTRYPOS

#define MAXENTRYPOS   (1<<14)

◆ MAXNUMPOS

#define MAXNUMPOS   (256)

Definition at line 86 of file ts_type.h.

Referenced by add_pos(), tsvectorrecv(), uniquePos(), and uniqueWORD().

◆ MAXSTRLEN

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

◆ MAXSTRPOS

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

◆ OP_AND

◆ OP_COUNT

#define OP_COUNT   4

Definition at line 170 of file ts_type.h.

◆ OP_NOT

◆ OP_OR

◆ OP_PHRASE

◆ OP_PRIORITY

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

Definition at line 175 of file ts_type.h.

Referenced by cleanOpStack().

◆ PG_GETARG_TSQUERY

◆ PG_GETARG_TSQUERY_COPY

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

◆ PG_GETARG_TSVECTOR

◆ PG_GETARG_TSVECTOR_COPY

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

Definition at line 121 of file ts_type.h.

Referenced by tsvector_unnest().

◆ PG_RETURN_TSQUERY

#define PG_RETURN_TSQUERY (   x)    return TSQueryGetDatum(x)

◆ PG_RETURN_TSVECTOR

#define PG_RETURN_TSVECTOR (   x)    return TSVectorGetDatum(x)

◆ POSDATALEN

◆ POSDATAPTR

◆ QI_OPR

◆ QI_VAL

◆ 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.

Referenced by clean_stopword_intree(), findoprnd_recurse(), parse_tsquery(), and pushStop().

◆ QO_PRIORITY

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

Definition at line 177 of file ts_type.h.

Referenced by infix().

◆ 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 220 of file ts_type.h.

Referenced by parse_tsquery(), and QTN2QT().

◆ TSQueryGetDatum

#define TSQueryGetDatum (   X)    PointerGetDatum(X)

Definition at line 237 of file ts_type.h.

Referenced by ts_match_tq(), and ts_match_tt().

◆ TSVectorGetDatum

#define TSVectorGetDatum (   X)    PointerGetDatum(X)

◆ WEP_GETPOS

◆ WEP_GETWEIGHT

◆ WEP_SETPOS

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

Definition at line 83 of file ts_type.h.

Referenced by add_pos(), calc_rank_and(), gettoken_tsvector(), and make_tsvector().

◆ WEP_SETWEIGHT

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

Typedef Documentation

◆ QueryItemType

Definition at line 131 of file ts_type.h.

◆ TSQuery

Definition at line 212 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.

References WEP_GETPOS.

Referenced by uniqueLongPos(), and uniquePos().

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 }
uint16 WordEntryPos
Definition: ts_type.h:63
#define WEP_GETPOS(x)
Definition: ts_type.h:80

Variable Documentation

◆ tsearch_op_priority

const int tsearch_op_priority[OP_COUNT]

Definition at line 27 of file tsquery.c.