[MDEV-6158] concat cap to max_allowed_packet Created: 2014-04-23  Updated: 2014-04-25  Resolved: 2014-04-25

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.10
Fix Version/s: None

Type: Bug Priority: Major
Reporter: VAROQUI Stephane Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

replace into mysql.http_contents select '/history',  (select CONCAT('{"server":"zOBFqxNABETgELkfy0nYH8G+Olk=","history":[', GROUP_CONCAT(COLUMN_JSON(status)  separator ',\n') ,'\n]}')  from mysql.http_status_history ORDER BY COLUMN_GET(status,'date' as datetime) ),  'text/plain';
 
MariaDB [(none)]> show warnings;
+---------+------+-----------------------------------------------------------------------------+
| Level   | Code | Message                                                                     |
+---------+------+-----------------------------------------------------------------------------+
| Warning | 1301 | Result of concat() was larger than max_allowed_packet (1048576) - truncated |
+---------+------+-----------------------------------------------------------------------------+
1 row in set (0.00 sec)
 
 select * from mysql.http_contents where name="/history";
+----------+---------+------------+
| name     | content | type       |
+----------+---------+------------+
| /history | NULL    | text/plain |
+----------+---------+------------+
1 row in set (0.02 sec)

MariaDB [(none)]> select CONCAT('{"server":"zOBFqxNABETgELkfy0nYH8G+Olk=","history":[', GROUP_CONCAT(COLUMN_JSON(status)  separator ',\n') ,'\n]}') from  from mysql.http_status_history ; 
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from mysql.http_status_history' at line 1
MariaDB [(none)]> select CONCAT('{"server":"zOBFqxNABETgELkfy0nYH8G+Olk=","history":[', GROUP_CONCAT(COLUMN_JSON(status)  separator ',\n') ,'\n]}') from mysql.http_status_history ; 
+----------------------------------------------------------------------------------------------------------------------------+
| CONCAT('{"server":"zOBFqxNABETgELkfy0nYH8G+Olk=","history":[', GROUP_CONCAT(COLUMN_JSON(status)  separator ',\n') ,'\n]}') |
+----------------------------------------------------------------------------------------------------------------------------+
| NULL                                                                                                                       |
+----------------------------------------------------------------------------------------------------------------------------+
1 row in set, 1 warning (0.02 sec)

This code works fine when max_allowed_packed is increased

Possible issue are :

  • max_allowed_packed is not a session variable and can't be easily changed dynamically
  • should truncate the result but not return NULL on overflow
  • max_allowed_packed is documented to be the query buffer and not the query result buffer.


 Comments   
Comment by Elena Stepanova [ 2014-04-25 ]

That's how it works in all versions of MySQL (at least starting from 5.1), and MariaDB.
NULL for string functions is explicitly documented in MySQL manual ( http://dev.mysql.com/doc/refman/5.5/en/string-functions.html ):

String-valued functions return NULL if the length of the result would be greater than the value of the max_allowed_packet system variable


Regarding this:

max_allowed_packed is documented to be the query buffer and not the query result buffer.

Could you please point at the place in documentation where it is said? It might need fixing.
The main max_allowed_packet description, both in MySQL manual and in MariaDB KB, says nothing of the kind:
http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_max_allowed_packet

The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function.

https://mariadb.com/kb/en/server-system-variables/#max_allowed_packet

Maximum size in bytes of a packet or a generated/intermediate string.

Given the above, I'm closing it as not a bug. If you disagree, please comment to re-open.

Generated at Thu Feb 08 07:09:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.