Re: type SERIAL in C host-struct - Mailing list pgsql-general

From Peter J. Holzer
Subject Re: type SERIAL in C host-struct
Date
Msg-id 20191109153153.GA21937@hjp.at
Whole thread Raw
In response to Re: type SERIAL in C host-struct  (Matthias Apitz <guru@unixarea.de>)
Responses Re: type SERIAL in C host-struct  (Matthias Apitz <guru@unixarea.de>)
List pgsql-general
On 2019-11-07 20:14:47 +0100, Matthias Apitz wrote:
> At the end of the day we came up with the following solution:
>
>         strcpy(host_struct.name, "Sigrid");
>         EXEC SQL select nextval('lina_lid_seq') into :host_struct.ser;
>
>         EXEC SQL INSERT INTO lina VALUES ( :host_struct );
>
> which seems to work fine. Any comments about side effects?

You are performing two queries instead of one, so you have to wait for
one extra round trip. Not a problem if client and server are on the same
network or you insert a few host_structs per second. May be a problem if
client and server are in different datacenters and you want to do
hundreds of inserts per second.

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment

pgsql-general by date:

Previous
From: Jehan-Guillaume de Rorthais
Date:
Subject: Re: logical replication - negative bitmapset member not allowed
Next
From: Matthias Apitz
Date:
Subject: Re: type SERIAL in C host-struct