1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00
two TABLE_LIST copy eliminated


include/mysqld_error.h:
  errors of view
libmysqld/Makefile.am:
  new view file
mysql-test/r/connect.result:
  SHOW TABLE show type of table
mysql-test/r/ctype_recoding.result:
  SHOW TABLE show type of table
mysql-test/r/drop.result:
  SHOW TABLE show type of table
mysql-test/r/grant.result:
  new two privileges (CRETEA|SHOW VIEW)
mysql-test/r/lowercase_table.result:
  SHOW TABLE show type of table
mysql-test/r/ps_1general.result:
  SHOW TABLE show type of table
mysql-test/r/rename.result:
  SHOW TABLE show type of table
mysql-test/r/rpl000009.result:
  SHOW TABLE show type of table
mysql-test/r/rpl_error_ignored_table.result:
  SHOW TABLE show type of table
mysql-test/r/select.result:
  SHOW TABLE show type of table
mysql-test/r/system_mysql_db.result:
  SHOW TABLE show type of table
  new two privileges (CRETEA|SHOW VIEW)
mysql-test/t/system_mysql_db_fix.test:
  removing all system tables
scripts/mysql_fix_privilege_tables.sql:
  new two privileges (CRETEA|SHOW VIEW)
sql/Makefile.am:
  new VIEW related file
sql/ha_myisammrg.cc:
  two TABLE_LIST copy eliminated
sql/item.cc:
  VIEW
sql/item.h:
  VIEW
sql/item_subselect.cc:
  VIEW
sql/item_subselect.h:
  VIEW
sql/lex.h:
  VIEW
sql/lock.cc:
  VIEW
sql/mysql_priv.h:
  VIEW
sql/mysqld.cc:
  VIEW
  new parameter - sql_updatable_view_key
sql/opt_sum.cc:
  two TABLE_LIST copy eliminated
sql/set_var.cc:
  new parameter - sql_updatable_view_key
sql/share/czech/errmsg.txt:
  errors messages of views
sql/share/danish/errmsg.txt:
  errors messages of views
sql/share/dutch/errmsg.txt:
  errors messages of views
sql/share/english/errmsg.txt:
  errors messages of views
sql/share/estonian/errmsg.txt:
  errors messages of views
sql/share/french/errmsg.txt:
  errors messages of views
sql/share/german/errmsg.txt:
  errors messages of views
sql/share/greek/errmsg.txt:
  errors messages of views
sql/share/hungarian/errmsg.txt:
  errors messages of views
sql/share/italian/errmsg.txt:
  errors messages of views
sql/share/japanese/errmsg.txt:
  errors messages of views
sql/share/korean/errmsg.txt:
  errors messages of views
sql/share/norwegian-ny/errmsg.txt:
  errors messages of views
sql/share/norwegian/errmsg.txt:
  errors messages of views
sql/share/polish/errmsg.txt:
  errors messages of views
sql/share/portuguese/errmsg.txt:
  errors messages of views
sql/share/romanian/errmsg.txt:
  errors messages of views
sql/share/russian/errmsg.txt:
  errors messages of views
sql/share/serbian/errmsg.txt:
  errors messages of views
sql/share/slovak/errmsg.txt:
  errors messages of views
sql/share/spanish/errmsg.txt:
  errors messages of views
sql/share/swedish/errmsg.txt:
  errors messages of views
sql/share/ukrainian/errmsg.txt:
  errors messages of views
sql/slave.cc:
  two TABLE_LIST copy eliminated
sql/sp.cc:
  VIEW
sql/sql_acl.cc:
  VIEW
sql/sql_acl.h:
  VIEW
sql/sql_base.cc:
  VIEW
sql/sql_cache.cc:
  two TABLE_LIST copy eliminated
sql/sql_class.h:
  VIEW
sql/sql_db.cc:
  two TABLE_LIST copy eliminated
sql/sql_delete.cc:
  VIEW
sql/sql_derived.cc:
  VIEW
sql/sql_handler.cc:
  two TABLE_LIST copy eliminated
sql/sql_help.cc:
  two TABLE_LIST copy eliminated
sql/sql_insert.cc:
  VIEW
sql/sql_lex.cc:
  VIEW
sql/sql_lex.h:
  VIEW
sql/sql_load.cc:
  VIEW
sql/sql_olap.cc:
  VIEW
sql/sql_parse.cc:
  two TABLE_LIST copy eliminated
  VIEW
sql/sql_prepare.cc:
  VIEW
sql/sql_rename.cc:
  two TABLE_LIST copy eliminated
sql/sql_select.cc:
  VIEW
sql/sql_show.cc:
  VIEW
sql/sql_table.cc:
  VIEW
sql/sql_union.cc:
  VIEW
sql/sql_update.cc:
  VIEW
sql/sql_yacc.yy:
  VIEW
sql/table.cc:
  VIEW
sql/table.h:
  VIEW
sql/tztime.cc:
  two TABLE_LIST copy eliminated
sql/unireg.h:
  VIEW
tests/client_test.c:
  VIEW
This commit is contained in:
unknown
2004-07-16 01:15:55 +03:00
parent b0df20349d
commit 8790b1e65c
85 changed files with 6126 additions and 1250 deletions

View File

@ -39,6 +39,8 @@ static TYPELIB grant_types = { sizeof(grant_names)/sizeof(char **),
static int
store_create_info(THD *thd, TABLE *table, String *packet);
static int
view_store_create_info(THD *thd, TABLE_LIST *table, String *packet);
/*
@ -141,6 +143,9 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild)
List<char> files;
char *file_name;
Protocol *protocol= thd->protocol;
uint len;
bool show_type = !test(thd->variables.sql_mode &
(MODE_NO_FIELD_OPTIONS | MODE_MYSQL323));
DBUG_ENTER("mysqld_show_tables");
field->name=(char*) thd->alloc(20+(uint) strlen(db)+
@ -149,9 +154,12 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild)
if (wild && wild[0])
strxmov(end," (",wild,")",NullS);
field->max_length=NAME_LEN;
(void) sprintf(path,"%s/%s",mysql_data_home,db);
(void) unpack_dirname(path,path);
(void) my_snprintf(path, FN_LEN, "%s/%s", mysql_data_home, db);
end= path + (len= unpack_dirname(path,path));
len= FN_LEN - len;
field_list.push_back(field);
if (show_type)
field_list.push_back(new Item_empty_string("Type", 5));
if (protocol->send_fields(&field_list,1))
DBUG_RETURN(1);
if (mysql_find_files(thd,&files,db,path,wild,0))
@ -161,6 +169,22 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild)
{
protocol->prepare_for_resend();
protocol->store(file_name, system_charset_info);
if (show_type)
{
my_snprintf(end, len, "/%s%s", file_name, reg_ext);
switch (mysql_frm_type(path))
{
case FRMTYPE_ERROR:
protocol->store("error", system_charset_info);
break;
case FRMTYPE_TABLE:
protocol->store("table", system_charset_info);
break;
case FRMTYPE_VIEW:
protocol->store("view", system_charset_info);
break;
}
}
if (protocol->write())
DBUG_RETURN(-1);
}
@ -516,9 +540,10 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
protocol->store(file_name, system_charset_info);
table_list.db=(char*) db;
table_list.real_name= table_list.alias= file_name;
table_list.select_lex= &thd->lex->select_lex;
if (lower_case_table_names)
my_casedn_str(files_charset_info, file_name);
if (!(table = open_ltable(thd, &table_list, TL_READ)))
if (open_and_lock_tables(thd, &table_list))
{
for (uint i=2 ; i < field_list.elements ; i++)
protocol->store_null();
@ -526,10 +551,16 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
protocol->store(thd->net.last_error, system_charset_info);
thd->clear_error();
}
else if (table_list.view)
{
for (uint i= 2; i < field_list.elements; i++)
protocol->store_null();
protocol->store("view", system_charset_info);
}
else
{
const char *str;
handler *file=table->file;
handler *file= (table= table_list.table)->file;
file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
protocol->store(file->table_type(), system_charset_info);
protocol->store((ulonglong) table->frm_version);
@ -630,8 +661,8 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
if (comment != table->comment)
my_free(comment,MYF(0));
}
close_thread_tables(thd,0);
}
close_thread_tables(thd, 0);
if (protocol->write())
DBUG_RETURN(-1);
}
@ -657,11 +688,13 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->real_name));
if (!(table = open_ltable(thd, table_list, TL_UNLOCK)))
table_list->lock_type= TL_UNLOCK;
if (open_and_lock_tables(thd, table_list))
{
send_error(thd);
DBUG_RETURN(1);
}
table= table_list->table;
file=table->file;
file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@ -755,7 +788,10 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
/* Add grant options & comments */
end=tmp;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
col_access= get_column_grant(thd,table_list,field) & COL_ACLS;
col_access= get_column_grant(thd, &table_list->grant,
table_list->db,
table_list->real_name,
field->field_name) & COL_ACLS;
for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
{
if (col_access & 1)
@ -793,14 +829,24 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->real_name));
/* Only one table for now */
if (!(table = open_ltable(thd, table_list, TL_UNLOCK)))
/* Only one table for now, but VIEW can involve several tables */
if (open_and_lock_tables(thd, table_list))
{
send_error(thd);
DBUG_RETURN(1);
}
/* 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);
}
table= table_list->table;
if (store_create_info(thd, table, &buffer))
if ((table_list->view ?
view_store_create_info(thd, table_list, &buffer) :
store_create_info(thd, table, &buffer)))
DBUG_RETURN(-1);
List<Item> field_list;
@ -812,11 +858,21 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(1);
protocol->prepare_for_resend();
protocol->store(table->table_name, system_charset_info);
buffer.length(0);
if (store_create_info(thd, table, &buffer))
DBUG_RETURN(-1);
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);
}
else
{
protocol->store(table->table_name, system_charset_info);
if (store_create_info(thd, table, &buffer))
DBUG_RETURN(-1);
}
protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
if (protocol->write())
DBUG_RETURN(1);
send_eof(thd);
@ -1483,6 +1539,35 @@ store_create_info(THD *thd, TABLE *table, String *packet)
}
static int
view_store_create_info(THD *thd, TABLE_LIST *table, String *buff)
{
my_bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
MODE_ORACLE |
MODE_MSSQL |
MODE_DB2 |
MODE_MAXDB |
MODE_ANSI)) != 0;
buff->append("CREATE ", 7);
if(!foreign_db_mode && (table->algorithm == VIEW_ALGORITHM_MERGE ||
table->algorithm == VIEW_ALGORITHM_TMEPTABLE))
{
buff->append("ALGORITHM=", 10);
if (table->algorithm == VIEW_ALGORITHM_TMEPTABLE)
buff->append("TMPTABLE ", 9);
else
buff->append("MERGE ", 6);
}
buff->append("VIEW ", 5);
buff->append(table->view_db.str, table->view_db.length);
buff->append('.');
buff->append(table->view_name.str, table->view_name.length);
buff->append(" AS ", 4);
buff->append(table->query.str, table->query.length);
return 0;
}
/****************************************************************************
Return info about all processes
returns for each thread: thread id, user, host, db, command, info