1462
1463
char temp_file_path[FN_REFLEN];
1464
if ((fd= internal::create_temp_file(temp_file_path, TMPDIR,
1465
if ((fd= internal::create_temp_file(temp_file_path, NULL,
1465
1466
"tmp", MYF(MY_WME))) < 0)
1466
1467
die("Failed to create temporary file for ds");
3386
3387
abort_not_supported_test("Test requires charset '%s'", charset_name);
3389
static void fill_global_error_names()
3391
drizzle_result_st res;
3392
drizzle_return_t ret;
3394
drizzle_con_st *con= &cur_con->con;
3396
global_error_names.clear();
3398
const std::string ds_query("select error_name, error_code "
3399
"from data_dictionary.errors");
3400
if (drizzle_query_str(con, &res, ds_query.c_str(), &ret) == NULL ||
3401
ret != DRIZZLE_RETURN_OK)
3403
if (ret == DRIZZLE_RETURN_ERROR_CODE)
3405
die("Error running query '%s': %d %s", ds_query.c_str(),
3406
drizzle_result_error_code(&res), drizzle_result_error(&res));
3407
drizzle_result_free(&res);
3411
die("Error running query '%s': %d %s", ds_query.c_str(), ret,
3412
drizzle_con_error(con));
3415
if (drizzle_result_column_count(&res) == 0 ||
3416
drizzle_result_buffer(&res) != DRIZZLE_RETURN_OK)
3418
drizzle_result_free(&res);
3419
die("Query '%s' didn't return a result set", ds_query.c_str());
3422
while ((row= drizzle_row_next(&res)) && row[0])
3425
Concatenate all fields in the first row with tab in between
3426
and assign that string to the $variable
3428
size_t *lengths= drizzle_row_field_sizes(&res);
3429
const std::string error_name(row[0], lengths[0]);
3430
const std::string error_code(row[1], lengths[1]);
3434
global_error_names.insert(ErrorCodes::value_type(error_name,
3435
boost::lexical_cast<uint32_t>(error_code)));
3437
catch (boost::bad_lexical_cast &ex)
3439
drizzle_result_free(&res);
3440
die("Invalid error_code from Drizzle: %s", ex.what());
3445
drizzle_result_free(&res);
3448
3390
static uint32_t get_errcode_from_name(char *error_name, char *error_end)
3450
3392
size_t err_name_len= error_end - error_name;
3451
3393
string error_name_s(error_name, err_name_len);
3453
ErrorCodes::iterator it= global_error_names.find(error_name_s);
3454
if (it != global_error_names.end())
3456
return (*it).second;
3459
die("Unknown SQL error name '%s'", error_name_s.c_str());
3395
uint32_t code= global_error_names.getErrorCode(error_name_s);
3398
die("Unknown SQL error name '%s'", error_name_s.c_str());
3463
3403
static void do_get_errcodes(struct st_command *command)
5754
5694
safe_connect(&cur_con->con, cur_con->name, opt_host, opt_user, opt_pass,
5755
5695
opt_db, opt_port);
5757
fill_global_error_names();
5759
5697
/* Use all time until exit if no explicit 'start_timer' */
5760
5698
timer_start= timer_now();