Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UR4Ax-0000R9-Lh for pgsql-docs@arkaria.postgresql.org; Sat, 13 Apr 2013 17:23:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UR4Ax-0003eE-3B for pgsql-docs@arkaria.postgresql.org; Sat, 13 Apr 2013 17:23:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UR4Av-0003e6-74 for pgsql-docs@postgresql.org; Sat, 13 Apr 2013 17:23:41 +0000 Received: from mail-ia0-x233.google.com ([2607:f8b0:4001:c02::233]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UR4Ar-0004Bz-3a for pgsql-docs@postgresql.org; Sat, 13 Apr 2013 17:23:40 +0000 Received: by mail-ia0-f179.google.com with SMTP id l25so3233159iad.24 for ; Sat, 13 Apr 2013 10:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=jUyS3Ghs/epiPEToxYWndk0la8ySBak/s2W+y+DMK/Y=; b=z+PWtr5x0ZgwjSPnJmNuk+0eBP6nsQ8o0w00g+HX1IrBSIr4pjYEKNTJxeb5XqnKCF Dzdwzp2VXMNIpjmZ5lCa1+ib9At9OOMxRbakdfwRQhJtg4qj1VBsuJ7rPX//jQsLaHb/ C2WcjX75TSdVCAjOXV9mzk+AK1wjjE0ymg4AE3fuI9N63YlJChYvnqNxMAlwQhtpJ+yA BK3Ol3PsR84696ZIVbVtRm7TfVYVvF5diXX5OUz7FS0eBXjfTM0q/RDP339soESnJONp e1WXsh9xuFbw6YCX2HzUHvSoX09laZ3kz5qA/bpESAheNvNzzH3/nyKN7ymfQhl4o1MB D4uw== X-Received: by 10.42.42.69 with SMTP id s5mr8997957ice.2.1365873814693; Sat, 13 Apr 2013 10:23:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.31.36 with HTTP; Sat, 13 Apr 2013 10:23:14 -0700 (PDT) In-Reply-To: <1365858403.20086.7.camel@vanquo.pezone.net> References: <1365858403.20086.7.camel@vanquo.pezone.net> From: Rodrigo Barboza Date: Sat, 13 Apr 2013 14:23:14 -0300 Message-ID: Subject: Re: User defined type without single quotes To: Peter Eisentraut Cc: pgsql-docs@postgresql.org Content-Type: multipart/alternative; boundary=bcaec50fe5f588a41d04da414780 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --bcaec50fe5f588a41d04da414780 Content-Type: text/plain; charset=ISO-8859-1 Thank you, Peter! On Sat, Apr 13, 2013 at 10:06 AM, Peter Eisentraut wrote: > On Thu, 2013-04-04 at 19:50 -0300, Rodrigo Barboza wrote: > > -- my_uint32 is my new type > > CREATE TABLE test (a my_uin32); > > > > If I try to run this insert, postgres complain about the type: > > INSERT INTO teste (a) VALUES (10); > > > > But this one works: > > NSERT INTO teste (a) VALUES ('10'::my_uint); > > > > Is there a way to avoid the single quotes? > > > A constant like 10 is initially assigned one of the integer types (the > exact rules are in the documentation). In order to be able to store > that into a column of a custom type, you need to define a cast between > the integer type and your type with at least assignment context. > > --bcaec50fe5f588a41d04da414780 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thank you, Peter!


=
On Sat, Apr 13, 2013 at 10:06 AM, Peter Eisentra= ut <peter_e@gmx.net> wrote:
On Thu, 2013-04-04 at 19:5= 0 -0300, Rodrigo Barboza wrote:
> -- my_uint32 is my new type
> CREATE TABLE test (a my_uin32);
>
> If I try to run this insert, postgres complain about the type:
> INSERT INTO teste (a) VALUES (10);
>
> But this one works:
> NSERT INTO teste (a) VALUES ('10'::my_uint);
>
> Is there a way to avoid the single quotes?
>
A constant like 10 is initially assigned one of the integer types (th= e
exact rules are in the documentation). =A0In order to be able to store
that into a column of a custom type, you need to define a cast between
the integer type and your type with at least assignment context.


--bcaec50fe5f588a41d04da414780--