pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Darko Prenosil <Darko.Prenosil@finteh.hr>
To: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql interfaces <pgsql-interfaces@postgresql.org>
Date: Wed, 3 Oct 2001 19:13:07 +0200
Message-ID: <007e01c14c2e$d1e69240$ef00000a@darko> (raw)

Hi guys, 
Sorry for bothering you, but we ran into a situation...
Story goes like this: 
We wanted to use non-blocking PQSendQuery to send a large query which consists of many SELECTs. Our pglib interface sent just first 8192 bytes and returned EOF. Whole query was more than 64k.

We took a brief look through the source and here is what confuses us:

These two chunks of code are from fe-misc.c

pqPutBytes(const char *s, size_t nbytes, PGconn *conn){
........
while (nbytes > avail)
 {
  memcpy(conn->outBuffer + conn->outCount, s, avail);
  conn->outCount += avail;
  s += avail;
  nbytes -= avail;
  if (pqFlush(conn))                       
   return EOF;
  avail = conn->outBufSize;
 }
...........
}

*************************************
pqFlush(PGconn *conn) {
............
#ifdef USE_SSL
   /* can't do anything for our SSL users yet */
   if (conn->ssl == NULL)
   {
#endif
    if (pqIsnonblocking(conn))
    {
     /* shift the contents of the buffer */
     memmove(conn->outBuffer, ptr, len);
     conn->outCount = len;
     return EOF;                                    <- Why it returns EOF after just shifting the buffer ???
    }
#ifdef USE_SSL
   }
#endif
...............
}


When we corected the code to look like this:

#ifdef USE_SSL
   /* can't do anything for our SSL users yet */
   if (conn->ssl == NULL)
   {
    if (pqIsnonblocking(conn))
    {
     /* shift the contents of the buffer */
     memmove(conn->outBuffer, ptr, len);
     conn->outCount = len;
     return EOF;                                   
    }
   }
#endif

we succeed to send queries bigger than 8k. We tried to figure what is happening, and saw that there
is few pqWait calls, but our queries are send correctly. Is there some fact that we are missing ?
Can You please explain ???
Maybe it is important to say that we are compiling library for WIN32.


Thanks.
Darko

view thread (2+ messages)  latest in thread

Message-ID: <007e01c14c2e$d1e69240$ef00000a@darko>
Permalink:  ../007e01c14c2e$d1e69240$ef00000a@darko/
Also on:    postgresql.org/message-id/007e01c14c2e$d1e69240$ef00000a@darko

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: Darko.Prenosil@finteh.hr, pgman@candle.pha.pa.us, tgl@sss.pgh.pa.us
  Subject: Re: 
  In-Reply-To: <007e01c14c2e$d1e69240$ef00000a@darko>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox