Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahuT8-0000Oz-UR for pgadmin-hackers@arkaria.postgresql.org; Mon, 21 Mar 2016 07:41:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ahuT7-0004uE-US for pgadmin-hackers@arkaria.postgresql.org; Mon, 21 Mar 2016 07:41:41 +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 1ahuT7-0004u7-6h for pgadmin-hackers@postgresql.org; Mon, 21 Mar 2016 07:41:41 +0000 Received: from mail-lb0-x22c.google.com ([2a00:1450:4010:c04::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1ahuT3-0006j2-Gc for pgadmin-hackers@postgresql.org; Mon, 21 Mar 2016 07:41:39 +0000 Received: by mail-lb0-x22c.google.com with SMTP id oe12so121509091lbc.0 for ; Mon, 21 Mar 2016 00:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=2mNyDHy7ZZP7yuZXJiVDOI7MUE/qGl92fm8qwgWoQwU=; b=MBd/b5VOF3DhPj49w+71BUbNbLpQ+J9wAO5C9pUh5abHO1SSUsnJdzMlOOv2IFyZgs kXtDyPTWYkdRSAH7DnDfScbKJYzt2o7KkDqTLLp1Vi9d752c7BeJSITjM5yhMNWw4BU1 gGfHV3ZRRs3GX/RfZBoXXv1b3w9PFNJjzDRA4Nw+5oPyNSNOKacKg9V1rm2oVGPtLN3v ncB0QNDePF28OIZutnWtF+uCFvNRgxNMkQ7R/hokq3Y/J8APVNQ6QDuTGjgWtPVIoGTZ XozrrSc0vTQVElolrsuPqa/zq41WPE53OFt30clMiIT4hI6iXEFgK6rg9SqWYg+Xry1V dbjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=2mNyDHy7ZZP7yuZXJiVDOI7MUE/qGl92fm8qwgWoQwU=; b=Y694DYAU2u5DEW8UJgpg6I/0alBOgeiY7qweqysgAAKFYaY/v1OrkvrgDmj3fBxknr VWZlbouV1hH1oqDxi/Uy+IqLUMOZ9pdDZGbsm5USMWAhbAZIreFUyzraM4K7KbnnZSKU f5/eeV+AWM+XeX+bvSSpiZX/HC20bPsVL0ADxnFNC2mSKN3TrqcTKst560iNJrboZU7L fTYM2VkhrKECf/Ji4mHE/6AOtUFJg90oGAWXl/Kh8PzqCoUn1VWby9xAKOztEqfys7A4 3Pz3odNC2XDalu1UWMWHg6CI7cPN/ZWeatCgphbp8jF5NcCXQN8WRSTDiSoSbaz7yrkt imaw== X-Gm-Message-State: AD7BkJJz7hdT/DZZqph2e9Q/oTHdephSxyDfI9XvDWfdo8F0zcV+QqmJwudXjhdKA3hskus2MCct/7LSldj5s+xc MIME-Version: 1.0 X-Received: by 10.112.157.66 with SMTP id wk2mr8512037lbb.53.1458546094754; Mon, 21 Mar 2016 00:41:34 -0700 (PDT) Received: by 10.25.159.85 with HTTP; Mon, 21 Mar 2016 00:41:34 -0700 (PDT) In-Reply-To: References: Date: Mon, 21 Mar 2016 13:11:34 +0530 Message-ID: Subject: Re: pgAdmin4 PATCH: Domain Module From: Khushboo Vashi To: Dave Page Cc: pgadmin-hackers Content-Type: multipart/alternative; boundary=001a11c32484dde3bc052e8a3950 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org --001a11c32484dde3bc052e8a3950 Content-Type: text/plain; charset=UTF-8 Hi Dave, On Fri, Mar 18, 2016 at 8:31 PM, Dave Page wrote: > On Thu, Mar 17, 2016 at 5:39 PM, Khushboo Vashi > wrote: > > Hi Dave, > > > > I have a query regarding your below feedback : > > > > - Default values should be auto-quoted when necessary (ie. strings, on a > > text-based domain). > > > > To resolve this, I have checked the typcategory field from pg_type for > the > > base_type selected for the Domain. > > If the typcategory is String type (i.e. S), then only I have used > qtLiteral > > function to quote the default value. > > > > Is this right approach or not? > > Yes, I think that's a good approach (at least, I don't see any > downsides right now :-) ) > > After implementing above approach, I found some issues: 1> If I put quotes explicitly, user can not set any expression as a default value For example, CREATE OR REPLACE FUNCTION test_text_return() RETURNS TEXT AS $$ SELECT now()::text; $$ LANGUAGE 'sql'; CREATE DOMAIN text_domin AS TEXT DEFAULT public.test_text_return(); In this case, if I put quotes for default value, it will be set as a string rather than an expression. 2> When I set any string for the default value, it is getting stored with the datatype like 'test_default'::text So, in the Default Value (Properties Dialogue), it is showing 'test_default'::text I have tried pg_get_expr(typdefaultbin, 0) to fetch only default value (without datatype), but it returns the whole expression. As per my discussion with Ashesh, we feel - we should not quote the default value after looking at the above example. Please, let me know what should I do further? -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company --001a11c32484dde3bc052e8a3950 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Dave,


On Fri, Mar 18, 2016 at 8:31 PM, Dave Page <dpage@pgadmin= .org> wrote:
On Thu, Mar 17, 2016 at 5:39 PM, Khushboo Vashi
<khushboo.vashi@enter= prisedb.com> wrote:
> Hi Dave,
>
> I have a query regarding your below feedback :
>
> - Default values should be auto-quoted when necessary (ie. strings, on= a
> text-based domain).
>
> To resolve this, I have checked the typcategory field from pg_type for= the
> base_type selected for the Domain.
> If the typcategory is String type=C2=A0 (i.e. S), then only I have use= d qtLiteral
> function to quote the default value.
>
> Is this right approach or not?

Yes, I think that's a good approach (at least, I don't see a= ny
downsides right now :-) )

=C2=A0<= /div>
After implementing above approac= h, I found some issues:

1> If I put quotes explicitly, user can not set any expression as= a default value=C2=A0
=C2=A0 =C2=A0 For example,

=C2=A0CREATE OR REPLACE FUNCTION test_tex= t_return() RETURNS TEXT AS
$$
=C2=A0SELECT now()::text;
$$ LANGUAG= E 'sql';


CREATE DOMAIN text_domin AS TEXT DEFAULT public= .test_text_return();

<= /span>
=C2=A0=C2=A0=C2=A0=C2=A0 = In this case, if I put quotes for default value, it will be set as a string= rather than an expression.


2> When I set any string for the default value, it is get= ting stored with the datatype like 'test_default'::text
<= /div>
=C2=A0=C2=A0=C2=A0=C2=A0 So, in = the Default Value (Properties Dialogue), it is showing 'test_default= 9;::text
=C2=A0=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 I have tried p= g_get_expr(typdefaultbin, 0) to fetch only default value (without datatype)= , but it returns the whole expression.


As per my discussion with Ashesh, we fe= el - we should not quote the default value after looking at the above examp= le.

Please, let me know what should I do further?


--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--001a11c32484dde3bc052e8a3950--