Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6613451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:13:13+00:00 2026-05-25T20:13:13+00:00

I have a Postgres client sending queries like SELECT … FROM public.mycontent mycontent WHERE

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:13:13+00:00Added an answer on May 25, 2026 at 8:13 pm

    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.

    from gevent import socket, server, Greenlet, joinall
    
    def pipe(source_socket, destination_socket, modify=False):
        while True:
            try:
                data = source_socket.recv(1024)
            except socket.error, e:
                break
            else:
                if data:
                    if modify: data = data.replace("limit 10", "limit 1 ")
                    destination_socket.send(data)
                else:
                    break
    
    def pg_proxy(client_socket, address):
        pg_socket = socket.create_connection(("localhost", 5432))
        pg_socket.settimeout(300.0)
        client_socket.settimeout(300.0)
        joinall((
            Greenlet.spawn(pipe, client_socket, pg_socket, modify=True),
            Greenlet.spawn(pipe, pg_socket, client_socket, modify=False)
        ))
        pg_socket.close()
        client_socket.close()
    
    if __name__ == '__main__':
        s = server.StreamServer(("localhost", 5433), pg_proxy)
        s.serve_forever()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a Postgres 8.4 database that contains a varchar(10000) column. I'd like
I have a table in a DB (Postgres based), which acts like a superclass
I have a postgres table like this: CREATE SEQUENCE seq; CREATE TABLE tbl (id
I have a postgres table that looks in part like: Year | Month |
I have a query SELECT cd.signoffdate, min(cmp.dsignoff) as dsignoff FROM clients AS c LEFT
I have Postgres version 8.4.8 select version(); PostgreSQL 8.4.8 on i686-pc-linux-gnu, compiled by GCC
I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user
I have a postgres database with a user table (userid, firstname, lastname) and a
I have a Postgres instance building a GIN index. It's looking at about 200,000
I have two tables (in postgres) - ads and logs. After every insert into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.