MCPcopy Create free account
hub / github.com/MariaDB/server / parse

Method parse

sql/opt_histogram_json.cc:696–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694*/
695
696bool Histogram_json_hb::parse(MEM_ROOT *mem_root, const char *db_name,
697 const char *table_name, Field *field,
698 const char *hist_data, size_t hist_data_len)
699{
700 json_engine_t je;
701 int rc;
702 const char *err= "JSON parse error";
703 double total_size;
704 int end_element;
705 bool end_assigned;
706
707 DBUG_ENTER("Histogram_json_hb::parse");
708
709 mem_root_dynamic_array_init(mem_root, PSI_INSTRUMENT_MEM,
710 &je.stack, sizeof(int), NULL,
711 JSON_DEPTH_DEFAULT, JSON_DEPTH_INC, MYF(0));
712
713 json_scan_start(&je, &my_charset_utf8mb4_bin,
714 (const uchar*)hist_data,
715 (const uchar*)hist_data+hist_data_len);
716
717 if (json_scan_next(&je))
718 goto err;
719
720 if (je.state != JST_OBJ_START)
721 {
722 err= "Root JSON element must be a JSON object";
723 goto err;
724 }
725
726 while (1)
727 {
728 if (json_scan_next(&je))
729 goto err;
730 if (je.state == JST_OBJ_END)
731 break; // End of object
732
733 if (je.state != JST_KEY)
734 goto err; // Can' really have this: JSON object has keys in it
735
736 Json_string hist_key_name(JSON_NAME);
737 if (json_key_matches(&je, hist_key_name.get()))
738 {
739 total_size= 0.0;
740 end_element= -1;
741 if (json_scan_next(&je))
742 goto err;
743
744 if (je.state != JST_ARRAY_START)
745 {
746 err= "histogram_hb must contain an array";
747 goto err;
748 }
749
750 while (!(rc= parse_bucket(&je, field, &total_size, &end_assigned, &err)))
751 {
752 if (end_assigned && end_element != -1)
753 end_element= (int)buckets.size();

Callers

nothing calls this directly

Calls 10

json_scan_startFunction · 0.85
json_scan_nextFunction · 0.85
json_key_matchesFunction · 0.85
json_skip_keyFunction · 0.85
push_warning_printfFunction · 0.85
sql_print_errorFunction · 0.70
getMethod · 0.45
sizeMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected