refactor: rename DTree to DValue
This commit is contained in:
+11
-11
@@ -96,9 +96,9 @@ String mysql_escape(String raw, char quote_char)
|
||||
return(result);
|
||||
}
|
||||
|
||||
DTree field_to_dtree_node(char* data_ptr, MySQLFieldInfo field_info, u32 len)
|
||||
DValue field_to_dv_node(char* data_ptr, MySQLFieldInfo field_info, u32 len)
|
||||
{
|
||||
DTree result;
|
||||
DValue result;
|
||||
switch(field_info.type)
|
||||
{
|
||||
case(MYSQL_TYPE_TINY):
|
||||
@@ -133,9 +133,9 @@ DTree field_to_dtree_node(char* data_ptr, MySQLFieldInfo field_info, u32 len)
|
||||
return(result);
|
||||
}
|
||||
|
||||
DTree MySQL::get_pending_result()
|
||||
DValue MySQL::get_pending_result()
|
||||
{
|
||||
DTree result_data;
|
||||
DValue result_data;
|
||||
// based on: https://dev.mysql.com/doc/c-api/5.7/en/mysql-field-count.html
|
||||
MYSQL_RES *result;
|
||||
result = mysql_store_result((MYSQL*)connection);
|
||||
@@ -167,11 +167,11 @@ DTree MySQL::get_pending_result()
|
||||
MYSQL_ROW row;
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
DTree row_data;
|
||||
DValue row_data;
|
||||
auto lengths = mysql_fetch_lengths(result);
|
||||
for(i = 0; i < field_count; i++)
|
||||
{
|
||||
row_data[field_info[i].name] = field_to_dtree_node(row[i], field_info[i], lengths[i]);
|
||||
row_data[field_info[i].name] = field_to_dv_node(row[i], field_info[i], lengths[i]);
|
||||
}
|
||||
result_data.push(row_data);
|
||||
}
|
||||
@@ -196,22 +196,22 @@ DTree MySQL::get_pending_result()
|
||||
|
||||
static bool mysql_has_unquoted_positional_placeholder(String query);
|
||||
|
||||
DTree MySQL::query(String q)
|
||||
DValue MySQL::query(String q)
|
||||
{
|
||||
if(mysql_has_unquoted_positional_placeholder(q))
|
||||
{
|
||||
_preload_next_error_code = CR_UNKNOWN_ERROR;
|
||||
statement_info = "mysql positional ? placeholders are not supported; use named :name placeholders";
|
||||
return(DTree());
|
||||
return(DValue());
|
||||
}
|
||||
if(!connection)
|
||||
{
|
||||
_preload_next_error_code = CR_UNKNOWN_ERROR;
|
||||
statement_info = "mysql connection is not open";
|
||||
return(DTree());
|
||||
return(DValue());
|
||||
}
|
||||
_preload_next_error_code = mysql_query((MYSQL*)connection, q.c_str());
|
||||
DTree result;
|
||||
DValue result;
|
||||
if(_preload_next_error_code == 0)
|
||||
result = get_pending_result();
|
||||
return(result);
|
||||
@@ -253,7 +253,7 @@ static bool mysql_has_unquoted_positional_placeholder(String query)
|
||||
return(false);
|
||||
}
|
||||
|
||||
DTree MySQL::query(String q, StringMap params)
|
||||
DValue MySQL::query(String q, StringMap params)
|
||||
{
|
||||
// Positional ? placeholders survive named substitution (values are always
|
||||
// quoted by escape()), so the check in query(String) covers this path too.
|
||||
|
||||
Reference in New Issue
Block a user