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 1qyV8I-008pcB-6Z for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Nov 2023 10:41:02 +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 1qyV8F-00Cotp-R5 for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Nov 2023 10:40:59 +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 1qyV8F-00Coth-IS for pgsql-bugs@lists.postgresql.org; Thu, 02 Nov 2023 10:40:59 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qyV8A-003ai4-6u for pgsql-bugs@lists.postgresql.org; Thu, 02 Nov 2023 10:40:58 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-9a6190af24aso118142566b.0 for ; Thu, 02 Nov 2023 03:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1698921653; x=1699526453; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=PO/EXvb5W93AnWHoICXFnU0uu1aOf5mOtgT+9zFiU2I=; b=BDDQ0gXJw+rOmKKeuhfuvQNc/1gpsZfBU1yLuC22M3IzqXvyQzRFtTHzOKs1h80jAt eZPnbBldLiy59ac+V/Cj2JjZYZvacatgqWVHxlqT5CFI/Tg/KcKr/sz/8oteF1+ylkmL PCbgFnt9MaicrLmhqZePU4o9VT3cIsQ0pWrjAAjFDwGgNmP4O6JmfOIorU4bXRaZULQ7 9s5GpYkqdCnPZ1EjEApUljPxTeffqRyGwX5wScBYCysaUuJC32PTwegCkdqJiZEjoGmi GeZ/9sYmyzq9M6lxthHinoTWzJFl+K7xSXResIhZFilRrHDJ8paulXsBTXrxGZFZ7lXd AIiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698921653; x=1699526453; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PO/EXvb5W93AnWHoICXFnU0uu1aOf5mOtgT+9zFiU2I=; b=Kx3XZNckGMAWZ0DJVpYuTAGoqwyRHp5fFyQZWXihAeipWKFP1VtSgXwmOGTTI0fgQq zNNp7qEO7ohGyvDNBPIfuVnhkjJ/AWOZSqKIFWGxS1YbuSywBmhhgnBDasSqFyS10lIO +ekbgCjXloLkX3LCWlM097z9OdyuJ/fevLpSqSWLnd4RrSjHtPjUfuWUbLtfG2aiQTQD Wdm+8cG5mzDHSk4x+h3ud9rIiQurl9KQXdYEGJYiBB0L7BaAqMEuDS3VKFzbSAh2IwGQ uFXS2QKGPux4yGcHT21mSv5mqKFg2hOgvKsvgC8Kw1eK1jdvtR8q4sNDgx+DY311H1xz W18Q== X-Gm-Message-State: AOJu0YyD/5PcUhho4KmxHhvelXkxJ7fWwgllbmyCHSIQ0TXtWS/wpvGu 8wmRI/HWyd6kFZ5yCW+X3AlDc/oFEycYp1KbORc= X-Google-Smtp-Source: AGHT+IFrZeujAaRGKv8d5jXvJ1bIuLGNJkoWSpi9poo07qaF+wQSaGbSkqdZDkhUImCPRk8a2ODtMA== X-Received: by 2002:a17:906:db0d:b0:9d3:ccd1:a922 with SMTP id xj13-20020a170906db0d00b009d3ccd1a922mr4095874ejb.58.1698921652526; Thu, 02 Nov 2023 03:40:52 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:671d:efcb:786d:3c60:89d1]) by smtp.gmail.com with ESMTPSA id lu13-20020a170906facd00b009ad8796a6aesm967525ejb.56.2023.11.02.03.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 03:40:52 -0700 (PDT) Message-ID: <61d0757cd0a4414e9f733071dbf07a314fc0d5d6.camel@cybertec.at> Subject: Re: BUG #18178: New Restriction on "ON SELECT" rules on tables From: Laurenz Albe To: joshua.uyehara@gmail.com, pgsql-bugs@lists.postgresql.org Date: Thu, 02 Nov 2023 11:40:51 +0100 In-Reply-To: <18178-05534d7064044d2d@postgresql.org> References: <18178-05534d7064044d2d@postgresql.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2023-11-01 at 23:25 +0000, PG Bug reporting form wrote: > PostgreSQL version: 16.0 > Operating system: Windows Server 2022 >=20 > Apologies if this is not the right place to report this, but it is either= a=20 > 'bug' in the documentation, or (I'm hoping) a breaking change that could = be > reverted. >=20 > The documentation for rules specifically states that "ON SELECT" rules ca= n > be created on tables (and I have functionality/use cases that rely on tha= t) > behavior, but pg16 breaks that. Where does it say that? That would be a documentation bug. > In investigating the issue I did find what is likely the related release > note for 16 "Remove the ability to create views manually with ON SELECT > rules (Tom Lane)", but couldn't find any related discussion of the > rationale, suggested workarounds, or whether anyone else has yet run into > the same class of issues (possible given the recency of the release). The relevant commit is here: https://git.postgresql.org/gitweb/?p=3Dpostgresql.git;a=3Dcommit;h=3Db23cd1= 85fd5410e5204683933f848d4583e34b35 and it links to this discussion thread: https://www.postgresql.org/message-id/flat/CALDaNm2yXz%2BzOtv7y5zBd5WKT8O0L= d3YxikuU3dcyCvxF7gypA%40mail.gmail.com Basically, the behavior was considered a wart, and it caused problems, so it was decided to get rid of it. > The issue is, basically, that there are broad classes of database > abstraction middleware that are configured via database introspection at > runtime and do not understand or implement the concept of updateable view= s > and foreign tables. The easiest workaround for that limitation in postgr= es > has always been to create a local table stand-in with all operations > rerouted to the foreign table via rules. So these "broad classes of database abstraction middleware" are smart enough to tell that a foreign table is not a table, but too dumb to recognize a table that has been converted to a view. What keeps you from creating a view instead of creating a table and then turning it into a view? Can the "broad classes" distinguish between these two things? How? It cannot be pg_class.relkind, because that is changed when you create an ON SELECT rule called _RETURN. Perhaps pg_class.relfilenode? > If I need to report this somewhere else, or send to one of the mailing > lists, please let me know. You have been relying on a hack to work around a deficiency in the "broad classes". I can't speak for PostgreSQL, but I see little chance for this change to be reverted. I'd say that the correct thing to do would be to ask the "broad classes" to enhance their code so that they work properly with foreign tables. Yours, Laurenz Albe