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 1tXdRb-00BMr8-Lc for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jan 2025 09:42:44 +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 1tXdRa-00GkXU-7r for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jan 2025 09:42:42 +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 1tXdRZ-00GkXJ-UV for pgsql-hackers@lists.postgresql.org; Tue, 14 Jan 2025 09:42:42 +0000 Received: from fhigh-b7-smtp.messagingengine.com ([202.12.124.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tXdRZ-000Kj3-0Y for pgsql-hackers@postgresql.org; Tue, 14 Jan 2025 09:42:41 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id D36852540146; Tue, 14 Jan 2025 04:42:39 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 14 Jan 2025 04:42:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1736847759; x=1736934159; bh=WY+RO5xB+9+rW1OiVtmWT19vGfaSC3NS 6Cq3m2oJgz4=; b=kSlDx8EstIa5Nq+zDwZVWtzMsbjYLtv081V8mgeq8g6ZH9a3 iSBNQbJKqGnsl07qwYhqMnAcqa32Uib6Y+B0r+uXl9H0x6J0RZDrbMraBreku+qT 8miPyWFp22ZTfhL0v4L9wG12ZjtnShHJ1hcCkmstQKJ0vJhI8IzHfhpNWigzKgtm gpW48KRustVvQxNK4RiWmkYGnd3MR2LOnyEJM4KXnW66RpHLU9tDZ11N8ESu/nF5 30eKp5jIApUJWQzDwOmK2NR7ZYlvo4Zdz8sjW8AOA5HMwYCaWCNyRxIFSTCo6BIp THFMee6/c4gKe1i8fUobTCysHJes1xw65xCW7Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736847759; x= 1736934159; bh=WY+RO5xB+9+rW1OiVtmWT19vGfaSC3NS6Cq3m2oJgz4=; b=K YZQJQEg7HsdYard/m6WofSEO9KwEwAnxBa0laRECw8LPz2p1mtSgBW+zImVZ3knl 87YzEzGTCweKwsZCysSoKC0SSDEa7aggnaGAt6s+G2ydAa8DCB6zq1lQmgZf4MZa sfK5bwIVp2r1oOF70E2CUP5FqtOI9dQMb+w6hEuu4YKl8kWFBX5SLoGcFzPqK8Ma i2hg1F1mFcJyVsSgsCAEkQZZQcmGDnQER+P9BIjzL/8qADBsluu8Q+A/n0OuJ8Ta zfxCa2OxnduPFX+jA1Dd5nvzejjCgu5b5N2A/AZMlo2R8qsc7beExW+BzHQ+a8PE WytJY/CIomLcc00Osl8ng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudehiedgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdej necuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvg hnthhrrghuthdrohhrgheqnecuggftrfgrthhtvghrnhepgfejtdfhkeeftdeugfeileeh teeljeeghfeuledthfeutedvffdukeefjefhgeehnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhesvghishgvnhhtrhgruhhtrdho rhhgpdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhope hjihgrnhdruhhnihhvvghrshgrlhhithihsehgmhgrihhlrdgtohhmpdhrtghpthhtohep phhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtoh epuggvrghnrdgrrdhrrghshhgvvggusehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Jan 2025 04:42:38 -0500 (EST) Message-ID: Date: Tue, 14 Jan 2025 10:42:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Virtual generated columns To: jian he Cc: pgsql-hackers , Dean Rasheed References: <732a9543-0312-4f0c-a471-857b507a3546@eisentraut.org> <0f811f71-8c86-4e1b-b3bb-6a535674a440@eisentraut.org> <09800cb1-43aa-4239-8918-46b71ede4900@eisentraut.org> <536b281b-2cb3-4477-971f-c64838bc6263@eisentraut.org> <51875199-d5f5-41ed-92dc-3e7b1b996991@eisentraut.org> <84adfb1b-826c-42b2-a907-b327d3760c7e@eisentraut.org> Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 09.01.25 09:38, jian he wrote: >> create user foo; >> create user bar; >> grant create on schema public to foo; >> \c - foo >> create table t1 (id int, ccnum text, ccredacted text generated always as >> (repeat('*', 12) || substr(ccnum, 13, 4)) virtual); >> grant select (id, ccredacted) on table t1 to bar; >> insert into t1 values (1, '1234567890123456'); >> \c - bar >> select * from t1; -- permission denied >> select id, ccredacted from t1; -- ok > > I think this is expected. > however once the user can access the pg_catalog, > then he can use pg_get_expr > figure out the generation expression. > > so here "bar" can figure out the column value of ccnum, i think. Having access to the expression definition doesn't help you reverse the computation, if the computation itself is not reversible.