Skip to content

Commit ca1886b

Browse files
author
Nikita Glukhov
committed
Remove unused json functions
1 parent 3204b87 commit ca1886b

File tree

6 files changed

+208
-3356
lines changed

6 files changed

+208
-3356
lines changed

src/backend/tsearch/to_tsany.c

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,7 @@ jsonb_to_tsvector(PG_FUNCTION_ARGS)
350350
* Worker function for json(_string)_to_tsvector(_byid)
351351
*/
352352
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)
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
379369
json_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

399381
Datum
400382
json_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
422396
json_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)
445411
Datum
446412
json_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);

src/backend/tsearch/wparser.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,7 @@ Datum
455455
ts_headline_json_byid_opt(PG_FUNCTION_ARGS)
456456
{
457457
Oid tsconfig = PG_GETARG_OID(0);
458-
#ifndef JSON_GENERIC
459-
text *json = PG_GETARG_TEXT_P(1);
460-
#else
461458
Jsonb *json = DatumGetJsontP(PG_GETARG_DATUM(1));
462-
#endif
463459
TSQuery query = PG_GETARG_TSQUERY(2);
464460
text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
465461
text *out;
@@ -486,10 +482,6 @@ ts_headline_json_byid_opt(PG_FUNCTION_ARGS)
486482
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
487483
errmsg("text search parser does not support headline creation")));
488484

489-
#ifndef JSON_GENERIC
490-
out = transform_json_string_values(json, state, action);
491-
PG_FREE_IF_COPY(json, 1);
492-
#else
493485
{
494486
Jsonb *jsonb = transform_jsonb_string_values(json, state, action, true);
495487
char *str = JsonToCString(&jsonb->root);
@@ -500,7 +492,6 @@ ts_headline_json_byid_opt(PG_FUNCTION_ARGS)
500492

501493
PG_FREE_IF_COPY_JSONB(json, 1);
502494
}
503-
#endif
504495

505496
PG_FREE_IF_COPY(query, 2);
506497
if (opt)

0 commit comments

Comments
 (0)