mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Added SQLSTATE to client/server protocol
bmove_allign -> bmove_align Added OLAP function ROLLUP Split mysql_fix_privilege_tables to a script and a .sql data file Added new (MEMROOT*) functions to avoid calling current_thd() when creating some common objects. Added table_alias_charset, for easier --lower-case-table-name handling Better SQL_MODE handling (Setting complex options also sets sub options) New (faster) assembler string functions for x86
This commit is contained in:
@@ -200,7 +200,9 @@ static int com_nopager(String *str, char*), com_pager(String *str, char*),
|
||||
static int read_lines(bool execute_commands);
|
||||
static int sql_connect(char *host,char *database,char *user,char *password,
|
||||
uint silent);
|
||||
static int put_info(const char *str,INFO_TYPE info,uint error=0);
|
||||
static int put_info(const char *str,INFO_TYPE info,uint error=0,
|
||||
const char *sql_state=0);
|
||||
static int put_error(MYSQL *mysql);
|
||||
static void safe_put_field(const char *pos,ulong length);
|
||||
static void xmlencode_print(const char *src, uint length);
|
||||
static void init_pager();
|
||||
@@ -1437,7 +1439,7 @@ int mysql_real_query_for_lazy(const char *buf, int length)
|
||||
{
|
||||
if (!mysql_real_query(&mysql,buf,length))
|
||||
return 0;
|
||||
uint error=put_info(mysql_error(&mysql),INFO_ERROR, mysql_errno(&mysql));
|
||||
int error= put_error(&mysql);
|
||||
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR || retry > 1 ||
|
||||
!opt_reconnect)
|
||||
return error;
|
||||
@@ -1452,8 +1454,7 @@ int mysql_store_result_for_lazy(MYSQL_RES **result)
|
||||
return 0;
|
||||
|
||||
if (mysql_error(&mysql)[0])
|
||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
|
||||
return put_error(&mysql);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1653,9 +1654,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
|
||||
if (quick)
|
||||
{
|
||||
if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql))
|
||||
{
|
||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
}
|
||||
return put_error(&mysql);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1717,7 +1716,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
|
||||
put_info("",INFO_RESULT); // Empty row
|
||||
|
||||
if (result && !mysql_eof(result)) /* Something wrong when using quick */
|
||||
error=put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
error= put_error(&mysql);
|
||||
else if (unbuffered)
|
||||
fflush(stdout);
|
||||
mysql_free_result(result);
|
||||
@@ -2431,12 +2430,12 @@ com_use(String *buffer __attribute__((unused)), char *line)
|
||||
if (mysql_select_db(&mysql,tmp))
|
||||
{
|
||||
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR)
|
||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
return put_error(&mysql);
|
||||
|
||||
if (reconnect())
|
||||
return opt_reconnect ? -1 : 1; // Fatal error
|
||||
if (mysql_select_db(&mysql,tmp))
|
||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
return put_error(&mysql);
|
||||
}
|
||||
my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
current_db=my_strdup(tmp,MYF(MY_WME));
|
||||
@@ -2557,7 +2556,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
|
||||
(mysql_errno(&mysql) != CR_CONN_HOST_ERROR &&
|
||||
mysql_errno(&mysql) != CR_CONNECTION_ERROR))
|
||||
{
|
||||
put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||
(void) put_error(&mysql);
|
||||
(void) fflush(stdout);
|
||||
return ignore_errors ? -1 : 1; // Abort
|
||||
}
|
||||
@@ -2707,7 +2706,7 @@ select_limit, max_join_size);
|
||||
|
||||
|
||||
static int
|
||||
put_info(const char *str,INFO_TYPE info_type,uint error)
|
||||
put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
|
||||
{
|
||||
FILE *file= (info_type == INFO_ERROR ? stderr : stdout);
|
||||
static int inited=0;
|
||||
@@ -2752,7 +2751,12 @@ put_info(const char *str,INFO_TYPE info_type,uint error)
|
||||
putchar('\007'); /* This should make a bell */
|
||||
vidattr(A_STANDOUT);
|
||||
if (error)
|
||||
(void) tee_fprintf(file, "ERROR %d: ", error);
|
||||
{
|
||||
if (sqlstate)
|
||||
(void) tee_fprintf(file, "ERROR %d (%s): ", error, sqlstate);
|
||||
else
|
||||
(void) tee_fprintf(file, "ERROR %d: ", error);
|
||||
}
|
||||
else
|
||||
tee_puts("ERROR: ", file);
|
||||
}
|
||||
@@ -2767,6 +2771,14 @@ put_info(const char *str,INFO_TYPE info_type,uint error)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
put_error(MYSQL *mysql)
|
||||
{
|
||||
return put_info(mysql_error(mysql), INFO_ERROR, mysql_errno(mysql),
|
||||
mysql_sqlstate(mysql));
|
||||
}
|
||||
|
||||
|
||||
static void remove_cntrl(String &buffer)
|
||||
{
|
||||
char *start,*end;
|
||||
@@ -3085,4 +3097,3 @@ void sql_element_free(void *ptr)
|
||||
my_free((gptr) ptr,MYF(0));
|
||||
}
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
Reference in New Issue
Block a user