diff options
author | unknown <timour@mysql.com> | 2005-12-07 10:47:43 +0200 |
---|---|---|
committer | unknown <timour@mysql.com> | 2005-12-07 10:47:43 +0200 |
commit | f1ac6bb9758369653c37099d7f36fe0a47ad2d35 (patch) | |
tree | 5c45e53e7f09589e61835d39a983102878f0071e /sql/table.cc | |
parent | fd2beeda33771172dbb95518df3233cb7e005187 (diff) | |
parent | f095abaa4748c5ad2c302b8697c819d3fbd5de2a (diff) | |
download | mariadb-git-f1ac6bb9758369653c37099d7f36fe0a47ad2d35.tar.gz |
Merge mysql.com:/home/timka/mysql/src/5.0-2486
into mysql.com:/home/timka/mysql/src/5.1-dbg
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_acl.h:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/table.h:
Auto merged
sql/sql_base.cc:
SCCS merged
sql/table.cc:
SCCS merged
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 110 |
1 files changed, 42 insertions, 68 deletions
diff --git a/sql/table.cc b/sql/table.cc index ff29a33ef03..26a5e9362b8 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3080,60 +3080,6 @@ GRANT_INFO *Natural_join_column::grant() } - -#ifndef NO_EMBEDDED_ACCESS_CHECKS - -/* - Check the access rights for the current join column. - columns. - - SYNOPSIS - Natural_join_column::check_grants() - - DESCRIPTION - Check the access rights to a column from a natural join in a generic - way that hides the heterogeneity of the column representation - whether - it is a view or a stored table colum. - - RETURN - FALSE The column can be accessed - TRUE There are no access rights to all equivalent columns -*/ - -bool -Natural_join_column::check_grants(THD *thd, const char *name, uint length) -{ - GRANT_INFO *grant; - const char *db_name; - const char *table_name; - Security_context *save_security_ctx= thd->security_ctx; - Security_context *new_sctx= table_ref->security_ctx; - bool res; - - if (view_field) - { - DBUG_ASSERT(table_field == NULL); - grant= &(table_ref->grant); - db_name= table_ref->view_db.str; - table_name= table_ref->view_name.str; - } - else - { - DBUG_ASSERT(table_field && view_field == NULL); - grant= &(table_ref->table->grant); - db_name= table_ref->table->s->db.str; - table_name= table_ref->table->s->table_name.str; - } - - if (new_sctx) - thd->security_ctx= new_sctx; - res= check_grant_column(thd, grant, db_name, table_name, name, length); - thd->security_ctx= save_security_ctx; - return res; -} -#endif - - void Field_iterator_view::set(TABLE_LIST *table) { DBUG_ASSERT(table->field_translation); @@ -3176,8 +3122,9 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, if (view->schema_table_reformed) { /* - In case of SHOW command (schema_table_reformed set) all items are - fixed + Translation table items are always Item_fields and already fixed + ('mysql_schema_table' function). So we can return directly the + field. This case happens only for 'show & where' commands. */ DBUG_ASSERT(field && field->fixed); DBUG_RETURN(field); @@ -3209,21 +3156,14 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, void Field_iterator_natural_join::set(TABLE_LIST *table_ref) { DBUG_ASSERT(table_ref->join_columns); - delete column_ref_it; - - /* - TODO: try not to allocate new iterator every time. If we have to, - then check for out of memory condition. - */ - column_ref_it= new List_iterator_fast<Natural_join_column> - (*(table_ref->join_columns)); - cur_column_ref= (*column_ref_it)++; + column_ref_it.init(*(table_ref->join_columns)); + cur_column_ref= column_ref_it++; } void Field_iterator_natural_join::next() { - cur_column_ref= (*column_ref_it)++; + cur_column_ref= column_ref_it++; DBUG_ASSERT(!cur_column_ref || ! cur_column_ref->table_field || cur_column_ref->table_ref->table == cur_column_ref->table_field->table); @@ -3350,7 +3290,6 @@ GRANT_INFO *Field_iterator_table_ref::grant() SYNOPSIS Field_iterator_table_ref::get_or_create_column_ref() - thd [in] pointer to current thread is_created [out] set to TRUE if the column was created, FALSE if we return an already created colum @@ -3363,7 +3302,7 @@ GRANT_INFO *Field_iterator_table_ref::grant() */ Natural_join_column * -Field_iterator_table_ref::get_or_create_column_ref(THD *thd, bool *is_created) +Field_iterator_table_ref::get_or_create_column_ref(bool *is_created) { Natural_join_column *nj_col; @@ -3397,6 +3336,41 @@ Field_iterator_table_ref::get_or_create_column_ref(THD *thd, bool *is_created) } +/* + Return an existing reference to a column of a natural/using join. + + SYNOPSIS + Field_iterator_table_ref::get_natural_column_ref() + + DESCRIPTION + The method should be called in contexts where it is expected that + all natural join columns are already created, and that the column + being retrieved is a Natural_join_column. + + RETURN + # Pointer to a column of a natural join (or its operand) + NULL No memory to allocate the column +*/ + +Natural_join_column * +Field_iterator_table_ref::get_natural_column_ref() +{ + Natural_join_column *nj_col; + + DBUG_ASSERT(field_it == &natural_join_it); + /* + The field belongs to a NATURAL join, therefore the column reference was + already created via one of the two constructor calls above. In this case + we just return the already created column reference. + */ + nj_col= natural_join_it.column_ref(); + DBUG_ASSERT(nj_col && + (!nj_col->table_field || + nj_col->table_ref->table == nj_col->table_field->table)); + return nj_col; +} + + /***************************************************************************** ** Instansiate templates *****************************************************************************/ |