[HACKERS] compiling client utils under win32 - current 7.3devel is broken

2002-09-25 Thread Joe Conway

I'm trying to get the client utilities to compile under win32/VS.net per 
http://developer.postgresql.org/docs/postgres/install-win32.html.

I was able to do this successfully using the 7.2.2 tarball, but using current 
7.3devel there are a number of minor issues (missing defines, adjustments to 
includes), and one more difficult item (at least so far). The latter is the 
use of gettimeofday in fe-connect.c:connectDBComplete for which there does not 
seem to be a good alternate under win32.

In connectDBComplete I see:

/*
  * Prepare to time calculations, if connect_timeout isn't zero.
  */
if (conn-connect_timeout != NULL)
{
   remains.tv_sec = atoi(conn-connect_timeout);

so it seems that the connection timeout can only be specified to the nearest 
second. Given that, is there any reason not to use time() instead of 
gettimeofday()?

It looks like there is a great deal of complexity added to the function just 
to accommodate the fact that gettimeofday returns seconds and microseconds as 
distinct members of the result struct. I think switching this code to use 
time() would both simplify it, and make it win32 compatible.

Comments?

Joe



---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [HACKERS] compiling client utils under win32 - current 7.3devel is broken

2002-09-25 Thread Tom Lane

Joe Conway [EMAIL PROTECTED] writes:
 ...it seems that the connection timeout can only be specified to the nearest 
 second. Given that, is there any reason not to use time() instead of 
 gettimeofday()?

As the code stands it's pretty necessary.  Since we'll go around the
loop multiple times, in much less than a second per loop in most cases,
the timeout resolution will be really poor if we only measure each
iteration to the nearest second.

 It looks like there is a great deal of complexity added to the function just 
 to accommodate the fact that gettimeofday returns seconds and microseconds as
 distinct members of the result struct.

It is ugly coding; if you can think of a better way, go for it.

It might work to measure time since the start of the whole process, or
until the timeout target, rather than accumulating adjustments to the
remains count each time through.  In other words something like

at start: targettime = time() + specified-timeout

each time we are about to wait: set select timeout to
targettime - time().

This bounds the error at 1 second which is probably good enough (you
might want to add 1 to targettime to ensure the error is in the
conservative direction of not timing out too soon).

regards, tom lane

---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Re: [HACKERS] compiling client utils under win32 - current 7.3devel

2002-09-25 Thread Joe Conway

Tom Lane wrote:
 It might work to measure time since the start of the whole process, or
 until the timeout target, rather than accumulating adjustments to the
 remains count each time through.  In other words something like
 
   at start: targettime = time() + specified-timeout
 
   each time we are about to wait: set select timeout to
   targettime - time().
 
 This bounds the error at 1 second which is probably good enough (you
 might want to add 1 to targettime to ensure the error is in the
 conservative direction of not timing out too soon).
 

I was working with this approach, when I noticed on *unmodified* cvs tip 
(about a day old):

test=# set statement_timeout=1;
SET
test=# \dt
ERROR:  Query was cancelled.
test=#

At:
   http://developer.postgresql.org/docs/postgres/runtime-config.html#LOGGING
the setting is described like this:

STATEMENT_TIMEOUT (integer)

Aborts any statement that takes over the specified number of milliseconds. A 
value of zero turns off the timer.

The proposed change will take this to a 1 second granularity anyway, so I was 
thinking we should change the setting to have a UOM of seconds, and fix the 
documentation. Any comments or concerns with regard to this plan?

Thanks,

Joe


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [HACKERS] compiling client utils under win32 - current 7.3devel

2002-09-25 Thread Bruce Momjian

Joe Conway wrote:
 I was working with this approach, when I noticed on *unmodified* cvs tip 
 (about a day old):
 
 test=# set statement_timeout=1;
 SET
 test=# \dt
 ERROR:  Query was cancelled.
 test=#
 
 At:
http://developer.postgresql.org/docs/postgres/runtime-config.html#LOGGING
 the setting is described like this:
 
 STATEMENT_TIMEOUT (integer)
 
 Aborts any statement that takes over the specified number of milliseconds. A 
 value of zero turns off the timer.
 
 The proposed change will take this to a 1 second granularity anyway, so I was 
 thinking we should change the setting to have a UOM of seconds, and fix the 
 documentation. Any comments or concerns with regard to this plan?

Uh, I thought you were changing connection_timeout, which is libpq and
not a GUC parameter, not statement_timeout.  Do we want sub-second
timeout values?  Not sure.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



Re: [HACKERS] compiling client utils under win32 - current 7.3devel

2002-09-25 Thread Joe Conway

Bruce Momjian wrote:
 Uh, I thought you were changing connection_timeout, which is libpq and
 not a GUC parameter

Yup, you're right -- I got myself confused. Sorry.

 not statement_timeout.  Do we want sub-second
 timeout values?  Not sure.
 

I found it surprising that the statement_timeout was not in units of seconds, 
but that's only because I read the docs after I tried it instead of before. I 
can't think of a reason to have sub-second values, but it's probably not worth 
changing it at this point.

Joe


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [HACKERS] compiling client utils under win32 - current 7.3devel

2002-09-25 Thread Bruce Momjian

Joe Conway wrote:
 Bruce Momjian wrote:
  Uh, I thought you were changing connection_timeout, which is libpq and
  not a GUC parameter
 
 Yup, you're right -- I got myself confused. Sorry.
 
  not statement_timeout.  Do we want sub-second
  timeout values?  Not sure.
  
 
 I found it surprising that the statement_timeout was not in units of seconds, 
 but that's only because I read the docs after I tried it instead of before. I 
 can't think of a reason to have sub-second values, but it's probably not worth 
 changing it at this point.

Most queries are sub-second in duration so it seemed logical to keep it
the same as deadlock_timeout.  I can see someone setting a 1/2 second
delay for queries.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])



Re: [HACKERS] compiling client utils under win32 - current 7.3devel

2002-09-25 Thread Tom Lane

Bruce Momjian [EMAIL PROTECTED] writes:
 Joe Conway wrote:
 I can't think of a reason to have sub-second values, but it's
 probably not worth changing it at this point.

 Most queries are sub-second in duration so it seemed logical to keep it
 the same as deadlock_timeout.

And machines get faster all the time.

I'm not too concerned about resolution of a connection timeout, but
I think we want to be able to express small query timeouts.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly