@@ -360,13 +360,7 @@ jsonb_to_tsvector(PG_FUNCTION_ARGS)
360
360
* Worker function for json(_string)_to_tsvector(_byid)
361
361
*/
362
362
static TSVector
363
- json_to_tsvector_worker (Oid cfgId ,
364
- #ifndef JSON_GENERIC
365
- text * json ,
366
- #else
367
- Jsonb * json ,
368
- #endif
369
- uint32 flags )
363
+ json_to_tsvector_worker (Oid cfgId , Jsonb * json , uint32 flags )
370
364
{
371
365
TSVectorBuildState state ;
372
366
ParsedText prs ;
@@ -376,11 +370,7 @@ json_to_tsvector_worker(Oid cfgId,
376
370
state .prs = & prs ;
377
371
state .cfgId = cfgId ;
378
372
379
- #ifndef JSON_GENERIC
380
- iterate_json_values (json , flags , & state , add_to_tsvector );
381
- #else
382
373
iterate_jsonb_values (json , flags , & state , add_to_tsvector );
383
- #endif
384
374
385
375
return make_tsvector (& prs );
386
376
}
@@ -389,41 +379,25 @@ Datum
389
379
json_string_to_tsvector_byid (PG_FUNCTION_ARGS )
390
380
{
391
381
Oid cfgId = PG_GETARG_OID (0 );
392
- #ifndef JSON_GENERIC
393
- text * json = PG_GETARG_TEXT_P (1 );
394
- #else
395
382
Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (1 ));
396
- #endif
397
383
TSVector result ;
398
384
399
385
result = json_to_tsvector_worker (cfgId , json , jtiString );
400
- #ifndef JSON_GENERIC
401
- PG_FREE_IF_COPY (json , 1 );
402
- #else
403
386
PG_FREE_IF_COPY_JSONB (json , 1 );
404
- #endif
405
387
406
388
PG_RETURN_TSVECTOR (result );
407
389
}
408
390
409
391
Datum
410
392
json_string_to_tsvector (PG_FUNCTION_ARGS )
411
393
{
412
- #ifndef JSON_GENERIC
413
- text * json = PG_GETARG_TEXT_P (0 );
414
- #else
415
394
Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (0 ));
416
- #endif
417
395
Oid cfgId ;
418
396
TSVector result ;
419
397
420
398
cfgId = getTSCurrentConfig (true);
421
399
result = json_to_tsvector_worker (cfgId , json , jtiString );
422
- #ifndef JSON_GENERIC
423
- PG_FREE_IF_COPY (json , 0 );
424
- #else
425
400
PG_FREE_IF_COPY_JSONB (json , 0 );
426
- #endif
427
401
428
402
PG_RETURN_TSVECTOR (result );
429
403
}
@@ -432,21 +406,13 @@ Datum
432
406
json_to_tsvector_byid (PG_FUNCTION_ARGS )
433
407
{
434
408
Oid cfgId = PG_GETARG_OID (0 );
435
- #ifndef JSON_GENERIC
436
- text * json = PG_GETARG_TEXT_P (1 );
437
- #else
438
409
Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (1 ));
439
- #endif
440
410
Jsonb * jbFlags = PG_GETARG_JSONB_P (2 );
441
411
TSVector result ;
442
412
uint32 flags = parse_jsonb_index_flags (jbFlags );
443
413
444
414
result = json_to_tsvector_worker (cfgId , json , flags );
445
- #ifndef JSON_GENERIC
446
- PG_FREE_IF_COPY (json , 1 );
447
- #else
448
415
PG_FREE_IF_COPY_JSONB (json , 1 );
449
- #endif
450
416
PG_FREE_IF_COPY_JSONB (jbFlags , 2 );
451
417
452
418
PG_RETURN_TSVECTOR (result );
@@ -455,23 +421,15 @@ json_to_tsvector_byid(PG_FUNCTION_ARGS)
455
421
Datum
456
422
json_to_tsvector (PG_FUNCTION_ARGS )
457
423
{
458
- #ifndef JSON_GENERIC
459
- text * json = PG_GETARG_TEXT_P (0 );
460
- #else
461
424
Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (0 ));
462
- #endif
463
425
Jsonb * jbFlags = PG_GETARG_JSONB_P (1 );
464
426
Oid cfgId ;
465
427
TSVector result ;
466
428
uint32 flags = parse_jsonb_index_flags (jbFlags );
467
429
468
430
cfgId = getTSCurrentConfig (true);
469
431
result = json_to_tsvector_worker (cfgId , json , flags );
470
- #ifndef JSON_GENERIC
471
- PG_FREE_IF_COPY (json , 0 );
472
- #else
473
432
PG_FREE_IF_COPY_JSONB (json , 0 );
474
- #endif
475
433
PG_FREE_IF_COPY_JSONB (jbFlags , 1 );
476
434
477
435
PG_RETURN_TSVECTOR (result );
0 commit comments