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.96) (envelope-from ) id 1vvY3D-007LSe-0q for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Feb 2026 09:52:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvY3B-00Bc8s-00 for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Feb 2026 09:52:53 +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.96) (envelope-from ) id 1vvY3A-00Bc8h-1j for pgsql-hackers@lists.postgresql.org; Thu, 26 Feb 2026 09:52:52 +0000 Received: from mail-yx1-xb135.google.com ([2607:f8b0:4864:20::b135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vvY37-00000001H1S-1Zv2 for pgsql-hackers@lists.postgresql.org; Thu, 26 Feb 2026 09:52:51 +0000 Received: by mail-yx1-xb135.google.com with SMTP id 956f58d0204a3-64ae222d87dso482149d50.2 for ; Thu, 26 Feb 2026 01:52:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772099570; cv=none; d=google.com; s=arc-20240605; b=QKGeo3pPz3xpZ4kvKASOeZkGInjLoNCITN09lWbNYTHa45Y1pa8poeQ51kBcySLYYP B7CVWdHsHNwESIDHe7BV8HByob1+a+/VMMxl94Y1QSxcBGywFmAZax9LNP8R9Eymr0rr uQjkqG4Hb/vlqAstBfgPKw5t+TVU+nIFYHbUnOmoyzjBgJ539a1orDoRp84Rf/JWxX9V HRPjNrbyACRK1mlFPRQx64oMToI2myZ7qLFfLlK3g8HMnFXGh+t1Iy98JcR9FtVwjAD6 QABLV18YEIsAnZq3TnYsSLTu5WzoFWLPEbB557Dx9v1XHaaFWgwX8miSl1Z3Z6mPDl9R 6qGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Ki/rQbkMlEcSgqEfv6LfJBnumIiO3cK7+W0kASR8SY4=; fh=nwNxTtLLPTU0ewfLM7SSbrjMajMl+wwnFkCY/fi90vE=; b=N7rEvk1M6pNk4A+rrcUqpMxwWafSmSioLFVAt8HtrCQtX+dn3dYrj2rYPLV/ak3xt4 tQsgc/++3khXiKxbhk/KbNHwNkFR5hIMYfVxMb5cNRuXF8hkXFqAUKHorV8nVH87Qx3o j2QXiRt6yx6a+Q+vK0LzHoi7J4CD5MeXcFwHpVUl7SzYkN9/CDk995Lv14heN+NatFG/ Qx+HgDEwPMUuE9HtwMmiosz58cerysl81/gXdY5hA7DTJ4Jedqp3SJeI4tUqL0gsGNW3 T61e1ddQgZ7XfeHPHWqEUvA9lWRYwARRGXGWdkgcorDlS8UyXfApmsBZ7CKymA4yrWRN 6ZFw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772099570; x=1772704370; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=Ki/rQbkMlEcSgqEfv6LfJBnumIiO3cK7+W0kASR8SY4=; b=L/Te/lcezTlP2QTiC82+27ADUQd6lIfNchR3bKsLLz+ptOFuJprnklNTobNv6mHd8B le8MmObQa0CtXpp3b353SWohT4Xk/EF24Qg4zcLiuxMgs7gMMn2gUhb6ENhqwgpUXGto zIxRQiW77h3OPg2rZwJLqt/7BTBXS1/E1d7AZ6uRgMgmyga569SMfzKYmzZ/l1NfRdaF IxiLo49GVcZGWZRmiwJF9K4Kplh4tbRCaKn+kuznBfgR5ZcTIVmlsehNJPV3pWn5QrH5 dT3kUkp3Fgj5Qy4MKFjNe/g0x0madnlYJtUk0vZ8EyPy+r00ZJB7WhNkdaWJrRsXncpT aHMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772099570; x=1772704370; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ki/rQbkMlEcSgqEfv6LfJBnumIiO3cK7+W0kASR8SY4=; b=Oz20lfkT2YEzQ9Ebzfr9IW07oWJ1crOL+dbZSy2h9hLt9x2cs9nmBm6oNMUqdGAhlG b+gjyJ026izGp2EKXEtkf939NRsI8ta3tjjwRqAPtg9F49/Y7IqAdX+SMX2AR9x53Ufp nCuuWu4qrH3LGfNk8Eq6MzEAImqJvjieLEUr/ld18QXu99Y2B11E5PotCMwSM1eW7Q9s WY+PzxmpEp7jWTO4LJjNfg8Kdx/NnLrRbq7f9kmfmR+BSti/BJ4/sEX/H/wkmjN+UD6x MVAHR4nlTLlIEbnYr2ygR2gfXMt/3NvmATPqjFq24p8winqhIJnD6Poo0t4zNopkBrv3 BdyA== X-Gm-Message-State: AOJu0YyOFOBHq5KrvBaN9lHUzzpkz8Mf6jM2dyQyAL+bFF9maJ9I4Gug z4uoOtI/xITAXsEKbKWz19n1lh2AlVUgABPKaNjPh1k/xn+Y4aoJbBEL/Yktuqn7PK49OdNkgNC uHPLfDmHvXnjE5xgyRjaLGAW7YaTXEZA7yRLF X-Gm-Gg: ATEYQzwpDMwChOrFA38xnZJNmU7YqyEAucLjVfvff0vkuWVGHcE/wRKLblHAVU3oW+a n77TCrm1h14V+OQhQ4RgGM5QR0vQFJGD5nykYPGe9++SSxZSMBTeo8L5To9xMHmJxupaVUjQxRt lljNy/P6AVwLQS1sBxvR/TiSzDBInww60Le5W7NSCOCiNaclyfN4DY+bnllz3oNJy8reG7fkqJz /XOl7/zPKwlvlfDExQ0D/H0Zg3USuEbUjE/W4PQpxj1LF6mowJmvNxzWwPJtw5aZVjiF0PVxkRT +sEsqN0eg8Km2K+Tgw== X-Received: by 2002:a05:690e:1444:b0:64a:cf34:d9ac with SMTP id 956f58d0204a3-64cb7c0cd7cmr1087296d50.29.1772099569583; Thu, 26 Feb 2026 01:52:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Shin Berg Date: Thu, 26 Feb 2026 18:52:38 +0900 X-Gm-Features: AaiRm51bGSteBPKwThlsHb1mMDKp25B4IUzkNZEFwAAef0BkiP8XyI6rcXYaXPc Message-ID: Subject: Re: Inconsistency in owner assignment between INDEX and STATISTICS To: pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000005a0aca064bb71580" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005a0aca064bb71580 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Gentle ping on this thread =E2=80=94 any thoughts or concerns about the proposed alignment? Thanks. On Sat, Feb 14, 2026 at 5:48=E2=80=AFPM Shin Berg wro= te: > Hi, > > I'd like to raise a small consistency issue between how INDEX and extende= d > STATISTICS handle object ownership, and ask whether aligning them would b= e > desirable. > > Current behavior (tested on REL_17_STABLE): > > - When a superuser creates an INDEX on another user's table, the index is > owned by the *table owner* (see catalog/index.c: index relation's relowne= r > is set from the heap relation's relowner). > - When a superuser creates STATISTICS on another user's table, the > statistics object is owned by the *current user* (statscmds.c: stxowner = =3D > GetUserId()). > > So in a scenario where a DBA creates both an index and extended statistic= s > on a user's table, the table owner can DROP the index (because they own i= t) > but cannot DROP the statistics object (they get "does not exist" when > lacking ownership, which hides the real permission issue). That can cause > operational friction in multi-tenant or shared-schema setups (e.g. the > table owner cannot drop the statistics to resolve dependency issues befor= e > altering the table). > > Reproduction (as superuser, then as table owner): > > CREATE SCHEMA shared_schema; > CREATE USER bob; > GRANT USAGE, CREATE ON SCHEMA shared_schema TO bob; > > SET ROLE bob; > CREATE TABLE shared_schema.bob_table (a int, b int); > RESET ROLE; > > CREATE INDEX idx_bob ON shared_schema.bob_table(a); > CREATE STATISTICS stat_bob ON a, b FROM shared_schema.bob_table; > > SELECT 'INDEX', c.relname, pg_get_userbyid(c.relowner) FROM pg_index i > JOIN pg_class c ON c.oid =3D i.indexrelid > WHERE indrelid =3D 'shared_schema.bob_table'::regclass > UNION ALL > SELECT 'STATISTICS', stxname, pg_get_userbyid(stxowner) FROM > pg_statistic_ext > WHERE stxrelid =3D 'shared_schema.bob_table'::regclass; > -- INDEX owner =3D bob, STATISTICS owner =3D superuser > > SET ROLE bob; > DROP INDEX shared_schema.idx_bob; -- succeeds > DROP STATISTICS shared_schema.stat_bob; -- ERROR: statistics object > "..." does not exist > > I'm not sure if the current STATISTICS ownership behavior was intentional= . > If it wasn't, would it make sense to assign the statistics object's owner > to the relation owner (same as INDEX) for consistency and to avoid the > above scenario? > > Thanks for your time. > --0000000000005a0aca064bb71580 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Gentle ping on this thread =E2=80=94 any thoughts or conce= rns about the
proposed alignment?

Thanks.

On= Sat, Feb 14, 2026 at 5:48=E2=80=AFPM Shin Berg <sjh910805@gmail.com> wrote:
Hi,

I'd like= to raise a small consistency issue between how INDEX and extended STATISTI= CS handle object ownership, and ask whether aligning them would be desirabl= e.

Current behavior (tested on REL_17_STABLE):

- When a super= user creates an INDEX on another user's table, the index is owned by th= e *table owner* (see catalog/index.c: index relation's relowner is set = from the heap relation's relowner).
- When a superuser creates STATI= STICS on another user's table, the statistics object is owned by the *c= urrent user* (statscmds.c: stxowner =3D GetUserId()).

So in a scenar= io where a DBA creates both an index and extended statistics on a user'= s table, the table owner can DROP the index (because they own it) but canno= t DROP the statistics object (they get "does not exist" when lack= ing ownership, which hides the real permission issue). That can cause opera= tional friction in multi-tenant or shared-schema setups (e.g. the table own= er cannot drop the statistics to resolve dependency issues before altering = the table).

Reproduction (as superuser, then as table owner):
=C2=A0 CREATE SCHEMA shared_schema;
=C2=A0 CREATE USER bob;
=C2=A0 G= RANT USAGE, CREATE ON SCHEMA shared_schema TO bob;

=C2=A0 SET ROLE b= ob;
=C2=A0 CREATE TABLE shared_schema.bob_table (a int, b int);
=C2= =A0 RESET ROLE;

=C2=A0 CREATE INDEX idx_bob ON shared_schema.bob_tab= le(a);
=C2=A0 CREATE STATISTICS stat_bob ON a, b FROM shared_schema.bob_= table;

=C2=A0 SELECT 'INDEX', c.relname, pg_get_userbyid(c.r= elowner) FROM pg_index i
=C2=A0 =C2=A0 JOIN pg_class c ON c.oid =3D i.in= dexrelid
=C2=A0 =C2=A0 WHERE indrelid =3D 'shared_schema.bob_table&#= 39;::regclass
=C2=A0 UNION ALL
=C2=A0 SELECT 'STATISTICS', st= xname, pg_get_userbyid(stxowner) FROM pg_statistic_ext
=C2=A0 =C2=A0 WHE= RE stxrelid =3D 'shared_schema.bob_table'::regclass;
=C2=A0 -- I= NDEX owner =3D bob, STATISTICS owner =3D superuser

=C2=A0 SET ROLE b= ob;
=C2=A0 DROP INDEX shared_schema.idx_bob; =C2=A0 =C2=A0 =C2=A0 =C2=A0= -- succeeds
=C2=A0 DROP STATISTICS shared_schema.stat_bob; =C2=A0-- ERRO= R: statistics object "..." does not exist

I'm not sure= if the current STATISTICS ownership behavior was intentional. If it wasn&#= 39;t, would it make sense to assign the statistics object's owner to th= e relation owner (same as INDEX) for consistency and to avoid the above sce= nario?

Thanks for your time.
--0000000000005a0aca064bb71580--