PostgreSQL Source Code  git master
to_tsany.c File Reference
#include "postgres.h"
#include "tsearch/ts_cache.h"
#include "tsearch/ts_utils.h"
#include "utils/builtins.h"
#include "utils/jsonapi.h"
Include dependency graph for to_tsany.c:

Go to the source code of this file.

Data Structures

struct  MorphOpaque
 
struct  TSVectorBuildState
 

Typedefs

typedef struct MorphOpaque MorphOpaque
 
typedef struct TSVectorBuildState TSVectorBuildState
 

Functions

static void add_to_tsvector (void *_state, char *elem_value, int elem_len)
 
Datum get_current_ts_config (PG_FUNCTION_ARGS)
 
static int compareWORD (const void *a, const void *b)
 
static int uniqueWORD (ParsedWord *a, int32 l)
 
TSVector make_tsvector (ParsedText *prs)
 
Datum to_tsvector_byid (PG_FUNCTION_ARGS)
 
Datum to_tsvector (PG_FUNCTION_ARGS)
 
static TSVector jsonb_to_tsvector_worker (Oid cfgId, Jsonb *jb, uint32 flags)
 
Datum jsonb_string_to_tsvector_byid (PG_FUNCTION_ARGS)
 
Datum jsonb_string_to_tsvector (PG_FUNCTION_ARGS)
 
Datum jsonb_to_tsvector_byid (PG_FUNCTION_ARGS)
 
Datum jsonb_to_tsvector (PG_FUNCTION_ARGS)
 
static TSVector json_to_tsvector_worker (Oid cfgId, text *json, uint32 flags)
 
Datum json_string_to_tsvector_byid (PG_FUNCTION_ARGS)
 
Datum json_string_to_tsvector (PG_FUNCTION_ARGS)
 
Datum json_to_tsvector_byid (PG_FUNCTION_ARGS)
 
Datum json_to_tsvector (PG_FUNCTION_ARGS)
 
static void pushval_morph (Datum opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
 
Datum to_tsquery_byid (PG_FUNCTION_ARGS)
 
Datum to_tsquery (PG_FUNCTION_ARGS)
 
Datum plainto_tsquery_byid (PG_FUNCTION_ARGS)
 
Datum plainto_tsquery (PG_FUNCTION_ARGS)
 
Datum phraseto_tsquery_byid (PG_FUNCTION_ARGS)
 
Datum phraseto_tsquery (PG_FUNCTION_ARGS)
 
Datum websearch_to_tsquery_byid (PG_FUNCTION_ARGS)
 
Datum websearch_to_tsquery (PG_FUNCTION_ARGS)
 

Typedef Documentation

◆ MorphOpaque

◆ TSVectorBuildState

Function Documentation

◆ add_to_tsvector()

static void add_to_tsvector ( void *  _state,
char *  elem_value,
int  elem_len 
)
static

Definition at line 432 of file to_tsany.c.

References TSVectorBuildState::cfgId, ParsedText::curwords, ParsedText::lenwords, palloc(), parsetext(), ParsedText::pos, TSVectorBuildState::prs, and ParsedText::words.

Referenced by json_to_tsvector_worker(), and jsonb_to_tsvector_worker().

433 {
435  ParsedText *prs = state->prs;
436  int32 prevwords;
437 
438  if (prs->words == NULL)
439  {
440  /*
441  * First time through: initialize words array to a reasonable size.
442  * (parsetext() will realloc it bigger as needed.)
443  */
444  prs->lenwords = 16;
445  prs->words = (ParsedWord *) palloc(sizeof(ParsedWord) * prs->lenwords);
446  prs->curwords = 0;
447  prs->pos = 0;
448  }
449 
450  prevwords = prs->curwords;
451 
452  parsetext(state->cfgId, prs, elem_value, elem_len);
453 
454  /*
455  * If we extracted any words from this JSON element, advance pos to create
456  * an artificial break between elements. This is because we don't want
457  * phrase searches to think that the last word in this element is adjacent
458  * to the first word in the next one.
459  */
460  if (prs->curwords > prevwords)
461  prs->pos += 1;
462 }
int32 lenwords
Definition: ts_utils.h:101
int32 curwords
Definition: ts_utils.h:102
signed int int32
Definition: c.h:313
void parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
Definition: ts_parse.c:358
ParsedWord * words
Definition: ts_utils.h:100
ParsedText * prs
Definition: to_tsany.c:30
Definition: regguts.h:298
int32 pos
Definition: ts_utils.h:103
void * palloc(Size size)
Definition: mcxt.c:924

◆ compareWORD()

static int compareWORD ( const void *  a,
const void *  b 
)
static

Definition at line 47 of file to_tsany.c.

References tsCompareString(), and word().

Referenced by uniqueWORD().

48 {
49  int res;
50 
51  res = tsCompareString(
52  ((const ParsedWord *) a)->word, ((const ParsedWord *) a)->len,
53  ((const ParsedWord *) b)->word, ((const ParsedWord *) b)->len,
54  false);
55 
56  if (res == 0)
57  {
58  if (((const ParsedWord *) a)->pos.pos == ((const ParsedWord *) b)->pos.pos)
59  return 0;
60 
61  res = (((const ParsedWord *) a)->pos.pos > ((const ParsedWord *) b)->pos.pos) ? 1 : -1;
62  }
63 
64  return res;
65 }
int32 tsCompareString(char *a, int lena, char *b, int lenb, bool prefix)
Definition: tsvector_op.c:1160
static void word(struct vars *, int, struct state *, struct state *)
Definition: regcomp.c:1244

◆ get_current_ts_config()

Datum get_current_ts_config ( PG_FUNCTION_ARGS  )

Definition at line 38 of file to_tsany.c.

References getTSCurrentConfig(), and PG_RETURN_OID.

39 {
41 }
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PG_RETURN_OID(x)
Definition: fmgr.h:325

◆ json_string_to_tsvector()

Datum json_string_to_tsvector ( PG_FUNCTION_ARGS  )

Definition at line 382 of file to_tsany.c.

References getTSCurrentConfig(), json_to_tsvector_worker(), jtiString, PG_FREE_IF_COPY, PG_GETARG_TEXT_P, and PG_RETURN_TSVECTOR.

383 {
384  text *json = PG_GETARG_TEXT_P(0);
385  Oid cfgId;
386  TSVector result;
387 
388  cfgId = getTSCurrentConfig(true);
389  result = json_to_tsvector_worker(cfgId, json, jtiString);
390  PG_FREE_IF_COPY(json, 0);
391 
392  PG_RETURN_TSVECTOR(result);
393 }
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
unsigned int Oid
Definition: postgres_ext.h:31
static TSVector json_to_tsvector_worker(Oid cfgId, text *json, uint32 flags)
Definition: to_tsany.c:353
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
#define PG_GETARG_TEXT_P(n)
Definition: fmgr.h:305
Definition: c.h:516

◆ json_string_to_tsvector_byid()

Datum json_string_to_tsvector_byid ( PG_FUNCTION_ARGS  )

Definition at line 369 of file to_tsany.c.

References json_to_tsvector_worker(), jtiString, PG_FREE_IF_COPY, PG_GETARG_OID, PG_GETARG_TEXT_P, and PG_RETURN_TSVECTOR.

370 {
371  Oid cfgId = PG_GETARG_OID(0);
372  text *json = PG_GETARG_TEXT_P(1);
373  TSVector result;
374 
375  result = json_to_tsvector_worker(cfgId, json, jtiString);
376  PG_FREE_IF_COPY(json, 1);
377 
378  PG_RETURN_TSVECTOR(result);
379 }
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
static TSVector json_to_tsvector_worker(Oid cfgId, text *json, uint32 flags)
Definition: to_tsany.c:353
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
#define PG_GETARG_TEXT_P(n)
Definition: fmgr.h:305
Definition: c.h:516

◆ json_to_tsvector()

Datum json_to_tsvector ( PG_FUNCTION_ARGS  )

Definition at line 412 of file to_tsany.c.

References getTSCurrentConfig(), json_to_tsvector_worker(), parse_jsonb_index_flags(), PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_GETARG_TEXT_P, and PG_RETURN_TSVECTOR.

413 {
414  text *json = PG_GETARG_TEXT_P(0);
415  Jsonb *jbFlags = PG_GETARG_JSONB_P(1);
416  Oid cfgId;
417  TSVector result;
418  uint32 flags = parse_jsonb_index_flags(jbFlags);
419 
420  cfgId = getTSCurrentConfig(true);
421  result = json_to_tsvector_worker(cfgId, json, flags);
422  PG_FREE_IF_COPY(json, 0);
423  PG_FREE_IF_COPY(jbFlags, 1);
424 
425  PG_RETURN_TSVECTOR(result);
426 }
Definition: jsonb.h:215
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
unsigned int Oid
Definition: postgres_ext.h:31
uint32 parse_jsonb_index_flags(Jsonb *jb)
Definition: jsonfuncs.c:4952
unsigned int uint32
Definition: c.h:325
static TSVector json_to_tsvector_worker(Oid cfgId, text *json, uint32 flags)
Definition: to_tsany.c:353
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
#define PG_GETARG_TEXT_P(n)
Definition: fmgr.h:305
Definition: c.h:516
#define PG_GETARG_JSONB_P(x)
Definition: jsonb.h:70

◆ json_to_tsvector_byid()

Datum json_to_tsvector_byid ( PG_FUNCTION_ARGS  )

Definition at line 396 of file to_tsany.c.

References json_to_tsvector_worker(), parse_jsonb_index_flags(), PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_GETARG_OID, PG_GETARG_TEXT_P, and PG_RETURN_TSVECTOR.

397 {
398  Oid cfgId = PG_GETARG_OID(0);
399  text *json = PG_GETARG_TEXT_P(1);
400  Jsonb *jbFlags = PG_GETARG_JSONB_P(2);
401  TSVector result;
402  uint32 flags = parse_jsonb_index_flags(jbFlags);
403 
404  result = json_to_tsvector_worker(cfgId, json, flags);
405  PG_FREE_IF_COPY(json, 1);
406  PG_FREE_IF_COPY(jbFlags, 2);
407 
408  PG_RETURN_TSVECTOR(result);
409 }
Definition: jsonb.h:215
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
uint32 parse_jsonb_index_flags(Jsonb *jb)
Definition: jsonfuncs.c:4952
unsigned int uint32
Definition: c.h:325
static TSVector json_to_tsvector_worker(Oid cfgId, text *json, uint32 flags)
Definition: to_tsany.c:353
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
#define PG_GETARG_TEXT_P(n)
Definition: fmgr.h:305
Definition: c.h:516
#define PG_GETARG_JSONB_P(x)
Definition: jsonb.h:70

◆ json_to_tsvector_worker()

static TSVector json_to_tsvector_worker ( Oid  cfgId,
text json,
uint32  flags 
)
static

Definition at line 353 of file to_tsany.c.

References add_to_tsvector(), TSVectorBuildState::cfgId, ParsedText::curwords, iterate_json_values(), make_tsvector(), TSVectorBuildState::prs, and ParsedText::words.

Referenced by json_string_to_tsvector(), json_string_to_tsvector_byid(), json_to_tsvector(), and json_to_tsvector_byid().

354 {
356  ParsedText prs;
357 
358  prs.words = NULL;
359  prs.curwords = 0;
360  state.prs = &prs;
361  state.cfgId = cfgId;
362 
363  iterate_json_values(json, flags, &state, add_to_tsvector);
364 
365  return make_tsvector(&prs);
366 }
TSVector make_tsvector(ParsedText *prs)
Definition: to_tsany.c:156
static void add_to_tsvector(void *_state, char *elem_value, int elem_len)
Definition: to_tsany.c:432
int32 curwords
Definition: ts_utils.h:102
ParsedWord * words
Definition: ts_utils.h:100
ParsedText * prs
Definition: to_tsany.c:30
void iterate_json_values(text *json, uint32 flags, void *action_state, JsonIterateStringValuesAction action)
Definition: jsonfuncs.c:5088
Definition: regguts.h:298

◆ jsonb_string_to_tsvector()

Datum jsonb_string_to_tsvector ( PG_FUNCTION_ARGS  )

Definition at line 303 of file to_tsany.c.

References getTSCurrentConfig(), jsonb_to_tsvector_worker(), jtiString, PG_FREE_IF_COPY, PG_GETARG_JSONB_P, and PG_RETURN_TSVECTOR.

304 {
305  Jsonb *jb = PG_GETARG_JSONB_P(0);
306  Oid cfgId;
307  TSVector result;
308 
309  cfgId = getTSCurrentConfig(true);
310  result = jsonb_to_tsvector_worker(cfgId, jb, jtiString);
311  PG_FREE_IF_COPY(jb, 0);
312 
313  PG_RETURN_TSVECTOR(result);
314 }
Definition: jsonb.h:215
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
static TSVector jsonb_to_tsvector_worker(Oid cfgId, Jsonb *jb, uint32 flags)
Definition: to_tsany.c:274
#define PG_GETARG_JSONB_P(x)
Definition: jsonb.h:70

◆ jsonb_string_to_tsvector_byid()

Datum jsonb_string_to_tsvector_byid ( PG_FUNCTION_ARGS  )

Definition at line 290 of file to_tsany.c.

References jsonb_to_tsvector_worker(), jtiString, PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_GETARG_OID, and PG_RETURN_TSVECTOR.

291 {
292  Oid cfgId = PG_GETARG_OID(0);
293  Jsonb *jb = PG_GETARG_JSONB_P(1);
294  TSVector result;
295 
296  result = jsonb_to_tsvector_worker(cfgId, jb, jtiString);
297  PG_FREE_IF_COPY(jb, 1);
298 
299  PG_RETURN_TSVECTOR(result);
300 }
Definition: jsonb.h:215
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
static TSVector jsonb_to_tsvector_worker(Oid cfgId, Jsonb *jb, uint32 flags)
Definition: to_tsany.c:274
#define PG_GETARG_JSONB_P(x)
Definition: jsonb.h:70

◆ jsonb_to_tsvector()

Datum jsonb_to_tsvector ( PG_FUNCTION_ARGS  )

Definition at line 333 of file to_tsany.c.

References getTSCurrentConfig(), jsonb_to_tsvector_worker(), parse_jsonb_index_flags(), PG_FREE_IF_COPY, PG_GETARG_JSONB_P, and PG_RETURN_TSVECTOR.

334 {
335  Jsonb *jb = PG_GETARG_JSONB_P(0);
336  Jsonb *jbFlags = PG_GETARG_JSONB_P(1);
337  Oid cfgId;
338  TSVector result;
339  uint32 flags = parse_jsonb_index_flags(jbFlags);
340 
341  cfgId = getTSCurrentConfig(true);
342  result = jsonb_to_tsvector_worker(cfgId, jb, flags);
343  PG_FREE_IF_COPY(jb, 0);
344  PG_FREE_IF_COPY(jbFlags, 1);
345 
346  PG_RETURN_TSVECTOR(result);
347 }
Definition: jsonb.h:215
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
unsigned int Oid
Definition: postgres_ext.h:31
uint32 parse_jsonb_index_flags(Jsonb *jb)
Definition: jsonfuncs.c:4952
unsigned int uint32
Definition: c.h:325
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
static TSVector jsonb_to_tsvector_worker(Oid cfgId, Jsonb *jb, uint32 flags)
Definition: to_tsany.c:274
#define PG_GETARG_JSONB_P(x)
Definition: jsonb.h:70

◆ jsonb_to_tsvector_byid()

Datum jsonb_to_tsvector_byid ( PG_FUNCTION_ARGS  )

Definition at line 317 of file to_tsany.c.

References jsonb_to_tsvector_worker(), parse_jsonb_index_flags(), PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_GETARG_OID, and PG_RETURN_TSVECTOR.

318 {
319  Oid cfgId = PG_GETARG_OID(0);
320  Jsonb *jb = PG_GETARG_JSONB_P(1);
321  Jsonb *jbFlags = PG_GETARG_JSONB_P(2);
322  TSVector result;
323  uint32 flags = parse_jsonb_index_flags(jbFlags);
324 
325  result = jsonb_to_tsvector_worker(cfgId, jb, flags);
326  PG_FREE_IF_COPY(jb, 1);
327  PG_FREE_IF_COPY(jbFlags, 2);
328 
329  PG_RETURN_TSVECTOR(result);
330 }
Definition: jsonb.h:215
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
uint32 parse_jsonb_index_flags(Jsonb *jb)
Definition: jsonfuncs.c:4952
unsigned int uint32
Definition: c.h:325
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
static TSVector jsonb_to_tsvector_worker(Oid cfgId, Jsonb *jb, uint32 flags)
Definition: to_tsany.c:274
#define PG_GETARG_JSONB_P(x)
Definition: jsonb.h:70

◆ jsonb_to_tsvector_worker()

static TSVector jsonb_to_tsvector_worker ( Oid  cfgId,
Jsonb jb,
uint32  flags 
)
static

Definition at line 274 of file to_tsany.c.

References add_to_tsvector(), TSVectorBuildState::cfgId, ParsedText::curwords, iterate_jsonb_values(), make_tsvector(), TSVectorBuildState::prs, and ParsedText::words.

Referenced by jsonb_string_to_tsvector(), jsonb_string_to_tsvector_byid(), jsonb_to_tsvector(), and jsonb_to_tsvector_byid().

275 {
277  ParsedText prs;
278 
279  prs.words = NULL;
280  prs.curwords = 0;
281  state.prs = &prs;
282  state.cfgId = cfgId;
283 
284  iterate_jsonb_values(jb, flags, &state, add_to_tsvector);
285 
286  return make_tsvector(&prs);
287 }
TSVector make_tsvector(ParsedText *prs)
Definition: to_tsany.c:156
static void add_to_tsvector(void *_state, char *elem_value, int elem_len)
Definition: to_tsany.c:432
void iterate_jsonb_values(Jsonb *jb, uint32 flags, void *state, JsonIterateStringValuesAction action)
Definition: jsonfuncs.c:5020
int32 curwords
Definition: ts_utils.h:102
ParsedWord * words
Definition: ts_utils.h:100
ParsedText * prs
Definition: to_tsany.c:30
Definition: regguts.h:298

◆ make_tsvector()

TSVector make_tsvector ( ParsedText prs)

Definition at line 156 of file to_tsany.c.

References ParsedWord::alen, ARRPTR, CALCDATASIZE, ParsedText::curwords, elog, ereport, errcode(), errmsg(), ERROR, WordEntry::haspos, i, WordEntry::len, ParsedWord::len, MAXSTRPOS, palloc0(), pfree(), WordEntry::pos, ParsedWord::pos, POSDATAPTR, SET_VARSIZE, SHORTALIGN, TSVectorData::size, generate_unaccent_rules::str, STRPTR, uniqueWORD(), WEP_SETPOS, WEP_SETWEIGHT, ParsedWord::word, and ParsedText::words.

Referenced by json_to_tsvector_worker(), jsonb_to_tsvector_worker(), to_tsvector_byid(), and tsvector_update_trigger().

157 {
158  int i,
159  j,
160  lenstr = 0,
161  totallen;
162  TSVector in;
163  WordEntry *ptr;
164  char *str;
165  int stroff;
166 
167  /* Merge duplicate words */
168  if (prs->curwords > 0)
169  prs->curwords = uniqueWORD(prs->words, prs->curwords);
170 
171  /* Determine space needed */
172  for (i = 0; i < prs->curwords; i++)
173  {
174  lenstr += prs->words[i].len;
175  if (prs->words[i].alen)
176  {
177  lenstr = SHORTALIGN(lenstr);
178  lenstr += sizeof(uint16) + prs->words[i].pos.apos[0] * sizeof(WordEntryPos);
179  }
180  }
181 
182  if (lenstr > MAXSTRPOS)
183  ereport(ERROR,
184  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
185  errmsg("string is too long for tsvector (%d bytes, max %d bytes)", lenstr, MAXSTRPOS)));
186 
187  totallen = CALCDATASIZE(prs->curwords, lenstr);
188  in = (TSVector) palloc0(totallen);
189  SET_VARSIZE(in, totallen);
190  in->size = prs->curwords;
191 
192  ptr = ARRPTR(in);
193  str = STRPTR(in);
194  stroff = 0;
195  for (i = 0; i < prs->curwords; i++)
196  {
197  ptr->len = prs->words[i].len;
198  ptr->pos = stroff;
199  memcpy(str + stroff, prs->words[i].word, prs->words[i].len);
200  stroff += prs->words[i].len;
201  pfree(prs->words[i].word);
202  if (prs->words[i].alen)
203  {
204  int k = prs->words[i].pos.apos[0];
205  WordEntryPos *wptr;
206 
207  if (k > 0xFFFF)
208  elog(ERROR, "positions array too long");
209 
210  ptr->haspos = 1;
211  stroff = SHORTALIGN(stroff);
212  *(uint16 *) (str + stroff) = (uint16) k;
213  wptr = POSDATAPTR(in, ptr);
214  for (j = 0; j < k; j++)
215  {
216  WEP_SETWEIGHT(wptr[j], 0);
217  WEP_SETPOS(wptr[j], prs->words[i].pos.apos[j + 1]);
218  }
219  stroff += sizeof(uint16) + k * sizeof(WordEntryPos);
220  pfree(prs->words[i].pos.apos);
221  }
222  else
223  ptr->haspos = 0;
224  ptr++;
225  }
226 
227  if (prs->words)
228  pfree(prs->words);
229 
230  return in;
231 }
uint16 WordEntryPos
Definition: ts_type.h:63
uint32 len
Definition: ts_type.h:44
int errcode(int sqlerrcode)
Definition: elog.c:575
#define MAXSTRPOS
Definition: ts_type.h:50
#define WEP_SETPOS(x, v)
Definition: ts_type.h:83
int32 curwords
Definition: ts_utils.h:102
#define POSDATAPTR(x, e)
Definition: ts_type.h:111
unsigned short uint16
Definition: c.h:324
void pfree(void *pointer)
Definition: mcxt.c:1031
#define ERROR
Definition: elog.h:43
#define WEP_SETWEIGHT(x, v)
Definition: ts_type.h:82
int32 size
Definition: ts_type.h:93
ParsedWord * words
Definition: ts_utils.h:100
uint16 pos
Definition: ts_utils.h:84
uint32 haspos
Definition: ts_type.h:44
#define ereport(elevel, rest)
Definition: elog.h:122
#define CALCDATASIZE(x, lenstr)
Definition: hstore.h:72
void * palloc0(Size size)
Definition: mcxt.c:955
TSVectorData * TSVector
Definition: ts_type.h:98
uint16 len
Definition: ts_utils.h:80
uint32 pos
Definition: ts_type.h:44
uint32 alen
Definition: ts_utils.h:95
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define STRPTR(x)
Definition: hstore.h:76
int i
static int uniqueWORD(ParsedWord *a, int32 l)
Definition: to_tsany.c:68
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:329
#define ARRPTR(x)
Definition: cube.c:26
#define elog
Definition: elog.h:219
#define SHORTALIGN(LEN)
Definition: c.h:648
char * word
Definition: ts_utils.h:94

◆ phraseto_tsquery()

Datum phraseto_tsquery ( PG_FUNCTION_ARGS  )

Definition at line 648 of file to_tsany.c.

References DirectFunctionCall2, getTSCurrentConfig(), ObjectIdGetDatum, PG_GETARG_TEXT_PP, PG_RETURN_DATUM, phraseto_tsquery_byid(), and PointerGetDatum.

649 {
650  text *in = PG_GETARG_TEXT_PP(0);
651  Oid cfgId;
652 
653  cfgId = getTSCurrentConfig(true);
655  ObjectIdGetDatum(cfgId),
656  PointerGetDatum(in)));
657 }
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PointerGetDatum(X)
Definition: postgres.h:541
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:318
Definition: c.h:516
Datum phraseto_tsquery_byid(PG_FUNCTION_ARGS)
Definition: to_tsany.c:630
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:592

◆ phraseto_tsquery_byid()

Datum phraseto_tsquery_byid ( PG_FUNCTION_ARGS  )

Definition at line 630 of file to_tsany.c.

References MorphOpaque::cfg_id, OP_PHRASE, P_TSQ_PLAIN, parse_tsquery(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_TSQUERY, PointerGetDatum, pushval_morph(), MorphOpaque::qoperator, and text_to_cstring().

Referenced by phraseto_tsquery().

631 {
632  text *in = PG_GETARG_TEXT_PP(1);
633  TSQuery query;
634  MorphOpaque data;
635 
636  data.cfg_id = PG_GETARG_OID(0);
637  data.qoperator = OP_PHRASE;
638 
639  query = parse_tsquery(text_to_cstring(in),
641  PointerGetDatum(&data),
642  P_TSQ_PLAIN);
643 
644  PG_RETURN_TSQUERY(query);
645 }
#define PointerGetDatum(X)
Definition: postgres.h:541
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define PG_RETURN_TSQUERY(x)
Definition: ts_type.h:240
int qoperator
Definition: to_tsany.c:25
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
#define P_TSQ_PLAIN
Definition: ts_utils.h:61
#define OP_PHRASE
Definition: ts_type.h:169
Oid cfg_id
Definition: to_tsany.c:24
TSQuery parse_tsquery(char *buf, PushFunction pushval, Datum opaque, int flags)
Definition: tsquery.c:817
char * text_to_cstring(const text *t)
Definition: varlena.c:182
Definition: c.h:516
static void pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
Definition: to_tsany.c:481

◆ plainto_tsquery()

Datum plainto_tsquery ( PG_FUNCTION_ARGS  )

Definition at line 617 of file to_tsany.c.

References DirectFunctionCall2, getTSCurrentConfig(), ObjectIdGetDatum, PG_GETARG_TEXT_PP, PG_RETURN_DATUM, plainto_tsquery_byid(), and PointerGetDatum.

Referenced by ts_match_tt().

618 {
619  text *in = PG_GETARG_TEXT_PP(0);
620  Oid cfgId;
621 
622  cfgId = getTSCurrentConfig(true);
624  ObjectIdGetDatum(cfgId),
625  PointerGetDatum(in)));
626 }
Datum plainto_tsquery_byid(PG_FUNCTION_ARGS)
Definition: to_tsany.c:599
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PointerGetDatum(X)
Definition: postgres.h:541
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:318
Definition: c.h:516
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:592

◆ plainto_tsquery_byid()

Datum plainto_tsquery_byid ( PG_FUNCTION_ARGS  )

Definition at line 599 of file to_tsany.c.

References MorphOpaque::cfg_id, OP_AND, P_TSQ_PLAIN, parse_tsquery(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_POINTER, PointerGetDatum, pushval_morph(), MorphOpaque::qoperator, and text_to_cstring().

Referenced by plainto_tsquery().

600 {
601  text *in = PG_GETARG_TEXT_PP(1);
602  TSQuery query;
603  MorphOpaque data;
604 
605  data.cfg_id = PG_GETARG_OID(0);
606  data.qoperator = OP_AND;
607 
608  query = parse_tsquery(text_to_cstring(in),
610  PointerGetDatum(&data),
611  P_TSQ_PLAIN);
612 
613  PG_RETURN_POINTER(query);
614 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:326
#define PointerGetDatum(X)
Definition: postgres.h:541
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define OP_AND
Definition: ts_type.h:167
int qoperator
Definition: to_tsany.c:25
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
#define P_TSQ_PLAIN
Definition: ts_utils.h:61
Oid cfg_id
Definition: to_tsany.c:24
TSQuery parse_tsquery(char *buf, PushFunction pushval, Datum opaque, int flags)
Definition: tsquery.c:817
char * text_to_cstring(const text *t)
Definition: varlena.c:182
Definition: c.h:516
static void pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
Definition: to_tsany.c:481

◆ pushval_morph()

static void pushval_morph ( Datum  opaque,
TSQueryParserState  state,
char *  strval,
int  lenval,
int16  weight,
bool  prefix 
)
static

Definition at line 481 of file to_tsany.c.

References MorphOpaque::cfg_id, ParsedText::curwords, DatumGetPointer, ParsedWord::flags, ParsedWord::len, ParsedText::lenwords, ParsedWord::nvariant, OP_AND, OP_OR, palloc(), parsetext(), pfree(), ParsedWord::pos, ParsedText::pos, pushOperator(), pushStop(), pushValue(), MorphOpaque::qoperator, TSL_PREFIX, ParsedWord::word, and ParsedText::words.

Referenced by phraseto_tsquery_byid(), plainto_tsquery_byid(), to_tsquery_byid(), and websearch_to_tsquery_byid().

482 {
483  int32 count = 0;
484  ParsedText prs;
485  uint32 variant,
486  pos = 0,
487  cntvar = 0,
488  cntpos = 0,
489  cnt = 0;
490  MorphOpaque *data = (MorphOpaque *) DatumGetPointer(opaque);
491 
492  prs.lenwords = 4;
493  prs.curwords = 0;
494  prs.pos = 0;
495  prs.words = (ParsedWord *) palloc(sizeof(ParsedWord) * prs.lenwords);
496 
497  parsetext(data->cfg_id, &prs, strval, lenval);
498 
499  if (prs.curwords > 0)
500  {
501  while (count < prs.curwords)
502  {
503  /*
504  * Were any stop words removed? If so, fill empty positions with
505  * placeholders linked by an appropriate operator.
506  */
507  if (pos > 0 && pos + 1 < prs.words[count].pos.pos)
508  {
509  while (pos + 1 < prs.words[count].pos.pos)
510  {
511  /* put placeholders for each missing stop word */
512  pushStop(state);
513  if (cntpos)
514  pushOperator(state, data->qoperator, 1);
515  cntpos++;
516  pos++;
517  }
518  }
519 
520  /* save current word's position */
521  pos = prs.words[count].pos.pos;
522 
523  /* Go through all variants obtained from this token */
524  cntvar = 0;
525  while (count < prs.curwords && pos == prs.words[count].pos.pos)
526  {
527  variant = prs.words[count].nvariant;
528 
529  /* Push all words belonging to the same variant */
530  cnt = 0;
531  while (count < prs.curwords &&
532  pos == prs.words[count].pos.pos &&
533  variant == prs.words[count].nvariant)
534  {
535  pushValue(state,
536  prs.words[count].word,
537  prs.words[count].len,
538  weight,
539  ((prs.words[count].flags & TSL_PREFIX) || prefix));
540  pfree(prs.words[count].word);
541  if (cnt)
542  pushOperator(state, OP_AND, 0);
543  cnt++;
544  count++;
545  }
546 
547  if (cntvar)
548  pushOperator(state, OP_OR, 0);
549  cntvar++;
550  }
551 
552  if (cntpos)
553  {
554  /* distance may be useful */
555  pushOperator(state, data->qoperator, 1);
556  }
557 
558  cntpos++;
559  }
560 
561  pfree(prs.words);
562 
563  }
564  else
565  pushStop(state);
566 }
#define TSL_PREFIX
Definition: ts_public.h:116
uint16 nvariant
Definition: ts_utils.h:81
int32 lenwords
Definition: ts_utils.h:101
#define OP_OR
Definition: ts_type.h:168
int32 curwords
Definition: ts_utils.h:102
signed int int32
Definition: c.h:313
#define OP_AND
Definition: ts_type.h:167
void pfree(void *pointer)
Definition: mcxt.c:1031
void parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
Definition: ts_parse.c:358
int qoperator
Definition: to_tsany.c:25
void pushStop(TSQueryParserState state)
Definition: tsquery.c:630
void pushValue(TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
Definition: tsquery.c:594
unsigned int uint32
Definition: c.h:325
ParsedWord * words
Definition: ts_utils.h:100
uint16 pos
Definition: ts_utils.h:84
void pushOperator(TSQueryParserState state, int8 oper, int16 distance)
Definition: tsquery.c:545
uint16 len
Definition: ts_utils.h:80
int32 pos
Definition: ts_utils.h:103
Oid cfg_id
Definition: to_tsany.c:24
#define DatumGetPointer(X)
Definition: postgres.h:534
uint16 flags
Definition: ts_utils.h:93
void * palloc(Size size)
Definition: mcxt.c:924
char * word
Definition: ts_utils.h:94

◆ to_tsquery()

Datum to_tsquery ( PG_FUNCTION_ARGS  )

Definition at line 587 of file to_tsany.c.

References DirectFunctionCall2, getTSCurrentConfig(), ObjectIdGetDatum, PG_GETARG_TEXT_PP, PG_RETURN_DATUM, PointerGetDatum, and to_tsquery_byid().

588 {
589  text *in = PG_GETARG_TEXT_PP(0);
590  Oid cfgId;
591 
592  cfgId = getTSCurrentConfig(true);
594  ObjectIdGetDatum(cfgId),
595  PointerGetDatum(in)));
596 }
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PointerGetDatum(X)
Definition: postgres.h:541
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:318
Datum to_tsquery_byid(PG_FUNCTION_ARGS)
Definition: to_tsany.c:569
Definition: c.h:516
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:592

◆ to_tsquery_byid()

Datum to_tsquery_byid ( PG_FUNCTION_ARGS  )

Definition at line 569 of file to_tsany.c.

References MorphOpaque::cfg_id, OP_AND, parse_tsquery(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_TSQUERY, PointerGetDatum, pushval_morph(), MorphOpaque::qoperator, and text_to_cstring().

Referenced by to_tsquery().

570 {
571  text *in = PG_GETARG_TEXT_PP(1);
572  TSQuery query;
573  MorphOpaque data;
574 
575  data.cfg_id = PG_GETARG_OID(0);
576  data.qoperator = OP_AND;
577 
578  query = parse_tsquery(text_to_cstring(in),
580  PointerGetDatum(&data),
581  0);
582 
583  PG_RETURN_TSQUERY(query);
584 }
#define PointerGetDatum(X)
Definition: postgres.h:541
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define PG_RETURN_TSQUERY(x)
Definition: ts_type.h:240
#define OP_AND
Definition: ts_type.h:167
int qoperator
Definition: to_tsany.c:25
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
Oid cfg_id
Definition: to_tsany.c:24
TSQuery parse_tsquery(char *buf, PushFunction pushval, Datum opaque, int flags)
Definition: tsquery.c:817
char * text_to_cstring(const text *t)
Definition: varlena.c:182
Definition: c.h:516
static void pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
Definition: to_tsany.c:481

◆ to_tsvector()

Datum to_tsvector ( PG_FUNCTION_ARGS  )

Definition at line 259 of file to_tsany.c.

References DirectFunctionCall2, getTSCurrentConfig(), ObjectIdGetDatum, PG_GETARG_TEXT_PP, PG_RETURN_DATUM, PointerGetDatum, and to_tsvector_byid().

Referenced by ts_match_tq(), and ts_match_tt().

260 {
261  text *in = PG_GETARG_TEXT_PP(0);
262  Oid cfgId;
263 
264  cfgId = getTSCurrentConfig(true);
266  ObjectIdGetDatum(cfgId),
267  PointerGetDatum(in)));
268 }
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PointerGetDatum(X)
Definition: postgres.h:541
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
Datum to_tsvector_byid(PG_FUNCTION_ARGS)
Definition: to_tsany.c:234
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:318
Definition: c.h:516
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:592

◆ to_tsvector_byid()

Datum to_tsvector_byid ( PG_FUNCTION_ARGS  )

Definition at line 234 of file to_tsany.c.

References ParsedText::curwords, ParsedText::lenwords, make_tsvector(), palloc(), parsetext(), PG_FREE_IF_COPY, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_TSVECTOR, ParsedText::pos, VARDATA_ANY, VARSIZE_ANY_EXHDR, and ParsedText::words.

Referenced by to_tsvector().

235 {
236  Oid cfgId = PG_GETARG_OID(0);
237  text *in = PG_GETARG_TEXT_PP(1);
238  ParsedText prs;
239  TSVector out;
240 
241  prs.lenwords = VARSIZE_ANY_EXHDR(in) / 6; /* just estimation of word's
242  * number */
243  if (prs.lenwords < 2)
244  prs.lenwords = 2;
245  prs.curwords = 0;
246  prs.pos = 0;
247  prs.words = (ParsedWord *) palloc(sizeof(ParsedWord) * prs.lenwords);
248 
249  parsetext(cfgId, &prs, VARDATA_ANY(in), VARSIZE_ANY_EXHDR(in));
250 
251  PG_FREE_IF_COPY(in, 1);
252 
253  out = make_tsvector(&prs);
254 
255  PG_RETURN_TSVECTOR(out);
256 }
TSVector make_tsvector(ParsedText *prs)
Definition: to_tsany.c:156
#define VARDATA_ANY(PTR)
Definition: postgres.h:348
#define PG_RETURN_TSVECTOR(x)
Definition: ts_type.h:122
int32 lenwords
Definition: ts_utils.h:101
unsigned int Oid
Definition: postgres_ext.h:31
int32 curwords
Definition: ts_utils.h:102
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
void parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
Definition: ts_parse.c:358
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
ParsedWord * words
Definition: ts_utils.h:100
int32 pos
Definition: ts_utils.h:103
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:230
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:341
void * palloc(Size size)
Definition: mcxt.c:924
Definition: c.h:516

◆ uniqueWORD()

static int uniqueWORD ( ParsedWord a,
int32  l 
)
static

Definition at line 68 of file to_tsany.c.

References ParsedWord::alen, compareWORD(), ParsedWord::len, LIMITPOS, MAXENTRYPOS, MAXNUMPOS, palloc(), pfree(), ParsedWord::pos, qsort, repalloc(), and ParsedWord::word.

Referenced by make_tsvector().

69 {
70  ParsedWord *ptr,
71  *res;
72  int tmppos;
73 
74  if (l == 1)
75  {
76  tmppos = LIMITPOS(a->pos.pos);
77  a->alen = 2;
78  a->pos.apos = (uint16 *) palloc(sizeof(uint16) * a->alen);
79  a->pos.apos[0] = 1;
80  a->pos.apos[1] = tmppos;
81  return l;
82  }
83 
84  res = a;
85  ptr = a + 1;
86 
87  /*
88  * Sort words with its positions
89  */
90  qsort((void *) a, l, sizeof(ParsedWord), compareWORD);
91 
92  /*
93  * Initialize first word and its first position
94  */
95  tmppos = LIMITPOS(a->pos.pos);
96  a->alen = 2;
97  a->pos.apos = (uint16 *) palloc(sizeof(uint16) * a->alen);
98  a->pos.apos[0] = 1;
99  a->pos.apos[1] = tmppos;
100 
101  /*
102  * Summarize position information for each word
103  */
104  while (ptr - a < l)
105  {
106  if (!(ptr->len == res->len &&
107  strncmp(ptr->word, res->word, res->len) == 0))
108  {
109  /*
110  * Got a new word, so put it in result
111  */
112  res++;
113  res->len = ptr->len;
114  res->word = ptr->word;
115  tmppos = LIMITPOS(ptr->pos.pos);
116  res->alen = 2;
117  res->pos.apos = (uint16 *) palloc(sizeof(uint16) * res->alen);
118  res->pos.apos[0] = 1;
119  res->pos.apos[1] = tmppos;
120  }
121  else
122  {
123  /*
124  * The word already exists, so adjust position information. But
125  * before we should check size of position's array, max allowed
126  * value for position and uniqueness of position
127  */
128  pfree(ptr->word);
129  if (res->pos.apos[0] < MAXNUMPOS - 1 && res->pos.apos[res->pos.apos[0]] != MAXENTRYPOS - 1 &&
130  res->pos.apos[res->pos.apos[0]] != LIMITPOS(ptr->pos.pos))
131  {
132  if (res->pos.apos[0] + 1 >= res->alen)
133  {
134  res->alen *= 2;
135  res->pos.apos = (uint16 *) repalloc(res->pos.apos, sizeof(uint16) * res->alen);
136  }
137  if (res->pos.apos[0] == 0 || res->pos.apos[res->pos.apos[0]] != LIMITPOS(ptr->pos.pos))
138  {
139  res->pos.apos[res->pos.apos[0] + 1] = LIMITPOS(ptr->pos.pos);
140  res->pos.apos[0]++;
141  }
142  }
143  }
144  ptr++;
145  }
146 
147  return res + 1 - a;
148 }
unsigned short uint16
Definition: c.h:324
void pfree(void *pointer)
Definition: mcxt.c:1031
#define MAXNUMPOS
Definition: ts_type.h:86
uint16 pos
Definition: ts_utils.h:84
static int compareWORD(const void *a, const void *b)
Definition: to_tsany.c:47
uint16 len
Definition: ts_utils.h:80
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1044
uint32 alen
Definition: ts_utils.h:95
void * palloc(Size size)
Definition: mcxt.c:924
#define LIMITPOS(x)
Definition: ts_type.h:87
#define qsort(a, b, c, d)
Definition: port.h:421
#define MAXENTRYPOS
Definition: ts_type.h:85
char * word
Definition: ts_utils.h:94

◆ websearch_to_tsquery()

Datum websearch_to_tsquery ( PG_FUNCTION_ARGS  )

Definition at line 679 of file to_tsany.c.

References DirectFunctionCall2, getTSCurrentConfig(), ObjectIdGetDatum, PG_GETARG_TEXT_PP, PG_RETURN_DATUM, PointerGetDatum, and websearch_to_tsquery_byid().

680 {
681  text *in = PG_GETARG_TEXT_PP(0);
682  Oid cfgId;
683 
684  cfgId = getTSCurrentConfig(true);
686  ObjectIdGetDatum(cfgId),
687  PointerGetDatum(in)));
688 
689 }
Oid getTSCurrentConfig(bool emitError)
Definition: ts_cache.c:560
#define PointerGetDatum(X)
Definition: postgres.h:541
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:318
Definition: c.h:516
Datum websearch_to_tsquery_byid(PG_FUNCTION_ARGS)
Definition: to_tsany.c:660
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:592

◆ websearch_to_tsquery_byid()

Datum websearch_to_tsquery_byid ( PG_FUNCTION_ARGS  )

Definition at line 660 of file to_tsany.c.

References MorphOpaque::cfg_id, OP_AND, P_TSQ_WEB, parse_tsquery(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_TSQUERY, PointerGetDatum, pushval_morph(), MorphOpaque::qoperator, and text_to_cstring().

Referenced by websearch_to_tsquery().

661 {
662  text *in = PG_GETARG_TEXT_PP(1);
663  MorphOpaque data;
664  TSQuery query = NULL;
665 
666  data.cfg_id = PG_GETARG_OID(0);
667 
668  data.qoperator = OP_AND;
669 
670  query = parse_tsquery(text_to_cstring(in),
672  PointerGetDatum(&data),
673  P_TSQ_WEB);
674 
675  PG_RETURN_TSQUERY(query);
676 }
#define PointerGetDatum(X)
Definition: postgres.h:541
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define PG_RETURN_TSQUERY(x)
Definition: ts_type.h:240
#define OP_AND
Definition: ts_type.h:167
int qoperator
Definition: to_tsany.c:25
#define PG_GETARG_OID(n)
Definition: fmgr.h:245
Oid cfg_id
Definition: to_tsany.c:24
#define P_TSQ_WEB
Definition: ts_utils.h:62
TSQuery parse_tsquery(char *buf, PushFunction pushval, Datum opaque, int flags)
Definition: tsquery.c:817
char * text_to_cstring(const text *t)
Definition: varlena.c:182
Definition: c.h:516
static void pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
Definition: to_tsany.c:481