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

builtin uncompress function ignored the four bytes length #8578

Closed
niedhui opened this issue Dec 4, 2018 · 2 comments · Fixed by #8586
Closed

builtin uncompress function ignored the four bytes length #8578

niedhui opened this issue Dec 4, 2018 · 2 comments · Fixed by #8586
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility

Comments

@niedhui
Copy link
Contributor

niedhui commented Dec 4, 2018

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
mysql> select uncompress(unhex('02000000789CCB48CDC9C95728CF2FCA4901001A0B045D'));
  1. What did you expect to see?
mysql> select uncompress(unhex('02000000789CCB48CDC9C95728CF2FCA4901001A0B045D'));
+---------------------------------------------------------------------+
| uncompress(unhex('02000000789CCB48CDC9C95728CF2FCA4901001A0B045D')) |
+---------------------------------------------------------------------+
| NULL                                                                |
+---------------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+--------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                          |
+---------+------+--------------------------------------------------------------------------------------------------+
| Warning | 1258 | ZLIB: Not enough room in the output buffer (probably, length of uncompressed data was corrupted) |
+---------+------+--------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
  1. What did you see instead?
+---------------------------------------------------------------------+
| uncompress(unhex('02000000789CCB48CDC9C95728CF2FCA4901001A0B045D')) |
+---------------------------------------------------------------------+
| hello world                                                         |
+---------------------------------------------------------------------+
1 row in set (0.01 sec)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
tidb_version(): Release Version: v2.1.0-rc.2-10-gb30dbd0
Git Commit Hash: b30dbd06acaab088a1e8fa004e189c651ca08bf1
Git Branch: master
UTC Build Time: 2018-09-17 01:20:48
GoVersion: go version go1.11 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
  1. more info
    This is found when I try to implement builtin compress and uncompress function in TiKV (implement compress,uncompress,uncompressed_length tikv/tikv#3856)
    the first four bytes stored the length of the uncompress string, if it's less than the corrected length (maybe corrupted), MySQL return Null, TiDB just ignore it.
@zimulala
Copy link
Contributor

zimulala commented Dec 4, 2018

@niedhui
Thanks for your feedback!
Would you like to file a PR to fix it? Refer to https://dev.mysql.com/doc/refman/5.7/en/encryption-functions.html#function_uncompress

@zimulala zimulala added type/bug The issue is confirmed as a bug. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Dec 4, 2018
@ziyi-yan
Copy link
Contributor

ziyi-yan commented Dec 5, 2018

I am trying to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants