Commit graph

20492 commits

Author SHA1 Message Date
Alexey Botchkov
dca6ff48c1 fix for bug 857051 ST_EQUALS returns TRUE on two nonidentical MULTIPOINTs
The 'single point' event was forgotten in the relation's calculation

per-file comments:
  mysql-test/r/gis-precise.result
fix for bug 857051 ST_EQUALS returns TRUE on two nonidentical MULTIPOINTs
        test result updated.
  mysql-test/t/gis-precise.test
fix for bug 857051 ST_EQUALS returns TRUE on two nonidentical MULTIPOINTs
        test case added.
  sql/gcalc_tools.cc
fix for bug 857051 ST_EQUALS returns TRUE on two nonidentical MULTIPOINTs
        scev_single_point is properly handled.
2011-09-23 15:25:48 +05:00
Alexey Botchkov
53ad390ff0 fix for 857050 ST_WITHIN returns wrong result with MULTIPOINT and POLYGON
return GEOMETRYCOLLECTION EMPTY, not NULL for the query

per-file comments:
  mysql-test/r/gis.result
fix for 857050 ST_WITHIN returns wrong result with MULTIPOINT and POLYGON
        test result updated.
  sql/spatial.cc
fix for 857050 ST_WITHIN returns wrong result with MULTIPOINT and POLYGON
        return of the Geometry::envelope() changed for the empty geometry.
2011-09-23 15:05:36 +05:00
Michael Widenius
22e793639a Added new options to KILL. New syntax is KILL [HARD|SOFT] [CONNECTION|QUERY] [ID | USER user_name]
- If USER is given, all threads for that user is signaled
- If SOFT is used then the KILL will not be sent to the handler. This can be used to not interrupt critical things in the handler like 'REPAIR'.

Internally added more kill signals. This gives us more information of why a query/connection was killed.
- KILL_SERVER is used when server is going down. In this case the users gets ER_SHUTDOWN as the reason connection was killed.
- Changed signals to number in correct order, which makes it easier to test how the signal should affect the code.
- New error message ER_CONNECTION_KILLED if connection was killed by 'KILL CONNECTION'. Before we got error ER_SHUTDOWN.

Changed names of not used parameters KILL_QUERY & KILL_CONNCTION to mysql_kill() to not conflict with defines in the server


include/mysql.h.pp:
  Updated file
include/mysql_com.h:
  Changed names of not used parameters KILL_QUERY & KILL_CONNCTION to mysql_kill() to not conflict with defines in the server
mysql-test/r/kill.result:
  Added test of KILL USER
mysql-test/suite/rpl/r/rpl_stm_000001.result:
  Updated error code
mysql-test/suite/rpl/t/rpl_stm_000001.test:
  Updated error codes
mysql-test/t/flush_read_lock_kill.test:
  Updated error codes
mysql-test/t/kill.test:
  Added test of KILL USER
plugin/handler_socket/handlersocket/database.cpp:
  Removed THD:: from KILL
sql/debug_sync.cc:
  Removed THD:: from KILL
sql/event_scheduler.cc:
  Removed THD:: from KILL
sql/filesort.cc:
  Removed THD:: from KILL
sql/ha_ndbcluster_binlog.cc:
  Removed THD:: from KILL
sql/handler.cc:
  Removed THD:: from KILL
  Simplify code.
sql/lex.h:
  Added new keywords HARD | SOFT
sql/log.cc:
  Removed THD:: from KILL
  Added testing of new error ER_CONNECTION_KILLED
sql/log_event.cc:
  Removed THD:: from KILL
  Added testing of new error ER_CONNECTION_KILLED
sql/mysql_priv.h:
  Added new prototypes
sql/mysqld.cc:
  Removed THD:: from KILL
  Use KILL_SERVER_HARD signal on shutdown.
sql/scheduler.cc:
  Removed THD:: from KILL
  Simplify test if connection should be killed
sql/share/errmsg.txt:
  New error message ER_CONNECTION_KILLED
sql/slave.cc:
  Removed THD:: from KILL
sql/sp_head.cc:
  Removed THD:: from KILL
sql/sql_base.cc:
  Removed THD:: from KILL
sql/sql_cache.cc:
  Removed THD:: from KILL
sql/sql_class.cc:
  Removed THD:: from KILL
  Added killed_errno()
  Only signal kill to storage engine if HARD bit is set.
sql/sql_class.h:
  Move KILL options out from THD to make them easier to use in sql_yacc.yy
sql/sql_connect.cc:
  Removed THD:: from KILL
sql/sql_delete.cc:
  Removed THD:: from KILL
sql/sql_error.cc:
  Removed THD:: from KILL
sql/sql_insert.cc:
  Removed THD:: from KILL
  Simplifed testing if thread is killed.
sql/sql_lex.h:
  Added kill options to st_lex
sql/sql_load.cc:
  Removed THD:: from KILL
sql/sql_parse.cc:
  Added kill options to st_lex
  Simplifed and optimzed testing of thd->killed at end of query
  Added support for KILL USER
  Extended sql_kill() to allow use of more kill signals.
sql/sql_repl.cc:
  Removed THD:: from KILL
sql/sql_show.cc:
  Removed THD:: from KILL
  Simplied testing if query/connection was killed
sql/sql_table.cc:
  Removed THD:: from KILL
sql/sql_update.cc:
  Removed THD:: from KILL
sql/sql_yacc.yy:
  Added support for new KILL syntax: KILL [HARD|SOFT] [CONNECTION|QUERY] [ID | USER user_name]
storage/archive/ha_archive.cc:
  Simplify compilation
storage/maria/ha_maria.cc:
  Removed THD:: from KILL
2011-09-23 01:13:38 +03:00
Sergey Petrunya
ebbdb14a02 BUG#849776: Wrong result with semijoin + "Impossible where"
- Provide fix_after_pullout() function for Item_in_optimizer and other Item_XXX classes (basically, all of them
  that have eval_not_null_tables, which means they have special rules for calculating not_null_tables_cache value)
2011-09-23 01:25:08 +04:00
Alexey Botchkov
5123f59ed2 fixed bugs
855485  ST_CROSSES returns different result than PostGIS for overlapping polygons
855487  ST_WITHIN returns wrong result for partially overlapping polygons
855492  ST_WITHIN returns TRUE on point on the edge of a polygon
855497  ST_ENVELOPE of GEOMETRYCOLLECTION EMPTY returns NULL and not GEOMETRYCOLLECTION EMPTY
855503  ST_EQUALS reports TRUE between a POLYGON and a MULTILINESTRING
855505  ST_TOUCHES reports TRUE for intersecting polygon and linestring

        Changed the way weird functions like Crosses or Touches treated.
        Added BORDER handling to the Gcalc_function.

per-file comments:
  mysql-test/r/gis-precise.result
        GIS bugs fixed.
        test result updated.
  mysql-test/t/gis-precise.test
        GIS bugs fixed.
        test cases added.
  sql/gcalc_slicescan.h
        GIS bugs fixed.
  sql/gcalc_tools.cc
        GIS bugs fixed.
  sql/gcalc_tools.h
        GIS bugs fixed.
  sql/item_create.cc
        GIS bugs fixed.
  sql/item_geofunc.cc
        GIS bugs fixed.
  sql/item_geofunc.h
        GIS bugs fixed.
  sql/spatial.cc
        GIS bugs fixed.
2011-09-22 18:53:36 +05:00
Sergey Petrunya
42b928ca05 Fix after previous cset: update test results 2011-09-22 01:55:17 +04:00
Alexey Botchkov
d0f2e1e551 bug 855336 ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
per-file comments:
  mysql-test/r/gis.result
bug 855336      ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
        test result updated.
  mysql-test/t/gis.test
bug 855336      ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
        test case added.
  sql/item_geofunc.cc
bug 855336      ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
        geom_length() call fixed.
  sql/spatial.cc
bug 855336      ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
        Geometry_collection::geom_length implemented.
  sql/spatial.h
bug 855336      ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
        Geometry_collection::geom_length declaration added.
2011-09-21 13:26:21 +05:00
Alexey Botchkov
6b64baf3b9 fix for bug 848926 GIS functions return "GEOMETRYCOLLECTION()" instead of "GEOMETRYCOLLECTION EMPTY"
per-file comments:
  mysql-test/r/gis.result
fix for bug 848926 GIS functions return "GEOMETRYCOLLECTION()" instead of "GEOMETRYCOLLECTION EMPTY"
        test result updated.
  mysql-test/t/gis.test
fix for bug 848926 GIS functions return "GEOMETRYCOLLECTION()" instead of "GEOMETRYCOLLECTION EMPTY"
        test case added.
  sql/gstream.cc
fix for bug 848926 GIS functions return "GEOMETRYCOLLECTION()" instead of "GEOMETRYCOLLECTION EMPTY"
        lookup_next_word() implemented.
  sql/gstream.h
fix for bug 848926 GIS functions return "GEOMETRYCOLLECTION()" instead of "GEOMETRYCOLLECTION EMPTY"
        lookup_next_word() added.
  sql/spatial.cc
fix for bug 848926 GIS functions return "GEOMETRYCOLLECTION()" instead of "GEOMETRYCOLLECTION EMPTY"
        name changed for the empty geometry.
  sql/spatial.h
fix for bug 848926 GIS functions return "GEOMETRYCOLLECTION()" instead of "GEOMETRYCOLLECTION EMPTY"
        declarations modified.
2011-09-21 12:50:03 +05:00
Alexey Botchkov
25b5019c34 bugs fixed
855253 Compiler error: gcalc_slicescan.cc:2036: error: suggest parentheses around comparison in operand of .|. in maria-5.3-gis
        850775 ST_AREA does not work on GEOMETRYCOLLECTIONs in maria-5.3-gis

per-file comments:
  mysql-test/r/gis.result
        test result updated.
  mysql-test/t/gis.test
        test case added for 850775.
  sql/gcalc_slicescan.cc
        compiler error fixed.
  sql/spatial.cc
        ST_AREA implementation for GEOMETRY_COLLECTION, POINT and LINESTRING.
  sql/spatial.h
        area() declarations added.
2011-09-21 09:29:37 +05:00
Alexey Botchkov
0249413a6a several bugs fixed here.
849789  Second assertion `m_poly_borders->next' failed in Gcalc_operation_reducer::count_slice in maria-5.3-gis
        849791  Fourth assertion `n > 0 && n < SINUSES_CALCULATED*2+1' in get_n_sincos
        849789  Second assertion `m_poly_borders->next' failed in Gcalc_operation_reducer::count_slice in maria-5.3-gis
        848901   Assertion `fabs(cur_isc->x-m_cur_intersection->x) + fabs(cur_isc->y-m_cur_intersection->y) < 0.000000000001' failed in Gcalc_scan_iterator::intersection_scan() in maria-5.3-gis
        
per-file comments:
  mysql-test/r/gis-precise.result
        test result updated.
  mysql-test/r/gis.result
        test result updated.
  sql/gcalc_slicescan.cc
        bugfixes.
  sql/gcalc_slicescan.h
        bugfixes.
  sql/gcalc_tools.cc
        bugfixes.
  sql/gcalc_tools.h
        bugfixes.
  sql/item_geofunc.cc
        bugfixes.
  sql/spatial.cc
        bugfixes.
2011-09-21 00:04:41 +05:00
Sergey Petrunya
0df523d1f3 Merge 2011-09-20 20:43:57 +04:00
Sergey Petrunya
f0323a40d8 BUG#849763: Wrong result with second execution of prepared statement with semijoin + view
- The problem was that Item_direct_view_ref and its embedded Item_field were getting incorrect
  value of item->used_tables() after fix_fields() in the second and subsequent EXECUTE.
- Made relevant fixes in Item_field::fix_fields() and find_field_in_tables(), so that the 
  Item_field gets the correct attributes.
2011-09-20 20:40:07 +04:00
Sergey Petrunya
4bcd5baa0e Merge 2011-09-17 23:58:36 +04:00
Sergey Petrunya
27cd8d7b70 BUG##849717: Crash in Item_func::fix_fields on second execution of a prepared statement with semijoin
- If convert_join_subqueries_to_semijoins() decides to wrap Item_in_subselect in Item_in_optimizer, 
  it should do so in prep_on_expr/prep_where, too, as long as they are present.
  There seems to be two possibilities of how we arrive in this function:
  - prep_on_expr/prep_where==NULL, and will be set later by simplify_joins()
  - prep_on_expr/prep_where!=NULL, and it is a copy_and_or_structure()-made copy of on_expr/where.
  the latter can happen for some (but not all!) nested joins. This bug was that we didn't handle this case.
2011-09-17 23:53:50 +04:00
Sergey Vojtovich
a33b42146e Merge. 2011-09-16 16:03:08 +04:00
Sergey Vojtovich
3f9cbd7731 BUG#11761180 - 53646: MYISAMPACK CORRUPTS TABLES WITH
FULLTEXT INDEXES

myisamchk may create incorrect fulltext index for compressed
tables. Incorrect data pointer size was used while creating
fulltext index.

mysql-test/r/myisampack.result:
  A test case for BUG#11761180.
mysql-test/t/myisampack.test:
  A test case for BUG#11761180.
storage/myisam/ft_boolean_search.c:
  rec_reflength on share may have adjustments required for
  compressed tables and must be used instead of rec_reflength
  on base info.
storage/myisam/ft_nlq_search.c:
  rec_reflength on share may have adjustments required for
  compressed tables and must be used instead of rec_reflength
  on base info.
storage/myisam/mi_check.c:
  rec_reflength on share may have adjustments required for
  compressed tables and must be used instead of rec_reflength
  on base info.
storage/myisam/mi_write.c:
  rec_reflength on share may have adjustments required for
  compressed tables and must be used instead of rec_reflength
  on base info.
2011-09-16 15:30:31 +04:00
Mattias Jonsson
1cfcab041a merge into 5.1-sec of bug#11766879. 2011-09-15 19:26:38 +02:00
unknown
40761a9a73 Merge from mysql-5.1.59-release 2011-09-15 18:48:54 +02:00
Michael Widenius
574e51e5fd Merge with 5.2 2011-09-15 17:25:37 +03:00
Michael Widenius
64d6cbe556 Removed duplicate test 2011-09-15 16:36:43 +03:00
Bjorn Munch
52960624d3 Bug #12793118 MYSQLTEST: --ERROR AND --DISABLE_ABORT_ON_ERROR DO NOT WORK FOR SQL IN COMMANDS
Call handle_error() instead of die() when evaluating these
  Must remember "current command" with link to errors to ignore
  Added test cases to mysqltest.test
2011-09-14 15:19:24 +02:00
Sergey Petrunya
ef2a4f11e1 Merge 2011-09-14 12:43:29 +04:00
Sergey Petrunya
5ebff8ab78 BUG#730133: Wrong result with jkl = 7, BKA, ICP in maria-5.3 + compound index
- Mrr_ordered_index_reader::interrupt_read() and resume_read() should 
  save/restore not just index lookup tuple, but entire index tuple.
  Key parts that are not used for index lookup can be still used in
  pushed index condition. Failure to save/restore will cause the index
  condition to be evaluated over the wrong values.
2011-09-13 23:45:02 +04:00
Michael Widenius
4139bba281 Increased version number
Give proper error to client on shutdown.

configure.in:
  Increased version number
mysql-test/mysql-test-run.pl:
  Ignore errors that one can get while running with --mysqld=--log-warnings=2
mysql-test/r/variables.result:
  Remember original value of log_warnings
mysql-test/suite/rpl/r/rpl_idempotency.result:
  Ignore errors that one can get while running with --mysqld=--log-warnings=2
mysql-test/suite/rpl/t/rpl_idempotency.test:
  Ignore errors that one can get while running with --mysqld=--log-warnings=2
mysql-test/t/variables.test:
  Remember original value of log_warnings
sql/mysqld.cc:
  Give proper error to close_connection() on shutdown
storage/maria/ha_maria.cc:
  Added missing DBUG_RETURN
2011-09-13 18:46:47 +03:00
Alexey Botchkov
5a04ac7bf0 Fix for bug 848939 Wrong result with ST_INTERSECTION between linestrings and a polygon in 5.3-gis
Coordinates were mistakenly reversed for MULTIPOINT.

per-file comments:
  mysql-test/r/gis-precise.result
Fix for bug 848939 Wrong result with ST_INTERSECTION between linestrings and a polygon in 5.3-gis
        test result updated.
  mysql-test/t/gis-precise.test
Fix for bug 848939 Wrong result with ST_INTERSECTION between linestrings and a polygon in 5.3-gis
        test case added.
  sql/gcalc_tools.cc
Fix for bug 848939 Wrong result with ST_INTERSECTION between linestrings and a polygon in 5.3-gis
        coordinates set in the proper order.
2011-09-13 18:26:16 +05:00
Alexey Botchkov
b408b1bbbc Fix for bug #848901 Assertion `fabs(cur_isc->x-m_cur_intersection->x) + fabs(cur_isc->y-m_cur_intersection->y) < 0.000000000001' failed in Gcalc_scan_iterator::intersection_scan() in maria-5.3-gis
That assertion's check was too tight. Released it a bit.

per-file comments:
  mysql-test/r/gis-precise.result
        Fix for bug #848901
        test result updated.
  mysql-test/t/gis-precise.test
        Fix for bug #848901
        test case added.
  sql/gcalc_slicescan.cc
        Fix for bug #848901
        The DBUG_ASSERT check is too tight here.
2011-09-13 15:19:55 +05:00
Alexey Botchkov
3882c5d62c Fix for few similar bugs:
#841622 Assertion `t->rp->type == Gcalc_function::shape_line' failed in Gcalc_operation_reducer::end_line in maria-5.3-gi
  #841625 Assertion `m_poly_borders->next' failed in Gcalc_operation_reducer::count_slice in maria-5.3-gis
  #841638 Assertion `!m_prev || m_prev->x != x || m_prev->y != y' failed in Gcalc_shape_transporter::int_add_point in maria-5.3-gis
  #841662 Third assertion `n > 0 && n < SINUSES_CALCULATED*2+1' in get_n_sincos
  #841745 Assertion `!sp0->is_bottom()' failed in Gcalc_scan_iterator::find_intersections in maria-5.3-gis

  They mostly was caused by inprecision of double arithmetic.
  Fixed by changes in how to handle multiple intersections to keep their order right.

  Also ST_DISTANCE(GEOM, EMPTY_GEOM) was defined as NULL.


per-file comments:
  mysql-test/r/gis-precise.result
   GIS bugfixes.
        test result updated.
  mysql-test/t/gis-precise.test
   GIS bugfixes.
        test cases added.
  sql/gcalc_slicescan.cc
   GIS bugfixes.
        If intersections are close, add order checks to cope with the
        double calcualtions imprecision.
  sql/gcalc_slicescan.h
   GIS bugfixes.
        n_row parameter added to intersection to check their order.
  sql/item_geofunc.cc
   GIS bugfixes.
        ST_DISTANCE(GEOM, EMPTY_GEOM) returns NULL.
2011-09-13 13:59:11 +05:00
Michael Widenius
3fb22ac5e1 Merge with 5.2 2011-09-10 18:01:27 +03:00
Sergey Petrunya
3769841d9e BUG#833600: Wrong result with view + outer join + uncorrelated subquery (non-semijoin)
- The bug was caused by outer join being incorrectly converted into inner because of 
  invalid return values of Item_direct_view_ref::not_null_tables().
- Provided a correct Item_direct_view_ref::not_null_tables() function.
2011-09-08 23:24:47 +04:00
Sergey Petrunya
19a4309acf Automerge. 2011-09-08 21:38:10 +04:00
Igor Babaev
5746b96825 Merge. 2011-09-08 09:21:31 -07:00
Sergey Petrunya
5673aa41c3 BUG#830993: Crash in end_read_record with derived table
- Let join buffering code correctly take into account rowids needed 
  by DuplicateElimination when it is calculating minimum record sizes.
- In JOIN_CACHE::write_record_data, added asserts that prevent us from 
  writing beyond the end of the buffer.
2011-09-08 19:48:14 +04:00
unknown
b80641b36c LP BUG#813418 fix.
The problem was that optimization code did not take into account later feature when instad of NOT before BETWEEN it has negated flag into the Item_func_between inherited from Item_func_neg_opt. So optimizer tried process NOT BETWEEN as BETWEEN.

The patch just switches off the optimisation for NOT BETWEEN as it was before when NOT function was really used.
2011-09-08 16:57:46 +03:00
Sergei Golubchik
3e97aeafd6 lp:839387 Assertion `(Item_result)i != TIME_RESULT' failed with CASE + datetime
remove incorrect DBUG_ASSERT().
Fix incorrectly used cmp_item::get_comparator() in Item_func_case and Item_equal
2011-09-07 20:39:47 +02:00
Sergey Petrunya
ee66fbb402 Merge 2011-09-06 20:59:29 +04:00
Igor Babaev
1cd3627665 Merge. 2011-09-06 08:38:35 -07:00
Igor Babaev
da59130ec1 Fixed LP bug #838633.
For any query JOIN::optimize() should call the method
SELECT::save_leaf_tables after the last transformation
that utilizes the statement memory rather than the 
execution memory.
2011-09-06 07:17:39 -07:00
Sergey Petrunya
fc6b6435b4 BUG#823930: Wrong result with semijoin materialization and blob fields
- Make subquery_types_allow_materialization() detect a case where 
  create_tmp_table() would create a blob column which would make it 
  impossible to use materialization
  Non-semi-join materialization worked because it detected that this case
  and felt back to use IN->EXISTS. Semi-join Materialization cannot easily
  fallback, so we have to detect this case early.
2011-09-06 17:06:04 +04:00
Sergey Petrunya
e1435a5178 BUG#834739: Wrong result with 3-way inner join, LooseScan,multipart keys
- Don't use join buffering for tables that are within ranges that are 
  covered by LooseScan strategy.
2011-09-05 20:51:37 +04:00
Sergey Petrunya
6035d0d755 BUG#834758: Wrong result with innner join, LooseScan, two-column IN() predicate
- get_bound_sj_equalities() would produce incorrect bitmap when non-first 
  equality was bound, which resulted in invalid LooseScan plans.
2011-09-05 19:28:22 +04:00
unknown
ae23d4c985 Merge LP BUG#780386 5.2->5.3 (where other fix was present) 2011-09-05 10:14:48 +03:00
unknown
8b062c1fef Fix of LP BUG#780386.
ALL subquery should return TRUE if subquery rowa set is empty independently
  of left part.  The problem was that Item_func_(eq,ne,gt,ge,lt,le) do not
  call execution of second argument if first is NULL no in this case subquery
  will not be executed and when Item_func_not_all calls any_value() of the
  subquery or aggregation function which report that there was rows. So for
  NULL < ALL (SELECT...) result was FALSE instead of TRUE.
  
  Fix is just swapping of arguments of Item_func_(eq,ne,gt,ge,lt,le) (with
  changing the operation if it is needed) so that result will be the same
  (for examole a < b is equal to b > a). This fix exploit the fact that
  first argument will be executed in any case.
2011-09-05 09:29:49 +03:00
Alexey Botchkov
a1315808b4 bug 839327 Crash in Gcalc_operation_reducer::end_couple with ST_UNION and MULTIPOLYGONs in 5.3-gis.
When edges of a polygon coicide, it can form an pike, that is turned into a line after an operation.
        In this case a former polygon point can be an end of a single line, and that case wasn't properly handled.


per-file comments:
  mysql-test/r/gis-precise.result
bug 839327 Crash in Gcalc_operation_reducer::end_couple with ST_UNION and MULTIPOLYGONs in 5.3-gis.
        test result updated.

  mysql-test/t/gis-precise.test
bug 839327 Crash in Gcalc_operation_reducer::end_couple with ST_UNION and MULTIPOLYGONs in 5.3-gis.
        test case added.

  sql/gcalc_tools.cc
bug 839327 Crash in Gcalc_operation_reducer::end_couple with ST_UNION and MULTIPOLYGONs in 5.3-gis.
        in the scev_two_ends case check if we have single line ending on a polygon node.
2011-09-05 09:49:46 +05:00
Alexey Botchkov
97eae1cd63 bug 839318 Crash in Gcalc_scan_iterator::point::get_shape with ST_DISTANCE and MULTILINESTRING in maria-5.3-gis.
wrong variable was used as a result of inattentive copypaste.

per-file comments:
  mysql-test/r/gis-precise.result
bug 839318 Crash in Gcalc_scan_iterator::point::get_shape with ST_DISTANCE and MULTILINESTRING in maria-5.3-gis.
     test result updated.

  mysql-test/t/gis-precise.test
bug 839318 Crash in Gcalc_scan_iterator::point::get_shape with ST_DISTANCE and MULTILINESTRING in maria-5.3-gis.
     test case added.

  sql/item_geofunc.cc
bug 839318 Crash in Gcalc_scan_iterator::point::get_shape with ST_DISTANCE and MULTILINESTRING in maria-5.3-gis.
     use 'ev' variable instead of the 'evpos'.
2011-09-05 09:13:58 +05:00
Alexey Botchkov
6dfa30e938 bug 839341 100% CPU usage with ST_UNION in maria-5.3-gis.
Line loops weren't recognized when collect results.
    Fixed by checking if we got the same beginning point of the line.

per-file comments:
  mysql-test/r/gis-precise.result
bug 839341 100% CPU usage with ST_UNION in maria-5.3-gis.
      test result updated.
  mysql-test/t/gis-precise.test
bug 839341 100% CPU usage with ST_UNION in maria-5.3-gis.
      test case added.
  sql/gcalc_tools.cc
bug 839341 100% CPU usage with ST_UNION in maria-5.3-gis.
      check if we get the beginning node of the linestring, then cut the loop.
2011-09-04 23:48:17 +05:00
Alexey Botchkov
eefff87652 bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
We didn't implement an empty geometry. And returning NULL instead of it is not
    quite correct. So here is the implementation of the empty value as GEOMETRYCOLLECTION().

per-file comments:
  mysql-test/r/gis-precise.result
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
    test result updated.

  mysql-test/r/gis.result
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
    test result updated.

  mysql-test/t/gis-precise.test
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
    test case added.

  mysql-test/t/gis.test
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
    test case added.

  sql/field.cc
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
    store GEOMETRYCOLLECTION() properly.

  sql/gcalc_tools.cc
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
    create the GEOMETRYCOLLECTION() for the empty result.

  sql/gstream.h
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
    next_symbol() added.

  sql/spatial.cc
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
    code modified to handle 0 geometries in the GEOMETRYCOLLECTION properly.
2011-09-04 19:11:04 +05:00
Sergey Petrunya
55cde3b428 BUG#836532: Crash in Item_equal_fields_iterator::get_curr_field with semijoin+materialization
- Item_in_subselect::inject_in_to_exists_cond() should not call 
  ((Item_cond*)join->conds)->argument_list()->concat(join->cond_equal->current_level)
  as that makes two lists share their tail, and the cond_equal list
  will end up containing non-Item_equal objects when substitute_for_best_equal_field()
  walks through join->conds and replaces all Item_equal objects with Item_func_eq objects.
  - So, instead of using List::concat(), manually copy entries from one list to another.
2011-09-04 16:35:37 +04:00
Sergey Petrunya
5be4148e58 BUG#834514: Assertion `!table || (!table->read_set || bitmap_is_set(...' with aggregates
- Make find_all_keys() not to rely on table->tmp_set remaining constant during execution
  quick_index_merge_select->reset() may change it.
2011-09-03 17:05:05 +04:00
Sergey Petrunya
28a7050912 BUG#836507: Crash in setup_sj_materialization_part1() with semijoin+materialization
- setup_sj_materialization() code failed to take into account that it can be that 
  the first [in join order ordering] table inside semi-join-materialization nest 
  is also an inner table wrt an outer join (that is embedded in the semi-join).  
  This can happen when all of the tables that are inside the semi-join but not inside
  the outer join are constant.
- Made a trivial to not assume that table's embedding join nest is the semi-join 
  nest: instead, walk up the outer join nests until we reach the semi-join nest.
2011-09-02 23:44:28 +04:00
Sergey Petrunya
da61ecccee BUG#836523: Crash in JOIN::get_partial_cost_and_fanout with semijoin+materialization
- Make JOIN::get_partial_cost_and_fanout() be able to handle join plans with 
  semi-join-materialization nests.
2011-09-02 22:43:35 +04:00
unknown
429a5557d8 Merge of merge 2011-09-02 15:36:02 +03:00
unknown
b152c4c71d Merge 5.2->5.3 2011-09-02 15:10:10 +03:00
Sergey Petrunya
f9d84e34e8 Merge 2011-09-02 14:32:48 +04:00
unknown
37a8497d49 LP BUG#823169 fix.
For ANY subqueries NULLs should be ignored (if there is other values) when finding max min.
For ALL subqueries NULLs should be saved if they found.

Optimisation for ALL suqbueries if NULL is possible in the SELECT list with max/min aggregate function switched off.

Some test changed where NULL is not used but optimization with max/min aggregate function important so NOT NULL added.

mysql-test/r/explain.result:
  Forced old optimization.
mysql-test/r/subselect.result:
  Forced old optimization.
  
  New test suite.
mysql-test/t/explain.test:
  Forced old optimization.
mysql-test/t/subselect.test:
  Forced old optimization.
  
  New test suite.
sql/item_subselect.cc:
  Store converted subquery type.
  
  Switch off aggregate function optimisation for ALL and nulls.
sql/sql_class.cc:
  Fixed NULL comparison.
sql/sql_class.h:
  Store converted subquery type.
2011-09-02 10:11:13 +03:00
Alexey Botchkov
c937b7588f bugs #801560 and #802194
tests added.

per-file comments:
  mysql-test/r/gis-precise.result
bugs #801560 and #802194
        test result updated.

  mysql-test/t/gis-precise.test
bugs #801560 and #802194
        test case added.
2011-09-02 09:38:17 +05:00
unknown
ea8aa32909 Fix for bug lp:834492
Analysis:
In the test query semi-join merges the inner-most subquery
into the outer subquery, and the optimization of the merged
subquery finds some new index access methods. Later the
IN-EXISTS transformation is applied to the unmerged subquery.
Since the optimizer is instructed to not consider
materialization, it reoptimizes the plan in-place to take into
account the new IN-EXISTS conditions. Just before reoptimization
JOIN::choose_subquery_plan resets the query plan, which also
resets the access methods found during the semi-join merge.
Then reoptimization discovers there are no new access methods,
but it leaves the query plan in its reset state. Later semi-join
crashes because it assumes these access methods are present.

Solution:
When reoptimizing in-place, reset the query plan only after new
access methods were discovered. If no new access methods were
discovered, leave the current plan as it was.
2011-09-01 23:53:12 +03:00
Sergei Golubchik
11ebbabb08 sec_to_time() in the integer context was losing the sign of the result 2011-09-01 14:23:03 +04:00
Alexey Botchkov
152f3c5e28 PostGIS-style 'same point' handling. 2011-09-01 11:44:56 +05:00
Norvald H. Ryeng
c6de8c8c05 Bug#11765254 - 58200: ASSERTION FAILED: PARAM.SORT_LENGTH WHEN
GROUPING BY FUNCTIONS.... (PART

The bug was introduced in a patch for bug 49897.

Problem: The assertion inserted by the original patch to guard against
zero-lenght sort keys during merge phase triggers also when the whole
set fits in memory.

Fix: Move assert so that it does not trigger if the whole set is in
memory.


mysql-test/r/group_by.result:
  Add test for bug#11765254
mysql-test/t/group_by.test:
  Add test for bug#11765254
sql/filesort.cc:
  Move assertion
2011-08-30 09:56:07 +02:00
Sergey Petrunya
2e6ae6ebf4 BUG##836491: Crash in Item_field::Item_field from add_ref_to_table_cond() with semijoin+materialization
- Let create_tmp_table set KEY_PART_INFO::fieldnr. It is needed in add_ref_to_table_cond(), and possibly other places.
2011-08-29 21:54:16 +04:00
Sergey Petrunya
945a595aa3 BUG#834534: Assertion `0' failed in replace_where_subcondition with semijoin subquery in HAVING
- The problem was that the code that made the check whether the subquery is an AND-part of the WHERE 
  clause didn't work correctly for nested subqueries. In particular, grand-child subquery in HAVING was 
  treated as if it was in the WHERE, which eventually caused an assert when replace_where_subcondition
  looked for the subquery predicate in the WHERE and couldn't find it there.

- The fix: Removed implementation of "thd_marker approach". thd->thd_marker was used to determine the 
  location of subquery predicate: setup_conds() would set accordingly it when making the 

    {where|on_expr}->fix_fields(...)

  call so that AND-parts of the WHERE/ON clauses can determine they are the AND-parts. 
  Item_cond_or::fix_fields(), Item_func::fix_fields(), Item_subselect::fix_fields (this one was missed),
  and all other items-that-contain-items had to reset thd->thd_marker before calling fix_fields() for 
  their children items, so that the children can see they are not AND-parts of WHERE/ON.
- The "thd_marker approach" required that a lot of code in different locations maintains correct value of
  thd->thd_marker, so it was replaced with:
- The new approach with mark_as_condition_AND_part does not keep context in thd->thd_marker. Instead, 
  setup_conds() now calls

    {where|on_expr}->mark_as_condition_AND_part()

  and implementations of that function make sure that: 
   - parts of AND-expressions get the mark_as_condition_AND_part() call
   - Item_in_subselect objects record that they are AND-parts of WHERE/ON
2011-08-29 19:57:41 +04:00
Michael Widenius
282c303746 Added MariaDB executable comment syntax: /*M!##### */
client/mysql.cc:
  Don't remove MariaDB executable comments.
mysql-test/r/comments.result:
  Test MariaDB executable comments.
mysql-test/r/mysql.result:
  Test MariaDB executable comments.
mysql-test/t/comments.test:
  Test MariaDB executable comments.
mysql-test/t/mysql.test:
  Test MariaDB executable comments.
sql/sql_cache.cc:
  Don't delete MariaDB executable comments.
sql/sql_lex.cc:
  Handle MariaDB executable comments
2011-08-29 18:14:14 +03:00
Tor Didriksen
f610c56587 BUG#12911710 - VALGRIND FAILURE IN ROW-DEBUG:PERFSCHEMA.SOCKET_SUMMARY_BY_INSTANCE_FUNC
Converting the number zero to binary and back yielded the number zero,
but with no digits, i.e. zero precision.
This made the multiply algorithm go haywire in various ways.


include/decimal.h:
  Document struct st_decimal_t
mysql-test/r/type_newdecimal.result:
  New test case (valgrind warnings)
mysql-test/t/type_newdecimal.test:
  New test case (valgrind warnings)
sql/my_decimal.h:
  Remove the HAVE_purify enabled/disabled code.
strings/decimal.c:
  Make a proper zero, with non-zero precision.
2011-08-29 11:24:36 +02:00
unknown
2df1914791 Fix bug lp:827416
Analysis:
Constant table optimization of the outer query finds that
the right side of the equality is a constant that can
be used for an eq_ref access to fetch one row from t1,
and substitute t1 with a constant. Thus constant optimization
triggers evaluation of the subquery during the optimize
phase of the outer query.

The innermost subquery requires a plan with a temporary
table because with InnoDB tables the exact count of rows
is not known, and the empty tables cannot be optimzied
way. JOIN::exec for the innermost subquery substitutes
the subquery tables with a temporary table.

When EXPLAIN gets to print the tables in the innermost
subquery, EXPLAIN needs to print the name of each table
through the corresponding TABLE_LIST object. However,
the temporary table created during execution doesn't
have a corresponding TABLE_LIST, so we get a null
pointer exception.

Solution:
The solution is to forbid using expensive constant
expressions for eq_ref access for contant table
optimization. Notice that eq_ref with a subquery
providing the value is still possible during regular
execution.
2011-08-27 00:40:29 +03:00
Sergey Vojtovich
9fb4a47ef4 Merge. 2011-08-24 11:18:00 +04:00
Mattias Jonsson
0fca226942 Bug#11766879/Bug#60106: DIFF BETWEEN # OF INDEXES IN MYSQL VS INNODB,
PARTITONING, ON INDEX CREATE

If the first partition succeeded in adding a index, but a successive partition failed,
then the first partition had still the new index.

The fix reverts the added indexes from previous partitions on failure.
2011-08-23 15:13:17 +02:00
unknown
ee28dec858 Automatic merge. 2011-08-23 15:51:47 +03:00
unknown
c1a6dbe5b2 Fixed bug lp:825018
Analysis:
During the first execution of the query through the stored
procedure, the optimization phase calls
substitute_for_best_equal_field(), which calls
Item_in_optimizer::transform(). The latter replaces
Item_in_subselect::left_expr with args[0] via assignment.
In this test case args[0] is an Item_outer_ref which is
created/deallocated for each re-execution. As a result,
during the second execution Item_in_subselect::left_expr
pointed to freed memory, which resulted in a crash.

Solution:
The solution is to use change_item_tree(), so that the
origianal left expression is restored after each execution.
2011-08-23 15:39:15 +03:00
unknown
9e60b55fd0 Fix bug lp:825095
Analysis:
Partial matching is used even when there are no NULLs in
a materialized subquery, as long as the left NOT IN operand
may contain NULL values.

This case was not handled correctly in two different places.
First, the implementation of parital matching did not clear
the set of matching columns when the merge process advanced
to the next row.

Second, there is no need to perform partial matching at all
when the left operand has no NULLs.

Solution:
First fix subselect_rowid_merge_engine::partial_match() to
properly cleanup the bitmap of matching keys when advancing
to the next row.

Second, change subselect_partial_match_engine::exec() so
that when the materialized subquery doesn't contain any
NULLs, and the left operand of [NOT] IN doesn't contain
NULLs either, the method returns without doing any
unnecessary partial matching. The correct result in this
case is in Item::in_value.
2011-08-23 00:00:13 +03:00
Sergei Golubchik
5dc1a2231f lp:822760 Wrong result with view + invalid dates
sql/sql_select.cc:
  items' cmp_type()'s must match, not result_type()'s
2011-08-22 13:38:32 +02:00
Igor Babaev
aab970f5e1 Fixed LP bug #826279.
When the WHERE/HAVING condition of a subquery has been transformed
by the optimizer the pointer stored the 'where'/'having' field 
of the SELECT_LEX structure used for the subquery must be updated
accordingly. Otherwise the pointer may refer to an invalid item.
This can lead to the reported assertion failure for some queries
with correlated subqueries
2011-08-19 21:02:05 -07:00
Sergey Vojtovich
a8ee6e48f7 BUG#11763712 - 56458: KILLING A FLUSH TABLE FOR A MERGE/CHILD
CRASHES SERVER

Flushing of MERGE table or one of its child tables, which was
locked by flushing thread using LOCK TABLES, might have caused
crashes or assertion failures if the thread failed to reopen
child or parent table.
Particularly, this might have happened when another connection
killed this FLUSH TABLE statement/connection.
Also this problem might have occurred when we failed to reopen
MERGE table or one of its children when executing DDL statement
under LOCK TABLES.

The problem was caused by the fact that reopen_tables() might
have failed to reopen child table but still tried to reopen,
reattach children for and re-lock its parent. Vice versa it
might have failed to reopen parent but kept references from
children to parent around. Since reopen_tables() closes table
it has failed to reopen and therefore frees all associated
memory such dangling references led to crashes when followed.

This patch solves this problem by ensuring that we always close
parent table and all its children if we fail to reopen this
table or one of its children. Same happens if we fail to reattach
children to parent.

Affects 5.1 only.

mysql-test/r/merge.result:
  A test case for BUG#11763712.
mysql-test/t/merge.test:
  A test case for BUG#11763712.
sql/sql_base.cc:
  When flushing tables under LOCK TABLES, all locked
  and flushed tables are released and then reopened.
  It may happen that we failed to reopen some tables,
  in this case we reopen as much tables as possible.
  
  If it was not possible to reopen MERGE child, MERGE
  parent is unusable and must be removed from thread
  open tables list.
  
  If it was not possible to reopen MERGE parent, all
  MERGE child table objects are unusable as well, at
  least because their locks are handled by MERGE parent.
  They must also be removed from thread open tables
  list.
  
  In other words if it was impossible to reopen any
  object of a MERGE table or reattach child tables,
  all objects of this MERGE table must be considered
  unusable and closed.
2011-08-18 10:38:51 +04:00
unknown
6b70cc538b Fix bug lp:813473
The bug is a duplicate of MySQL's Bug#11764086,
however MySQL's fix is incomplete for MariaDB, so
this fix is slightly different.

In addition, this patch renames
Item_func_not_all::top_level() to is_top_level_item()
to make it in line with the analogous methods of
Item_in_optimizer, and Item_subselect.

Analysis:
It is possible to determine whether a predicate is
NULL-rejecting only if it is a top-level one. However,
this was not taken into account for Item_in_optimizer.
As a result, a NOT IN predicate was erroneously
considered as NULL-rejecting, and the NULL-complemented
rows generated by the outer join were rejected before
being checked by the NOT IN predicate.

Solution:
Change Item_in_optimizer to be considered as
NULL-rejecting only if it a top-level predicate.
2011-08-17 14:10:32 +03:00
Sergey Petrunya
6321619496 Merge 2011-08-17 12:02:02 +04:00
Sergey Petrunya
e4bb53341f BUG#826935 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
- add_ref_to_table_cond() should not just overwrite pre_idx_push_select_cond
  with the contents tab->select_cond.
  pre_idx_push_select_cond exists precisely for the reason that it may contain
  a condition that is a strict superset of what is in tab->select_cond. 
  The fix is to inject generated equality into pre_idx_push_select_cond.
2011-08-17 11:57:01 +04:00
Igor Babaev
249a10c7dd Fixed LP bug #825035.
The value of maybe_null flag should be saved for the second execution
of a prepared statement from SELECT that uses an outer join.
2011-08-16 22:48:35 -07:00
Sergey Petrunya
3ed416ab1a Merge 2011-08-16 21:54:48 +04:00
Sergey Petrunya
c9494dc42d BUG#818280: crash in do_copy_not_null() in maria-5.3 with semijoin
- Make simplify_joins() set maybe_null=FALSE for tables that were on the 
  inner sides of inner joins and then were moved to the inner sides of semi-joins.
2011-08-16 21:42:25 +04:00
Igor Babaev
be03fe9c29 Fixed LP bug #824463.
When merging a view / derived table the function SELECT_LEX::merge_subquery
incorrectly updated the list SELECT_LEX::leaf_tables. Erroneously it
appended the leaf_tables list of the merged object L and then removed the
reference to the merged object T from the SELECT_LEX::leaf_tables list.
A correct implementation should insert the list L into the
SELECT_LEX::leaf_tables list in place of the element of the list that 
refers to T.
The bug could lead to wrong results or even crashes for queries with
nested outer joins over views / derived tables.
2011-08-15 23:18:36 -07:00
Michael Widenius
fb135f7ee5 Automatic merge with 5.2 2011-08-15 22:14:08 +03:00
unknown
d2206ad149 Fixed test results after the tests adding. 2011-08-12 14:31:40 +03:00
unknown
fede2ee7f1 Bug lp:781508: Take relevant test cases from MySQL 5.6 feature preview trees
Identified all test cases in the MySQL file subquery.inc that are
not present in MariaDB. This patch adds the test cases that are:
- not present in MySQL 5.5, and
- already fixed in MariaDB 5.3

The patch adds test cases for the following mysql-trunk bugs:
- Bug#12763207 - not a bug, mysql-trunk, added test case
- BUG#50257    - not a bug, mysql-trunk, added test case
- Bug 11765699 - not a bug, mysql-trunk, added test case
- BUG#12616253 - not a bug, mysql-trunk, added test case

The comparison was based on the following version of
  mysql-trunk:
  
  revno: 3350 [merge]
  committer: Marko Mäkelä <marko.makela@oracle.com>
  branch nick: mysql-trunk
  timestamp: Mon 2011-08-08 12:42:09 +0300
  message:
    Merge mysql-5.5 to mysql-trunk.
2011-08-12 11:39:29 +03:00
Igor Babaev
07e9d34c54 Added a test case for LP bug #823835 - a duplicate of bug 823189. 2011-08-11 22:34:41 -07:00
Igor Babaev
8b56830f7b Fixed LP bug #823189.
The method Item_ref::not_null_tables() returned incorrect bitmap
for outer references to view columns. This could cause an invalid
conversion of an outer join into an inner join that could lead
to a wrong result set for a query with a correlated subquery over
an outer join whose where condition had an outer reference to a view.
2011-08-11 20:24:32 -07:00
Igor Babaev
4ddea0cb93 Fixed LP bug #823826.
The method Item_func_isnull::update_used_tables() erroneously did not
update cached values stored in the fields used_tables_cache and
const_item_cache of the Item_func_isnull objects. As a result the
Item_func_isnull::used_tables() returned wrong bitmaps and, as a
consequence, push-down predicates could be attached to wrong tables.
2011-08-11 12:11:04 -07:00
Michael Widenius
397fc34f44 Fixes MySQL bug#48972: mysqldump --insert-ignore leaves set unique_checks=0.
This fixes a bug that when you use mysqldump --no-create-info to generate a dump that you want to merge with an existing table,
you can get an innodb table with duplicated unique keys.
Patch orignally by Eric Bergen.


client/mysqldump.c:
  Only use UNIQUE_CHECKS=0 for tables that are created.
  This solves the issue that you can't get duplicate unique keys when merging two dumps.
mysql-test/r/mysqldump.result:
  Test for mysqldump --no-create-info
2011-08-10 13:08:19 +03:00
unknown
209682577f Bug lp:781508: Take relevant test cases from MySQL 5.6 feature preview trees
Identified all test cases in the MySQL file subquery_mat.inc that are
not present in MariaDB. In total found 8 test cases for the following
MySQL bugs:
* BUG#49630 - not a bug in MariaDB, added test case
* BUG#52538 - not a bug in MariaDB, added test case (checked with VG)
* BUG#53103 - not a bug in MariaDB, added test case
* BUG#54511 - not a bug in MariaDB, added test case
* BUG#56367 - not a bug in MariaDB, added test case
* BUG#59833 - not a bug in MariaDB, added test case
* BUG#11852644 - not a bug in MariaDB, added test case
* BUG#12668294 - not a bug in MariaDB, added test case

All of these MySQL bugs are not present in MariaDB 5.3.

The comparison was based on the following version of
mysql-trunk:

revno: 3350 [merge]
committer: Marko Mäkelä <marko.makela@oracle.com>
branch nick: mysql-trunk
timestamp: Mon 2011-08-08 12:42:09 +0300
message:
  Merge mysql-5.5 to mysql-trunk.
2011-08-09 18:34:26 +03:00
Ramil Kalimullin
c7087cd53c Manual merge from mysql-5.1. 2011-08-09 11:42:07 +04:00
unknown
a6037394e3 Fix bug lp:817384
This bug is a special case of lp:813447.

Analysis:
Constant optimization finds that the condition t2.a = 1
can be used to access the primary key of table 't2'. As
a result both outer table t1,t2 are considered as constant
when we reach the execution phase. At the same time, during
constant optimization, the IN predicate is not evaluated
because it is expensive.

When execution of the outer query reaches do_select(),
control flow enter the branch:
if (join->table_count == join->const_tables)
{ ... }
This branch checks only the WHERE and HAVING clauses,
but doesn't check the ON clauses of the query. Since the
IN predicate was not evaluated during optimization, it is
not evaluated at all, thus execution doesn't detect that
the ON clause is FALSE.

Solution:
Similar to the patch for bug lp:813447, exclude system
tables from constant substitution based on unique key
lookups if there is an expensive ON condition on the
inner table.
2011-08-09 10:28:57 +03:00
Igor Babaev
b7e9713ee3 Fixed LP bug #819716.
Do not optimize derived table for the second time ever.
2011-08-08 22:02:10 -07:00
Tatjana Azundris Nuernberg
4cc0600342 merge 2011-08-08 13:17:01 +01:00
Sergey Petrunya
0e19f3e36f Backport of:
revno: 2876.47.174
revision-id: jorgen.loland@oracle.com-20110519120355-qn7eprkad9jqwu5j
parent: mayank.prasad@oracle.com-20110518143645-bdxv4udzrmqsjmhq
committer: Jorgen Loland <jorgen.loland@oracle.com>
branch nick: mysql-trunk-11765831
timestamp: Thu 2011-05-19 14:03:55 +0200
message:
  BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER 
                        AWAY QUALIFYING ROWS
        
  The problem was that the ranges created when OR'ing two 
  conditions could be incorrect. Without the bugfix, 
  "I <> 6 OR (I <> 8 AND J = 5)" would create these ranges:
  
  "NULL < I < 6",
  "6 <= I <= 6 AND 5 <= J <= 5",
  "6 < I < 8",
  "8 <= I <= 8 AND 5 <= J <= 5",
  "8 < I"
  
  While the correct ranges is
  "NULL < I < 6",
  "6 <= I <= 6 AND 5 <= J <= 5",
  "6 < I"
  
  The problem occurs when key_or() ORs
  (1) "NULL < I < 6, 6 <= I <= 6 AND 5 <= J <= 5, 6 < I" with 
  (2) "8 < I AND 5 <= J <= 5"
  
  The reason for the bug is that in key_or(), SEL_ARG *tmp is 
  used to point to the range in (1) above that is merged with 
  (2) while key1 points to the root of the red-black tree of 
  (1). When merging (1) and (2), tmp refers to the "6 < I" 
  part whereas the root is the "6 <= ... AND 5 <= J <= 5" part. 
  
  key_or() decides that the tmp range needs to be split into
  "6 < I < 8, 8 <= I <= 8, 8 < I", in which next_key_part of the 
  second range should be that of tmp. However, next_key_part is
  set to key1->next_key_part ("5 <= J <= 5") instead of 
  tmp->next_key_part (empty). Fixing this gives the correct but
  not optimal ranges:
  "NULL < I < 6",
  "6 <= I <= 6 AND 5 <= J <= 5",
  "6 < I < 8",
  "8 <= I <= 8",
  "8 < I"
  
  A second problem can be seen above: key_or() may create 
  adjacent ranges that could be replaced with a single range. 
  Fixes for this is also included in the patch so that the range
  above becomes correct AND optimal:
  "NULL < I < 6",
  "6 <= I <= 6 AND 5 <= J <= 5",
  "6 < I"
  
  Merging adjacent ranges like this gives a slightly lower cost 
  estimate for the range access.
2011-08-05 22:01:49 +04:00
Sergey Glukhov
3468b55a21 Bug#11766594 59736: SELECT DISTINCT.. INCORRECT RESULT WITH DETERMINISTIC FUNCTION IN WHERE C
There is an optimization of DISTINCT in JOIN::optimize()
which depends on THD::used_tables value. Each SELECT statement
inside SP resets used_tables value(see mysql_select()) and it
leads to wrong result. The fix is to replace THD::used_tables
with LEX::used_tables.


mysql-test/r/sp.result:
  test case
mysql-test/t/sp.test:
  test case
sql/sql_base.cc:
  THD::used_tables is replaced with LEX::used_tables
sql/sql_class.cc:
  THD::used_tables is replaced with LEX::used_tables
sql/sql_class.h:
  THD::used_tables is replaced with LEX::used_tables
sql/sql_insert.cc:
  THD::used_tables is replaced with LEX::used_tables
sql/sql_lex.cc:
  THD::used_tables is replaced with LEX::used_tables
sql/sql_lex.h:
  THD::used_tables is replaced with LEX::used_tables
sql/sql_prepare.cc:
  THD::used_tables is replaced with LEX::used_tables
sql/sql_select.cc:
  THD::used_tables is replaced with LEX::used_tables
2011-08-02 11:33:45 +04:00
Igor Babaev
103c4461ca Fixed LP bug #817360.
This problem could be observed for queries with nested outer joins
for which the not_exist optimization were applicable. 
The problem was caused by the code of the patch for bug #49322
that erroneously forced the return to the previous nested loop
level when the join algorithm successfully builds a partial record
for an embedded outer to which the not_exist optimization could be
applied.
Actually the immediate return to the previous nested loops level
is correct only if this partial record is rejected by a predicate
pushed down to one of the inner tables of this outer join. Otherwise
attempts to find extensions of this record must be made.
2011-07-29 17:09:16 -07:00
Sergey Glukhov
3050742dd9 Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0,
The problem is that TIME_FUZZY_DATE is explicitly used for get_arg0_date()
function in Item_date_typecast::get_date method. The fix is to use real
fuzzy_date value.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  use real fuzzy_date value
2011-07-27 12:34:25 +04:00
Igor Babaev
668eb2b55e Removed settings of 'derived_merge' to 'on' in ps tests. 2011-07-22 23:47:28 -07:00
Igor Babaev
2092436457 Merge. 2011-07-21 15:55:08 -07:00
Igor Babaev
63abf00a62 Made the optimizer switches 'derived_merge' and 'derived_with_keys'
off by default.
2011-07-21 14:23:08 -07:00
unknown
813aaac51d Fix for LP BUG#806071
In case of two views with subqueries it is dificult to decide about order of injected ORDER BY clauses.
A simple solution is just prohibit ORDER BY injection if there is other order by.

mysql-test/r/view.result:
  New test added, old test changed.
mysql-test/t/view.test:
  New test aded.
sql/share/errmsg.txt:
  new warning added.
sql/sql_view.cc:
  Inject ORDER BY only if there is no other one.
  
  Warning about ignoring ORDER BY in this case for EXPLAIN EXTENDED.
2011-07-21 23:37:40 +03:00
Sergey Petrunya
c86ffc23ee BUG#803457: Wrong result with semijoin + view + outer join in maria-5.3-subqueries-mwl90
- Correct handling of outer joins + DuplicateWeedout (docs pending)
2011-07-21 19:14:34 +04:00
unknown
ef2b4b14e1 Merge from 5.2 2011-07-21 15:50:25 +03:00
unknown
f675536aa4 Merge 5.1->5.2 2011-07-21 13:15:09 +03:00
unknown
ee06e4d65e Removed incorrect fix and its test suite (the test suit is duplicate).
Fixed explains of previous patch.

mysql-test/r/explain.result:
  Fixed explains of previous patch.
mysql-test/r/join_outer.result:
  Fixed explains of previous patch.
mysql-test/r/negation_elimination.result:
  Fixed explains of previous patch.
mysql-test/r/view.result:
  Fixed explains of previous patch.
mysql-test/suite/innodb/r/innodb_mysql.result:
  Removed duplicate test suite.
mysql-test/suite/innodb/t/innodb_mysql.test:
  Removed duplicate test suite.
mysql-test/suite/innodb_plugin/r/innodb_mysql.result:
  Removed duplicate test suite.
mysql-test/suite/innodb_plugin/t/innodb_mysql.test:
  Removed duplicate test suite.
sql/opt_range.h:
  Removed incorrect fix.
sql/records.cc:
  Removed incorrect fix.
2011-07-21 12:29:00 +03:00
unknown
20a2e1d0ac Fix of LP BUG#777809
There are 2 volatile condition constructions AND/OR constructions and fields(references) when first
good supported to be top elements of conditions because it is normal practice
(see copy_andor_structure for example) fields without any expression in the condition is really rare
and mostly useless case however it could lead to problems when optimiser changes/moves them unaware
of other variables referring to them. An easy solution of this problem is just to replace single field
in a condition with equivalent expression well supported by the server (<field> -> <field> != 0).

mysql-test/r/view.result:
  New test added.
mysql-test/t/view.test:
  New test added.
sql/sql_parse.cc:
  <field> -> <field> != 0
sql/sql_yacc.yy:
  <field> -> <field> != 0
2011-07-21 11:20:55 +03:00
Igor Babaev
4a03a1d777 Fixed LP bug #813447.
Do not make substitution of a single-row table if it is an inner
table of an outer join with on expression containing an expensive
subquery.
2011-07-21 00:43:37 -07:00
Igor Babaev
2e8542f462 Fixed LP bug #791761.
An aggregating query over an empty set of a join of two tables
with a rejecting HAVING clause erroneously could return a row.
It could happen in the cases when the optimizer made a conclusion
that the aggregating set was empty.
Wrong results were produced because the server missed initial
setting for aggregation functions in the mentioned cases.
2011-07-20 21:55:55 -07:00
Igor Babaev
6dc1cdc205 Merge. 2011-07-20 16:49:36 -07:00
Igor Babaev
57f4965f36 Fixed LP bug #702301.
The function matching_cond should take into account that
there may be always false constant conjunctive conditions
that has not been evaluated yet,for example, conjunctive
conditions with non-correlated subqueries.
2011-07-20 16:09:28 -07:00
unknown
2b6a23447b Fix of LP BUG#780386.
ALL subquery should return TRUE if subquery rowa set is empty independently
of left part.  The problem was that Item_func_(eq,ne,gt,ge,lt,le) do not
call execution of second argument if first is NULL no in this case subquery
will not be executed and when Item_func_not_all calls any_value() of the
subquery or aggregation function which report that there was rows. So for
NULL < ALL (SELECT...) result was FALSE instead of TRUE.

Fix is just swapping of arguments of Item_func_(eq,ne,gt,ge,lt,le) (with
changing the operation if it is needed) so that result will be the same
(for examole a < b is equal to b > a). This fix exploit the fact that
first argument will be executed in any case.

mysql-test/r/subselect.result:
  The test suite added.
mysql-test/r/subselect_no_mat.result:
  The test suite added.
mysql-test/r/subselect_no_opts.result:
  The test suite added.
mysql-test/r/subselect_no_semijoin.result:
  The test suite added.
mysql-test/r/subselect_scache.result:
  The test suite added.
mysql-test/t/subselect.test:
  The test suite added.
sql/item_cmpfunc.cc:
  Swap arguments creation methods added.
sql/item_cmpfunc.h:
  Swap arguments creation methods added.
sql/item_subselect.cc:
  Swap arguments of the comparison.
2011-07-20 21:48:41 +03:00
Sergey Petrunya
837c6722ed Merge fix for BUG##806524 2011-07-20 11:21:30 +04:00
Sergey Petrunya
b11eff4025 BUG##806524: Assertion `join->best_read < 1.7976931348623157e+308 with table_elimination=on and derived_merge=on
reset_nj_counters() used to rely on the fact that join nests have 
table->table==NULL. This ceased to be true wit new derived table
optimizations. Use test for table->nested_join!=NULL instead.
2011-07-20 01:31:40 +04:00
unknown
99cce18955 Fixed LP BUG#800696.
The problem was that optimizer removes some outer references (it they are
constant for example) and the list of outer items built during prepare phase is
not actual during execution phase when we need it as the cache parameters.
First solution was use pointer on pointer on outer reference Item and
initialize temporary table on demand. This solved most problem except case
when optimiser also reduce Item which contains outer references ('OR' in
this bug test suite).

The solution is to build the list of outer reference items on execution
phase (after optimization) on demand (just before temporary table creation)
by walking Item tree and finding outer references among Item_ident
(Item_field/Item_ref) and Item_sum items.

Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs).

Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future).

mysql-test/r/subselect_cache.result:
  A new test added.
mysql-test/r/subselect_scache.result:
  Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result).
mysql-test/t/subselect_cache.test:
  Added a new test.
sql/item.cc:
  depends_on removed.
  
  Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references.
  
  Item_cache_wrapper collect parameters befor initialization of its cache.
sql/item.h:
  depends_on removed.
  
  Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references.
sql/item_cmpfunc.cc:
  depends_on removed.
  
  Added processor (collect_outer_ref_processor) to collect outer references.
sql/item_cmpfunc.h:
  Added processor (collect_outer_ref_processor) to collect outer references.
sql/item_subselect.cc:
  depends_on removed.
  Added processor get_cache_parameters() method to collect outer references.
sql/item_subselect.h:
  depends_on removed.
  Added processor get_cache_parameters() method to collect outer references.
sql/item_sum.cc:
  Added processor (collect_outer_ref_processor) method to collect outer references.
sql/item_sum.h:
  Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references.
sql/opt_range.cc:
  depends_on removed.
sql/sql_base.cc:
  depends_on removed.
sql/sql_class.h:
  New iterator added.
sql/sql_expression_cache.cc:
  Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done).
sql/sql_expression_cache.h:
  Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done).
sql/sql_lex.cc:
  depends_on removed.
sql/sql_lex.h:
  depends_on removed.
sql/sql_list.h:
  Added add_unique method to add only unique elements to the list.
sql/sql_select.cc:
  Support of new Item list added.
sql/sql_select.h:
  Support of new Item list added.
2011-07-19 23:19:10 +03:00
Sergey Petrunya
5df875b02b BUG#803303: Wrong result with semijoin=on, outer join in maria-5.3-subqueries-mwl90
- Add testcase.
2011-07-19 22:22:40 +04:00
Sergey Petrunya
775ac38dcd Buildbot fixes: add --sorted-result 2011-07-19 13:48:16 +04:00
Sergey Petrunya
265b51df73 Merge 2011-07-19 11:45:46 +04:00
Igor Babaev
cfc7896461 Merge. 2011-07-18 23:21:48 -07:00
unknown
c9e236828e Fix bug lp:782305
Analysis:
Both the wrong result and the valgrind warning were a result
of incomplete cleanup of the MIN/MAX subquery rewrite. At the
first execution of the query, the non-aggregate subquery is
transformed into an aggregate MIN/MAX subquery. During the
fix_fields phase of the MIN/MAX function, it sets the property
st_select_lex::with_sum_func to true.

The second execution of the query finds this flag to be ON.
When optimization reaches the same MIN/MAX subquery
transformation, it tests if the subquery is an aggregate or not.
Since select_lex->with_sum_func == true from the previous
execution, the transformation executes the second branch that
handles aggregate subqueries. This substitutes the subquery
Item into a Item_maxmin_subselect. At the same time elsewhere
it is assumed that the subquery Item is of type
Item_allany_subselect. Ultimately this results in casting the
actual object to the wrong class, and calling the wrong
any_value() method from empty_underlying_subquery().

Solution:
Cleanup the st_select_lex::with_sum_func property in the case
when the MIN/MAX transformation was performed for a non-aggregate
subquery, so that the transformation can be repeated.
2011-07-18 23:45:38 +03:00
Tor Didriksen
cdb8bb981c automerge 5.0->security => 5.1-security 2011-07-18 09:08:19 +02:00
Tor Didriksen
1b18b486de Bug#12406055 post-push fix: ignore float output 2011-07-18 09:06:59 +02:00
Igor Babaev
a7287d9ae1 Fixed LP bug #793448.
This bug could lead to wrong result sets for a query over a
materialized derived table or view accessed by a multi-component
key.
It happened because the function get_next_field_for_derived_key
was supposed to update its argument, and it did not do it.
2011-07-17 23:12:31 -07:00
Igor Babaev
cc0195d6a1 Merge with the latest 5.3 code. 2011-07-17 00:52:07 -07:00
Igor Babaev
d37465a9cc Fixed LP bug #794901.
Also:
1. simplified the code of the function mysql_derived_merge_for_insert.
2. moved merge of views/dt for multi-update/delete to the prepare stage.
3. the list of the references to the candidates for semi-join now is
   allocated in the statement memory.
2011-07-16 23:57:43 -07:00
Tor Didriksen
93915d0d50 merge 5.0-security => 5.1-security 2011-07-15 14:08:14 +02:00
Tor Didriksen
cfcd49b467 Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REAL
The buffer was simply too small.
In 5.5 and trunk, the size is 311 + 31,
in 5.1 and below, the size is 331


client/sql_string.cc:
  Increase buffer size in String::set(double, ...)
include/m_string.h:
  Increase FLOATING_POINT_BUFFER
mysql-test/r/type_float.result:
  New test cases.
mysql-test/t/type_float.test:
  New test cases.
sql/sql_string.cc:
  Increase buffer size in String::set(double, ...)
sql/unireg.h:
  Move definition of FLOATING_POINT_BUFFER
2011-07-15 14:07:38 +02:00
unknown
c1b6eb1490 Merge of subquery cache off by default. 2011-07-15 12:16:46 +03:00
unknown
af284b55f0 Make subquery cache off by default.
mysql-test/r/subselect_scache.result:
  Test with subquery cache on.
mysql-test/t/subselect_scache.test:
  Test with subquery cache on.
2011-07-15 11:36:36 +03:00
unknown
06fb641c0b Automatic merge. 2011-07-15 09:17:22 +03:00
Igor Babaev
03081bc1fd Changed the default setting of the optimizer switch 'optimize_join_buffer_size'.
Made it 'off' by default.
2011-07-14 22:24:59 -07:00
Sergey Petrunya
0aaae1e31d Test result update forgotten in pre-previous cset. 2011-07-15 03:34:00 +04:00
Sergey Petrunya
56a23357ae BUG#803457: Wrong result with semijoin + view + outer join in maria-5.3-subqueries-mwl90
(This is not a real fix for this bug, even though it makes it to no longer repeat)
- Semi-join subquery predicates, i.e. ... WHERE outer_expr IN (SELECT ...) may have null-rejecting properties,
  may allow to convert outer joins into inner.
- When convert_subq_to_sj() injected IN-equality into parent's WHERE/ON clause, it didn't call 
  $new_cond->top_level_item(), which would cause null-rejecting properties to be lost.
- Fixed, now the mentioned outer-to-inner conversion will really take place.
2011-07-15 02:58:34 +04:00
unknown
445fcaa81a MWL#68 efficient partial matching
- Added an initial set of feature-specific test cases
- Handled the special case where the materialized subquery of an
  IN predicates consists of only NULL values.
- Fixed a bug where making Item_in_subselect a constant,
  didn't respect its null_value value.
2011-07-15 00:23:57 +03:00
Sergey Petrunya
932d516656 Merge 2011-07-14 20:06:46 +04:00
Sergey Petrunya
2a9c86be26 BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
- Make {ha_myisam,ha_maria}::index_read_idx_map check pushed index condition.
- Address review feedback (added comments)
2011-07-14 17:44:37 +04:00
unknown
53681ee5db Fix bug lp:777691
Analysis:

For some of the re-executions of the correlated subquery the
where clause is false. In these cases the execution of the
subquery detects that it must generate a NULL row because of
implicit grouping. In this case the subquery execution reaches
the following code in do_select():

        while ((table= li++))
          mark_as_null_row(table->table);

This code marks all rows in the table as complete NULL rows.
In the example, when evaluating the field t2.f10 for the second
row, all bits of Field::null_ptr[0] are set by the previous call
to mark_as_null_row(). Then the call to Field::is_null()
returns true, resulting in a NULL for the MAX function.

Thus the lines above are not suitable for subquery re-execution
because mark_as_null_row() changes the NULL bits of each table
field, and there is no logic to restore these fields.

Solution:

The call to mark_as_null_row() was added by the fix for bug
lp:613029. Therefore removing the fix for lp:613029 corrects
this wrong result. At the same time the test for lp:613029
behaves correctly because the changes of MWL#89 result in a
different execution path where:
- the constant subquery is evaluated via JOIN::exec_const_cond
- detecting that it has an empty result triggers the branch
  if (zero_result_cause)
    return_zero_rows()
- return_zero_rows() calls mark_as_null_row().
2011-07-14 12:53:00 +03:00
unknown
c4097382ef Automatic merge. 2011-07-14 10:22:18 +03:00
Igor Babaev
ff9c406c1d Fixed LP bug #809179.
The attribute not_null_tables could be calculated incorrectly in the
function SELECT_LEX::update_used_tables for queries over views 
with row items in the WHERE clause. It happened because no 
implementation of the virtual callback function eval_not_null_tables
was provided for the class Item_row.
Also slightly optimized the code calculating the value of the maybe_null
flag for tables in the function SELECT_LEX::update_used_tables.
2011-07-13 21:06:28 -07:00
Sergey Petrunya
85571ea76c Disable LooseScan and FirstMatch when outer joins are present. 2011-07-14 01:53:05 +04:00
unknown
1e6bd6b4df Fix bug lp:809266
Analysis:
This is a bug in MWL#68, where it was incorrectly assumed
that if there is a match in the only non-null key, then
if there is a covering NULL row on all remaining NULL-able
columns there is a partial match. However, this is not the case,
because even if there is such a null-only sub-row, it is not
guaranteed to be part of the matched sub-row. The matched sub-row
and the NULL-only sub-row may be parts of different rows.

In fact there are two cases:
- there is a complete row with only NULL values, and
- all nullable columns contain only NULL values.

These two cases were incorrectly mixed up in the class member
  subselect_partial_match_engine::covering_null_row_width.


Solution:
The solution is to:
- split covering_null_row_width into two members:
  has_covering_null_row, and has_covering_null_columns, and
- take into account each state during initialization and
  execution.
2011-07-14 00:15:07 +03:00
unknown
61eb3423b4 Merged the fix for bug lp:608744 2011-07-13 17:11:46 +03:00
unknown
990584d73a Fixed bug lp:809245
In addition to the bug fix explained below, the patch performs
few renames, and adds some comments to avoid similar problems.

Analysis:
The failed assert was due to a bug in MWL#68, where it was
incorrectly assumed that the size of the bitmap
subselect_rowid_merge_engine::null_only_columns should be
the same as the size of the array of Ordered_keys.

The bitmap null_only_columns contains bits to mark columns
that contain only NULLs. Therefore the indexes of the bits
to be set in null_only_columns are different from the indexes
of the Ordered_keys. If there is a NULL-only column that appears
in a table after the last partial match column with Ordered_key,
this NULL-only column would require setting a bit with index
bigger than the size of the bitmap null_only_columns.

Accessing such a bit caused the failed assert.

Solution:
Upon analysis, it turns out that null_only_columns is not needed
at all, because we are looking for partial matches, and having
such columns guarantees that there is a partial match for any
corresponding outer value.

Therefore the patch removes
  subselect_rowid_merge_engine::null_only_columns.
2011-07-13 17:09:09 +03:00
Sergey Petrunya
bf28449803 Update test results for previous cset 2011-07-13 16:49:52 +04:00
Alexey Botchkov
90c4df7a4a Fix for bug #804266 Memory corruption/valgrind warning/crash in move_hole() with ST_UNION.
Second smaller hole in the polygon got link to the bigger one as it's the
        outer ring. Fixed by specifying the outer ring explicitly.


per-file comments:
  mysql-test/r/gis-precise.result
Fix for bug #804266 Memory corruption/valgrind warning/crash in move_hole() with ST_UNION.
        test result updated.

  mysql-test/t/gis-precise.test
Fix for bug #804266 Memory corruption/valgrind warning/crash in move_hole() with ST_UNION.
        test case added.

  sql/gcalc_tools.cc
Fix for bug #804266 Memory corruption/valgrind warning/crash in move_hole() with ST_UNION.
        specify the outer ring explicitly in the get_polygon_result parameter.

  sql/gcalc_tools.h
Fix for bug #804266 Memory corruption/valgrind warning/crash in move_hole() with ST_UNION.
        add the outer ring as a parameter to the get_polygon_result.
2011-07-13 14:57:27 +05:00
Igor Babaev
5819dfcdf6 Fixed LP bug #809206.
The bitmap of used tables must be evaluated for the select list of every
materialized derived table / view and saved in a dedicated field.
This is also applied to materialized subqueries.
2011-07-12 23:47:35 -07:00
Sergey Petrunya
419c20f10a Merge 2011-07-12 13:02:19 +04:00
Alexey Botchkov
e7c9f52fd9 Fix for bug #801217 Assertion `t1->result_range' in Gcalc_operation_reducer::end_couple.
We cannot cut a line from a polygon. So if the polygon fits the condition, and
        the intersection of a line and the polygon doesn't, we just skip the line.
        That rule wasn't applied if the line start was inside the polygon, which leaded
        to the assertion.

per-file comments:
  mysql-test/r/gis-precise.result
Fix for bug #801217 Assertion `t1->result_range' in Gcalc_operation_reducer::end_couple.
        test result updated.
  mysql-test/t/gis-precise.test
Fix for bug #801217 Assertion `t1->result_range' in Gcalc_operation_reducer::end_couple.
        test case added.
  sql/gcalc_tools.cc
Fix for bug #801217 Assertion `t1->result_range' in Gcalc_operation_reducer::end_couple.
        Don't mark the line as a border if it's inside a polygon that fits the result condition.
2011-07-12 11:21:20 +05:00
Tatjana Azundris Nuernberg
083a316d1f Bug#11758414/Bug#50614: Default storage_engine not honored when set from within a stored procedure
When CREATE TABLE wasn't given ENGINE=... it would determine
the default ENGINE at parse-time rather than at execution
time, leading to incorrect behaviour (namely, later changes
to the default engine being ignore) when calling CREATE TABLE
from a stored procedure.

We now defer working out the default engine till execution of
CREATE TABLE.


mysql-test/r/sp_trans.result:
  results!
mysql-test/t/sp_trans.test:
  Show that CREATE TABLE (called from store routine) heeds
  any changes after CREATE SP / parse-time. Show that explicitly
  requesting an ENGINE still works.
sql/sql_parse.cc:
  If no ENGINE=... was given at parse-time, determine default
  engine at execution time of CREATE TABLE.
sql/sql_yacc.yy:
  If CREATE TABLE is not given ENGINE=..., don't bother
  figuring out the default engine during parsing; we'll
  do it at execution time instead to be aware of the
  latest updates.
2011-07-12 06:08:52 +01:00
Igor Babaev
6e5413853e Merge with the latest 5.3 code. 2011-07-11 14:00:44 -07:00
Sergey Petrunya
2c28412e2e Port of code for: (part of testcase is in mysql-test/t/subquery*.test and will be ported separately)
Bug#11766642: crash in Item_field::register_field_in_read_map 
              with view

(Former 59793)

Prior to the refactoring in this patch, Item_cond_xor behaved 
partially as an Item_cond and partially as an Item_func. The
reasoning behind this was that XOR is currently not optimized
(thus should be Item_func instead of Item_cond), but it was 
planned optimize it in the future (thus, made Item_cond anyway 
to ease optimization later). 

Even though Item_cond inherits from Item_func, there are 
differences between these two. One difference is that the 
arguments are stored differently. Item_cond stores them in a 
list while Item_func store them in an args[]. 

BUG no 45221 was caused by Item_cond_xor storing arguments in 
the list while users of the objects would look for them in 
args[]. The fix back then was to store the arguments in both 
locations.

In this bug, Item_cond_xor initially gets two Item_field 
arguments. These are stored in the list inherited from 
Item_cond and in args[] inherited from Item_func. During
resolution, find_field_in_view() replaces the Item_fields 
stored in the list with Item_direct_view_refs, but args[] 
still points to the unresolved Item_fields. This shows that 
the fix for 45221 was incorrect.

The refactoring performed in this patch removes the confusion
by making the XOR item an Item_func period. A neg_transformer() 
is also implemented for Item_func_xor to improve performance 
when negating XOR expressions. An XOR is negated by negating 
one of the operands.
2011-07-11 23:48:35 +04:00
Igor Babaev
47aee19827 Fixed LP bug #793386.
Auto-generated names for view field items must be allocated in
the statement memory, not in the execution memory of the statement.
2011-07-11 10:56:48 -07:00
Tor Didriksen
08ecbd5adb Bug#11765255 - 58201: VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS
We must allocate a larger ref_pointer_array. We failed to account for extra
items allocated here:
#0  find_order_in_list 
  uint el= all_fields.elements;
  all_fields.push_front(order_item); /* Add new field to field list. */
  ref_pointer_array[el]= order_item;
  order->item= ref_pointer_array + el;
#1  setup_order
#2  setup_without_group
#3  JOIN::prepare


mysql-test/r/order_by.result:
  New test case.
mysql-test/r/union.result:
  New test case.
mysql-test/t/order_by.test:
  New test case.
mysql-test/t/union.test:
  New test case.
sql/sql_lex.cc:
  find_order_in_list() may need some extra space, so multiply og_num by two.
sql/sql_union.cc:
  For UNION, the 'n_sum_items' are accumulated in the "global_parameters" select_lex.
  This number must be propagated to setup_ref_array()
  
  When preparing a 'fake_select_lex' we need to use global_parameters->order_list
  rather than fake_select_lex->order_list (see comments inside st_select_lex_unit::cleanup)
2011-07-11 11:20:19 +02:00
Igor Babaev
f8db35bd15 Fixed LP bug #806504.
Missing initialization of the bitmap not_null_tables_cache to 0 
in the function Item_func::eval_not_null_tables caused this bug.
This function is called indirectly from the function
SELECT_LEX::update_used_tables after merging mergeable views and
derived tables into the main query. The leaf tables of resulting
query may change their bitmap numbers after this merge. That's why
the not_null_tables_cache bitmaps must be updated. Due to the bug 
mentioned above the result of the re-evaluation of the 
not_null_tables_cache turned out to be incorrect in some cases.
This could trigger an invalid conversion of outer joins into 
inner joins leading to invalid query result sets.

Also removed an implicit conversion from int to bool in the function
SELECT_LEX::update_used_tables.
2011-07-10 17:19:45 -07:00
Igor Babaev
a515802c5b Fixed LP bug #806097.
The value of THD::used tables should be re-evaluated after merges
of views and derived tables into the main query. 
Now it's done in the function SELECT_LEX::update_used_tables.
The re-evaluation of the 'used_table' bitmaps for the items
in HAVING, GROUP BY and ORDER BY clauses has been added as well.
2011-07-09 22:34:56 -07:00
Sergey Petrunya
a4f5e01475 Merge @@optimizer_switch default settings changes into 5.3 2011-07-09 11:20:15 +04:00
Igor Babaev
ae7ed5adf2 Merge. 2011-07-08 16:42:59 -07:00
Igor Babaev
5ead4083ec Fixed LP bug #806510.
The bug was caused by an incorrect code of the function
Item_direct_view_ref::replace_equal_field introduced in the
patch for bugs 717577, 724942. The function erroneously
returned the wrapped field instead of the Item_direct_view_ref
object itself in the cases when no replacement happened.

The bug masked two other minor bugs that could result in not
quite correct output of the EXPLAIN command for some queries.
They were fixed in the patch as well.
2011-07-08 16:39:28 -07:00
Sergey Petrunya
834bdfa1c8 Update test results for previous csets. 2011-07-08 22:01:02 +04:00
Sergey Petrunya
2d325b3cc2 Forgot to add these two files when setting semijoin=off by default:
- Scavenged subquery tests from testcases other than t/subselect*.test and put them into single file
2011-07-08 18:49:53 +04:00
Sergey Petrunya
1492de8563 Set the default to be mrr=off,mrr_sort_keys=off:
- Set the default
- Adjust the testcases so that 'new' tests are run with optimizations turned on.
- Pull out relevant tests from "irrelevant" tests and run them with optimizations on.
- Run range.test and innodb.test with both mrr=on and mrr=off
2011-07-08 18:46:47 +04:00
Alexey Botchkov
67e937095c Fix for bug #804259 Second assertion in Gis_geometry_collection::init_from_opresult.
A polygon has no right to have holes that are actually points.
        So just skip them when we collect the result of an operation.

per-file comments:
  mysql-test/r/gis-precise.result
Fix for bug #804259 Second assertion in Gis_geometry_collection::init_from_opresult.
        test result updated.
  mysql-test/t/gis-precise.test
Fix for bug #804259 Second assertion in Gis_geometry_collection::init_from_opresult.
        test case added.
  sql/gcalc_tools.cc
Fix for bug #804259 Second assertion in Gis_geometry_collection::init_from_opresult.
        Skip the point in the result if it's the hole inside a polygon.
2011-07-08 15:38:15 +05:00
unknown
d43063939c Merge test cases for bugs that were fixed by MWL#89. 2011-07-08 10:56:46 +03:00
unknown
e98aecc2e0 Test for bug lp:611382
The bug itself has been fixed by MWL#89.
2011-07-08 10:51:53 +03:00
unknown
57432d0c64 Test case for bug lp:611396
The bug itself has been fixed by MWL#89.
2011-07-08 08:52:30 +03:00
Igor Babaev
f222a51340 Merge. 2011-07-07 13:06:40 -07:00
Igor Babaev
e55e78eeda Fixed LP bug #806477.
The offending query returns a wrong result set because the optimizer
erroneously eliminated the where condition evaluated it to TRUE.
The cause of this wrong transformation was that the flag maybe_null
for an inner table of the outer join was not set to TRUE after the 
table had replaced the wrapping view.
Now the function SELECT_LEX::update_used_tables resets the value
of the maybe_null flag for each leaf table of the query after all
merges of views have been done.
2011-07-07 13:04:48 -07:00
Alexey Botchkov
e182ae27cd Fix for bug #805860 Second assertion Assertion `n > 0 && n < SINUSES_CALCULATED*2+1' in get_n_sincos.
Just typo-style mistake. Should be '||' instead of '&&'.

per-file comments:
  mysql-test/r/gis-precise.result
Fix for bug #805860 Second assertion Assertion `n > 0 && n < SINUSES_CALCULATED*2+1' in get_n_sincos.
        test result updated.
  mysql-test/t/gis-precise.test
Fix for bug #805860 Second assertion Assertion `n > 0 && n < SINUSES_CALCULATED*2+1' in get_n_sincos.
        test case added.
  sql/item_geofunc.cc
Fix for bug #805860 Second assertion Assertion `n > 0 && n < SINUSES_CALCULATED*2+1' in get_n_sincos.
        condition fixed.
2011-07-07 21:30:51 +05:00
unknown
0f36ab3a52 Test for bug lp:612543
The bug itself has been fixed by MWL#89.
2011-07-07 17:22:28 +03:00
unknown
5f5cbf7684 Test case for bug lp:611690
The bug itself has been fixed by MWL#89.
2011-07-07 17:07:13 +03:00
unknown
4128ec4852 Fix bug lp:806943
Analysis:
This bug is yet another incarnation of the generic problem
where optimization of the outer query triggers evaluation
of a subquery, and this evaluation performs a destructive
change to the subquery plan. Specifically a temp table is
created for the DISTINCT operation that replaces the
original subquery table. Later, select_describe() attempts
to print the table name, however, there is no corresponding
TABLE_LIST object to the internal temp table, so we get a
crash. Execution works fine because it is not interested in
the corresponding TABLE_LIST object (or its name).

Solution:
Similar to other such bugs, block the evaluation of expensive
Items in convert_const_to_int().
2011-07-07 16:28:26 +03:00
Alexey Botchkov
13f6e1119f Fix for bug #804324 Assertion 0 in Gcalc_scan_iterator::pop_suitable_intersection
There were actually two bugs. One was when the line that intersects itself
        the intersection point treated as it doesn't belong to the line.
        Second when edges partly coincide, wrong result produced when we try to find their
        intersection.


per-file comments:
  mysql-test/r/gis-precise.result
Fix for bug #804324 Assertion 0 in Gcalc_scan_iterator::pop_suitable_intersection
        test result updated.

  mysql-test/t/gis-precise.test
Fix for bug #804324 Assertion 0 in Gcalc_scan_iterator::pop_suitable_intersection
        test case added.

  sql/gcalc_slicescan.cc
Fix for bug #804324 Assertion 0 in Gcalc_scan_iterator::pop_suitable_intersection
        skip the intersection if it just line that intersects itself.

  sql/gcalc_tools.cc
Fix for bug #804324 Assertion 0 in Gcalc_scan_iterator::pop_suitable_intersection
        if edges coincide, just pick the first coinciding poing as an intersection.
2011-07-07 16:59:45 +05:00
Georgi Kodinov
c298dad7fd weave merge of mysql-5.1->mysql-5.1-security 2011-07-07 14:27:26 +03:00
Igor Babaev
b79316f583 Fixed LP bug #806431.
The function generate_derived_keys_for_table incorrectly handled
the cases when a materialized view or derived table could be accessed
by different keys on the same fields if these keys depended on the
same tables.
2011-07-06 17:24:42 -07:00
unknown
db36ce1de0 Merge the fix for bug lp:802979 2011-07-06 17:27:38 +03:00
Sergey Petrunya
a5a8683f70 # BUG#611704: Crash in replace_where_subcondition with nested subquery and semijoin=on
- SELECT_LEX::merge_subquery should not set "(*in_subq)->emb_on_expr_nest= derived" for subqueries that 
  are in the ON expressions of semi-joins.
2011-07-06 10:21:31 +04:00
Karen Langford
f6398a86dd Merge from mysql-5.1.58-release 2011-07-06 00:56:51 +02:00
Sergey Petrunya
9e95a54793 Merge fix for BUG#803365 2011-07-05 21:48:50 +04:00
Sergey Petrunya
05d54b121c BUG#803365: Crash in pull_out_semijoin_tables with outer join + semijoin + derived tables in maria-5.3 with WL#106
- Don't perform table pullout out of semi-join nests that have nested outer joins.
2011-07-05 21:22:13 +04:00
Alexey Botchkov
f3b850a7b5 bug #804305 Crash in wkb_get_double with ST_INTERSECTION.
That crash happened with the complicated topology of the result.
        If we found a hole in a polygon whose outside border was already
        found, we need to paste the hole right after it and respectively
        shift polygons after it. Also we need to update poly_position fields
        in these polygons. That last thing wasn't properly done that led to the
        crash.
        To fix that we keep the list of the found polygons and update the
        poly_positions that are bigger or equal to where we placed the next hole.


per-file comments:
  mysql-test/r/gis-precise.result
bug #804305 Crash in wkb_get_double with ST_INTERSECTION.
        test result updated.
  mysql-test/t/gis-precise.test
bug #804305 Crash in wkb_get_double with ST_INTERSECTION.
        test result added.
  sql/gcalc_tools.cc
bug #804305 Crash in wkb_get_double with ST_INTERSECTION.
        keep the list of the found polygons and update their poly_position fields respectively.
  sql/gcalc_tools.h
bug #804305 Crash in wkb_get_double with ST_INTERSECTION.
        Gcalc_result_receiver::move_hole interface changed.
2011-07-05 19:42:35 +05:00
unknown
d93b4c5394 MWL#163 lp:798213: Remove the --innodb-release-locks-early feature.
The bug lp:798213 exposes a design flaw in --innodb-release-locks-early.
It does not work with InnoDB crash recovery, so it breaks transactional
integrety. So remove the feature.
2011-07-05 15:28:15 +02:00
Sergey Petrunya
c1de6f8b77 Change the default @@optimizer_switch setting from
semijoin=on,firstmatch=on,loosescan=on
to
  semijoin=off,firstmatch=off,loosescan=off
Adjust the testcases:
- Modify subselect*.test and join_cache.test so that all tests
  use the same execution paths as before (i.e. optimizations that
  are being tested are enabled)
- Let all other test files run with the new default settings (i.e.
  with new optimizations disabled)
- Copy subquery testcases from these files into t/subselect_extra.test
  which will run them with new optimizations enabled.
2011-07-05 01:44:15 +04:00
unknown
59784abead Fix LP bug lp:802979
Analysis:
This bug consists of two related problems that are
result of too early evaluation of single-row subqueries
during the optimization phase of the outer query.

Several optimizer code paths try to evaluate single-row
subqueries in order to produce a constant and use that
constant for further optimzation.

When the execution of the subquery peforms destructive
changes to the representation of the subquery, and these
changes are not anticipated by the subsequent optimization
phases of the outer query, we tipically get a crash or
failed assert.

Specifically, in this bug the inner-most suqbuery with
DISTINCT triggers a substitution of the original JOIN
object by a single-table JOIN object with a temp table
needed to perform the DISTINCT operation (created by
JOIN::make_simple_join).

This substitution breaks EXPLAIN because:
a) in the first example JOIN::cleanup no longer can
reach the original table of the innermost subquery, and
close all indexes, and
b) in this second test query, EXPLAIN attempts to print
the name of the internal temp table, and crashes because
the temp table has no name (NULL pointer instead).

Solution:
a) fully disable subquery evaluation during optimization
in all cases - both for constant propagation and range
optimization, and
b) change JOIN::join_free() to perform cleanup irrespective
of EXPLAIN or not.
2011-07-04 14:51:16 +03:00
Alexey Botchkov
7f55ea1211 fix for bug #801212 Assertion with ST_INTERSECTION on NULL values
The ::val_str() method has to return NULL if it calculated
        the null_value, not just set the related flag.

per-file comments:
  mysql-test/r/gis-precise.result
fix for bug #801212 Assertion with ST_INTERSECTION on NULL values
        test result updated.
  mysql-test/t/gis-precise.test
fix for bug #801212 Assertion with ST_INTERSECTION on NULL values
        test case added.
  sql/item_geofunc.cc
fix for bug #801212 Assertion with ST_INTERSECTION on NULL values
        return NULL from the val_str if we get the null_value.
2011-07-04 16:17:34 +05:00
Alexey Botchkov
0e6c889c83 bug #801199 Infinite recursion in Gcalc_function::count_internal with ST_BUFFER over MULTIPOINT
Collections were treated mistakenly, so the counter for the final UNION operation
        received the wrong value.
        As a fix we implement Item_func_buffer::Transporter::start_collection() method,
        where we set the proper operation and the operand counter.
        start_poly() and start_line() were also modified to function correctly for the 
        polygon as a part of a collection.

per-file comments:
  mysql-test/r/gis-precise.result
bug #801199 Infinite recursion in Gcalc_function::count_internal with ST_BUFFER over MULTIPOINT
        test result updated.

  mysql-test/t/gis-precise.test
bug #801199 Infinite recursion in Gcalc_function::count_internal with ST_BUFFER over MULTIPOINT
        test case added.

  sql/item_geofunc.cc
bug #801199 Infinite recursion in Gcalc_function::count_internal with ST_BUFFER over MULTIPOINT
        start_collection() implemented.

  sql/item_geofunc.h
bug #801199 Infinite recursion in Gcalc_function::count_internal with ST_BUFFER over MULTIPOINT
        Item_func_buffer::Transporter::start_collection() defined.
2011-07-04 16:03:36 +05:00
Igor Babaev
3f7d51d0d8 Fixed LP bug #804686.
The assert conditions in the functions Item_direct_ref_to_ident::transform
and Item_direct_ref_to_ident::compile could be not valid after constant
propagation when fields and field references may be substituted for constants.
Not only these invalid asserts have been removed, but the functions containing
them have been removed as well because now Item_ref::transform and 
Item_ref::compile can be used instead of them.
2011-07-03 14:59:01 -07:00
Michael Widenius
ec3c26a515 Fixed compilation & test issues found by buildbot
include/Makefile.am:
  Added missing \
mysql-test/mysql-test-run.pl:
  Suppress warning when ha_archive is not compiled
mysql-test/r/variables-big.result:
  Updated results
2011-07-02 17:37:59 +03:00
Igor Babaev
006dedf537 Fixed LP bug #804515.
If no index is used to access a materialized derived table or view
then the value of TABLE_REF::key for this table must be (-1).
2011-07-01 21:53:47 -07:00
Michael Widenius
8318ef14af Automatic merge 2011-07-01 15:35:34 +03:00
Michael Widenius
3c78bfe7f1 Added progress reporting for alter table, LOAD DATA INFILE and for aria tables: check table, repair table, analyze table.
- The client gets a progress report message that triggers a callback function if requested with mysql_options(MYSQL_PROGRESS_CALLBACK, function)
- Added Progress field last to 'show processlist'
- Stage, Max_stage and Progress field added to information_schema.progresslist
- The 'mysql' client by defaults enables progress reports when the output is a tty.
- Added progress_report_time time variable to configure how often progress reports is sent to client
Added read only system variable 'in_transaction' which is 1 if we have executed a BEGIN statement.


client/client_priv.h:
  Added OPT_REPORT_PROGRESS
client/mysql.cc:
  Added option --progress-reports (on by default if not batch mode)
  Progress reports is written to stdout for long running commands
include/Makefile.am:
  Added mysql/service_progress_report.h
include/myisamchk.h:
  Added variables to be able to do progress reporting in Aria and later in MyISAM
include/mysql.h:
  Added new mysql_options() parameter: MYSQL_PROGRESS_CALLBACK
include/mysql.h.pp:
  Added new mysql_options() parameter: MYSQL_PROGRESS_CALLBACK
include/mysql/plugin.h:
  Added functions for reporting progress.
include/mysql/plugin_auth.h.pp:
  Added functions for reporting progress.
include/mysql_com.h:
  Added CLIENT_PROGRESS mysql_real_connect() flag.
include/sql_common.h:
  Added callback function for reporting progress
mysql-test/r/old-mode.result:
  Ensure that SHOW PROGRESSLIST doesn't have the Progress column in old mode.
mysql-test/suite/funcs_1/datadict/datadict_priv.inc:
  Added new column
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
  Test all new PROCESSLIST columns
mysql-test/suite/funcs_1/r/is_columns_is.result:
  Updated results
mysql-test/suite/funcs_1/r/is_columns_is_embedded.result:
  Updated results
mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result:
  Updated results
mysql-test/suite/funcs_1/r/is_tables_is_embedded.result:
  Updated results
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
  Updated results
mysql-test/suite/funcs_1/r/processlist_priv_ps.result:
  Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
  Updated results
mysql-test/suite/funcs_1/r/processlist_val_ps.result:
  Updated results
mysql-test/suite/pbxt/r/pbxt_locking.result:
  Updated results
mysql-test/suite/pbxt/r/skip_name_resolve.result:
  Updated results
mysql-test/t/old-mode.test:
  Ensure that SHOW PROGRESSLIST doesn't have the Progress column in old mode.
plugin/handler_socket/handlersocket/Makefile.am:
  Added -lmysqlservices
scripts/mytop.sh:
  Made 'State' field width dynamic.
  Added 'Progress' to process list display.
sql-common/client.c:
  Added handling of progress messages.
  Removed check_license() function.
sql/mysql_priv.h:
  Added opt_progress_report_time
sql/mysqld.cc:
  Added progress_report_time time variable to configure how often progress reports is sent to client
sql/protocol.cc:
  Added net_send_progress_packet()
sql/protocol.h:
  New prototypes
sql/set_var.cc:
  Added variables progress_report_time and in_transaction
sql/sql_acl.cc:
  Safety fix: Made client_capabilities ulonglong
sql/sql_class.cc:
  Added interface functions for progress reporting
sql/sql_class.h:
  Added varibles in THD for progress reporting.
  Added CF_REPORT_PROGRESS
sql/sql_load.cc:
  Added progress reporting for LOAD DATA INFILE
sql/sql_parse.cc:
  Added CF_REPORT_PROGRESS for top level commands for which it's safe to send progress reports to client
sql/sql_show.cc:
  Added Progress field last to 'show processlist'
  Stage, Max_stage and Progress field added to information_schema.progresslist
sql/sql_table.cc:
  Added progress reporting for ALTER TABLE
  Added THD as argument to copy_data_between_tables()
storage/maria/ha_maria.cc:
  Added progress reporting for check table, repair table, analyze table
  Fixed a bug in start_bulk_insert() that caused alter table to always run with all keys enabled.
storage/maria/ma_check.c:
  Added progress reporting
  Remember old state before starting repair. This removes some warnings from optimize_table if create-with-sort fails.
storage/maria/ma_check_standalone.h:
  Added dummy reporting function for standalone Aria programs.
storage/maria/ma_sort.c:
  Added progress reporting
storage/maria/maria_chk.c:
  Updated version
storage/maria/maria_def.h:
  Added new prototypes
tests/mysql_client_test.c:
  Added test case for progress reporting
2011-07-01 15:08:30 +03:00
Sergey Petrunya
1ecfc9551c Merge first chunk of OJ+SJ fixes into 5.3 2011-07-01 12:45:45 +04:00
Sergei Golubchik
5a9ba869a6 Added read only system variable 'in_transaction' which tells if there's
an active transaction.

fixed a bug - not clearing "in transaction" status on set @@autocommit=1
2011-07-01 10:20:11 +02:00
Igor Babaev
584954ab6e Fixed LP bug #803851.
The function generate_derived_keys_for_table should set the value of
the number of keys for the derived table to 0 before it starts 
generating key definitions for the table. It's important as the
function can be called twice by the optimizer for a derived table
if the query contains a subquery to which the IN-EXIST transformation
is applicable.

Fixed a valgrind complain.
2011-06-30 19:32:19 -07:00
Sergey Petrunya
e2eafc3bd1 Fix buildbot failures:
- JOIN::prepare would have set JOIN::table_count to incorrect value (bad merge of MWL 106)
- optimize_keyuse() would use table-bit as table number
  (the change in optimize_keyuse is also the reason for query plan changes. Not 
   expected to have much effect because only handles cases of no index statistics)
- st_select_lex::register_dependency_item() ignored the fact that some of the 
  selects on the dependency paths could have been merged to their parents (because they 
  were mergeable VIEWs)
- Undo the incorrect fix in Item_subselect::recalc_used_tables(): do not call 
  fix_after_pullout() for Item_subselect::Ref_to_outside members.
2011-06-30 20:49:11 +04:00
Alexey Botchkov
a9a6597d59 fix for bug #201189 ST_BUFFER asserts if radius = 0.
Internal caclucations can't handle zero distance properly.
        As the ST_BUFFER(geom, 0) is in fact NOOP, we'll just return the
        'geom' as the result here.

per-file comments:
  mysql-test/r/gis-precise.result
fix for bug #201189 ST_BUFFER asserts if radius = 0.
        test result updated.

  mysql-test/t/gis-precise.test
fix for bug #201189 ST_BUFFER asserts if radius = 0.
        test case added.

  sql/item_geofunc.cc
fix for bug #201189 ST_BUFFER asserts if radius = 0.
        return the first argument as the result of the ST_BUFFER, if
        the distance is 0 there.
2011-06-30 19:24:52 +05:00
Alexey Botchkov
4f49cdf8d3 fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION
If the result contains a polygon with a hole, consequitive shapes weren't calculated
        properly, as the hole appeared as shape in the result, but actually it's a single shape
        with the surrounding polygon. It's more natural to use the size of the result as
        a border instead of the number of resulting shapes.

per-file comments:
  mysql-test/r/gis-precise.result
fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION 
        test result updated.
  mysql-test/t/gis-precise.test
fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION 
        test case added.
  sql/spatial.cc
fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION 
        check the data lenght instead of number of shapes.
  sql/spatial.h
fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION 
        check the data lenght instead of number of shapes.
2011-06-30 18:18:27 +05:00
Igor Babaev
55165f5174 Fixed LP bug #802845.
If the expression for a derived table contained a clause LIMIT 0
SELECT from such derived table incorrectly returned a non-empty set.

Fixed by ensuring JOIN::do_send_rows to be updated after the call
of st_select_lex_unit::set_limit that sets the value of 
JOIN::unit->select_limit_cnt.
2011-06-29 20:07:24 -07:00
Igor Babaev
bd62c82380 Fixed LP bug #803410.
Due to this bug in the function generate_derived_keys_for_table some
key definitions to access materialized derived tables or materialized
views were constructed with invalid info for their key parts.
This could make the server crash when it optimized queries using 
materialized derived tables or materialized views.
2011-06-29 16:05:16 -07:00
Sergey Petrunya
f30b4a0ded lp:802965: Crash in do_copy_not_null with semijoin=on in maria-5.3
- The crash was because a NOT NULL table column inside the subquery was considered NULLable
  because the code thought it was on the inner side of an outer join nest.
- Fixed by making correct distinction between tables inside outer join nests and inside semi-join nests.
2011-06-29 15:07:28 +04:00
Sergey Petrunya
1aede4d1c8 Merge 2011-06-29 11:52:26 +04:00
Igor Babaev
a853c7dd18 Merge. 2011-06-28 19:56:30 -07:00
Igor Babaev
31edda66fd Fixed LP bug #802860.
This crashing bug could manifest itself at execution of join queries
over materialized derived tables with IN subquery predicates in the
where clause. If for such a query the optimizer chose to use duplicate
weed-out with duplicates in a materialized derived table and chose to
employ join cache the the execution could cause a crash of the server.
It happened because the JOIN_CACHE::init method assumed  that the value
of TABLE::file::ref is set at the moment when the method was called 
for the employed join cache. It's true for regular tables, but it's 
not true for materialized derived tables that are filled now at the
first access to them, i.e. after the JOIN_CACHE::init has done its job.

To fix this problem for any ROWID field of materialized derived table
the procedure that copies fields from record buffers into the employed
join buffer first checks whether the value of TABLE::file::ref has 
been set for the table, and if it's not so the procedure sets this value.
2011-06-28 18:31:54 -07:00
Sergey Petrunya
4493197125 Followup to previous commit:
- Update test results
- Fix a problem with PS: 
   = convert_subq_to_sj() should not save where to prep_where or on_expr to prep_on_expr.
   = After an unmerged subquery predicate has been pulled, it should call fix_after_pullout() for 
     outer_refs.
2011-06-28 17:42:10 +04:00
unknown
78fa331eaa Fixed bug lp:800679
Analysis:
  The failed assert ensured that the choice of subquery strategy
  is performed only for queries with at least one table. If there
  is a LIMIT 0 clause all tables are removed, and the subquery is
  neither optimized, nor executed during actual optimization. However,
  if the query is EXPLAIN-ed, the EXPLAIN execution path doesn't remove
  the query tables if there is a LIMIT 0 clause. As a result, the
  subquery optimization code is called, which violates the ASSERT
  condition.
  
Solution:
  Transform the assert into a condition, and if the outer query
  has no tables assume that there will be at most one subquery
  execution.
  
  There is potentially a better solution by reengineering the
  EXPLAIN/optimize code, so that subquery optimization is not
  done if not needed. Such a solution would be a lot bigger and
  more complex than a bug fix.
2011-06-28 15:48:44 +03:00
Sergey Petrunya
95cba1043e BUG#751484: Valgrind warning / sporadic crash in evaluate_join_record sql_select.cc:14099 with semijoin
- Added testcase. The bug is most likely fixed by MWL#90 code.
2011-06-28 11:11:26 +04:00
Igor Babaev
5ce5e8db92 Merge 2011-06-27 23:36:20 -07:00
Igor Babaev
9c4a3ced11 Fixed LP bug #800535.
The function create_view_field in some cases incorrectly set the maybe_null
flag for the returned items.
2011-06-27 23:07:46 -07:00
Sergey Petrunya
a28c8a3cf7 Merge semi-join+outer-join fixes into 5.3 2011-06-27 23:40:58 +04:00
Michael Widenius
ba9a890f0c New status variables: Rows_tmp_read, Handler_tmp_update and Handler_tmp_write
Split status variable Rows_read to Rows_read and Rows_tmp_read so that one can see how much real data is read.
Same was done with with Handler_update and Handler_write.
Fixed bug in MEMORY tables where some variables was counted twice.
Added new internal handler call 'ha_close()' to have one place to gather statistics.
Fixed bug where thd->open_options was set to wrong value when doing admin_recreate_table()


mysql-test/r/status.result:
  Updated test results and added new tests
mysql-test/r/status_user.result:
  Udated test results
mysql-test/t/status.test:
  Added new test for temporary table status variables
sql/ha_partition.cc:
  Changed to call ha_close() instead of close()
sql/handler.cc:
  Added internal_tmp_table variable for easy checking of temporary tables.
  Added new internal handler call 'ha_close()' to have one place to gather statistics.
  Gather statistics for internal temporary tables.
sql/handler.h:
  Added handler variables internal_tmp_table, rows_tmp_read.
  Split function update_index_statistics() to two.
  Added ha_update_tmp_row() for faster tmp table handling with more statistics.
sql/item_sum.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/multi_range_read.cc:
  close() -> ha_close()
sql/mysqld.cc:
  New status variables: Rows_tmp_read, Handler_tmp_update and Handler_tmp_write
sql/opt_range.cc:
  close() -> ha_close()
sql/sql_base.cc:
  close() -> ha_close()
sql/sql_class.cc:
  Added handling of rows_tmp_read
sql/sql_class.h:
  Added new satistics variables.
  rows_read++  ->  update_rows_read() to be able to correctly count reads to internal temp tables.
  Added handler::ha_update_tmp_row()
sql/sql_connect.cc:
  Added comment
sql/sql_expression_cache.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/sql_select.cc:
  close() -> ha_close()
  ha_update_row() -> ha_update_tmp_row()
sql/sql_show.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/sql_table.cc:
  Fixed bug where thd->open_options was set to wrong value when doing admin_recreate_table()
sql/sql_union.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/sql_update.cc:
  ha_write_row() -> ha_write_tmp_row()
sql/table.cc:
  close() -> ha_close()
storage/heap/ha_heap.cc:
  Removed double counting of statistic variables.
  close -> ha_close() to get tmp table statistics.
storage/maria/ha_maria.cc:
  close -> ha_close() to get tmp table statistics.
2011-06-27 19:07:24 +03:00
Sergey Petrunya
c25728cdd9 More semi-join + outer-join testcases. 2011-06-27 19:15:29 +04:00
Igor Babaev
77f8874c8b Fixed LP bug #802023.
Made mergeable views and mergeable derived tables transparent for
the MIN/MAX optimization.
2011-06-25 14:02:27 -07:00
Igor Babaev
c68020210f Added test cases for LP bug #798625 and LP bug #800085
fixed by the patch for LP bug 798621.
2011-06-24 21:18:20 -07:00
Igor Babaev
37bac085da Fixed LP bug #799499.
The following were missing in the patch for mwl106:
- KEY_PART_INFO::fieldnr were not set for generated keys to access
  tmp tables storing the rows of materialized derived tables/views
- TABLE_SHARE::column_bitmap_size was not set for tmp tables storing
  the rows of materialized derived tables/views.
These could cause crashes or memory overwrite.
2011-06-24 18:42:14 -07:00
Igor Babaev
fb22eb1391 Fixed LP bug #798576.
If a view/derived table is non-mergeable then the definition of the tmp table
to store the rows for it is created at the prepare stage. In this case if the
view definition uses outer joins and a view column belongs to an inner table
of one of them then the column should be considered as nullable independently
on nullability of the underlying column. If the underlying column happens to be
defined as non-nullable then the function create_tmp_field_from_item rather 
than the function create_tmp_field_from_field should be employed to create
the definition of the interesting column in the tmp table.
2011-06-24 14:38:53 -07:00
Sergey Petrunya
7880039fc0 Merge 5.2 -> 5.3
(testcase for #798597 now crashes)
2011-06-24 21:43:31 +04:00
Sergey Petrunya
d3fc669535 Merge semi-join+outer join fixes into 5.3 2011-06-24 13:21:16 +04:00
Michael Widenius
66b3e82953 Merge with 5.1 2011-06-24 12:13:03 +03:00
Michael Widenius
6a9ac86cd3 Fix for bug lp:798597 Incorrect "Duplicate entry" error with views and GROUP BY
mysql-test/r/join.result:
  Test case for LP:798597
mysql-test/t/join.test:
  Test case for LP:798597
sql/sql_select.cc:
  In simplify_joins we reset table->maybe_null for outer join tables that can't ever be NULL.
  This caused a conflict between the previously calculated items and the group_buffer against the fields
  in the temporary table that are created as not null thanks to the optimization.
  The fix is to correct the group by items to also be not_null so that they match the used fields and keys.
2011-06-24 10:08:09 +03:00
Igor Babaev
3cf0d6f446 Fixed LP bug #800518.
The function simple_pred did not take into account that a multiple equality
could include ref items (more exactly items of the class Item_direct_view_ref).
It caused crashes for queries over derived tables or views if the
min/max optimization could be applied to these queries.
2011-06-23 14:48:45 -07:00
Sergey Petrunya
ed54ec7eb5 Make semi-joins work with outer joins:
- evaluate_null_complemented_join_record() should perform FirstMatch checks.
2011-06-22 15:22:27 +04:00
Sergey Petrunya
eea95a15d3 Make semi-joins work with outer joins part #2:
- Do make the DuplicateWeedout check for outer joins.
2011-06-22 14:33:11 +04:00
Sergey Petrunya
038be98979 BUG#600958 RQG: Crash in optimize_semijoin_nests
- Testcase.
2011-06-22 14:17:01 +04:00
Igor Babaev
1f6b32bc37 Merge 2011-06-21 18:17:28 -07:00
Igor Babaev
e7578ac612 Fixed LP bug #798621.
The patch for bugs 717577 and 724942 has missed to make adjustments for the
call item_equal->add_const(const_item, orig_field_item) in the function
check_simple_equality that builds multiple equality for a field and a constant.
As a result, when this field happens to be a view field and the corresponding
Item_field object F is wrapped in an Item_direct_view_ref object R the object
F is placed in the multiple equality instead of the object R.
A substitution of an equal item for F potentially can cause very serious
problems and in some cases can lead to crashes of the server.
2011-06-21 18:00:58 -07:00
Sergey Petrunya
6adddca80e Make semi-joins work with outer joins part #1:
- Make make_outerjoin_info() correctly process semi-join nests
- Make make_join_select() attach conditions to the right places.
2011-06-22 01:57:28 +04:00
unknown
e1d734f383 MWL#89
Removed forgotten EXPLAIN EXTENDED from the test file.
2011-06-21 23:01:01 +03:00
Sergei Golubchik
135ce0ba6c lp:790513 MariaDB crashes on startup
initialize plugins earlier, to support, for example, non-MyISAM mysql.plugin table.
2011-06-21 17:40:51 +02:00
unknown
44570d2b12 MWL#89
Automerged with 5.3.
2011-06-21 16:00:41 +03:00
unknown
a02682abcc MWL#89
- Added regression test with queries over the WORLD database.
- Discovered and fixed several bugs in the related cost calculation
  functionality both in the semijoin and non-semijon subquery code.
- Added DBUG printing of the cost variables used to decide between
  IN-EXISTS and MATERIALIZATION.
2011-06-21 15:50:07 +03:00
Alexey Botchkov
b826c88841 gis-related tests fixes.
merging.
2011-06-20 00:21:41 +05:00
Sergey Petrunya
a0973ba22e Merge fix for BUG#778406. 2011-06-17 17:45:41 +04:00
Georgi Kodinov
bad47ac671 auto-merge of mysql-5.1->mysql-5.1-security 2011-06-16 12:21:53 +03:00
Igor Babaev
078b59f5bc Merge of mwl #106 into 5.3. 2011-06-15 21:48:38 -07:00
Sergey Petrunya
bce51cebcb BUG#778406: Crash in hp_movelink with Aria engine and subqueries
-In  do_sj_dups_weedout(), set nulls_ptr to point to NULL bytes (and not to length bytes) of the DuplicateWeedout column.
2011-06-15 18:37:01 +04:00
Sergey Petrunya
a9d73e093a BUG#761598: Update .result file 2011-06-15 17:40:18 +04:00
Sergey Petrunya
0d7fcf2380 BUG#598247: partition.test produces valgrind errors in 5.3-based branches
- Testcase
2011-06-15 16:02:32 +04:00
Sergey Petrunya
b0f423c5d3 BUG#761598: InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock() in maria-5.3
- Testcase
2011-06-15 15:32:24 +04:00
Sergey Petrunya
ff3aa60d2b BUG#751439 Assertion `!table->file || table->file->inited == handler::NONE' failed with subquery
- Add testcase
2011-06-15 13:43:04 +04:00
Sergei Golubchik
54d0ec5732 fix for cast of negative numbers to datetime 2011-06-14 18:45:14 +02:00
Alexey Botchkov
9d51588e95 Precision spatial function tests added. 2011-06-14 11:20:48 +05:00
Igor Babaev
56eb6d7e69 Fixed LP bug #794890.
Changed the code that processing of multi-updates and multi-deletes
with multitable views at the prepare stage.

A proper solution would be: never to perform any transformations of views
before and at the prepare stage. Yet it would  require re-engineering
of the code that checks privileges and updatability of views.
Ultimately this re-engineering has to be done to provide a clean solution
for INSERT/UPDATE/DELETE statements that use views.

Fixed a valgrind problem in the function TABLE::use_index.
2011-06-13 19:03:03 -07:00
Mattias Jonsson
44aa582bb3 merge 2011-06-13 11:09:56 +02:00
Michael Widenius
ff0b30219f Updated to new error messages for partitions when .par file is missing 2011-06-11 14:53:08 +03:00
Michael Widenius
9f6f04360a Merge with Sergei's tree to get in latest microsecond patches and also fixes to innodb_plugin. 2011-06-11 12:04:42 +03:00
Sergey Petrunya
b6437d7dbf BUG#727183: WL#90 does not trigger with non-comma joins
- Add a testcase (the bug has already been fixed)
2011-06-10 12:45:43 +04:00
Sergei Golubchik
10fedf675a change test_if_equality_guarantees_uniqueness()
from an ad hoc set of limitations
to a correct rule
2011-06-10 10:14:20 +02:00
Dmitry Shulga
1fea8c1b90 Fixed bug#11753738 (formely known as bug#45235) - 5.1 DOES NOT SUPPORT 5.0-ONLY
SYNTAX TRIGGERS IN ANY WAY

Table with triggers which were using deprecated (5.0-only) syntax became
unavailable for any DML and DDL after upgrade to 5.1 version of server.
Attempt to execute any statement on such a table resulted in parsing
error reported. Since this included DROP TRIGGER and DROP TABLE
statements (actually, the latter was allowed but was not functioning
properly for such tables) it was impossible to fix the problem without
manual operations on .TRG and .TRN files in data directory.

The problem was that failure to parse trigger body (due to 5.0-only
syntax) when opening trigger file for a table prevented the table
from being open. This made all operations on the table impossible
(except DROP TABLE which due to peculiarity in its implementation
dropped the table but left trigger files around).

This patch solves this problem by silencing error which occurs when
we parse trigger body during table open. Error message is preserved
for the future use and table is marked as having a broken trigger.
We also try to analyze parse tree to recover trigger name, which
will be needed in order to drop the broken trigger. DML statements
which invoke triggers on the table marked as having broken trigger
are prohibited and emit saved error message. The same happens for
DDL which change triggers except DROP TRIGGER and DROP TABLE which
try their best to do what was requested. Table becomes no longer
marked as having broken trigger when last such trigger is dropped.

mysql-test/r/trigger-compat.result:
  Add results for test case for bug#45235
mysql-test/t/trigger-compat.test:
  Add test case for bug#45235.
sql/sp_head.cc:
  Added protection against MEM_ROOT double restoring to
  sp_head::restore_thd_mem_root() method. Since this
  method can be sometimes called twice during parsing
  of stored routine (the first time during normal flow
  of parsing, and the second time when a syntax error
  is detected) we need to shortcut execution of the
  method to avoid damaging MEM_ROOT by the second
  consecutive call to this method.
sql/sql_trigger.cc:
  Added error handler Deprecated_trigger_syntax_handler to 
  catch non-OOM errors during parsing of trigger body.
  
  Added handling of parse errors into method 
  Table_triggers_list::check_n_load().
sql/sql_trigger.h:
  Added new members to handle broken triggers and error messages.
2011-06-10 10:52:39 +07:00
Igor Babaev
ab411f8f1c Fixed LP bug #794909.
The function generate_derived_keys did not take into account the fact
that the last element in the array of keyuses could be just a barrier
element. In some cases it could lead to a crash of the server.

Also fixed a couple of other bugs in generate_derived_keys: the inner 
loop in the body of if this function did not change the cycle variables
properly.
2011-06-09 12:43:28 -07:00
Dmitry Shulga
53e4a85204 Follow-up for patch of bug#11764334. 2011-06-10 01:05:10 +07:00
Dmitry Shulga
fa913a0b98 Fixed bug#11764334 (formerly bug#57156): ALTER EVENT CHANGES
THE EVENT STATUS.

Any ALTER EVENT statement on a disabled event enabled it back
(unless this ALTER EVENT statement explicitly disabled the event).

The problem was that during processing of an ALTER EVENT statement
value of status field was overwritten unconditionally even if new
value was not specified explicitly. As a consequence this field
was set to default value for status which corresponds to ENABLE.

The solution is to check if status field was explicitly specified in
ALTER EVENT statement before assigning new value to status field.

mysql-test/r/events_bugs.result:
  test's result for Bug#11764334 was added.
mysql-test/t/events_bugs.test:
  new test for Bug#11764334 was added.
sql/event_db_repository.cc:
  mysql_event_fill_row() was modified: set value for status field
  in events tables only in case if statement CREATE EVENT
  is being processed or if this value was set in ALTER EVENT
  statement.
  Event_db_repository::create_event was modified: removed redundant
  setting of status field after return from call to mysql_event_fill_row().
sql/event_parse_data.h:
  Event_parse_data structure was modified: added flag
  status_changed that is set to true if status's value
  was changed in ALTER EVENT statement.
sql/sql_yacc.yy:
  Set flag status_changed if status was set in ALTER EVENT
  statement.
2011-06-10 00:03:17 +07:00
Dmitry Shulga
184ecd9899 Fixed bug#11840395 (formerly known as bug#60347: THE STRING "VERSIONDATA"
SEEMS TO BE 'LEAKING' INTO THE SCHEMA NAME SPACE)
and bug#12428824 (Parser stack overflow and crash in sp_add_used_routine
with obscure query).

The first problem was that attempts to call a stored function by
its fully qualified name ended up with unwarranted error "ERROR 1305
(42000): FUNCTION someMixedCaseDb.my_function_name does not exist"
if this function belonged to a schema that had uppercase letters in
its name AND --lower_case_table_names was equal to either 1 or 2.

The second problem was that 5.5 version of MySQL server might have
crashed when a user tried to call stored function with too long name
or too long database name (i.e if a function and database name combined
occupied more than 2*3*64 bytes in utf8). This issue didn't affect
versions of server < 5.5.
 
The first problem was caused by the fact that in cases when a stored
function was called by its fully qualified name we didn't lowercase
name of its schema before performing look up of the function in
mysql.proc table even although lower_case_table_names mode was on.
As result we were unable to find this function since during its
creation we store lowercased version of schema name in the system
table in this mode and field for schema name uses binary collation.

Calls to stored functions were unaffected by this problem since for
them schema name is converted to lowercase as necessary.

The reason for the second bug was that MySQL Server didn't check length
of function name and database name before proceeding with execution of
stored function. As a consequence too long database name or function
name caused buffer overruns in places where the code assumes that their
length is within fixed limits, like mdl_key_init() in 5.5.

Again this issue didn't affect calls to stored procedures as for them
length of schema name and procedure name are properly checked.

This patch fixes both these bugs by adding calls to check_db_name()
and check_routine_name() to grammar rule which corresponds to a call
to a stored function. These functions ensure that length of database
name and function name for routine called is within standard limit.
Moreover call to check_db_name() handles conversion of database name
to lowercase if --lower_case_table_names mode is on.

Note that even although the second issue seems to be only reproducible
in 5.5 we still add code fixing it to 5.1 to be on the safe side (and
make code a bit more robust against possible future changes).

mysql-test/r/sp-error.result:
  Added testcase results for bug#12428824.
mysql-test/r/sp.result:
  Added testcase result for bug#11840395.
mysql-test/t/sp-error.test:
  Added testcase for bug#12428824.
mysql-test/t/sp.test:
  Added testcase for bug#11840395.
sql/sql_yacc.yy:
  Modified 'function_call_generic' rule to call check_db_name() and
  check_routine_name() in order to ensure that lengths of database name
  and function name are within limits. check_db_name() is also responsible
  for normalizing function's database name for lookup in cases when
  lowercase_table_names mode is on.
2011-06-09 23:30:52 +07:00
Sergei Golubchik
c3f665dc66 bugfixes:
microsecond(TIME)
  alter table datetime<->datetime(6)
  max(TIME), mix(TIME) 

mysql-test/t/func_if.test:
  fix the test case of avoid overflow
sql/field.cc:
  don't use make_date() and make_time()
sql/field.h:
  correct eq_def() for temporal fields
sql/item.cc:
  move datetime caching from Item_cache_int
  to Item_cache_temporal
sql/item.h:
  move datetime caching from Item_cache_int
  to Item_cache_temporal
sql/item_func.cc:
  use existing helper methods, don't duplicate
sql/item_sum.cc:
  argument cache must use argument's cmp_type, not result_type.
sql/item_timefunc.cc:
  use existing methods, don't tuplicate.
  remove unused function.
  fix micorseconds() to support TIME argument
sql/mysql_priv.h:
  dead code
sql/time.cc:
  dead code
2011-06-09 17:23:39 +02:00
Igor Babaev
7f345153f9 Fixed LP bug #794038.
INSERT/UPDATE/DELETE statement that used a temptable view v1 could lead to
a crash if v1 was defined as a select from a mergeable view v2 that selected
rows from a temptable view v3. 
 
When INSERT/UPDATE/DELETE uses a view that is not updatable then field
translation for the view should be created before the prepare phase.
2011-06-09 00:13:00 -07:00