22 #include "utils/fmgrprotos.h"
88 char *BufferStr = (
char *)
arg;
91 &BufferStr[
b->entry.pos],
b->entry.len,
118 res->entry.len) == 0))
121 buflen +=
res->entry.len;
122 if (
res->entry.haspos)
134 if (
res->entry.haspos)
143 res->poslen = newlen;
149 res->entry.haspos = 1;
158 buflen +=
res->entry.len;
159 if (
res->entry.haspos)
181 Node *escontext = fcinfo->context;
215 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
216 errmsg(
"word is too long (%ld bytes, max %ld bytes)",
222 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
223 errmsg(
"string is too long for tsvector (%ld bytes, max %ld bytes)",
235 while ((
cur -
tmpbuf) + toklen >= buflen)
276 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
277 errmsg(
"string is too long for tsvector (%d bytes, max %d bytes)", buflen,
MAXSTRPOS)));
291 if (arr[
i].entry.haspos)
294 if (arr[
i].poslen > 0xFFFF)
303 memcpy(strbuf + stroff, arr[
i].pos, arr[
i].poslen *
sizeof(
WordEntryPos));
311 Assert((strbuf + stroff - (
char *) in) == totallen);
329 lenbuf = out->
size * 2 + out->
size - 1 + 2 ;
330 for (
i = 0;
i < out->
size;
i++)
337 curout = outbuf = (
char *)
palloc(lenbuf);
338 for (
i = 0;
i < out->
size;
i++)
340 curbegin = curin =
STRPTR(out) + ptr->
pos;
344 while (curin - curbegin < ptr->
len)
350 else if (
t_iseq(curin,
'\\'))
354 *curout++ = *curin++;
421 for (
i = 0;
i < vec->
size;
i++)
439 for (
j = 0;
j < npos;
j++)
460 bool needSort =
false;
470 vec->
size = nentries;
473 for (
i = 0;
i < nentries;
i++)
484 lex_len = strlen(lexeme);
486 elog(
ERROR,
"invalid tsvector: lexeme too long");
489 elog(
ERROR,
"invalid tsvector: maximum total lexeme length exceeded");
492 elog(
ERROR,
"unexpected number of tsvector positions");
499 while (hdrlen +
SHORTALIGN(datalen + lex_len) +
510 memcpy(
STRPTR(vec) + datalen, lexeme, lex_len);
532 *(
STRPTR(vec) + datalen) =
'\0';
539 for (
j = 0;
j < npos;
j++)
543 elog(
ERROR,
"position information is misordered");
#define Assert(condition)
static void PGresult * res
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)
#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 pfree(void *pointer)
void * palloc0(Size size)
void * repalloc(void *pointer, 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 WordEntryCMP(WordEntry *a, WordEntry *b, char *buf)
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