Commit graph

1571 commits

Author SHA1 Message Date
Sergei Golubchik
383007c75d mysql cli: fix USE command quoting
* use proper sql quoting rules for USE, while preserving
  as much of historical behavior as possible
* short commands (\u) behave as before
2016-10-13 21:38:32 +02:00
Sergey Vojtovich
0ea4c73dae Fixed compilation failure due to unused var. 2016-04-23 12:15:18 +04:00
Sergei Golubchik
b069d19284 Merge branch 'mysql/5.5' into 5.5 2016-04-20 15:25:55 +02:00
Sergei Golubchik
ce355304e6 MDEV-9885 Client doesn't start if 'TERM' unknown
1. don't exit if setupterm() failed
2. don't use vidattr() if setupterm() failed
2016-04-19 11:27:00 +02:00
Ramil Kalimullin
b3e9211e48 WL#9072: Backport WL#8785 to 5.5 2016-02-19 23:31:10 +04:00
Sergei Golubchik
c4cb240061 MDEV-9024 Build fails with VS2015
cherry-pick f1daf9ce from 10.0 branch
-------------------------------------

Fix build failures caused by new C runtime library
- isnan, snprintf, struct timespec are now defined, attempt to
redefine them leads
- P_tmpdir, tzname are no more defined
-  lfind() and lsearch() in lf_hash.c had to be renamed,  declaration
conflicts with some C runtime functions with the same name declared in
a header included by stdlib.h

 Also fix couple of annoying warnings :
- remove #define NOMINMAX from config.h to avoid "redefined" compiler
warnings(NOMINMAX is already in compile flags)

- disable incremental linker in Debug as well (feature not used much
and compiler crashes often)

Also simplify package building with Wix, require Wix 3.9 or later
(VS2015 is not compatible with old Wix 3.5/3.6)
2016-02-06 22:41:58 +01:00
Sergei Golubchik
1ddfce4840 mysql-5.5.40 2014-10-06 19:53:55 +02:00
Sergei Golubchik
ae3cc4f1b7 MDEV-6561 libedit detection is broken
fix readline/libedit detection:
* search in readline/, editline/ and edit/readline/
* fix typos CMAKE_REQUIRES_LIBRARIES -> CMAKE_REQUIRED_LIBRARIES
* use correct libedit API
* use different cmake variables for libedit and readline
2014-09-09 19:03:05 +02:00
Venkata Sidagam
a0537faa8b Bug #17297324 GLIBC DOUBLE FREE OR CORRUPTION WHEN KILLING CLIENT; CTRL+C
Description: Sometimes when killing the mysql command line client with
KILL -2(SIGINT), mysql client core dumps as a result of a double free or
corruption.

Analysis: When we run the mysql client in command line mode it will goes
to mysql_end() and frees many data structures. At the same time (i.e
after some data structures are freed), if we give "KILL -2" signal then
the signal will be handled with function handle_kill_signal() and as
part of it will again calls mysql_end() and goes with free() to the
already freed data structure for batch_readline_end() function, which
causes core dump.

Fix: Ignoring SIGQUIT and SIGINT signals when cleanup process starts.
This will help in resolving the double free issues, which occurs 
in case the signal handler function is started in between of the 
clean up function.
For 5.6 we need to ignore SIGHUP also.
2014-07-21 11:26:50 +05:30
Venkata Sidagam
c20c135a23 Bug #17297324 GLIBC DOUBLE FREE OR CORRUPTION WHEN KILLING CLIENT; CTRL+C
Description: Sometimes when killing the mysql command line client with
KILL -2(SIGINT), mysql client core dumps as a result of a double free or
corruption.

Analysis: When we run the mysql client in command line mode it will goes
to mysql_end() and frees many data structures. At the same time (i.e
after some data structures are freed), if we give "KILL -2" signal then
the signal will be handled with function handle_kill_signal() and as
part of it will again calls mysql_end() and goes with free() to the
already freed data structure for batch_readline_end() function, which
causes core dump.

Fix: Ignoring SIGQUIT and SIGINT signals when cleanup process starts.
This will help in resolving the double free issues, which occurs 
in case the signal handler function is started in between of the 
clean up function.
For 5.6 we need to ignore SIGHUP also.
2014-07-21 11:26:50 +05:30
Sergei Golubchik
cb67dcb618 mysql-5.5.37 selective merge 2014-03-27 22:26:58 +01:00
Vamsikrishna Bhagi
6923c1d9a5 Bug #18186103 BUFFER OVERFLOW IN CLIENT
Problem: While printing the Server version, mysql client
         doesn't check for the buffer overflow in a
         String variable.

Solution: Used a different print function which checks the
          allocated length before writing into the string.
2014-02-12 15:17:37 +05:30
Vamsikrishna Bhagi
c187840b6b Bug #18186103 BUFFER OVERFLOW IN CLIENT
Problem: While printing the Server version, mysql client
         doesn't check for the buffer overflow in a
         String variable.

Solution: Used a different print function which checks the
          allocated length before writing into the string.
2014-02-12 15:17:37 +05:30
Sergei Golubchik
6b6d40fa6c 5.3 merge 2014-01-28 10:58:18 +01:00
Sergei Golubchik
52340eee1a 5.2 merge 2014-01-28 10:27:52 +01:00
Sergei Golubchik
19b24f8f53 5.1 merge 2014-01-28 10:23:11 +01:00
Sergei Golubchik
16e0cae0cc fixed a client-side overflow in mysql cli 2014-01-28 10:21:47 +01:00
Sergei Golubchik
8ece9de833 workaround test failures in buildbot:
in some VMs readline thinks that the window size is zero. ignore it.
2014-01-26 21:49:31 +01:00
Michael Widenius
04bee0af2e Fix for MDEV-5547: Bad error message when moving very old .frm files to MariaDB 5.5.
mysql_upgrade --help now also prints out --default options and variable values.
mysql_upgrade now prints permission errors.
mysql_upgrade doesn't print some non essential info if --silent is used.
Added handler error message about incompatible versions
Fixed that mysqlbug and mysql_install_db have the executable flag set.
Removed executable flag for some non executable files.
Changed in mysql_install_db askmonty.org to mariadb.com.
Ensured that all client executables prints --default options the same way.
Allow REPAIR ... USE_FRM for old .frm files if the are still compatible.
Extended shown error for storage engine messages.


client/mysql.cc:
  print_defaults() should be first (as in all other programs)
client/mysql_upgrade.c:
  --help now also prints out --default options and variable values
  Print out error if wrong permissions
  Don't print info if --silent
client/mysqladmin.cc:
  print_defaults() should be first (as in all other programs)
client/mysqlbinlog.cc:
  Added print_defaults() to --help
client/mysqlcheck.c:
  Added empty line in --help
client/mysqlimport.c:
  Added empty line in --help
client/mysqlshow.c:
  Made --help compatible
client/mysqlslap.c:
  Made --help compatible
client/mysqltest.cc:
  Added print_defaults() to --help
include/handler_ername.h:
  Added handler error message
include/my_base.h:
  Added handler error message
mysql-test/r/mysql_upgrade.result:
  Updated results
mysql-test/r/repair.result:
  Added test case for better error messages
mysql-test/std_data/host_old.MYD:
  Added test case for better error messages
mysql-test/std_data/host_old.MYI:
  Added test case for better error messages
mysql-test/std_data/host_old.frm:
  Added test case for better error messages
mysql-test/t/repair.test:
  Added test case for better error messages
mysys/my_handler_errors.h:
  Added handler error message
scripts/CMakeLists.txt:
  Fixed that mysqlbug and mysql_install_db have the executable flag set
scripts/mysql_install_db.sh:
  askmonty.org -> mariadb.com
sql/ha_partition.cc:
  Sometimes table_type() can be called for errors even if partition didn't manage to open any files
sql/handler.cc:
  Write clear text for not handled, but defined error messages.
sql/share/errmsg-utf8.txt:
  Extended shown error for storage engine messages
sql/sql_admin.cc:
  Allow REPAIR ... USE_FRM for old .frm files if the are still compatible
storage/myisam/ha_myisam.cc:
  Use new error message
2014-01-22 15:16:57 +02:00
Sergei Golubchik
70f6ac10b3 MDEV-5323 Ctrl-C not working under Ubuntu
don't reset interrupted_query after sending the KILL signal, otherwise
the client won't know it has to stop fetching and printing the data.
2013-12-11 17:42:33 +01:00
Sergei Golubchik
b718dc449b mysql --skip-column-names flag should not affect alignment of field values,
set num_flag[] unconditionally, not under "if (column_names)"

http://ronaldbradford.com/blog/unexplained-trivial-mysql-behavior-2013-08-02/
2013-08-08 13:33:15 +02:00
Sergei Golubchik
005c7e5421 mysql-5.5.32 merge 2013-07-16 19:09:54 +02:00
Sergei Golubchik
2db4392bf4 MDEV-4297 mysql --binary-mode
backport mysql --binary-mode (bug#11747577, bug#33048)
2013-06-10 21:45:30 +02:00
Sergei Golubchik
07315d3603 strmake_buf(X,Y) helper, equivalent to strmake(X,Y,sizeof(X)-1)
with a bit of lame protection against abuse.
2013-04-17 19:42:34 +02:00
Nirbhay Choubey
6d6af5477e Merge of patch for bug#14685362 from mysql-5.1. 2013-03-18 12:46:06 +05:30
Nirbhay Choubey
fb401ad38e Merge of patch for bug#14685362 from mysql-5.1. 2013-03-18 12:46:06 +05:30
Nirbhay Choubey
a6adbd0533 Bug#14685362 : MEMORY LEAKS IN MYSQL CLIENT IN
INTERACTIVE MODE

In interactive mode, libedit/readline allocates memory
for every new line entered & later the allocated memory
never gets freed.

Fixed by freeing the allocated memory blocks appropriately.
2013-03-18 12:44:38 +05:30
Nirbhay Choubey
78eb581829 Bug#14685362 : MEMORY LEAKS IN MYSQL CLIENT IN
INTERACTIVE MODE

In interactive mode, libedit/readline allocates memory
for every new line entered & later the allocated memory
never gets freed.

Fixed by freeing the allocated memory blocks appropriately.
2013-03-18 12:44:38 +05:30
Sergei Golubchik
8161c6772d merge with mysql-5.5.30 minus few incorrect or not applicable changesets 2013-02-28 18:42:49 +01:00
Vladislav Vaintroub
e03e9aab73 MDEV-4181 : ensure mysql client's beep works on all Windows systems.
Use MessageBeep, which employs sound card, rather than system speaker.
The secondary benefit is that one can use volume control for this sound
(see MySQL's Bug #17088)
2013-02-20 14:52:43 +01:00
Nirbhay Choubey
fc311cc623 Bug#13639125 DELIMITER STRIPS THE NEXT NEW LINE
IN A SQL STATEMENT

While processing each lines entered at the prompt,
mysql client appends a '\n' to all the lines except
for delimiter commands. However the same logic must
not apply if 'delimiter' is part of a string or a
comment, for which a '\n' should be added.

Fixed by adding appropriate checks.

Added a test case.
2012-12-12 22:31:03 +05:30
Nirbhay Choubey
fc2ad0afc3 Bug#13639125 DELIMITER STRIPS THE NEXT NEW LINE
IN A SQL STATEMENT

While processing each lines entered at the prompt,
mysql client appends a '\n' to all the lines except
for delimiter commands. However the same logic must
not apply if 'delimiter' is part of a string or a
comment, for which a '\n' should be added.

Fixed by adding appropriate checks.

Added a test case.
2012-12-12 22:31:03 +05:30
unknown
3f59033536 Merge MariaDB 5.1.66 -> 5.2 -> 5.3 2012-11-09 10:11:20 +02:00
unknown
c5cef4b166 Merge MariaDB 5.1.66 -> 5.2.12 2012-11-08 15:24:35 +02:00
unknown
7c23d6d0c6 Merge MySQL 5.1.66 -> MariaDB 5.1.65 2012-11-06 11:52:55 +02:00
Sergei Golubchik
ee9afef271 mysql-5.5.28 2012-10-16 13:04:42 +02:00
Nirbhay Choubey
f820334bbf Bug#14645196 MYSQL CLIENT'S USE COMMAND FAILS
WHEN DBNAME CONTAINS MULTIPLE QUOTES

MySQL client's USE command might fail if the
database name contains multiple quotes (backticks).

The reason behind the failure being the method
that client uses to remove/escape the quotes
while parsing the USE command's option (dbname),
where the option parsing might terminate if a
matching quote is found.

Also, C-APIs like mysql_select_db() expect a
normalized dbname. Now, in certain cases, client
might fail to normalize dbname similar to that of
server and hence mysql_select_db() would fail.

Fixed by getting the normalized dbname (indirectly)
from the server by directly sending the "USE dbanme"
as query to the server followed by a "SELECT DATABASE()".
The above steps are only performed if number of quotes
in the dbname is greater than 2. Once the normalized
dbname is received, the original db is restored.
2012-09-21 23:28:55 +05:30
Nirbhay Choubey
600aa420d6 Bug#14645196 MYSQL CLIENT'S USE COMMAND FAILS
WHEN DBNAME CONTAINS MULTIPLE QUOTES

MySQL client's USE command might fail if the
database name contains multiple quotes (backticks).

The reason behind the failure being the method
that client uses to remove/escape the quotes
while parsing the USE command's option (dbname),
where the option parsing might terminate if a
matching quote is found.

Also, C-APIs like mysql_select_db() expect a
normalized dbname. Now, in certain cases, client
might fail to normalize dbname similar to that of
server and hence mysql_select_db() would fail.

Fixed by getting the normalized dbname (indirectly)
from the server by directly sending the "USE dbanme"
as query to the server followed by a "SELECT DATABASE()".
The above steps are only performed if number of quotes
in the dbname is greater than 2. Once the normalized
dbname is received, the original db is restored.
2012-09-21 23:28:55 +05:30
Nirbhay Choubey
02ee112f9a Merge of fix for Bug#14645196 from mysql-5.1 2012-09-21 23:31:32 +05:30
Nirbhay Choubey
967fd170f5 Merge of fix for Bug#14645196 from mysql-5.1 2012-09-21 23:31:32 +05:30
Michael Widenius
d618dfe32d Added function last_value() which returns the last value but evalutes all arguments as a side effect.
Original patch by Eric Herman

client/mysql.cc:
  Added LAST_VALUE
mysql-test/r/last_value.result:
  Testing of LAST_VALUE
mysql-test/t/last_value.test:
  Testing of LAST_VALUE
sql/item_func.cc:
  Added LAST_VALUE()
sql/item_func.h:
  Added LAST_VALUE()
sql/lex.h:
  Added LAST_VALUE()
sql/sql_yacc.yy:
  Added LAST_VALUE()
2012-09-05 18:23:51 +03:00
Nirbhay Choubey
ffdc4bc8cd Merge of patch for Bug#13928675 from mysql-5.1. 2012-08-07 19:07:13 +05:30
Nirbhay Choubey
fb697972b3 Merge of patch for Bug#13928675 from mysql-5.1. 2012-08-07 19:07:13 +05:30
Nirbhay Choubey
5ad8292c63 Bug#13928675 MYSQL CLIENT COPYRIGHT NOTICE MUST
SHOW 2012 INSTEAD OF 2011

* Added a new macro to hold the current year :
  COPYRIGHT_NOTICE_CURRENT_YEAR
* Modified ORACLE_WELCOME_COPYRIGHT_NOTICE macro
  to take the initial year as parameter and pick
  current year from the above mentioned macro.
2012-08-07 18:58:19 +05:30
Nirbhay Choubey
d4e4538b2d Bug#13928675 MYSQL CLIENT COPYRIGHT NOTICE MUST
SHOW 2012 INSTEAD OF 2011

* Added a new macro to hold the current year :
  COPYRIGHT_NOTICE_CURRENT_YEAR
* Modified ORACLE_WELCOME_COPYRIGHT_NOTICE macro
  to take the initial year as parameter and pick
  current year from the above mentioned macro.
2012-08-07 18:58:19 +05:30
Venkata Sidagam
daa380b9cd Bug #12615411 - server side help doesn't work as first statement
Merged from mysql-5.1 to mysql-5.5
2012-07-19 14:14:03 +05:30
Venkata Sidagam
e5eacf70a7 Bug #12615411 - server side help doesn't work as first statement
Merged from mysql-5.1 to mysql-5.5
2012-07-19 14:14:03 +05:30
Venkata Sidagam
913e3a8475 Bug #12615411 - server side help doesn't work as first statement
Problem description:
Giving "help 'contents'" in the mysql client as a first statement
gives error

Analysis:
In com_server_help() function the "server_cmd" variable was
initialised with buffer->ptr(). And the "server_cmd" variable is not
updated since we are passing "'contents'"(with single quote) so the
buffer->ptr() consists of the previous buffer values and it was sent
to the mysql_real_query() hence we are getting error.

Fix:
We are not initialising the "server_cmd" variable and we are updating
the variable with "server_cmd= cmd_buf" in any of the case i.e with
single quote or without single quote for the contents.
As part of error message improvement, added new error message in case
of "help 'contents'".

client/mysql.cc:
  com_server_help(): Properly updated the server_cmd variable and improved
  the error message.
2012-07-19 13:52:34 +05:30
Venkata Sidagam
6ee1c03043 Bug #12615411 - server side help doesn't work as first statement
Problem description:
Giving "help 'contents'" in the mysql client as a first statement
gives error

Analysis:
In com_server_help() function the "server_cmd" variable was
initialised with buffer->ptr(). And the "server_cmd" variable is not
updated since we are passing "'contents'"(with single quote) so the
buffer->ptr() consists of the previous buffer values and it was sent
to the mysql_real_query() hence we are getting error.

Fix:
We are not initialising the "server_cmd" variable and we are updating
the variable with "server_cmd= cmd_buf" in any of the case i.e with
single quote or without single quote for the contents.
As part of error message improvement, added new error message in case
of "help 'contents'".
2012-07-19 13:52:34 +05:30
Georgi Kodinov
06f6e4fe95 Bug #12998841: libmysql divulges plaintext password upon request in 5.5
1. Clear text password client plugin disabled by default.
2. Added an environment variable LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN, that
when set to something starting with '1', 'Y' or 'y' will enable the clear
text
plugin for all connections.
3. Added a new mysql_options() option : MYSQL_ENABLE_CLEARTEXT_PLUGIN
that takes an my_bool argument. When the value of the argument is non-zero
the clear text plugin is enabled for this connection only.
4. Added an enable-cleartext-plugin config file option that takes a numeric

argument. If the numeric value of the numeric argument is non-zero the
clear
text plugin is enabled for the connection
5. Added a boolean command line option "--enable_cleartext_plugin" to
mysql, mysqlslap and mysqladmin. When specified it will call mysql_options
with the effect of #3
6. Added a new CLEARTEXT option to the connect command in mysqltest.
When specified it will enable the cleartext plugin for usage.
7. Added test cases and updated existing ones that need the clear text
plugin.
2012-07-05 09:55:20 +03:00