Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
  2. index 7f8777e..5d32938 100644
  3. --- a/mysql-test/r/win.result
  4. +++ b/mysql-test/r/win.result
  5. @@ -2762,10 +2762,8 @@ CREATE TABLE t1 (i INT);
  6. INSERT INTO t1 VALUES (3), (1), (2);
  7. SELECT i, ROW_NUMBER() OVER () FROM t1 WHERE 1 = 2;
  8. i ROW_NUMBER() OVER ()
  9. -NULL 1
  10. SELECT i, COUNT(*) OVER () FROM t1 WHERE 1 = 2;
  11. i COUNT(*) OVER ()
  12. -NULL 1
  13. DROP TABLE t1;
  14. #
  15. # MDEV-12051: window function in query with implicit grouping
  16. @@ -3141,3 +3139,11 @@ sum(i) over (order by i) interval(sum(i) over (order by i), 10, 20)
  17. 33 2
  18. 63 2
  19. drop table t1;
  20. +#
  21. +# MDEV-13352: Server crashes in st_join_table::remove_duplicates
  22. +#
  23. +CREATE TABLE t1 (i INT);
  24. +INSERT INTO t1 VALUES (1),(2);
  25. +SELECT DISTINCT ROW_NUMBER() OVER(), i FROM t1 WHERE 0;
  26. +ROW_NUMBER() OVER() i
  27. +DROP TABLE t1;
  28. diff --git a/mysql-test/r/win_insert_select.result b/mysql-test/r/win_insert_select.result
  29. index c86576d..93545e6 100644
  30. --- a/mysql-test/r/win_insert_select.result
  31. +++ b/mysql-test/r/win_insert_select.result
  32. @@ -11,10 +11,6 @@ c1 c2
  33. 4 manual_insert_2
  34. 11 should repeat 4 times [11-14]
  35. 12 should repeat 4 times [11-14]
  36. -13 should repeat 4 times [11-14]
  37. -14 should repeat 4 times [11-14]
  38. -0 should_have_0
  39. -2 should_have_2
  40. DELETE FROM t1;
  41. EXECUTE populate_table;
  42. INSERT INTO t1
  43. diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
  44. index aff717e..2b029d6 100644
  45. --- a/mysql-test/t/win.test
  46. +++ b/mysql-test/t/win.test
  47. @@ -1923,3 +1923,13 @@ insert into t1 values (1),(2),(10),(20),(30);
  48. select sum(i) over (order by i), interval(sum(i) over (order by i), 10, 20)
  49. from t1;
  50. drop table t1;
  51. +
  52. +--echo #
  53. +--echo # MDEV-13352: Server crashes in st_join_table::remove_duplicates
  54. +--echo #
  55. +CREATE TABLE t1 (i INT);
  56. +INSERT INTO t1 VALUES (1),(2);
  57. +SELECT DISTINCT ROW_NUMBER() OVER(), i FROM t1 WHERE 0;
  58. +DROP TABLE t1;
  59. +
  60. +
  61. diff --git a/sql/sql_select.cc b/sql/sql_select.cc
  62. index e8e3998..0966b2a 100644
  63. --- a/sql/sql_select.cc
  64. +++ b/sql/sql_select.cc
  65. @@ -3398,8 +3398,14 @@ void JOIN::exec_inner()
  66.  
  67. if (zero_result_cause)
  68. {
  69. - if (select_lex->have_window_funcs())
  70. + if (select_lex->have_window_funcs() && send_row_on_empty_set())
  71. {
  72. + /*
  73. + The query produces just one row but it has window functions.
  74. +
  75. + The only way to compute the value of window function(s) is to
  76. + run the entire window function computation step (there is no shortcut).
  77. + */
  78. const_tables= table_count;
  79. first_select= sub_select_postjoin_aggr;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement