Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDGvC-0002sI-VF for pgsql-committers@arkaria.postgresql.org; Wed, 25 Sep 2019 23:42:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDGvB-0007vB-HD for pgsql-committers@arkaria.postgresql.org; Wed, 25 Sep 2019 23:42:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDGv9-0007u1-Ln for pgsql-committers@lists.postgresql.org; Wed, 25 Sep 2019 23:42:09 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDGv5-00021H-9R for pgsql-committers@lists.postgresql.org; Wed, 25 Sep 2019 23:42:07 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E0BFA5DE; Wed, 25 Sep 2019 19:41:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 25 Sep 2019 19:41:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=5GU5ah0eopGzagxC4ujT8f2uhDs W1RDyjG8HUrTvKis=; b=BeVP2fYJayEYSF112ATDWAZv7MqdcyYIkkAjSMFMMIE J0eoR+37yAybGESHmcQhjRoECcYeKGa6DI8+FjI36/3S7JRNSFHYtcnCLCTQVWNb mr1tgaOfCLqTYSpkRdE7STK0YdCMbeo4XNDeHE/AZKUDDcLm5xMOispxRjT8L2nZ BQj03xP0f86sm4cClYRQzQ8AOY2CsdiQFiRElh8E8z2iEksq5Pp0uF1AEGoNJuKv Uc5S3Cjx1JTyAQ5nzzUiSFz6U3z58+uNeLnwvUNkbeutGH9Kgr3J0Riue3Rd+qGr iN9hHfFVsyVmd+hy8k4YjCOLwykxQ2lKtiVkOb7eRzA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=5GU5ah 0eopGzagxC4ujT8f2uhDsW1RDyjG8HUrTvKis=; b=g+ZGJn0oO8UFNsBH4AsviY HOHfh6s1w5db4H6DQj2Y+k0bgf7RPqX+4zRqXUtUGlTfDQrpkWV1aA5O8m9Zh4tn 1gIlzA7TnMkf0hJyoR1oVQQRU+SHcWYUygX7N5YWuk+m8wypUnNiKBkyYL626R+0 1TbbR9WabVzxYu9n5BIPQvmRSmrPucuSZnXXFKh+TsPnokv2xoyeg3GEZT8IMrC1 XoYyLtsVJhmqyijaBhcgqmZhXJpI/hFm6yVW2u/Q+QTyVeh+5IC/UeKN8H5WOt29 qr2x2PpaeN52iNk8r+mHkZkv4HtJsifVfvOZHxANmYcqsQjFU1CBbydu5CKPpHfw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrfeefgddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdefhedmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddu necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuffhomhgrihhnpehpohhsthhgrhdrvghsnecukfhppeduuddu rddutddvrddukedtrddukeehnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvg hlsehprghquhhivghrrdighiiinecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id D0A098005B; Wed, 25 Sep 2019 19:41:56 -0400 (EDT) Date: Thu, 26 Sep 2019 08:41:52 +0900 From: Michael Paquier To: Alvaro Herrera Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Support reloptions of enum type Message-ID: <20190925234152.GA2115@paquier.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="O5XBE6gyVG5Rl6Rj" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --O5XBE6gyVG5Rl6Rj Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Alvaro, On Wed, Sep 25, 2019 at 06:59:24PM +0000, Alvaro Herrera wrote: > Support reloptions of enum type >=20 > All our current in core relation options of type string (not many, > admittedly) behave in reality like enums. But after seeing an > implementation for enum reloptions, it's clear that strings are messier, > so introduce the new reloption type. Switch all string options to be > enums instead. >=20 > Fortunately we have a recently introduced test module for reloptions, so > we don't lose coverage of string reloptions, which may still be used by > third-party modules. >=20 > Authors: Nikolay Shaplov, =C1lvaro Herrera > Reviewed-by: Nikita Glukhov, Aleksandr Parfenov > Discussion: https://postgr.es/m/43332102.S2V5pIjXRx@x200m This part from commit 773df88 is incorrect: @@ -661,6 +700,13 @@ allocate_reloption(bits32 kinds, int type, const char *name, const char *desc, newoption->type =3D type; newoption->lockmode =3D lockmode; + /* + * Set the default lock mode for this option. There is no actual way + * for a module to enforce it when declaring a custom relation option, + * so just use the highest level, which is safe for all cases. + */ + newoption->lockmode =3D AccessExclusiveLock; Any caller of allocate_reloption() passes down its own lockmode definition, hence you are removing the pluggability of the API. I think that you just got trapped by an incorrect rebase. Do you mind if I apply the attached to fix the issue? Or perhaps you would prefer fixing the issue yourself? I noted some inconsistencies with the rest while on it (please see attached). -- Michael --YZ5djTAD1cGYuMQK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="reloptions-lockmode.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/co= mmon/reloptions.c index 85627a05a3..b5072c00fe 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -700,13 +700,6 @@ allocate_reloption(bits32 kinds, int type, const char = *name, const char *desc, newoption->type =3D type; newoption->lockmode =3D lockmode; =20 - /* - * Set the default lock mode for this option. There is no actual way - * for a module to enforce it when declaring a custom relation option, - * so just use the highest level, which is safe for all cases. - */ - newoption->lockmode =3D AccessExclusiveLock; - MemoryContextSwitchTo(oldcxt); =20 return newoption; diff --git a/src/test/modules/dummy_index_am/README b/src/test/modules/dumm= y_index_am/README index 7bcdec56f3..61f3360fd1 100644 --- a/src/test/modules/dummy_index_am/README +++ b/src/test/modules/dummy_index_am/README @@ -8,4 +8,5 @@ This includes tests for all relation option types: - boolean - integer - real +- enum - strings (with and without NULL as default) diff --git a/src/test/modules/dummy_index_am/expected/reloptions.out b/src/= test/modules/dummy_index_am/expected/reloptions.out index 99742f6fdc..c873a80bb7 100644 --- a/src/test/modules/dummy_index_am/expected/reloptions.out +++ b/src/test/modules/dummy_index_am/expected/reloptions.out @@ -20,6 +20,7 @@ CREATE INDEX dummy_test_idx ON dummy_test_tab option_bool =3D false, option_int =3D 5, option_real =3D 3.1, + option_enum =3D 'two', option_string_val =3D NULL, option_string_null =3D 'val'); NOTICE: new option value for string parameter null @@ -32,9 +33,10 @@ SELECT unnest(reloptions) FROM pg_class WHERE relname = =3D 'dummy_test_idx'; option_bool=3Dfalse option_int=3D5 option_real=3D3.1 + option_enum=3Dtwo option_string_val=3Dnull option_string_null=3Dval -(5 rows) +(6 rows) =20 -- ALTER INDEX .. SET ALTER INDEX dummy_test_idx SET (option_int =3D 10); diff --git a/src/test/modules/dummy_index_am/sql/reloptions.sql b/src/test/= modules/dummy_index_am/sql/reloptions.sql index 0172cf094e..6749d763e6 100644 --- a/src/test/modules/dummy_index_am/sql/reloptions.sql +++ b/src/test/modules/dummy_index_am/sql/reloptions.sql @@ -20,6 +20,7 @@ CREATE INDEX dummy_test_idx ON dummy_test_tab option_bool =3D false, option_int =3D 5, option_real =3D 3.1, + option_enum =3D 'two', option_string_val =3D NULL, option_string_null =3D 'val'); -- Silence again validation checks for strings until the end of the test. --YZ5djTAD1cGYuMQK-- --O5XBE6gyVG5Rl6Rj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl2L+0AACgkQnvQgOdby QH0JDA//cTWQyE0/Fa04RG/r57zGKTr2g1wB4cGCWSCem67F2b5lpEarNbHgq8Pw elMiAI80Vrbw+k4CqUt5VjN7DKYpvHtMVufb5dltKPTL7yJqIlb4PFxHilH4Cnvc Kgpv/AZNx+g/D+4EbaVfQN21m8ME4RVHkMYUGdUu1fDwehtRYFPiKg4hJDS2zQvu bWBVY2zuBpE84rpOuK1SB10JJ7ZzdIBV+JVosBdegLbPG9GRYzWgxbY3wjGrZjem lNYQ9Kf73lb0upFatTtrl5VxZpQtQtej+v7022Z/lbW4c6Pk8hKT6YUp4iajeRkZ 65jKjNdd5WLL0ANyy7+8k/GyGuiH/m19S2VmfmL7oe1mTvsfBnq4PaMaOgQvdNNp 1XwuP7Encw4dk1l2NtwKKvX7+JkfKMyUMg79ZvP5wDDahrvp+YCSt2lDWuSX5zCU GgbC+lQo1S6vs1pjtyR6bNwqbgmgY/DY1NmqYkwfdLUFi5MeZyVgDmMoH2WaOb/Z NMMGVBy/jG/5D5BODr1qLzxSI3rELUsl7SsPKgRG932kHr5YPxEjH8cnU4GlW/uG OEvlO0bEvoG6TydODC2uJ/z1o8la4uPt8q9rClwqeJrqgEswcuDj9NFwtz7qkroK /ONTD1wDYhTrRwExURCtrfW2xpV0ahF1AnAz8rUnpd62mJWlBuw= =KPw5 -----END PGP SIGNATURE----- --O5XBE6gyVG5Rl6Rj--