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 1vvvLP-00AQWZ-06 for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Feb 2026 10:45:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvvLN-002UEL-36 for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Feb 2026 10:45:13 +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.96) (envelope-from ) id 1vvvLN-002UE6-21 for pgsql-hackers@lists.postgresql.org; Fri, 27 Feb 2026 10:45:13 +0000 Received: from mail-dl1-x122f.google.com ([2607:f8b0:4864:20::122f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vvvLK-00000001YJc-35nL for pgsql-hackers@lists.postgresql.org; Fri, 27 Feb 2026 10:45:13 +0000 Received: by mail-dl1-x122f.google.com with SMTP id a92af1059eb24-12732e6a123so1801051c88.1 for ; Fri, 27 Feb 2026 02:45:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772189109; cv=none; d=google.com; s=arc-20240605; b=VbQAZ4XCUNhsMfrdv/onY9Vb4gyCZqRf5bGM0PFi3RlPzuLWCs1YnhvpwoCoXI+ft7 0yeSpi3DedZhr5L2we0ZFnKFJyMDLPYMoKd9s8XpZo/9mO8E5KkqgbzSTJbGtZKKMMzN TBwY8pc8+OkM1L/T4qP7layl0+QKjKswd+bnAVvbtiKHuqF73pP7Ue89dhEO5uBq74U3 H2OvW4wAsDdKYsy1bz3kR/EUt5tnaDuRDw3a8RGCrY2IoQQOqyVy++Wh/V4d59j9vgWu DoJvsL8rT0CvdQdMQkR5TDIahn1P/gKNq9PrxS2iHWClYDgSYJLn7injJapcLjfDnUaT PlcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=Pf62O3cz8hk+GWrh946XGA4lipXT9dErCKXSEqKgzQU=; fh=AZrUifxl7VsQCpqQRN+W0fHWaSH064hCAtgYY87IdaA=; b=XkQgnGBeqtdPRvbp3upRNOLxqYGrxoOYISqjs56W3F8o78Boj8K3ZMzKs0sR3HGMrE gWy4WU7doJcEqTTzkW56woHvCGF563QyUP4b2ywd/dQbbYeXDCUCl4ljch/3kI6QOBna 9I5UMzTA906Mh6GaJypWtHhhSdla9vKc6/I3WYY2XQLyC7wgFLATodg64Nw1dNQiAgoj LvSovbXK6/VGwoSQ7h9vTvVWw+i3mhiRoL30hC5EtClXwH7Xv3WkIKJISwl8k7BdoxAc O5QuIkdn8rGo1beag5EVzsx5ePkZ7mTvXYO24Xzyub2KDWaLVOfSCQ5KUNObwGldpS8i EpqQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772189109; x=1772793909; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Pf62O3cz8hk+GWrh946XGA4lipXT9dErCKXSEqKgzQU=; b=JWlUEv68H7t7cyE2jX6o8kzrP/I+WF7P2X2TtGQEtlJWP9uGpMKj+4++62+z949nfF 9ep33frur1/488n66IYohDy9BJxftVM15SlWPoRmWBnj6QHA+Em312GEj8EKcJLlEiEX lM5mu+6A1zrb/8NG8V2kUKorV1VOls2MZ6EdEtYXrFFm+Db6trOVFz1JqVb7R0or55V9 q2gBuuxcurfVr32LmZYvqWXtEvEmjQSlV/V94efKHJvY2ZLmm30gaz35oq0RJVKlnHwQ H2OV9YyxcEX8WTZ/tvgb9DcrcM6X26nwB0hqUqUQgUjXlRJbWYrPXZ90AVKUGzFwdOHP z6xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772189109; x=1772793909; h=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=Pf62O3cz8hk+GWrh946XGA4lipXT9dErCKXSEqKgzQU=; b=neNJJ33yR5dfJTm+SNNMJnRDSGqDHZ3JAdq+JLOzrtFQp8i0RctpXB6zULEyI3CFdW aZTdie80ge2pt8JdOEObkTm94I7OzP+MpMu4iW4dQ2GscmbnnPTAuv4xqs8Wg2UARFUK PrPVUc16Ezq+Xrk7NpfzMgVnNU0SaFc5vv3Ms/4iMZ+wq8E40JG0CQFBwChiQEBZsfQk qK2PD0PkgCtDpeZ770FB3LoWXn+BY8XCIMYrcXin4pCwfU04N2bzDNjGW523qsu/0Z6A A3be9Hh3n+uV48EsPYLSAdAirqbjd91H4xo5A2kBW0es2JYX4ENnj2w+Q6OJNChLg403 AcaQ== X-Forwarded-Encrypted: i=1; AJvYcCWu8l468HB/hmlDz5KHYQYATC6dGH2fFGCDn0WfHilOw54nRg58wHul4VcmpHX7S+XrZi8yBSIHD/qb+iBD@lists.postgresql.org X-Gm-Message-State: AOJu0YwTE1WlvUXv2x5HRfAC88RdebBR6J+Jm4+ZApFhWc97MD2MkUCs lPyoZ4wji23YT7kRg+/j4Cqo7bAda1ceEzlAPtgkuV7xjG5ZqPZEiH+74Mkk6/5bWk6+/zAzTKq QYjWOROU2EASNyGli1lrF6DjiJzuwpVs= X-Gm-Gg: ATEYQzzgga6dqb/Y1AtzjTRra6JYwcGZvQGJUngCg8mnEnS6YcyW+zi5Qgmcjw8AgFi DTKWPG8Gk/s4qt/bBAOmC79fnTtssQ20J6VBFBaN95wWBdXdtR99+PnXHUYiuTcWA9gc2lSQdBB LGfO3lcqPX7spgP//1cXR+ZJdHV2aLzlDeQPbcvr7fa0MruI5Js8F2QM+FkvYW5DYhV63mOh7JI HVoXTuAYgaIR7SQgX1kbJpfhnm14EYjMAMLa0hwdUqwqRwZNUVI+Hge2JOTnGxEEH6qR1P7+7CY a22N5es= X-Received: by 2002:a05:7022:61a:b0:127:3480:7ca1 with SMTP id a92af1059eb24-1278fc98f99mr821060c88.1.1772189108551; Fri, 27 Feb 2026 02:45:08 -0800 (PST) MIME-Version: 1.0 References: <1178617.1753217685@sss.pgh.pa.us> In-Reply-To: From: Soumya S Murali Date: Fri, 27 Feb 2026 16:15:33 +0530 X-Gm-Features: AaiRm53rdp58_5Bbssd3iTOfq9w2jAd4o4csVBBw-_O5Cp3BxS3CtWIfkJ20LA8 Message-ID: Subject: Re: support create index on virtual generated column. To: jian he Cc: Corey Huinker , Tom Lane , PostgreSQL Hackers Content-Type: multipart/mixed; boundary="0000000000004af7ec064bcbeedf" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004af7ec064bcbeedf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all, On Thu, Feb 19, 2026 at 5:18=E2=80=AFPM jian he wrote: > > On Thu, Jul 31, 2025 at 2:24=E2=80=AFAM Corey Huinker wrote: > > > >> > >> Besides, this does nothing you haven't been able to do for > >> decades with expression indexes. > > > > > > What I'm hoping for with this feature is a smoother transition when peo= ple start introducing virtual columns. If there was already an index on tha= t expression, and some queries start using the new virtual column (with the= same expression), will that cause those queries to miss the index we alrea= dy have? If it doesn't, then a customer can roll out the query changes at w= ill and not need to do some cut-over from using the expression to using the= virtual column. > > > > hi. > I am not sure whether this concern has been addressed, as I am still some= what > confused by the above paragraph. > > As noted earlier, creating an index on a virtual generated column results= in a > new index, and that index behaves the same as a regular expression index. > > An updated and polished patch is attached. The regress tests are quite ve= rbose > at the moment, since I make it covered all index types (btree, gist, spgi= st, > hash, gin, and brin). > I went through the discussions and have reviewed the patch. During testing, I encountered a segmentation fault during initdb which occurred due to a crash in bootstrap mode when ComputeIndexAttrs() was invoked with pstate =3D=3D NULL while system catalog indexes were being created. The virtual generated column handling logic was executing unconditionally, which is unsafe during bootstrap because catalog and syscache state are not fully initialized. I fixed this by guarding the virtual generated column logic to skip the logic when IsBootstrapProcessingMode() is true so that it can prevent the generated-column rewrite from executing during bootstrap. After the fix, initdb no longer crashes in bootstrap mode, the full regression test suite passes cleanly, the server starts normally and key behaviors like index creation on virtual generated columns, planner rewrite, dependency tracking, partitioned table support, and dump/restore roundtrips are all correct. Also I performed some additional validations to ensure consistent behaviours. With the bootstrap guard in place, the patch seems functionally correct, catalog-safe, and dump/restore safe. Kindly review the patch. Looking forward to more feedback. Regards, Soumya --0000000000004af7ec064bcbeedf Content-Type: text/x-patch; charset="US-ASCII"; name="0001-skip-virtual-generated-column-handling-during-bootst.patch" Content-Disposition: attachment; filename="0001-skip-virtual-generated-column-handling-during-bootst.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_mm4r4ufl0 RnJvbSAxZDgzNzhlZDA1ZTM1YzMwM2ExYWQ4MTIwYTU5YmNhOGExMTU3NTU0IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBTb3VteWEgPHNvdW15YW11cmFsaS53b3JrQGdtYWlsLmNvbT4K RGF0ZTogRnJpLCAyNyBGZWIgMjAyNiAxNjowMDowNSArMDUzMApTdWJqZWN0OiBbUEFUQ0hdIHNr aXAgdmlydHVhbCBnZW5lcmF0ZWQgY29sdW1uIGhhbmRsaW5nIGR1cmluZyBib290c3RyYXAKClNp Z25lZC1vZmYtYnk6IFNvdW15YSA8c291bXlhbXVyYWxpLndvcmtAZ21haWwuY29tPgotLS0KIHNy Yy9iYWNrZW5kL2NvbW1hbmRzL2luZGV4Y21kcy5jIHwgNCArKystCiAxIGZpbGUgY2hhbmdlZCwg MyBpbnNlcnRpb25zKCspLCAxIGRlbGV0a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