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.96) (envelope-from ) id 1vM6a0-0014qP-0c for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Nov 2025 15:28:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vM6Zy-002XEJ-2q for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Nov 2025 15:28:15 +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.96) (envelope-from ) id 1vM6Zy-002XEA-1u for pgsql-hackers@lists.postgresql.org; Thu, 20 Nov 2025 15:28:14 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vM6Zv-000Xrp-1z for pgsql-hackers@postgresql.org; Thu, 20 Nov 2025 15:28:14 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-64080ccf749so1665456a12.2 for ; Thu, 20 Nov 2025 07:28:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763652491; x=1764257291; 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=wBw731Sjqa63iypZSRULG5k+/sZgn/i2UZsix4CwVSs=; b=M4tj5xvgnqiyE3/zYruD/K31/rP/rMc0vP3FWjMqiTdSQYfW+YuEoEZpm1fjL6fAO8 aQSIGst40fUseI4polWcpV2QTvQXkoYOWzYqTgyexSm+DO2KmzgvFO7rYMxwjCySAPqB /qw4YfCl68Z0jxLzaelglibuZ+mR+4SSLAjUGRo7kj5fTLAgd8RI3CYbPGmCSmQJElhm dpyvx5XniZFekNjqYfsb/UUSRQiVCoYLs0F30tc8MChZlQEvRaeeMM5J+Y8RAiXafT5e 1OBtlHgSkhwk0Hms1Zst7MIHGGOkDpN5VlmzkPtu2VC6MEhTFPgTSgxXfB1e/qvBIKL+ Ux0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763652491; x=1764257291; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wBw731Sjqa63iypZSRULG5k+/sZgn/i2UZsix4CwVSs=; b=I3rgelNpkUqSZid+jpCnafdsVg4Jd7L99QVuJd7cQQVy7P5J8Z/SJNOHWxz5g/+9nZ ESyfQ4MBLherfK5btD+DYaiVO1DsrrKHPWhrokcktAWhj8wZbuP6fFvCnqLLxVpiU8Zu vI+BuCEiN6PhtbWJlxBnWGiYcgc30iNFboSBAH9tzUF1zMqY0L5G3BgU/o51R4yMIz/9 Fh76YwgnRkcfXCYcfuK8nzLfR9dLU7ZQFdOQzFt5L2x7lhCGtf4sPrxmsIqAAw7387Tk rFf/ytwhe4kBvlZZtsBLqEF+n+s1AtePnhTZa11l8gKj7cHnPQJMDgqCeHC67TcVrfyk yqmA== X-Forwarded-Encrypted: i=1; AJvYcCWm6DHEyMeqNS1YrbUOhkA8NsCz6KU2Usp17lQ6TIjz+RBThXSCj4nBtgvYEeYc8OkDD2HFXOAzcqb5FR3q@postgresql.org X-Gm-Message-State: AOJu0YwOFP/P4Jv6I34ey0nSliH7QbJXru9m5+uC7sl+K6Hp2nw4SM5h uqa0Ag60kbIvFLP4S4CVQa7GaZNEY4H5y+pgRkjVbvEMHWKkmfuUvL2BCwY0B78wYPrAJzujB+r RexzA6IPPnIB9n2S6ND6un/M5RUUx7zE= X-Gm-Gg: ASbGnctdKInmehPdQicMKUg3t4elxHLxqT6r9CKCCgsiFeXu32YPLaojSpk+h4HEYLY YMqnnu4hN9Bes8InX9oWK+Ng4Y7GXzCo3zu3PjQ6zmmkp0upvkG0ZJnFXqOg1aI96eoi5syY+EU 5LTMvzCw7ntHeFIjHp+HXQwOMTsveUtVfu3ZBEAd5X/4xkovGrBp2Yp55B5T9/8P8EC83FlBqxe CaQAf4CCeposwsxMpbBL//jCZL4EfTKQiAhaOWRBnGl/xQ1twIKviG9jG6skUpIHBhfv9zc X-Google-Smtp-Source: AGHT+IEAc2jsd8yfJpMIj4WlVyYi+y7t5o1/0KW5lFzDWaqFEqhyhg78FJfxjgMpy7fbynLQRHt5eJU+LQ4QWqlOC48= X-Received: by 2002:a05:6402:42c4:b0:640:c95c:be17 with SMTP id 4fb4d7f45d1cf-645364594dbmr4065361a12.16.1763652490546; Thu, 20 Nov 2025 07:28:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Melanie Plageman Date: Thu, 20 Nov 2025 10:27:59 -0500 X-Gm-Features: AWmQ_bmkeICzdWZDrGMSQVOYSKP7YQ_VPNlBIvmu3YmvpXoXYw6NeSRmxPgRgfY Message-ID: Subject: Re: Trying out read streams in pgvector (an extension) To: Nazir Bilal Yavuz Cc: Thomas Munro , "Jonathan S. Katz" , pgsql-hackers 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 Wed, Nov 19, 2025 at 2:28=E2=80=AFAM Nazir Bilal Yavuz wrote: > > > To make sure 1) distance isn't reset to a resume_distance from > > read_stream_begin_relation() and 2) unexpected buffers aren't returned > > from the read stream, we could error out in read_stream_resume() if > > pinned_buffers > 0. And in read_stream_reset(), we would save distance > > in resume_distance before clearing distance. That would allow calling > > read_stream_resume() either if you called read_stream_reset() or if > > you exhausted the stream yourself. See rough attached patch for a > > sketch of this. > > This looks correct to me. What do you think about using an assert > instead of erroring out? I'm not totally opposed to this. My rationale for making it an error is that the developer could have test cases where all the buffers are consumed but the code is written such that that won't always happen. Then if a real production query doesn't consume all the buffers, it could return wrong results (I think). That will mean the user can't complete their query until the extension author releases a new version of their code. But I'm not sure what the right answer is here. - Melanie