Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqfeF-0006jX-6S for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Mar 2017 12:45:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cqfeE-0000bc-Pf for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Mar 2017 12:45:54 +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 1cqfeD-0000bT-VT for pgsql-hackers@postgresql.org; Wed, 22 Mar 2017 12:45:54 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cqfeB-0007mm-GR for pgsql-hackers@postgresql.org; Wed, 22 Mar 2017 12:45:52 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id D865020B8D; Wed, 22 Mar 2017 08:45:50 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Wed, 22 Mar 2017 08:45:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=iDrBckHleY1YHEkTsTa0+AKsYXyr2SpdXcz9Xda1bLE=; b=Cy5q5I68 xATO2nkU8azt5MqcE7hXUrWLoFIqDENv4FiqFtUmnz566Z3waRzm4QO1gbd2RtfC +UKuAqN6uy3f1nfVJetZT2eZEGnqzYIxkn+vIZ5V5axqLx9nWHxWxzYCSvqWd+hC qNf+N3cmXC1Hp0JsKdkc5v4afzm6byslgL3qbnK2NS8K3i1Ur3v+tBtXYmNfFgmR zmjiRda5ve2qfFdPP5kmY6Qpme8/wgW19CDc98wCaCBe8yH7mDnwfCc/zmfWD2O4 gSu8c6UhVWKzSLqNy4BtzxEA1Jvb0dQLd3hU1ue9vp2GO9fxCQkmRXqEhFn3ffMg AAq6K6jvmt5A8A== X-ME-Sender: X-Sasl-enc: XmawBFn3ZIfzkd1VUlHR2gh4Iip9wmGHNezF5MHM4OvR 1490186750 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id A34CC7E033; Wed, 22 Mar 2017 08:45:50 -0400 (EDT) Subject: Re: identity columns To: Vitaly Burovoy References: <6adbacbf-73bc-dd1a-2033-63409180fd18@2ndquadrant.com> <4ef801f2-64ce-1a58-277d-d9389ae7770d@2ndquadrant.com> <1cf308b6-4f5c-05ba-cc74-0a7121603fcf@2ndquadrant.com> Cc: pgsql-hackers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Wed, 22 Mar 2017 08:45:50 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) 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 On 3/22/17 03:59, Vitaly Burovoy wrote: > Column's IDENTITY behavior is very similar to a DEFAULT one. We write > "SET DEFAULT" and don't care whether it was set before or not, because > we can't have many of them for a single column. Why should we do that > for IDENTITY? One indication is that the SQL standard requires that DROP IDENTITY only succeed if the column is currently an identity column. That is different from how DEFAULT works. Another difference is that there is no such thing as "no default", because in absence of an explicit default, it is NULL. So all you are doing with SET DEFAULT or DROP DEFAULT is changing the default. You are not actually adding or removing it. Therefore, the final effect of SET DEFAULT is the same no matter whether another default was there before or not. For ADD/SET IDENTITY, you get different behaviors. For example: ADD .. AS IDENTITY (START 2) creates a new sequence that starts at 2 and uses default parameters otherwise. But SET (START 2) alters the start parameter of an existing sequence. So depending on whether you already have an identity sequence, these commands do completely different things. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers