Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tx9GK-0001Xp-4j for pgsql-jdbc@arkaria.postgresql.org; Mon, 21 Jan 2013 04:45:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tx9GI-0002Lv-NT for pgsql-jdbc@arkaria.postgresql.org; Mon, 21 Jan 2013 04:45:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tx9G5-0002BJ-NU for pgsql-jdbc@postgresql.org; Mon, 21 Jan 2013 04:45:21 +0000 Received: from [222.73.24.84] (helo=song.cn.fujitsu.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tx9G1-0008ID-7A for pgsql-jdbc@postgresql.org; Mon, 21 Jan 2013 04:45:21 +0000 X-IronPort-AV: E=Sophos;i="4.84,504,1355068800"; d="scan'208";a="6618667" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 21 Jan 2013 12:43:02 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r0L4j7MW005153; Mon, 21 Jan 2013 12:45:08 +0800 Received: from [127.0.0.1] ([10.167.159.99]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013012112441609-1052166 ; Mon, 21 Jan 2013 12:44:16 +0800 Message-ID: <50FCC7EC.7050307@cn.fujitsu.com> Date: Mon, 21 Jan 2013 12:45:32 +0800 From: Chen Huajun User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Lightning/1.0b2 Thunderbird/3.1.20 MIME-Version: 1.0 To: dmp CC: pgsql-jdbc@postgresql.org Subject: Re: [BUGS]log can not be output when use DataSource References: <50F8335B.6070404@ttc-cmc.net> <50FA1403.7020301@cn.fujitsu.com> <50FAF98A.1030008@ttc-cmc.net> <50FBCA78.3040007@cn.fujitsu.com> <50FC3529.3060101@ttc-cmc.net> In-Reply-To: <50FC3529.3060101@ttc-cmc.net> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/21 12:44:16, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/21 12:44:16, Serialize complete at 2013/01/21 12:44:16 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8; format=flowed X-Host-Lookup-Failed: Reverse DNS lookup failed for 222.73.24.84 (failed) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org > If you would create sample code to run to validate both your > bug report and test your patch you may have seen the breakage. > I can tell you that in all cases when DataSource.SetLogLevel(0) > your patch breaks the standard of the user overrides the > Driver.setLogLevel() when it is stipulated. > > I know that valid inputs maybe only be Driver.INFO & Driver.DEBUG, > but if you treat the PgJDBC has a black box which you stimulate > and watch the output then we can not ignore the boundard cases of > <0, 0, & >2. I had considered the above problem when made the patch, and i thought 0 is a invalid input and ignored it. Normally,a invalid input should lead to one of the following results. 1)a error 2)a undefined behavior I think a undefined behavior can not give user any guarantee, and it is not needed for modification to keep the undefined behavior same as past. However,i alse begin to agree with you danap,May be it is better to keep the behavior of DataSource.SetLogLevel(0) same as past and same as other invalid input(<0), consider that implementation for the guarantee seems not so hard. By the way, I suggest to add a new loglevel such as Driver.NONE(0) to explicitly set log off.So when Driver.setLogLevel() turn the log on, DriverManager.getConnection() or DataSource.setLogLevel() can turn the log off by a legal input Driver.NONE(0). Chen Huajun (2013/01/21 2:19), dmp wrote: > Hello Chen, > > Lets look at the current behavior without your patch of > both DriverManager and DataSource. > > Note: > > 1. X Indicating Parameter not set > 2. Boundary cases <0 and >2 > 3. DriverManager.getConnection() is the standard as > Chen you have stated, which DataSource should duplicate. > > DriverManager.getConnection(connectionString); > > Driver.setLogLevel() | ConnectionString &logLevel | Logging > > X <0 No Logging > X 0 No Logging > X 1 INFO Logging > X 2 DEBUG Logging > X >2 DEBUG Logging > ---------------------------------------- > <0 <0 No Logging > <0 0 No Logging > <0 1 INFO Logging > <0 2 DEBUG Logging > <0 >2 DEBUG Logging > ---------------------------------------- > 0 <0 No Logging > 0 0 No Logging > 0 1 INFO Logging > 0 2 DEBUG Logging > 0 >2 DEBUG Logging > ---------------------------------------- > 1 <0 No Logging > 1 0 No Logging > > You can continue down this path, but the behavior > will always be ConnectionString &logLevel overrides > Driver.setLogLevel(). Lets May sure we have the > last case though in the sequence which on review > seems to operate appropriately with logLevel now > following Driver.setLogLevel() when logLevel in > the connectionString is not set. > > ----------------------------------------- > <0 X No Logging > 0 X No Logging > 1 X INFO Logging > 2 X DEBUG Logging > >2 X DEBUG Logging > > DataSource.getConnection() > > Driver.setLogLevel() | DataSource.setLogLevel() | Logging > > X <0 No Logging > X 0 No Logging > X 1 INFO Logging > X 2 DEBUG Logging > X >2 DEBUG Logging > ---------------------------------------- > <0 <0 No Logging > <0 0 No Logging > <0 1 INFO Logging > <0 2 DEBUG Logging > <0 >2 DEBUG Logging > ---------------------------------------- > 0 <0 No Logging > 0 0 No Logging > 0 1 INFO Logging > 0 2 DEBUG Logging > 0 >2 DEBUG Logging > ---------------------------------------- > 1 <0 No Logging > 1 0 No Logging > > Again you can continue down this path and everything > looks good with DataSource.setLogLevel() overriding > Driver.setLogLevel(). Lets not forget though the last > case though which is broken as you pointed out. > > ----------------------------------------- > <0 X No Logging > 0 X No Logging > 1 X No Logging > 2 X No Logging > >2 X No Logging > > Now lets look at the current behavior your patch has which > I will present just one case where it breaks the standard > set by the DriverManager.getConnection(). > > DataSource.getConnection() > > Driver.setLogLevel() | DataSource.setLogLevel() | Logging > > ----------------------------------------- > 1 <0 No Logging > 1 0 INFO Logging <<<---- Breaks standard > 1 1 INFO Logging > 1 2 DEBUG Logging > 1 >2 DEBUG Logging > > Chen, > > If you would create sample code to run to validate both your > bug report and test your patch you may have seen the breakage. > I can tell you that in all cases when DataSource.SetLogLevel(0) > your patch breaks the standard of the user overrides the > Driver.setLogLevel() when it is stipulated. > > I know that valid inputs maybe only be Driver.INFO & Driver.DEBUG, > but if you treat the PgJDBC has a black box which you stimulate > and watch the output then we can not ignore the boundard cases of > <0, 0, & >2. > > danap. > > > Chen Huajun wrote: >> >> danap I am also a bit confused for what's the expected behavior of >> PgJDBC driver. > > -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc