66
77namespace sql_engine {
88
9- MySQLRemoteExecutor::MySQLRemoteExecutor (sql_parser::Arena& arena)
10- : arena_(arena) {}
9+ MySQLRemoteExecutor::MySQLRemoteExecutor () {}
1110
1211MySQLRemoteExecutor::~MySQLRemoteExecutor () {
1312 disconnect_all ();
@@ -131,21 +130,20 @@ ResultSet MySQLRemoteExecutor::mysql_result_to_resultset(MYSQL_RES* res) {
131130 MYSQL_ROW mysql_row;
132131 while ((mysql_row = mysql_fetch_row (res)) != nullptr ) {
133132 unsigned long * lengths = mysql_fetch_lengths (res);
134- Row row = make_row (arena_, rs.column_count );
133+ Row& row = rs. add_heap_row ( rs.column_count );
135134 for (unsigned int i = 0 ; i < num_fields; ++i) {
136135 bool is_null = (mysql_row[i] == nullptr );
137136 Value v = mysql_field_to_value (
138- mysql_row[i], is_null ? 0 : lengths[i],
137+ rs, mysql_row[i], is_null ? 0 : lengths[i],
139138 fields[i].type , is_null);
140139 row.set (static_cast <uint16_t >(i), v);
141140 }
142- rs.rows .push_back (row);
143141 }
144142 return rs;
145143}
146144
147145Value MySQLRemoteExecutor::mysql_field_to_value (
148- const char * data, unsigned long length,
146+ ResultSet& rs, const char * data, unsigned long length,
149147 enum_field_types type, bool is_null) {
150148
151149 if (is_null) return value_null ();
@@ -165,8 +163,7 @@ Value MySQLRemoteExecutor::mysql_field_to_value(
165163
166164 case MYSQL_TYPE_DECIMAL:
167165 case MYSQL_TYPE_NEWDECIMAL: {
168- // Store as decimal (numeric string) in arena
169- sql_parser::StringRef s = arena_.allocate_string (data, static_cast <uint32_t >(length));
166+ sql_parser::StringRef s = rs.own_string (data, static_cast <uint32_t >(length));
170167 return value_decimal (s);
171168 }
172169
@@ -197,18 +194,18 @@ Value MySQLRemoteExecutor::mysql_field_to_value(
197194 case MYSQL_TYPE_TINY_BLOB:
198195 case MYSQL_TYPE_MEDIUM_BLOB:
199196 case MYSQL_TYPE_LONG_BLOB: {
200- sql_parser::StringRef s = arena_. allocate_string (data, static_cast <uint32_t >(length));
197+ sql_parser::StringRef s = rs. own_string (data, static_cast <uint32_t >(length));
201198 return value_bytes (s);
202199 }
203200
204201 case MYSQL_TYPE_JSON: {
205- sql_parser::StringRef s = arena_. allocate_string (data, static_cast <uint32_t >(length));
202+ sql_parser::StringRef s = rs. own_string (data, static_cast <uint32_t >(length));
206203 return value_json (s);
207204 }
208205
209206 default : {
210207 // STRING, VAR_STRING, ENUM, SET, etc. — treat as string
211- sql_parser::StringRef s = arena_. allocate_string (data, static_cast <uint32_t >(length));
208+ sql_parser::StringRef s = rs. own_string (data, static_cast <uint32_t >(length));
212209 return value_string (s);
213210 }
214211 }
0 commit comments