Commit graph

2161 commits

Author SHA1 Message Date
Gleb Shchepa
e642140b18 Bug# 30946: mysqldump silently ignores --default-character-set
when used with --tab

1) New syntax: added CHARACTER SET clause to the
  SELECT ... INTO OUTFILE (to complement the same clause in
  LOAD DATA INFILE).
  mysqldump is updated to use this in --tab mode.

2) ESCAPED BY/ENCLOSED BY field parameters are documented as
   accepting CHAR argument, however SELECT .. INTO OUTFILE
   silently ignored rests of multisymbol arguments.
   For the symmetrical behavior with LOAD DATA INFILE the
   server has been modified to fail with the same error:

     ERROR 42000: Field separator argument is not what is
                  expected; check the manual

3) Current LOAD DATA INFILE recognizes field/line separators
   "as is" without converting from client charset to data
   file charset. So, it is supposed, that input file of
   LOAD DATA INFILE consists of data in one charset and
   separators in other charset. For the compatibility with
   that [buggy] behaviour SELECT INTO OUTFILE implementation
   has been saved "as is" too, but the new warning message
   has been added:

     Non-ASCII separator arguments are not fully supported

   This message warns on field/line separators that contain
   non-ASCII symbols.
2009-07-31 22:14:52 +05:00
Mikael Ronstrom
c0890b5d20 Bug#46354, when defining partitions without subpartition definition after defining it with the first partition and using list partition caused crash, fixed by more error checks in parser 2009-07-29 17:56:32 +02:00
Guilhem Bichot
b1073fb7a7 Bug#45829 "CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing":
those keywords do nothing in 5.1 (they are meant for future versions, for example featuring the Maria engine)
so they are here removed from the syntax. Adding those keywords to future versions when needed is:
- WL#5034 "Add TRANSACTIONA=0|1 and PAGE_CHECKSUM=0|1 clauses to CREATE TABLE"
- WL#5037 "New ROW_FORMAT value for CREATE TABLE: PAGE"
2009-07-29 10:54:20 +02:00
Georgi Kodinov
683b866575 automerge 2009-07-16 10:31:00 +03:00
Georgi Kodinov
8acf778eae Bug #45287: phase 1 : 32 bit compilation warnings
Fixed the following problems:
1. cmake 2.6 warning because of a changed default on
how the dependencies to libraries with a specified 
path are resolved.
Fixed by requiring cmake 2.6.
2. Removed an obsolete pre-NT4 hack including defining
Windows system defines to alter the behavior of windows.h.
3. Disabled warning C4065 on compiling sql_yacc.cc because
of a know incompatibility in some of the newer bison binaries.
2009-07-15 16:46:25 +03:00
Gleb Shchepa
8724706aa8 Bug #41156: List of derived tables acts like a chain of
mutually-nested subqueries

Queries of the form

  SELECT * FROM (SELECT 1) AS t1,
                (SELECT 2) AS t2,...
                (SELECT 32) AS t32

caused the "Too high level of nesting for select" error
as if the query has a form

  SELECT * FROM (SELECT 1 FROM (SELECT 2 FROM (SELECT 3 FROM...


The table_factor parser rule has been modified to adjust
the LEX::nest_level variable value after every derived table.
2009-07-11 23:44:29 +05:00
Staale Smedseng
c429fac63c Merge from 5.0-bugteam 2009-06-17 16:56:44 +02:00
Staale Smedseng
30fccdaaae Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
      
Compiling MySQL with gcc 4.3.2 and later produces a number of 
warnings, many of which are new with the recent compiler
versions.
                  
This bug will be resolved in more than one patch to limit the
size of changesets. This is the second patch, fixing more
of the warnings.
2009-06-17 15:54:01 +02:00
Staale Smedseng
e6e1f4ac84 Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2

Compiling MySQL with gcc 4.3.2 and later produces a number of 
warnings, many of which are new with the recent compiler
versions.
            
This bug will be resolved in more than one patch to limit the
size of changesets. This is the second patch, fixing more
of the warnings.
2009-06-10 16:04:07 +02:00
Alexey Kopytov
bdcce95f13 Manual merge. 2009-06-01 16:00:38 +04:00
Alexey Kopytov
2df531fdc4 Bug #44767: invalid memory reads in password() and
old_password() functions   
The PASSWORD() and OLD_PASSWORD() functions could lead to   
memory reads outside of an internal buffer when used with BLOB   
arguments.   
  
String::c_ptr() assumes there is at least one extra byte  
in the internally allocated buffer when adding the trailing  
'\0'.  This, however, may not be the case when a String object  
was initialized with externally allocated buffer.  
  
The bug was fixed by adding an additional "length" argument to  
make_scrambled_password_323() and make_scrambled_password() in  
order to avoid String::c_ptr() calls for  
PASSWORD()/OLD_PASSWORD().  
  
However, since the make_scrambled_password[_323] functions are  
a part of the client library ABI, the functions with the new  
interfaces were implemented with the 'my_' prefix in their  
names, with the old functions changed to be wrappers around  
the new ones to maintain interface compatibility.
2009-05-27 14:20:57 +04:00
Chad MILLER
128afdc3e5 Merge community up to enterprise, thus ending the community-server
adventure.
2009-05-06 09:06:32 -04:00
Alexey Botchkov
08690ef254 merging 2009-04-29 07:59:10 +05:00
Alexey Botchkov
8dafd2b95d merging 2009-04-28 14:48:54 +05:00
Chad MILLER
978e8e06b0 Merge 5.0.80 release and 5.0 community. Version left at 5.0.80. 2009-04-14 13:20:13 -04:00
Davi Arnaut
ec762cbd82 Merge Bug#43230 into mysql-5.1-bugteam 2009-04-03 16:46:00 -03:00
Davi Arnaut
aebaf079d1 Bug#43230: SELECT ... FOR UPDATE can hang with FLUSH TABLES WITH READ LOCK indefinitely
The problem is that a SELECT .. FOR UPDATE statement might open
a table and later wait for a impeding global read lock without
noticing whether it is holding a table that is being waited upon
the the flush phase of the process that took the global read
lock.

The same problem also affected the following statements:

LOCK TABLES .. WRITE
UPDATE .. SET (update and multi-table update)
TRUNCATE TABLE ..
LOAD DATA ..

The solution is to make the above statements wait for a impending
global read lock before opening the tables. If there is no
impending global read lock, the statement raises a temporary
protection against global read locks and progresses smoothly
towards completion.

Important notice: the patch does not try to address all possible
cases, only those which are common and can be fixed unintrusively
enough for 5.0.
2009-04-03 16:11:54 -03:00
Kristofer Pettersson
1634777203 Bug#39843 DELETE requires write access to table in subquery in where clause
An unnecessarily restrictive lock were taken on sub-SELECTs during DELETE.

During parsing, a global structure is reused for sub-SELECTs and the attribute
keeping track of lock options were not reset properly.
This patch introduces a new attribute to keep track on the syntactical lock
option elements found in a sub-SELECT and then sets the lock options accordingly.

Now the sub-SELECTs will try to acquire a READ lock if possible
instead of a WRITE lock as inherited from the outer DELETE statement.
2009-03-05 15:22:33 +01:00
Davi Arnaut
d5f92fec29 Bug#41077: Warning contains wrong future version
Substitute all references of MySQL version "5.2" to "6.0" in
deprecation warning messages.Deprecated constructs are being
removed in the 6.0 tree.
2009-02-16 08:38:15 -03:00
Georgi Kodinov
e23292155a merged additional fix for bug 33813 to 5.1-bugteam 2009-02-12 17:30:38 +02:00
Georgi Kodinov
074dade352 Bug #33813: Schema names are case-sensitive in DROP FUNCTION
Additional fix:
 1. Revert the unification of DROP FUNCTION
and DROP PROCEDURE, because DROP FUNCTION can be used to
drop UDFs (that have a non-qualified name and don't require
database name to be present and valid).
 2. Fixed the case sensitivity problem by adding a call to 
check_db_name() (similar to the sp_name production).
2009-02-12 16:36:43 +02:00
Georgi Kodinov
f9f8fee93c merged bug 33813 to 5.1-bugteam 2009-02-12 11:52:01 +02:00
Georgi Kodinov
b57c541425 Bug #33813: Schema names are case-sensitive in DROP FUNCTION
The parser was not using the correct fully-qualified-name
production for DROP FUNCTION.
Fixed by copying the production from DROP PROCEDURE.
Tested in the windows specific suite to make sure it's 
tested on a case-insensitive file system.
2009-02-10 11:58:19 +02:00
Chad MILLER
1c73da70ce Merged from 5.0 (enterprise). 2008-12-17 15:01:34 -05:00
timothy.smith@sun.com
abd8574914 Merge from mysql-5.1.30-release 2008-11-27 00:02:10 +01:00
Alexey Botchkov
52989c445f Bug#25058 ignored return codes in memory allocation functions
memory allocation error checks added for functions
   calling insert_dynamic()

per-file messages:
  myisam/mi_delete.c
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  myisam/mi_write.c
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  server-tools/instance-manager/instance_options.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/slave.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sp_head.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sp_head.h
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sp_pcontext.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sp_pcontext.h
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sql_select.cc
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
  sql/sql_yacc.yy
Bug#25058 ignored return codes in memory allocation functions
    out-of-memory errors handled
2008-11-21 17:38:42 +04:00
Build Team
366adeab08 Added "Sun Microsystems, Inc." to copyright headers on files modified
since Oct 1st
2008-11-10 21:21:49 +01:00
Mattias Jonsson
f113311d4b Bug#39434: ALTER TABLE CHECK/OPTIMIZE/ANALYZE PARTITION work
on non-partitioned table

Problem was that partitioning specific commands was accepted
for non partitioned tables and treated like
ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE, after bug-20129 was fixed,
which changed the code path from mysql_alter_table to
mysql_admin_table.

Solution was to check if the table was partitioned before
trying to execute the admin command
2008-10-10 20:12:38 +02:00
Sergey Glukhov
524eb067e0 5.0->5.1 bugteam merge 2008-10-02 17:53:08 +05:00
Sergey Glukhov
aa9f6a62a7 Bug#35924 DEFINER should be stored 'quoted' in I_S
The '@' symbol can not be used in the host name according to rfc952.
The fix:
added function check_host_name(LEX_STRING *str)
which checks that all symbols in host name string are valid and
host name length is not more than max host name length
(just moved check_string_length() function from the parser into check_host_name()).
2008-10-02 16:57:52 +05:00
Davi Arnaut
35ffaf10e3 Bug#34306: Can't make copy of log tables when server binary log is enabled
The problem is that when statement-based replication was enabled,
statements such as INSERT INTO .. SELECT FROM .. and CREATE TABLE
.. SELECT FROM need to grab a read lock on the source table that
does not permit concurrent inserts, which would in turn be denied
if the source table is a log table because log tables can't be
locked exclusively.

The solution is to not take such a lock when the source table is
a log table as it is unsafe to replicate log tables under statement
based replication. Furthermore, the read lock that does not permits
concurrent inserts is now only taken if statement-based replication
is enabled and if the source table is not a log table.
2008-09-29 10:53:40 -03:00
Gleb Shchepa
db1d38c910 Bug#26020: User-Defined Variables are not consistent with
columns data types

The "SELECT @lastId, @lastId := Id FROM t" query returns
different result sets depending on the type of the Id column
(INT or BIGINT).

Note: this fix doesn't cover the case when a select query
references an user variable and stored function that
updates a value of that variable, in this case a result
is indeterminate.


The server uses incorrect assumption about a constantness of
an user variable value as a select list item: 

The server caches a last query number where that variable
was changed and compares this number with a current query
number. If these numbers are different, the server guesses,
that the variable is not updating in the current query, so
a respective select list item is a constant. However, in some
common cases the server updates cached query number too late.


The server has been modified to memorize user variable
assignments during the parse phase to take them into account
on the next (query preparation) phase independently of the
order of user variable references/assignments in a select
item list.
2008-09-18 13:38:44 +05:00
Tatiana A. Nurnberg
5de76e39e7 Bug#35981: ALTER EVENT causes the server to change the PRESERVE option.
If [NOT] PRESERVE was not given, parser always defaulted to NOT
PRESERVE, making it impossible for the "not given = no change"
rule to work in ALTER EVENT. Leaving out the PRESERVE-clause
defaults to NOT PRESERVE on CREATE now, and to "no change" in
ALTER.
2008-09-11 09:51:02 +02:00
Evgeny Potemkin
aa74a314e4 Bug#37908: Skipped access right check caused server crash.
The check_table_access function initializes per-table grant info and performs
access rights check. It wasn't called for SHOW STATUS statement thus left
grants info uninitialized. In some cases this led to server crash. In other
cases it allowed a user to check for presence/absence of arbitrary values in
any tables.
      
Now the check_table_access function is called prior to the statement
processing.
2008-09-05 14:44:16 +04:00
Tatiana A. Nurnberg
4b317a5688 Bug#35981: ALTER EVENT causes the server to change the PRESERVE option.
If [NOT] PRESERVE was not given, parser always defaulted to NOT
PRESERVE, making it impossible for the "not given = no change"
rule to work in ALTER EVENT. Leaving out the PRESERVE-clause
defaults to NOT PRESERVE on CREATE now, and to "no change" in
ALTER.
2008-08-18 13:05:51 +02:00
Mattias Jonsson
45c8998bdd merge (into the latest mysql-5.1-bugteam tree) 2008-08-13 08:59:05 +02:00
Marc Alff
9b619d2d49 Bug#38296 (low memory crash with many conditions in a query)
This fix is for 5.1 only : back porting the 6.0 patch manually

The parser code in sql/sql_yacc.yy needs to be more robust to out of
memory conditions, so that when parsing a query fails due to OOM,
the thread gracefully returns an error.

Before this fix, a new/alloc returning NULL could:
- cause a crash, if dereferencing the NULL pointer,
- produce a corrupted parsed tree, containing NULL nodes,
- alter the semantic of a query, by silently dropping token values or nodes

With this fix:
- C++ constructors are *not* executed with a NULL "this" pointer
when operator new fails.
This is achieved by declaring "operator new" with a "throw ()" clause,
so that a failed new gracefully returns NULL on OOM conditions.

- calls to new/alloc are tested for a NULL result,

- The thread diagnostic area is set to an error status when OOM occurs.
This ensures that a request failing in the server properly returns an
ER_OUT_OF_RESOURCES error to the client.

- OOM conditions cause the parser to stop immediately (MYSQL_YYABORT).
This prevents causing further crashes when using a partially built parsed
tree in further rules in the parser.

No test scripts are provided, since automating OOM failures is not
instrumented in the server.
Tested under the debugger, to verify that an error in alloc_root cause the
thread to returns gracefully all the way to the client application, with
an ER_OUT_OF_RESOURCES error.
2008-08-12 17:05:19 -06:00
Mattias Jonsson
07e9a6dc2a Bug#20129: ALTER TABLE ... REPAIR PARTITION ... complains that
partition is corrupt

The main problem was that ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR
PARTITION took another code path (over mysql_alter_table instead of
mysql_admin_table) which differs in two ways:
1) alter table opens the tables in a different way than admin tables do
   resulting in returning with error before it tried the command
2) alter table does not start to send any diagnostic rows to the client
   which the lower admin functions continue to use -> resulting in
   assertion crash

The fix:
Remapped ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION to use
the same code path as ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE t.
Adding check in mysql_admin_table to setup the partition list for
which partitions that should be used.


Partitioned tables will still not work with
REPAIR TABLE/PARTITION USE_FRM, since that requires moving partitions
to tables, REPAIR TABLE t USE_FRM, and check that the data still
fulfills the partitioning function and then move the table back to
being a partition.

NOTE: I have removed the following functions from the handler
interface:
analyze_partitions, check_partitions, optimize_partitions,
repair_partitions
Since they are not longer needed.
THIS ALTERS THE STORAGE ENGINE API
2008-08-11 20:02:03 +02:00
Marc Alff
394691cd90 Bug#38296 (low memory crash with many conditions in a query)
This fix is for 5.0 only : back porting the 6.0 patch manually

The parser code in sql/sql_yacc.yy needs to be more robust to out of
memory conditions, so that when parsing a query fails due to OOM,
the thread gracefully returns an error.

Before this fix, a new/alloc returning NULL could:
- cause a crash, if dereferencing the NULL pointer,
- produce a corrupted parsed tree, containing NULL nodes,
- alter the semantic of a query, by silently dropping token values or nodes

With this fix:
- C++ constructors are *not* executed with a NULL "this" pointer
when operator new fails.
This is achieved by declaring "operator new" with a "throw ()" clause,
so that a failed new gracefully returns NULL on OOM conditions.

- calls to new/alloc are tested for a NULL result,

- The thread diagnostic area is set to an error status when OOM occurs.
This ensures that a request failing in the server properly returns an
ER_OUT_OF_RESOURCES error to the client.

- OOM conditions cause the parser to stop immediately (MYSQL_YYABORT).
This prevents causing further crashes when using a partially built parsed
tree in further rules in the parser.

No test scripts are provided, since automating OOM failures is not
instrumented in the server.
Tested under the debugger, to verify that an error in alloc_root cause the
thread to returns gracefully all the way to the client application, with
an ER_OUT_OF_RESOURCES error.
2008-08-11 10:10:00 -06:00
Jonathan Perkin
956f8cfeb7 Merge from mysql-5.0.66-release 2008-07-17 17:35:05 +02:00
Marc Alff
566e3389c2 Bug#35577, manual merge mysql-5.0-bugteam -> mysql-5.1-bugteam 2008-07-14 19:43:12 -06:00
Marc Alff
0816ee6d34 Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on
build)

The crash was caused by freeing the internal parser stack during the parser
execution.
This occured only for complex stored procedures, after reallocating the parser
stack using my_yyoverflow(), with the following C call stack:
- MYSQLparse()
- any rule calling sp_head::restore_lex()
- lex_end()
- x_free(lex->yacc_yyss), xfree(lex->yacc_yyvs)

The root cause is the implementation of stored procedures, which breaks the
assumption from 4.1 that there is only one LEX structure per parser call.

The solution is to separate the LEX structure into:
- attributes that represent a statement (the current LEX structure),
- attributes that relate to the syntax parser itself (Yacc_state),
so that parsing multiple statements in stored programs can create multiple
LEX structures while not changing the unique Yacc_state.

Now, Yacc_state and the existing Lex_input_stream are aggregated into
Parser_state, a structure that represent the complete state of the (Lexical +
Syntax) parser.
2008-07-14 15:41:30 -06:00
Chad MILLER
dae4c823e9 Merge from 5.0 trunk. 2008-07-14 16:16:37 -04:00
Chad MILLER
c94a46240a Merge chunk from trunk. 2008-07-10 14:50:07 -04:00
Chad MILLER
06756c19c5 Merge chunk from trunk. 2008-07-10 14:47:53 -04:00
Marc Alff
8454773a97 Manual merge of bug#26030 in mysql-5.1-bugteam 2008-07-07 15:53:20 -06:00
Marc Alff
f3ff1aeb9c Bug#26030 (Parsing fails for stored routine w/multi-statement execution
enabled)

Before this fix, the lexer and parser would treat the ';' character as a
different token (either ';' or END_OF_INPUT), based on convoluted logic,
which failed in simple cases where a stored procedure is implemented as a
single statement, and used in a multi query.

With this fix:
- the character ';' is always parsed as a ';' token in the lexer,
- parsing multi queries is implemented in the parser, in the 'query:' rules,
- the value of thd->client_capabilities, which is the capabilities
  negotiated between the client and the server during bootstrap,
  is immutable and not arbitrarily modified during parsing (which was the
  root cause of the bug)
2008-07-07 10:00:08 -06:00
kostja@bodhi.(none)
2c0ce2a832 Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  bodhi.(none):/opt/local/work/mysql-5.1-27430
2008-05-20 11:38:17 +04:00
gkodinov/kgeorge@magare.gmz
f6951f3e9f Bug #32858: Erro: "Incorrect usage of UNION and INTO" does not take
subselects into account
  
It is forbidden to use the SELECT INTO construction inside UNION statements
unless on the last SELECT of the union. The parser records whether it 
has seen INTO or not when parsing a UNION statement. But if the INTO was
legally used in an outer query, an error is thrown if UNION is seen in a
subquery. Fixed in 5.0 by remembering the nesting level of INTO tokens and 
mitigate the error unless it collides with the UNION.
2008-05-13 18:10:46 +03:00
thek@adventure.(none)
19a22f87e9 Bug#35997 Event scheduler seems to let the server crash, if it is embedded.
The event scheduler was not designed to work in embedded mode. This
patch disables and excludes the event scheduler when the server is
compiled for embedded build.
2008-05-09 09:43:02 +02:00