Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1og2AM-0004Vi-St for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Oct 2022 11:02:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1og2AL-00035x-O4 for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Oct 2022 11:02:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1og2AL-00035o-G7 for pgsql-bugs@lists.postgresql.org; Wed, 05 Oct 2022 11:02:17 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1og2AG-00075Q-Ao for pgsql-bugs@lists.postgresql.org; Wed, 05 Oct 2022 11:02:16 +0000 Received: by mail-oi1-x231.google.com with SMTP id t79so3759801oie.0 for ; Wed, 05 Oct 2022 04:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:to:from:date:from:to:cc:subject:date:message-id :reply-to; bh=I6F+qp+SlLTp2YPTj2+V/QyGwD/XzNa1dIuyBUee9WI=; b=DJT0lkH8yUd5aRDdx1LCe1WHAOe1t4m1DiGd/sya3D9ShTxze7d/c/+PNyZw+idV9w m7qRPVibHvSMh3gcsEsFUocdG6DLS4Xp1QHulVgEVV0E1DOVSO1wO/ypOpNT7O3QNvQU GJE67w9D/i9TzTL6G1VIwn+OtZdVReQgELJ7U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I6F+qp+SlLTp2YPTj2+V/QyGwD/XzNa1dIuyBUee9WI=; b=DNBZHjbsG86XFD8i54nbwtiZ0RfljfSYvXHaTYPN/gTs5ySDT2CAsRMSoXvUh1D1wo MGMEOnSXNPYq/xDkjW3dlGuniUnA2erd3rXAiqb5si/igneu5jXuDU060fXumNd0pX34 IS7/QWYznTeZFt2MTmRQ/y01tXD+zquUmsph3wrRcQwXNXacd2F62KhLDoF32bkgYUmg ycpRfjTQRf3shnpEVt/Akg/MHnJRTX9nZ7qN8ZuPaG/V28LAO7KrG5g/82SLtW283M3a 4msXHPTVaqmvpVf7aGWD3N44XLHMX+yHXqN8uCuMLBqVxj/D91Q24uiedS4FKC4h7mg0 jtgA== X-Gm-Message-State: ACrzQf3lwnJx/k+Np68O37oIaiGbFEme4nVSDBe+x9ugdjmCBxnqD2xM QHyws+CRSxQNv6XKNR/igFvTMKMVx6H8g6m+ X-Google-Smtp-Source: AMsMyM49xdg2aO+iWEKUeEz8liwNVS/c42/Hi6f7SFWIvWQ47D1RH+RNxO2pUqJbcKdEtpMXvqrjOw== X-Received: by 2002:a05:6808:188b:b0:350:b024:73c4 with SMTP id bi11-20020a056808188b00b00350b02473c4mr1859664oib.107.1664967731628; Wed, 05 Oct 2022 04:02:11 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::2e]) by smtp.gmail.com with ESMTPSA id e6-20020a4aa606000000b004762a830156sm3272175oom.32.2022.10.05.04.02.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Oct 2022 04:02:11 -0700 (PDT) Date: Wed, 5 Oct 2022 04:02:09 -0700 From: Noah Misch To: annika.ruohtula@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17616: Silently skipping to update data to the database with owner privileges using flyway scripts Message-ID: <20221005110209.GB2255375@rfd.leadboat.com> References: <17616-195bac997f5bac61@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17616-195bac997f5bac61@postgresql.org> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Sep 16, 2022 at 10:00:24AM +0000, PG Bug reporting form wrote: > About a week ago I found that one update script was silently ignoring > updating data to a table. > I found a workaround which seemed to fix the issue: I added grant-statement > "GRANT USAGE ON SCHEMA TO """ after adding the > column to the table and before the actually updating the data to the new > column. After that, the update-statement was working ok. Lacking USAGE on a schema does not cause "silently ignoring updating data to a table". If the same table name exists in multiple schemas, it can cause you to update a different schema's table. Example: === create user alice; create schema a; create schema b; grant usage on schema b to alice; create table a.x (c int); create table b.x (c int); grant insert on table b.x to alice; set session authorization alice; set search_path = a, b; insert into x values (1); -- updates b.x \dt x === It's also possible to write a trigger that silently stops the update due to the missing USAGE privilege. > Currently it has been working ok, but of course we are > a bit worried about the situation, because in theory this should not be > needed for the owner of the database. The database owner doesn't broadly bypass privilege checks. It's normal that "GRANT USAGE ON SCHEMA TO """ could increase the database owner's effective privileges. > Is it possible there is some bug here > related to some timing how the default privileges and the instantiated > privileges are generated? It's not impossible, but we'd need a self-contained test (https://www.postgresql.org/docs/current/bug-reporting.html).