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 1oFuit-0003Lt-QM for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Jul 2022 09:49:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oFuis-0005Nn-M1 for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Jul 2022 09:49:58 +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 1oFuis-0005LO-Bo for pgsql-hackers@lists.postgresql.org; Mon, 25 Jul 2022 09:49:58 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFuiq-0001ko-4h for pgsql-hackers@postgresql.org; Mon, 25 Jul 2022 09:49:57 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 41BE83200564; Mon, 25 Jul 2022 05:49:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 25 Jul 2022 05:49:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1658742593; x=1658828993; bh=n DGNA/kerUHKJRtgT7aEc242p5nZhoyYdurFwsmU0U4=; b=yzXTFoUaNn87POw6z Qnv76WdlZ8W2pyuYZSLOkWpA5x2ncjdw/u7/tn5wviTqw00lbVI6S3adwP/T5Vnq 06X+4X1beE1b1S7IgAMetHsfHZJhjL0ND60/IgtZwDM/QEYKbS40uDsYtTB6foJZ yfn89MG6phRjUK3TUtyBV5tWv0oVfY19UPZDHqqAHrCJP932pDkgebwdED/FiApn BuwFrjRV7QuUpW1Lg3ZJ0TTq67IQ1x2jhZxwNZkALNO11RxdjKHRZBs7FYr9SV7x 3TwD8rPqf95AGItqoZzF6bjPtWfC6vUpIGEhVTvVooOMZpfH4b41+Dma6fO6GGa4 blYIA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddtkedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepudelkeekgfdttdettdekgfduvdeiffelteegjeeihfet heekveeftedtuddvhfeunecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Jul 2022 05:49:52 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 5FC66369; Mon, 25 Jul 2022 11:49:50 +0200 (CEST) Date: Mon, 25 Jul 2022 11:49:50 +0200 From: Alvaro Herrera To: Michael Paquier Cc: Tom Lane , Dean Rasheed , Matthias van de Meent , Simon Riggs , PostgreSQL Hackers Subject: Re: Make name optional in CREATE STATISTICS Message-ID: <20220725094950.sifjxu2olmptbuz3@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="anhvcjyfzjkrlz2x" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --anhvcjyfzjkrlz2x Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2022-Jul-23, Michael Paquier wrote: > As the problem comes down to the fact that INDEX/TABLE, SCHEMA and > DATABASE/SYSTEM need to handle names for different object types each, > I think that we could do something like the attached, removing one > block on the way at the cost of an extra parser node. Yeah, looks good. I propose to also test the error for reindexing a different database, which is currently uncovered, as attached. > By the way, it seems that 83011ce also broke the case of "REINDEX > DATABASE CONCURRENTLY", where the parser missed the addition of a > DefElem for "concurrently" in this case. Wow. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "Escucha y olvidarás; ve y recordarás; haz y entenderás" (Confucio) --anhvcjyfzjkrlz2x Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="tweak-reindex.patch" diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index dfb0d85d66..f9037761f9 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -9115,8 +9115,8 @@ ReindexStmt: ReindexStmt *n = makeNode(ReindexStmt); n->kind = REINDEX_OBJECT_SCHEMA; - n->name = $5; n->relation = NULL; + n->name = $5; n->params = $2; if ($4) n->params = lappend(n->params, @@ -9126,9 +9126,10 @@ ReindexStmt: | REINDEX opt_reindex_option_list reindex_target_all opt_concurrently opt_single_name { ReindexStmt *n = makeNode(ReindexStmt); + n->kind = $3; - n->name = $5; n->relation = NULL; + n->name = $5; n->params = $2; if ($4) n->params = lappend(n->params, diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 801b396398..6cd57e3eaa 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -2529,6 +2529,9 @@ ERROR: cannot reindex system catalogs concurrently -- Warns about catalog relations REINDEX SCHEMA CONCURRENTLY pg_catalog; WARNING: cannot reindex system catalogs concurrently, skipping all +-- Not the current database +REINDEX DATABASE not_current_database; +ERROR: can only reindex the currently open database -- Check the relation status, there should not be invalid indexes \d concur_reindex_tab Table "public.concur_reindex_tab" diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql index 4b75790e47..a3738833b2 100644 --- a/src/test/regress/sql/create_index.sql +++ b/src/test/regress/sql/create_index.sql @@ -1076,6 +1076,8 @@ REINDEX (CONCURRENTLY) SYSTEM postgres; -- ditto REINDEX (CONCURRENTLY) SYSTEM; -- ditto -- Warns about catalog relations REINDEX SCHEMA CONCURRENTLY pg_catalog; +-- Not the current database +REINDEX DATABASE not_current_database; -- Check the relation status, there should not be invalid indexes \d concur_reindex_tab --anhvcjyfzjkrlz2x--