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 1snv0m-006wOQ-Ml for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Sep 2024 07:10:06 +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 1snv0m-008BoX-AS for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Sep 2024 07:10:04 +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.94.2) (envelope-from ) id 1snv0m-008BoP-0J for pgsql-bugs@lists.postgresql.org; Tue, 10 Sep 2024 07:10:04 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1snv0i-000QtR-JE for pgsql-bugs@lists.postgresql.org; Tue, 10 Sep 2024 07:10:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:To:Sender:From:Date:Cc:Content-Transfer-Encoding: Content-ID:Content-Description; bh=1GuqYru0DIPHVMMTSbRMRGiAAIchCAbVUPPlQDrpWls=; b=RMsR7Bbt4DAVWypISFk9kR4++X ArylTy3ofx1/UtLI9yhbb2mZ1CrEgw+sJO15GW/n+45C83U85DuIz8oITAAhALr1t5BofkYi7DZ1a 5U/d/3tMfwkIHFfvUtSSkufY5xf5L/CWoyo3u2l14dvFaVJ6+vJU9uhet6sV7FDbbuU0=; Received: from depesz by depesz.com with local (Exim 4.96) (envelope-from ) id 1snv0i-008BI9-2T; Tue, 10 Sep 2024 09:10:00 +0200 Date: Tue, 10 Sep 2024 09:10:00 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: sanskar@flintk12.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18607: UNION ALL discards all foreign key relations + indexes Message-ID: Reply-To: depesz@depesz.com References: <18607-651aa996c1e71d48@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <18607-651aa996c1e71d48@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Sep 09, 2024 at 03:16:33PM +0000, PG Bug reporting form wrote: > Consider the query below -> > > " > CREATE OR REPLACE VIEW v3.temp_view AS > SELECT * FROM users WHERE id = 'e-1' > UNION ALL > SELECT * FROM users WHERE id = 'e-2'; > " > > groups.id is a primary key and has a unique index defined on the same. What is groups? Your view is named "temp_view", and it's using "users", not "groups". > Either way when the view is created, the indexes and the related relations > of the foreign key references are being dropped. > (Same with "UNION"). What do you mean dropped? You had index on column id in table users, and after view creation you don't have anymore? Can you please show full example, that I can run on empty database, that exhibits the problem? Best regards, depesz