Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6767ceb

Browse files
committed
pg_dump/pg_restore now always use SET SESSION AUTHORIZATION, not \connect,
to control object ownership. The use-set-session-authorization andno-reconnect switches are obsolete (still accepted on the command line,but they don't do anything). This is a precursor to fixing handlingof CREATE SCHEMA, which will be a separate commit.
1 parent45de72b commit6767ceb

File tree

7 files changed

+111
-243
lines changed

7 files changed

+111
-243
lines changed

‎doc/src/sgml/ref/pg_dump.sgml

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.64 2003/09/11 21:42:20 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.65 2003/09/23 22:48:53 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -318,16 +318,16 @@ PostgreSQL documentation
318318
<term><option>--no-owner</option></term>
319319
<listitem>
320320
<para>
321-
Do not output commands to set the
322-
objectownership to match the original database. Typically,
323-
<application>pg_dump</application> issues
324-
(<application>psql</application>-specific) <command>\connect</command>
325-
statements to set ownership of schema elements. See also
326-
under <option>-R</option> and <option>-X
327-
use-set-session-authorization</option>. Note that
328-
<option>-O</option> does not preventallreconnections tothe
329-
database, only the ones thatare exclusively used for
330-
ownershipadjustments.
321+
Do not output commands to set
322+
ownershipof objectsto match the original database.
323+
By default,<application>pg_dump</application> issues
324+
<command>SET SESSION AUTHORIZATION</command>
325+
statements to set ownership ofcreatedschema elements.
326+
These statements
327+
will fail when the script is run unless it is started by a superuser
328+
(or the same user that ownsallof the objects inthe script).
329+
To make a script thatcan be restored by any user, but will give
330+
that userownershipof all the objects, specify <option>-O</>.
331331
</para>
332332

333333
<para>
@@ -343,27 +343,8 @@ PostgreSQL documentation
343343
<term><option>--no-reconnect</option></term>
344344
<listitem>
345345
<para>
346-
Prohibit <application>pg_dump</application>
347-
from outputting a script that would require reconnections to
348-
the database while being restored. An average restoration
349-
script usually has to reconnect several times as different
350-
users to set the original ownerships of the objects. This
351-
option is a rather blunt instrument because it makes
352-
<application>pg_dump</application> lose this ownership information,
353-
<emphasis>unless</emphasis> you use the <option>-X
354-
use-set-session-authorization</option> option.
355-
</para>
356-
357-
<para>
358-
One possible reason why reconnections during restore might not
359-
be desired is if the access to the database requires manual
360-
interaction (e.g., passwords).
361-
</para>
362-
363-
<para>
364-
This option is only meaningful for the plain-text format. For
365-
the other formats, you may specify the option when you
366-
call <command>pg_restore</command>.
346+
This option is obsolete but still accepted for backwards
347+
compatibility.
367348
</para>
368349
</listitem>
369350
</varlistentry>
@@ -385,8 +366,7 @@ PostgreSQL documentation
385366
<para>
386367
Specify the superuser user name to use when disabling triggers.
387368
This is only relevant if <option>--disable-triggers</> is used.
388-
(Usually, it's better to specify
389-
<option>--use-set-session-authorization</>, and then start the
369+
(Usually, it's better to leave this out, and instead start the
390370
resulting script as superuser.)
391371
</para>
392372
</listitem>
@@ -444,32 +424,10 @@ PostgreSQL documentation
444424
<term><option>--use-set-session-authorization</></term>
445425
<listitem>
446426
<para>
447-
Normally, if a (plain-text mode) script generated by
448-
<application>pg_dump</application> must alter the current database
449-
user (e.g., to set correct object ownerships), it uses the
450-
<application>psql</application> <command>\connect</command> command.
451-
This command actually opens a new connection, which might
452-
require manual interaction (e.g., passwords). If you use the
453-
<option>-X use-set-session-authorization</option> option, then
454-
<application>pg_dump</application> will instead output <xref
455-
linkend="sql-set-session-authorization" endterm="sql-set-session-authorization-title"> commands. This has
456-
the same effect, but it requires that the user restoring the
457-
database from the generated script be a database superuser.
458-
This option effectively overrides the <option>-R</option>
459-
option.
460-
</para>
461-
462-
<para>
463-
Since <xref linkend="sql-set-session-authorization" endterm="sql-set-session-authorization-title"> is a
464-
standard SQL command, whereas <command>\connect</command> only
465-
works in <application>psql</application>, this option also enhances
466-
the theoretical portability of the output script.
467-
</para>
468-
469-
<para>
470-
This option is only meaningful for the plain-text format. For
471-
the other formats, you may specify the option when you
472-
call <command>pg_restore</command>.
427+
This option is obsolete but still accepted for backwards
428+
compatibility.
429+
<application>pg_dump</application> now always behaves in the
430+
way formerly selected by this option.
473431
</para>
474432
</listitem>
475433
</varlistentry>
@@ -490,10 +448,8 @@ PostgreSQL documentation
490448
<para>
491449
Presently, the commands emitted for <option>--disable-triggers</>
492450
must be done as superuser. So, you should also specify
493-
a superuser name with <option>-S</>, or preferably specify
494-
<option>--use-set-session-authorization</> and then be careful to
495-
start the resulting script as a superuser. If you give neither
496-
option, the entire script must be run as superuser.
451+
a superuser name with <option>-S</>, or preferably be careful to
452+
start the resulting script as a superuser.
497453
</para>
498454

499455
<para>

‎doc/src/sgml/ref/pg_restore.sgml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.42 2003/09/11 21:42:20 momjian Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.43 2003/09/23 22:48:53 tgl Exp $ -->
22

33
<refentry id="APP-PGRESTORE">
44
<refmeta>
@@ -261,10 +261,16 @@
261261
<term><option>--no-owner</option></term>
262262
<listitem>
263263
<para>
264-
Prevent any attempt to restore original object
265-
ownership. Objects will be owned by the user name used to
266-
attach to the database. See also under <option>-R</option> and
267-
<option>-X use-set-session-authorization</option>.
264+
Do not output commands to set
265+
ownership of objects to match the original database.
266+
By default, <application>pg_restore</application> issues
267+
<command>SET SESSION AUTHORIZATION</command>
268+
statements to set ownership of created schema elements.
269+
These statements will fail unless the initial connection to the
270+
database is made by a superuser
271+
(or the same user that owns all of the objects in the script).
272+
With <option>-O</option>, any user name can be used for the
273+
initial connection, and this user will own all the created objects.
268274
</para>
269275
</listitem>
270276
</varlistentry>
@@ -311,20 +317,8 @@
311317
<term><option>--no-reconnect</option></term>
312318
<listitem>
313319
<para>
314-
While restoring an archive, <application>pg_restore</application>
315-
typically has to reconnect to the database several times with
316-
different user names to set the correct ownership of the
317-
created objects. If this is undesirable (e.g., because manual
318-
interaction (passwords) would be necessary for each
319-
reconnection), this option prevents
320-
<application>pg_restore</application> from issuing any reconnection
321-
requests. (A connection request while in plain text mode, not
322-
connected to a database, is made by putting out a <xref
323-
linkend="app-psql"> <command>\connect</command> command.)
324-
However, this option is a rather blunt instrument because it
325-
makes <application>pg_restore</application> lose all object ownership
326-
information, <emphasis>unless</emphasis> you use the
327-
<option>-X use-set-session-authorization</option> option.
320+
This option is obsolete but still accepted for backwards
321+
compatibility.
328322
</para>
329323
</listitem>
330324
</varlistentry>
@@ -397,16 +391,10 @@
397391
<term><option>--use-set-session-authorization</option></term>
398392
<listitem>
399393
<para>
400-
Normally, if restoring an archive requires altering the
401-
current database user (e.g., to set correct object
402-
ownerships), a new connection to the database must be opened,
403-
which might require manual interaction (e.g., passwords). If
404-
you use the <option>-X use-set-session-authorization</option> option,
405-
then <application>pg_restore</application> will instead use the <xref
406-
linkend="sql-set-session-authorization" endterm="sql-set-session-authorization-title"> command. This has
407-
the same effect, but it requires that the user restoring the
408-
archive is a database superuser. This option effectively
409-
overrides the <option>-R</option> option.
394+
This option is obsolete but still accepted for backwards
395+
compatibility.
396+
<application>pg_restore</application> now always behaves in the
397+
way formerly selected by this option.
410398
</para>
411399
</listitem>
412400
</varlistentry>
@@ -428,8 +416,7 @@
428416
Presently, the commands emitted for
429417
<option>--disable-triggers</> must be done as superuser. So, you
430418
should also specify a superuser name with <option>-S</>, or
431-
preferably specify <option>--use-set-session-authorization</> and
432-
run <application>pg_restore</application> as a
419+
preferably run <application>pg_restore</application> as a
433420
<productname>PostgreSQL</> superuser.
434421
</para>
435422
</listitem>

‎src/bin/pg_dump/pg_backup.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.25 2003/08/28 20:21:34 tgl Exp $
18+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.26 2003/09/23 22:48:53 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -62,12 +62,7 @@ typedef int (*DataDumperPtr) (Archive *AH, char *oid, void *userArg);
6262
typedefstruct_restoreOptions
6363
{
6464
intcreate;/* Issue commands to create the database */
65-
intnoOwner;/* Don't reconnect to database to match
66-
* original object owner */
67-
intnoReconnect;/* Don't reconnect to database under any
68-
* cirsumstances */
69-
intuse_setsessauth;/* use SET SESSSION AUTHORIZATION instead
70-
* of \connect */
65+
intnoOwner;/* Don't try to match original object owner */
7166
intdisable_triggers;/* disable triggers during
7267
* data-only restore */
7368
char*superuser;/* Username to use as superuser */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp