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 1vrBKG-008AAv-1c for pgsql-hackers@arkaria.postgresql.org; Sat, 14 Feb 2026 08:48:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vrBKE-00HIJT-17 for pgsql-hackers@arkaria.postgresql.org; Sat, 14 Feb 2026 08:48:26 +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 1vrBKD-00HIJL-2t for pgsql-hackers@lists.postgresql.org; Sat, 14 Feb 2026 08:48:26 +0000 Received: from mail-yx1-xb12d.google.com ([2607:f8b0:4864:20::b12d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vrBKA-00000000Zjw-3ecb for pgsql-hackers@lists.postgresql.org; Sat, 14 Feb 2026 08:48:24 +0000 Received: by mail-yx1-xb12d.google.com with SMTP id 956f58d0204a3-64ada2c30a1so1669618d50.0 for ; Sat, 14 Feb 2026 00:48:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771058903; cv=none; d=google.com; s=arc-20240605; b=gf2oAVIsvGJVe5Zc1KCgdnOMIKk8MoRlwKkAOtHepPdrzB+DKzrH+fiJ9N3js1uy3q YDT3O+M+jNW9jl+mvsYEM93h6THjONbBmR2qtTyw88B21tS3wX/cIoaE+beUjX8hx2Ie YkMJutxHY+NkhvqZ3kZJKeNeYQqx2kMEeZU99jt7cMQQJE2LxjqR/hgXnPBrphpTCnJy OMkjt9KUfDEAmmRL8OmbWOVrY2YZkuL5eq00SHreJu6WM05UU6JLL29D/l0GAUir2h1C yEWUj+a0dt5YlEcXTSwiLRhbmzSUdH2ptRZIJYYIx1/M+TKd57nIc79gqzKIEQewo32o GLBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=MiPe3Df/3hABIN1xnVuqq6BEmqXtNBQMGyzmIp8jz6s=; fh=nwNxTtLLPTU0ewfLM7SSbrjMajMl+wwnFkCY/fi90vE=; b=WK27dW99pb+JepUniiUQMe7BYWVSN3aW2mQOfXF0+JwKXMJU1EnIWTqdwWXd+lfLF5 dS0jr6vPaTs96QizWZD7JKTuhBCrpHnmy44L0qOSoJ5HMfH4XAXxm7yvPp+h/0Viaicq gC5Qpt0CwU5o9RABznaldcVA4Pog1q4Qmuxnwb141PXN0qa99ikedZADESsdSOLUjgXC dWQDS/YVAcVjXhF3w7Yez1nGBpu//oRTrUPrS+RgHIt7f5CH4EZb8tshpktjvwUjsVrf CCdL1zn4lWQBSZ9AjRFSEVPWzSaedWK3x0Nq5pyjZNLrvf8lEFqRParTE62Tf9JevJOa Vwyw==; 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=1771058903; x=1771663703; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=MiPe3Df/3hABIN1xnVuqq6BEmqXtNBQMGyzmIp8jz6s=; b=MI8J0tk6qSYh6OCT/9C60evdeIjo5czRDpq3bgZdYYa1W1CY3pVjUKzQqexwHxPYlG 1RXISIoboyDyCDIfxw+Gf0L+PFYF6mGmEv2bAdwPsqRFvbP51ZtyrrY3Ptoxsp8soPES BSd1N0iAj8zKEJa5ZatSrr45wL6kGn2OWe8kmgCUoKKG1Rd8p9H0G8UZczD6wU+tLcNz Di+opwKmFuNGdtoPopgBlULA6N2bA9nKZgMWm8lgOrJSb5Aq7RtMdG0oa7Vy3smlcOGF cO6RDtltusm4JoCbgzT9IB+TA6gtkH1YSHyS+AXAt1wVQO/D9JFVrhEkXyKrqspqsP34 RaNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771058903; x=1771663703; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MiPe3Df/3hABIN1xnVuqq6BEmqXtNBQMGyzmIp8jz6s=; b=oQGpLprR0eLfK2vkPhRJ7Cy6qvQt1edBK1J5W36AfRnJn6pLhALkamQzyI8A1zk8GH YFkDpodBXFU/LVD5rD+LcnyhFhyArvlWjKsMOiGlUlOuRr3O01kQUFO11awU3TWrFqQA PbLJDISmJSJ5dbDKg1Nkov0ZnuJdta97D9E4ZkgerovwHyB2ZEhGNv2vWtJhck21ht9o nid4GXRdXOJZQxbAcrGvayWxRsmR+7t6Hx7rjMvM7ubfTz8k9+LQ5T0zVCgLWq3XfKJk dpuQPnn4klo3N5FD8Is+r89bADEklGw0rCSJh8NNeR5sXsGaAXNyI3lRTztW2qcZlkcT avnw== X-Gm-Message-State: AOJu0Yzw+dYxdFw38J9ClLXdclrD/q3+2MjpGtKKXikwwL1qQ5CfwEJb MX55V/rP1A60MlwFXh8Ctn2OTjg7x1XaIY/4wXFH9UEHHZq8/iQwn9lHUaSAaSr+HBDvBWtF8jz MyJYn+kDwL87bnG35xil/if3YiZ/HndFMJjKL X-Gm-Gg: AZuq6aLeJ7nNiwpf8D+ym8hh5ZvIm+Z1a6GDeLd1USxaPoQ2vTGssllTOox8BnZAnUr 110rCx5cjCO3aR2l/Yt0eYxidMBUnvaEgFvk3B5ep7Uso0/mGx7O7vL1KEpIxyTVjamNhJPrDeR W6bgGN4Qh4gtuv4qSk9YGoKQ4+rfCqUyYRgVr9MhGW0MFXKT5k8E3DOKHl6ZlGqoh+a3At8XLMs DH1xCB2kJZuW1hhD6XzzDLlICy0GRVC6UkKD/x0sTcGe+bvimjRU84UTX8o0MzUsrt6Pd+ADnkv XDKvtHqLNWaZQg/N/2o= X-Received: by 2002:a05:690e:d4e:b0:649:ec59:726c with SMTP id 956f58d0204a3-64c197ae855mr4039192d50.21.1771058902616; Sat, 14 Feb 2026 00:48:22 -0800 (PST) MIME-Version: 1.0 From: Shin Berg Date: Sat, 14 Feb 2026 17:48:11 +0900 X-Gm-Features: AZwV_QjXYte4Rzdmw6oiKYqe_hKP-d6PgG8B7JNzE05qDVbPVfjNcq-cumo8lQE Message-ID: Subject: Inconsistency in owner assignment between INDEX and STATISTICS To: pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000c44c99064ac4c83b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c44c99064ac4c83b Content-Type: text/plain; charset="UTF-8" Hi, I'd like to raise a small consistency issue between how INDEX and extended STATISTICS handle object ownership, and ask whether aligning them would be 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 relowner 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 = GetUserId()). So in a scenario 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 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 before 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 = i.indexrelid WHERE indrelid = 'shared_schema.bob_table'::regclass UNION ALL SELECT 'STATISTICS', stxname, pg_get_userbyid(stxowner) FROM pg_statistic_ext WHERE stxrelid = 'shared_schema.bob_table'::regclass; -- INDEX owner = bob, STATISTICS owner = 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. --000000000000c44c99064ac4c83b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

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

Current behavior (tested = on REL_17_STABLE):

- When a superuser creates an INDEX on another us= er's table, the index is owned by the *table owner* (see catalog/index.= c: index relation's relowner is set from the heap relation's relown= er).
- 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 inde= x and extended statistics on a user's table, the table owner can DROP t= he index (because they own it) 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 re= solve 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 GRANT USAGE, CREATE ON SCHEMA shared= _schema TO bob;

=C2=A0 SET ROLE bob;
=C2=A0 CREATE TABLE shared_s= chema.bob_table (a int, b int);
=C2=A0 RESET ROLE;

=C2=A0 CREATE = INDEX idx_bob ON shared_schema.bob_table(a);
=C2=A0 CREATE STATISTICS st= at_bob ON a, b FROM shared_schema.bob_table;

=C2=A0 SELECT 'INDE= X', c.relname, pg_get_userbyid(c.relowner) FROM pg_index i
=C2=A0 = =C2=A0 JOIN pg_class c ON c.oid =3D i.indexrelid
=C2=A0 =C2=A0 WHERE ind= relid =3D 'shared_schema.bob_table'::regclass
=C2=A0 UNION ALL=C2=A0 SELECT 'STATISTICS', stxname, pg_get_userbyid(stxowner) FR= OM pg_statistic_ext
=C2=A0 =C2=A0 WHERE stxrelid =3D 'shared_schema.= bob_table'::regclass;
=C2=A0 -- INDEX owner =3D bob, STATISTICS owne= r =3D superuser

=C2=A0 SET ROLE bob;
=C2=A0 DROP INDEX shared_sch= ema.idx_bob; =C2=A0 =C2=A0 =C2=A0 =C2=A0-- succeeds
=C2=A0 DROP STATISTI= CS shared_schema.stat_bob; =C2=A0-- ERROR: statistics object "..."= ; does not exist

I'm not sure if the current STATISTICS ownershi= p 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) fo= r consistency and to avoid the above scenario?

Thanks for your time.=
--000000000000c44c99064ac4c83b--