pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
compiling client utils under win32 - current 7.3devel is broken
7+ messages / 3 participants
[nested] [flat]

* compiling client utils under win32 - current 7.3devel is broken
@ 2002-09-25 22:04  Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Joe Conway @ 2002-09-25 22:04 UTC (permalink / raw)
  To: pgsql-hackers

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





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: compiling client utils under win32 - current 7.3devel is broken
@ 2002-09-25 22:18  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2002-09-25 22:18 UTC (permalink / raw)
  To: Joe Conway <mail@joeconway.com>; +Cc: pgsql-hackers

Joe Conway <mail@joeconway.com> 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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: compiling client utils under win32 - current 7.3devel
@ 2002-09-26 00:52  Joe Conway <mail@joeconway.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Joe Conway @ 2002-09-26 00:52 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers

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




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: compiling client utils under win32 - current 7.3devel
@ 2002-09-26 02:11  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Bruce Momjian @ 2002-09-26 02:11 UTC (permalink / raw)
  To: Joe Conway <mail@joeconway.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers

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
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: compiling client utils under win32 - current 7.3devel
@ 2002-09-26 03:21  Joe Conway <mail@joeconway.com>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Joe Conway @ 2002-09-26 03:21 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers

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




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: compiling client utils under win32 - current 7.3devel
@ 2002-09-26 03:56  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Bruce Momjian @ 2002-09-26 03:56 UTC (permalink / raw)
  To: Joe Conway <mail@joeconway.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers

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
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: compiling client utils under win32 - current 7.3devel
@ 2002-09-26 04:02  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2002-09-26 04:02 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Joe Conway <mail@joeconway.com>; pgsql-hackers

Bruce Momjian <pgman@candle.pha.pa.us> 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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2002-09-26 04:02 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-09-25 22:04 compiling client utils under win32 - current 7.3devel is broken Joe Conway <mail@joeconway.com>
2002-09-25 22:18 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-09-26 00:52   ` Re: compiling client utils under win32 - current 7.3devel Joe Conway <mail@joeconway.com>
2002-09-26 02:11     ` Re: compiling client utils under win32 - current 7.3devel Bruce Momjian <pgman@candle.pha.pa.us>
2002-09-26 03:21       ` Re: compiling client utils under win32 - current 7.3devel Joe Conway <mail@joeconway.com>
2002-09-26 03:56         ` Re: compiling client utils under win32 - current 7.3devel Bruce Momjian <pgman@candle.pha.pa.us>
2002-09-26 04:02           ` Re: compiling client utils under win32 - current 7.3devel Tom Lane <tgl@sss.pgh.pa.us>

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