I'll fix the NULL issue, but with the current code figuring out the length is not trivial enough, so I'd like to leave that for the "rewriting of to_index_string" (for which I'll make a ticket shortly).