Re: Most efficient way for libPQ .. PGresult serialization

From: Joshua Bay <joshuabay93(at)gmail(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Most efficient way for libPQ .. PGresult serialization
Date: 2016-08-19 14:16:35
Message-ID: CABb-U3anP61O_9megDVCu0xqB51OvOA-v5ivkjdUJDi+XMwF0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Oh I see.
I just read more on use cases PgBouncer, but seems like it can't be used
for my project.
The reason is that I need to have my middleware to have full control over
each transaction.
That is it must be able to decide if it's going to commit or abort a single
query (reason why libpq is used in the middleware), and it must be able to
decide when to send back the result. Also it does things like load
balancing with it's algorithm.

So, what middleware does is (simplied, ignoring other details)
1. listens to query and does load balancing
2. execute query on behalf of client to server with libpq (does not have to
be libpq).
3. serialize the result and send it back

And the #3 is why I asked for ways to serialize PGresult (of libpq)

Client app will deserialize the result and thus be able to interpret
PGresult as if it used libpq itself.

Thanks!

On Thu, Aug 18, 2016 at 9:05 PM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:

>
> On 19 August 2016 at 03:08, Joshua Bay <joshuabay93(at)gmail(dot)com> wrote:
>
>> Thanks,
>> But I don't think my question was clear enough.
>>
>> I already managed the connection pooling, and what I need is to serialize
>> the result.
>>
>> If PGresult was a contiguous block, I could have just create buffer and
>> call memcpy for serialization, but structure of result seems much more
>> complicated.
>>
>> So, I was asking if there is an easy way to achieve serialization
>>
>
> It's wire format is a serialization. That's kind of the point.
>
> I don't understand what you're trying to do here, so it's hard to give a
> better answer.
>
> --
> Craig Ringer http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yury Zhuravlev 2016-08-19 14:17:06 Re: WIP: About CMake v2
Previous Message Merlin Moncure 2016-08-19 14:08:25 Re: Why we lost Uber as a user