Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XgDPS-0008D9-Ag for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Oct 2014 13:54:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XgDPR-0000Xp-8B for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Oct 2014 13:54:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XgDPP-0000Xg-6D for pgsql-bugs@postgresql.org; Mon, 20 Oct 2014 13:54:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XgDPM-0007zR-Cw for pgsql-bugs@postgresql.org; Mon, 20 Oct 2014 13:54:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s9KDrnBC003052; Mon, 20 Oct 2014 09:53:50 -0400 From: Tom Lane To: chenhj cc: pgsql-bugs@postgresql.org Subject: Re: 32 bit libpq fail to connecting when set a very large "connect_timeout" value In-reply-to: <75f4618f.c0f7.1492c250468.Coremail.chjischj@163.com> References: <75f4618f.c0f7.1492c250468.Coremail.chjischj@163.com> Comments: In-reply-to chenhj message dated "Mon, 20 Oct 2014 14:01:03 +0800" Date: Mon, 20 Oct 2014 09:53:49 -0400 Message-ID: <3051.1413813229@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org chenhj writes: > [chenhj@node2 ~]$ export PGCONNECT_TIMEOUT=2147483647 That's a pretty darn silly setting, wouldn't you agree? > finish_time = time(NULL) + timeout; > if(finish_time < ((time_t) 0)) > { > finish_time = ((time_t) -1); > } I don't care for this "fix" because it assumes that all current and future time_t's are positive. On 32-bit machines that would break in 2038 ... unless time_t is redefined as unsigned 32-bit, in which case the test becomes useless. It might be possible to develop a test for overflow that would work regardless of the width or signedness of time_t, but ISTM the work would be vastly out of proportion to the benefit. And you'd still not have dealt with PGCONNECT_TIMEOUT > 2^31, which arguably is another "bug" case here. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs