Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hjUdp-0008D0-If for pgsql-general@arkaria.postgresql.org; Fri, 05 Jul 2019 20:17:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hjUdo-0006JH-FN for pgsql-general@arkaria.postgresql.org; Fri, 05 Jul 2019 20:17:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hjUdo-0005y9-5A for pgsql-general@lists.postgresql.org; Fri, 05 Jul 2019 20:17:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hjUd9-0005P8-07 for pgsql-general@postgresql.org; Fri, 05 Jul 2019 20:16:42 +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 x65KGK4e025357; Fri, 5 Jul 2019 16:16:20 -0400 From: Tom Lane To: PegoraroF10 cc: pgsql-general@postgresql.org Subject: Re: Converting to identity columns with domains on PK columns In-reply-to: <1562356860333-0.post@n3.nabble.com> References: <1562269287792-0.post@n3.nabble.com> <9dcaef4ca4f464078c22d4658eabd6baf43f9940.camel@cybertec.at> <1562326734199-0.post@n3.nabble.com> <81ddd3d0-bfb0-f52e-318c-622ab8e9fa9b@aklaver.com> <1562356860333-0.post@n3.nabble.com> Comments: In-reply-to PegoraroF10 message dated "Fri, 05 Jul 2019 13:01:00 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <25355.1562357780.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 05 Jul 2019 16:16:20 -0400 Message-ID: <25356.1562357780@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PegoraroF10 writes: > Adrian, on Firebird if you create a table or procedure with fields or params > declared with domains, they can be used with those domains or with their > base type. On Postgres I32 is not equal to integer. > create procedure myproc(id i32) returns(x i32) as ... > select * from myproc(cast(5 as integer)) -- works on firebird. On Postgres > it doesn´t because that procedure or function expects for a I32 and not a > integer. Really? regression=# create domain i32 as int; CREATE DOMAIN regression=# create function myproc(id i32) returns i32 language sql as 'select $1'; CREATE FUNCTION regression=# select myproc(cast(5 as integer)); myproc -------- 5 (1 row) I think the primary reason we don't allow domains over int for identity columns is that it's not clear how domain constraints ought to interact with the identity-value-generating behavior. regards, tom lane