Bug #46609 Short display width when extracting microseconds
Submitted: 7 Aug 2009 17:19 Modified: 7 Aug 2009 17:41
Reporter: Peter Gulutzan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.38-debug, 4.1, 5.0, 5.1, azalea OS:Linux (SUSE 11.1 64-bit)
Assigned to: CPU Architecture:Any

[7 Aug 2009 17:19] Peter Gulutzan
Description:
I use EXTRACT(MICROSECONDS FROM datetime).
The result is INT(2).
But there might be 6 digits.

How to repeat:
CREATE TABLE t AS
SELECT EXTRACT(MICROSECOND FROM TIMESTAMP '2005-01-01 01:02:03.123456');
SHOW CREATE TABLE t;
[7 Aug 2009 17:41] Sveta Smirnova
Thank you for the report.

Verified as described.

$mysql50  -T
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 829
Server version: 5.0.85-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT EXTRACT(MICROSECOND FROM TIMESTAMP '2005-01-01 01:02:03.123456');
Field   1:  `EXTRACT(MICROSECOND FROM TIMESTAMP '2005-01-01 01:02:03.123456')`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     2
Max_length: 6
Decimals:   0
Flags:      BINARY NUM 

+------------------------------------------------------------------+
| EXTRACT(MICROSECOND FROM TIMESTAMP '2005-01-01 01:02:03.123456') |
+------------------------------------------------------------------+
|                                                           123456 | 
+------------------------------------------------------------------+
1 row in set (0.14 sec)