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 1t4KrI-0001i3-MP for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Oct 2024 14:00:08 +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 1t4KrG-0004Iz-VB for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Oct 2024 14:00:07 +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 1t4KrG-0004Iq-IE for pgsql-hackers@lists.postgresql.org; Fri, 25 Oct 2024 14:00:07 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t4KrE-002o0M-8c for pgsql-hackers@postgresql.org; Fri, 25 Oct 2024 14:00:05 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-539e3f35268so2709218e87.3 for ; Fri, 25 Oct 2024 07:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729864802; x=1730469602; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=cH57jKLmrxk+v09rbhNpm0RO94sNX1vcKyX7gEqHW+s=; b=ZuiTWSW6Lo/ShGfVwNROMixsG6aDeooQFH5ehCQSkGlAjUtz4XA8PlkVpYstuTG8PZ V4jr3Ov8+J9FwPsazmx5jOXxqKA6OTYt8EaXMV90jeWBno+eLtiaA8eTYEdasC6wjOsZ y6rUDEzfG3dsv0rweq0CpriUGdUn+fnlE6W6pkV77HmUeGe9u9D7Mgg9O1SUFdEX3uju 3RtlhDsja40MuGdSK2I74br+8t9XV5Q1bWMGF5BGXnL4qPkYaqCrxvA9yTzKU1LGdmEV EOv5nb0P8qodAcKKjsJG+RazpH/a0f4uYhe81Yk32tcLNZOmCzBimH10ALiiAnLsk5Hz MPYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729864802; x=1730469602; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cH57jKLmrxk+v09rbhNpm0RO94sNX1vcKyX7gEqHW+s=; b=Co31bAwC9dzFzhcXXRlPhyVsPPUfgc9VOmwY+bdhYf/jpF4IktOn68o48YvePJWY/L epIyKFcFWkW2MIdAIwtuaXk5SEPDz+gbwZY/WZ8+YCLPRMo/bZFhWvy+dgowfHxGtcLr ZivZJkZ1UyX73gQvs/ewMBDdYh5xDpspZ41MSsj12dkSFv9ihcZ8GgwzDa1BFAFzdOAa ZWwoevSp5JfFMSW2cChQNTSqRR2I4sJvX6AMGeZPGPzug40/0ftkxkl+p325QzWluNAz C/92MkJDPT+G7wfkArteJYYtc+kZKPQNp1ZjeqYvIK6Pg9tjt26WK54MYyo3CVrHtoAI kw9g== X-Forwarded-Encrypted: i=1; AJvYcCXZnKM7rSpRXC6v43L3NJ2xQalOUClP4CBlWi9IGXwB/MQniObLTE9oKwaJV/wknh9C0etJzO+4ao+v5BrP@postgresql.org X-Gm-Message-State: AOJu0YxtyrCB+8moTj0TMLRwIm2VvLlQyYX6BlDDVB1rI9UG09qKtPy7 taHGWqZsDVcvoKNQAgqLeXnHPuqI8d6H4WLr8CUW7cSiEzU1pZnc X-Google-Smtp-Source: AGHT+IExtufbWZxQANt0pfQQsTYXGR8V2RZPkfjZ66CCYl3bmVb6/gHNFQxptD97UA1NFbCOkV58AQ== X-Received: by 2002:a05:6512:e83:b0:52e:9e70:d068 with SMTP id 2adb3069b0e04-53b1a2f1fdfmr5614828e87.4.1729864802180; Fri, 25 Oct 2024 07:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.29.188]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53b2e1df213sm196919e87.260.2024.10.25.07.00.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Oct 2024 07:00:01 -0700 (PDT) Message-ID: Date: Fri, 25 Oct 2024 17:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails Content-Language: en-US From: Alexander Lakhin To: Alvaro Herrera , Tender Wang Cc: Jehan-Guillaume de Rorthais , Junwang Zhao , "pgsql-hackers@postgresql.org" , Guillaume Lelarge , Michael Paquier References: <202410221432.3qtqbk2q6o7q@alvherre.pgsql> <461e9c26-2076-8224-e119-84998b6a784e@gmail.com> In-Reply-To: <461e9c26-2076-8224-e119-84998b6a784e@gmail.com> 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 Hello Alvaro and Tender Wang, 24.10.2024 17:00, Alexander Lakhin wrote: > Please look at a new anomaly introduced with 53af9491a. When running the > following script: > CREATE TABLE t (a int, b int, PRIMARY KEY (a, b)); > CREATE TABLE pt (a int, b int, FOREIGN KEY (a, b) REFERENCES t(a, b)) >  PARTITION BY LIST (a); > > CREATE TABLE tp1 (x int, a int, b int); > ALTER TABLE tp1 DROP COLUMN x; > > ALTER TABLE pt ATTACH PARTITION tp1 FOR VALUES IN (1); > > ALTER TABLE pt DETACH PARTITION tp1; I've also discovered another anomaly with a similar setup, but it's not related to 53af9491a. CREATE TABLE t (a int, PRIMARY KEY (a)); INSERT INTO t VALUES (1); CREATE TABLE pt (b int, a int) PARTITION BY RANGE (a); ALTER TABLE pt DROP COLUMN b; ALTER TABLE pt ADD FOREIGN KEY (a) REFERENCES t ON DELETE SET DEFAULT (a); CREATE TABLE tp1 PARTITION OF pt FOR VALUES FROM (1) TO (2); ALTER TABLE pt DETACH PARTITION tp1; DELETE FROM t; \d+ t This script ends up with: ERROR:  invalid attribute number 2 ERROR:  cache lookup failed for attribute 2 of relation 16398 (Perhaps it deserves a separate discussion.) Best regards, Alexander