I have a Postgres client sending queries like
SELECT ... FROM "public"."mycontent" "mycontent"
WHERE (strpos(substring("mycontent"."summary" from 1), 'search_string') + 1 - 1 > 0)
to our Postgres server. I want the client to use my full text search function, but I have no access to the client’s code. So I am looking for a way to rewrite all incoming query in the above form to something like:
SELECT ... FROM "public"."mycontent" "mycontent"
WHERE id in full_text_search('search_string')
Note the extraction of the ‘search_string’, so Postgres Rules cannot be used here because they don’t do such extraction. I hope anyone knows of any postgres middleware or proxy that can do query rewrite, or is there any other better idea? Thank you.
I guess I have to answer my own question. I implemented a postgres proxy server for rewriting query, using python gevent socket programming. Note this doesn’t work if connection uses SSL.