pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Support reloptions of enum type
6+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2019-09-27 fbfa566488  Fix lockmode initialization for custom relation options
* pgsql: Support reloptions of enum type
@ 2019-09-25 18:59  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 2 replies; 6+ messages in thread

From: Alvaro Herrera @ 2019-09-25 18:59 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Support reloptions of enum type

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.

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.

Authors: Nikolay Shaplov, Álvaro Herrera
Reviewed-by: Nikita Glukhov, Aleksandr Parfenov
Discussion: https://postgr.es/m/43332102.S2V5pIjXRx@x200m

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/773df883e8f7543958d0d719c025b5f47c5a67f0

Modified Files
--------------
src/backend/access/common/reloptions.c             | 132 +++++++++++++++++++--
src/backend/access/gist/gistbuild.c                |  25 +---
src/backend/access/gist/gistutil.c                 |   2 +-
src/backend/commands/view.c                        |  18 ---
src/include/access/gist_private.h                  |  10 +-
src/include/access/reloptions.h                    |  24 ++++
src/include/commands/view.h                        |   2 -
src/include/utils/rel.h                            |  25 ++--
src/test/modules/dummy_index_am/dummy_index_am.c   |  37 ++++--
src/test/modules/dummy_index_am/sql/reloptions.sql |  10 ++
src/test/regress/expected/gist.out                 |   2 +-
src/test/regress/expected/updatable_views.out      |   2 +-
12 files changed, 214 insertions(+), 75 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Support reloptions of enum type
@ 2019-09-25 19:19  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
  1 sibling, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2019-09-25 19:19 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

On 2019-Sep-25, Alvaro Herrera wrote:

> Support reloptions of enum type

I forgot to "git add" an expected output file.  Pushing in a minute ..

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Support reloptions of enum type
@ 2019-09-25 23:41  Michael Paquier <michael@paquier.xyz>
  parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
  1 sibling, 2 replies; 6+ messages in thread

From: Michael Paquier @ 2019-09-25 23:41 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: pgsql-committers@lists.postgresql.org

Hi Alvaro,

On Wed, Sep 25, 2019 at 06:59:24PM +0000, Alvaro Herrera wrote:
> Support reloptions of enum type
> 
> 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.
> 
> 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.
> 
> Authors: Nikolay Shaplov, Álvaro 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 = type;
    newoption->lockmode = 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 = 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

Attachments:

reloptions-lockmode.patch (text/x-diff, 2.4K) download diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/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 = type; newoption->lockmode = 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 = AccessExclusiveLock; - MemoryContextSwitchTo(oldcxt); return newoption; diff --git a/src/test/modules/dummy_index_am/README b/src/test/modules/dummy_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 = false, option_int = 5, option_real = 3.1, + option_enum = 'two', option_string_val = NULL, option_string_null = 'val'); NOTICE: new option value for string parameter null @@ -32,9 +33,10 @@ SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx'; option_bool=false option_int=5 option_real=3.1 + option_enum=two option_string_val=null option_string_null=val -(5 rows) +(6 rows) -- ALTER INDEX .. SET ALTER INDEX dummy_test_idx SET (option_int = 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 = false, option_int = 5, option_real = 3.1, + option_enum = 'two', option_string_val = NULL, option_string_null = 'val'); -- Silence again validation checks for strings until the end of the test.
signature.asc (application/pgp-signature, 832B) download ^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: pgsql: Support reloptions of enum type
@ 2019-09-27 00:32  Michael Paquier <michael@paquier.xyz>
  parent: Michael Paquier <michael@paquier.xyz>
  1 sibling, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2019-09-27 00:32 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: pgsql-committers@lists.postgresql.org

On Thu, Sep 26, 2019 at 08:41:52AM +0900, Michael Paquier wrote:
> 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).

And applied as of fbfa566.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Support reloptions of enum type
@ 2019-09-27 01:19  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Michael Paquier <michael@paquier.xyz>
  1 sibling, 1 reply; 6+ messages in thread

From: Alvaro Herrera @ 2019-09-27 01:19 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-committers@lists.postgresql.org

Hello, sorry I didn't notice this email.

On 2019-Sep-26, Michael Paquier wrote:

> This part from commit 773df88 is incorrect:

> +   /*
> +    * 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 = AccessExclusiveLock;

You're right, this was a merge blunder :-(  Sorry about that.

> 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).

Thanks for fixing.  It all looks correct to me.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Support reloptions of enum type
@ 2019-09-27 01:51  Michael Paquier <michael@paquier.xyz>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2019-09-27 01:51 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-committers@lists.postgresql.org

On Thu, Sep 26, 2019 at 10:19:47PM -0300, Alvaro Herrera wrote:
> Thanks for fixing.  It all looks correct to me.

Thanks for double-checking.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2019-09-27 01:51 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 18:59 pgsql: Support reloptions of enum type Alvaro Herrera <alvherre@alvh.no-ip.org>
2019-09-25 19:19 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2019-09-25 23:41 ` Michael Paquier <michael@paquier.xyz>
2019-09-27 00:32   ` Michael Paquier <michael@paquier.xyz>
2019-09-27 01:19   ` Alvaro Herrera <alvherre@2ndquadrant.com>
2019-09-27 01:51     ` Michael Paquier <michael@paquier.xyz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox