Bug #42897 Print to Screen Errors from Select in cmd

Submitted: 16 Feb 2009 17:54 Modified: 20 Mar 2009 6:39
Reporter: Edward Strinden Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1, 5.0, 5,1, 6.0 bzr OS:Any
Assigned to: CPU Architecture:Any
Tags: cmd, columns, layout, print

[16 Feb 2009 17:54] Edward Strinden
Description:
maybe a copy of Bug #37314

mysql> select * from event; select * from pet;
+----------+------------+----------+------------------------------+
| name     | date       | type     | remark                       |
+----------+------------+----------+------------------------------+
 | luffy   | 1995-05-15 | litter   | 4 kittens, 3 female, 1 male
 | uffy    | 1993-06-23 | litter   | 5 puppies, 2 female, 3 male
         | | 1994-06-19 | litter   | 3 puppies, 3 female
    | py   | 1999-03-21 | vet      | needed beak straightened
                  | -03 | vet      | broken rib
                            | el   |
                            | el   |
     |     | 1998-08-28 | birthday | Gave him a new chew toy
  | aws    | 1998-03-17 | birthday | Gave him a new flea collar
| Whistler | 1998-12-09 | birthday | First birthday               |
+----------+------------+----------+------------------------------+
10 rows in set (0.00 sec)

+----------+--------+---------+------+------------+------------+
| name     | owner  | species | sex  | birth      | death      |
+----------+--------+---------+------+------------+------------+
| Fluffy   | Harold | cat     | f    | 1993-02-04 | NULL       |
| Claws    | Gwen   | cat     | m    | 1994-03-17 | NULL       |
| Buffy    | Harold | dog     | f    | 1989-05-13 | NULL       |
| Fang     | Benny  | dog     | m    | 1990-08-27 | NULL       |
| Bowser   | Diane  | bear    | m    | 1989-09-30 | 1995-07-29 |
| Chirpy   | Gwen   | bird    | f    | 1998-09-11 | NULL       |
| Whistler | Gwen   | bird    | NULL | 1997-12-09 | NULL       |
| Slim     | Benny  | snake   | m    | 1996-04-29 | NULL       |
| Puffball | Diane  | dog     | m    | 2003-01-31 | NULL       |
+----------+--------+---------+------+------------+------------+
9 rows in set (0.00 sec)

The print layout can become parsed, as seen above.

Found in working through the examples in the manual.

Eddie

How to repeat:
Manual Example 3.3.4.9 in Windows_cmd>mysql>

Suggested fix:
I'm sorry, I wish I new more about programming so I could suggest a fix.  When I find one I will submit it.
[17 Feb 2009 8:05] Sveta Smirnova
Thank you for the report.

Please provide output of SHOW CREATE TABLE event and dump of its content.
[17 Feb 2009 15:52] Edward Strinden
Dump of show create table event; show create table event\G:

mysql> use menagerie;
Database changed
mysql> show create table event;
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
-----------------------------------------------+
| Table | Create Table

                                               |
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
-----------------------------------------------+
| event | CREATE TABLE `event` (
  `name` varchar(20) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `type` varchar(15) DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
-----------------------------------------------+
1 row in set (0.11 sec)

mysql> show create table event\G;
*************************** 1. row ***************************
       Table: event
Create Table: CREATE TABLE `event` (
  `name` varchar(20) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `type` varchar(15) DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

ERROR:
No query specified

mysql>
[17 Feb 2009 21:37] Sveta Smirnova
Thank you for the feedback.

Please send dump of event table - output of `mysqldump dbname event`: if I understood correctly you complain about formatting errors, so I want to be sure table does not contain unnecessary tabulations, linebreaks or other special symbols.
[18 Mar 2009 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[18 Mar 2009 15:11] Edward Strinden
Output of mysqldump

C:\WINDOWS>mysqldump menagerie event -u root -p
Enter password: **************
-- MySQL dump 10.13  Distrib 5.1.31, for Win32 (ia32)
--
-- Host: localhost    Database: menagerie
-- ------------------------------------------------------
-- Server version       5.1.31-community

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
*/;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `event`
--

DROP TABLE IF EXISTS `event`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `event` (
  `name` varchar(20) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `type` varchar(15) DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Dumping data for table `event`
--

LOCK TABLES `event` WRITE;
/*!40000 ALTER TABLE `event` DISABLE KEYS */;
INSERT INTO `event` VALUES ('Fluffy','1995-05-15','litter','4 kittens, 3 female,
 1 male\r'),('Buffy','1993-06-23','litter','5 puppies, 2 female, 3 male\r'),('Bu
ffy','1994-06-19','litter','3 puppies, 3 female\r'),('Chirpy','1999-03-21','vet'
,'needed beak straightened\r'),('Slim','1997-08-03','vet','broken rib\r'),('Bows
er','1991-10-12','kennel','\r'),('Fang','1991-10-12','kennel','\r'),('Fang','199
8-08-28','birthday','Gave him a new chew toy\r'),('Claws','1998-03-17','birthday
','Gave him a new flea collar\r'),('Whistler','1998-12-09','birthday','First bir
thday');
/*!40000 ALTER TABLE `event` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2009-03-18 13:44:03
[19 Mar 2009 6:16] Sveta Smirnova
Thank you for the report.

Verified as described.
[19 Mar 2009 22:23] Jim Winstead
Your data contains carriage return characters (the "\r" you can see in the dump), which will result in the sort of output you see.
[20 Mar 2009 6:24] Sveta Smirnova
Jim,

right. But please look attention problem is not formatting, but no value in `name` field displayed. Or only part of such value.For example I expect

mysql> select * from event limit 1;
+--------+------------+--------+------------------------------+
| name   | date       | type   | remark                       |
+--------+------------+--------+------------------------------+
 | Fluffy | 1995-05-15 | litter | 4 kittens, 3 female, 1 male
+--------+------------+--------+------------------------------+
1 row in set (0.00 sec)

but get:

mysql> select * from event limit 1;
+--------+------------+--------+------------------------------+
| name   | date       | type   | remark                       |
+--------+------------+--------+------------------------------+
 | luffy | 1995-05-15 | litter | 4 kittens, 3 female, 1 male
+--------+------------+--------+------------------------------+
1 row in set (0.00 sec)

or I expect:

mysql> select * from event limit 3;
+--------+------------+--------+------------------------------+
| name   | date       | type   | remark                       |
+--------+------------+--------+------------------------------+
 | Fluffy | 1995-05-15 | litter | 4 kittens, 3 female, 1 male
 | Buffy  | 1993-06-23 | litter | 5 puppies, 2 female, 3 male
 | Buffy | 1994-06-19 | litter | 3 puppies, 3 female
+--------+------------+--------+------------------------------+
3 rows in set (0.00 sec)

but get:

mysql> select * from event limit 3;
+--------+------------+--------+------------------------------+
| name   | date       | type   | remark                       |
+--------+------------+--------+------------------------------+
 | luffy | 1995-05-15 | litter | 4 kittens, 3 female, 1 male
 | uffy  | 1993-06-23 | litter | 5 puppies, 2 female, 3 male
         | 1994-06-19 | litter | 3 puppies, 3 female
+--------+------------+--------+------------------------------+
3 rows in set (0.00 sec)
[20 Mar 2009 6:39] Sveta Smirnova
Probably

mysql> select * from event limit 1;
+--------+------------+--------+------------------------------+
| name   | date       | type   | remark                       |
+--------+------------+--------+------------------------------+
 | luffy | 1995-05-15 | litter | 4 kittens, 3 female, 1 male
+--------+------------+--------+------------------------------+
1 row in set (0.00 sec)

is correct, but why no value in `name` field displayed since line 3 while value in the `remark` field still contains single '\r'?

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.045 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.