Commit graph

1556 commits

Author SHA1 Message Date
unknown
21fd6c0f1d Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-rt-merge


sql/sql_yacc.yy:
  Auto merged
sql-common/client.c:
  Auto merged
2007-11-28 07:23:51 -07:00
unknown
a11256f49a Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-rt-merge


sql/mysqld.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-11-21 18:35:02 -07:00
unknown
1ae0237f24 Merge adventure.(none):/home/thek/Development/cpp/bug31153/my50-bug31153
into  adventure.(none):/home/thek/Development/cpp/mysql-5.0-runtime


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_yacc.yy:
  Manual merge.
2007-11-21 10:02:44 +01:00
unknown
18851d9ea7 Fix for bug #30495: optimize table t1,t2,t3 extended errors
Problem: we have CHECK TABLE options allowed (by accident?) for
ANALYZE/OPTIMIZE TABLE.

Fix: disable them.

Note: it might require additional fixes in 5.1/6.0


mysql-test/r/analyze.result:
  Fix for bug #30495: optimize table t1,t2,t3 extended errors
    - test result.
mysql-test/t/analyze.test:
  Fix for bug #30495: optimize table t1,t2,t3 extended errors
    - test case.
sql/sql_yacc.yy:
  Fix for bug #30495: optimize table t1,t2,t3 extended errors
    - opt_mi_check_type (CHECK TABLE options) removed from analyze: and optimize:
2007-11-21 11:11:22 +04:00
unknown
bb681dbc88 Bug #31153 calling stored procedure crashes server if available memory is low
When the server was out of memory it crashed because of invalid memory access.

This patch adds detection for failed memory allocations and make the server
output a proper error message.


sql/mysqld.cc:
  Don't try to push_warning from within push_warning. It will cause a recursion
  until the stack is consumed.
  
  If my_net_init fails (for example: because of OOM) the temporary vio object 
  might have been attached to the thd object already. This will cause a double
  free on the vio object when the thd object is deleted later on and the server
  will crash.
sql/sp_head.cc:
  Added check for out-of-memory on a 'new' operation.
  Refactored reset_lex method to return a error state code instead of void.
  Initialize the mem-root with init_sql_alloc to get a basic error handler for
  memory allocation problems. This alone won't prevent the server from crashing,
  NULL pointers have to be accounted for as well.
sql/sp_head.h:
  Use the throw() clause in operator new, to indicate to the compiler that
  memory allocation can fail and return NULL, so that the compiler should
  generate code to check for NULL before invoking C++ constructors, to be
  crash safe.
sql/sql_base.cc:
  Use init_sql_alloc to get basic out-of-memory error handling.
sql/sql_lex.h:
  Use the throw() clause in operator new, to indicate to the compiler that
  memory allocation can fail and return NULL, so that the compiler should
  generate code to check for NULL before invoking C++ constructors, to be
  crash safe.
sql/sql_prepare.cc:
  Use init_sql_alloc to get basic out-of-memory error handling.
sql/sql_yacc.yy:
  Check for memory allocation failures where it matters.
2007-11-19 17:59:44 +01:00
unknown
04ff9d4da0 Fixed bug #27695: View should not be allowed to have empty or
all space column names.

The parser has been modified to check VIEW column names
with the check_column_name function and to report an error
on empty and all space column names (same as for TABLE
column names).


sql/sql_yacc.yy:
  Fixed bug #27695.
  The parser has been modified to check VIEW column aliases
  with the check_column_name function and to report an error
  on empty columns and all space columns (same as for TABLE
  column names).
mysql-test/t/select.test:
  Updated test case for bug #27695.
mysql-test/r/select.result:
  Updated test case for bug #27695.
2007-10-25 10:32:52 +05:00
unknown
8479eb1db7 Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into  mysql.com:/home/gluh/MySQL/Merge/5.0-opt


client/mysqldump.c:
  Auto merged
include/config-win.h:
  Auto merged
libmysql/libmysql.c:
  Auto merged
myisam/sort.c:
  Auto merged
mysql-test/r/func_sapdb.result:
  Auto merged
mysql-test/r/variables.result:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_innodb.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/item_timefunc.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
tests/mysql_client_test.c:
  Auto merged
mysql-test/r/type_datetime.result:
  manual merge
mysql-test/r/type_decimal.result:
  manual merge
mysql-test/t/type_datetime.test:
  manual merge
mysql-test/t/type_decimal.test:
  manual merge
sql/item.cc:
  manual merge
2007-10-23 18:51:43 +05:00
unknown
933bf86954 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B30825-new-5.0-opt


sql/field.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-10-23 11:26:37 +03:00
unknown
42b6424327 Fixed broken call to my_error
sql/sql_yacc.yy:
  Fixed error message to use char*, not LEX_STRING
2007-10-16 14:27:20 -06:00
unknown
f1d7a96b0a Bug#28318 (CREATE FUNCTION (UDF) requires a schema) -- part II
The root cause of the issue was that the CREATE FUNCTION grammar,
for User Defined Functions, was using the sp_name rule.
The sp_name rule is intended for fully qualified stored procedure names,
like either ident.ident, or just ident but with a default database
implicitly selected.

A UDF does not have a fully qualified name, only a name (ident), and should
not use the sp_name grammar fragment during parsing.

The fix is to re-organize the CREATE FUNCTION grammar, to better separate:
- creating UDF (no definer, can have AGGREGATE, simple ident)
- creating Stored Functions (definer, no AGGREGATE, fully qualified name)

With the test case provided, another issue was exposed which is also fixed:
the DROP FUNCTION statement was using sp_name and also failing when no database
is implicitly selected, when droping UDF functions.
The fix is also to change the grammar so that DROP FUNCTION works with
both the ident.ident syntax (to drop a stored function), or just the ident
syntax (to drop either a UDF or a Stored Function, in the current database)


mysql-test/r/sp-error.result:
  Adjust test results
mysql-test/r/udf.result:
  Adjust test results
mysql-test/t/sp-error.test:
  Adjust test results
mysql-test/t/udf.test:
  Adjust test results
sql/sql_parse.cc:
  CREATE UDF FUNCTION does not use a fully qualified name.
sql/sql_yacc.yy:
  Fix grammar for CREATE / DROP FUNCTION, FOR udf
  Improve error messages for select no_such_function()
2007-10-15 19:15:38 -06:00
unknown
048006e2f9 Bug#30986 Character set introducer followed by a HEX string can return bad result(addon)
issue an error if string has illegal characters


mysql-test/r/ctype_utf8.result:
  issue an error if string has illegal characters
mysql-test/t/ctype_utf8.test:
  issue an error if string has illegal characters
sql/item.cc:
  issue an error if string has illegal characters
sql/item.h:
  issue an error if string has illegal characters
sql/sql_yacc.yy:
  issue an error if string has illegal characters
2007-10-15 18:40:58 +05:00
unknown
f30eacb223 Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero
Bug#30982 CHAR(..USING..) can return a not-well-formed string
Bug#30986 Character set introducer followed by a HEX string can return bad result
check_well_formed_result moved to Item from Item_str_func
fixed Item_func_char::val_str for proper ucs symbols converting
added check for well formed strings for correct conversion of constants with underscore
charset


mysql-test/r/ctype_ucs.result:
  test result
mysql-test/r/ctype_utf8.result:
  test result
mysql-test/t/ctype_ucs.test:
  test case
mysql-test/t/ctype_utf8.test:
  test case
sql/item.cc:
  check_well_formed_result() moved from Item_str_func
sql/item.h:
  check_well_formed_result() moved from Item_str_func
sql/item_strfunc.cc:
  check_well_formed_result moved to Item
  fixed Item_func_char::val_str for proper ucs symbols converting
sql/item_strfunc.h:
  check_well_formed_result moved to Item
sql/sql_yacc.yy:
  added check for well formed string
2007-10-11 16:07:10 +05:00
unknown
aec287fd67 Bug #30825: Problems when putting a non-spatial index on a GIS column
Fixed the usage of spatial data (and Point in specific) with 
 non-spatial indexes.
 Several problems :
   - The length of the Point class was not updated to include the 
     spatial reference system identifier. Fixed by increasing with 4 
     bytes.
   - The storage length of the spatial columns was not accounting for
     the length that is prepended to it. Fixed by treating the 
     spatial data columns as blobs (and thus increasing the storage
     length)
   - When creating the key image for comparison in index read wrong
     key image was created (the one needed for and r-tree search,
     not the one for b-tree/other search). Fixed by treating the
     spatial data columns as blobs (and creating the correct kind of
     image based on the index type). 


mysql-test/r/bdb_gis.result:
  Bug #30825: bdb tests
mysql-test/r/gis-rtree.result:
  Bug #30825: key length changed
mysql-test/r/gis.result:
  Bug #30825: MyISAM tests
mysql-test/r/innodb_gis.result:
  Bug #30825: InnoDB tests
mysql-test/t/bdb_gis.test:
  Bug #30825: bdb tests
mysql-test/t/gis.test:
  Bug #30825: MyISAM tests
mysql-test/t/innodb_gis.test:
  Bug #30825: InnoDB tests
sql/field.cc:
  Bug #30825: Removed Field_geom::get_key_image as Field_blog::get_key_image 
    takes type parameter into consideration and is a superset of 
    Field_geom::get_key_image()
sql/field.h:
  Bug #30825: Removed Field_geom::get_key_image as Field_blog::get_key_image 
    takes type parameter into consideration and is a superset of 
    Field_geom::get_key_image()
sql/sql_select.h:
  Bug #30825: Geometry data are a blob derivate
sql/sql_table.cc:
  Bug #30825: Increased key length to accomodate for
    spatial reference system identifier (srid)
sql/sql_yacc.yy:
  Bug #30825: Increased key length to accomodate for
    spatial reference system identifier (srid)
sql/table.cc:
  Bug #30825: It stores a length for spatial data
   as well, so increase the storage length (as it's
   done for blobs).
mysql-test/include/gis_keys.inc:
  Bug #30825: Test file for spatial data and non-spatial indexes
2007-10-10 16:26:02 +03:00
unknown
e952df911c Merge virtua-cwbas201-21-158-74.ctb.virtua.com.br:/Users/davi/mysql/push/bugs/28318-5.0
into  virtua-cwbas201-21-158-74.ctb.virtua.com.br:/Users/davi/mysql/push/mysql-5.0-runtime


sql/sql_yacc.yy:
  Auto merged
2007-10-09 20:48:37 -03:00
unknown
ad104d5bfd Bug#28318 CREATE FUNCTION (UDF) requires a schema
Bug#29816 Syntactically wrong query fails with misleading error message

The core problem is that an SQL-invoked function name can be a <schema
qualified routine name> that contains no <schema name>, but the mysql
parser insists that all stored procedures (function, procedures and
triggers) must have a <schema name>, which is not true for functions.
This problem is especially visible when trying to create a function
or when a query contains a syntax error after a function call (in the
same query), both will fail with a "No database selected" message if
the session is not attached to a particular schema, but the first
one should succeed and the second fail with a "syntax error" message.

Part of the fix is to revamp the sp name handling so that a schema
name may be omitted for functions -- this means that the internal
function name representation may not have a dot, which represents
that the function doesn't have a schema name. The other part is
to place schema checks after the type (function, trigger or procedure)
of the routine is known.


mysql-test/r/sp-error.result:
  Add test case result for Bug#29816
mysql-test/r/udf.result:
  Add test case result for Bug#28318
mysql-test/t/sp-error.test:
  Add test case for Bug#29816
mysql-test/t/udf.test:
  Add test case for Bug#28318
sql/sp.cc:
  Copy the (last) nul byte of the stored routine key and move name parsing
  code to the sp_name class constructor.
sql/sp_head.cc:
  Revamp routine name parsing for when no schema is specified and
  omit dot from the qualified name if the routine is not associated
  with a scheme name.
sql/sp_head.h:
  Name parsing got bigger, uninline by moving to a single unit -- the sp_head.cc
  file.
sql/sql_yacc.yy:
  Only copy the schema name if one is actually set and check for schema
  name presence only where it's necessary.
2007-10-09 20:46:33 -03:00
unknown
2978fcc3e9 Merge gleb.loc:/home/uchum/work/bk/5.0
into  gleb.loc:/home/uchum/work/bk/5.0-opt


sql/sql_yacc.yy:
  Auto merged
mysql-test/r/sp.result:
  SCCS merged
mysql-test/t/sp.test:
  SCCS merged
2007-09-12 23:41:35 +05:00
unknown
403ed43b1d Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data0/mhansson/my50-bug30234-push


sql/sql_yacc.yy:
  Auto merged
2007-09-03 12:44:17 +02:00
unknown
f0d4beee79 Bug #30234: Unexpected behavior using DELETE with AS and USING
DELETE FROM ... USING ... statements with the following type of 
ambiguous aliasing gave unexpected results:
DELETE FROM t1 AS alias USING t1, t2 AS alias WHERE t1.a = alias.a;
This query would leave table t1 intact but delete rows from t2.
Fixed by changing DELETE FROM ... USING syntax so that only alias 
references (as opposed to alias declarations) may be used in FROM.


mysql-test/r/delete.result:
  Bug#30234: Test Result
mysql-test/t/delete.test:
  Bug#30234: Test Case
sql/sql_yacc.yy:
  Bug#30234:
  - Added parser rule table_alias_ref_list that contains a list of table 
    aliases only.
  - Added parser rule table_alias_ref that sets the TL_OPTION_ALIAS in 
    order to turn off semantic checking that applies only for table names.
2007-09-03 11:55:35 +02:00
unknown
e0e44ad66e Bug#30625 (Performance, reduce depth for expressions)
This is a performance bug, affecting in particular the bison generated code
for the parser.

Prior to this fix, the grammar used a long chain of reduces to parse an
expression, like:
  bit_expr -> bit_term
  bit_term -> bit_factor
  bit_factor -> value_expr
  value_expr -> term
  term -> factor
etc

This chain of reduces cause the internal state automaton in the generated
parser to execute more state transitions and more reduces, so that the
generated MySQLParse() function would spend a lot of time looping to execute
all the grammar reductions.

With this patch, the grammar has been reorganized so that rules are more
"flat", limiting the depth of reduces needed to parse <expr>.

Tests have been written to enforce that relative priorities and properties
of operators have not changed while changing the grammar.

See the bug report for performance data.


mysql-test/r/parser_precedence.result:
  Improved test coverage for operator precedence
mysql-test/t/parser_precedence.test:
  Improved test coverage for operator precedence
sql/sql_yacc.yy:
  Simplified the grammar to improve performances
2007-08-28 11:16:03 -06:00
unknown
d4e34c80d6 Merge malff@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  weblab.(none):/home/marcsql/TREE/mysql-5.0-30237


sql/sql_yacc.yy:
  Auto merged
2007-08-22 11:06:42 -06:00
unknown
fb1be0f1e5 Bug#30237 (Performance regression in boolean expressions)
This is a performance bug, related to the parsing or 'OR' and 'AND' boolean
expressions.

Let N be the number of expressions involved in a OR (respectively AND).

When N=1

For example, "select 1" involve only 1 term: there is no OR operator.

In 4.0 and 4.1, parsing expressions not involving OR had no overhead.
In 5.0, parsing adds some overhead, with Select->expr_list.

With this patch, the overhead introduced in 5.0 has been removed,
so that performances for N=1 should be identical to the 4.0 performances,
which are optimal (there is no code executed at all)

The overhead in 5.0 was in fact affecting significantly some operations.
For example, loading 1 Million rows into a table with INSERTs,
for a table that has 100 columns, leads to parsing 100 Millions of
expressions, which means that the overhead related to Select->expr_list
is executed 100 Million times ...

Considering that N=1 is by far the most probable expression,
this case should be optimal.

When N=2

For example, "select a OR b" involves 2 terms in the OR operator.

In 4.0 and 4.1, parsing expressions involving 2 terms created 1 Item_cond_or
node, which is the expected result.
In 5.0, parsing these expression also produced 1 node, but with some extra
overhead related to Select->expr_list : creating 1 list in Select->expr_list
and another in Item_cond::list is inefficient.

With this patch, the overhead introduced in 5.0 has been removed
so that performances for N=2 should be identical to the 4.0 performances.
Note that the memory allocation uses the new (thd->mem_root) syntax
directly.
The cost of "is_cond_or" is estimated to be neglectable: the real problem
of the performance degradation comes from unneeded memory allocations.

When N>=3

For example, "select a OR b OR c ...", which involves 3 or more terms.

In 4.0 and 4.1, the parser had no significant cost overhead, but produced
an Item tree which is difficult to evaluate / optimize during runtime.
In 5.0, the parser produces a better Item tree, using the Item_cond
constructor that accepts a list of children directly, but at an extra cost
related to Select->expr_list.

With this patch, the code is implemented to take the best of the two
implementations:
- there is no overhead with Select->expr_list
- the Item tree generated is optimized and flattened.

This is achieved by adding children nodes into the Item tree directly,
with Item_cond::add(), which avoids the need for temporary lists and memory
allocation

Note that this patch also provide an extra optimization, that the previous
code in 5.0 did not provide: expressions are flattened in the Item tree,
based on what the expression already parsed is, and not based on the order
in which rules are reduced.

For example : "(a OR b) OR c", "a OR (b OR c)" would both be represented
with 2 Item_cond_or nodes before this patch, and with 1 node only with this
patch. The logic used is based on the mathematical properties of the OR
operator (it's associative), and produces a simpler tree.


sql/item_cmpfunc.h:
  Improved performances for parsing boolean expressions
sql/sql_yacc.yy:
  Improved performances for parsing boolean expressions
mysql-test/r/parser_precedence.result:
  Added test cases to cover boolean operator precedence
mysql-test/t/parser_precedence.test:
  Added test cases to cover boolean operator precedence
2007-08-22 11:05:35 -06:00
unknown
6c1edb11d4 Merge mkindahl@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl
into  dl145h.mysql.com:/data0/mkindahl/mysql-5.0-2team


mysql-test/r/func_time.result:
  Auto merged
mysql-test/t/func_time.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-08-03 18:59:16 +02:00
unknown
0d1972aa72 Merge mysql.com:/home/bar/mysql-work/mysql-5.0.b28875
into  mysql.com:/home/bar/mysql-work/mysql-5.0-rpl


mysql-test/r/ctype_utf8.result:
  Auto merged
mysql-test/t/ctype_utf8.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
strings/conf_to_src.c:
  Auto merged
strings/ctype-extra.c:
  Auto merged
mysql-test/r/ctype_ucs.result:
  After merge fix
mysql-test/t/ctype_ucs.test:
  After merge fix
2007-08-03 15:30:31 +05:00
unknown
53df09a9a6 Bug#28875 Conversion between ASCII and LATIN1 charsets does not function
(Regression, caused by a patch for the bug 22646).
Problem: when result type of date_format() was changed from
binary string to character string, mixing date_format()
with a ascii column in CONCAT() stopped to work.
Fix:
- adding "repertoire" flag into DTCollation class,
to mark items which can return only pure ASCII strings.
- allow character set conversion from pure ASCII to other character sets.


include/m_ctype.h:
  Defining new flags.
  Adding new function prototypes.
mysql-test/r/ctype_ucs.result:
  Adding tests.
mysql-test/r/ctype_utf8.result:
  Adding tests.
mysql-test/r/func_time.result:
  Adding tests.
mysql-test/t/ctype_ucs.test:
  Adding tests.
mysql-test/t/ctype_utf8.test:
  Adding tests.
mysql-test/t/func_time.test:
  Adding test.
mysys/charset.c:
  Adding pure ASCII detection when loading a dynamic character set.
sql/item.cc:
  - Moving detection of a Unicode superset into function.
  - Adding detection of a ASCII subset.
  - Adding creation of to-ASCII character set convertor when
    safe_charset_converter() failed and when the argument.
    repertoire is know to be pure ASCII.
sql/item.h:
  - Adding "repertoire" member into DTCollation class.
  - Adding "repertoire" argument to constructors.
  - Adding new methods:
    set_repertoire_from_charset()
    set_repertoire_from_value()
sql/item_func.cc:
  Adding "repertoire" argument.
sql/item_strfunc.cc:
  Adding "repertoire" argument.
sql/item_timefunc.cc:
  Initializing the result repertoire taking into account the "is_ascii"
  flag of the current locale.
sql/sql_lex.cc:
  Detect 7bit strings, return in Lex->text_string_is_7bit.
sql/sql_lex.h:
  Adding new member into LEX structure.
  Adding new member into Lex_input_stream
sql/sql_string.cc:
  Allow simple copy from pure ASCII to a ASCII-based character set.
sql/sql_yacc.yy:
  Depening on Lex->text_string_is_7bit and character set features,
  create Item_string with MY_REPERTOIRE_ASCII when it is possible.
strings/conf_to_src.c:
  - Adding printing of the "MY_CS_PUREASCII" flag
  - Adding printing of copyright
strings/ctype-extra.c:
  Recreating ctype-extra.c: ascii_general_ci and ascii_bin
  are now marked with MY_CS_PUREASCII flag.
strings/ctype.c:
  Adding new functions.
2007-08-03 15:25:23 +05:00
unknown
90d6229652 Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  ramayana.hindu.god:/home/tsmith/m/bk/maint/50


sql/handler.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
2007-08-01 18:39:13 -06:00
unknown
33fc4ad4e1 Fixed bug #30120.
SP with local variables with non-ASCII names crashed the server.

The server replaces SP local variable names with NAME_CONST calls
when putting statements into the binary log. It used UTF8-encoded
item names as variable names for the replacement inside NAME_CONST
calls. However, statement string may be encoded by any
known character set by the SET NAMES statement.
The server used byte length of UTF8-encoded names to increment
the position in the query string that led to array index overrun.


sql/item.cc:
  Fixed bug #30120.
  The Item_splocal class constructor has been modified to
  accept new parameter `len_in_q': the byte length of
  variable name in the query string.
sql/item.h:
  Fixed bug #30120.
  The Item_splocal class has been modified to keep new
  field `len_in_query': the byte length of variable name in
  the query string.
sql/sp_head.cc:
  Fixed bug #30120.
  The subst_spvars function has been modified to increment
  position in the query string by the lengths of not
  encoded variable names instead of byte length of names
  encoded to UTF-8.
sql/sql_yacc.yy:
  Fixed bug #30120.
  The simple_ident rule action has been modified to
  pass the byte length of the local variable name token
  to the Item_splocal object constructor.
mysql-test/t/sp.test:
  Updated test case for bug #30120.
mysql-test/r/sp.result:
  Updated test case for bug #30120.
2007-07-30 04:35:16 +05:00
unknown
04fc8b71d6 Bug#29959 (Non-standard bison syntax in sql_yacc.yy)
In sql/sql_yacc.yy, use the %prec construct at the end of rule join_table


sql/sql_yacc.yy:
  In sql/sql_yacc.yy, use the %prec construct at the end of rule join_table
2007-07-23 16:23:35 -06:00
unknown
b94fb82847 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.(none):/opt/local/work/mysql-5.0-runtime


mysql-test/t/sp.test:
  Auto merged
sql/item.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Manual merge.
mysql-test/t/innodb_mysql.test:
  Manual merge.
2007-07-16 23:41:28 +04:00
unknown
1d40659c1f Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  bodhi.(none):/opt/local/work/mysql-5.0-26141-final


sql/sql_yacc.yy:
  Auto merged
2007-07-12 22:28:13 +04:00
unknown
9dc3088f9e A fix and a test case for Bug#26141 mixing table types in trigger
causes full table lock on innodb table.
Also fixes Bug#28502 Triggers that update another innodb table 
will block on X lock unnecessarily (duplciate).
Code review fixes.

Both bugs' synopses are misleading: InnoDB table is
not X locked. The statements, however, cannot proceed concurrently, 
but this happens due to lock conflicts for tables used in triggers,
not for the InnoDB table. 

If a user had an InnoDB table, and two triggers, AFTER UPDATE and 
AFTER INSERT, competing for different resources (e.g. two distinct
MyISAM tables), then these two triggers would not be able to execute
concurrently. Moreover, INSERTS/UPDATES of the InnoDB table would
not be able to run concurrently. 
The problem had other side-effects (see respective bug reports).

This behavior was a consequence of a shortcoming of the pre-locking
algorithm, which would not distinguish between different DML operations
(e.g. INSERT and DELETE) and pre-lock all the tables
that are used by any trigger defined on the subject table.

The idea of the fix is to extend the pre-locking algorithm to keep track,
for each table, what DML operation it is used for and not
load triggers that are known to never be fired.


mysql-test/r/trigger-trans.result:
  Update results (Bug#26141)
mysql-test/r/trigger.result:
  Update results (Bug#28502)
mysql-test/t/trigger-trans.test:
  Add a test case for Bug#26141 mixing table types in trigger causes 
  full table lock on innodb table.
mysql-test/t/trigger.test:
  Add a test case for Bug#28502 Triggers that update another innodb 
  table will block echo on X lock unnecessarily. Add more test 
  coverage for triggers.
sql/item.h:
  enum trg_event_type is needed in table.h
sql/sp.cc:
  Take into account table_list->trg_event_map when determining
  what tables to pre-lock. 
  
  After this change, if we attempt to fire a 
  trigger for which we had not pre-locked any tables, error
  'Table was not locked with LOCK TABLES' will be printed.
  This, however, should never happen, provided the pre-locking
  algorithm has no programming bugs.
  
  Previously a trigger key in the sroutines hash was based on the name 
  of the table the trigger belongs to. This was possible because we would
  always add to the pre-locking list all the triggers defined for a table when
  handling this table.
  Now the key is based on the name of the trigger, owing
  to the fact that a trigger name must be unique in the database it
  belongs to.
sql/sp_head.cc:
  Generate sroutines hash key in init_spname(). This is a convenient
  place since there we have all the necessary information and can
  avoid an extra alloc.
  
  Maintain and merge trg_event_map when adding and merging elements
  of the pre-locking list.
sql/sp_head.h:
  Add ,m_sroutines_key member, used when inserting the sphead for a
  trigger into the cache of routines used by a statement.
  Previously the key was based on the table name the trigger belonged
  to, since for a given table we would add to the sroutines list
  all the triggers defined on it.
sql/sql_lex.cc:
  Introduce a new lex step: set_trg_event_type_for_tables().
  It is called when we have finished parsing but before opening
  and locking tables. Now this step is used to evaluate for each
  TABLE_LIST instance which INSERT/UPDATE/DELETE operation, if any,
  it is used in.
  In future this method could be extended to aggregate other information
  that is hard to aggregate during parsing.
sql/sql_lex.h:
  Add declaration for set_trg_event_type_for_tables().
sql/sql_parse.cc:
  Call set_trg_event_type_for_tables() after MYSQLparse(). Remove tabs.
sql/sql_prepare.cc:
  Call set_trg_event_type_for_tables() after  MYSQLparse().
sql/sql_trigger.cc:
  Call set_trg_event_type_for_tables() after MYSQLparse().
sql/sql_trigger.h:
  Remove an obsolete member.
sql/sql_view.cc:
  Call set_trg_event_type_for_tables() after MYSQLparse().
sql/sql_yacc.yy:
  Move assignment of sp_head::m_type before calling sp_head::init_spname(), 
  one is now used inside another.
sql/table.cc:
  Implement TABLE_LIST::set_trg_event_map() - a method that calculates
  wh triggers may be fired on this table when executing a statement.
sql/table.h:
  Add missing declarations.
  Move declaration of trg_event_type from item.h (it will be needed for 
  trg_event_map bitmap when we start using Bitmap template instead
  of uint8).
2007-07-12 22:26:41 +04:00
unknown
0bc3e69f92 A fix and a test case for Bug#25859 ALTER DATABASE works w/o parameters.
Fix the parser to make the database options not optional.


mysql-test/r/information_schema.result:
  Update results (Bug#25859)
mysql-test/t/information_schema.test:
  Add a test case for Bug#25859 "ALTER DATABASE works w/o parameters"
sql/sql_yacc.yy:
  Fix Bug#25859 ALTER DATABASE works w/o parameters - require
  parameters in the parser.
2007-07-12 01:10:29 +04:00
unknown
e8966deecc A fix and a test case for Bug#29050 Creation of a legal stored procedure
fails if a database is not selected prior.

The problem manifested itself when a user tried to
create a routine that had non-fully-qualified identifiers in its bodies
and there was no current database selected.

This is a regression introduced by the fix for Bug 19022:

The patch for Bug 19022 changes the code to always produce a warning
if we can't resolve the current database in the parser. 
In this case this was not necessary, since even though the produced
parsed tree was incorrect, we never re-use sphead
that was obtained at first parsing of CREATE PROCEDURE.
The sphead that is anyhow used is always obtained through db_load_routine,
and there we change the current database to sphead->m_db before
calling yyparse.

The idea of the fix is to resolve the current database directly using 
lex->sphead->m_db member when parsing a stored routine body, when
such is present.

This patch removes the need to reset the current database
when loading a trigger or routine definition into SP cache.
The redundant code will be removed in 5.1.


mysql-test/r/sp.result:
  Update test results (Bug#29050)
mysql-test/r/trigger.result:
  Update results.
mysql-test/t/sp.test:
  Add a test case for Bug#29050
mysql-test/t/trigger.test:
  Fix wrong behavior covered with tests.
sql/sql_lex.cc:
  Implement st_lex::copy_db_to().
sql/sql_lex.h:
  Declare st_lex::copy_db_to().
sql/sql_parse.cc:
  Use st_lex::copy_db_to() in add_table_to_list, rather than
  THD::copy_db_to(). The former will use the database of the sphead,
  if we're parsing a stored routine, not the default database in
  THD. The default database is needed to initialize tables->db
  when the database part was not explicitly specified in the identifier.
sql/sql_yacc.yy:
  Use st_lex::copy_db_to() in the parser, rather than
  THD::copy_db_to(). The former will use the database of the sphead,
  if we're parsing a stored routine, not the default database in
  THD.
2007-07-05 11:34:04 +04:00
unknown
c68336b15a Merge lthalmann@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  mysql.com:/nfsdisk1/lars/bk/mysql-5.0-rpl


sql/sql_yacc.yy:
  Auto merged
2007-07-02 17:02:01 +02:00
unknown
2b09b6c57c Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge


sql/item_sum.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-07-02 13:22:23 +02:00
unknown
c5ebbb6571 Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-base
into  weblab.(none):/home/marcsql/TREE/mysql-5.0-rt-merge


sql/sql_yacc.yy:
  Auto merged
2007-06-25 10:32:38 -06:00
unknown
ab5e152132 Merge adventure.(none):/home/thek/Development/cpp/bug28846/my50-bug28846
into  adventure.(none):/home/thek/Development/cpp/mysql-5.0-runtime


sql/sql_class.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-06-22 15:40:35 +02:00
unknown
9b940d0cb7 Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl
into  mysql.com:/home/bar/mysql-work/mysql-5.0.b28925


sql/sql_yacc.yy:
  Auto merged
mysql-test/r/ctype_ucs2_def.result:
  After merge fix
mysql-test/t/ctype_ucs2_def.test:
  After merge fix
2007-06-22 17:28:26 +05:00
unknown
46c3d7b87d Bug#28925 GROUP_CONCAT inserts wrong separators for a ucs2 column
Problem: separator was not converted to the result character set,
so the result was a mixture of two different character sets,
which was especially bad for UCS2.
Fix: convert separator to the result character set.


mysql-test/r/ctype_ucs.result:
  Adding test case
mysql-test/r/ctype_ucs2_def.result:
  Adding test case
mysql-test/t/ctype_ucs.test:
  Adding test case
mysql-test/t/ctype_ucs2_def.test:
  Adding test case
sql/item_sum.cc:
  Adding conversion of separator to the result character set
sql/sql_yacc.yy:
  Fixing GROUPC_CONCAT problems when "mysqld --default-character-set=ucs2".
2007-06-22 17:18:40 +05:00
unknown
099be80130 Bug#28846 Use of undocumented Prepared Statements crashes server
ALTER VIEW is currently not supported as a prepared statement
and should be disabled as such as they otherwise could cause server crashes.

ALTER VIEW is currently not supported when called from stored
procedures or functions for related reasons and should also be disabled.

This patch disables these DDL statements and adjusts the appropriate test
cases accordingly.

Additional tests has been added to reflect on the fact that we do support
CREATE/ALTER/DROP TABLE for Prepared Statements (PS), Stored Procedures (SP)
and PS within SP.


mysql-test/r/ps_1general.result:
  - Updated test to reflect on the new policy to disallow ALTER VIEW within SP.
mysql-test/r/sp-dynamic.result:
  - Added PS ALTER TABLE test from within SP-context to demonstrate that CREATE/ALTER/DROP
  TABLE statements is working.
  - Added PS CREATE/ALTER/DROP VIEW tests from within SP-context to show that
  ALTER VIEW is not supported, CREATE VIEW/DROP VIEW are supported.
mysql-test/r/sp-error.result:
  - Updated test to reflect on the new policy to disallow VIEW DDL within SP.
mysql-test/t/ps_1general.test:
  - Updated test to reflect on the new policy to disallow VIEW DDL within SP.
mysql-test/t/sp-dynamic.test:
  - Add PS ALTER TABLE test from within SP to demonstrate that CREATE/ALTER/DROP
  TABLE statements are supported.
mysql-test/t/sp-error.test:
  - Updated test to reflect on the new policy to disallow ALTER VIEW
  within SP-context.
  - Changed error code 1314 to the more abstract ER_SP_BADSTATEMENT.
sql/sql_class.h:
  - Added comment for clarity
sql/sql_parse.cc:
  - Added comment for clarity
sql/sql_prepare.cc:
  - Disallow ALTER VIEW as prepared statements until they are
    properly supported. Note that SQLCOM_CREATE_VIEW also handles ALTER VIEW
    statements.
sql/sql_view.cc:
  - converted to doxygen comments
  - Added comment for clarity
sql/sql_yacc.yy:
  - Disallow ALTER VIEW statements within a SP.
  If the parser is operating within the SP context, this is shown
  on the sp->sphead pointer. If this flag is set for view DDL operations
  we stop parsing with the error 'ER_SP_BAD_STATEMENT'.
2007-06-22 11:55:48 +02:00
unknown
bfc61f2ea9 Merge damien-katzs-computer.local:/Users/dkatz/mysql50
into  damien-katzs-computer.local:/Users/dkatz/50_win


sql/sql_yacc.yy:
  Auto merged
2007-06-19 18:03:47 -04:00
unknown
5941479ee3 Bug #28921 Queries containing UDF functions are cached
Fixed runtime to no longer allow the caching of queries with UDF calls.


mysql-test/r/udf.result:
  Added a test that turns on caching and checks that querys calling UDFs don't get cached.
mysql-test/t/udf.test:
  Added a test that turns on caching and checks that querys calling UDFs don't get cached.
sql/sql_yacc.yy:
  Fixed code to set safe_to_cache_query=0 regardless if the function call is a UDF or SP. Where it was placed previously -- at the very end of the else testing for UDFs -- it only executed the statement if the function call was a stored procedure call.
2007-06-18 17:55:12 -04:00
unknown
2a9bb27424 Bug #29053 SQL_CACHE in UNION causes non-deterministic functions to be cached
Changed code to enforce that SQL_CACHE only in the first SELECT is used to turn on caching(as documented), but any SQL_NO_CACHE will turn off caching (not documented, but a useful behaviour, especially for machine generated queries). Added test cases to explicitly test the documented caching behaviour and test cases for the reported bug. 


mysql-test/r/query_cache.result:
  Added non-bug specific tests that ensure that only SQL_CACHE in the first SELECT is respected when encountered by the parser. These tests validate what is already documented, that only the outer most SELECTS can use the SQL_CACHE option to turn on caching. Because it would break existing SQL applications, we do not return an error if the SQL_CACHE expression is found in nested SELECTs. Also added test to validate nested SELECT can contain SQL_NO_CACHE and it will always turn off caching for the whole query. 
  
  Also added a bug specific test case to validate that the buggy behavior as reported has been fixed.
mysql-test/t/query_cache.test:
  Added non-bug specific tests that ensure that only SQL_CACHE in the first SELECT is respected when encountered by the parser. These tests validate what is already documented, that only the outer most SELECTS can use the SQL_CACHE option to turn on caching. Because it would break existing SQL applications, we do not return an error if the SQL_CACHE expression is found in nested SELECTs. Also added test to validate nested SELECT can contain SQL_NO_CACHE and it will always turn off caching for the whole query. 
  
  Also added a bug specific test case to validate that the buggy behavior as reported has been fixed.
sql/sql_yacc.yy:
  Added an explicit check to make sure "SELECT SQL_CACHE" only works on the first select in a query.
  
  The parser will always hit the outermost SELECT first, and if the SQL_CACHE option is found it sets the safe_to_query flag in the lex. Then, if there are subseqent "uncachable" subqueries or functions, as it parses those elements it sets the safe_to_query to 0. However, this cause problems if nested SELECTs also used the SQL_CACHE option, because then it would set back safe_to_query to 1, even though there are uncacheable expressions previously parsed.
  
  By adding the check to ensure only the first SELECT can turn caching on, it means a subsequent SQL_CACHE option can't turn caching back on after a uncacheable subsequery was already encountered.
2007-06-18 17:16:20 -04:00
unknown
6f168d1255 Merge bk@192.168.21.1:mysql-5.0
into  mysql.com:/d2/hf/mrg/mysql-5.0-opt


client/mysqltest.c:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/innodb_mysql.result:
  merging
mysql-test/t/innodb_mysql.test:
  merging
sql/sql_select.cc:
  merging
2007-06-14 16:41:10 +05:00
unknown
98c7c87e45 Merge mysql.com:/home/gluh/MySQL/Merge/4.1-opt
into  mysql.com:/home/gluh/MySQL/Merge/5.0-opt


mysql-test/r/subselect.result:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/t/subselect.test:
  manual merge
2007-06-06 18:33:04 +05:00
unknown
593afb6a73 Bug#28553 mysqld crash in "purge master log before(select time from information_schema)"
forbid the use of subselect in PURGE LOGS BEFORE command


mysql-test/r/subselect.result:
  test result
mysql-test/t/subselect.test:
  test case
sql/sql_yacc.yy:
  forbid the use of subselect in PURGE LOGS BEFORE command
2007-06-06 18:29:15 +05:00
unknown
f5bc5381ae Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.0
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/jun05/50


client/mysqldump.c:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-06-05 23:04:40 +02:00
unknown
1c72c3a8c1 Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/50
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/jun05/50


mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/t/mysqltest.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-06-05 17:28:49 +02:00
unknown
b313fe1352 Merge bk-internal:/home/bk/mysql-5.0-opt
into  macbook.gmz:/Users/kgeorge/mysql/work/B26162-5.0-opt


mysql-test/r/trigger.result:
  Auto merged
mysql-test/t/trigger.test:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-06-03 10:03:37 +03:00
unknown
f9a41f9f35 Bug #26162: Trigger DML ignores low_priority_updates setting
The value of "low-priority-updates" option and the LOW PRIORITY
prefix was taken into account at parse time.
This caused triggers (among others) to ignore this flag (if
supplied for the DML statement).
Moved reading of the LOW_PRIORITY flag at run time.
Fixed an incosistency when handling
SET GLOBAL LOW_PRIORITY_UPDATES : now it is in effect for
delayed INSERTs.
Tested by checking the effect of LOW_PRIORITY flag via a 
trigger.


include/thr_lock.h:
  Bug #26162: moved reading of the LOW PRIORITY flag at run time
mysql-test/r/trigger.result:
  Bug #26162: test case
mysql-test/t/trigger.test:
  Bug #26162: test case
sql/set_var.cc:
  Bug #26162: fixed the handling of the "low-priority-updates" option
sql/sql_base.cc:
  Bug #26162: moved reading of the LOW PRIORITY flag at run time
sql/sql_yacc.yy:
  Bug #26162: moved reading of the LOW PRIORITY flag at run time
2007-06-03 09:40:00 +03:00
unknown
7be03ef01f Merge mysql.com:/home/ram/work/mysql-5.0-maint
into  mysql.com:/home/ram/work/b28464.new/b28464.new.5.0


sql/item.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/item.cc:
  SCCS merged
2007-05-24 20:21:04 +05:00