@@ -350,13 +350,7 @@ jsonb_to_tsvector(PG_FUNCTION_ARGS)
350350 * Worker function for json(_string)_to_tsvector(_byid)
351351 */
352352static 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 )
360354{
361355 TSVectorBuildState state ;
362356 ParsedText prs ;
@@ -366,11 +360,7 @@ json_to_tsvector_worker(Oid cfgId,
366360 state .prs = & prs ;
367361 state .cfgId = cfgId ;
368362
369- #ifndef JSON_GENERIC
370- iterate_json_values (json , flags , & state , add_to_tsvector );
371- #else
372363 iterate_jsonb_values (json , flags , & state , add_to_tsvector );
373- #endif
374364
375365 return make_tsvector (& prs );
376366}
@@ -379,41 +369,25 @@ Datum
379369json_string_to_tsvector_byid (PG_FUNCTION_ARGS )
380370{
381371 Oid cfgId = PG_GETARG_OID (0 );
382- #ifndef JSON_GENERIC
383- text * json = PG_GETARG_TEXT_P (1 );
384- #else
385372 Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (1 ));
386- #endif
387373 TSVector result ;
388374
389375 result = json_to_tsvector_worker (cfgId , json , jtiString );
390- #ifndef JSON_GENERIC
391- PG_FREE_IF_COPY (json , 1 );
392- #else
393376 PG_FREE_IF_COPY_JSONB (json , 1 );
394- #endif
395377
396378 PG_RETURN_TSVECTOR (result );
397379}
398380
399381Datum
400382json_string_to_tsvector (PG_FUNCTION_ARGS )
401383{
402- #ifndef JSON_GENERIC
403- text * json = PG_GETARG_TEXT_P (0 );
404- #else
405384 Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (0 ));
406- #endif
407385 Oid cfgId ;
408386 TSVector result ;
409387
410388 cfgId = getTSCurrentConfig (true);
411389 result = json_to_tsvector_worker (cfgId , json , jtiString );
412- #ifndef JSON_GENERIC
413- PG_FREE_IF_COPY (json , 0 );
414- #else
415390 PG_FREE_IF_COPY_JSONB (json , 0 );
416- #endif
417391
418392 PG_RETURN_TSVECTOR (result );
419393}
@@ -422,21 +396,13 @@ Datum
422396json_to_tsvector_byid (PG_FUNCTION_ARGS )
423397{
424398 Oid cfgId = PG_GETARG_OID (0 );
425- #ifndef JSON_GENERIC
426- text * json = PG_GETARG_TEXT_P (1 );
427- #else
428399 Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (1 ));
429- #endif
430400 Jsonb * jbFlags = PG_GETARG_JSONB_P (2 );
431401 TSVector result ;
432402 uint32 flags = parse_jsonb_index_flags (jbFlags );
433403
434404 result = json_to_tsvector_worker (cfgId , json , flags );
435- #ifndef JSON_GENERIC
436- PG_FREE_IF_COPY (json , 1 );
437- #else
438405 PG_FREE_IF_COPY_JSONB (json , 1 );
439- #endif
440406 PG_FREE_IF_COPY_JSONB (jbFlags , 2 );
441407
442408 PG_RETURN_TSVECTOR (result );
@@ -445,23 +411,15 @@ json_to_tsvector_byid(PG_FUNCTION_ARGS)
445411Datum
446412json_to_tsvector (PG_FUNCTION_ARGS )
447413{
448- #ifndef JSON_GENERIC
449- text * json = PG_GETARG_TEXT_P (0 );
450- #else
451414 Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (0 ));
452- #endif
453415 Jsonb * jbFlags = PG_GETARG_JSONB_P (1 );
454416 Oid cfgId ;
455417 TSVector result ;
456418 uint32 flags = parse_jsonb_index_flags (jbFlags );
457419
458420 cfgId = getTSCurrentConfig (true);
459421 result = json_to_tsvector_worker (cfgId , json , flags );
460- #ifndef JSON_GENERIC
461- PG_FREE_IF_COPY (json , 0 );
462- #else
463422 PG_FREE_IF_COPY_JSONB (json , 0 );
464- #endif
465423 PG_FREE_IF_COPY_JSONB (jbFlags , 1 );
466424
467425 PG_RETURN_TSVECTOR (result );
0 commit comments