Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extended keyword for the explain statement has been removed #894

Merged
merged 2 commits into from
Nov 11, 2017
Merged

extended keyword for the explain statement has been removed #894

merged 2 commits into from
Nov 11, 2017

Conversation

yahonda
Copy link
Contributor

@yahonda yahonda commented Sep 23, 2017

This pull request addresses #893

$ bundle exec rspec ./spec/mysql2/client_spec.rb:328
Run options: include {:locations=>{"./spec/mysql2/client_spec.rb"=>[328]}}

Randomized with seed 11457

Mysql2::Client
  #warning_count
    when has a warnings
      should > 0 (FAILED - 1)

Failures:

  1) Mysql2::Client#warning_count when has a warnings should > 0
     Failure/Error: _query(sql, @query_options.merge(options))

     Mysql2::Error:
       You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select 1' at line 1
     # ./lib/mysql2/client.rb:120:in `_query'
     # ./lib/mysql2/client.rb:120:in `block in query'
     # ./lib/mysql2/client.rb:119:in `handle_interrupt'
     # ./lib/mysql2/client.rb:119:in `query'
     # ./spec/mysql2/client_spec.rb:331:in `block (4 levels) in <top (required)>'

Finished in 0.0126 seconds (files took 0.18505 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/mysql2/client_spec.rb:328 # Mysql2::Client#warning_count when has a warnings should > 0

Randomized with seed 11457

$

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-3.html

The deprecated EXTENDED and PARTITIONS keywords for the EXPLAIN statement have been removed. These keywords are unnecessary because their effect is always enabled.

Use another select 1/0 which generates warnings:

mysql> select 1/0;
+------+
| 1/0  |
+------+
| NULL |
+------+
1 row in set, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+---------------+
| Level   | Code | Message       |
+---------+------+---------------+
| Warning | 1365 | Division by 0 |
+---------+------+---------------+
1 row in set (0.00 sec)

mysql>

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-3.html
> The deprecated EXTENDED and PARTITIONS keywords for the EXPLAIN statement have been removed. These keywords are unnecessary because their effect is always enabled.

Use another `select 1/0` which generates warnings:

```sql
mysql> select 1/0;
+------+
| 1/0  |
+------+
| NULL |
+------+
1 row in set, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+---------------+
| Level   | Code | Message       |
+---------+------+---------------+
| Warning | 1365 | Division by 0 |
+---------+------+---------------+
1 row in set (0.00 sec)

mysql>
```
@sodabrew
Copy link
Collaborator

Thank you for looking into this MySQL 8.0 issue! Unfortunately this does not generate a warning with MySQL < 8.0. Would an SELECT with a syntax error work?

@yahonda
Copy link
Contributor Author

yahonda commented Sep 23, 2017

Use DROP TABLE IF EXISTS test.no_such_table explained in https://dev.mysql.com/doc/refman/5.7/en/show-warnings.html

mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message                            |
+-------+------+------------------------------------+
| Note  | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set (0.00 sec)

mysql>

Would an SELECT with a syntax error work?

Attempted to useselect statement, which just returns ERROR , not like Query OK, 0 rows affected, 1 warning (0.00 sec). Then prefer to use drop table statement here.

mysql> select * from test.no_such_table;
ERROR 1146 (42S02): Table 'test.no_such_table' doesn't exist
mysql> SHOW WARNINGS;
+-------+------+------------------------------------------+
| Level | Code | Message                                  |
+-------+------+------------------------------------------+
| Error | 1146 | Table 'test.no_such_table' doesn't exist |
+-------+------+------------------------------------------+
1 row in set (0.00 sec)

mysql>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants