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 1tHM3p-006Slt-Ib for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Nov 2024 11:54:53 +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 1tHM3m-00GBG0-RR for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Nov 2024 11:54:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tHM3m-00GBFq-He for pgsql-hackers@lists.postgresql.org; Sat, 30 Nov 2024 11:54:51 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tHM3k-000JKv-DS for pgsql-hackers@postgresql.org; Sat, 30 Nov 2024 11:54:51 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-aa51b8c5f4dso363253566b.2 for ; Sat, 30 Nov 2024 03:54:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732967687; x=1733572487; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=goaPo9J72GxLcPDwV+C7n9rY+b+JMsHmO+q80kiKpXA=; b=D06pfeHghcOk0uH45f9BUjrjf0J6Av6wBiMW6/PaR9sN/DGymFYEjWbVayayGSk1VS uZvkrzn3N7tXQbTxSo2gEGUn8vqOshdKDXKHVKCn5EpibsQWG5FqUIARVt3IQ4FE1+DV PWTHmeyMdvqdCcCvx4Wta4x/pC/k8EK5MHWv9jv6CuqTR5kmnBUio3ZsDVK6c4/mZzUW zP3XENDt4zOEnS36GwqkYmdRNWTX3xJB/R4Cit3FqgBGhDk9yieTrfI0DeHPNsjnFF0e VjGBMIUiOCcuQmF02eNS5beoeqGfC+qPgegoEzN0KuYoTiur0NN15h9tqcD1FK8d7pX8 dDOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732967687; x=1733572487; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=goaPo9J72GxLcPDwV+C7n9rY+b+JMsHmO+q80kiKpXA=; b=Bjp0L+WCsvEmQAgZpNzZDGdqcyBcQVuEOwbPJ4kRc6iutToqhvDUlMeQu7dzbZcBus rfDHhJiQBMenOk7kFABfPfJ03w+DkPW88RhUHJz/ULDRV8tVg/HptR+Mx62fxa9w2WJg A52A9jyY4Fkr8YOH66rF6VAdu7JnmNW5BuDXidTZLjNqGsM0a2COsXljUkUVIj7GBSTM 3qCOI1wgsGKcm2QZexYPgI2IGX2ZECqJK2Z8skH9a4d8IsYYuxbEUFuh+JpP5zek8o9B bAKLLjeVK8lMEx5iBSOLFcE6JrBcq0DdXINvgwJ1VgTOcde5HOmBjyxbYuqRg8tg3MBJ pogQ== X-Gm-Message-State: AOJu0Ywf+z/hL5qcxPj3he95jVWFol1GzVvwbYVf4j92Zjen109y5jUf sC4DJ23rm8gCWxadZx8lVk84s+EP9hbPxpX1G1DDcJd3pYLDnbbZgifws1pOJU9X0uRmatKfSxj cyYxlsLoyLNECr4aMGIpNwVl9z3cgN5FH5ubscOYl X-Gm-Gg: ASbGncsMeo37dgc3jQYnvpBrnpXyPO6kY3HJ4K9gPtDSnTYJ7uEoNLhr1qaaxo/O8Ch S/0lEdWaTtHvmqNOOYtyZfCrKeeq4TkU= X-Google-Smtp-Source: AGHT+IEVVRQNBUz8I82KTfonMzSQ4FW0puvifvOB5ZvlhFTYUlk7283r12FRQrBX17uJuGVzPPdFBjuE9Qqsg5hW3ps= X-Received: by 2002:a17:906:1ba9:b0:aa5:4672:663b with SMTP id a640c23a62f3a-aa581062a73mr1187539866b.55.1732967687122; Sat, 30 Nov 2024 03:54:47 -0800 (PST) MIME-Version: 1.0 References: <582986626.20241129201134@dima.nikitin.name> In-Reply-To: <582986626.20241129201134@dima.nikitin.name> From: Junwang Zhao Date: Sat, 30 Nov 2024 19:54:35 +0800 Message-ID: Subject: Re: Unclear code - please elaborate To: Dmitry Nikitin Cc: pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Nov 30, 2024 at 4:15=E2=80=AFPM Dmitry Nikitin wrote: > > Hello , > > https://github.com/postgres/postgres/blob/5d39becf8ba0080c98fee4b635755= 52f6800b012/src/backend/optimizer/prep/prepjointree.c#L3856 > bms_next_member() is allowed to return the zero as a valid value. Subsequ= ent rt_fetch() offsets that > zero to -1 which leads to the assertion down the code. Nothing wrong here= ? Either zero is simply not > possible after that bms_next_member() because of some factors behind the = code? > rtindex 0 is not used, see the logic of setup_simple_rel_arrays and the com= ments of PlannerInfo.simple_rel_array. /* * simple_rel_array holds pointers to "base rels" and "other rels" (see * comments for RelOptInfo for more info). It is indexed by rangetable * index (so entry 0 is always wasted). Entries can be NULL when an RTE * does not correspond to a base relation, such as a join RTE or an * unreferenced view RTE; or if the RelOptInfo hasn't been made yet. */ > > -- > Best regards, > Dmitry mailto:pgsql-hackers@dima.nikitin.name > > > --=20 Regards Junwang Zhao