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 1sjzjJ-006UCL-Qm for pgsql-general@arkaria.postgresql.org; Fri, 30 Aug 2024 11:23:50 +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 1sjzjH-002B8D-Re for pgsql-general@arkaria.postgresql.org; Fri, 30 Aug 2024 11:23:48 +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 1sjzjH-002B7u-8z for pgsql-general@lists.postgresql.org; Fri, 30 Aug 2024 11:23:48 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sjzjE-002AJL-8X for pgsql-general@lists.postgresql.org; Fri, 30 Aug 2024 11:23:46 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2d3e46ba5bcso1254577a91.0 for ; Fri, 30 Aug 2024 04:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitnine-net.20230601.gappssmtp.com; s=20230601; t=1725017022; x=1725621822; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2nu6WIrKsdwGAop9eFvFYfyVKb+WEa0fa4o6yE0DWh8=; b=p5LdF2R5cwr/hRBr8YC3BGGvK6IPcZVKs6lJchPbybDu48/wiPopv4OD/cUkq6Hl8d Dp2C9Fr8UYlWOZbcA2mvEeYjWGZYkEzw0bsFnJAmBsHzB+BkN7IQ1XJUpz7h9yva+Fvz tQdsJwI9qQdLfbBpe/L0WolkS1C8Xw5KNgnn31CVojyCvtgu7IdcvDVmW17KRDJ22nby TkDbH0mTsEETsDgTzzZ6OUmgctA4W2XqMv2tkNdTpf+VOGT8k1q6okuTARpEbkUR6f5V W6KW4OU8KiWKk1he2FUwqre0YoBL+IqwRRBKRw73796zNBBQ2JpgR/hifyyerUyuO1Wc B9fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725017022; x=1725621822; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2nu6WIrKsdwGAop9eFvFYfyVKb+WEa0fa4o6yE0DWh8=; b=G3HNdSi9o6SAOf30zIJfK78mNE1zbq5WS6o8BiRDqZN0SBlasC7d2+ziLTW2Uiu//3 T23ezRC12sYSIXKpfiXV+jcrWvikNIXKyPwvrWlk7mz1YoXkJ1hy2meo2Ixa5LjlzAuz EIK+H2coEEPylsj4lUunfW/8LGUlxDcUiJgmSbzqhLN+gV01l4O+Jyu9Jc6uq9K8zxKv 8jjIgCdLSS5exJ8fl5fgCXjss0Usu7KdeXPDKtwIJx3R1IAzgGaBc0lITiGb2XVTBqbX +VJPAaTEpIGaRQlZJythcI1rMlfz9HAkUqpgJzDlvjGm3g1ttnUxI73YDi09QHACQWEZ Sm2w== X-Gm-Message-State: AOJu0Yw78GEvwo7hZkLQs0O3h1cfESyitM3vtMO9D+Iq9dHze69rrHio ESanSJ7COhikzZss3prsC3BExyWbBizz2yTCXBTjqSEBVXBpeSlOK/2ggpXeMQwB92ziNUXir1N cyGaxWYv/FMpePr9H7fqZeISoCysZAhFSeu49ZfMmw5Sh0ABLSzE4Bg== X-Google-Smtp-Source: AGHT+IHU24rDh01AMS6T2HEnYN7H70/R+bfTMnN7dAzKXrHR1rAo5YAtjTGurU14FiI9lzLaT1EQs4yJ9Jxv+pBsXf8= X-Received: by 2002:a17:90b:3e8a:b0:2c9:7616:dec7 with SMTP id 98e67ed59e1d1-2d85617be6amr6026766a91.6.1725017022088; Fri, 30 Aug 2024 04:23:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Muhammad Usman Khan Date: Fri, 30 Aug 2024 16:23:30 +0500 Message-ID: Subject: Re: default privileges are npt working To: Atul Kumar Cc: pgsql-general Content-Type: multipart/alternative; boundary="000000000000d55e180620e4d23c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000d55e180620e4d23c Content-Type: text/plain; charset="UTF-8" Hi. I think the ALTER DEFAULT PRIVILEGES command affects only tables that are created after the command is executed. Tables created by the writer user before you executed the ALTER DEFAULT PRIVILEGES command would not automatically have select privileges granted to the reader user. You can try by explicitly granting select privileges on the existing tables to the reader user. On Fri, 30 Aug 2024 at 16:14, Atul Kumar wrote: > Hi, > > I have a postgres instance running on version 15 in centos7. > > I have created a custom database and revoked all public privileges from > that database. > > Then I have created a custom schema in that custom database. > > Now I have created one writer *user* and one reader *user *by postgres > superuser and then granted connect privileges on the database. > > Then I have given all privileges of schema level and table level to the > writer *user *so that it can create tables and insert data in the tables > in that schema. > > And for reader *user * I have granted usage only privileges on schema > level and select privileges on table level so that it can only read the > data of tables. > > Then I granted default "select" privileges to reader *user *to read data > of all tables created by writer *user* using below command: > > alter default privileges in schema grant select on tables > to . > > but when I am connected to the reader user I am not able to read the data > inserted by the writer *user* and getting permission denied error. > > I can only see the list of tables created by the writer user, not the data. > > Am I missing something here? Please let me know. > > *My Goal: To read the data by reader user inserted by writer user.* > > > Regards. > --000000000000d55e180620e4d23c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi.
I think the = ALTER DEFAULT PRIVILEGES command affects only tables that are create= d after=C2=A0the command is executed. Tables created by the writer user bef= ore you executed the ALTER DEFAULT PRIVILEGES command would no= t automatically have select=C2=A0pr= ivileges granted to the reader user.=C2=A0 You can try by explicitly granting select=C2=A0privileges on the ex= isting tables to the reader user.


<= /div>

--000000000000d55e180620e4d23c--