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 1uFmEz-008UUF-KC for pgsql-hackers@arkaria.postgresql.org; Fri, 16 May 2025 04:00:10 +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 1uFmEx-0006lB-T0 for pgsql-hackers@arkaria.postgresql.org; Fri, 16 May 2025 04:00:07 +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.94.2) (envelope-from ) id 1uFmEx-0006l2-HV for pgsql-hackers@lists.postgresql.org; Fri, 16 May 2025 04:00:07 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uFmEu-0021Gy-34 for pgsql-hackers@postgresql.org; Fri, 16 May 2025 04:00:06 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-54b10594812so1850143e87.1 for ; Thu, 15 May 2025 21:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747368003; x=1747972803; darn=postgresql.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=imFysddXMrMWf0DOap1A65ZgpZi2E/zgTSQ7g0/kIT8=; b=UwF9EU5rYnyE84IqfIFVgPKphkDNLM8pTPE/p9nLvUVDOnvNdwBYEcI2Tq6jqhNJTi zPacX2hntA0bBDJgQzlgGZrfP7/Rktc33O62leKDwE2bq0TWcjoHUIEzMCnltSYy0VRe SKc4HyS5el6CAYNfWhfdRMpTIo96+2C4b0rOEjnFDMLgkDQKaZAFsak4XVg2Yhi9z3Tu X1QX+xulIaoelzUxDWxTi2DX9vYyL3qEkr4dqgX2fc102S73GaYtGGUnoPy5U0WF3JYF b56AShPu7igZgBDERV8HJLKv/xAyLU07IJoSE0Um9jxa49JPIPA3QbfU4cNSsrk58N9o 6TEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747368003; x=1747972803; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=imFysddXMrMWf0DOap1A65ZgpZi2E/zgTSQ7g0/kIT8=; b=eYp3rREWwGa/7MxP8/FBy3oSvpSWrzvcItYwOS3u2/vZt7dIoviFoxeElk7F+IKCwK gGZiM6RaKfwpfnxkegiiD4imC4/UbOxySxdahettAc12gJkqRp9d9bjSuTSTyIk8aBqp Ec4cqh9HFKepZHz5esu908NcneniBPVwttbFDhVJcVXt2OhCBHXxlxASPWpbXJ6CLkm9 mY1qgwpi1sHG8xJSCzc6XwUnw+Mvj/Vy2CzFtd+FKLuVFYvomRC7et4JxxF/JwNl+gj3 neSJ1Xkig4kBHkqhX7gKACV4SbsNWFRKYi98pTTSe4nx4r4q7E1YGSJpTyGc793l31VJ CQiQ== X-Forwarded-Encrypted: i=1; AJvYcCVvUJsftznLIk8uWMR25Gh1cHQZ2MM7WYY3K/Jeo3/jDo3fL8tgyZNsvlNB2nO8Kih8oIyZOn/A0Xl4NS+S@postgresql.org X-Gm-Message-State: AOJu0Yw+4wMd9ZaW8cTxpTJRC96V/ovpOdwdrOCVGjKD6sB9doVnC75Q SYrpU47aGtwWTpi3Wj0seXzSiD2eVsBKmXMLYcvP/V+H8dSVMalwXfCH X-Gm-Gg: ASbGncvoOGMg7Hgqbws907m6UpgytONs0mWxkUubKC8o/dtAGLB4yOYkWXEY6FRXqkR ZdzBzyEhQIf8Lnf/R6SR5DaKT0W7pPWlxFc/lIAhhyZGTRIX8H1mGiekk436u0nHfqOG7s6PaFh 58sp40XEqQCVHZa5K11nm/QC/7SJVLw0jE7eu4jcvDwTzkCYhHjz+VpLZY/QESlsUxf3eqe6dOF zFun0/O86AzGaXgzX7MvjeoNNTNFx8pvbOdmztm7Ie+ceCk46iFeN/6QaQd59ePu4lHE6m6HPmS Z4nxLx+dxJC6Qr3+2l/VJQn5neIz30Z5jul25NLaotzlIDPTvyTtzg== X-Google-Smtp-Source: AGHT+IEvRVhyPpRcrA2Wf4bkV6RK6rKomBk0HadU8xPw1YlAXSWLEHo106VxxJ+rS5OZSJ42WxHa/A== X-Received: by 2002:a05:6512:6805:b0:545:381:70a with SMTP id 2adb3069b0e04-550e71a892dmr431166e87.15.1747368002893; Thu, 15 May 2025 21:00:02 -0700 (PDT) Received: from [192.168.0.50] ([89.149.93.214]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-550e7018073sm228322e87.129.2025.05.15.21.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 May 2025 21:00:02 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------MG5vWnU07v1y1ru5g8WKHsNy" Message-ID: Date: Fri, 16 May 2025 07:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Virtual generated columns To: Richard Guo Cc: Peter Eisentraut , Dean Rasheed , jian he , Zhang Mingli , pgsql-hackers References: <12d5cce9-917f-4a99-86d3-715bb3b363bb@Spark> Content-Language: en-US From: Alexander Lakhin In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------MG5vWnU07v1y1ru5g8WKHsNy Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Richard, 22.02.2025 16:55, Richard Guo wrote: > create table t (a int, b int); > create table vt (a int, b int generated always as (a * 2)); > > insert into t values (1, 1); > insert into vt values (1); > > # select 1 from t t1 where exists > (select 1 from vt where exists > (select t1.a from t t2 where vt.b = 2)); > ERROR: unexpected virtual generated column reference I've discovered yet another way to trigger that error: create table vt (a int, b int generated always as (a * 2), c int); insert into vt values(1); alter table vt alter column c type bigint using b + c; ERROR:  XX000: unexpected virtual generated column reference LOCATION:  CheckVarSlotCompatibility, execExprInterp.c:2410 Shouldn't this be expected/supported? Best regards, Alexander Lakhin Neon (https://neon.tech) --------------MG5vWnU07v1y1ru5g8WKHsNy Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello Richard,

22.02.2025 16:55, Richard Guo wrote:
create table t (a int, b int);
create table vt (a int, b int generated always as (a * 2));

insert into t values (1, 1);
insert into vt values (1);

# select 1 from t t1 where exists
   (select 1 from vt where exists
    (select t1.a from t t2 where vt.b = 2));
ERROR:  unexpected virtual generated column reference

I've discovered yet another way to trigger that error:
create table vt (a int, b int generated always as (a * 2), c int);
insert into vt values(1);
alter table vt alter column c type bigint using b + c;

ERROR:  XX000: unexpected virtual generated column reference
LOCATION:  CheckVarSlotCompatibility, execExprInterp.c:2410

Shouldn't this be expected/supported?

Best regards,
Alexander Lakhin
Neon (https://neon.tech) --------------MG5vWnU07v1y1ru5g8WKHsNy--