1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

errors without code removed

net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
(WL#2133)
This commit is contained in:
bell@sanja.is.com.ua
2004-10-20 04:04:37 +03:00
parent 09e9651acc
commit 4714a6e744
86 changed files with 1886 additions and 1566 deletions

View File

@ -48,7 +48,7 @@ view_store_create_info(THD *thd, TABLE_LIST *table, String *packet);
A database is a directory in the mysql_data_home directory
*/
int
bool
mysqld_show_dbs(THD *thd,const char *wild)
{
Item_string *field=new Item_string("",0,thd->charset());
@ -68,9 +68,9 @@ mysqld_show_dbs(THD *thd,const char *wild)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
if (mysql_find_files(thd,&files,NullS,mysql_data_home,wild,1))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
List_iterator_fast<char> it(files);
while ((file_name=it++))
@ -84,11 +84,11 @@ mysqld_show_dbs(THD *thd,const char *wild)
protocol->prepare_for_resend();
protocol->store(file_name, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
@ -96,7 +96,7 @@ mysqld_show_dbs(THD *thd,const char *wild)
List all open tables in a database
***************************************************************************/
int mysqld_show_open_tables(THD *thd,const char *wild)
bool mysqld_show_open_tables(THD *thd,const char *wild)
{
List<Item> field_list;
OPEN_TABLE_LIST *open_list;
@ -110,10 +110,10 @@ int mysqld_show_open_tables(THD *thd,const char *wild)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
if (!(open_list=list_open_tables(thd,wild)) && thd->is_fatal_error)
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
for (; open_list ; open_list=open_list->next)
{
@ -124,11 +124,11 @@ int mysqld_show_open_tables(THD *thd,const char *wild)
protocol->store_tiny((longlong) open_list->locked);
if (protocol->write())
{
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
@ -137,7 +137,7 @@ int mysqld_show_open_tables(THD *thd,const char *wild)
** A table is a .frm file in the current databasedir
***************************************************************************/
int mysqld_show_tables(THD *thd, const char *db, const char *wild,
bool mysqld_show_tables(THD *thd, const char *db, const char *wild,
bool show_type)
{
Item_string *field=new Item_string("",0,thd->charset());
@ -162,10 +162,9 @@ int mysqld_show_tables(THD *thd, const char *db, const char *wild,
if (show_type)
field_list.push_back(new Item_empty_string("table_type", 10));
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
if (mysql_find_files(thd,&files,db,path,wild,0))
DBUG_RETURN(-1);
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF) ||
mysql_find_files(thd,&files,db,path,wild,0))
DBUG_RETURN(TRUE);
List_iterator_fast<char> it(files);
while ((file_name=it++))
{
@ -190,17 +189,17 @@ int mysqld_show_tables(THD *thd, const char *db, const char *wild,
}
}
if (protocol->write())
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
/***************************************************************************
** List all table types supported
***************************************************************************/
int mysqld_show_storage_engines(THD *thd)
bool mysqld_show_storage_engines(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
@ -212,7 +211,7 @@ int mysqld_show_storage_engines(THD *thd)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
const char *default_type_name=
ha_get_storage_engine((enum db_type)thd->variables.table_type);
@ -230,10 +229,10 @@ int mysqld_show_storage_engines(THD *thd)
protocol->store(option_name, system_charset_info);
protocol->store(types->comment, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
@ -275,7 +274,7 @@ static struct show_privileges_st sys_privileges[]=
{NullS, NullS, NullS}
};
int mysqld_show_privileges(THD *thd)
bool mysqld_show_privileges(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
@ -287,7 +286,7 @@ int mysqld_show_privileges(THD *thd)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
show_privileges_st *privilege= sys_privileges;
for (privilege= sys_privileges; privilege->privilege ; privilege++)
@ -297,10 +296,10 @@ int mysqld_show_privileges(THD *thd)
protocol->store(privilege->context, system_charset_info);
protocol->store(privilege->comment, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
@ -340,7 +339,7 @@ static struct show_column_type_st sys_column_types[]=
"A very small integer"},
};
int mysqld_show_column_types(THD *thd)
bool mysqld_show_column_types(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
@ -363,7 +362,7 @@ int mysqld_show_column_types(THD *thd)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
/* TODO: Change the loop to not use 'i' */
for (uint i=0; i < sizeof(sys_column_types)/sizeof(sys_column_types[0]); i++)
@ -384,10 +383,10 @@ int mysqld_show_column_types(THD *thd)
protocol->store(sys_column_types[i].default_value, system_charset_info);
protocol->store(sys_column_types[i].comment, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
@ -486,7 +485,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
Extended version of mysqld_show_tables
***************************************************************************/
int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
bool mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
{
Item *item;
List<char> files;
@ -496,7 +495,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
TABLE *table;
Protocol *protocol= thd->protocol;
TIME time;
int res;
bool res;
DBUG_ENTER("mysqld_extend_show_tables");
(void) sprintf(path,"%s/%s",mysql_data_home,db);
@ -537,11 +536,9 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
field_list.push_back(item=new Item_empty_string("Comment",80));
item->maybe_null=1;
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
if (mysql_find_files(thd,&files,db,path,wild,0))
DBUG_RETURN(-1);
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF) ||
mysql_find_files(thd,&files,db,path,wild,0))
DBUG_RETURN(TRUE);
List_iterator_fast<char> it(files);
while ((file_name=it++))
{
@ -558,14 +555,12 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
{
for (uint i=2 ; i < field_list.elements ; i++)
protocol->store_null();
// Send error to Comment field if possible
if (res < 0)
// Send error to Comment field
if (res)
{
protocol->store(thd->net.last_error, system_charset_info);
thd->clear_error();
}
else
DBUG_RETURN(1);
}
else if (table_list.view)
{
@ -680,10 +675,10 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
}
close_thread_tables(thd, 0);
if (protocol->write())
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
@ -691,7 +686,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
** List all columns in a table_list->real_name
***************************************************************************/
int
bool
mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
bool verbose)
{
@ -707,11 +702,9 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
table_list->real_name));
table_list->lock_type= TL_UNLOCK;
if ((res= open_and_lock_tables(thd, table_list)))
if (open_and_lock_tables(thd, table_list))
{
if (res < 0)
send_error(thd);
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
}
table= table_list->table;
file=table->file;
@ -737,7 +730,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
// Send first number of fields and records
if (protocol->send_records_num(&field_list, (ulonglong)file->records) ||
protocol->send_fields(&field_list, Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
restore_record(table,default_values); // Get empty record
Field **ptr,*field;
@ -844,16 +837,16 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
system_charset_info);
}
if (protocol->write())
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
}
}
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
int
bool
mysqld_show_create(THD *thd, TABLE_LIST *table_list)
{
TABLE *table;
@ -866,18 +859,16 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
table_list->real_name));
/* Only one table for now, but VIEW can involve several tables */
if ((res= open_and_lock_tables(thd, table_list)))
if (open_and_lock_tables(thd, table_list))
{
if (res < 0)
send_error(thd);
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
}
/* TODO: add environment variables show when it become possible */
if (thd->lex->only_view && !table_list->view)
{
my_error(ER_WRONG_OBJECT, MYF(0), table_list->db,
table_list->real_name, "VIEW");
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
table= table_list->table;
@ -885,7 +876,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
if ((table_list->view ?
view_store_create_info(thd, table_list, &buffer) :
store_create_info(thd, table, &buffer)))
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
List<Item> field_list;
if (table_list->view)
@ -904,31 +895,31 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
protocol->prepare_for_resend();
buffer.length(0);
if (table_list->view)
{
protocol->store(table_list->view_name.str, system_charset_info);
if (view_store_create_info(thd, table_list, &buffer))
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
else
{
protocol->store(table->table_name, system_charset_info);
if (store_create_info(thd, table, &buffer))
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
}
protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
if (protocol->write())
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
int mysqld_show_create_db(THD *thd, char *dbname,
HA_CREATE_INFO *create_info)
bool mysqld_show_create_db(THD *thd, char *dbname,
HA_CREATE_INFO *create_info)
{
int length;
char path[FN_REFLEN];
@ -945,8 +936,8 @@ int mysqld_show_create_db(THD *thd, char *dbname,
if (check_db_name(dbname))
{
net_printf(thd,ER_WRONG_DB_NAME, dbname);
DBUG_RETURN(1);
my_error(ER_WRONG_DB_NAME, MYF(0), dbname);
DBUG_RETURN(TRUE);
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@ -957,11 +948,11 @@ int mysqld_show_create_db(THD *thd, char *dbname,
thd->master_access);
if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
{
net_printf(thd,ER_DBACCESS_DENIED_ERROR,
thd->priv_user, thd->host_or_ip, dbname);
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
thd->priv_user, thd->host_or_ip, dbname);
mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
thd->priv_user, thd->host_or_ip, dbname);
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
}
#endif
@ -975,8 +966,8 @@ int mysqld_show_create_db(THD *thd, char *dbname,
}
if (access(path,F_OK))
{
net_printf(thd,ER_BAD_DB_ERROR,dbname);
DBUG_RETURN(1);
my_error(ER_BAD_DB_ERROR, MYF(0), dbname);
DBUG_RETURN(TRUE);
}
if (found_libchar)
path[length-1]= FN_LIBCHAR;
@ -989,7 +980,7 @@ int mysqld_show_create_db(THD *thd, char *dbname,
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
protocol->prepare_for_resend();
protocol->store(dbname, strlen(dbname), system_charset_info);
@ -1014,12 +1005,12 @@ int mysqld_show_create_db(THD *thd, char *dbname,
protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
if (protocol->write())
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
int
bool
mysqld_show_logs(THD *thd)
{
List<Item> field_list;
@ -1032,19 +1023,19 @@ mysqld_show_logs(THD *thd)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
#ifdef HAVE_BERKELEY_DB
if ((have_berkeley_db == SHOW_OPTION_YES) && berkeley_show_logs(protocol))
DBUG_RETURN(-1);
DBUG_RETURN(TRUE);
#endif
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
int
bool
mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
{
TABLE *table;
@ -1055,8 +1046,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
if (!(table = open_ltable(thd, table_list, TL_UNLOCK)))
{
send_error(thd);
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
}
List<Item> field_list;
@ -1082,7 +1072,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
KEY *key_info=table->key_info;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME);
@ -1133,11 +1123,11 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
else
protocol->store("", 0, system_charset_info);
if (protocol->write())
DBUG_RETURN(1); /* purecov: inspected */
DBUG_RETURN(TRUE); /* purecov: inspected */
}
}
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
}
@ -1155,12 +1145,8 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
DBUG_PRINT("enter",("table: %s",table_list->real_name));
table_list->lock_type= TL_UNLOCK;
if ((res= open_and_lock_tables(thd, table_list)))
{
if (res < 0)
send_error(thd);
if (open_and_lock_tables(thd, table_list))
DBUG_VOID_RETURN;
}
table= table_list->table;
List<Item> field_list;
@ -1805,7 +1791,7 @@ static bool write_collation(Protocol *protocol, CHARSET_INFO *cs)
return protocol->write();
}
int mysqld_show_collations(THD *thd, const char *wild)
bool mysqld_show_collations(THD *thd, const char *wild)
{
char buff[8192];
String packet2(buff,sizeof(buff),thd->charset());
@ -1813,7 +1799,7 @@ int mysqld_show_collations(THD *thd, const char *wild)
CHARSET_INFO **cs;
Protocol *protocol= thd->protocol;
DBUG_ENTER("mysqld_show_charsets");
DBUG_ENTER(" mysqld_show_collations");
field_list.push_back(new Item_empty_string("Collation",30));
field_list.push_back(new Item_empty_string("Charset",30));
@ -1824,7 +1810,7 @@ int mysqld_show_collations(THD *thd, const char *wild)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ )
{
@ -1845,10 +1831,10 @@ int mysqld_show_collations(THD *thd, const char *wild)
}
}
}
send_eof(thd);
DBUG_RETURN(0);
send_eof(thd);
DBUG_RETURN(FALSE);
err:
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
}
static bool write_charset(Protocol *protocol, CHARSET_INFO *cs)
@ -1861,7 +1847,7 @@ static bool write_charset(Protocol *protocol, CHARSET_INFO *cs)
return protocol->write();
}
int mysqld_show_charsets(THD *thd, const char *wild)
bool mysqld_show_charsets(THD *thd, const char *wild)
{
char buff[8192];
String packet2(buff,sizeof(buff),thd->charset());
@ -1878,7 +1864,7 @@ int mysqld_show_charsets(THD *thd, const char *wild)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ )
{
@ -1891,18 +1877,18 @@ int mysqld_show_charsets(THD *thd, const char *wild)
goto err;
}
}
send_eof(thd);
DBUG_RETURN(0);
send_eof(thd);
DBUG_RETURN(FALSE);
err:
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
}
int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
enum enum_var_type value_type,
pthread_mutex_t *mutex,
struct system_status_var *status_var)
bool mysqld_show(THD *thd, const char *wild, show_var_st *variables,
enum enum_var_type value_type,
pthread_mutex_t *mutex,
struct system_status_var *status_var)
{
char buff[1024];
List<Item> field_list;
@ -1914,7 +1900,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
field_list.push_back(new Item_empty_string("Value",256));
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1); /* purecov: inspected */
DBUG_RETURN(TRUE); /* purecov: inspected */
null_lex_str.str= 0; // For sys_var->value_ptr()
null_lex_str.length= 0;
@ -2206,11 +2192,11 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
}
pthread_mutex_unlock(mutex);
send_eof(thd);
DBUG_RETURN(0);
DBUG_RETURN(FALSE);
err:
pthread_mutex_unlock(mutex);
DBUG_RETURN(1);
DBUG_RETURN(TRUE);
}