16
16
#include "tsearch/ts_utils.h"
17
17
#include "utils/array.h"
18
18
#include "utils/builtins.h"
19
+ #include "utils/bytea.h"
19
20
20
21
#include "rum.h"
21
22
@@ -225,11 +226,13 @@ extract_wraps(QueryItemWrap *wrap, ExtractContext *context, int level)
225
226
int index = context -> index ;
226
227
227
228
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 ])));
228
230
229
231
while (wrap -> parent )
230
232
{
231
233
QueryItemWrap * parent = wrap -> parent ;
232
234
uint32 sum ;
235
+ elog (NOTICE , "%d %d %d" , parent -> num , parent -> sum , wrap -> not );
233
236
encode_varbyte ((uint32 ) parent -> num , & ptr );
234
237
sum = (uint32 )abs (parent -> sum );
235
238
sum <<= 2 ;
@@ -338,7 +341,7 @@ ruminv_extract_tsvector(PG_FUNCTION_ARGS)
338
341
{
339
342
text * txt ;
340
343
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 );
342
345
entries [i ] = PointerGetDatum (txt );
343
346
}
344
347
}
@@ -364,7 +367,7 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
364
367
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
365
368
bool * recheck = (bool * ) PG_GETARG_POINTER (5 );
366
369
Datum * addInfo = (Datum * ) PG_GETARG_POINTER (8 );
367
- /* bool *addInfoIsNull = (bool *) PG_GETARG_POINTER(9); */
370
+ bool * addInfoIsNull = (bool * ) PG_GETARG_POINTER (9 );
368
371
bool res = false;
369
372
int i ,
370
373
lastIndex = 0 ;
@@ -374,14 +377,22 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
374
377
375
378
for (i = 0 ; i < nkeys ; i ++ )
376
379
{
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 ;
380
383
TmpNode * child = NULL ;
381
384
382
385
if (!check [i ])
383
386
continue ;
384
387
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
+
385
396
if (size == 0 )
386
397
{
387
398
res = true;
@@ -402,6 +413,8 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
402
413
403
414
index = num - 1 ;
404
415
416
+ /* elog(NOTICE, "a %d %d %d %d", i, index, sum, not);*/
417
+
405
418
if (child )
406
419
{
407
420
child -> parent = index ;
@@ -432,6 +445,11 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
432
445
}
433
446
}
434
447
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
+
435
453
for (i = lastIndex - 1 ; i >= 0 ; i -- )
436
454
{
437
455
if (nodes [i ].parent != -2 )
@@ -446,13 +464,13 @@ ruminv_tsvector_consistent(PG_FUNCTION_ARGS)
446
464
else
447
465
{
448
466
int parent = nodes [i ].parent ;
449
- nodes [parent ].sum += nodes [i ].not ? 1 : - 1 ;
467
+ nodes [parent ].sum += nodes [i ].not ? - 1 : 1 ;
450
468
}
451
469
}
452
470
}
453
471
}
454
472
455
- elog (NOTICE , "%d" , res );
473
+ /* elog(NOTICE, "%d", res);*/
456
474
457
475
PG_RETURN_BOOL (res );
458
476
}
0 commit comments