summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/item_create.cc9
-rw-r--r--sql/item_geofunc.cc28
-rw-r--r--sql/item_geofunc.h5
-rw-r--r--sql/mysqld.cc5
-rw-r--r--sql/share/errmsg.txt26
-rw-r--r--sql/sql_acl.cc15
-rw-r--r--sql/sql_lex.cc21
-rw-r--r--sql/sql_show.cc27
-rw-r--r--sql/sql_view.cc3
-rw-r--r--sql/sql_yacc.yy4
-rw-r--r--sql/table.h1
11 files changed, 94 insertions, 50 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 7d57757432e..e0e18094705 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -450,6 +450,7 @@ 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) {
@@ -460,7 +461,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 ? dec : 2);
+ 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 ? dec : 2);
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 57ee7971c8d..cec313dc8ca 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2738,9 +2738,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/share/errmsg.txt b/sql/share/errmsg.txt
index 4f37b1ab4d2..e90f54608e1 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -54,7 +54,7 @@ ER_CANT_CREATE_FILE
cze "Nemohu vytvo-Bit soubor '%-.64s' (chybov kd: %d)"
dan "Kan ikke oprette filen '%-.64s' (Fejlkode: %d)"
nla "Kan file '%-.64s' niet aanmaken (Errcode: %d)"
- eng "Can't create file '%-.64s' (errno: %d)"
+ eng "Can't create file '%-.200s' (errno: %d)"
est "Ei suuda luua faili '%-.64s' (veakood: %d)"
fre "Ne peut crer le fichier '%-.64s' (Errcode: %d)"
ger "Kann Datei '%-.64s' nicht erzeugen (Fehler: %d)"
@@ -278,7 +278,7 @@ ER_CANT_GET_STAT
cze "Nemohu z-Bskat stav '%-.64s' (chybov kd: %d)"
dan "Kan ikke lse status af '%-.64s' (Fejlkode: %d)"
nla "Kan de status niet krijgen van '%-.64s' (Errcode: %d)"
- eng "Can't get status of '%-.64s' (errno: %d)"
+ eng "Can't get status of '%-.200s' (errno: %d)"
jps "'%-.64s' ̃XeC^X܂. (errno: %d)",
est "Ei suuda lugeda '%-.64s' olekut (veakood: %d)"
fre "Ne peut obtenir le status de '%-.64s' (Errcode: %d)"
@@ -353,7 +353,7 @@ ER_CANT_OPEN_FILE
cze "Nemohu otev-Bt soubor '%-.64s' (chybov kd: %d)"
dan "Kan ikke bne fil: '%-.64s' (Fejlkode: %d)"
nla "Kan de file '%-.64s' niet openen (Errcode: %d)"
- eng "Can't open file: '%-.64s' (errno: %d)"
+ eng "Can't open file: '%-.200s' (errno: %d)"
jps "'%-.64s' t@CJł܂ (errno: %d)",
est "Ei suuda avada faili '%-.64s' (veakood: %d)"
fre "Ne peut ouvrir le fichier: '%-.64s' (Errcode: %d)"
@@ -378,7 +378,7 @@ ER_FILE_NOT_FOUND
cze "Nemohu naj-Bt soubor '%-.64s' (chybov kd: %d)"
dan "Kan ikke finde fila: '%-.64s' (Fejlkode: %d)"
nla "Kan de file: '%-.64s' niet vinden (Errcode: %d)"
- eng "Can't find file: '%-.64s' (errno: %d)"
+ eng "Can't find file: '%-.200s' (errno: %d)"
jps "'%-.64s' t@Ct鎖ł܂.(errno: %d)",
est "Ei suuda leida faili '%-.64s' (veakood: %d)"
fre "Ne peut trouver le fichier: '%-.64s' (Errcode: %d)"
@@ -549,7 +549,7 @@ ER_ERROR_ON_READ
cze "Chyba p-Bi ten souboru '%-.64s' (chybov kd: %d)"
dan "Fejl ved lsning af '%-.64s' (Fejlkode: %d)"
nla "Fout bij het lezen van file '%-.64s' (Errcode: %d)"
- eng "Error reading file '%-.64s' (errno: %d)"
+ eng "Error reading file '%-.200s' (errno: %d)"
jps "'%-.64s' t@C̓ǂݍ݃G[ (errno: %d)",
est "Viga faili '%-.64s' lugemisel (veakood: %d)"
fre "Erreur en lecture du fichier '%-.64s' (Errcode: %d)"
@@ -599,7 +599,7 @@ ER_ERROR_ON_WRITE
cze "Chyba p-Bi zpisu do souboru '%-.64s' (chybov kd: %d)"
dan "Fejl ved skriving av filen '%-.64s' (Fejlkode: %d)"
nla "Fout bij het wegschrijven van file '%-.64s' (Errcode: %d)"
- eng "Error writing file '%-.64s' (errno: %d)"
+ eng "Error writing file '%-.200s' (errno: %d)"
jps "'%-.64s' t@Cł܂ (errno: %d)",
est "Viga faili '%-.64s' kirjutamisel (veakood: %d)"
fre "Erreur d'criture du fichier '%-.64s' (Errcode: %d)"
@@ -772,7 +772,7 @@ ER_NOT_FORM_FILE
cze "Nespr-Bvn informace v souboru '%-.64s'"
dan "Forkert indhold i: '%-.64s'"
nla "Verkeerde info in file: '%-.64s'"
- eng "Incorrect information in file: '%-.64s'"
+ eng "Incorrect information in file: '%-.200s'"
jps "t@C '%-.64s' info ԈĂ悤ł",
est "Vigane informatsioon failis '%-.64s'"
fre "Information erronne dans le fichier: '%-.64s'"
@@ -797,7 +797,7 @@ ER_NOT_KEYFILE
cze "Nespr-Bvn kl pro tabulku '%-.64s'; pokuste se ho opravit"
dan "Fejl i indeksfilen til tabellen '%-.64s'; prv at reparere den"
nla "Verkeerde zoeksleutel file voor tabel: '%-.64s'; probeer het te repareren"
- eng "Incorrect key file for table '%-.64s'; try to repair it"
+ eng "Incorrect key file for table '%-.200s'; try to repair it"
jps "'%-.64s' e[u key file ԈĂ悤ł. CĂ",
est "Tabeli '%-.64s' vtmefail on vigane; proovi seda parandada"
fre "Index corrompu dans la table: '%-.64s'; essayez de le rparer"
@@ -2044,7 +2044,7 @@ ER_TEXTFILE_NOT_READABLE
cze "Soubor '%-.64s' mus-B bt v adresi databze nebo iteln pro vechny"
dan "Filen '%-.64s' skal vre i database-folderen og kunne lses af alle"
nla "Het bestand '%-.64s' dient in de database directory voor the komen of leesbaar voor iedereen te zijn."
- eng "The file '%-.64s' must be in the database directory or be readable by all"
+ eng "The file '%-.128s' must be in the database directory or be readable by all"
jps "t@C '%-.64s' databse directory ɂ邩SẴ[U[ǂ߂悤ɋ‚ĂȂ΂Ȃ܂.",
est "Fail '%-.64s' peab asuma andmebaasi kataloogis vi olema kigile loetav"
fre "Le fichier '%-.64s' doit tre dans le rpertoire de la base et lisible par tous"
@@ -2069,7 +2069,7 @@ ER_FILE_EXISTS_ERROR
cze "Soubor '%-.64s' ji-B existuje"
dan "Filen '%-.64s' eksisterer allerede"
nla "Het bestand '%-.64s' bestaat reeds"
- eng "File '%-.80s' already exists"
+ eng "File '%-.200s' already exists"
jps "File '%-.64s' ͊ɑ݂܂",
est "Fail '%-.80s' juba eksisteerib"
fre "Le fichier '%-.64s' existe dj"
@@ -2345,7 +2345,7 @@ ER_NO_UNIQUE_LOGFILE
cze "Nemohu vytvo-Bit jednoznan jmno logovacho souboru %s.(1-999)\n"
dan "Kan ikke lave unikt log-filnavn %s.(1-999)\n"
nla "Het is niet mogelijk een unieke naam te maken voor de logfile %s.(1-999)\n"
- eng "Can't generate a unique log-filename %-.64s.(1-999)\n"
+ eng "Can't generate a unique log-filename %-.200s.(1-999)\n"
est "Ei suuda luua unikaalset logifaili nime %-.64s.(1-999)\n"
fre "Ne peut gnrer un unique nom de journal %s.(1-999)\n"
ger "Kann keinen eindeutigen Dateinamen fr die Logdatei %-.64s(1-999) erzeugen\n"
@@ -5218,7 +5218,7 @@ ER_FPARSER_BAD_HEADER
rus " '%-.64s'"
ukr "צ ̦ '%-.64s'"
ER_FPARSER_EOF_IN_COMMENT
- eng "Unexpected end of file while parsing comment '%-.64s'"
+ eng "Unexpected end of file while parsing comment '%-.200s'"
ger "Unerwartetes Dateiende beim Parsen des Kommentars '%-.64s'"
rus " '%-.64s'"
ukr "Ħ ˦ Ҧ '%-.64s'"
@@ -5387,7 +5387,7 @@ ER_LOGGING_PROHIBIT_CHANGING_OF
eng "Binary logging and replication forbid changing the global server %s"
ger "Binrlogs und Replikation verhindern Wechsel des globalen Servers %s"
ER_NO_FILE_MAPPING
- eng "Can't map file: %-.64s, errno: %d"
+ eng "Can't map file: %-.200s, errno: %d"
ger "Kann Datei nicht abbilden: %-.64s, Fehler: %d"
ER_WRONG_MAGIC
eng "Wrong magic in %-.64s"
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index ae5ea210a47..6e25878671d 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -3787,9 +3787,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 bb66fde79fe..563ebce4ff7 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -558,23 +558,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 a4f7062810f..433238cb853 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3140,31 +3140,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 16ee6505886..b4ee542ac39 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -999,7 +999,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 5d0a583f7d1..d2aca27c836 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -4359,6 +4359,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 ); }
@@ -4368,6 +4370,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 8c2ad8d8fdf..5136ac2c4db 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -573,6 +573,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 */