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

Function append_json_value

sql/item_jsonfunc.cc:2094–2136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2092
2093
2094static int append_json_value(String *str, Item *item, String *tmp_val)
2095{
2096 if (item->type_handler()->is_bool_type())
2097 {
2098 longlong v_int= item->val_int();
2099 const char *t_f;
2100 int t_f_len;
2101
2102 if (item->null_value)
2103 goto append_null;
2104
2105 if (v_int)
2106 {
2107 t_f= "true";
2108 t_f_len= 4;
2109 }
2110 else
2111 {
2112 t_f= "false";
2113 t_f_len= 5;
2114 }
2115
2116 return str->append(t_f, t_f_len);
2117 }
2118 {
2119 String *sv= item->val_json(tmp_val);
2120 if (item->null_value)
2121 goto append_null;
2122 if (is_json_type(item))
2123 return str->append(sv->ptr(), sv->length());
2124
2125 if (item->result_type() == STRING_RESULT)
2126 {
2127 return str->append('"') ||
2128 st_append_escaped(str, sv) ||
2129 str->append('"');
2130 }
2131 return st_append_escaped(str, sv);
2132 }
2133
2134append_null:
2135 return str->append(STRING_WITH_LEN("null"));
2136}
2137
2138
2139static int append_json_value_from_field(String *str,

Callers 3

val_strMethod · 0.85
get_str_from_itemMethod · 0.85
addMethod · 0.85

Calls 10

is_json_typeFunction · 0.85
st_append_escapedFunction · 0.85
is_bool_typeMethod · 0.45
type_handlerMethod · 0.45
val_intMethod · 0.45
appendMethod · 0.45
val_jsonMethod · 0.45
ptrMethod · 0.45
lengthMethod · 0.45
result_typeMethod · 0.45

Tested by

no test coverage detected