Re: dropdb --force - Mailing list pgsql-hackers

From vignesh C
Subject Re: dropdb --force
Date
Msg-id CALDaNm3nP8AF_0Bi6ucTUjRrvrUfj5hRQVp-z+crwXnevLsEuw@mail.gmail.com
Whole thread Raw
In response to Re: dropdb --force  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: dropdb --force
List pgsql-hackers
On Sat, Sep 21, 2019 at 10:09 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
> fixed
>
> Thank you for check. I am sending updated patch
>
Thanks for fixing all the comments.
Couple of suggestions:
-DROP DATABASE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
+DROP DATABASE [ ( <replaceable class="parameter">option</replaceable>
[, ...] ) ] [ IF EXISTS ] <replaceable
class="parameter">name</replaceable>
+
+<phrase>where <replaceable class="parameter">option</replaceable> can
be one of:</phrase>
+
+    FORCE

+drop_option_list:
+ drop_option
+ {
+ $$ = list_make1((Node *) $1);
+ }
+ | drop_option_list ',' drop_option
+ {
+ $$ = lappend($1, (Node *) $3);
+ }
+ ;
+
+drop_option: FORCE
+ {
+ $$ = makeDefElem("force", NULL, @1);
+ }
+ ;

Currently only force option is supported in: drop database (force) dbname
Should we have a list or a single element for this?
I'm not sure if we have any plans to add more option in this area.

If possible we can add an error message like 'ERROR:  unrecognized
drop database option "force1"' if an invalid input is given.
The above error message will be inline with error message of vacuum's
error message whose syntax is similar to the current feature.
We could throw the error from here:
  case T_DropdbStmt:
  {
  DropdbStmt *stmt = (DropdbStmt *) parsetree;
+ bool force = false;
+ ListCell   *lc;
+
+ foreach(lc, stmt->options)
+ {
+ DefElem    *item = (DefElem *) lfirst(lc);
+
+ if (strcmp(item->defname, "force") == 0)
+ force = true;
+ }
Thoughts?

Regards,
Vignesh
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: range test for hash index?
Next
From: Michael Paquier
Date:
Subject: Re: Fix example in partitioning documentation