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 1t0siA-00DdCt-Fz for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Oct 2024 01:20:26 +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 1t0si7-00DqZG-Qi for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Oct 2024 01:20:24 +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 1t0si7-00DqVc-GI for pgsql-hackers@lists.postgresql.org; Wed, 16 Oct 2024 01:20:23 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t0si5-001Gyy-OB for pgsql-hackers@lists.postgresql.org; Wed, 16 Oct 2024 01:20:23 +0000 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-83a94a60379so33062139f.2 for ; Tue, 15 Oct 2024 18:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729041620; x=1729646420; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BnetJmr4jfW7g8zJFGR2T2Y7Z7AEyQTFMmq5QJa/AXY=; b=Ah2ZeIZfjr4vpGszty+qRaNScRFMVMXlCxiEIVukgHCT75bKvAKxKzuYA8h+OylfWS NoSiEQ0C3lIDNGp0tK+sQcgJEumFZPt+Vj2/XH4u7jTE6sONEwxtcp+T1KlbTWhKs5VT V7XfJ835I3dM80/nVVdjypDyMIWtApybukGQcG9yEtTpmc5F8Wy+egG3VZn1NziQ9Cvq Oy4Bt8yvCOuhJhGKSFOUjKS+YjpVsGgS4JO0DJcDTfra3ZCmZhpURL5VqYkXdELa4Y27 mjnynG4FK3A1vvhlj6dY6MizoJmf/epYy7DenTvRuObF/aY/uZ73njoYe7mG9r/0LqM/ dLag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729041620; x=1729646420; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BnetJmr4jfW7g8zJFGR2T2Y7Z7AEyQTFMmq5QJa/AXY=; b=MwoiAbBlIBDJIJoP5rEkiDCTxKsIeDL92Q6jlssTpfh7BDaeXV4/q/KUa6Q+D7SgCz BOc5tyjT4k6mHep9uMVdzWudZFFytpjBn/XqPFkwofi6GE2ll+Bw/+fNhsJG/w4gCd8b UB3URDsneC/ajLm+5c0xoM+1xNjT7QfGMo1v6idnMef62g2LpRV9W7UTSkbbNXMNmUlx rZmdDj6EcwJP28Shu9o2uZ6No3Ct2ybl+qV5RxesiUXb9CRHCzo+921nACCO6yp/j4m5 EDZyl7Y6P/OofQbupomDnZajtYaS3YqBh7wZKOZRDLriSBf8Ooidn7LLwudXHRszJb2C WZ/A== X-Forwarded-Encrypted: i=1; AJvYcCVpRmeNSmrr8sUtTthn1neoewL4MwaH3F7+Sbz8fJNRtV7FM6bFCkHEpzdDg+ULj/T78cpUczx2FmfOtTes@lists.postgresql.org X-Gm-Message-State: AOJu0YyF/+MXsbUDjCjeDW5Eh9oRCiLFuPts4d28+HO5sNF+MdxrvQGM JWudNrCraR8etrKGXkTDVctoTlk9fnqUK3zhhEUMRFmjSRtDVuzm X-Google-Smtp-Source: AGHT+IE+lFMKP+aMVNsV+MkwhI9duqJX+Gl6DOtWSt8rYaSJTCUI4t4Cnxv/5e+LDcT4Q2HS8XNjUA== X-Received: by 2002:a05:6602:1408:b0:83a:9476:2593 with SMTP id ca18e2360f4ac-83a947626b8mr298104239f.14.1729041620033; Tue, 15 Oct 2024 18:20:20 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-83a8b53c9c1sm53870539f.50.2024.10.15.18.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 18:20:19 -0700 (PDT) Date: Tue, 15 Oct 2024 20:20:17 -0500 From: Nathan Bossart To: Michael Paquier Cc: Alexander Lakhin , Tom Lane , "Jonathan S. Katz" , PostgreSQL Hackers Subject: Re: Large expressions in indexes can't be stored (non-TOASTable) Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Oct 16, 2024 at 09:12:31AM +0900, Michael Paquier wrote: > - if (!ctx->rel->rd_rel->reltoastrelid) > + if (!OidIsValid(RelationGetToastRelid(ctx->rel))) > > This set of diffs in 0002 is a nice cleanup. I'd wish for relying > less on zero comparitons when assuming that InvalidOid is in use. I'm wondering if there's any concern about this one causing back-patching pain. If so, I can just add the macro for use in new code. > +static inline void > +AssertHasSnapshotForToast(Relation rel) > +{ > + /* bootstrap mode in particular breaks this rule */ > + if (!IsNormalProcessingMode()) > + return; > + > + /* if the relation doesn't have a TOAST table, we are good */ > + if (!OidIsValid(RelationGetToastRelid(rel))) > + return; > + > + Assert(HaveRegisteredOrActiveSnapshot()); > +} > > Using a separate inlined routine is indeed cleaner as you have > documented the assumptions behind the check. Wouldn't it be better to > use a USE_ASSERT_CHECKING block? These two checks for normal > processing and toastrelid are cheap lookups, but we don't need them at > all in non-assert paths, so I'd suggest to ignore them entirely for > the non-USE_ASSERT_CHECKING case. I assume all of this will get compiled out in non-USE_ASSERT_CHECKING builds as-is, but I see no problem with surrounding it with an #ifdef to be sure. -- nathan