Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j4ANq-00024a-Vy for pgsql-committers@arkaria.postgresql.org; Tue, 18 Feb 2020 21:26:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j4ANp-0004h4-Hw for pgsql-committers@arkaria.postgresql.org; Tue, 18 Feb 2020 21:26:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j4ANp-0004gx-31 for pgsql-committers@lists.postgresql.org; Tue, 18 Feb 2020 21:26:21 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j4ANi-0004Ae-Cu for pgsql-committers@lists.postgresql.org; Tue, 18 Feb 2020 21:26:19 +0000 Received: by mail-pf1-x429.google.com with SMTP id x185so11297526pfc.5 for ; Tue, 18 Feb 2020 13:26:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=glfngPmNssPpFqrUuqsUrur1XtFSUyI7jb97z2Bw/TI=; b=vsgxgyIq3fF2S6ZZXQrqabp5o3KZBoMurbl6YxI3+G7P5LBUSV4fp9uEYPHtQK3rfY 2bfk3K9u4eGhH2vejINeWTlLeCtaXFTIidJfmeh9ZFkaCubW1bTFO2mYl32P6jVz65f/ Jzseny7r6IXZ+aqSPHq6DKdCDG6JW1+WLh7izzk400xjeRQxR9nw9WSu+ntLJ6cOe+do H2yzYx+OR0OUx2/M3AJ/wdt8aiMycnwg+QEDOEfOV4MK8jE4p8U7t/mGL0JJ7dFFE0FR RklDzYN6IA4PDVvuCZ3dWAxYt81kl9elL5lVx/OYsP3G9S3okc+mT/Bzof8NN61/SKwJ Dy6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=glfngPmNssPpFqrUuqsUrur1XtFSUyI7jb97z2Bw/TI=; b=I56XR/GhnyMY6g1JbiA9JJ2+GeMsTYspcIHELK1a0rUC/wgcjBIRl7k5q6rynGA1cA BLXv1lidxV+XQB6Lc6DhtHbw5YM3VPQ2bBtujcdl9Jefep59vuCMMl2cLZjcur1g1Yyp IHpK2qkP7E6LOXvVTZ03S0SKn8s27Kc/vJc3CUde62AMsitnxn2S7c61TmSl9y+O5orV NlGs+yig8QsjSMWyTrxOfWHv4A/4VVODZpzq1sequKiNrH+k2cRsrl5vkleMrQsnnxEJ xjrQGcM3+m6DpDXGsAxXNsUDnMi8C15+7fAU758NKR8/qCNoDAqtWyWT++ggI62/7qrn N3dQ== X-Gm-Message-State: APjAAAXXq+b4ke76uaZa9Y2uflJg7y6j5pzg5F+kftuWv2/kFmo9fvlP z2XOSnwXJ0wtMKzHZ/Yoznn+Mw== X-Google-Smtp-Source: APXvYqxJW5vJ80glf2WbcC72Vrrr+uAE1Oryf+ADKOd8GN7iI36aJ+b+muK5VcTuvjyR5/b8GVpXrA== X-Received: by 2002:a62:e91a:: with SMTP id j26mr23902546pfh.189.1582061172964; Tue, 18 Feb 2020 13:26:12 -0800 (PST) Received: from jdavis (102.sub-174-194-146.myvzw.com. [174.194.146.102]) by smtp.gmail.com with ESMTPSA id h3sm5058671pfo.102.2020.02.18.13.26.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 13:26:11 -0800 (PST) Message-ID: <96262b6442f8f752f42b50e9cc8ee69e0d9b43fc.camel@j-davis.com> Subject: Re: pgsql: Logical Tape Set: lazily allocate read buffer. From: Jeff Davis To: Tom Lane , Jeff Davis Cc: pgsql-committers@lists.postgresql.org Date: Tue, 18 Feb 2020 13:25:52 -0800 In-Reply-To: <20351.1581868306@sss.pgh.pa.us> References: <20351.1581868306@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, 2020-02-16 at 10:51 -0500, Tom Lane wrote: > Is there a reason for that to be coded in such an obscure and fragile > fashion, rather than having the test be say "if (lt->buffer == > NULL)"? I did that to match the original behavior, which is to only allocate the read buffer if the tape is non-empty. A tape with a NULL buffer is in a valid state after a rewind, though it's precarious. It raises quite a few questions about what the valid states of a tape are, and what usages of the API are allowed. That was all true even before 7fdd919a (or perhaps I made a mistake and moving the code around was not safe after all). I think the best fix now is to just allocate the buffer even if the tape is empty. That would stop Coverity from complaining, and I couldn't detect any obvious performance regression. Later, we can document the valid states a little better, and validate them with Asserts and/or the type system. Regards, Jeff Davis