mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Merge mysql.com:/home/my/mysql-5.0
into mysql.com:/home/my/mysql-5.1 BUILD/FINISH.sh: Auto merged BitKeeper/deleted/.del-makefilewin.i~5c8479dcb8a455b2: Auto merged BitKeeper/deleted/.del-makefilewin~13888739357b3025: Auto merged BitKeeper/deleted/.del-makefilewin~14f24a4a173e2fcd: Auto merged BitKeeper/deleted/.del-makefilewin~15e9e5c9e8fa870b: Auto merged BitKeeper/deleted/.del-makefilewin~1c53f31b88dd36e: Auto merged BitKeeper/deleted/.del-makefilewin~1dbc058d76ebf1db: Auto merged BitKeeper/deleted/.del-makefilewin~2e0407fe123f8365: Auto merged BitKeeper/deleted/.del-makefilewin~2fc379bd4065c995: Auto merged BitKeeper/deleted/.del-makefilewin~389ee2dcf79afb79: Auto merged BitKeeper/deleted/.del-makefilewin~4d139e182457e553: Auto merged BitKeeper/deleted/.del-makefilewin~5104767c73775697: Auto merged BitKeeper/deleted/.del-makefilewin~608ed49dcd88e0f7: Auto merged BitKeeper/deleted/.del-makefilewin~63acd666293282a: Auto merged BitKeeper/deleted/.del-makefilewin~6ba64863bce3d0b8: Auto merged BitKeeper/deleted/.del-makefilewin~72a64128bacce71b: Auto merged BitKeeper/deleted/.del-makefilewin~78000390c783b1c5: Auto merged BitKeeper/deleted/.del-makefilewin~7a9d7d5a42bbfaf5: Auto merged Makefile.am: Auto merged BitKeeper/deleted/.del-makefilewin~a40ea12eebdd6ef0: Auto merged BitKeeper/deleted/.del-makefilewin~aeea7c82f21f7cf5: Auto merged BitKeeper/deleted/.del-makefilewin~b643e38d8da389ac: Auto merged BitKeeper/deleted/.del-makefilewin~c7b621c745e5de95: Auto merged BitKeeper/deleted/.del-makefilewin~c8273a47b90f52bb: Auto merged BitKeeper/deleted/.del-makefilewin~d1a9d1f7d33fcb73: Auto merged BitKeeper/deleted/.del-makefilewin~d37b6b303348c871: Auto merged BitKeeper/deleted/.del-makefilewin~d90f35fdc3f2ee5f: Auto merged BitKeeper/deleted/.del-makefilewin~dc4b8ad5ea53bd: Auto merged BitKeeper/deleted/.del-makefilewin~dea10ec1c94f7be: Auto merged BitKeeper/deleted/.del-makefilewin~ef3a208fa0e9b0db: Auto merged BitKeeper/deleted/.del-makefilewin~f1e3b890aa1c9ea3: Auto merged BitKeeper/deleted/.del-makefilewin~f4b7b99a887b7de: Auto merged BitKeeper/deleted/.del-makefilewin~fdda94ad32fa9e34: Auto merged BitKeeper/deleted/.del-my_cnf~977f69858affc57b: Auto merged BitKeeper/etc/config: Auto merged VC++Files/libmysqld/libmysqld.dsp: Auto merged VC++Files/sql/mysqld.dsp: Auto merged client/mysqltest.c: Auto merged include/Makefile.am: Auto merged include/base64.h: Auto merged include/my_base.h: Auto merged include/mysql_com.h: Auto merged libmysqld/Makefile.am: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/ndb_basic.result: Auto merged mysql-test/r/ndb_condition_pushdown.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/query_cache.test: Auto merged mysys/Makefile.am: Auto merged mysys/base64.c: Auto merged scripts/make_win_src_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged sql/Makefile.am: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_berkeley.h: Auto merged sql/ha_federated.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item_subselect.cc: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sp.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_help.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged storage/heap/_check.c: Auto merged storage/heap/hp_create.c: Auto merged storage/innobase/include/Makefile.am: Auto merged storage/innobase/include/rem0rec.h: Auto merged storage/innobase/include/rem0rec.ic: Auto merged storage/innobase/row/row0ins.c: Auto merged storage/innobase/row/row0upd.c: Auto merged storage/myisam/mi_check.c: Auto merged storage/myisam/mi_delete.c: Auto merged storage/myisam/mi_rkey.c: Auto merged storage/myisam/mi_rnext_same.c: Auto merged storage/myisam/mi_search.c: Auto merged storage/myisam/mi_write.c: Auto merged storage/myisam/myisamchk.c: Auto merged storage/myisam/myisamdef.h: Auto merged storage/myisam/sort.c: Auto merged storage/myisammrg/myrg_queue.c: Auto merged storage/ndb/config/type_util.mk.am: Auto merged storage/ndb/include/kernel/signaldata/DumpStateOrd.hpp: Auto merged storage/ndb/include/mgmapi/mgmapi_config_parameters.h: Auto merged storage/ndb/include/mgmapi/ndbd_exit_codes.h: Auto merged storage/ndb/include/transporter/TransporterCallback.hpp: Auto merged storage/ndb/src/common/mgmcommon/IPCConfig.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.hpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.unix.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.win32.cpp: Auto merged storage/ndb/src/common/transporter/Transporter.hpp: Auto merged storage/ndb/src/common/transporter/TransporterRegistry.cpp: Auto merged storage/ndb/src/common/util/Makefile.am: Auto merged storage/ndb/src/common/util/Parser.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Auto merged storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Auto merged storage/ndb/src/kernel/error/ndbd_exit_codes.c: Auto merged storage/ndb/src/kernel/vm/FastScheduler.cpp: Auto merged storage/ndb/src/kernel/vm/TransporterCallback.cpp: Auto merged storage/ndb/src/kernel/vm/VMSignal.hpp: Auto merged storage/ndb/src/mgmapi/mgmapi.cpp: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.hpp: Auto merged storage/ndb/src/mgmsrv/Services.cpp: Auto merged storage/ndb/src/ndbapi/TransporterFacade.cpp: Auto merged storage/ndb/test/ndbapi/testBackup.cpp: Auto merged storage/ndb/test/ndbapi/testOperations.cpp: Auto merged storage/ndb/test/src/HugoCalculator.cpp: Auto merged storage/ndb/tools/ndb_condig.cpp: Auto merged strings/ctype-big5.c: Auto merged strings/ctype-ucs2.c: Auto merged support-files/mysql.spec.sh: Auto merged BUILD/SETUP.sh: manual merge configure.in: manual merge mysql-test/r/alter_table.result: manual merge sql/handler.cc: manual merge sql/mysql_priv.h: manual merge sql/records.cc: manual merge sql/share/errmsg.txt: manual merge sql/sql_table.cc: manual merge Fix labels sql/sql_update.cc: manual merge sql/table.cc: manual merge sql/unireg.cc: manual merge storage/ndb/config/type_ndbapi.mk.am: manual merge
This commit is contained in:
246
sql/sql_parse.cc
246
sql/sql_parse.cc
@@ -1769,6 +1769,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
/* Saved variable value */
|
||||
my_bool old_innodb_table_locks=
|
||||
IF_INNOBASE_DB(thd->variables.innodb_table_locks, FALSE);
|
||||
/* used as fields initializator */
|
||||
lex_start(thd, 0, 0);
|
||||
|
||||
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS],
|
||||
@@ -2319,8 +2321,6 @@ mysql_execute_command(THD *thd)
|
||||
LEX *lex= thd->lex;
|
||||
/* first SELECT_LEX (have special meaning for many of non-SELECTcommands) */
|
||||
SELECT_LEX *select_lex= &lex->select_lex;
|
||||
bool slave_fake_lock= 0;
|
||||
MYSQL_LOCK *fake_prev_lock= 0;
|
||||
/* first table of first SELECT_LEX */
|
||||
TABLE_LIST *first_table= (TABLE_LIST*) select_lex->table_list.first;
|
||||
/* list of all tables in query */
|
||||
@@ -2369,34 +2369,21 @@ mysql_execute_command(THD *thd)
|
||||
#ifdef HAVE_REPLICATION
|
||||
if (thd->slave_thread)
|
||||
{
|
||||
if (lex->sql_command == SQLCOM_UPDATE_MULTI)
|
||||
{
|
||||
DBUG_PRINT("info",("need faked locked tables"));
|
||||
|
||||
if (check_multi_update_lock(thd))
|
||||
goto error;
|
||||
|
||||
/* Fix for replication, the tables are opened and locked,
|
||||
now we pretend that we have performed a LOCK TABLES action */
|
||||
|
||||
fake_prev_lock= thd->locked_tables;
|
||||
if (thd->lock)
|
||||
thd->locked_tables= thd->lock;
|
||||
thd->lock= 0;
|
||||
slave_fake_lock= 1;
|
||||
}
|
||||
/*
|
||||
Skip if we are in the slave thread, some table rules have been
|
||||
given and the table list says the query should not be replicated.
|
||||
Check if statment should be skipped because of slave filtering
|
||||
rules
|
||||
|
||||
Exceptions are:
|
||||
- UPDATE MULTI: For this statement, we want to check the filtering
|
||||
rules later in the code
|
||||
- SET: we always execute it (Not that many SET commands exists in
|
||||
the binary log anyway -- only 4.1 masters write SET statements,
|
||||
in 5.0 there are no SET statements in the binary log)
|
||||
- DROP TEMPORARY TABLE IF EXISTS: we always execute it (otherwise we
|
||||
have stale files on slave caused by exclusion of one tmp table).
|
||||
*/
|
||||
if (!(lex->sql_command == SQLCOM_SET_OPTION) &&
|
||||
if (!(lex->sql_command == SQLCOM_UPDATE_MULTI) &&
|
||||
!(lex->sql_command == SQLCOM_SET_OPTION) &&
|
||||
!(lex->sql_command == SQLCOM_DROP_TABLE &&
|
||||
lex->drop_temporary && lex->drop_if_exists) &&
|
||||
all_tables_not_ok(thd, all_tables))
|
||||
@@ -2419,7 +2406,7 @@ mysql_execute_command(THD *thd)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* !HAVE_REPLICATION */
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
||||
/*
|
||||
When option readonly is set deny operations which change tables.
|
||||
@@ -3211,23 +3198,36 @@ end_with_restore_list:
|
||||
if (result != 2)
|
||||
break;
|
||||
case SQLCOM_UPDATE_MULTI:
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
/* if we switched from normal update, rights are checked */
|
||||
if (result != 2)
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
/* if we switched from normal update, rights are checked */
|
||||
if (result != 2)
|
||||
{
|
||||
if ((res= multi_update_precheck(thd, all_tables)))
|
||||
break;
|
||||
}
|
||||
else
|
||||
res= 0;
|
||||
if ((res= multi_update_precheck(thd, all_tables)))
|
||||
break;
|
||||
}
|
||||
else
|
||||
res= 0;
|
||||
|
||||
res= mysql_multi_update(thd, all_tables,
|
||||
&select_lex->item_list,
|
||||
&lex->value_list,
|
||||
select_lex->where,
|
||||
select_lex->options,
|
||||
lex->duplicates, lex->ignore, unit, select_lex);
|
||||
if ((res= mysql_multi_update_prepare(thd)))
|
||||
break;
|
||||
|
||||
#ifdef HAVE_REPLICATION
|
||||
/* Check slave filtering rules */
|
||||
if (thd->slave_thread && all_tables_not_ok(thd, all_tables))
|
||||
{
|
||||
/* we warn the slave SQL thread */
|
||||
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
|
||||
break;
|
||||
}
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
||||
res= mysql_multi_update(thd, all_tables,
|
||||
&select_lex->item_list,
|
||||
&lex->value_list,
|
||||
select_lex->where,
|
||||
select_lex->options,
|
||||
lex->duplicates, lex->ignore, unit, select_lex);
|
||||
break;
|
||||
}
|
||||
case SQLCOM_REPLACE:
|
||||
@@ -3688,6 +3688,8 @@ end_with_restore_list:
|
||||
if (check_access(thd, INSERT_ACL, "mysql", 0, 1, 1, 0) &&
|
||||
check_global_access(thd,CREATE_USER_ACL))
|
||||
break;
|
||||
if (end_active_trans(thd))
|
||||
goto error;
|
||||
if (!(res= mysql_create_user(thd, lex->users_list)))
|
||||
{
|
||||
if (mysql_bin_log.is_open())
|
||||
@@ -3704,6 +3706,8 @@ end_with_restore_list:
|
||||
if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 1, 0) &&
|
||||
check_global_access(thd,CREATE_USER_ACL))
|
||||
break;
|
||||
if (end_active_trans(thd))
|
||||
goto error;
|
||||
if (!(res= mysql_drop_user(thd, lex->users_list)))
|
||||
{
|
||||
if (mysql_bin_log.is_open())
|
||||
@@ -3720,6 +3724,8 @@ end_with_restore_list:
|
||||
if (check_access(thd, UPDATE_ACL, "mysql", 0, 1, 1, 0) &&
|
||||
check_global_access(thd,CREATE_USER_ACL))
|
||||
break;
|
||||
if (end_active_trans(thd))
|
||||
goto error;
|
||||
if (!(res= mysql_rename_user(thd, lex->users_list)))
|
||||
{
|
||||
if (mysql_bin_log.is_open())
|
||||
@@ -4066,6 +4072,19 @@ end_with_restore_list:
|
||||
|
||||
DBUG_ASSERT(lex->sphead != 0);
|
||||
|
||||
if (!lex->sphead->m_db.str || !lex->sphead->m_db.str[0])
|
||||
{
|
||||
if (! thd->db)
|
||||
{
|
||||
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
|
||||
delete lex->sphead;
|
||||
lex->sphead= 0;
|
||||
goto error;
|
||||
}
|
||||
lex->sphead->m_db.length= strlen(thd->db);
|
||||
lex->sphead->m_db.str= thd->db;
|
||||
}
|
||||
|
||||
if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0,
|
||||
is_schema_db(lex->sphead->m_db.str)))
|
||||
{
|
||||
@@ -4075,13 +4094,10 @@ end_with_restore_list:
|
||||
}
|
||||
|
||||
if (end_active_trans(thd))
|
||||
goto error;
|
||||
|
||||
if (!lex->sphead->m_db.str || !lex->sphead->m_db.str[0])
|
||||
{
|
||||
lex->sphead->m_db.length= strlen(thd->db);
|
||||
lex->sphead->m_db.str= strmake_root(thd->mem_root, thd->db,
|
||||
lex->sphead->m_db.length);
|
||||
delete lex->sphead;
|
||||
lex->sphead= 0;
|
||||
goto error;
|
||||
}
|
||||
|
||||
name= lex->sphead->name(&namelen);
|
||||
@@ -4108,11 +4124,23 @@ end_with_restore_list:
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
We need to copy name and db in order to use them for
|
||||
check_routine_access which is called after lex->sphead has
|
||||
been deleted.
|
||||
*/
|
||||
name= thd->strdup(name);
|
||||
db= thd->strmake(lex->sphead->m_db.str, lex->sphead->m_db.length);
|
||||
lex->sphead->m_db.str= db= thd->strmake(lex->sphead->m_db.str,
|
||||
lex->sphead->m_db.length);
|
||||
res= (result= lex->sphead->create(thd));
|
||||
if (result == SP_OK)
|
||||
{
|
||||
/*
|
||||
We must cleanup the unit and the lex here because
|
||||
sp_grant_privileges calls (indirectly) db_find_routine,
|
||||
which in turn may call yyparse with THD::lex.
|
||||
TODO: fix db_find_routine to use a temporary lex.
|
||||
*/
|
||||
lex->unit.cleanup();
|
||||
delete lex->sphead;
|
||||
lex->sphead= 0;
|
||||
@@ -4514,6 +4542,9 @@ end_with_restore_list:
|
||||
}
|
||||
case SQLCOM_CREATE_VIEW:
|
||||
{
|
||||
if (end_active_trans(thd))
|
||||
goto error;
|
||||
|
||||
if (!(res= mysql_create_view(thd, thd->lex->create_view_mode)) &&
|
||||
mysql_bin_log.is_open())
|
||||
{
|
||||
@@ -4528,7 +4559,8 @@ end_with_restore_list:
|
||||
command[thd->lex->create_view_mode].length);
|
||||
view_store_options(thd, first_table, &buff);
|
||||
buff.append("VIEW ", 5);
|
||||
if (!first_table->current_db_used)
|
||||
/* Test if user supplied a db (ie: we did not use thd->db) */
|
||||
if (first_table->db != thd->db && first_table->db[0])
|
||||
{
|
||||
append_identifier(thd, &buff, first_table->db,
|
||||
first_table->db_length);
|
||||
@@ -4560,6 +4592,9 @@ end_with_restore_list:
|
||||
}
|
||||
case SQLCOM_CREATE_TRIGGER:
|
||||
{
|
||||
if (end_active_trans(thd))
|
||||
goto error;
|
||||
|
||||
res= mysql_create_or_drop_trigger(thd, all_tables, 1);
|
||||
|
||||
/* We don't care about trigger body after this point */
|
||||
@@ -4569,6 +4604,9 @@ end_with_restore_list:
|
||||
}
|
||||
case SQLCOM_DROP_TRIGGER:
|
||||
{
|
||||
if (end_active_trans(thd))
|
||||
goto error;
|
||||
|
||||
res= mysql_create_or_drop_trigger(thd, all_tables, 0);
|
||||
break;
|
||||
}
|
||||
@@ -4776,14 +4814,6 @@ error:
|
||||
res= 1;
|
||||
|
||||
cleanup:
|
||||
if (unlikely(slave_fake_lock))
|
||||
{
|
||||
DBUG_PRINT("info",("undoing faked lock"));
|
||||
thd->lock= thd->locked_tables;
|
||||
thd->locked_tables= fake_prev_lock;
|
||||
if (thd->lock == thd->locked_tables)
|
||||
thd->lock= 0;
|
||||
}
|
||||
DBUG_RETURN(res || thd->net.report_error);
|
||||
}
|
||||
|
||||
@@ -4854,7 +4884,6 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
bool db_is_pattern= test(want_access & GRANT_ACL);
|
||||
#endif
|
||||
ulong dummy;
|
||||
const char *db_name;
|
||||
DBUG_ENTER("check_access");
|
||||
DBUG_PRINT("enter",("db: %s want_access: %lu master_access: %lu",
|
||||
db ? db : "", want_access, sctx->master_access));
|
||||
@@ -4872,15 +4901,16 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
DBUG_RETURN(TRUE); /* purecov: tested */
|
||||
}
|
||||
|
||||
db_name= db ? db : thd->db;
|
||||
if (schema_db)
|
||||
{
|
||||
if (want_access & ~(SELECT_ACL | EXTRA_ACL))
|
||||
{
|
||||
if (!no_errors)
|
||||
{
|
||||
const char *db_name= db ? db : thd->db;
|
||||
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
|
||||
sctx->priv_user,
|
||||
sctx->priv_host, db_name);
|
||||
sctx->priv_user, sctx->priv_host, db_name);
|
||||
}
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
else
|
||||
@@ -5000,8 +5030,14 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
|
||||
{
|
||||
uint found=0;
|
||||
ulong found_access=0;
|
||||
TABLE_LIST *org_tables=tables;
|
||||
for (; tables; tables= tables->next_global)
|
||||
TABLE_LIST *org_tables= tables;
|
||||
TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
|
||||
/*
|
||||
The check that first_not_own_table is not reached is for the case when
|
||||
the given table list refers to the list for prelocking (contains tables
|
||||
of other queries). For simple queries first_not_own_table is 0.
|
||||
*/
|
||||
for (; tables != first_not_own_table; tables= tables->next_global)
|
||||
{
|
||||
if (tables->schema_table &&
|
||||
(want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
|
||||
@@ -5012,6 +5048,11 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
|
||||
information_schema_name.str);
|
||||
return TRUE;
|
||||
}
|
||||
/*
|
||||
Register access for view underlying table.
|
||||
Remove SHOW_VIEW_ACL, because it will be checked during making view
|
||||
*/
|
||||
tables->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL);
|
||||
if (tables->derived || tables->schema_table || tables->belong_to_view ||
|
||||
(tables->table && (int)tables->table->s->tmp_table) ||
|
||||
my_tz_check_n_skip_implicit_tables(&tables,
|
||||
@@ -5055,11 +5096,16 @@ check_routine_access(THD *thd, ulong want_access,char *db, char *name,
|
||||
tables->db= db;
|
||||
tables->table_name= tables->alias= name;
|
||||
|
||||
if ((thd->security_ctx->master_access & want_access) == want_access &&
|
||||
!thd->db)
|
||||
/*
|
||||
The following test is just a shortcut for check_access() (to avoid
|
||||
calculating db_access) under the assumption that it's common to
|
||||
give persons global right to execute all stored SP (but not
|
||||
necessary to create them).
|
||||
*/
|
||||
if ((thd->security_ctx->master_access & want_access) == want_access)
|
||||
tables->grant.privilege= want_access;
|
||||
else if (check_access(thd,want_access,db,&tables->grant.privilege,
|
||||
0, no_errors, test(tables->schema_table)))
|
||||
0, no_errors, 0))
|
||||
return TRUE;
|
||||
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
@@ -5760,7 +5806,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
|
||||
case FIELD_TYPE_NULL:
|
||||
break;
|
||||
case FIELD_TYPE_NEWDECIMAL:
|
||||
if (!length)
|
||||
if (!length && !new_field->decimals)
|
||||
new_field->length= 10;
|
||||
if (new_field->length > DECIMAL_MAX_PRECISION)
|
||||
{
|
||||
@@ -6146,14 +6192,12 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
{
|
||||
ptr->db= thd->db;
|
||||
ptr->db_length= thd->db_length;
|
||||
ptr->current_db_used= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The following can't be "" as we may do 'casedn_str()' on it */
|
||||
ptr->db= empty_c_string;
|
||||
ptr->db_length= 0;
|
||||
ptr->current_db_used= 1;
|
||||
}
|
||||
if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
|
||||
ptr->db= thd->strdup(ptr->db);
|
||||
@@ -6168,8 +6212,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX);
|
||||
ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);
|
||||
ptr->derived= table->sel;
|
||||
if (!my_strcasecmp(system_charset_info, ptr->db,
|
||||
information_schema_name.str))
|
||||
if (!ptr->derived && !my_strcasecmp(system_charset_info, ptr->db,
|
||||
information_schema_name.str))
|
||||
{
|
||||
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name);
|
||||
if (!schema_table ||
|
||||
@@ -6916,57 +6960,6 @@ bool check_simple_select()
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Setup locking for multi-table updates. Used by the replication slave.
|
||||
Replication slave SQL thread examines (all_tables_not_ok()) the
|
||||
locking state of referenced tables to determine if the query has to
|
||||
be executed or ignored. Since in multi-table update, the
|
||||
'default' lock is read-only, this lock is corrected early enough by
|
||||
calling this function, before the slave decides to execute/ignore.
|
||||
|
||||
SYNOPSIS
|
||||
check_multi_update_lock()
|
||||
thd Current thread
|
||||
|
||||
RETURN VALUES
|
||||
0 ok
|
||||
1 error
|
||||
*/
|
||||
static bool check_multi_update_lock(THD *thd)
|
||||
{
|
||||
bool res= 1;
|
||||
LEX *lex= thd->lex;
|
||||
TABLE_LIST *table, *tables= lex->query_tables;
|
||||
DBUG_ENTER("check_multi_update_lock");
|
||||
|
||||
if (check_db_used(thd, tables))
|
||||
goto error;
|
||||
|
||||
/*
|
||||
Ensure that we have UPDATE or SELECT privilege for each table
|
||||
The exact privilege is checked in mysql_multi_update()
|
||||
*/
|
||||
for (table= tables ; table ; table= table->next_local)
|
||||
{
|
||||
TABLE_LIST *save= table->next_local;
|
||||
table->next_local= 0;
|
||||
if ((check_access(thd, UPDATE_ACL, table->db,
|
||||
&table->grant.privilege,0,1, test(table->schema_table)) ||
|
||||
(grant_option && check_grant(thd, UPDATE_ACL, table,0,1,1))) &&
|
||||
check_one_table_access(thd, SELECT_ACL, table))
|
||||
goto error;
|
||||
table->next_local= save;
|
||||
}
|
||||
|
||||
if (mysql_multi_update_prepare(thd))
|
||||
goto error;
|
||||
|
||||
res= 0;
|
||||
|
||||
error:
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
||||
Comp_creator *comp_eq_creator(bool invert)
|
||||
{
|
||||
@@ -7453,9 +7446,9 @@ Item *negate_expression(THD *thd, Item *expr)
|
||||
Assign as view definer current user
|
||||
|
||||
SYNOPSIS
|
||||
default_definer()
|
||||
Secytity_context current decurity context
|
||||
definer structure where it should be assigned
|
||||
default_view_definer()
|
||||
sctx current security context
|
||||
definer structure where it should be assigned
|
||||
|
||||
RETURN
|
||||
FALSE OK
|
||||
@@ -7466,15 +7459,14 @@ bool default_view_definer(Security_context *sctx, st_lex_user *definer)
|
||||
{
|
||||
definer->user.str= sctx->priv_user;
|
||||
definer->user.length= strlen(sctx->priv_user);
|
||||
if (*sctx->priv_host != 0)
|
||||
{
|
||||
definer->host.str= sctx->priv_host;
|
||||
definer->host.length= strlen(sctx->priv_host);
|
||||
}
|
||||
else
|
||||
|
||||
if (!*sctx->priv_host)
|
||||
{
|
||||
my_error(ER_NO_VIEW_USER, MYF(0));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
definer->host.str= sctx->priv_host;
|
||||
definer->host.length= strlen(sctx->priv_host);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user