Re: libpq and multi-threading

2023-05-03 Thread Geoff Winkless
On Wed, 3 May 2023 at 12:11, Michael J. Baars < mjbaars1977.pgsql.hack...@gmail.com> wrote: > The shared common address space is controlled by the clone(2) CLONE_VM > option. Indeed this results in an environment in which both the parent and > the child can read / write each other's memory, but dy

Re: libpq and multi-threading

2023-05-03 Thread Peter J. Holzer
On 2023-05-03 06:35:26 -0600, Michael Loftis wrote: > That is not a thread. Linux man clone right at the start … > > “clone, __clone2, clone3 - create a child process” > > What you want is pthread_create (or similar) clone is the system call which is used to create both processes and threads (in

Re: libpq and multi-threading

2023-05-03 Thread Michael J. Baars
Hi Michael, Are pthread_* functions really such an improvement over clone? Does it make an 'freely passing around' of PGresult objects possible? Like it matters, process or thread. We were talking about the documentation and this 'freely passing around' PGresult object. I just don't think it is a

Re: libpq and multi-threading

2023-05-03 Thread Michael Loftis
That is not a thread. Linux man clone right at the start … “clone, __clone2, clone3 - create a child process” What you want is pthread_create (or similar) There’s a bunch of not well documented dragons if you’re trying to treat a child process as a thread. Use POSIX Threads, as pretty much anyti

Re: libpq and multi-threading

2023-05-03 Thread Michael J. Baars
Hi Peter, The shared common address space is controlled by the clone(2) CLONE_VM option. Indeed this results in an environment in which both the parent and the child can read / write each other's memory, but dynamic memory being allocated using malloc(3) from two different threads simulaneously wi

Re: libpq and multi-threading

2023-05-02 Thread Peter J. Holzer
On 2023-05-02 17:43:06 +0200, Michael J. Baars wrote: > I don't think it is, but let me shed some more light on it. One possibly quite important information you haven't told us yet is which OS you use. Or how you create the threads, how you pass the results around, what else you are possibly doin

Re: libpq and multi-threading

2023-05-02 Thread Michael J. Baars
Hi David, My mistake. Too much fiddling around, but better than no fiddling around. It appears both sides make mistakes, or does your freely passing around work better than mine? On Tue, 2 May 2023, 17:57 David G. Johnston, wrote: > On Tue, May 2, 2023 at 2:38 AM Michael J. Baars < > mjbaars197

Re: libpq and multi-threading

2023-05-02 Thread David G. Johnston
On Tue, May 2, 2023 at 2:38 AM Michael J. Baars < mjbaars1977.pgsql.hack...@gmail.com> wrote: > I have already tried to set the PostgreSQL 'dynamic_shared_memory_type' > configuration option to 'mmap', but this does not help. > > Of course it doesn't, that is a server-side configuration. "Specifi

Re: libpq and multi-threading

2023-05-02 Thread Michael J. Baars
I was able to reproduce from here. On Tue, 2 May 2023, 15:49 Laurenz Albe, wrote: > On Tue, 2023-05-02 at 11:38 +0200, Michael J. Baars wrote: > > I have a question about libpq and multi-threading. > > > > In the PostgreSQL documentation ( > https://www.postgresql.org

Re: libpq and multi-threading

2023-05-02 Thread Laurenz Albe
On Tue, 2023-05-02 at 11:38 +0200, Michael J. Baars wrote: > I have a question about libpq and multi-threading. > > In the PostgreSQL documentation > (https://www.postgresql.org/docs/15/libpq-threading.html) > it says that results can be passed around freely between threads. How

libpq and multi-threading

2023-05-02 Thread Michael J. Baars
Hi All, I have a question about libpq and multi-threading. In the PostgreSQL documentation ( https://www.postgresql.org/docs/15/libpq-threading.html) it says that results can be passed around freely between threads. However, when I try to read the result from the parent thread, the program