We should use a select-statement in the code. Waiting for a range query will never return since the channel is never closed from the other end.
First, it looks as if pgsql has a bug or I am using it incorrectly. Second, we should first make it work and prepared statements is an optimization. Third, we can always add in prepared statements later.
We assume each serial message has the form: ".*\n" Since we simply need to tick every time a \n arrives, so we use the textproto scanner to break the input into such entries.
A nice guy, Alex Neumann, wrote to me about his effort to write a pure-go postgresql driver. Rather than my fast binding hack, it is probably better to help him with his project.