summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <rburnett@bk-internal.mysql.com>2006-08-17 22:30:32 +0200
committerunknown <rburnett@bk-internal.mysql.com>2006-08-17 22:30:32 +0200
commiteda1afe22209c838475abca464f11755f6e73df0 (patch)
treed2d9102e20068e358bfb5117ae4b4f668c489147 /sql
parent62af392e62de554b8943697fe42962e56a9f4aaa (diff)
parent703717c705594592be0bce8b160aeec0ec1d51ba (diff)
downloadmariadb-git-eda1afe22209c838475abca464f11755f6e73df0.tar.gz
Merge bk-internal.mysql.com:/data0/bk/mysql-5.1
into bk-internal.mysql.com:/data0/bk/mysql-5.1-kt mysql-test/r/type_newdecimal.result: Auto merged mysql-test/t/type_newdecimal.test: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/item_create.cc10
-rw-r--r--sql/item_geofunc.cc28
-rw-r--r--sql/item_geofunc.h5
-rw-r--r--sql/mysqld.cc5
-rw-r--r--sql/sql_acl.cc15
-rw-r--r--sql/sql_lex.cc21
-rw-r--r--sql/sql_show.cc31
-rw-r--r--sql/sql_view.cc3
-rw-r--r--sql/sql_yacc.yy4
-rw-r--r--sql/table.h1
10 files changed, 83 insertions, 40 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc
index e02ba384717..3a93ec6e516 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -454,6 +454,8 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
CHARSET_INFO *cs)
{
Item *res;
+ int tmp_len;
+ LINT_INIT(res);
switch (cast_type) {
case ITEM_CAST_BINARY: res= new Item_func_binary(a); break;
@@ -463,7 +465,13 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
case ITEM_CAST_TIME: res= new Item_time_typecast(a); break;
case ITEM_CAST_DATETIME: res= new Item_datetime_typecast(a); break;
case ITEM_CAST_DECIMAL:
- res= new Item_decimal_typecast(a, (len > 0) ? len : 10, dec);
+ tmp_len= (len>0) ? len : 10;
+ if (tmp_len < dec)
+ {
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
+ return 0;
+ }
+ res= new Item_decimal_typecast(a, tmp_len, dec);
break;
case ITEM_CAST_CHAR:
res= new Item_char_typecast(a, len, cs ? cs :
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 2b92e72e728..c5200e26cb7 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -25,6 +25,12 @@
#ifdef HAVE_SPATIAL
#include <m_ctype.h>
+Field *Item_geometry_func::tmp_table_field(TABLE *t_arg)
+{
+ return new Field_geom(max_length, maybe_null, name, t_arg,
+ (Field::geometry_type) get_geometry_type());
+}
+
void Item_geometry_func::fix_length_and_dec()
{
collation.set(&my_charset_bin);
@@ -32,6 +38,10 @@ void Item_geometry_func::fix_length_and_dec()
max_length=MAX_BLOB_WIDTH;
}
+int Item_geometry_func::get_geometry_type() const
+{
+ return (int)Field::GEOM_GEOMETRY;
+}
String *Item_func_geometry_from_text::val_str(String *str)
{
@@ -152,6 +162,12 @@ String *Item_func_geometry_type::val_str(String *str)
}
+int Item_func_envelope::get_geometry_type() const
+{
+ return (int) Field::GEOM_POLYGON;
+}
+
+
String *Item_func_envelope::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@@ -176,6 +192,12 @@ String *Item_func_envelope::val_str(String *str)
}
+int Item_func_centroid::get_geometry_type() const
+{
+ return (int) Field::GEOM_POINT;
+}
+
+
String *Item_func_centroid::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@@ -310,6 +332,12 @@ err:
*/
+int Item_func_point::get_geometry_type() const
+{
+ return (int) Field::GEOM_POINT;
+}
+
+
String *Item_func_point::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index 1f64fdba609..4848f59301d 100644
--- a/sql/item_geofunc.h
+++ b/sql/item_geofunc.h
@@ -33,6 +33,8 @@ public:
Item_geometry_func(List<Item> &list) :Item_str_func(list) {}
void fix_length_and_dec();
enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; }
+ Field *tmp_table_field(TABLE *t_arg);
+ virtual int get_geometry_type() const;
};
class Item_func_geometry_from_text: public Item_geometry_func
@@ -89,6 +91,7 @@ public:
Item_func_centroid(Item *a): Item_geometry_func(a) {}
const char *func_name() const { return "centroid"; }
String *val_str(String *);
+ int get_geometry_type() const;
};
class Item_func_envelope: public Item_geometry_func
@@ -97,6 +100,7 @@ public:
Item_func_envelope(Item *a): Item_geometry_func(a) {}
const char *func_name() const { return "envelope"; }
String *val_str(String *);
+ int get_geometry_type() const;
};
class Item_func_point: public Item_geometry_func
@@ -106,6 +110,7 @@ public:
Item_func_point(Item *a, Item *b, Item *srid): Item_geometry_func(a, b, srid) {}
const char *func_name() const { return "point"; }
String *val_str(String *);
+ int get_geometry_type() const;
};
class Item_func_spatial_decomp: public Item_geometry_func
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 9714759e6e2..419ea27b941 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2785,9 +2785,8 @@ static int init_common_variables(const char *conf_file_name, int argc,
get corrupted if accesses with names of different case.
*/
DBUG_PRINT("info", ("lower_case_table_names: %d", lower_case_table_names));
- if (!lower_case_table_names &&
- (lower_case_file_system=
- (test_if_case_insensitive(mysql_real_data_home) == 1)))
+ lower_case_file_system= test_if_case_insensitive(mysql_real_data_home);
+ if (!lower_case_table_names && lower_case_file_system == 1)
{
if (lower_case_table_names_used)
{
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 5590dd0049d..af2de0ca779 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -3932,9 +3932,24 @@ bool check_column_grant_in_table_ref(THD *thd, TABLE_LIST * table_ref,
if (table_ref->view || table_ref->field_translation)
{
/* View or derived information schema table. */
+ ulong view_privs;
grant= &(table_ref->grant);
db_name= table_ref->view_db.str;
table_name= table_ref->view_name.str;
+ if (table_ref->belong_to_view &&
+ (thd->lex->sql_command == SQLCOM_SHOW_FIELDS ||
+ thd->lex->sql_command == SQLCOM_SHOW_CREATE))
+ {
+ view_privs= get_column_grant(thd, grant, db_name, table_name, name);
+ if (view_privs & VIEW_ANY_ACL)
+ {
+ table_ref->belong_to_view->allowed_show= TRUE;
+ return FALSE;
+ }
+ table_ref->belong_to_view->allowed_show= FALSE;
+ my_message(ER_VIEW_NO_EXPLAIN, ER(ER_VIEW_NO_EXPLAIN), MYF(0));
+ return TRUE;
+ }
}
else
{
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index bf0da9d46ef..c5064df931b 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -567,23 +567,20 @@ int MYSQLlex(void *arg, void *yythd)
case MY_LEX_IDENT_OR_NCHAR:
if (yyPeek() != '\'')
- { // Found x'hex-number'
+ {
state= MY_LEX_IDENT;
break;
}
- yyGet(); // Skip '
- while ((c = yyGet()) && (c !='\'')) ;
- length=(lex->ptr - lex->tok_start); // Length of hexnum+3
- if (c != '\'')
+ /* Found N'string' */
+ lex->tok_start++; // Skip N
+ yySkip(); // Skip '
+ if (!(yylval->lex_str.str = get_text(lex)))
{
- return(ABORT_SYM); // Illegal hex constant
+ state= MY_LEX_CHAR; // Read char by char
+ break;
}
- yyGet(); // get_token makes an unget
- yylval->lex_str=get_token(lex,length);
- yylval->lex_str.str+=2; // Skip x'
- yylval->lex_str.length-=3; // Don't count x' and last '
- lex->yytoklen-=3;
- return (NCHAR_STRING);
+ yylval->lex_str.length= lex->yytoklen;
+ return(NCHAR_STRING);
case MY_LEX_IDENT_OR_HEX:
if (yyPeek() == '\'')
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index edbec84e37b..fd0c0e7be11 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3070,9 +3070,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
table->field[5]->store("",0, cs);
table->field[5]->set_notnull();
}
- pos=(byte*) ((flags & NOT_NULL_FLAG) &&
- field->type() != FIELD_TYPE_TIMESTAMP ?
- "NO" : "YES");
+ pos=(byte*) ((flags & NOT_NULL_FLAG) ? "NO" : "YES");
table->field[6]->store((const char*) pos,
strlen((const char*) pos), cs);
is_blob= (field->type() == FIELD_TYPE_BLOB);
@@ -3549,31 +3547,18 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
if (tables->view)
{
Security_context *sctx= thd->security_ctx;
- ulong grant= SHOW_VIEW_ACL;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- char *save_table_name= tables->table_name;
- if (!my_strcasecmp(system_charset_info, tables->definer.user.str,
- sctx->priv_user) &&
- !my_strcasecmp(system_charset_info, tables->definer.host.str,
- sctx->priv_host))
- grant= SHOW_VIEW_ACL;
- else
+ if (!tables->allowed_show)
{
- tables->table_name= tables->view_name.str;
- if (check_access(thd, SHOW_VIEW_ACL , base_name,
- &tables->grant.privilege, 0, 1,
- test(tables->schema_table)))
- grant= get_table_grant(thd, tables);
- else
- grant= tables->grant.privilege;
+ if (!my_strcasecmp(system_charset_info, tables->definer.user.str,
+ sctx->priv_user) &&
+ !my_strcasecmp(system_charset_info, tables->definer.host.str,
+ sctx->priv_host))
+ tables->allowed_show= TRUE;
}
- tables->table_name= save_table_name;
-#endif
-
restore_record(table, s->default_values);
table->field[1]->store(tables->view_db.str, tables->view_db.length, cs);
table->field[2]->store(tables->view_name.str, tables->view_name.length, cs);
- if (grant & SHOW_VIEW_ACL)
+ if (tables->allowed_show)
{
char buff[2048];
String qwe_str(buff, sizeof(buff), cs);
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 5ec7ca9cfb4..9b551d624cf 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1001,7 +1001,8 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
}
}
else if (!table->prelocking_placeholder &&
- old_lex->sql_command == SQLCOM_SHOW_CREATE)
+ old_lex->sql_command == SQLCOM_SHOW_CREATE &&
+ !table->belong_to_view)
{
if (check_table_access(thd, SHOW_VIEW_ACL, table, 0))
goto err;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index eb3d0d40817..8b60eefe4ea 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -6075,6 +6075,8 @@ simple_expr:
lex->length ? atoi(lex->length) : -1,
lex->dec ? atoi(lex->dec) : 0,
lex->charset);
+ if (!$$)
+ YYABORT;
}
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= new Item_func_case(* $4, $2, $5 ); }
@@ -6084,6 +6086,8 @@ simple_expr:
Lex->length ? atoi(Lex->length) : -1,
Lex->dec ? atoi(Lex->dec) : 0,
Lex->charset);
+ if (!$$)
+ YYABORT;
}
| CONVERT_SYM '(' expr USING charset_name ')'
{ $$= new Item_func_conv_charset($3,$5); }
diff --git a/sql/table.h b/sql/table.h
index 7675c27823b..d8a9eb4dfa9 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -686,6 +686,7 @@ typedef struct st_table_list
tables. Unlike 'next_local', this in this list views are *not*
leaves. Created in setup_tables() -> make_leaves_list().
*/
+ bool allowed_show;
st_table_list *next_leaf;
Item *where; /* VIEW WHERE clause condition */
Item *check_option; /* WITH CHECK OPTION condition */