From a424d01173d0b6d446f752a220c827d28358831a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Mar 2003 09:49:09 +0300 Subject: fixed bug 209 (SQL_SELECT_LIMIT and query cache incompatibility) mysql-test/r/query_cache.result: test of SET OPTION SQL_SELECT_LIMIT mysql-test/t/query_cache.test: test of SET OPTION SQL_SELECT_LIMIT sql/sql_cache.cc: layout fixed SQL_SELECT_LIMIT stored in query cache now sql/sql_parse.cc: room for SQL_SELECT_LAYOUT storing added --- sql/sql_parse.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1bb1fd9d39a..9e222c4f944 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1029,7 +1029,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* We must allocate some extra memory for query cache */ if (!(thd->query= (char*) thd->memdup_w_gap((gptr) (packet), packet_length, - thd->db_length+2))) + thd->db_length+2+ + sizeof(ha_rows)))) break; thd->query[packet_length]=0; thd->packet.shrink(thd->variables.net_buffer_length);// Reclaim some memory -- cgit v1.2.1 From da0844b15fec2629c207dc13f33495f9c40eeb96 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Apr 2003 10:35:13 +0500 Subject: #244 bugfix (thread stack error message in embedded library) sql/mysql_priv.h: stack checking suppressed in EMBEDDED case sql/sql_parse.cc: code of check_stack_overrun ifdefed --- sql/sql_parse.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9e222c4f944..0ffdb68a179 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2697,6 +2697,7 @@ static bool check_merge_table_access(THD *thd, char *db, #define used_stack(A,B) (long) (B - A) #endif +#ifndef EMBEDDED_LIBRARY bool check_stack_overrun(THD *thd,char *buf __attribute__((unused))) { long stack_used; @@ -2710,6 +2711,7 @@ bool check_stack_overrun(THD *thd,char *buf __attribute__((unused))) } return 0; } +#endif /* EMBEDDED_LIBRARY */ #define MY_YACC_INIT 1000 // Start with big alloc #define MY_YACC_MAX 32000 // Because of 'short' -- cgit v1.2.1 From e357610ba303f303d0a9b8652a437a4cb0a3f22e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Apr 2003 19:45:09 +0300 Subject: A fix for a bug with uncached database privileges. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0ffdb68a179..29bd1393322 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2550,7 +2550,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, if ((thd->master_access & want_access) == want_access) { - *save_priv=thd->master_access; + *save_priv=thd->master_access | thd->db_access; DBUG_RETURN(FALSE); } if (((want_access & ~thd->master_access) & ~(DB_ACLS | EXTRA_ACL)) || -- cgit v1.2.1 From 930ded12ca1c0df3e8c86ae65a1e7461132a95be Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Apr 2003 20:58:41 +0300 Subject: Back porting a fix from 4.0 at customer's request --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 62c2f18c882..152d9c585ca 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2155,7 +2155,7 @@ check_access(THD *thd,uint want_access,const char *db, uint *save_priv, if ((thd->master_access & want_access) == want_access) { - *save_priv=thd->master_access; + *save_priv=thd->master_access | thd->db_access; return FALSE; } if ((want_access & ~thd->master_access) & ~(DB_ACLS | EXTRA_ACL) || -- cgit v1.2.1 From 62af18cb8729894625d005e260838f68b7c57175 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Apr 2003 20:43:28 +0300 Subject: Fix for -fbranch-probabilites (bug 268) Fix for LEFT/RIGHT/MID with multi-byte-character sets (bug 314) Fix for new bison 1.875 max_insert_delayed_threads and delayed_insert_timeout now works as documented (bug 211) Don't show port in SHOW PROCESSLIST for system threads Fix problem with ORDER BY being discarded for some DISTINCT queries (bug 275) Fixed bug with NATURAL LEFT JOIN, NATURAL RIGHT JOIN and RIGHT JOIN when using many joined tables (Bug 212) acinclude.m4: Fix for -fbranch-probabilites configure.in: Fix for -fbranch-probabilites myisam/mi_open.c: Give error instead of writing to stderr (Which user can't see) mysql-test/r/join.result: Update results after change to NATURAL/LEFT/RIGHT JOIN mysql-test/r/join_outer.result: Update results after change to NATURAL/LEFT/RIGHT JOIN mysql-test/r/select.result: Update results after change to NATURAL/LEFT/RIGHT JOIN mysql-test/t/join.test: Update results after change to NATURAL/LEFT/RIGHT JOIN sql/item_strfunc.cc: Fix for LEFT/RIGHT/MID with multi-byte-character sets sql/mysqld.cc: Fix for new bison 1.875 (Wrong error text message when one got syntax error) sql/sql_class.cc: Don't show port in SHOW PROCESSLIST for system threads sql/sql_insert.cc: max_insert_delayed_threads now works as documented. delayed_insert_timeout now works on Linux sql/sql_parse.cc: Added comment sql/sql_select.cc: Fix problem with ORDER BY being discarded and results returned un-sorted sql/sql_yacc.yy: Fixed bug with NATURAL LEFT JOIN, NATURAL RIGHT JOIN and RIGHT JOIN when using many joined tables. --- sql/sql_parse.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0ffdb68a179..1a8ea7da8f4 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -210,9 +210,9 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, !(thd->client_capabilities & CLIENT_LONG_PASSWORD),&ur); DBUG_PRINT("info", - ("Capabilities: %d packet_length: %ld Host: '%s' User: '%s' Using password: %s Access: %u db: '%s'", + ("Capabilities: %d packet_length: %ld Host: '%s' Login user: '%s' Priv_user: '%s' Using password: %s Access: %u db: '%s'", thd->client_capabilities, thd->max_client_packet_length, - thd->host_or_ip, thd->priv_user, + thd->host_or_ip, thd->user, thd->priv_user, passwd[0] ? "yes": "no", thd->master_access, thd->db ? thd->db : "*none*")); if (thd->master_access & NO_ACCESS) @@ -517,7 +517,6 @@ check_connections(THD *thd) DBUG_PRINT("info",("Host: %s",thd->host)); thd->host_or_ip= thd->host; thd->ip= 0; - thd->peer_port= 0; bzero((char*) &thd->remote,sizeof(struct sockaddr)); } /* Ensure that wrong hostnames doesn't cause buffer overflows */ @@ -3419,6 +3418,24 @@ void add_join_on(TABLE_LIST *b,Item *expr) } +/* + Mark that we have a NATURAL JOIN between two tables + + SYNOPSIS + add_join_natural() + a Table to do normal join with + b Do normal join with this table + + IMPLEMENTATION + This function just marks that table b should be joined with a. + The function setup_cond() will create in b->on_expr a list + of equal condition between all fields of the same name. + + SELECT * FROM t1 NATURAL LEFT JOIN t2 + <=> + SELECT * FROM t1 LEFT JOIN t2 ON (t1.i=t2.i and t1.j=t2.j ... ) +*/ + void add_join_natural(TABLE_LIST *a,TABLE_LIST *b) { b->natural_join=a; -- cgit v1.2.1 From a34fc634658ce1b2ba63a45ee6bad4355a390439 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Apr 2003 10:32:56 +0300 Subject: Fix for openssl on Solaris Fix for grant bug with SELECT * include/my_global.h: Fix for openssl on Solaris sql/item_strfunc.cc: Fix for openssl on Solaris sql/sql_acl.cc: Indentation cleanup sql/sql_base.cc: Fix for grant bug with SELECT * sql/sql_parse.cc: Added comment tests/grant.pl: New grant test for SELECT * tests/grant.res: new grant results --- sql/sql_parse.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1a8ea7da8f4..7479ef653a9 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2519,12 +2519,20 @@ error: /**************************************************************************** Get the user (global) and database privileges for all used tables - Returns true (error) if we can't get the privileges and we don't use - table/column grants. - The idea of EXTRA_ACL is that one will be granted access to the table if - one has the asked privilege on any column combination of the table; For - example to be able to check a table one needs to have SELECT privilege on - any column of the table. + + NOTES + The idea of EXTRA_ACL is that one will be granted access to the table if + one has the asked privilege on any column combination of the table; For + example to be able to check a table one needs to have SELECT privilege on + any column of the table. + + RETURN + 0 ok + 1 If we can't get the privileges and we don't use table/column grants. + + save_priv In this we store global and db level grants for the table + Note that we don't store db level grants if the global grants + is enough to satisfy the request. ****************************************************************************/ bool -- cgit v1.2.1 From d098137155f184aaa25b9710d40854928276fcaf Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 Apr 2003 00:15:18 +0200 Subject: CURRENT_USER() and "access denied" error messages now report hostname exactly as it was specified in the GRANT command (with wildcards, that is) BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- sql/sql_parse.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7479ef653a9..33b6c3f45c0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -186,7 +186,7 @@ end: /* Check if user is ok Updates: - thd->user, thd->master_access, thd->priv_user, thd->db, thd->db_access + thd->{user,master_access,priv_user,priv_host,db,db_access} */ static bool check_user(THD *thd,enum_server_command command, const char *user, @@ -205,7 +205,8 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, return 1; } thd->master_access=acl_getroot(thd, thd->host, thd->ip, thd->user, - passwd, thd->scramble, &thd->priv_user, + passwd, thd->scramble, + &thd->priv_user, &thd->priv_host, protocol_version == 9 || !(thd->client_capabilities & CLIENT_LONG_PASSWORD),&ur); @@ -2566,7 +2567,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, if (!no_errors) net_printf(&thd->net,ER_ACCESS_DENIED_ERROR, thd->priv_user, - thd->host_or_ip, + thd->priv_host, thd->password ? ER(ER_YES) : ER(ER_NO));/* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */ } @@ -2591,7 +2592,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, if (!no_errors) net_printf(&thd->net,ER_DBACCESS_DENIED_ERROR, thd->priv_user, - thd->host_or_ip, + thd->priv_host, db ? db : thd->db ? thd->db : "unknown"); /* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */ } -- cgit v1.2.1 From 6db41f7793d81c08f042e0b1ff23e5d387b2976f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Apr 2003 10:15:09 +0300 Subject: Fix reference to not initialized memory Changed handing of priv_host to fix bug in FLUSH PRIVILEGES libmysqld/lib_sql.cc: Changed handing of priv_host to fix bug in FLUSH PRIVILEGES myisam/mi_rkey.c: Fix reference to not initialized memory sql/sql_acl.cc: Changed handing of priv_host to fix bug in FLUSH PRIVILEGES sql/sql_acl.h: Changed handing of priv_host to fix bug in FLUSH PRIVILEGES sql/sql_class.h: Changed handing of priv_host to fix bug in FLUSH PRIVILEGES sql/sql_parse.cc: Changed handing of priv_host to fix bug in FLUSH PRIVILEGES sql/unireg.h: Changed handing of priv_host to fix bug in FLUSH PRIVILEGES --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 33b6c3f45c0..8d4ae065aa6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -206,7 +206,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, } thd->master_access=acl_getroot(thd, thd->host, thd->ip, thd->user, passwd, thd->scramble, - &thd->priv_user, &thd->priv_host, + &thd->priv_user, thd->priv_host, protocol_version == 9 || !(thd->client_capabilities & CLIENT_LONG_PASSWORD),&ur); -- cgit v1.2.1 From 4d91444b15a9d156875b4ba7df2efc301e10845b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 May 2003 23:15:46 +0300 Subject: Updated comment --- sql/sql_parse.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 60942e47337..2b1c05bfaeb 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2533,7 +2533,8 @@ error: save_priv In this we store global and db level grants for the table Note that we don't store db level grants if the global grants - is enough to satisfy the request. + is enough to satisfy the request and the global grants contains + a SELECT grant. ****************************************************************************/ bool -- cgit v1.2.1 From a57e7732897ee7973d82dccea0425c436845066a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 May 2003 23:59:24 +0300 Subject: Security patch to remove wrong error when one had a global update/delete privilige and a database specific SELECT privilege. sql/sql_acl.cc: Security patch sql/sql_base.cc: Security patch sql/sql_parse.cc: Security patch tests/grant.pl: Test of security patch tests/grant.res: Test of security patch --- sql/sql_parse.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 152d9c585ca..805063cb6dc 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2155,7 +2155,17 @@ check_access(THD *thd,uint want_access,const char *db, uint *save_priv, if ((thd->master_access & want_access) == want_access) { - *save_priv=thd->master_access | thd->db_access; + /* + If we don't have a global SELECT privilege, we have to get the database + specific access rights to be able to handle queries of type + UPDATE t1 SET a=1 WHERE b > 0 + */ + db_access= thd->db_access; + if (!(thd->master_access & SELECT_ACL) && + (db && (!thd->db || strcmp(db,thd->db)))) + db_access=acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr, + thd->priv_user, db); /* purecov: inspected */ + *save_priv=thd->master_access | db_access; return FALSE; } if ((want_access & ~thd->master_access) & ~(DB_ACLS | EXTRA_ACL) || -- cgit v1.2.1 From dc1e55f8194db83e7a40dea5bf49e9fef970826c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 May 2003 18:58:26 +0300 Subject: Fix for UNION and LEFT JOIN (Bug #386) Fixed wrong logging of Access denied error (Bug #398) include/my_global.h: Fix for QNX mysql-test/r/union.result: new test case mysql-test/t/union.test: Test of bug in union and left join mysys/my_seek.c: Safety fix to find out when pos gets a wrong value sql/field.h: Fix for UNION and LEFT JOIN sql/mysql_priv.h: Fix for UNION and LEFT JOIN sql/sql_base.cc: Fix for UNION and LEFT JOIN sql/sql_insert.cc: Fix for UNION and LEFT JOIN sql/sql_parse.cc: Fixed wrong logging of Access denied error sql/sql_union.cc: Fix for UNION and LEFT JOIN sql/sql_update.cc: Fix for UNION and LEFT JOIN --- sql/sql_parse.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 73983bc03b1..7496d05be50 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -196,9 +196,17 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, thd->db=0; thd->db_length=0; USER_RESOURCES ur; + char tmp_passwd[SCRAMBLE_LENGTH]; if (passwd[0] && strlen(passwd) != SCRAMBLE_LENGTH) return 1; + /* + Move password to temporary buffer as it may be stored in communication + buffer + */ + strmov(tmp_passwd, passwd); + passwd= tmp_passwd; // Use local copy + if (!(thd->user = my_strdup(user, MYF(0)))) { send_error(net,ER_OUT_OF_RESOURCES); @@ -264,6 +272,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, } else send_ok(net); // Ready to handle questions + thd->password= test(passwd[0]); // Remember for error messages return 0; // ok } @@ -617,7 +626,6 @@ check_connections(THD *thd) net->read_timeout=(uint) thd->variables.net_read_timeout; if (check_user(thd,COM_CONNECT, user, passwd, db, 1)) return (-1); - thd->password=test(passwd[0]); return 0; } @@ -1007,7 +1015,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, decrease_user_connections(save_uc); x_free((gptr) save_db); x_free((gptr) save_user); - thd->password=test(passwd[0]); break; } -- cgit v1.2.1 From d079990894e41dc3220156729f95557233dd88d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 May 2003 23:03:00 +0200 Subject: Fix for bug 343 : we require only REPLICATION CLIENT for SHOW SLAVE STATUS and SHOW MASTER STATUS, because this is what the manual states. We still accept SUPER. --- sql/sql_parse.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 73983bc03b1..fc30bb45ea6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1475,7 +1475,9 @@ mysql_execute_command(void) } case SQLCOM_SHOW_SLAVE_STAT: { - if (check_global_access(thd, SUPER_ACL)) + /* Accept two privileges */ + if (check_global_access(thd, SUPER_ACL) && + check_global_access(thd, REPL_CLIENT_ACL)) goto error; LOCK_ACTIVE_MI; res = show_master_info(thd,active_mi); @@ -1484,7 +1486,9 @@ mysql_execute_command(void) } case SQLCOM_SHOW_MASTER_STAT: { - if (check_global_access(thd, SUPER_ACL)) + /* Accept two privileges */ + if (check_global_access(thd, SUPER_ACL) && + check_global_access(thd, REPL_CLIENT_ACL)) goto error; res = show_binlog_info(thd); break; -- cgit v1.2.1 From 7297502a7bc6ab09d8e7c6cbd822bba4d58d4977 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 May 2003 01:55:23 +0300 Subject: Fix for checking global_access rights --- sql/sql_parse.cc | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 002af61fae6..ad2f7f9a8bd 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1482,9 +1482,8 @@ mysql_execute_command(void) } case SQLCOM_SHOW_SLAVE_STAT: { - /* Accept two privileges */ - if (check_global_access(thd, SUPER_ACL) && - check_global_access(thd, REPL_CLIENT_ACL)) + /* Accept one of two privileges */ + if (check_global_access(thd, SUPER_ACL | REPL_CLIENT_ACL)) goto error; LOCK_ACTIVE_MI; res = show_master_info(thd,active_mi); @@ -1493,9 +1492,8 @@ mysql_execute_command(void) } case SQLCOM_SHOW_MASTER_STAT: { - /* Accept two privileges */ - if (check_global_access(thd, SUPER_ACL) && - check_global_access(thd, REPL_CLIENT_ACL)) + /* Accept one of two privileges */ + if (check_global_access(thd, SUPER_ACL | REPL_CLIENT_ACL)) goto error; res = show_binlog_info(thd); break; @@ -2620,12 +2618,29 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, } -/* check for global access and give descriptive error message if it fails */ +/* + check for global access and give descriptive error message if it fails + + SYNOPSIS + check_global_access() + thd Thread handler + want_access Use should have any of these global rights + + WARNING + One gets access rigth if one has ANY of the rights in want_access + This is useful as one in most cases only need one global right, + but in some case we want to check if the user has SUPER or + REPL_CLIENT_ACL rights. + + RETURN + 0 ok + 1 Access denied. In this case an error is sent to the client +*/ bool check_global_access(THD *thd, ulong want_access) { char command[128]; - if ((thd->master_access & want_access) == want_access) + if ((thd->master_access & want_access)) return 0; get_privilege_desc(command, sizeof(command), want_access); net_printf(&thd->net,ER_SPECIFIC_ACCESS_DENIED_ERROR, -- cgit v1.2.1 From ac316cfdb33bd4974a90c240c7a14ecb6a29da34 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 May 2003 22:12:55 +0300 Subject: Fixed bug in CREATE ... DECIMAL(-1,1). Bug #432 mysql-test/mysql-test-run.sh: Ensure that tests are sorted mysql-test/r/type_decimal.result: Test for bug with decimal() mysql-test/t/type_decimal.test: Test for bug with decimal() sql/sql_parse.cc: Fixed bug in CREATE ... DECIMAL(-1,1) --- sql/sql_parse.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ad2f7f9a8bd..e69d260bf11 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2977,9 +2977,8 @@ bool add_field_to_list(char *field_name, enum_field_types type, new_field->change=change; new_field->interval=0; new_field->pack_length=0; - if (length) - if (!(new_field->length= (uint) atoi(length))) - length=0; /* purecov: inspected */ + if (length && !(new_field->length= (uint) atoi(length))) + length=0; /* purecov: inspected */ uint sign_len=type_modifier & UNSIGNED_FLAG ? 0 : 1; if (new_field->length && new_field->decimals && @@ -3015,10 +3014,13 @@ bool add_field_to_list(char *field_name, enum_field_types type, break; case FIELD_TYPE_DECIMAL: if (!length) - new_field->length = 10; // Default length for DECIMAL - new_field->length+=sign_len; - if (new_field->decimals) - new_field->length++; + new_field->length= 10; // Default length for DECIMAL + if (new_field->length < MAX_FIELD_WIDTH) // Skip wrong argument + { + new_field->length+=sign_len; + if (new_field->decimals) + new_field->length++; + } break; case FIELD_TYPE_BLOB: case FIELD_TYPE_TINY_BLOB: -- cgit v1.2.1 From 18dd37b8a101dab654a896eabd9e73bc71aed8ca Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 May 2003 12:01:38 +0300 Subject: Added option --read-only (Thanks to Markus Benning) myisam/myisamchk.c: Removed warning from fulltext when repairing many tables with fulltext index sql/init.cc: Remove not used variables sql/mysql_priv.h: Remove not used variables sql/mysqld.cc: Removed not used variables Added option --read-only Change opt_do_pstack and master_ssl to get them to work with my_getopt sql/set_var.cc: Option --read-only sql/sql_parse.cc: Option --read-only --- sql/sql_parse.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e69d260bf11..d9060b4b26e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1329,6 +1329,18 @@ mysql_execute_command(void) (table_rules_on && tables && thd->slave_thread && !tables_ok(thd,tables))) DBUG_VOID_RETURN; + + /* + When option readonly is set deny operations which change tables. + Except for the replication thread and the 'super' users. + */ + if (opt_readonly && + !(thd->slave_thread || (thd->master_access & SUPER_ACL)) && + (uc_update_queries[lex->sql_command] > 0)) + { + send_error(&thd->net,ER_CANT_UPDATE_WITH_READLOCK); + DBUG_VOID_RETURN; + } statistic_increment(com_stat[lex->sql_command],&LOCK_status); switch (lex->sql_command) { -- cgit v1.2.1