I'm curious what the exact HSQL return type of this function is. 

It would be useful to know this before we get into possible trouble -- maybe there could be a planner test for this?

If it is VARCHAR(MAX), we are safe, but we pass up a potential benefit for some edge cases (indexes? matviews?).
If it is exactly the type and size of its source string -- that's actually what the SQL standard specifies when the input's size is known -- and its source string has a limited length, then we will soon be back to the problem of making sure that we are not confusing a CHARACTERS limit for a BYTES limit for a function result (and possibly improperly inlining temp table columns, etc).