42 return (apos > bpos) ? 1 : -1;
89 char *BufferStr = (
char *)
arg;
92 &BufferStr[
b->entry.pos],
b->entry.len,
119 res->entry.len) == 0))
122 buflen +=
res->entry.len;
123 if (
res->entry.haspos)
135 if (
res->entry.haspos)
144 res->poslen = newlen;
150 res->entry.haspos = 1;
159 buflen +=
res->entry.len;
160 if (
res->entry.haspos)
182 Node *escontext = fcinfo->context;
216 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
217 errmsg(
"word is too long (%ld bytes, max %ld bytes)",
223 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
224 errmsg(
"string is too long for tsvector (%ld bytes, max %ld bytes)",
236 while ((
cur -
tmpbuf) + toklen >= buflen)
277 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
278 errmsg(
"string is too long for tsvector (%d bytes, max %d bytes)", buflen,
MAXSTRPOS)));
292 if (arr[
i].entry.haspos)
295 if (arr[
i].poslen > 0xFFFF)
304 memcpy(strbuf + stroff, arr[
i].pos, arr[
i].poslen *
sizeof(
WordEntryPos));
312 Assert((strbuf + stroff - (
char *) in) == totallen);
330 lenbuf = out->
size * 2 + out->
size - 1 + 2 ;
331 for (
i = 0;
i < out->
size;
i++)
338 curout = outbuf = (
char *)
palloc(lenbuf);
339 for (
i = 0;
i < out->
size;
i++)
341 curbegin = curin =
STRPTR(out) + ptr->
pos;
345 while (curin - curbegin < ptr->
len)
351 else if (
t_iseq(curin,
'\\'))
355 *curout++ = *curin++;
422 for (
i = 0;
i < vec->
size;
i++)
440 for (
j = 0;
j < npos;
j++)
461 bool needSort =
false;
471 vec->
size = nentries;
474 for (
i = 0;
i < nentries;
i++)
485 lex_len = strlen(lexeme);
487 elog(
ERROR,
"invalid tsvector: lexeme too long");
490 elog(
ERROR,
"invalid tsvector: maximum total lexeme length exceeded");
493 elog(
ERROR,
"unexpected number of tsvector positions");
500 while (hdrlen +
SHORTALIGN(datalen + lex_len) +
511 memcpy(
STRPTR(vec) + datalen, lexeme, lex_len);
533 *(
STRPTR(vec) + datalen) =
'\0';
540 for (
j = 0;
j < npos;
j++)
544 elog(
ERROR,
"position information is misordered");
547 datalen += (npos + 1) *
sizeof(
WordEntry);
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
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)
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)
#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