Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tskOu-005Dxr-6p for pgsql-general@arkaria.postgresql.org; Thu, 13 Mar 2025 15:23:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tskOs-00GDAk-S9 for pgsql-general@arkaria.postgresql.org; Thu, 13 Mar 2025 15:23:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tskOr-00GDAc-Mf for pgsql-general@lists.postgresql.org; Thu, 13 Mar 2025 15:23:10 +0000 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tskOp-002dO1-0w for pgsql-general@postgresql.org; Thu, 13 Mar 2025 15:23:08 +0000 Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 07FCB11400F7; Thu, 13 Mar 2025 11:23:06 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Thu, 13 Mar 2025 11:23:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1741879386; x=1741965786; bh=pKzw6V9UzJZuO4w1nR0y3VkeFt9h7fxNwjfdDysXcmU=; b= jZKFnZYrk43HomwILu+y+fsrCtXiHNowNc6ivqhVPtgl6WaVF9ckRIc72MaL3oi6 BUh3Mhar66gUiJyer0OMzWiogKou2FzbxUUwceb1oU+B2rokMlv0NqrS6TU2qf2s L8reFPweKcD4aEa4FiKuhM7ixTsOzP8CbdTwTkC49oQQhcf2q2nFVWaiWEntL7j4 k7vYY4DxFK0YIHUaTnzem9OsBk9bdqHRXL+N9nUclhG7LZ+4O2eXkGkuADUmx5nK l71a4/mJtLiMT3rBmS9Xif2itwg2lL2ouHpRBKDfIY4UoAqep/mj7DRyCr2wTZGk mbPmRhpLc/BtsrGpZXNLBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1741879386; x= 1741965786; bh=pKzw6V9UzJZuO4w1nR0y3VkeFt9h7fxNwjfdDysXcmU=; b=3 miuFlBM5DY0/LZ++gRP6lFKIETbRiIo+5a84AXyXS4EdQmkFGOoi/NdbJggHkveU r+yszmUlU7wS6SHbt+ONkH0GHv1gKtaTxJfuLHS22RI+oXp0ADqjrNlSmFhIBPxP ylNBYTENHK5deQ1D9VsEV3wpWTlNK86iFCAzjSpntlQR6dAYOCWTPrzZmHoiL2aO IhKrmK7t8PPMWJcdVA9lvNQN/e37WWyTbuoB86L5StWDKqW0C4RVqG1fYcqBI1FX +tekH6+91UOeBr5lDlMPbTcbJ/KGvlHvvICoUB7sx+yT1qYiy/RCev/fhj7dHzxw 4CVTc1ftIJVR1nH5mzvNw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduvdekfedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkff ggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghnucfmlhgr vhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtf frrghtthgvrhhnpeehvdeiffdvieetleejgeduieefhefhiedvffelueehveeutedugeff keehtdfgieenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgpdgprghmrgiioh hnrdgtohhmpdgrmhgriihonhdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrd gtohhmpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthho pehmrghrkhgsrhgrugihjhhusehouhhtlhhoohhkrdgtohhmpdhrtghpthhtohepphhgsh hqlhdqghgvnhgvrhgrlhesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Mar 2025 11:23:05 -0400 (EDT) Message-ID: <76cc9aae-2ae9-4211-8d42-ca7f81ea2632@aklaver.com> Date: Thu, 13 Mar 2025 08:23:04 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Duplicate Key Values To: mark bradley Cc: pgsql-general References: <513ddbee-135c-4af2-b6f6-acca667b8d09@aklaver.com> <84aac7bf-5638-4f1f-9772-ace0ea27e848@aklaver.com> <9203d0df-0ddd-4564-a985-59bcfcf1d294@aklaver.com> <08c96195-3d5f-4902-b5d7-15916a02e23f@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/13/25 07:56, mark bradley wrote: > >Mark, to illustrate: > > >create table node (node_id integer primary key, fld1 varchar); > >create table node_1 (node_id integer primary key, node_1_fld boolean) > >inherits ( node); > >NOTICE:  merging column "node_id" with inherited definition > > >insert into node values (1, 'dog'); > >insert into node_1 values (1, 'cat', 'f'); > > >select * from node; >  > node_id | fld1 > >---------+------ > >        1 | dog > >        1 | cat > > That would make sense except that I never explicitly use the > *inherits* option in the *node_1* (my *dataset*) table.  Postgres seems > to be assuming that. 1) Well it is there from \d node: Number of child tables: 2 (Use \d+ to list them.) and from \d dataset and \d processing_node Inherits: node Also it explains the behavior. 2) Postgres does not assume that, it was done explicitly by some command. > > Also, the second column in *node* and in *dataset* are two different > columns.  However, Postgres insists on the *node_type* attribute being > included (last column) in table *dataset *and won't let me delete > it.**This is redundant because every dataset is a dataset type of node. That is what inheritance does: https://www.postgresql.org/docs/current/sql-createtable.html " The optional INHERITS clause specifies a list of tables from which the new table automatically inherits all columns. Parent tables can be plain tables or foreign tables. Use of INHERITS creates a persistent relationship between the new child table and its parent table(s). Schema modifications to the parent(s) normally propagate to children as well, and by default the data of the child table is included in scans of the parent(s). If the same column name exists in more than one parent table, an error is reported unless the data types of the columns match in each of the parent tables. If there is no conflict, then the duplicate columns are merged to form a single column in the new table. If the column name list of the new table contains a column name that is also inherited, the data type must likewise match the inherited column(s), and the column definitions are merged into one. If the new table explicitly specifies a default value for the column, this default overrides any defaults from inherited declarations of the column. Otherwise, any parents that specify default values for the column must all specify the same default, or an error will be reported. CHECK constraints are merged in essentially the same way as columns: if multiple parent tables and/or the new table definition contain identically-named CHECK constraints, these constraints must all have the same check expression, or an error will be reported. Constraints having the same name and expression will be merged into one copy. A constraint marked NO INHERIT in a parent will not be considered. Notice that an unnamed CHECK constraint in the new table will never be merged, since a unique name will always be chosen for it. Column STORAGE settings are also copied from parent tables. If a column in the parent table is an identity column, that property is not inherited. A column in the child table can be declared identity column if desired. " > So, I think the crux of the problem is that Postgres assumes that > inheritance is declared when it is not. No it does not, as the screenshot shows. There is an explicit setting for 'Inherited from table(s)' > > More answers to your questions coming. > > Best regards, > Mark Brady > _amazon.com/author/markjbrady _ -- Adrian Klaver adrian.klaver@aklaver.com