| Bug #9899 | EXPLAIN SELECT 1; shows NOT_NULL_FLAG flag - but a NULL result | ||
|---|---|---|---|
| Submitted: | 14 Apr 2005 13:49 | Modified: | 21 Jun 2005 0:13 |
| Reporter: | MySQL-Front Team | ||
| Status: | Closed | ||
| Category: | Server | Severity: | S3 (Non-critical) |
| Version: | 4.1.13 | OS: | Microsoft Windows (Windows XP) |
| Assigned to: | Igor Babaev | Target Version: | |
[14 Apr 2005 15:58]
Jorge del Conde
Thanks for your bug report. Verified w/5.0.4
[27 May 2005 12:48]
Sergei Golubchik
4.1 is affected too
[7 Jun 2005 14:04]
Igor Babaev
The attribute of nullability was not set correctly for some columns of the EXPLAIN table.
This can be seen from the following example run from mysql that was launched
with the 'T' option:
mysql> explain select 1;
Catalog: 'def'
Database: ''
Table: ''
Name: 'id'
Type: 8
Length: 3
Max length: 1
Is_null: 0
Flags: 32929
Decimals: 0
Catalog: 'def'
Database: ''
Table: ''
Name: 'select_type'
Type: 253
Length: 19
Max length: 6
Is_null: 0
Flags: 1
Decimals: 31
Catalog: 'def'
Database: ''
Table: ''
Name: 'table'
Type: 253
Length: 64
Max length: 0
Is_null: 0
Flags: 1
Decimals: 31
Catalog: 'def'
Database: ''
Table: ''
Name: 'type'
Type: 253
Length: 10
Max length: 0
Is_null: 0
Flags: 1
Decimals: 31
Catalog: 'def'
Database: ''
Table: ''
Name: 'possible_keys'
Type: 253
Length: 4096
Max length: 0
Is_null: 1
Flags: 0
Decimals: 31
Catalog: 'def'
Database: ''
Table: ''
Name: 'key'
Type: 253
Length: 64
Max length: 0
Is_null: 1
Flags: 0
Decimals: 31
Catalog: 'def'
Database: ''
Table: ''
Name: 'key_len'
Type: 253
Length: 4096
Max length: 0
Is_null: 1
Flags: 128
Decimals: 31
Catalog: 'def'
Database: ''
Table: ''
Name: 'ref'
Type: 253
Length: 1024
Max length: 0
Is_null: 1
Flags: 0
Decimals: 31
Catalog: 'def'
Database: ''
Table: ''
Name: 'rows'
Type: 8
Length: 10
Max length: 0
Is_null: 0
Flags: 32929
Decimals: 0
Catalog: 'def'
Database: ''
Table: ''
Name: 'Extra'
Type: 253
Length: 255
Max length: 14
Is_null: 0
Flags: 1
Decimals: 31
+----+-------------+-------+------+---------------+------+---------+------+------+--------
--------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra
|
+----+-------------+-------+------+---------------+------+---------+------+------+--------
--------+
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No
tables used |
+----+-------------+-------+------+---------------+------+---------+------+------+--------
--------+
1 row in set (16.35 sec)
THe nullability attribute has to be set to 1 for the columns 'table', 'type' and 'rows'.
(This report and corresponding patch was prepared by Alexander Ivanov).
[7 Jun 2005 15:34]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/25706
[7 Jun 2005 18:41]
Igor Babaev
ChangeSet
1.2321 05/06/07 06:34:13 igor@rurik.mysql.com +6 -0
Many files:
Fixed bug #9899: erronious NOT_NULL flag for some attributes
in the EXPLAIN table.
The fix will appear in 4.1.13 and 5.0.7.
[8 Jun 2005 9:02]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/25742
[21 Jun 2005 0:13]
Mike Hillyer
Documented in the 4.1.13 and 5.0.7 changelogs: <listitem><para> The <literal>table</literal>, <literal>type</literal>, and <literal>rows</literal> columns of <literal>EXPLAIN</literal> output can now be <literal>NULL</literal>. This is required for using <literal>EXPLAIN</literal> on <literal>SELECT</literal> queries that use no tables (i.e. <literal>EXPLAIN SELECT 1</literal>). (Bug # 9899) </para></listitem>

Description: The query EXPLAIN SELECT 1; gives a result with one column. The flags of this column are 32929. So the NOT_NULL_FLAG is set. Nevertheless the third column (table) is NULL. If I run this query with version 4.0.22 on Linux I get one column ("Comment" called) with the content "No tables used". I'm sorry, but I don't know if this bug based on the server or the client library (libMySQL.dll). I use the libMySQL.dll in version 5.0.3-beta for this problem. How to repeat: EXPLAIN SELECT 1;