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

Function create_hash

sql/item_jsonfunc.cc:5707–5759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5705
5706
5707static bool create_hash(json_engine_t *value, HASH *items,
5708 bool &item_hash_inited,
5709 MEM_ROOT *hash_root, MEM_ROOT *current_mem_root,
5710 json_engine_t *temp_je, MEM_ROOT_DYNAMIC_ARRAY *stack)
5711{
5712 int level= value->stack_p;
5713 if (my_hash_init(PSI_INSTRUMENT_ME, items, value->s.cs, 0, 0, 0,
5714 get_key_name, NULL, 0))
5715 return true;
5716 item_hash_inited= true;
5717
5718 while (json_scan_next(value) == 0 && value->stack_p >= level)
5719 {
5720 const uchar *value_start= NULL;
5721 size_t value_len= 0;
5722 DYNAMIC_STRING norm_val;
5723
5724 if (json_read_value(value) ||
5725 get_current_value(value, value_start, value_len) ||
5726 init_dynamic_string(&norm_val, NULL, 0, 0))
5727 return true;
5728
5729 if (json_normalize(&norm_val, (const char*) value_start,
5730 value_len, value->s.cs, current_mem_root,
5731 temp_je, stack))
5732 {
5733 dynstr_free(&norm_val);
5734 return true;
5735 }
5736
5737 char *new_entry= (char*)alloc_root(hash_root,
5738 norm_val.length+1);
5739 if (!new_entry)
5740 {
5741 dynstr_free(&norm_val);
5742 return true;
5743 }
5744 else
5745 {
5746 strncpy(new_entry, norm_val.str, norm_val.length);
5747 new_entry[norm_val.length]='\0';
5748
5749 dynstr_free(&norm_val);
5750
5751 if (my_hash_insert(items, (const uchar *) new_entry))
5752 {
5753 my_free(new_entry);
5754 return true;
5755 }
5756 }
5757 }
5758 return false;
5759}
5760
5761
5762/*

Callers 2

fix_length_and_decMethod · 0.85

Calls 9

json_scan_nextFunction · 0.85
json_read_valueFunction · 0.85
get_current_valueFunction · 0.85
init_dynamic_stringFunction · 0.85
json_normalizeFunction · 0.85
dynstr_freeFunction · 0.85
alloc_rootFunction · 0.85
my_hash_insertFunction · 0.85
my_freeFunction · 0.85

Tested by

no test coverage detected