That is defined by the max size of a packet that can be sent or received by the engine, and it is configurable.
You can check your current value with this command:
SHOW VARIABLES LIKE 'max_allowed_packet';
However, a too big query would not cause it to take forever. You would get a Packet Too Large error.
If your session is hanging, there must be something else going on.