@@ -360,13 +360,7 @@ jsonb_to_tsvector(PG_FUNCTION_ARGS)
360360 * Worker function for json(_string)_to_tsvector(_byid)
361361 */
362362static 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 )
370364{
371365 TSVectorBuildState state ;
372366 ParsedText prs ;
@@ -376,11 +370,7 @@ json_to_tsvector_worker(Oid cfgId,
376370 state .prs = & prs ;
377371 state .cfgId = cfgId ;
378372
379- #ifndef JSON_GENERIC
380- iterate_json_values (json , flags , & state , add_to_tsvector );
381- #else
382373 iterate_jsonb_values (json , flags , & state , add_to_tsvector );
383- #endif
384374
385375 return make_tsvector (& prs );
386376}
@@ -389,41 +379,25 @@ Datum
389379json_string_to_tsvector_byid (PG_FUNCTION_ARGS )
390380{
391381 Oid cfgId = PG_GETARG_OID (0 );
392- #ifndef JSON_GENERIC
393- text * json = PG_GETARG_TEXT_P (1 );
394- #else
395382 Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (1 ));
396- #endif
397383 TSVector result ;
398384
399385 result = json_to_tsvector_worker (cfgId , json , jtiString );
400- #ifndef JSON_GENERIC
401- PG_FREE_IF_COPY (json , 1 );
402- #else
403386 PG_FREE_IF_COPY_JSONB (json , 1 );
404- #endif
405387
406388 PG_RETURN_TSVECTOR (result );
407389}
408390
409391Datum
410392json_string_to_tsvector (PG_FUNCTION_ARGS )
411393{
412- #ifndef JSON_GENERIC
413- text * json = PG_GETARG_TEXT_P (0 );
414- #else
415394 Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (0 ));
416- #endif
417395 Oid cfgId ;
418396 TSVector result ;
419397
420398 cfgId = getTSCurrentConfig (true);
421399 result = json_to_tsvector_worker (cfgId , json , jtiString );
422- #ifndef JSON_GENERIC
423- PG_FREE_IF_COPY (json , 0 );
424- #else
425400 PG_FREE_IF_COPY_JSONB (json , 0 );
426- #endif
427401
428402 PG_RETURN_TSVECTOR (result );
429403}
@@ -432,21 +406,13 @@ Datum
432406json_to_tsvector_byid (PG_FUNCTION_ARGS )
433407{
434408 Oid cfgId = PG_GETARG_OID (0 );
435- #ifndef JSON_GENERIC
436- text * json = PG_GETARG_TEXT_P (1 );
437- #else
438409 Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (1 ));
439- #endif
440410 Jsonb * jbFlags = PG_GETARG_JSONB_P (2 );
441411 TSVector result ;
442412 uint32 flags = parse_jsonb_index_flags (jbFlags );
443413
444414 result = json_to_tsvector_worker (cfgId , json , flags );
445- #ifndef JSON_GENERIC
446- PG_FREE_IF_COPY (json , 1 );
447- #else
448415 PG_FREE_IF_COPY_JSONB (json , 1 );
449- #endif
450416 PG_FREE_IF_COPY_JSONB (jbFlags , 2 );
451417
452418 PG_RETURN_TSVECTOR (result );
@@ -455,23 +421,15 @@ json_to_tsvector_byid(PG_FUNCTION_ARGS)
455421Datum
456422json_to_tsvector (PG_FUNCTION_ARGS )
457423{
458- #ifndef JSON_GENERIC
459- text * json = PG_GETARG_TEXT_P (0 );
460- #else
461424 Jsonb * json = DatumGetJsontP (PG_GETARG_DATUM (0 ));
462- #endif
463425 Jsonb * jbFlags = PG_GETARG_JSONB_P (1 );
464426 Oid cfgId ;
465427 TSVector result ;
466428 uint32 flags = parse_jsonb_index_flags (jbFlags );
467429
468430 cfgId = getTSCurrentConfig (true);
469431 result = json_to_tsvector_worker (cfgId , json , flags );
470- #ifndef JSON_GENERIC
471- PG_FREE_IF_COPY (json , 0 );
472- #else
473432 PG_FREE_IF_COPY_JSONB (json , 0 );
474- #endif
475433 PG_FREE_IF_COPY_JSONB (jbFlags , 1 );
476434
477435 PG_RETURN_TSVECTOR (result );
0 commit comments