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