close
The Wayback Machine - https://web.archive.org/web/20200915094530/https://github.com/dbcli/mycli/issues/868
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

'list index out of range' when dealing with '\r\n' #868

Open
whm2015 opened this issue May 24, 2020 · 3 comments
Open

'list index out of range' when dealing with '\r\n' #868

whm2015 opened this issue May 24, 2020 · 3 comments

Comments

@whm2015
Copy link

@whm2015 whm2015 commented May 24, 2020

I have a table which contains '\r\n' in it. When I select from the table the problem occured. The row which contains the special charactor can't be included in the select result, or else it will report the error.

At first the problem appears in version 1.17.0, then I changed to the newest version 1.21.1 in another machine, it sucessfully retured the result contain '\r\n', but failed to return another results contain '\rx\n'('x' is another charactor)

I draged the special row from the table into a new table named 'user_test', and I uploaded it so you might reproduce the problen.
user_test.txt
it has only two rows, each row has two columns named 'name' and 'username':
('akop\r\n','akop07')
('Pablo\rß\n','l1nkworld')

in version 1.17.0, select * from any row or all row from the table will fail

mysql root@localhost:test> select * from user_test limit 0, 1
list index out of range
mysql root@localhost:test> select * from user_test limit 1, 1
list index out of range
mysql root@localhost:test> select * from user_test
list index out of range

but select one column, or put the special column to the end, will success:

mysql root@localhost:test> select name from user_test
+-------+
| name  |
+-------+
| akop  |
|       |
|       |
| Pablo |
| ß     |
|       |
+-------+
2 rows in set
Time: 0.014s
mysql root@localhost:test> select username from user_test
+-----------+
| username  |
+-----------+
| akop07    |
| l1nkworld |
+-----------+
2 rows in set
Time: 0.013s
mysql root@localhost:test> select username, name from user_test
+-----------+-------+
| username  | name  |
+-----------+-------+
| akop07    | akop  |
|           |       |
| l1nkworld | Pablo |
|           | ß     |
+-----------+-------+
2 rows in set
Time: 0.013s

in version 1.21.1, it can handle the first row:

mysql root@10.1.1.61:test> select * from user_test limit 0, 1
+------+----------+
| name | username |
+------+----------+
| akop | akop07   |
|      |          |
+------+----------+
1 row in set
Time: 0.023s
mysql root@10.1.1.61:test> select * from user_test limit 1, 1
list index out of range
mysql root@10.1.1.61:test> select * from user_test
list index out of range

and also seccessfully returned when select one row or put the special row to the end, like the above:

mysql root@10.1.1.61:test> select name from user_test
+-------+
| name  |
+-------+
| akop  |
|       |
| Pablo |
| ݠ    |
|       |
+-------+
2 rows in set
Time: 0.022s
mysql root@10.1.1.61:test> select username from user_test
+-----------+
| username  |
+-----------+
| akop07    |
| l1nkworld |
+-----------+
2 rows in set
Time: 0.021s
mysql root@10.1.1.61:test> select username, name from user_test
+-----------+-------+
| username  | name  |
+-----------+-------+
| akop07    | akop  |
|           |       |
| l1nkworld | Pablo |
|           | ݠ    |
+-----------+-------+

If there is any problem with my operation or configuration, please let me know.
Thx.

@pasenor
Copy link
Member

@pasenor pasenor commented May 24, 2020

Thanks for reporting! It is a bug in the library we use for drawing tables (terminaltables). I'll see what can be done about it, in the meantime you can use one of the not affected formatters, for example grid or fancy_grid:

mysql root@(none):test> \T fancy_grid;                                              
Changed table format to fancy_grid
Time: 0.000s
mysql root@(none):test> select * from user_test;                                    
╒════════╤════════════╕
│ name   │ username   │
╞════════╪════════════╡
│ akop   │ akop07     │
├────────┼────────────┤
│ Pablo  │ l1nkworld  │
│ ß      │            │
╘════════╧════════════╛
2 rows in set
Time: 0.010s
@pasenor
Copy link
Member

@pasenor pasenor commented May 24, 2020

I think the right way to handle this situation in the formatters that don't draw lines between rows is to simply escape newline characters, otherwise the output would be ambiguous.

@whm2015
Copy link
Author

@whm2015 whm2015 commented May 24, 2020

Thanks a lot!

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.