Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU3tw-00053t-Fe for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Feb 2023 11:00:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pU3tu-0001WB-Vp for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Feb 2023 11:00:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU3tu-0001Vz-Kf for pgsql-hackers@lists.postgresql.org; Mon, 20 Feb 2023 11:00:06 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pU3ts-0004am-91 for pgsql-hackers@lists.postgresql.org; Mon, 20 Feb 2023 11:00:05 +0000 Received: by mail-lf1-x129.google.com with SMTP id m6so1256246lfq.5 for ; Mon, 20 Feb 2023 03:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YRE5LIqfgsHl7PtIV9m7melPNhCTUR2zj5zOVK47BNQ=; b=PoQBUlHrQM8xVQwpjaH3OihTEZahIf/vtP+GO4yNCPkqaMKw4+PZaUAf83MwDqL/aW 7IixGoXYpNqPI9zA/jS9lzCY2yBQnSi/XEMwKREIc2/eEYyVqYv/mtR/BFLktjZocTT9 P2jOkXtvMCC5YisJGHPc0kPMlSWrdpVN816oA0KzbWA5vc0QgI7NgThms8avc2Ph98xk aidFM9PDZk/aMYAGx0yiWjEhepUY+C6xSSltJZySqZuPXg07OvHRVNzqJFDlKiwJd2R2 S/sc+fpfje6gkubEmjuuyb284LLXzX5lk9zF4Hb5qghncfjz5unCwvxyV5+nkikzXgPl H14Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YRE5LIqfgsHl7PtIV9m7melPNhCTUR2zj5zOVK47BNQ=; b=DEL0qS3cKomZaqnrrXSIOHwF06CIDSNfFk1ggSJ7jAIbEM5ktrJzNhI8QGNVhurB1a TgPeTxcRMF8dube20g4S6FV38TWk5Jc6gEq93G3bnpiASKaxhPXOmvZG1A7b51DxkeFh qmPPkuenkEKKAGvwBDC80Ou79mH73H1vuZRspUlwEtLiGTj6WP1qEIUOmggLXmoDRN/t Dp2XcooQbcbmAFQvJ5WlkxAZMZRPEoeHSAWr9eivY4ZVG617kmILnLZpCOYuhO0WpuLB ClJl2VLvcGOXbOtF7K9ZnuQIRiZBsA7R/5WVtnEAF93hSpvfPmdP0eYwKHkEQQdsOMi6 nFeA== X-Gm-Message-State: AO0yUKUg6fFTQFnxgIP+oG3EwEFAOqjfzl1CDD4zONirHWJaxMw/w5kj IkH0ih4+KcCQan+yo9Mrxf4= X-Google-Smtp-Source: AK7set96dx+gkI/7wQQsrkxSkEBGqIUBRhRoYgm6gbzN3izKauAU71F7NysL9LdQY032QeWLiWwNzQ== X-Received: by 2002:ac2:5691:0:b0:4db:d97:224d with SMTP id 17-20020ac25691000000b004db0d97224dmr270627lfr.19.1676890802383; Mon, 20 Feb 2023 03:00:02 -0800 (PST) Received: from [1.0.0.7] ([178.155.5.178]) by smtp.gmail.com with ESMTPSA id y9-20020a197509000000b004d887e0e9edsm1490723lfe.168.2023.02.20.03.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Feb 2023 03:00:01 -0800 (PST) Message-ID: <36bee393-b351-16ac-93b2-d46d83637e45@gmail.com> Date: Mon, 20 Feb 2023 14: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: Killing off removed rels properly Content-Language: ru-RU To: Tom Lane , Richard Guo Cc: pgsql-hackers@lists.postgresql.org References: <229905.1676062220@sss.pgh.pa.us> <1343881.1676313553@sss.pgh.pa.us> From: Alexander Lakhin In-Reply-To: <1343881.1676313553@sss.pgh.pa.us> 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 Tom, 13.02.2023 21:39, Tom Lane wrote: > Richard Guo writes: >> On Sat, Feb 11, 2023 at 4:50 AM Tom Lane wrote: >>> I think it's time to clean this up by removing the rel from the >>> planner data structures altogether. The attached passes check-world, >>> and if it does trigger any problems I would say that's a clear >>> sign of bugs elsewhere. After this change the following query triggers an assert: CREATE TABLE tt (tid integer PRIMARY KEY) PARTITION BY LIST (tid); CREATE TABLE ttp PARTITION OF tt DEFAULT; CREATE TABLE st (sid integer); MERGE INTO tt USING st ON tt.tid = st.sid WHEN NOT MATCHED THEN INSERT VALUES (st.sid); ... #5  0x0000556fe84647eb in ExceptionalCondition (conditionName=0x556fe8619a46 "operation != CMD_MERGE",     fileName=0x556fe8618b73 "createplan.c", lineNumber=7121) at assert.c:66 #6  0x0000556fe8126502 in make_modifytable (root=0x556fe945be40, subplan=0x556fe9474420, operation=CMD_MERGE,     canSetTag=true, nominalRelation=1, rootRelation=1, partColsUpdated=false, resultRelations=0x556fe9475bb0,     updateColnosLists=0x0, withCheckOptionLists=0x0, returningLists=0x0, rowMarks=0x0, onconflict=0x0,     mergeActionLists=0x556fe9475c00, epqParam=0) at createplan.c:7121 #7  0x0000556fe811d479 in create_modifytable_plan (root=0x556fe945be40, best_path=0x556fe9474a40)     at createplan.c:2820 #8  0x0000556fe811912a in create_plan_recurse (root=0x556fe945be40, best_path=0x556fe9474a40, flags=1)     at createplan.c:530 #9  0x0000556fe8118ca8 in create_plan (root=0x556fe945be40, best_path=0x556fe9474a40) at createplan.c:347 #10 0x0000556fe812d4fd in standard_planner (parse=0x556fe937c2d0,     query_string=0x556fe937b178 "MERGE INTO tt USING st ON tt.tid = st.sid WHEN NOT MATCHED THEN INSERT VALUES (st.sid);", cursorOptions=2048, boundParams=0x0) at planner.c:418 ... It seems that before e9a20e451 the other branch of the following condition in make_modifytable() was executed:         /*          * If possible, we want to get the FdwRoutine from our RelOptInfo for          * the table.  But sometimes we don't have a RelOptInfo and must get          * it the hard way.  (In INSERT, the target relation is not scanned,          * so it's not a baserel; and there are also corner cases for          * updatable views where the target rel isn't a baserel.)          */         if (rti < root->simple_rel_array_size &&             root->simple_rel_array[rti] != NULL)         { ... Best regards, Alexander