40 return (apos > bpos) ? 1 : -1;
87 char *BufferStr = (
char *)
arg;
90 &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)
214 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
215 errmsg(
"word is too long (%ld bytes, max %ld bytes)",
221 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
222 errmsg(
"string is too long for tsvector (%ld bytes, max %ld bytes)",
234 while ((
cur -
tmpbuf) + toklen >= buflen)
244 memcpy((
void *)
cur, (
void *) token, toklen);
271 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
272 errmsg(
"string is too long for tsvector (%d bytes, max %d bytes)", buflen,
MAXSTRPOS)));
286 if (arr[
i].entry.haspos)
288 if (arr[
i].poslen > 0xFFFF)
297 memcpy(strbuf + stroff, arr[
i].pos, arr[
i].poslen *
sizeof(
WordEntryPos));
305 Assert((strbuf + stroff - (
char *) in) == totallen);
323 lenbuf = out->
size * 2 + out->
size - 1 + 2 ;
324 for (
i = 0;
i < out->
size;
i++)
331 curout = outbuf = (
char *)
palloc(lenbuf);
332 for (
i = 0;
i < out->
size;
i++)
334 curbegin = curin =
STRPTR(out) + ptr->
pos;
338 while (curin - curbegin < ptr->
len)
344 else if (
t_iseq(curin,
'\\'))
348 *curout++ = *curin++;
415 for (
i = 0;
i < vec->
size;
i++)
433 for (
j = 0;
j < npos;
j++)
454 bool needSort =
false;
464 vec->
size = nentries;
467 for (
i = 0;
i < nentries;
i++)
478 lex_len = strlen(lexeme);
480 elog(
ERROR,
"invalid tsvector: lexeme too long");
483 elog(
ERROR,
"invalid tsvector: maximum total lexeme length exceeded");
486 elog(
ERROR,
"unexpected number of tsvector positions");
493 while (hdrlen +
SHORTALIGN(datalen + lex_len) +
504 memcpy(
STRPTR(vec) + datalen, lexeme, lex_len);
526 *(
STRPTR(vec) + datalen) =
'\0';
533 for (
j = 0;
j < npos;
j++)
537 elog(
ERROR,
"position information is misordered");
540 datalen += (npos + 1) *
sizeof(
WordEntry);
static void PGresult * res
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#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)
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
#define qsort(a, b, c, d)
#define SET_VARSIZE(PTR, len)
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)
static StringInfoData tmpbuf