| 2092 | |
| 2093 | |
| 2094 | static 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 | |
| 2134 | append_null: |
| 2135 | return str->append(STRING_WITH_LEN("null")); |
| 2136 | } |
| 2137 | |
| 2138 | |
| 2139 | static int append_json_value_from_field(String *str, |
no test coverage detected