On Tue, Jan 21, 2014 at 1:33 AM, Simon Riggs <[email protected]> wrote:
> On 20 January 2014 17:00, Stephen Frost <[email protected]> wrote:
>> * Tom Lane ([email protected]) wrote:
>>> What if you're a superuser and you want to move everybody's objects
>>> (perhaps in preparation for dropping the tablespace)? I think there's
>>> value in both the ALL and OWNED forms.
>>
>> A superuser is considered to 'own' all objects and so 'ALL' and 'OWNED'
>> above would be the same when issued by a superuser, in the current
>> implementation.
>>
>> Looking at DROP OWNED and REASSIGN OWNED, they operate at the more
>> specific level of "OWNED" == "relowner" rather than if the role is
>> considered an 'owner' of the object through role membership, as you are
>> implying above.
>>
>> As such, I'll rework this to be more in-line with the existing OWNED BY
>> semantics of REASSIGN OWNED BY and DROP OWNED BY, which means we'd have:
>>
>> ALTER TABLESPACE name MOVE [ ALL | OWNED [ BY reluser ] ]
>> [ TABLES | INDEXES | MATERIALIZED VIEWS ] TO name opt_nowait
>>
>> eg:
>>
>> ALTER TABLESPACE tblspc1 MOVE ALL TO tblspc2;
>> ALTER TABLESPACE tblspc1 MOVE OWNED TO tblspc2;
>> ALTER TABLESPACE tblspc1 MOVE OWNED BY myrole TO tblspc2;
>> ALTER TABLESPACE tblspc1 MOVE TABLES OWNED BY myrole TO tblspc2;
>> ALTER TABLESPACE tblspc1 MOVE ALL OWNED BY myrole TO tblspc2;
>
> Sounds great, thanks.
We should add the tab-completion for ALTER TABLESPACE MOVE?
Attached does that.
Regards,
--
Fujii Masao
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 1622,1633 **** psql_completion(char *text, int start, int end)
COMPLETE_WITH_CONST("IDENTITY");
}
! /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
pg_strcasecmp(prev2_wd, "TABLESPACE") == 0)
{
static const char *const list_ALTERTSPC[] =
! {"RENAME TO", "OWNER TO", "SET", "RESET", NULL};
COMPLETE_WITH_LIST(list_ALTERTSPC);
}
--- 1622,1633 ----
COMPLETE_WITH_CONST("IDENTITY");
}
! /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET, MOVE */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
pg_strcasecmp(prev2_wd, "TABLESPACE") == 0)
{
static const char *const list_ALTERTSPC[] =
! {"RENAME TO", "OWNER TO", "SET", "RESET", "MOVE", NULL};
COMPLETE_WITH_LIST(list_ALTERTSPC);
}
***************
*** 1649,1654 **** psql_completion(char *text, int start, int end)
--- 1649,1675 ----
COMPLETE_WITH_LIST(list_TABLESPACEOPTIONS);
}
+ /* ALTER TABLESPACE <foo> MOVE ALL|TABLES|INDEXES|MATERIALIZED VIEWS */
+ else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
+ pg_strcasecmp(prev3_wd, "TABLESPACE") == 0 &&
+ pg_strcasecmp(prev_wd, "MOVE") == 0)
+ {
+ static const char *const list_TABLESPACEMOVETARGETS[] =
+ {"ALL", "TABLES", "INDEXES", "MATERIALIZED VIEWS", NULL};
+
+ COMPLETE_WITH_LIST(list_TABLESPACEMOVETARGETS);
+ }
+ else if ((pg_strcasecmp(prev4_wd, "TABLESPACE") == 0 &&
+ pg_strcasecmp(prev2_wd, "MOVE") == 0) ||
+ (pg_strcasecmp(prev5_wd, "TABLESPACE") == 0 &&
+ pg_strcasecmp(prev3_wd, "MOVE") == 0 &&
+ pg_strcasecmp(prev2_wd, "MATERIALIZED") == 0))
+ {
+ static const char *const list_TABLESPACEMOVEOPTIONS[] =
+ {"OWNED BY", "TO", NULL};
+
+ COMPLETE_WITH_LIST(list_TABLESPACEMOVEOPTIONS);
+ }
/* ALTER TEXT SEARCH */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
***************
*** 2559,2566 **** psql_completion(char *text, int start, int end)
* but we may as well tab-complete both: perhaps some users prefer one
* variant or the other.
*/
! else if (pg_strcasecmp(prev3_wd, "FETCH") == 0 ||
! pg_strcasecmp(prev3_wd, "MOVE") == 0)
{
static const char *const list_FROMIN[] =
{"FROM", "IN", NULL};
--- 2580,2588 ----
* but we may as well tab-complete both: perhaps some users prefer one
* variant or the other.
*/
! else if ((pg_strcasecmp(prev3_wd, "FETCH") == 0 ||
! pg_strcasecmp(prev3_wd, "MOVE") == 0) &&
! pg_strcasecmp(prev_wd, "TO") != 0)
{
static const char *const list_FROMIN[] =
{"FROM", "IN", NULL};
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers