Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYG4u-0004yx-Cr for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Jan 2017 17:49:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cYG4t-0001TS-W9 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Jan 2017 17:49:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cYG3U-0007L7-2M for pgsql-hackers@postgresql.org; Mon, 30 Jan 2017 17:47:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cYG3R-00066t-Hp for pgsql-hackers@postgresql.org; Mon, 30 Jan 2017 17:47:50 +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 v0UHligD017594; Mon, 30 Jan 2017 12:47:44 -0500 From: Tom Lane To: Rahila Syed cc: Daniel Verite , Stephen Frost , Ashutosh Bapat , pgsql-hackers Subject: Re: Improvements in psql hooks for variables In-reply-to: References: <11456.1485288184@sss.pgh.pa.us> Comments: In-reply-to Rahila Syed message dated "Mon, 30 Jan 2017 11:08:59 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17592.1485798464.1@sss.pgh.pa.us> Date: Mon, 30 Jan 2017 12:47:44 -0500 Message-ID: <17593.1485798464@sss.pgh.pa.us> X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Rahila Syed writes: > Please consider following comments on the patch. > In function ParseVariableNum, >> if (!val || !val[0]) >> return false; > Check for 'val == NULL' as in above condition is done even in callers of > ParseVariableNum(). > There should be only one such check. Meh ... I don't think it's unreasonable for ParseVariableNum to defend itself against that. The callers might or might not be applying a check --- for them, it would be a matter of do they need to detect presence or absence of an option, but not about whether the option value is valid. >> + psql_error("Invalid value \"%s\" for \"%s\"\nAn integer is >> expected\n", > Cant we have this error in ParseVariableNum() similar to > ParseVariableBool() ? Agreed, error messages should be stylistically similar. I'm not sure they can be exactly alike though. Right now the patch has ParseVariableBool saying + psql_error("unrecognized value \"%s\" for \"%s\": boolean expected\n", + value, name); while callers that don't use that error use PsqlVarEnumError which has + psql_error("Unrecognized value \"%s\" for \"%s\"\nAvailable values: %s\n", + value, name, suggestions); and then ParseVariableNum is as above. So first off we've got a capitalization inconsistency. Project style for backend messages is no initial cap; psql seems not to be on board with that entirely, but I'm definitely inclined to go with it here. As for "invalid" vs. "unrecognized", I'm not sure "unrecognized" really fits the bill for "this isn't an integer". So I'm inclined to leave that alone. I suggest we go with these: "invalid value \"%s\" for \"%s\": integer expected\n" "unrecognized value \"%s\" for \"%s\": boolean expected\n" "unrecognized value \"%s\" for \"%s\"\nAvailable values are: %s\n." where the last case is following the message style for hints. >> + * Switching AUTOCOMMIT from OFF to ON is not allowed when inside a >> + * transaction, because it cannot be effective until the current >> + * transaction is ended. > The above change in autocommit behaviour needs to be documented. Yeah, definitely. I'll go ahead and push the patch with these fixes. Thanks for reviewing! regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers