22#include "utils/fmgrprotos.h"
91 char *BufferStr = (
char *)
arg;
94 &BufferStr[
b->pos],
b->len,
178 Node *escontext = fcinfo->context;
212 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
213 errmsg(
"word is too long (%ld bytes, max %ld bytes)",
219 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
220 errmsg(
"string is too long for tsvector (%ld bytes, max %ld bytes)",
232 while ((
cur -
tmpbuf) + toklen >= buflen)
273 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
274 errmsg(
"string is too long for tsvector (%d bytes, max %d bytes)", buflen,
MAXSTRPOS)));
288 if (arr[
i].entry.haspos)
291 if (arr[
i].poslen > 0xFFFF)
300 memcpy(strbuf + stroff, arr[
i].pos, arr[
i].poslen *
sizeof(
WordEntryPos));
308 Assert((strbuf + stroff - (
char *) in) == totallen);
326 lenbuf = out->
size * 2 + out->
size - 1 + 2 ;
327 for (
i = 0;
i < out->
size;
i++)
334 curout = outbuf = (
char *)
palloc(lenbuf);
335 for (
i = 0;
i < out->
size;
i++)
337 curbegin = curin =
STRPTR(out) + ptr->
pos;
341 while (curin - curbegin < ptr->
len)
347 else if (
t_iseq(curin,
'\\'))
351 *curout++ = *curin++;
418 for (
i = 0;
i < vec->
size;
i++)
436 for (
j = 0;
j < npos;
j++)
457 bool needSort =
false;
467 vec->
size = nentries;
470 for (
i = 0;
i < nentries;
i++)
481 lex_len = strlen(lexeme);
483 elog(
ERROR,
"invalid tsvector: lexeme too long");
486 elog(
ERROR,
"invalid tsvector: maximum total lexeme length exceeded");
489 elog(
ERROR,
"unexpected number of tsvector positions");
496 while (hdrlen +
SHORTALIGN(datalen + lex_len) +
507 memcpy(
STRPTR(vec) + datalen, lexeme, lex_len);
529 *(
STRPTR(vec) + datalen) =
'\0';
536 for (
j = 0;
j < npos;
j++)
540 elog(
ERROR,
"position information is misordered");
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define PG_FREE_IF_COPY(ptr, n)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_GETARG_CSTRING(n)
Assert(PointerIsAligned(start, uint64))
#define CALCDATASIZE(x, lenstr)
static int pg_cmp_s32(int32 a, int32 b)
int pg_database_encoding_max_length(void)
int pg_mblen(const char *mbstr)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
#define SOFT_ERROR_OCCURRED(escontext)
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
#define qsort(a, b, c, d)
StringInfoData * StringInfo
WordEntry entries[FLEXIBLE_ARRAY_MEMBER]
#define PG_GETARG_TSVECTOR(n)
#define PG_RETURN_TSVECTOR(x)
#define WEP_SETWEIGHT(x, v)
Datum tsvectorout(PG_FUNCTION_ARGS)
static int uniquePos(WordEntryPos *a, int l)
Datum tsvectorrecv(PG_FUNCTION_ARGS)
static int compareentry(const void *va, const void *vb, void *arg)
Datum tsvectorin(PG_FUNCTION_ARGS)
int compareWordEntryPos(const void *a, const void *b)
Datum tsvectorsend(PG_FUNCTION_ARGS)
static int uniqueentry(WordEntryIN *a, int l, char *buf, int *outbuflen)
int32 tsCompareString(char *a, int lena, char *b, int lenb, bool prefix)
void close_tsvector_parser(TSVectorParseState state)
bool gettoken_tsvector(TSVectorParseState state, char **strval, int *lenval, WordEntryPos **pos_ptr, int *poslen, char **endptr)
TSVectorParseState init_tsvector_parser(char *input, int flags, Node *escontext)
#define SET_VARSIZE(PTR, len)
static StringInfoData tmpbuf