Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 974738a

Browse files
author
Alexander Korotkov
committed
Fix.
1 parent 0d26686 commit 974738a

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

rumtsquery.c

+25-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "tsearch/ts_utils.h"
1717
#include "utils/array.h"
1818
#include "utils/builtins.h"
19+
#include "utils/bytea.h"
1920

2021
#include "rum.h"
2122

@@ -225,11 +226,13 @@ extract_wraps(QueryItemWrap *wrap, ExtractContext *context, int level)
225226
int index = context->index;
226227

227228
context->entries[index] = PointerGetDatum(cstring_to_text_with_len(context->operand + wrap->distance, wrap->length));
229+
elog(NOTICE, "%s", text_to_cstring(DatumGetPointer(context->entries[index])));
228230

229231
while (wrap->parent)
230232
{
231233
QueryItemWrap *parent = wrap->parent;
232234
uint32 sum;
235+
elog(NOTICE, "%d %d %d", parent->num, parent->sum, wrap->not);
233236
encode_varbyte((uint32) parent->num, &ptr);
234237
sum = (uint32)abs(parent->sum);
235238
sum <<= 2;
@@ -338,7 +341,7 @@ ruminv_extract_tsvector(PG_FUNCTION_ARGS)
338341
{
339342
text *txt;
340343

341-
txt = cstring_to_text_with_len(STRPTR(vector) + we->pos, we->len);
344+
txt = cstring_to_text_with_len(STRPTR(vector) + we[i].pos, we[i].len);
342345
entries[i] = PointerGetDatum(txt);
343346
}
344347
}
@@ -364,7 +367,7 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
364367
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
365368
bool *recheck = (bool *) PG_GETARG_POINTER(5);
366369
Datum *addInfo = (Datum *) PG_GETARG_POINTER(8);
367-
/* bool *addInfoIsNull = (bool *) PG_GETARG_POINTER(9); */
370+
bool *addInfoIsNull = (bool *) PG_GETARG_POINTER(9);
368371
bool res = false;
369372
int i,
370373
lastIndex = 0;
@@ -374,14 +377,22 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
374377

375378
for (i = 0; i < nkeys; i++)
376379
{
377-
unsigned char *ptr = (unsigned char *)VARDATA_ANY(DatumGetPointer(addInfo[i])),
378-
*ptrEnd;
379-
int size = VARSIZE_ANY_EXHDR(DatumGetPointer(addInfo[i]));
380+
unsigned char *ptr,
381+
*ptrEnd;
382+
int size;
380383
TmpNode *child = NULL;
381384

382385
if (!check[i])
383386
continue;
384387

388+
if (addInfoIsNull[i])
389+
elog(ERROR, "Unexpected addInfoIsNull");
390+
391+
ptr = (unsigned char *)VARDATA_ANY(DatumGetPointer(addInfo[i]));
392+
size = VARSIZE_ANY_EXHDR(DatumGetPointer(addInfo[i]));
393+
394+
/* elog(NOTICE, "%d %s", i, DatumGetPointer(DirectFunctionCall1(byteaout, addInfo[i])));*/
395+
385396
if (size == 0)
386397
{
387398
res = true;
@@ -402,6 +413,8 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
402413

403414
index = num - 1;
404415

416+
/* elog(NOTICE, "a %d %d %d %d", i, index, sum, not);*/
417+
405418
if (child)
406419
{
407420
child->parent = index;
@@ -432,6 +445,11 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
432445
}
433446
}
434447

448+
/* for (i = 0; i < lastIndex; i++)
449+
{
450+
elog(NOTICE, "s %d %d %d %d", i, nodes[i].sum, nodes[i].parent, nodes[i].not);
451+
}*/
452+
435453
for (i = lastIndex - 1; i >= 0; i--)
436454
{
437455
if (nodes[i].parent != -2)
@@ -446,13 +464,13 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
446464
else
447465
{
448466
int parent = nodes[i].parent;
449-
nodes[parent].sum += nodes[i].not ? 1 : -1;
467+
nodes[parent].sum += nodes[i].not ? -1 : 1;
450468
}
451469
}
452470
}
453471
}
454472

455-
elog(NOTICE, "%d", res);
473+
/* elog(NOTICE, "%d", res);*/
456474

457475
PG_RETURN_BOOL(res);
458476
}

0 commit comments

Comments
 (0)