Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- pgsql/doc/extension/autoinc.example +35 -0
- pgsql/doc/extension/insert_username.example +20 -0
- pgsql/doc/extension/moddatetime.example +27 -0
- pgsql/doc/extension/refint.example +82 -0
- pgsql/doc/postgresql/html/acronyms.html +224 -0
- pgsql/doc/postgresql/html/admin.html +26 -0
- pgsql/doc/postgresql/html/adminpack.html +89 -0
- pgsql/doc/postgresql/html/amcheck.html +377 -0
- pgsql/doc/postgresql/html/app-clusterdb.html +122 -0
- pgsql/doc/postgresql/html/app-createdb.html +155 -0
- pgsql/doc/postgresql/html/app-createuser.html +205 -0
- pgsql/doc/postgresql/html/app-dropdb.html +111 -0
- pgsql/doc/postgresql/html/app-dropuser.html +104 -0
- pgsql/doc/postgresql/html/app-ecpg.html +108 -0
- pgsql/doc/postgresql/html/app-initdb.html +267 -0
- pgsql/doc/postgresql/html/app-pg-ctl.html +288 -0
- pgsql/doc/postgresql/html/app-pg-dumpall.html +364 -0
- pgsql/doc/postgresql/html/app-pg-isready.html +79 -0
- pgsql/doc/postgresql/html/app-pgamcheck.html +295 -0
- pgsql/doc/postgresql/html/app-pgbasebackup.html +555 -0
- pgsql/doc/postgresql/html/app-pgchecksums.html +75 -0
- pgsql/doc/postgresql/html/app-pgconfig.html +110 -0
- pgsql/doc/postgresql/html/app-pgcontroldata.html +23 -0
- pgsql/doc/postgresql/html/app-pgdump.html +863 -0
- pgsql/doc/postgresql/html/app-pgreceivewal.html +251 -0
- pgsql/doc/postgresql/html/app-pgreceivexlog.html +10 -0
- pgsql/doc/postgresql/html/app-pgrecvlogical.html +188 -0
- pgsql/doc/postgresql/html/app-pgresetwal.html +169 -0
- pgsql/doc/postgresql/html/app-pgresetxlog.html +10 -0
- pgsql/doc/postgresql/html/app-pgrestore.html +504 -0
- pgsql/doc/postgresql/html/app-pgrewind.html +210 -0
- pgsql/doc/postgresql/html/app-pgverifybackup.html +150 -0
- pgsql/doc/postgresql/html/app-postgres.html +416 -0
- pgsql/doc/postgresql/html/app-psql.html +0 -0
- pgsql/doc/postgresql/html/app-reindexdb.html +164 -0
- pgsql/doc/postgresql/html/app-vacuumdb.html +252 -0
- pgsql/doc/postgresql/html/appendix-obsolete.html +8 -0
- pgsql/doc/postgresql/html/appendixes.html +10 -0
- pgsql/doc/postgresql/html/applevel-consistency.html +115 -0
- pgsql/doc/postgresql/html/archive-module-callbacks.html +60 -0
- pgsql/doc/postgresql/html/archive-module-init.html +28 -0
- pgsql/doc/postgresql/html/archive-modules.html +24 -0
- pgsql/doc/postgresql/html/arrays.html +647 -0
- pgsql/doc/postgresql/html/auth-bsd.html +21 -0
- pgsql/doc/postgresql/html/auth-cert.html +25 -0
- pgsql/doc/postgresql/html/auth-delay.html +28 -0
- pgsql/doc/postgresql/html/auth-ident.html +52 -0
- pgsql/doc/postgresql/html/auth-ldap.html +190 -0
- pgsql/doc/postgresql/html/auth-methods.html +59 -0
- pgsql/doc/postgresql/html/auth-pam.html +31 -0
pgsql/doc/extension/autoinc.example
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
DROP SEQUENCE next_id;
|
| 2 |
+
DROP TABLE ids;
|
| 3 |
+
|
| 4 |
+
CREATE SEQUENCE next_id START -2 MINVALUE -2;
|
| 5 |
+
|
| 6 |
+
CREATE TABLE ids (
|
| 7 |
+
id int4,
|
| 8 |
+
idesc text
|
| 9 |
+
);
|
| 10 |
+
|
| 11 |
+
CREATE TRIGGER ids_nextid
|
| 12 |
+
BEFORE INSERT OR UPDATE ON ids
|
| 13 |
+
FOR EACH ROW
|
| 14 |
+
EXECUTE PROCEDURE autoinc (id, next_id);
|
| 15 |
+
|
| 16 |
+
INSERT INTO ids VALUES (0, 'first (-2 ?)');
|
| 17 |
+
INSERT INTO ids VALUES (null, 'second (-1 ?)');
|
| 18 |
+
INSERT INTO ids(idesc) VALUES ('third (1 ?!)');
|
| 19 |
+
|
| 20 |
+
SELECT * FROM ids;
|
| 21 |
+
|
| 22 |
+
UPDATE ids SET id = null, idesc = 'first: -2 --> 2'
|
| 23 |
+
WHERE idesc = 'first (-2 ?)';
|
| 24 |
+
UPDATE ids SET id = 0, idesc = 'second: -1 --> 3'
|
| 25 |
+
WHERE id = -1;
|
| 26 |
+
UPDATE ids SET id = 4, idesc = 'third: 1 --> 4'
|
| 27 |
+
WHERE id = 1;
|
| 28 |
+
|
| 29 |
+
SELECT * FROM ids;
|
| 30 |
+
|
| 31 |
+
SELECT 'Wasn''t it 4 ?' as nextval, nextval ('next_id') as value;
|
| 32 |
+
|
| 33 |
+
insert into ids (idesc) select textcat (idesc, '. Copy.') from ids;
|
| 34 |
+
|
| 35 |
+
SELECT * FROM ids;
|
pgsql/doc/extension/insert_username.example
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
DROP TABLE username_test;
|
| 2 |
+
|
| 3 |
+
CREATE TABLE username_test (
|
| 4 |
+
name text,
|
| 5 |
+
username text not null
|
| 6 |
+
);
|
| 7 |
+
|
| 8 |
+
CREATE TRIGGER insert_usernames
|
| 9 |
+
BEFORE INSERT OR UPDATE ON username_test
|
| 10 |
+
FOR EACH ROW
|
| 11 |
+
EXECUTE PROCEDURE insert_username (username);
|
| 12 |
+
|
| 13 |
+
INSERT INTO username_test VALUES ('nothing');
|
| 14 |
+
INSERT INTO username_test VALUES ('null', null);
|
| 15 |
+
INSERT INTO username_test VALUES ('empty string', '');
|
| 16 |
+
INSERT INTO username_test VALUES ('space', ' ');
|
| 17 |
+
INSERT INTO username_test VALUES ('tab', ' ');
|
| 18 |
+
INSERT INTO username_test VALUES ('name', 'name');
|
| 19 |
+
|
| 20 |
+
SELECT * FROM username_test;
|
pgsql/doc/extension/moddatetime.example
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
DROP TABLE mdt;
|
| 2 |
+
|
| 3 |
+
CREATE TABLE mdt (
|
| 4 |
+
id int4,
|
| 5 |
+
idesc text,
|
| 6 |
+
moddate timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
|
| 7 |
+
);
|
| 8 |
+
|
| 9 |
+
CREATE TRIGGER mdt_moddatetime
|
| 10 |
+
BEFORE UPDATE ON mdt
|
| 11 |
+
FOR EACH ROW
|
| 12 |
+
EXECUTE PROCEDURE moddatetime (moddate);
|
| 13 |
+
|
| 14 |
+
INSERT INTO mdt VALUES (1, 'first');
|
| 15 |
+
INSERT INTO mdt VALUES (2, 'second');
|
| 16 |
+
INSERT INTO mdt VALUES (3, 'third');
|
| 17 |
+
|
| 18 |
+
SELECT * FROM mdt;
|
| 19 |
+
|
| 20 |
+
UPDATE mdt SET id = 4
|
| 21 |
+
WHERE id = 1;
|
| 22 |
+
UPDATE mdt SET id = 5
|
| 23 |
+
WHERE id = 2;
|
| 24 |
+
UPDATE mdt SET id = 6
|
| 25 |
+
WHERE id = 3;
|
| 26 |
+
|
| 27 |
+
SELECT * FROM mdt;
|
pgsql/doc/extension/refint.example
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
--Column ID of table A is primary key:
|
| 2 |
+
|
| 3 |
+
CREATE TABLE A (
|
| 4 |
+
ID int4 not null
|
| 5 |
+
);
|
| 6 |
+
CREATE UNIQUE INDEX AI ON A (ID);
|
| 7 |
+
|
| 8 |
+
--Columns REFB of table B and REFC of C are foreign keys referencing ID of A:
|
| 9 |
+
|
| 10 |
+
CREATE TABLE B (
|
| 11 |
+
REFB int4
|
| 12 |
+
);
|
| 13 |
+
CREATE INDEX BI ON B (REFB);
|
| 14 |
+
|
| 15 |
+
CREATE TABLE C (
|
| 16 |
+
REFC int4
|
| 17 |
+
);
|
| 18 |
+
CREATE INDEX CI ON C (REFC);
|
| 19 |
+
|
| 20 |
+
--Trigger for table A:
|
| 21 |
+
|
| 22 |
+
CREATE TRIGGER AT BEFORE DELETE OR UPDATE ON A FOR EACH ROW
|
| 23 |
+
EXECUTE PROCEDURE
|
| 24 |
+
check_foreign_key (2, 'cascade', 'ID', 'B', 'REFB', 'C', 'REFC');
|
| 25 |
+
/*
|
| 26 |
+
2 - means that check must be performed for foreign keys of 2 tables.
|
| 27 |
+
cascade - defines that corresponding keys must be deleted.
|
| 28 |
+
ID - name of primary key column in triggered table (A). You may
|
| 29 |
+
use as many columns as you need.
|
| 30 |
+
B - name of (first) table with foreign keys.
|
| 31 |
+
REFB - name of foreign key column in this table. You may use as many
|
| 32 |
+
columns as you need, but number of key columns in referenced
|
| 33 |
+
table (A) must be the same.
|
| 34 |
+
C - name of second table with foreign keys.
|
| 35 |
+
REFC - name of foreign key column in this table.
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
--Trigger for table B:
|
| 39 |
+
|
| 40 |
+
CREATE TRIGGER BT BEFORE INSERT OR UPDATE ON B FOR EACH ROW
|
| 41 |
+
EXECUTE PROCEDURE
|
| 42 |
+
check_primary_key ('REFB', 'A', 'ID');
|
| 43 |
+
|
| 44 |
+
/*
|
| 45 |
+
REFB - name of foreign key column in triggered (B) table. You may use as
|
| 46 |
+
many columns as you need, but number of key columns in referenced
|
| 47 |
+
table must be the same.
|
| 48 |
+
A - referenced table name.
|
| 49 |
+
ID - name of primary key column in referenced table.
|
| 50 |
+
*/
|
| 51 |
+
|
| 52 |
+
--Trigger for table C:
|
| 53 |
+
|
| 54 |
+
CREATE TRIGGER CT BEFORE INSERT OR UPDATE ON C FOR EACH ROW
|
| 55 |
+
EXECUTE PROCEDURE
|
| 56 |
+
check_primary_key ('REFC', 'A', 'ID');
|
| 57 |
+
|
| 58 |
+
-- Now try
|
| 59 |
+
|
| 60 |
+
INSERT INTO A VALUES (10);
|
| 61 |
+
INSERT INTO A VALUES (20);
|
| 62 |
+
INSERT INTO A VALUES (30);
|
| 63 |
+
INSERT INTO A VALUES (40);
|
| 64 |
+
INSERT INTO A VALUES (50);
|
| 65 |
+
|
| 66 |
+
INSERT INTO B VALUES (1); -- invalid reference
|
| 67 |
+
INSERT INTO B VALUES (10);
|
| 68 |
+
INSERT INTO B VALUES (30);
|
| 69 |
+
INSERT INTO B VALUES (30);
|
| 70 |
+
|
| 71 |
+
INSERT INTO C VALUES (11); -- invalid reference
|
| 72 |
+
INSERT INTO C VALUES (20);
|
| 73 |
+
INSERT INTO C VALUES (20);
|
| 74 |
+
INSERT INTO C VALUES (30);
|
| 75 |
+
|
| 76 |
+
DELETE FROM A WHERE ID = 10;
|
| 77 |
+
DELETE FROM A WHERE ID = 20;
|
| 78 |
+
DELETE FROM A WHERE ID = 30;
|
| 79 |
+
|
| 80 |
+
SELECT * FROM A;
|
| 81 |
+
SELECT * FROM B;
|
| 82 |
+
SELECT * FROM C;
|
pgsql/doc/postgresql/html/acronyms.html
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Appendix L. Acronyms</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="limits.html" title="Appendix K. PostgreSQL Limits" /><link rel="next" href="glossary.html" title="Appendix M. Glossary" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Appendix L. Acronyms</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="limits.html" title="Appendix K. PostgreSQL Limits">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="appendixes.html" title="Part VIII. Appendixes">Up</a></td><th width="60%" align="center">Part VIII. Appendixes</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="glossary.html" title="Appendix M. Glossary">Next</a></td></tr></table><hr /></div><div class="appendix" id="ACRONYMS"><div class="titlepage"><div><div><h2 class="title">Appendix L. Acronyms</h2></div></div></div><p>
|
| 3 |
+
This is a list of acronyms commonly used in the <span class="productname">PostgreSQL</span>
|
| 4 |
+
documentation and in discussions about <span class="productname">PostgreSQL</span>.
|
| 5 |
+
|
| 6 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><acronym class="acronym">ANSI</acronym></span></dt><dd><p>
|
| 7 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/American_National_Standards_Institute" target="_top">
|
| 8 |
+
American National Standards Institute</a>
|
| 9 |
+
</p></dd><dt><span class="term"><acronym class="acronym">API</acronym></span></dt><dd><p>
|
| 10 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/API" target="_top">Application Programming Interface</a>
|
| 11 |
+
</p></dd><dt><span class="term"><acronym class="acronym">ASCII</acronym></span></dt><dd><p>
|
| 12 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Ascii" target="_top">American Standard
|
| 13 |
+
Code for Information Interchange</a>
|
| 14 |
+
</p></dd><dt><span class="term"><acronym class="acronym">BKI</acronym></span></dt><dd><p>
|
| 15 |
+
<a class="link" href="bki.html" title="Chapter 75. System Catalog Declarations and Initial Contents">Backend Interface</a>
|
| 16 |
+
</p></dd><dt><span class="term"><acronym class="acronym">CA</acronym></span></dt><dd><p>
|
| 17 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Certificate_authority" target="_top">Certificate Authority</a>
|
| 18 |
+
</p></dd><dt><span class="term"><acronym class="acronym">CIDR</acronym></span></dt><dd><p>
|
| 19 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing" target="_top">Classless
|
| 20 |
+
Inter-Domain Routing</a>
|
| 21 |
+
</p></dd><dt><span class="term"><acronym class="acronym">CPAN</acronym></span></dt><dd><p>
|
| 22 |
+
<a class="ulink" href="https://www.cpan.org/" target="_top">Comprehensive Perl Archive Network</a>
|
| 23 |
+
</p></dd><dt><span class="term"><acronym class="acronym">CRL</acronym></span></dt><dd><p>
|
| 24 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Certificate_revocation_list" target="_top">Certificate
|
| 25 |
+
Revocation List</a>
|
| 26 |
+
</p></dd><dt><span class="term"><acronym class="acronym">CSV</acronym></span></dt><dd><p>
|
| 27 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Comma-separated_values" target="_top">Comma
|
| 28 |
+
Separated Values</a>
|
| 29 |
+
</p></dd><dt><span class="term"><acronym class="acronym">CTE</acronym></span></dt><dd><p>
|
| 30 |
+
<a class="link" href="queries-with.html" title="7.8. WITH Queries (Common Table Expressions)">Common Table Expression</a>
|
| 31 |
+
</p></dd><dt><span class="term"><acronym class="acronym">CVE</acronym></span></dt><dd><p>
|
| 32 |
+
<a class="ulink" href="https://cve.mitre.org/" target="_top">Common Vulnerabilities and Exposures</a>
|
| 33 |
+
</p></dd><dt><span class="term"><acronym class="acronym">DBA</acronym></span></dt><dd><p>
|
| 34 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Database_administrator" target="_top">Database
|
| 35 |
+
Administrator</a>
|
| 36 |
+
</p></dd><dt><span class="term"><acronym class="acronym">DBI</acronym></span></dt><dd><p>
|
| 37 |
+
<a class="ulink" href="https://dbi.perl.org/" target="_top">Database Interface (Perl)</a>
|
| 38 |
+
</p></dd><dt><span class="term"><acronym class="acronym">DBMS</acronym></span></dt><dd><p>
|
| 39 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Dbms" target="_top">Database Management
|
| 40 |
+
System</a>
|
| 41 |
+
</p></dd><dt><span class="term"><acronym class="acronym">DDL</acronym></span></dt><dd><p>
|
| 42 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Data_Definition_Language" target="_top">Data
|
| 43 |
+
Definition Language</a>, SQL commands such as <code class="command">CREATE
|
| 44 |
+
TABLE</code>, <code class="command">ALTER USER</code>
|
| 45 |
+
</p></dd><dt><span class="term"><acronym class="acronym">DML</acronym></span></dt><dd><p>
|
| 46 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Data_Manipulation_Language" target="_top">Data
|
| 47 |
+
Manipulation Language</a>, SQL commands such as <code class="command">INSERT</code>,
|
| 48 |
+
<code class="command">UPDATE</code>, <code class="command">DELETE</code>
|
| 49 |
+
</p></dd><dt><span class="term"><acronym class="acronym">DST</acronym></span></dt><dd><p>
|
| 50 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Daylight_saving_time" target="_top">Daylight
|
| 51 |
+
Saving Time</a>
|
| 52 |
+
</p></dd><dt><span class="term"><acronym class="acronym">ECPG</acronym></span></dt><dd><p>
|
| 53 |
+
<a class="link" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Embedded C for PostgreSQL</a>
|
| 54 |
+
</p></dd><dt><span class="term"><acronym class="acronym">ESQL</acronym></span></dt><dd><p>
|
| 55 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Embedded_SQL" target="_top">Embedded
|
| 56 |
+
SQL</a>
|
| 57 |
+
</p></dd><dt><span class="term"><acronym class="acronym">FAQ</acronym></span></dt><dd><p>
|
| 58 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/FAQ" target="_top">Frequently Asked
|
| 59 |
+
Questions</a>
|
| 60 |
+
</p></dd><dt><span class="term"><acronym class="acronym">FSM</acronym></span></dt><dd><p>
|
| 61 |
+
<a class="link" href="storage-fsm.html" title="73.3. Free Space Map">Free Space Map</a>
|
| 62 |
+
</p></dd><dt><span class="term"><acronym class="acronym">GEQO</acronym></span></dt><dd><p>
|
| 63 |
+
<a class="link" href="geqo.html" title="Chapter 62. Genetic Query Optimizer">Genetic Query Optimizer</a>
|
| 64 |
+
</p></dd><dt><span class="term"><acronym class="acronym">GIN</acronym></span></dt><dd><p>
|
| 65 |
+
<a class="link" href="gin.html" title="Chapter 70. GIN Indexes">Generalized Inverted Index</a>
|
| 66 |
+
</p></dd><dt><span class="term"><acronym class="acronym">GiST</acronym></span></dt><dd><p>
|
| 67 |
+
<a class="link" href="gist.html" title="Chapter 68. GiST Indexes">Generalized Search Tree</a>
|
| 68 |
+
</p></dd><dt><span class="term"><acronym class="acronym">Git</acronym></span></dt><dd><p>
|
| 69 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Git_(software)" target="_top">Git</a>
|
| 70 |
+
</p></dd><dt><span class="term"><acronym class="acronym">GMT</acronym></span></dt><dd><p>
|
| 71 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/GMT" target="_top">Greenwich Mean Time</a>
|
| 72 |
+
</p></dd><dt><span class="term"><acronym class="acronym">GSSAPI</acronym></span></dt><dd><p>
|
| 73 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Generic_Security_Services_Application_Program_Interface" target="_top">Generic
|
| 74 |
+
Security Services Application Programming Interface</a>
|
| 75 |
+
</p></dd><dt><span class="term"><acronym class="acronym">GUC</acronym></span></dt><dd><p>
|
| 76 |
+
<a class="link" href="config-setting.html" title="20.1. Setting Parameters">Grand Unified Configuration</a>,
|
| 77 |
+
the <span class="productname">PostgreSQL</span> subsystem that handles server configuration
|
| 78 |
+
</p></dd><dt><span class="term"><acronym class="acronym">HBA</acronym></span></dt><dd><p>
|
| 79 |
+
<a class="link" href="auth-pg-hba-conf.html" title="21.1. The pg_hba.conf File">Host-Based Authentication</a>
|
| 80 |
+
</p></dd><dt><span class="term"><acronym class="acronym">HOT</acronym></span></dt><dd><p>
|
| 81 |
+
<a class="link" href="storage-hot.html" title="73.7. Heap-Only Tuples (HOT)">Heap-Only Tuples</a>
|
| 82 |
+
</p></dd><dt><span class="term"><acronym class="acronym">IEC</acronym></span></dt><dd><p>
|
| 83 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/International_Electrotechnical_Commission" target="_top">International
|
| 84 |
+
Electrotechnical Commission</a>
|
| 85 |
+
</p></dd><dt><span class="term"><acronym class="acronym">IEEE</acronym></span></dt><dd><p>
|
| 86 |
+
<a class="ulink" href="https://standards.ieee.org/" target="_top">Institute of Electrical and
|
| 87 |
+
Electronics Engineers</a>
|
| 88 |
+
</p></dd><dt><span class="term"><acronym class="acronym">IPC</acronym></span></dt><dd><p>
|
| 89 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Inter-process_communication" target="_top">Inter-Process
|
| 90 |
+
Communication</a>
|
| 91 |
+
</p></dd><dt><span class="term"><acronym class="acronym">ISO</acronym></span></dt><dd><p>
|
| 92 |
+
<a class="ulink" href="https://www.iso.org/home.html" target="_top">International Organization for
|
| 93 |
+
Standardization</a>
|
| 94 |
+
</p></dd><dt><span class="term"><acronym class="acronym">ISSN</acronym></span></dt><dd><p>
|
| 95 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Issn" target="_top">International Standard
|
| 96 |
+
Serial Number</a>
|
| 97 |
+
</p></dd><dt><span class="term"><acronym class="acronym">JDBC</acronym></span></dt><dd><p>
|
| 98 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Java_Database_Connectivity" target="_top">Java
|
| 99 |
+
Database Connectivity</a>
|
| 100 |
+
</p></dd><dt><span class="term"><acronym class="acronym">JIT</acronym></span></dt><dd><p>
|
| 101 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Just-in-time_compilation" target="_top">Just-in-Time
|
| 102 |
+
compilation</a>
|
| 103 |
+
</p></dd><dt><span class="term"><acronym class="acronym">JSON</acronym></span></dt><dd><p>
|
| 104 |
+
<a class="ulink" href="https://www.json.org" target="_top">JavaScript Object Notation</a>
|
| 105 |
+
</p></dd><dt><span class="term"><acronym class="acronym">LDAP</acronym></span></dt><dd><p>
|
| 106 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol" target="_top">Lightweight
|
| 107 |
+
Directory Access Protocol</a>
|
| 108 |
+
</p></dd><dt><span class="term"><acronym class="acronym">LSN</acronym></span></dt><dd><p>
|
| 109 |
+
<a class="glossterm" href="glossary.html#GLOSSARY-LOG-SEQUENCE-NUMBER"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-LOG-SEQUENCE-NUMBER" title="Log sequence number">Log Sequence Number</a></em></a>
|
| 110 |
+
</p></dd><dt><span class="term"><acronym class="acronym">MCF</acronym></span></dt><dd><p>
|
| 111 |
+
Most Common Frequency, that is the frequency associated with some
|
| 112 |
+
Most Common Value
|
| 113 |
+
</p></dd><dt><span class="term"><acronym class="acronym">MCV</acronym></span></dt><dd><p>
|
| 114 |
+
Most Common Value, one of the values appearing most often within a
|
| 115 |
+
particular table column
|
| 116 |
+
</p></dd><dt><span class="term"><acronym class="acronym">MITM</acronym></span></dt><dd><p>
|
| 117 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack" target="_top">
|
| 118 |
+
Man-in-the-middle attack</a>
|
| 119 |
+
</p></dd><dt><span class="term"><acronym class="acronym">MSVC</acronym></span></dt><dd><p>
|
| 120 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Visual_C++" target="_top"><span class="productname">Microsoft
|
| 121 |
+
Visual C</span></a>
|
| 122 |
+
</p></dd><dt><span class="term"><acronym class="acronym">MVCC</acronym></span></dt><dd><p>
|
| 123 |
+
<a class="link" href="mvcc.html" title="Chapter 13. Concurrency Control">Multi-Version Concurrency Control</a>
|
| 124 |
+
</p></dd><dt><span class="term"><acronym class="acronym">NLS</acronym></span></dt><dd><p>
|
| 125 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Internationalization_and_localization" target="_top">National
|
| 126 |
+
Language Support</a>
|
| 127 |
+
</p></dd><dt><span class="term"><acronym class="acronym">ODBC</acronym></span></dt><dd><p>
|
| 128 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Open_Database_Connectivity" target="_top">Open
|
| 129 |
+
Database Connectivity</a>
|
| 130 |
+
</p></dd><dt><span class="term"><acronym class="acronym">OID</acronym></span></dt><dd><p>
|
| 131 |
+
<a class="link" href="datatype-oid.html" title="8.19. Object Identifier Types">Object Identifier</a>
|
| 132 |
+
</p></dd><dt><span class="term"><acronym class="acronym">OLAP</acronym></span></dt><dd><p>
|
| 133 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Olap" target="_top">Online Analytical
|
| 134 |
+
Processing</a>
|
| 135 |
+
</p></dd><dt><span class="term"><acronym class="acronym">OLTP</acronym></span></dt><dd><p>
|
| 136 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/OLTP" target="_top">Online Transaction
|
| 137 |
+
Processing</a>
|
| 138 |
+
</p></dd><dt><span class="term"><acronym class="acronym">ORDBMS</acronym></span></dt><dd><p>
|
| 139 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/ORDBMS" target="_top">Object-Relational
|
| 140 |
+
Database Management System</a>
|
| 141 |
+
</p></dd><dt><span class="term"><acronym class="acronym">PAM</acronym></span></dt><dd><p>
|
| 142 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Pluggable_Authentication_Modules" target="_top">Pluggable
|
| 143 |
+
Authentication Modules</a>
|
| 144 |
+
</p></dd><dt><span class="term"><acronym class="acronym">PGSQL</acronym></span></dt><dd><p>
|
| 145 |
+
<a class="link" href="index.html" title="PostgreSQL 16.3 Documentation"><span class="productname">PostgreSQL</span></a>
|
| 146 |
+
</p></dd><dt><span class="term"><acronym class="acronym">PGXS</acronym></span></dt><dd><p>
|
| 147 |
+
<a class="link" href="extend-pgxs.html" title="38.18. Extension Building Infrastructure"><span class="productname">PostgreSQL</span> Extension System</a>
|
| 148 |
+
</p></dd><dt><span class="term"><acronym class="acronym">PID</acronym></span></dt><dd><p>
|
| 149 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Process_identifier" target="_top">Process Identifier</a>
|
| 150 |
+
</p></dd><dt><span class="term"><acronym class="acronym">PITR</acronym></span></dt><dd><p>
|
| 151 |
+
<a class="link" href="continuous-archiving.html" title="26.3. Continuous Archiving and Point-in-Time Recovery (PITR)">Point-In-Time
|
| 152 |
+
Recovery</a> (Continuous Archiving)
|
| 153 |
+
</p></dd><dt><span class="term"><acronym class="acronym">PL</acronym></span></dt><dd><p>
|
| 154 |
+
<a class="link" href="server-programming.html" title="Part V. Server Programming">Procedural Languages (server-side)</a>
|
| 155 |
+
</p></dd><dt><span class="term"><acronym class="acronym">POSIX</acronym></span></dt><dd><p>
|
| 156 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/POSIX" target="_top">Portable Operating
|
| 157 |
+
System Interface</a>
|
| 158 |
+
</p></dd><dt><span class="term"><acronym class="acronym">RDBMS</acronym></span></dt><dd><p>
|
| 159 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Relational_database_management_system" target="_top">Relational
|
| 160 |
+
Database Management System</a>
|
| 161 |
+
</p></dd><dt><span class="term"><acronym class="acronym">RFC</acronym></span></dt><dd><p>
|
| 162 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Request_for_Comments" target="_top">Request For
|
| 163 |
+
Comments</a>
|
| 164 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SGML</acronym></span></dt><dd><p>
|
| 165 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/SGML" target="_top">Standard Generalized
|
| 166 |
+
Markup Language</a>
|
| 167 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SNI</acronym></span></dt><dd><p>
|
| 168 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Server_Name_Indication" target="_top">
|
| 169 |
+
Server Name Indication</a>,
|
| 170 |
+
<a class="ulink" href="https://datatracker.ietf.org/doc/html/rfc6066#section-3" target="_top">RFC 6066</a>
|
| 171 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SPI</acronym></span></dt><dd><p>
|
| 172 |
+
<a class="link" href="spi.html" title="Chapter 47. Server Programming Interface">Server Programming Interface</a>
|
| 173 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SP-GiST</acronym></span></dt><dd><p>
|
| 174 |
+
<a class="link" href="spgist.html" title="Chapter 69. SP-GiST Indexes">Space-Partitioned Generalized Search Tree</a>
|
| 175 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SQL</acronym></span></dt><dd><p>
|
| 176 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/SQL" target="_top">Structured Query Language</a>
|
| 177 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SRF</acronym></span></dt><dd><p>
|
| 178 |
+
<a class="link" href="xfunc-c.html#XFUNC-C-RETURN-SET" title="38.10.8. Returning Sets">Set-Returning Function</a>
|
| 179 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SSH</acronym></span></dt><dd><p>
|
| 180 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Secure_Shell" target="_top">Secure
|
| 181 |
+
Shell</a>
|
| 182 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SSL</acronym></span></dt><dd><p>
|
| 183 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Secure_Sockets_Layer" target="_top">Secure Sockets Layer</a>
|
| 184 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SSPI</acronym></span></dt><dd><p>
|
| 185 |
+
<a class="ulink" href="https://msdn.microsoft.com/en-us/library/aa380493%28VS.85%29.aspx" target="_top">Security
|
| 186 |
+
Support Provider Interface</a>
|
| 187 |
+
</p></dd><dt><span class="term"><acronym class="acronym">SYSV</acronym></span></dt><dd><p>
|
| 188 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/System_V" target="_top">Unix System V</a>
|
| 189 |
+
</p></dd><dt><span class="term"><acronym class="acronym">TCP/IP</acronym></span></dt><dd><p>
|
| 190 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Transmission_Control_Protocol" target="_top">Transmission
|
| 191 |
+
Control Protocol (TCP) / Internet Protocol (IP)</a>
|
| 192 |
+
</p></dd><dt><span class="term"><acronym class="acronym">TID</acronym></span></dt><dd><p>
|
| 193 |
+
<a class="link" href="datatype-oid.html" title="8.19. Object Identifier Types">Tuple Identifier</a>
|
| 194 |
+
</p></dd><dt><span class="term"><acronym class="acronym">TLS</acronym></span></dt><dd><p>
|
| 195 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Transport_Layer_Security" target="_top">
|
| 196 |
+
Transport Layer Security</a>
|
| 197 |
+
</p></dd><dt><span class="term"><acronym class="acronym">TOAST</acronym></span></dt><dd><p>
|
| 198 |
+
<a class="link" href="storage-toast.html" title="73.2. TOAST">The Oversized-Attribute Storage Technique</a>
|
| 199 |
+
</p></dd><dt><span class="term"><acronym class="acronym">TPC</acronym></span></dt><dd><p>
|
| 200 |
+
<a class="ulink" href="http://www.tpc.org/" target="_top">Transaction Processing
|
| 201 |
+
Performance Council</a>
|
| 202 |
+
</p></dd><dt><span class="term"><acronym class="acronym">URL</acronym></span></dt><dd><p>
|
| 203 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/URL" target="_top">Uniform Resource
|
| 204 |
+
Locator</a>
|
| 205 |
+
</p></dd><dt><span class="term"><acronym class="acronym">UTC</acronym></span></dt><dd><p>
|
| 206 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_top">Coordinated
|
| 207 |
+
Universal Time</a>
|
| 208 |
+
</p></dd><dt><span class="term"><acronym class="acronym">UTF</acronym></span></dt><dd><p>
|
| 209 |
+
<a class="ulink" href="https://www.unicode.org/" target="_top">Unicode Transformation
|
| 210 |
+
Format</a>
|
| 211 |
+
</p></dd><dt><span class="term"><acronym class="acronym">UTF8</acronym></span></dt><dd><p>
|
| 212 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/Utf8" target="_top">Eight-Bit Unicode
|
| 213 |
+
Transformation Format</a>
|
| 214 |
+
</p></dd><dt><span class="term"><acronym class="acronym">UUID</acronym></span></dt><dd><p>
|
| 215 |
+
<a class="link" href="datatype-uuid.html" title="8.12. UUID Type">Universally Unique Identifier</a>
|
| 216 |
+
</p></dd><dt><span class="term"><acronym class="acronym">WAL</acronym></span></dt><dd><p>
|
| 217 |
+
<a class="link" href="wal.html" title="Chapter 30. Reliability and the Write-Ahead Log">Write-Ahead Log</a>
|
| 218 |
+
</p></dd><dt><span class="term"><acronym class="acronym">XID</acronym></span></dt><dd><p>
|
| 219 |
+
<a class="link" href="datatype-oid.html" title="8.19. Object Identifier Types">Transaction Identifier</a>
|
| 220 |
+
</p></dd><dt><span class="term"><acronym class="acronym">XML</acronym></span></dt><dd><p>
|
| 221 |
+
<a class="ulink" href="https://en.wikipedia.org/wiki/XML" target="_top">Extensible Markup
|
| 222 |
+
Language</a>
|
| 223 |
+
</p></dd></dl></div><p>
|
| 224 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="limits.html" title="Appendix K. PostgreSQL Limits">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendixes.html" title="Part VIII. Appendixes">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="glossary.html" title="Appendix M. Glossary">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix K. <span class="productname">PostgreSQL</span> Limits </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Appendix M. Glossary</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/admin.html
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Part III. Server Administration</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="parallel-safety.html" title="15.4. Parallel Safety" /><link rel="next" href="install-binaries.html" title="Chapter 16. Installation from Binaries" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Part III. Server Administration</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="parallel-safety.html" title="15.4. Parallel Safety">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="index.html" title="PostgreSQL 16.3 Documentation">Up</a></td><th width="60%" align="center">PostgreSQL 16.3 Documentation</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="install-binaries.html" title="Chapter 16. Installation from Binaries">Next</a></td></tr></table><hr /></div><div class="part" id="ADMIN"><div class="titlepage"><div><div><h1 class="title">Part III. Server Administration</h1></div></div></div><div class="partintro" id="id-1.6.2"><div></div><p>
|
| 3 |
+
This part covers topics that are of interest to a
|
| 4 |
+
<span class="productname">PostgreSQL</span> database administrator. This includes
|
| 5 |
+
installation of the software, set up and configuration of the
|
| 6 |
+
server, management of users and databases, and maintenance tasks.
|
| 7 |
+
Anyone who runs a <span class="productname">PostgreSQL</span> server, even for
|
| 8 |
+
personal use, but especially in production, should be familiar
|
| 9 |
+
with the topics covered in this part.
|
| 10 |
+
</p><p>
|
| 11 |
+
The information in this part is arranged approximately in the
|
| 12 |
+
order in which a new user should read it. But the chapters are
|
| 13 |
+
self-contained and can be read individually as desired. The
|
| 14 |
+
information in this part is presented in a narrative fashion in
|
| 15 |
+
topical units. Readers looking for a complete description of a
|
| 16 |
+
particular command should see <a class="xref" href="reference.html" title="Part VI. Reference">Part VI</a>.
|
| 17 |
+
</p><p>
|
| 18 |
+
The first few chapters are written so they can be understood
|
| 19 |
+
without prerequisite knowledge, so new users who need to set
|
| 20 |
+
up their own server can begin their exploration with this part.
|
| 21 |
+
The rest of this part is about tuning and management; that material
|
| 22 |
+
assumes that the reader is familiar with the general use of
|
| 23 |
+
the <span class="productname">PostgreSQL</span> database system. Readers are
|
| 24 |
+
encouraged to look at <a class="xref" href="tutorial.html" title="Part I. Tutorial">Part I</a> and <a class="xref" href="sql.html" title="Part II. The SQL Language">Part II</a> for additional information.
|
| 25 |
+
</p><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="chapter"><a href="install-binaries.html">16. Installation from Binaries</a></span></dt><dt><span class="chapter"><a href="installation.html">17. Installation from Source Code</a></span></dt><dd><dl><dt><span class="sect1"><a href="install-requirements.html">17.1. Requirements</a></span></dt><dt><span class="sect1"><a href="install-getsource.html">17.2. Getting the Source</a></span></dt><dt><span class="sect1"><a href="install-make.html">17.3. Building and Installation with Autoconf and Make</a></span></dt><dt><span class="sect1"><a href="install-meson.html">17.4. Building and Installation with Meson</a></span></dt><dt><span class="sect1"><a href="install-post.html">17.5. Post-Installation Setup</a></span></dt><dt><span class="sect1"><a href="supported-platforms.html">17.6. Supported Platforms</a></span></dt><dt><span class="sect1"><a href="installation-platform-notes.html">17.7. Platform-Specific Notes</a></span></dt></dl></dd><dt><span class="chapter"><a href="install-windows.html">18. Installation from Source Code on <span class="productname">Windows</span></a></span></dt><dd><dl><dt><span class="sect1"><a href="install-windows-full.html">18.1. Building with <span class="productname">Visual C++</span> or the
|
| 26 |
+
<span class="productname">Microsoft Windows SDK</span></a></span></dt></dl></dd><dt><span class="chapter"><a href="runtime.html">19. Server Setup and Operation</a></span></dt><dd><dl><dt><span class="sect1"><a href="postgres-user.html">19.1. The <span class="productname">PostgreSQL</span> User Account</a></span></dt><dt><span class="sect1"><a href="creating-cluster.html">19.2. Creating a Database Cluster</a></span></dt><dt><span class="sect1"><a href="server-start.html">19.3. Starting the Database Server</a></span></dt><dt><span class="sect1"><a href="kernel-resources.html">19.4. Managing Kernel Resources</a></span></dt><dt><span class="sect1"><a href="server-shutdown.html">19.5. Shutting Down the Server</a></span></dt><dt><span class="sect1"><a href="upgrading.html">19.6. Upgrading a <span class="productname">PostgreSQL</span> Cluster</a></span></dt><dt><span class="sect1"><a href="preventing-server-spoofing.html">19.7. Preventing Server Spoofing</a></span></dt><dt><span class="sect1"><a href="encryption-options.html">19.8. Encryption Options</a></span></dt><dt><span class="sect1"><a href="ssl-tcp.html">19.9. Secure TCP/IP Connections with SSL</a></span></dt><dt><span class="sect1"><a href="gssapi-enc.html">19.10. Secure TCP/IP Connections with GSSAPI Encryption</a></span></dt><dt><span class="sect1"><a href="ssh-tunnels.html">19.11. Secure TCP/IP Connections with <span class="application">SSH</span> Tunnels</a></span></dt><dt><span class="sect1"><a href="event-log-registration.html">19.12. Registering <span class="application">Event Log</span> on <span class="systemitem">Windows</span></a></span></dt></dl></dd><dt><span class="chapter"><a href="runtime-config.html">20. Server Configuration</a></span></dt><dd><dl><dt><span class="sect1"><a href="config-setting.html">20.1. Setting Parameters</a></span></dt><dt><span class="sect1"><a href="runtime-config-file-locations.html">20.2. File Locations</a></span></dt><dt><span class="sect1"><a href="runtime-config-connection.html">20.3. Connections and Authentication</a></span></dt><dt><span class="sect1"><a href="runtime-config-resource.html">20.4. Resource Consumption</a></span></dt><dt><span class="sect1"><a href="runtime-config-wal.html">20.5. Write Ahead Log</a></span></dt><dt><span class="sect1"><a href="runtime-config-replication.html">20.6. Replication</a></span></dt><dt><span class="sect1"><a href="runtime-config-query.html">20.7. Query Planning</a></span></dt><dt><span class="sect1"><a href="runtime-config-logging.html">20.8. Error Reporting and Logging</a></span></dt><dt><span class="sect1"><a href="runtime-config-statistics.html">20.9. Run-time Statistics</a></span></dt><dt><span class="sect1"><a href="runtime-config-autovacuum.html">20.10. Automatic Vacuuming</a></span></dt><dt><span class="sect1"><a href="runtime-config-client.html">20.11. Client Connection Defaults</a></span></dt><dt><span class="sect1"><a href="runtime-config-locks.html">20.12. Lock Management</a></span></dt><dt><span class="sect1"><a href="runtime-config-compatible.html">20.13. Version and Platform Compatibility</a></span></dt><dt><span class="sect1"><a href="runtime-config-error-handling.html">20.14. Error Handling</a></span></dt><dt><span class="sect1"><a href="runtime-config-preset.html">20.15. Preset Options</a></span></dt><dt><span class="sect1"><a href="runtime-config-custom.html">20.16. Customized Options</a></span></dt><dt><span class="sect1"><a href="runtime-config-developer.html">20.17. Developer Options</a></span></dt><dt><span class="sect1"><a href="runtime-config-short.html">20.18. Short Options</a></span></dt></dl></dd><dt><span class="chapter"><a href="client-authentication.html">21. Client Authentication</a></span></dt><dd><dl><dt><span class="sect1"><a href="auth-pg-hba-conf.html">21.1. The <code class="filename">pg_hba.conf</code> File</a></span></dt><dt><span class="sect1"><a href="auth-username-maps.html">21.2. User Name Maps</a></span></dt><dt><span class="sect1"><a href="auth-methods.html">21.3. Authentication Methods</a></span></dt><dt><span class="sect1"><a href="auth-trust.html">21.4. Trust Authentication</a></span></dt><dt><span class="sect1"><a href="auth-password.html">21.5. Password Authentication</a></span></dt><dt><span class="sect1"><a href="gssapi-auth.html">21.6. GSSAPI Authentication</a></span></dt><dt><span class="sect1"><a href="sspi-auth.html">21.7. SSPI Authentication</a></span></dt><dt><span class="sect1"><a href="auth-ident.html">21.8. Ident Authentication</a></span></dt><dt><span class="sect1"><a href="auth-peer.html">21.9. Peer Authentication</a></span></dt><dt><span class="sect1"><a href="auth-ldap.html">21.10. LDAP Authentication</a></span></dt><dt><span class="sect1"><a href="auth-radius.html">21.11. RADIUS Authentication</a></span></dt><dt><span class="sect1"><a href="auth-cert.html">21.12. Certificate Authentication</a></span></dt><dt><span class="sect1"><a href="auth-pam.html">21.13. PAM Authentication</a></span></dt><dt><span class="sect1"><a href="auth-bsd.html">21.14. BSD Authentication</a></span></dt><dt><span class="sect1"><a href="client-authentication-problems.html">21.15. Authentication Problems</a></span></dt></dl></dd><dt><span class="chapter"><a href="user-manag.html">22. Database Roles</a></span></dt><dd><dl><dt><span class="sect1"><a href="database-roles.html">22.1. Database Roles</a></span></dt><dt><span class="sect1"><a href="role-attributes.html">22.2. Role Attributes</a></span></dt><dt><span class="sect1"><a href="role-membership.html">22.3. Role Membership</a></span></dt><dt><span class="sect1"><a href="role-removal.html">22.4. Dropping Roles</a></span></dt><dt><span class="sect1"><a href="predefined-roles.html">22.5. Predefined Roles</a></span></dt><dt><span class="sect1"><a href="perm-functions.html">22.6. Function Security</a></span></dt></dl></dd><dt><span class="chapter"><a href="managing-databases.html">23. Managing Databases</a></span></dt><dd><dl><dt><span class="sect1"><a href="manage-ag-overview.html">23.1. Overview</a></span></dt><dt><span class="sect1"><a href="manage-ag-createdb.html">23.2. Creating a Database</a></span></dt><dt><span class="sect1"><a href="manage-ag-templatedbs.html">23.3. Template Databases</a></span></dt><dt><span class="sect1"><a href="manage-ag-config.html">23.4. Database Configuration</a></span></dt><dt><span class="sect1"><a href="manage-ag-dropdb.html">23.5. Destroying a Database</a></span></dt><dt><span class="sect1"><a href="manage-ag-tablespaces.html">23.6. Tablespaces</a></span></dt></dl></dd><dt><span class="chapter"><a href="charset.html">24. Localization</a></span></dt><dd><dl><dt><span class="sect1"><a href="locale.html">24.1. Locale Support</a></span></dt><dt><span class="sect1"><a href="collation.html">24.2. Collation Support</a></span></dt><dt><span class="sect1"><a href="multibyte.html">24.3. Character Set Support</a></span></dt></dl></dd><dt><span class="chapter"><a href="maintenance.html">25. Routine Database Maintenance Tasks</a></span></dt><dd><dl><dt><span class="sect1"><a href="routine-vacuuming.html">25.1. Routine Vacuuming</a></span></dt><dt><span class="sect1"><a href="routine-reindex.html">25.2. Routine Reindexing</a></span></dt><dt><span class="sect1"><a href="logfile-maintenance.html">25.3. Log File Maintenance</a></span></dt></dl></dd><dt><span class="chapter"><a href="backup.html">26. Backup and Restore</a></span></dt><dd><dl><dt><span class="sect1"><a href="backup-dump.html">26.1. <acronym class="acronym">SQL</acronym> Dump</a></span></dt><dt><span class="sect1"><a href="backup-file.html">26.2. File System Level Backup</a></span></dt><dt><span class="sect1"><a href="continuous-archiving.html">26.3. Continuous Archiving and Point-in-Time Recovery (PITR)</a></span></dt></dl></dd><dt><span class="chapter"><a href="high-availability.html">27. High Availability, Load Balancing, and Replication</a></span></dt><dd><dl><dt><span class="sect1"><a href="different-replication-solutions.html">27.1. Comparison of Different Solutions</a></span></dt><dt><span class="sect1"><a href="warm-standby.html">27.2. Log-Shipping Standby Servers</a></span></dt><dt><span class="sect1"><a href="warm-standby-failover.html">27.3. Failover</a></span></dt><dt><span class="sect1"><a href="hot-standby.html">27.4. Hot Standby</a></span></dt></dl></dd><dt><span class="chapter"><a href="monitoring.html">28. Monitoring Database Activity</a></span></dt><dd><dl><dt><span class="sect1"><a href="monitoring-ps.html">28.1. Standard Unix Tools</a></span></dt><dt><span class="sect1"><a href="monitoring-stats.html">28.2. The Cumulative Statistics System</a></span></dt><dt><span class="sect1"><a href="monitoring-locks.html">28.3. Viewing Locks</a></span></dt><dt><span class="sect1"><a href="progress-reporting.html">28.4. Progress Reporting</a></span></dt><dt><span class="sect1"><a href="dynamic-trace.html">28.5. Dynamic Tracing</a></span></dt></dl></dd><dt><span class="chapter"><a href="diskusage.html">29. Monitoring Disk Usage</a></span></dt><dd><dl><dt><span class="sect1"><a href="disk-usage.html">29.1. Determining Disk Usage</a></span></dt><dt><span class="sect1"><a href="disk-full.html">29.2. Disk Full Failure</a></span></dt></dl></dd><dt><span class="chapter"><a href="wal.html">30. Reliability and the Write-Ahead Log</a></span></dt><dd><dl><dt><span class="sect1"><a href="wal-reliability.html">30.1. Reliability</a></span></dt><dt><span class="sect1"><a href="checksums.html">30.2. Data Checksums</a></span></dt><dt><span class="sect1"><a href="wal-intro.html">30.3. Write-Ahead Logging (<acronym class="acronym">WAL</acronym>)</a></span></dt><dt><span class="sect1"><a href="wal-async-commit.html">30.4. Asynchronous Commit</a></span></dt><dt><span class="sect1"><a href="wal-configuration.html">30.5. <acronym class="acronym">WAL</acronym> Configuration</a></span></dt><dt><span class="sect1"><a href="wal-internals.html">30.6. WAL Internals</a></span></dt></dl></dd><dt><span class="chapter"><a href="logical-replication.html">31. Logical Replication</a></span></dt><dd><dl><dt><span class="sect1"><a href="logical-replication-publication.html">31.1. Publication</a></span></dt><dt><span class="sect1"><a href="logical-replication-subscription.html">31.2. Subscription</a></span></dt><dt><span class="sect1"><a href="logical-replication-row-filter.html">31.3. Row Filters</a></span></dt><dt><span class="sect1"><a href="logical-replication-col-lists.html">31.4. Column Lists</a></span></dt><dt><span class="sect1"><a href="logical-replication-conflicts.html">31.5. Conflicts</a></span></dt><dt><span class="sect1"><a href="logical-replication-restrictions.html">31.6. Restrictions</a></span></dt><dt><span class="sect1"><a href="logical-replication-architecture.html">31.7. Architecture</a></span></dt><dt><span class="sect1"><a href="logical-replication-monitoring.html">31.8. Monitoring</a></span></dt><dt><span class="sect1"><a href="logical-replication-security.html">31.9. Security</a></span></dt><dt><span class="sect1"><a href="logical-replication-config.html">31.10. Configuration Settings</a></span></dt><dt><span class="sect1"><a href="logical-replication-quick-setup.html">31.11. Quick Setup</a></span></dt></dl></dd><dt><span class="chapter"><a href="jit.html">32. Just-in-Time Compilation (<acronym class="acronym">JIT</acronym>)</a></span></dt><dd><dl><dt><span class="sect1"><a href="jit-reason.html">32.1. What Is <acronym class="acronym">JIT</acronym> compilation?</a></span></dt><dt><span class="sect1"><a href="jit-decision.html">32.2. When to <acronym class="acronym">JIT</acronym>?</a></span></dt><dt><span class="sect1"><a href="jit-configuration.html">32.3. Configuration</a></span></dt><dt><span class="sect1"><a href="jit-extensibility.html">32.4. Extensibility</a></span></dt></dl></dd><dt><span class="chapter"><a href="regress.html">33. Regression Tests</a></span></dt><dd><dl><dt><span class="sect1"><a href="regress-run.html">33.1. Running the Tests</a></span></dt><dt><span class="sect1"><a href="regress-evaluation.html">33.2. Test Evaluation</a></span></dt><dt><span class="sect1"><a href="regress-variant.html">33.3. Variant Comparison Files</a></span></dt><dt><span class="sect1"><a href="regress-tap.html">33.4. TAP Tests</a></span></dt><dt><span class="sect1"><a href="regress-coverage.html">33.5. Test Coverage Examination</a></span></dt></dl></dd></dl></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="parallel-safety.html" title="15.4. Parallel Safety">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html" title="PostgreSQL 16.3 Documentation">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="install-binaries.html" title="Chapter 16. Installation from Binaries">Next</a></td></tr><tr><td width="40%" align="left" valign="top">15.4. Parallel Safety </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 16. Installation from Binaries</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/adminpack.html
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.1. adminpack — pgAdmin support toolpack</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions" /><link rel="next" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.1. adminpack — pgAdmin support toolpack</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules and Extensions</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">Next</a></td></tr></table><hr /></div><div class="sect1" id="ADMINPACK"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.1. adminpack — pgAdmin support toolpack <a href="#ADMINPACK" class="id_link">#</a></h2></div></div></div><a id="id-1.11.7.11.2" class="indexterm"></a><p>
|
| 3 |
+
<code class="filename">adminpack</code> provides a number of support functions which
|
| 4 |
+
<span class="application">pgAdmin</span> and other administration and management tools can
|
| 5 |
+
use to provide additional functionality, such as remote management
|
| 6 |
+
of server log files.
|
| 7 |
+
Use of all these functions is only allowed to database superusers by default, but may be
|
| 8 |
+
allowed to other users by using the <code class="command">GRANT</code> command.
|
| 9 |
+
</p><p>
|
| 10 |
+
The functions shown in <a class="xref" href="adminpack.html#FUNCTIONS-ADMINPACK-TABLE" title="Table F.1. adminpack Functions">Table F.1</a> provide
|
| 11 |
+
write access to files on the machine hosting the server. (See also the
|
| 12 |
+
functions in <a class="xref" href="functions-admin.html#FUNCTIONS-ADMIN-GENFILE-TABLE" title="Table 9.101. Generic File Access Functions">Table 9.101</a>, which
|
| 13 |
+
provide read-only access.)
|
| 14 |
+
Only files within the database cluster directory can be accessed, unless the
|
| 15 |
+
user is a superuser or given privileges of one of the
|
| 16 |
+
<code class="literal">pg_read_server_files</code> or
|
| 17 |
+
<code class="literal">pg_write_server_files</code> roles, as appropriate for the
|
| 18 |
+
function, but either a relative or absolute path is allowable.
|
| 19 |
+
</p><div class="table" id="FUNCTIONS-ADMINPACK-TABLE"><p class="title"><strong>Table F.1. <code class="filename">adminpack</code> Functions</strong></p><div class="table-contents"><table class="table" summary="adminpack Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
|
| 20 |
+
Function
|
| 21 |
+
</p>
|
| 22 |
+
<p>
|
| 23 |
+
Description
|
| 24 |
+
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
|
| 25 |
+
<code class="function">pg_catalog.pg_file_write</code> ( <em class="parameter"><code>filename</code></em> <code class="type">text</code>, <em class="parameter"><code>data</code></em> <code class="type">text</code>, <em class="parameter"><code>append</code></em> <code class="type">boolean</code> )
|
| 26 |
+
→ <code class="returnvalue">bigint</code>
|
| 27 |
+
</p>
|
| 28 |
+
<p>
|
| 29 |
+
Writes, or appends to, a text file.
|
| 30 |
+
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
|
| 31 |
+
<code class="function">pg_catalog.pg_file_sync</code> ( <em class="parameter"><code>filename</code></em> <code class="type">text</code> )
|
| 32 |
+
→ <code class="returnvalue">void</code>
|
| 33 |
+
</p>
|
| 34 |
+
<p>
|
| 35 |
+
Flushes a file or directory to disk.
|
| 36 |
+
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
|
| 37 |
+
<code class="function">pg_catalog.pg_file_rename</code> ( <em class="parameter"><code>oldname</code></em> <code class="type">text</code>, <em class="parameter"><code>newname</code></em> <code class="type">text</code> [<span class="optional">, <em class="parameter"><code>archivename</code></em> <code class="type">text</code> </span>] )
|
| 38 |
+
→ <code class="returnvalue">boolean</code>
|
| 39 |
+
</p>
|
| 40 |
+
<p>
|
| 41 |
+
Renames a file.
|
| 42 |
+
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
|
| 43 |
+
<code class="function">pg_catalog.pg_file_unlink</code> ( <em class="parameter"><code>filename</code></em> <code class="type">text</code> )
|
| 44 |
+
→ <code class="returnvalue">boolean</code>
|
| 45 |
+
</p>
|
| 46 |
+
<p>
|
| 47 |
+
Removes a file.
|
| 48 |
+
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
|
| 49 |
+
<code class="function">pg_catalog.pg_logdir_ls</code> ()
|
| 50 |
+
→ <code class="returnvalue">setof record</code>
|
| 51 |
+
</p>
|
| 52 |
+
<p>
|
| 53 |
+
Lists the log files in the <code class="varname">log_directory</code> directory.
|
| 54 |
+
</p></td></tr></tbody></table></div></div><br class="table-break" /><a id="id-1.11.7.11.6" class="indexterm"></a><p>
|
| 55 |
+
<code class="function">pg_file_write</code> writes the specified <em class="parameter"><code>data</code></em> into
|
| 56 |
+
the file named by <em class="parameter"><code>filename</code></em>. If <em class="parameter"><code>append</code></em> is
|
| 57 |
+
false, the file must not already exist. If <em class="parameter"><code>append</code></em> is true,
|
| 58 |
+
the file can already exist, and will be appended to if so.
|
| 59 |
+
Returns the number of bytes written.
|
| 60 |
+
</p><a id="id-1.11.7.11.8" class="indexterm"></a><p>
|
| 61 |
+
<code class="function">pg_file_sync</code> fsyncs the specified file or directory
|
| 62 |
+
named by <em class="parameter"><code>filename</code></em>. An error is thrown
|
| 63 |
+
on failure (e.g., the specified file is not present). Note that
|
| 64 |
+
<a class="xref" href="runtime-config-error-handling.html#GUC-DATA-SYNC-RETRY">data_sync_retry</a> has no effect on this function,
|
| 65 |
+
and therefore a PANIC-level error will not be raised even on failure to
|
| 66 |
+
flush database files.
|
| 67 |
+
</p><a id="id-1.11.7.11.10" class="indexterm"></a><p>
|
| 68 |
+
<code class="function">pg_file_rename</code> renames a file. If <em class="parameter"><code>archivename</code></em>
|
| 69 |
+
is omitted or NULL, it simply renames <em class="parameter"><code>oldname</code></em>
|
| 70 |
+
to <em class="parameter"><code>newname</code></em> (which must not already exist).
|
| 71 |
+
If <em class="parameter"><code>archivename</code></em> is provided, it first
|
| 72 |
+
renames <em class="parameter"><code>newname</code></em> to <em class="parameter"><code>archivename</code></em> (which must
|
| 73 |
+
not already exist), and then renames <em class="parameter"><code>oldname</code></em>
|
| 74 |
+
to <em class="parameter"><code>newname</code></em>. In event of failure of the second rename step,
|
| 75 |
+
it will try to rename <em class="parameter"><code>archivename</code></em> back
|
| 76 |
+
to <em class="parameter"><code>newname</code></em> before reporting the error.
|
| 77 |
+
Returns true on success, false if the source file(s) are not present or
|
| 78 |
+
not writable; other cases throw errors.
|
| 79 |
+
</p><a id="id-1.11.7.11.12" class="indexterm"></a><p>
|
| 80 |
+
<code class="function">pg_file_unlink</code> removes the specified file.
|
| 81 |
+
Returns true on success, false if the specified file is not present
|
| 82 |
+
or the <code class="function">unlink()</code> call fails; other cases throw errors.
|
| 83 |
+
</p><a id="id-1.11.7.11.14" class="indexterm"></a><p>
|
| 84 |
+
<code class="function">pg_logdir_ls</code> returns the start timestamps and path
|
| 85 |
+
names of all the log files in the <a class="xref" href="runtime-config-logging.html#GUC-LOG-DIRECTORY">log_directory</a>
|
| 86 |
+
directory. The <a class="xref" href="runtime-config-logging.html#GUC-LOG-FILENAME">log_filename</a> parameter must have its
|
| 87 |
+
default setting (<code class="literal">postgresql-%Y-%m-%d_%H%M%S.log</code>) to use this
|
| 88 |
+
function.
|
| 89 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix F. Additional Supplied Modules and Extensions </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.2. amcheck — tools to verify table and index consistency</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/amcheck.html
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.2. amcheck — tools to verify table and index consistency</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="adminpack.html" title="F.1. adminpack — pgAdmin support toolpack" /><link rel="next" href="auth-delay.html" title="F.3. auth_delay — pause on authentication failure" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.2. amcheck — tools to verify table and index consistency</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="adminpack.html" title="F.1. adminpack — pgAdmin support toolpack">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules and Extensions</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="auth-delay.html" title="F.3. auth_delay — pause on authentication failure">Next</a></td></tr></table><hr /></div><div class="sect1" id="AMCHECK"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.2. amcheck — tools to verify table and index consistency <a href="#AMCHECK" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="amcheck.html#AMCHECK-FUNCTIONS">F.2.1. Functions</a></span></dt><dt><span class="sect2"><a href="amcheck.html#AMCHECK-OPTIONAL-HEAPALLINDEXED-VERIFICATION">F.2.2. Optional <em class="parameter"><code>heapallindexed</code></em> Verification</a></span></dt><dt><span class="sect2"><a href="amcheck.html#AMCHECK-USING-AMCHECK-EFFECTIVELY">F.2.3. Using <code class="filename">amcheck</code> Effectively</a></span></dt><dt><span class="sect2"><a href="amcheck.html#AMCHECK-REPAIRING-CORRUPTION">F.2.4. Repairing Corruption</a></span></dt></dl></div><a id="id-1.11.7.12.2" class="indexterm"></a><p>
|
| 3 |
+
The <code class="filename">amcheck</code> module provides functions that allow you to
|
| 4 |
+
verify the logical consistency of the structure of relations.
|
| 5 |
+
</p><p>
|
| 6 |
+
The B-Tree checking functions verify various <span class="emphasis"><em>invariants</em></span> in the
|
| 7 |
+
structure of the representation of particular relations. The
|
| 8 |
+
correctness of the access method functions behind index scans and
|
| 9 |
+
other important operations relies on these invariants always
|
| 10 |
+
holding. For example, certain functions verify, among other things,
|
| 11 |
+
that all B-Tree pages have items in <span class="quote">“<span class="quote">logical</span>”</span> order (e.g.,
|
| 12 |
+
for B-Tree indexes on <code class="type">text</code>, index tuples should be in
|
| 13 |
+
collated lexical order). If that particular invariant somehow fails
|
| 14 |
+
to hold, we can expect binary searches on the affected page to
|
| 15 |
+
incorrectly guide index scans, resulting in wrong answers to SQL
|
| 16 |
+
queries. If the structure appears to be valid, no error is raised.
|
| 17 |
+
</p><p>
|
| 18 |
+
Verification is performed using the same procedures as those used by
|
| 19 |
+
index scans themselves, which may be user-defined operator class
|
| 20 |
+
code. For example, B-Tree index verification relies on comparisons
|
| 21 |
+
made with one or more B-Tree support function 1 routines. See <a class="xref" href="xindex.html#XINDEX-SUPPORT" title="38.16.3. Index Method Support Routines">Section 38.16.3</a> for details of operator class support
|
| 22 |
+
functions.
|
| 23 |
+
</p><p>
|
| 24 |
+
Unlike the B-Tree checking functions which report corruption by raising
|
| 25 |
+
errors, the heap checking function <code class="function">verify_heapam</code> checks
|
| 26 |
+
a table and attempts to return a set of rows, one row per corruption
|
| 27 |
+
detected. Despite this, if facilities that
|
| 28 |
+
<code class="function">verify_heapam</code> relies upon are themselves corrupted, the
|
| 29 |
+
function may be unable to continue and may instead raise an error.
|
| 30 |
+
</p><p>
|
| 31 |
+
Permission to execute <code class="filename">amcheck</code> functions may be granted
|
| 32 |
+
to non-superusers, but before granting such permissions careful consideration
|
| 33 |
+
should be given to data security and privacy concerns. Although the
|
| 34 |
+
corruption reports generated by these functions do not focus on the contents
|
| 35 |
+
of the corrupted data so much as on the structure of that data and the nature
|
| 36 |
+
of the corruptions found, an attacker who gains permission to execute these
|
| 37 |
+
functions, particularly if the attacker can also induce corruption, might be
|
| 38 |
+
able to infer something of the data itself from such messages.
|
| 39 |
+
</p><div class="sect2" id="AMCHECK-FUNCTIONS"><div class="titlepage"><div><div><h3 class="title">F.2.1. Functions <a href="#AMCHECK-FUNCTIONS" class="id_link">#</a></h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">
|
| 40 |
+
<code class="function">bt_index_check(index regclass, heapallindexed boolean) returns void</code>
|
| 41 |
+
<a id="id-1.11.7.12.8.2.1.1.2" class="indexterm"></a>
|
| 42 |
+
</span></dt><dd><p>
|
| 43 |
+
<code class="function">bt_index_check</code> tests that its target, a
|
| 44 |
+
B-Tree index, respects a variety of invariants. Example usage:
|
| 45 |
+
</p><pre class="screen">
|
| 46 |
+
test=# SELECT bt_index_check(index => c.oid, heapallindexed => i.indisunique),
|
| 47 |
+
c.relname,
|
| 48 |
+
c.relpages
|
| 49 |
+
FROM pg_index i
|
| 50 |
+
JOIN pg_opclass op ON i.indclass[0] = op.oid
|
| 51 |
+
JOIN pg_am am ON op.opcmethod = am.oid
|
| 52 |
+
JOIN pg_class c ON i.indexrelid = c.oid
|
| 53 |
+
JOIN pg_namespace n ON c.relnamespace = n.oid
|
| 54 |
+
WHERE am.amname = 'btree' AND n.nspname = 'pg_catalog'
|
| 55 |
+
-- Don't check temp tables, which may be from another session:
|
| 56 |
+
AND c.relpersistence != 't'
|
| 57 |
+
-- Function may throw an error when this is omitted:
|
| 58 |
+
AND c.relkind = 'i' AND i.indisready AND i.indisvalid
|
| 59 |
+
ORDER BY c.relpages DESC LIMIT 10;
|
| 60 |
+
bt_index_check | relname | relpages
|
| 61 |
+
----------------+---------------------------------+----------
|
| 62 |
+
| pg_depend_reference_index | 43
|
| 63 |
+
| pg_depend_depender_index | 40
|
| 64 |
+
| pg_proc_proname_args_nsp_index | 31
|
| 65 |
+
| pg_description_o_c_o_index | 21
|
| 66 |
+
| pg_attribute_relid_attnam_index | 14
|
| 67 |
+
| pg_proc_oid_index | 10
|
| 68 |
+
| pg_attribute_relid_attnum_index | 9
|
| 69 |
+
| pg_amproc_fam_proc_index | 5
|
| 70 |
+
| pg_amop_opr_fam_index | 5
|
| 71 |
+
| pg_amop_fam_strat_index | 5
|
| 72 |
+
(10 rows)
|
| 73 |
+
</pre><p>
|
| 74 |
+
This example shows a session that performs verification of the
|
| 75 |
+
10 largest catalog indexes in the database <span class="quote">“<span class="quote">test</span>”</span>.
|
| 76 |
+
Verification of the presence of heap tuples as index tuples is
|
| 77 |
+
requested for the subset that are unique indexes. Since no
|
| 78 |
+
error is raised, all indexes tested appear to be logically
|
| 79 |
+
consistent. Naturally, this query could easily be changed to
|
| 80 |
+
call <code class="function">bt_index_check</code> for every index in the
|
| 81 |
+
database where verification is supported.
|
| 82 |
+
</p><p>
|
| 83 |
+
<code class="function">bt_index_check</code> acquires an <code class="literal">AccessShareLock</code>
|
| 84 |
+
on the target index and the heap relation it belongs to. This lock mode
|
| 85 |
+
is the same lock mode acquired on relations by simple
|
| 86 |
+
<code class="literal">SELECT</code> statements.
|
| 87 |
+
<code class="function">bt_index_check</code> does not verify invariants
|
| 88 |
+
that span child/parent relationships, but will verify the
|
| 89 |
+
presence of all heap tuples as index tuples within the index
|
| 90 |
+
when <em class="parameter"><code>heapallindexed</code></em> is
|
| 91 |
+
<code class="literal">true</code>. When a routine, lightweight test for
|
| 92 |
+
corruption is required in a live production environment, using
|
| 93 |
+
<code class="function">bt_index_check</code> often provides the best
|
| 94 |
+
trade-off between thoroughness of verification and limiting the
|
| 95 |
+
impact on application performance and availability.
|
| 96 |
+
</p></dd><dt><span class="term">
|
| 97 |
+
<code class="function">bt_index_parent_check(index regclass, heapallindexed boolean, rootdescend boolean) returns void</code>
|
| 98 |
+
<a id="id-1.11.7.12.8.2.2.1.2" class="indexterm"></a>
|
| 99 |
+
</span></dt><dd><p>
|
| 100 |
+
<code class="function">bt_index_parent_check</code> tests that its
|
| 101 |
+
target, a B-Tree index, respects a variety of invariants.
|
| 102 |
+
Optionally, when the <em class="parameter"><code>heapallindexed</code></em>
|
| 103 |
+
argument is <code class="literal">true</code>, the function verifies the
|
| 104 |
+
presence of all heap tuples that should be found within the
|
| 105 |
+
index. When the optional <em class="parameter"><code>rootdescend</code></em>
|
| 106 |
+
argument is <code class="literal">true</code>, verification re-finds
|
| 107 |
+
tuples on the leaf level by performing a new search from the
|
| 108 |
+
root page for each tuple. The checks that can be performed by
|
| 109 |
+
<code class="function">bt_index_parent_check</code> are a superset of the
|
| 110 |
+
checks that can be performed by <code class="function">bt_index_check</code>.
|
| 111 |
+
<code class="function">bt_index_parent_check</code> can be thought of as
|
| 112 |
+
a more thorough variant of <code class="function">bt_index_check</code>:
|
| 113 |
+
unlike <code class="function">bt_index_check</code>,
|
| 114 |
+
<code class="function">bt_index_parent_check</code> also checks
|
| 115 |
+
invariants that span parent/child relationships, including checking
|
| 116 |
+
that there are no missing downlinks in the index structure.
|
| 117 |
+
<code class="function">bt_index_parent_check</code> follows the general
|
| 118 |
+
convention of raising an error if it finds a logical
|
| 119 |
+
inconsistency or other problem.
|
| 120 |
+
</p><p>
|
| 121 |
+
A <code class="literal">ShareLock</code> is required on the target index by
|
| 122 |
+
<code class="function">bt_index_parent_check</code> (a
|
| 123 |
+
<code class="literal">ShareLock</code> is also acquired on the heap relation).
|
| 124 |
+
These locks prevent concurrent data modification from
|
| 125 |
+
<code class="command">INSERT</code>, <code class="command">UPDATE</code>, and <code class="command">DELETE</code>
|
| 126 |
+
commands. The locks also prevent the underlying relation from
|
| 127 |
+
being concurrently processed by <code class="command">VACUUM</code>, as well as
|
| 128 |
+
all other utility commands. Note that the function holds locks
|
| 129 |
+
only while running, not for the entire transaction.
|
| 130 |
+
</p><p>
|
| 131 |
+
<code class="function">bt_index_parent_check</code>'s additional
|
| 132 |
+
verification is more likely to detect various pathological
|
| 133 |
+
cases. These cases may involve an incorrectly implemented
|
| 134 |
+
B-Tree operator class used by the index that is checked, or,
|
| 135 |
+
hypothetically, undiscovered bugs in the underlying B-Tree index
|
| 136 |
+
access method code. Note that
|
| 137 |
+
<code class="function">bt_index_parent_check</code> cannot be used when
|
| 138 |
+
hot standby mode is enabled (i.e., on read-only physical
|
| 139 |
+
replicas), unlike <code class="function">bt_index_check</code>.
|
| 140 |
+
</p></dd></dl></div><div class="tip"><h3 class="title">Tip</h3><p>
|
| 141 |
+
<code class="function">bt_index_check</code> and
|
| 142 |
+
<code class="function">bt_index_parent_check</code> both output log
|
| 143 |
+
messages about the verification process at
|
| 144 |
+
<code class="literal">DEBUG1</code> and <code class="literal">DEBUG2</code> severity
|
| 145 |
+
levels. These messages provide detailed information about the
|
| 146 |
+
verification process that may be of interest to
|
| 147 |
+
<span class="productname">PostgreSQL</span> developers. Advanced users
|
| 148 |
+
may also find this information helpful, since it provides
|
| 149 |
+
additional context should verification actually detect an
|
| 150 |
+
inconsistency. Running:
|
| 151 |
+
</p><pre class="programlisting">
|
| 152 |
+
SET client_min_messages = DEBUG1;
|
| 153 |
+
</pre><p>
|
| 154 |
+
in an interactive <span class="application">psql</span> session before
|
| 155 |
+
running a verification query will display messages about the
|
| 156 |
+
progress of verification with a manageable level of detail.
|
| 157 |
+
</p></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">
|
| 158 |
+
<code class="function">
|
| 159 |
+
verify_heapam(relation regclass,
|
| 160 |
+
on_error_stop boolean,
|
| 161 |
+
check_toast boolean,
|
| 162 |
+
skip text,
|
| 163 |
+
startblock bigint,
|
| 164 |
+
endblock bigint,
|
| 165 |
+
blkno OUT bigint,
|
| 166 |
+
offnum OUT integer,
|
| 167 |
+
attnum OUT integer,
|
| 168 |
+
msg OUT text)
|
| 169 |
+
returns setof record
|
| 170 |
+
</code>
|
| 171 |
+
</span></dt><dd><p>
|
| 172 |
+
Checks a table, sequence, or materialized view for structural corruption,
|
| 173 |
+
where pages in the relation contain data that is invalidly formatted, and
|
| 174 |
+
for logical corruption, where pages are structurally valid but
|
| 175 |
+
inconsistent with the rest of the database cluster.
|
| 176 |
+
</p><p>
|
| 177 |
+
The following optional arguments are recognized:
|
| 178 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">on_error_stop</code></span></dt><dd><p>
|
| 179 |
+
If true, corruption checking stops at the end of the first block in
|
| 180 |
+
which any corruptions are found.
|
| 181 |
+
</p><p>
|
| 182 |
+
Defaults to false.
|
| 183 |
+
</p></dd><dt><span class="term"><code class="literal">check_toast</code></span></dt><dd><p>
|
| 184 |
+
If true, toasted values are checked against the target relation's
|
| 185 |
+
TOAST table.
|
| 186 |
+
</p><p>
|
| 187 |
+
This option is known to be slow. Also, if the toast table or its
|
| 188 |
+
index is corrupt, checking it against toast values could conceivably
|
| 189 |
+
crash the server, although in many cases this would just produce an
|
| 190 |
+
error.
|
| 191 |
+
</p><p>
|
| 192 |
+
Defaults to false.
|
| 193 |
+
</p></dd><dt><span class="term"><code class="literal">skip</code></span></dt><dd><p>
|
| 194 |
+
If not <code class="literal">none</code>, corruption checking skips blocks that
|
| 195 |
+
are marked as all-visible or all-frozen, as specified.
|
| 196 |
+
Valid options are <code class="literal">all-visible</code>,
|
| 197 |
+
<code class="literal">all-frozen</code> and <code class="literal">none</code>.
|
| 198 |
+
</p><p>
|
| 199 |
+
Defaults to <code class="literal">none</code>.
|
| 200 |
+
</p></dd><dt><span class="term"><code class="literal">startblock</code></span></dt><dd><p>
|
| 201 |
+
If specified, corruption checking begins at the specified block,
|
| 202 |
+
skipping all previous blocks. It is an error to specify a
|
| 203 |
+
<em class="parameter"><code>startblock</code></em> outside the range of blocks in the
|
| 204 |
+
target table.
|
| 205 |
+
</p><p>
|
| 206 |
+
By default, checking begins at the first block.
|
| 207 |
+
</p></dd><dt><span class="term"><code class="literal">endblock</code></span></dt><dd><p>
|
| 208 |
+
If specified, corruption checking ends at the specified block,
|
| 209 |
+
skipping all remaining blocks. It is an error to specify an
|
| 210 |
+
<em class="parameter"><code>endblock</code></em> outside the range of blocks in the target
|
| 211 |
+
table.
|
| 212 |
+
</p><p>
|
| 213 |
+
By default, all blocks are checked.
|
| 214 |
+
</p></dd></dl></div><p>
|
| 215 |
+
For each corruption detected, <code class="function">verify_heapam</code> returns
|
| 216 |
+
a row with the following columns:
|
| 217 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">blkno</code></span></dt><dd><p>
|
| 218 |
+
The number of the block containing the corrupt page.
|
| 219 |
+
</p></dd><dt><span class="term"><code class="literal">offnum</code></span></dt><dd><p>
|
| 220 |
+
The OffsetNumber of the corrupt tuple.
|
| 221 |
+
</p></dd><dt><span class="term"><code class="literal">attnum</code></span></dt><dd><p>
|
| 222 |
+
The attribute number of the corrupt column in the tuple, if the
|
| 223 |
+
corruption is specific to a column and not the tuple as a whole.
|
| 224 |
+
</p></dd><dt><span class="term"><code class="literal">msg</code></span></dt><dd><p>
|
| 225 |
+
A message describing the problem detected.
|
| 226 |
+
</p></dd></dl></div></dd></dl></div></div><div class="sect2" id="AMCHECK-OPTIONAL-HEAPALLINDEXED-VERIFICATION"><div class="titlepage"><div><div><h3 class="title">F.2.2. Optional <em class="parameter"><code>heapallindexed</code></em> Verification <a href="#AMCHECK-OPTIONAL-HEAPALLINDEXED-VERIFICATION" class="id_link">#</a></h3></div></div></div><p>
|
| 227 |
+
When the <em class="parameter"><code>heapallindexed</code></em> argument to B-Tree
|
| 228 |
+
verification functions is <code class="literal">true</code>, an additional
|
| 229 |
+
phase of verification is performed against the table associated with
|
| 230 |
+
the target index relation. This consists of a <span class="quote">“<span class="quote">dummy</span>”</span>
|
| 231 |
+
<code class="command">CREATE INDEX</code> operation, which checks for the
|
| 232 |
+
presence of all hypothetical new index tuples against a temporary,
|
| 233 |
+
in-memory summarizing structure (this is built when needed during
|
| 234 |
+
the basic first phase of verification). The summarizing structure
|
| 235 |
+
<span class="quote">“<span class="quote">fingerprints</span>”</span> every tuple found within the target
|
| 236 |
+
index. The high level principle behind
|
| 237 |
+
<em class="parameter"><code>heapallindexed</code></em> verification is that a new
|
| 238 |
+
index that is equivalent to the existing, target index must only
|
| 239 |
+
have entries that can be found in the existing structure.
|
| 240 |
+
</p><p>
|
| 241 |
+
The additional <em class="parameter"><code>heapallindexed</code></em> phase adds
|
| 242 |
+
significant overhead: verification will typically take several times
|
| 243 |
+
longer. However, there is no change to the relation-level locks
|
| 244 |
+
acquired when <em class="parameter"><code>heapallindexed</code></em> verification is
|
| 245 |
+
performed.
|
| 246 |
+
</p><p>
|
| 247 |
+
The summarizing structure is bound in size by
|
| 248 |
+
<code class="varname">maintenance_work_mem</code>. In order to ensure that
|
| 249 |
+
there is no more than a 2% probability of failure to detect an
|
| 250 |
+
inconsistency for each heap tuple that should be represented in the
|
| 251 |
+
index, approximately 2 bytes of memory are needed per tuple. As
|
| 252 |
+
less memory is made available per tuple, the probability of missing
|
| 253 |
+
an inconsistency slowly increases. This approach limits the
|
| 254 |
+
overhead of verification significantly, while only slightly reducing
|
| 255 |
+
the probability of detecting a problem, especially for installations
|
| 256 |
+
where verification is treated as a routine maintenance task. Any
|
| 257 |
+
single absent or malformed tuple has a new opportunity to be
|
| 258 |
+
detected with each new verification attempt.
|
| 259 |
+
</p></div><div class="sect2" id="AMCHECK-USING-AMCHECK-EFFECTIVELY"><div class="titlepage"><div><div><h3 class="title">F.2.3. Using <code class="filename">amcheck</code> Effectively <a href="#AMCHECK-USING-AMCHECK-EFFECTIVELY" class="id_link">#</a></h3></div></div></div><p>
|
| 260 |
+
<code class="filename">amcheck</code> can be effective at detecting various types of
|
| 261 |
+
failure modes that <a class="link" href="app-initdb.html#APP-INITDB-DATA-CHECKSUMS"><span class="application">data
|
| 262 |
+
checksums</span></a> will fail to catch. These include:
|
| 263 |
+
|
| 264 |
+
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
| 265 |
+
Structural inconsistencies caused by incorrect operator class
|
| 266 |
+
implementations.
|
| 267 |
+
</p><p>
|
| 268 |
+
This includes issues caused by the comparison rules of operating
|
| 269 |
+
system collations changing. Comparisons of datums of a collatable
|
| 270 |
+
type like <code class="type">text</code> must be immutable (just as all
|
| 271 |
+
comparisons used for B-Tree index scans must be immutable), which
|
| 272 |
+
implies that operating system collation rules must never change.
|
| 273 |
+
Though rare, updates to operating system collation rules can
|
| 274 |
+
cause these issues. More commonly, an inconsistency in the
|
| 275 |
+
collation order between a primary server and a standby server is
|
| 276 |
+
implicated, possibly because the <span class="emphasis"><em>major</em></span> operating
|
| 277 |
+
system version in use is inconsistent. Such inconsistencies will
|
| 278 |
+
generally only arise on standby servers, and so can generally
|
| 279 |
+
only be detected on standby servers.
|
| 280 |
+
</p><p>
|
| 281 |
+
If a problem like this arises, it may not affect each individual
|
| 282 |
+
index that is ordered using an affected collation, simply because
|
| 283 |
+
<span class="emphasis"><em>indexed</em></span> values might happen to have the same
|
| 284 |
+
absolute ordering regardless of the behavioral inconsistency. See
|
| 285 |
+
<a class="xref" href="locale.html" title="24.1. Locale Support">Section 24.1</a> and <a class="xref" href="collation.html" title="24.2. Collation Support">Section 24.2</a> for
|
| 286 |
+
further details about how <span class="productname">PostgreSQL</span> uses
|
| 287 |
+
operating system locales and collations.
|
| 288 |
+
</p></li><li class="listitem"><p>
|
| 289 |
+
Structural inconsistencies between indexes and the heap relations
|
| 290 |
+
that are indexed (when <em class="parameter"><code>heapallindexed</code></em>
|
| 291 |
+
verification is performed).
|
| 292 |
+
</p><p>
|
| 293 |
+
There is no cross-checking of indexes against their heap relation
|
| 294 |
+
during normal operation. Symptoms of heap corruption can be subtle.
|
| 295 |
+
</p></li><li class="listitem"><p>
|
| 296 |
+
Corruption caused by hypothetical undiscovered bugs in the
|
| 297 |
+
underlying <span class="productname">PostgreSQL</span> access method
|
| 298 |
+
code, sort code, or transaction management code.
|
| 299 |
+
</p><p>
|
| 300 |
+
Automatic verification of the structural integrity of indexes
|
| 301 |
+
plays a role in the general testing of new or proposed
|
| 302 |
+
<span class="productname">PostgreSQL</span> features that could plausibly allow a
|
| 303 |
+
logical inconsistency to be introduced. Verification of table
|
| 304 |
+
structure and associated visibility and transaction status
|
| 305 |
+
information plays a similar role. One obvious testing strategy
|
| 306 |
+
is to call <code class="filename">amcheck</code> functions continuously
|
| 307 |
+
when running the standard regression tests. See <a class="xref" href="regress-run.html" title="33.1. Running the Tests">Section 33.1</a> for details on running the tests.
|
| 308 |
+
</p></li><li class="listitem"><p>
|
| 309 |
+
File system or storage subsystem faults where checksums happen to
|
| 310 |
+
simply not be enabled.
|
| 311 |
+
</p><p>
|
| 312 |
+
Note that <code class="filename">amcheck</code> examines a page as represented in some
|
| 313 |
+
shared memory buffer at the time of verification if there is only a
|
| 314 |
+
shared buffer hit when accessing the block. Consequently,
|
| 315 |
+
<code class="filename">amcheck</code> does not necessarily examine data read from the
|
| 316 |
+
file system at the time of verification. Note that when checksums are
|
| 317 |
+
enabled, <code class="filename">amcheck</code> may raise an error due to a checksum
|
| 318 |
+
failure when a corrupt block is read into a buffer.
|
| 319 |
+
</p></li><li class="listitem"><p>
|
| 320 |
+
Corruption caused by faulty RAM, or the broader memory subsystem.
|
| 321 |
+
</p><p>
|
| 322 |
+
<span class="productname">PostgreSQL</span> does not protect against correctable
|
| 323 |
+
memory errors and it is assumed you will operate using RAM that
|
| 324 |
+
uses industry standard Error Correcting Codes (ECC) or better
|
| 325 |
+
protection. However, ECC memory is typically only immune to
|
| 326 |
+
single-bit errors, and should not be assumed to provide
|
| 327 |
+
<span class="emphasis"><em>absolute</em></span> protection against failures that
|
| 328 |
+
result in memory corruption.
|
| 329 |
+
</p><p>
|
| 330 |
+
When <em class="parameter"><code>heapallindexed</code></em> verification is
|
| 331 |
+
performed, there is generally a greatly increased chance of
|
| 332 |
+
detecting single-bit errors, since strict binary equality is
|
| 333 |
+
tested, and the indexed attributes within the heap are tested.
|
| 334 |
+
</p></li></ul></div><p>
|
| 335 |
+
</p><p>
|
| 336 |
+
Structural corruption can happen due to faulty storage hardware, or
|
| 337 |
+
relation files being overwritten or modified by unrelated software.
|
| 338 |
+
This kind of corruption can also be detected with
|
| 339 |
+
<a class="link" href="checksums.html" title="30.2. Data Checksums"><span class="application">data page
|
| 340 |
+
checksums</span></a>.
|
| 341 |
+
</p><p>
|
| 342 |
+
Relation pages which are correctly formatted, internally consistent, and
|
| 343 |
+
correct relative to their own internal checksums may still contain
|
| 344 |
+
logical corruption. As such, this kind of corruption cannot be detected
|
| 345 |
+
with <span class="application">checksums</span>. Examples include toasted
|
| 346 |
+
values in the main table which lack a corresponding entry in the toast
|
| 347 |
+
table, and tuples in the main table with a Transaction ID that is older
|
| 348 |
+
than the oldest valid Transaction ID in the database or cluster.
|
| 349 |
+
</p><p>
|
| 350 |
+
Multiple causes of logical corruption have been observed in production
|
| 351 |
+
systems, including bugs in the <span class="productname">PostgreSQL</span>
|
| 352 |
+
server software, faulty and ill-conceived backup and restore tools, and
|
| 353 |
+
user error.
|
| 354 |
+
</p><p>
|
| 355 |
+
Corrupt relations are most concerning in live production environments,
|
| 356 |
+
precisely the same environments where high risk activities are least
|
| 357 |
+
welcome. For this reason, <code class="function">verify_heapam</code> has been
|
| 358 |
+
designed to diagnose corruption without undue risk. It cannot guard
|
| 359 |
+
against all causes of backend crashes, as even executing the calling
|
| 360 |
+
query could be unsafe on a badly corrupted system. Access to <a class="link" href="catalogs-overview.html" title="53.1. Overview">catalog tables</a> is performed and could
|
| 361 |
+
be problematic if the catalogs themselves are corrupted.
|
| 362 |
+
</p><p>
|
| 363 |
+
In general, <code class="filename">amcheck</code> can only prove the presence of
|
| 364 |
+
corruption; it cannot prove its absence.
|
| 365 |
+
</p></div><div class="sect2" id="AMCHECK-REPAIRING-CORRUPTION"><div class="titlepage"><div><div><h3 class="title">F.2.4. Repairing Corruption <a href="#AMCHECK-REPAIRING-CORRUPTION" class="id_link">#</a></h3></div></div></div><p>
|
| 366 |
+
No error concerning corruption raised by <code class="filename">amcheck</code> should
|
| 367 |
+
ever be a false positive. <code class="filename">amcheck</code> raises
|
| 368 |
+
errors in the event of conditions that, by definition, should never
|
| 369 |
+
happen, and so careful analysis of <code class="filename">amcheck</code>
|
| 370 |
+
errors is often required.
|
| 371 |
+
</p><p>
|
| 372 |
+
There is no general method of repairing problems that
|
| 373 |
+
<code class="filename">amcheck</code> detects. An explanation for the root cause of
|
| 374 |
+
an invariant violation should be sought. <a class="xref" href="pageinspect.html" title="F.25. pageinspect — low-level inspection of database pages">pageinspect</a> may play a useful role in diagnosing
|
| 375 |
+
corruption that <code class="filename">amcheck</code> detects. A <code class="command">REINDEX</code>
|
| 376 |
+
may not be effective in repairing corruption.
|
| 377 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="adminpack.html" title="F.1. adminpack — pgAdmin support toolpack">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="auth-delay.html" title="F.3. auth_delay — pause on authentication failure">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.1. adminpack — pgAdmin support toolpack </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.3. auth_delay — pause on authentication failure</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-clusterdb.html
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>clusterdb</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="reference-client.html" title="PostgreSQL Client Applications" /><link rel="next" href="app-createdb.html" title="createdb" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">clusterdb</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="reference-client.html" title="PostgreSQL Client Applications">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-createdb.html" title="createdb">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-CLUSTERDB"><div class="titlepage"></div><a id="id-1.9.4.3.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">clusterdb</span></span></h2><p>clusterdb — cluster a <span class="productname">PostgreSQL</span> database</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.3.4.1"><code class="command">clusterdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [ <code class="option">--verbose</code> | <code class="option">-v</code> ]
|
| 3 |
+
[
|
| 4 |
+
<code class="option">--table</code> | <code class="option">-t</code>
|
| 5 |
+
<em class="replaceable"><code>table</code></em>
|
| 6 |
+
]
|
| 7 |
+
... [<em class="replaceable"><code>dbname</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.4.3.4.2"><code class="command">clusterdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [ <code class="option">--verbose</code> | <code class="option">-v</code> ] <code class="option">--all</code> | <code class="option">-a</code> </p></div></div><div class="refsect1" id="id-1.9.4.3.5"><h2>Description</h2><p>
|
| 8 |
+
<span class="application">clusterdb</span> is a utility for reclustering tables
|
| 9 |
+
in a <span class="productname">PostgreSQL</span> database. It finds tables
|
| 10 |
+
that have previously been clustered, and clusters them again on the same
|
| 11 |
+
index that was last used. Tables that have never been clustered are not
|
| 12 |
+
affected.
|
| 13 |
+
</p><p>
|
| 14 |
+
<span class="application">clusterdb</span> is a wrapper around the SQL
|
| 15 |
+
command <a class="xref" href="sql-cluster.html" title="CLUSTER"><span class="refentrytitle">CLUSTER</span></a>.
|
| 16 |
+
There is no effective difference between clustering databases via
|
| 17 |
+
this utility and via other methods for accessing the server.
|
| 18 |
+
</p></div><div class="refsect1" id="id-1.9.4.3.6"><h2>Options</h2><p>
|
| 19 |
+
<span class="application">clusterdb</span> accepts the following command-line arguments:
|
| 20 |
+
|
| 21 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--all</code></span></dt><dd><p>
|
| 22 |
+
Cluster all databases.
|
| 23 |
+
</p></dd><dt><span class="term"><code class="option">[<span class="optional">-d</span>] <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">[<span class="optional">--dbname=</span>]<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 24 |
+
Specifies the name of the database to be clustered,
|
| 25 |
+
when <code class="option">-a</code>/<code class="option">--all</code> is not used.
|
| 26 |
+
If this is not specified, the database name is read
|
| 27 |
+
from the environment variable <code class="envar">PGDATABASE</code>. If
|
| 28 |
+
that is not set, the user name specified for the connection is
|
| 29 |
+
used. The <em class="replaceable"><code>dbname</code></em> can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>. If so,
|
| 30 |
+
connection string parameters will override any conflicting command
|
| 31 |
+
line options.
|
| 32 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
|
| 33 |
+
Echo the commands that <span class="application">clusterdb</span> generates
|
| 34 |
+
and sends to the server.
|
| 35 |
+
</p></dd><dt><span class="term"><code class="option">-q</code><br /></span><span class="term"><code class="option">--quiet</code></span></dt><dd><p>
|
| 36 |
+
Do not display progress messages.
|
| 37 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>table</code></em></code><br /></span><span class="term"><code class="option">--table=<em class="replaceable"><code>table</code></em></code></span></dt><dd><p>
|
| 38 |
+
Cluster <em class="replaceable"><code>table</code></em> only.
|
| 39 |
+
Multiple tables can be clustered by writing multiple
|
| 40 |
+
<code class="option">-t</code> switches.
|
| 41 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 42 |
+
Print detailed information during processing.
|
| 43 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 44 |
+
Print the <span class="application">clusterdb</span> version and exit.
|
| 45 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 46 |
+
Show help about <span class="application">clusterdb</span> command line
|
| 47 |
+
arguments, and exit.
|
| 48 |
+
</p></dd></dl></div><p>
|
| 49 |
+
</p><p>
|
| 50 |
+
<span class="application">clusterdb</span> also accepts
|
| 51 |
+
the following command-line arguments for connection parameters:
|
| 52 |
+
|
| 53 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 54 |
+
Specifies the host name of the machine on which the server is
|
| 55 |
+
running. If the value begins with a slash, it is used as the
|
| 56 |
+
directory for the Unix domain socket.
|
| 57 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 58 |
+
Specifies the TCP port or local Unix domain socket file
|
| 59 |
+
extension on which the server
|
| 60 |
+
is listening for connections.
|
| 61 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 62 |
+
User name to connect as.
|
| 63 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 64 |
+
Never issue a password prompt. If the server requires
|
| 65 |
+
password authentication and a password is not available by
|
| 66 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 67 |
+
connection attempt will fail. This option can be useful in
|
| 68 |
+
batch jobs and scripts where no user is present to enter a
|
| 69 |
+
password.
|
| 70 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 71 |
+
Force <span class="application">clusterdb</span> to prompt for a
|
| 72 |
+
password before connecting to a database.
|
| 73 |
+
</p><p>
|
| 74 |
+
This option is never essential, since
|
| 75 |
+
<span class="application">clusterdb</span> will automatically prompt
|
| 76 |
+
for a password if the server demands password authentication.
|
| 77 |
+
However, <span class="application">clusterdb</span> will waste a
|
| 78 |
+
connection attempt finding out that the server wants a password.
|
| 79 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 80 |
+
connection attempt.
|
| 81 |
+
</p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 82 |
+
Specifies the name of the database to connect to to discover which
|
| 83 |
+
databases should be clustered,
|
| 84 |
+
when <code class="option">-a</code>/<code class="option">--all</code> is used.
|
| 85 |
+
If not specified, the <code class="literal">postgres</code> database will be used,
|
| 86 |
+
or if that does not exist, <code class="literal">template1</code> will be used.
|
| 87 |
+
This can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection
|
| 88 |
+
string</a>. If so, connection string parameters will override any
|
| 89 |
+
conflicting command line options. Also, connection string parameters
|
| 90 |
+
other than the database name itself will be re-used when connecting
|
| 91 |
+
to other databases.
|
| 92 |
+
</p></dd></dl></div><p>
|
| 93 |
+
</p></div><div class="refsect1" id="id-1.9.4.3.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATABASE</code><br /></span><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 94 |
+
Default connection parameters
|
| 95 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 96 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 97 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 98 |
+
<code class="literal">never</code>.
|
| 99 |
+
</p></dd></dl></div><p>
|
| 100 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 101 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 102 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 103 |
+
</p></div><div class="refsect1" id="id-1.9.4.3.8"><h2>Diagnostics</h2><p>
|
| 104 |
+
In case of difficulty, see <a class="xref" href="sql-cluster.html" title="CLUSTER"><span class="refentrytitle">CLUSTER</span></a>
|
| 105 |
+
and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for
|
| 106 |
+
discussions of potential problems and error messages.
|
| 107 |
+
The database server must be running at the
|
| 108 |
+
targeted host. Also, any default connection settings and environment
|
| 109 |
+
variables used by the <span class="application">libpq</span> front-end
|
| 110 |
+
library will apply.
|
| 111 |
+
</p></div><div class="refsect1" id="id-1.9.4.3.9"><h2>Examples</h2><p>
|
| 112 |
+
To cluster the database <code class="literal">test</code>:
|
| 113 |
+
</p><pre class="screen">
|
| 114 |
+
<code class="prompt">$ </code><strong class="userinput"><code>clusterdb test</code></strong>
|
| 115 |
+
</pre><p>
|
| 116 |
+
</p><p>
|
| 117 |
+
To cluster a single table
|
| 118 |
+
<code class="literal">foo</code> in a database named
|
| 119 |
+
<code class="literal">xyzzy</code>:
|
| 120 |
+
</p><pre class="screen">
|
| 121 |
+
<code class="prompt">$ </code><strong class="userinput"><code>clusterdb --table=foo xyzzy</code></strong>
|
| 122 |
+
</pre></div><div class="refsect1" id="id-1.9.4.3.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-cluster.html" title="CLUSTER"><span class="refentrytitle">CLUSTER</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="reference-client.html" title="PostgreSQL Client Applications">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-createdb.html" title="createdb">Next</a></td></tr><tr><td width="40%" align="left" valign="top">PostgreSQL Client Applications </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">createdb</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-createdb.html
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>createdb</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-clusterdb.html" title="clusterdb" /><link rel="next" href="app-createuser.html" title="createuser" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">createdb</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-clusterdb.html" title="clusterdb">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-createuser.html" title="createuser">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-CREATEDB"><div class="titlepage"></div><a id="id-1.9.4.4.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">createdb</span></span></h2><p>createdb — create a new <span class="productname">PostgreSQL</span> database</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.4.4.1"><code class="command">createdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>dbname</code></em>
|
| 3 |
+
[<em class="replaceable"><code>description</code></em>]]</p></div></div><div class="refsect1" id="R1-APP-CREATEDB-1"><h2>Description</h2><p>
|
| 4 |
+
<span class="application">createdb</span> creates a new <span class="productname">PostgreSQL</span>
|
| 5 |
+
database.
|
| 6 |
+
</p><p>
|
| 7 |
+
Normally, the database user who executes this command becomes the owner of
|
| 8 |
+
the new database.
|
| 9 |
+
However, a different owner can be specified via the <code class="option">-O</code>
|
| 10 |
+
option, if the executing user has appropriate privileges.
|
| 11 |
+
</p><p>
|
| 12 |
+
<span class="application">createdb</span> is a wrapper around the
|
| 13 |
+
<acronym class="acronym">SQL</acronym> command <a class="link" href="sql-createdatabase.html" title="CREATE DATABASE"><code class="command">CREATE DATABASE</code></a>.
|
| 14 |
+
There is no effective difference between creating databases via
|
| 15 |
+
this utility and via other methods for accessing the server.
|
| 16 |
+
</p></div><div class="refsect1" id="id-1.9.4.4.6"><h2>Options</h2><p>
|
| 17 |
+
<span class="application">createdb</span> accepts the following command-line arguments:
|
| 18 |
+
|
| 19 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>dbname</code></em></span></dt><dd><p>
|
| 20 |
+
Specifies the name of the database to be created. The name must be
|
| 21 |
+
unique among all <span class="productname">PostgreSQL</span> databases in this cluster.
|
| 22 |
+
The default is to create a database with the same name as the
|
| 23 |
+
current system user.
|
| 24 |
+
</p></dd><dt><span class="term"><em class="replaceable"><code>description</code></em></span></dt><dd><p>
|
| 25 |
+
Specifies a comment to be associated with the newly created
|
| 26 |
+
database.
|
| 27 |
+
</p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>tablespace</code></em></code><br /></span><span class="term"><code class="option">--tablespace=<em class="replaceable"><code>tablespace</code></em></code></span></dt><dd><p>
|
| 28 |
+
Specifies the default tablespace for the database. (This name
|
| 29 |
+
is processed as a double-quoted identifier.)
|
| 30 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
|
| 31 |
+
Echo the commands that <span class="application">createdb</span> generates
|
| 32 |
+
and sends to the server.
|
| 33 |
+
</p></dd><dt><span class="term"><code class="option">-E <em class="replaceable"><code>encoding</code></em></code><br /></span><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span></dt><dd><p>
|
| 34 |
+
Specifies the character encoding scheme to be used in this
|
| 35 |
+
database. The character sets supported by the
|
| 36 |
+
<span class="productname">PostgreSQL</span> server are described in
|
| 37 |
+
<a class="xref" href="multibyte.html#MULTIBYTE-CHARSET-SUPPORTED" title="24.3.1. Supported Character Sets">Section 24.3.1</a>.
|
| 38 |
+
</p></dd><dt><span class="term"><code class="option">-l <em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--locale=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
|
| 39 |
+
Specifies the locale to be used in this database. This is equivalent
|
| 40 |
+
to specifying <code class="option">--lc-collate</code>,
|
| 41 |
+
<code class="option">--lc-ctype</code>, and <code class="option">--icu-locale</code> to the
|
| 42 |
+
same value. Some locales are only valid for ICU and must be set with
|
| 43 |
+
<code class="option">--icu-locale</code>.
|
| 44 |
+
</p></dd><dt><span class="term"><code class="option">--lc-collate=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
|
| 45 |
+
Specifies the LC_COLLATE setting to be used in this database.
|
| 46 |
+
</p></dd><dt><span class="term"><code class="option">--lc-ctype=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
|
| 47 |
+
Specifies the LC_CTYPE setting to be used in this database.
|
| 48 |
+
</p></dd><dt><span class="term"><code class="option">--icu-locale=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
|
| 49 |
+
Specifies the ICU locale ID to be used in this database, if the
|
| 50 |
+
ICU locale provider is selected.
|
| 51 |
+
</p></dd><dt><span class="term"><code class="option">--icu-rules=<em class="replaceable"><code>rules</code></em></code></span></dt><dd><p>
|
| 52 |
+
Specifies additional collation rules to customize the behavior of the
|
| 53 |
+
default collation of this database. This is supported for ICU only.
|
| 54 |
+
</p></dd><dt><span class="term"><code class="option">--locale-provider={<code class="literal">libc</code>|<code class="literal">icu</code>}</code></span></dt><dd><p>
|
| 55 |
+
Specifies the locale provider for the database's default collation.
|
| 56 |
+
</p></dd><dt><span class="term"><code class="option">-O <em class="replaceable"><code>owner</code></em></code><br /></span><span class="term"><code class="option">--owner=<em class="replaceable"><code>owner</code></em></code></span></dt><dd><p>
|
| 57 |
+
Specifies the database user who will own the new database.
|
| 58 |
+
(This name is processed as a double-quoted identifier.)
|
| 59 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>strategy</code></em></code><br /></span><span class="term"><code class="option">--strategy=<em class="replaceable"><code>strategy</code></em></code></span></dt><dd><p>
|
| 60 |
+
Specifies the database creation strategy. See
|
| 61 |
+
<a class="xref" href="sql-createdatabase.html#CREATE-DATABASE-STRATEGY">CREATE DATABASE STRATEGY</a> for more details.
|
| 62 |
+
</p></dd><dt><span class="term"><code class="option">-T <em class="replaceable"><code>template</code></em></code><br /></span><span class="term"><code class="option">--template=<em class="replaceable"><code>template</code></em></code></span></dt><dd><p>
|
| 63 |
+
Specifies the template database from which to build this
|
| 64 |
+
database. (This name is processed as a double-quoted identifier.)
|
| 65 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 66 |
+
Print the <span class="application">createdb</span> version and exit.
|
| 67 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 68 |
+
Show help about <span class="application">createdb</span> command line
|
| 69 |
+
arguments, and exit.
|
| 70 |
+
</p></dd></dl></div><p>
|
| 71 |
+
</p><p>
|
| 72 |
+
The options <code class="option">-D</code>, <code class="option">-l</code>, <code class="option">-E</code>,
|
| 73 |
+
<code class="option">-O</code>, and
|
| 74 |
+
<code class="option">-T</code> correspond to options of the underlying
|
| 75 |
+
SQL command <a class="link" href="sql-createdatabase.html" title="CREATE DATABASE"><code class="command">CREATE DATABASE</code></a>; see there for more information
|
| 76 |
+
about them.
|
| 77 |
+
</p><p>
|
| 78 |
+
<span class="application">createdb</span> also accepts the following
|
| 79 |
+
command-line arguments for connection parameters:
|
| 80 |
+
|
| 81 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 82 |
+
Specifies the host name of the machine on which the
|
| 83 |
+
server is running. If the value begins with a slash, it is used
|
| 84 |
+
as the directory for the Unix domain socket.
|
| 85 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 86 |
+
Specifies the TCP port or the local Unix domain socket file
|
| 87 |
+
extension on which the server is listening for connections.
|
| 88 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 89 |
+
User name to connect as.
|
| 90 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 91 |
+
Never issue a password prompt. If the server requires
|
| 92 |
+
password authentication and a password is not available by
|
| 93 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 94 |
+
connection attempt will fail. This option can be useful in
|
| 95 |
+
batch jobs and scripts where no user is present to enter a
|
| 96 |
+
password.
|
| 97 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 98 |
+
Force <span class="application">createdb</span> to prompt for a
|
| 99 |
+
password before connecting to a database.
|
| 100 |
+
</p><p>
|
| 101 |
+
This option is never essential, since
|
| 102 |
+
<span class="application">createdb</span> will automatically prompt
|
| 103 |
+
for a password if the server demands password authentication.
|
| 104 |
+
However, <span class="application">createdb</span> will waste a
|
| 105 |
+
connection attempt finding out that the server wants a password.
|
| 106 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 107 |
+
connection attempt.
|
| 108 |
+
</p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 109 |
+
Specifies the name of the database to connect to when creating the
|
| 110 |
+
new database. If not specified, the <code class="literal">postgres</code>
|
| 111 |
+
database will be used; if that does not exist (or if it is the name
|
| 112 |
+
of the new database being created), <code class="literal">template1</code> will
|
| 113 |
+
be used.
|
| 114 |
+
This can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection
|
| 115 |
+
string</a>. If so, connection string parameters will override any
|
| 116 |
+
conflicting command line options.
|
| 117 |
+
</p></dd></dl></div><p>
|
| 118 |
+
</p></div><div class="refsect1" id="id-1.9.4.4.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATABASE</code></span></dt><dd><p>
|
| 119 |
+
If set, the name of the database to create, unless overridden on
|
| 120 |
+
the command line.
|
| 121 |
+
</p></dd><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 122 |
+
Default connection parameters. <code class="envar">PGUSER</code> also
|
| 123 |
+
determines the name of the database to create, if it is not
|
| 124 |
+
specified on the command line or by <code class="envar">PGDATABASE</code>.
|
| 125 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 126 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 127 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 128 |
+
<code class="literal">never</code>.
|
| 129 |
+
</p></dd></dl></div><p>
|
| 130 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 131 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 132 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 133 |
+
</p></div><div class="refsect1" id="id-1.9.4.4.8"><h2>Diagnostics</h2><p>
|
| 134 |
+
In case of difficulty, see <a class="xref" href="sql-createdatabase.html" title="CREATE DATABASE"><span class="refentrytitle">CREATE DATABASE</span></a>
|
| 135 |
+
and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for
|
| 136 |
+
discussions of potential problems and error messages.
|
| 137 |
+
The database server must be running at the
|
| 138 |
+
targeted host. Also, any default connection settings and environment
|
| 139 |
+
variables used by the <span class="application">libpq</span> front-end
|
| 140 |
+
library will apply.
|
| 141 |
+
</p></div><div class="refsect1" id="id-1.9.4.4.9"><h2>Examples</h2><p>
|
| 142 |
+
To create the database <code class="literal">demo</code> using the default
|
| 143 |
+
database server:
|
| 144 |
+
</p><pre class="screen">
|
| 145 |
+
<code class="prompt">$ </code><strong class="userinput"><code>createdb demo</code></strong>
|
| 146 |
+
</pre><p>
|
| 147 |
+
</p><p>
|
| 148 |
+
To create the database <code class="literal">demo</code> using the
|
| 149 |
+
server on host <code class="literal">eden</code>, port 5000, using the
|
| 150 |
+
<code class="literal">template0</code> template database, here is the
|
| 151 |
+
command-line command and the underlying SQL command:
|
| 152 |
+
</p><pre class="screen">
|
| 153 |
+
<code class="prompt">$ </code><strong class="userinput"><code>createdb -p 5000 -h eden -T template0 -e demo</code></strong>
|
| 154 |
+
<code class="computeroutput">CREATE DATABASE demo TEMPLATE template0;</code>
|
| 155 |
+
</pre></div><div class="refsect1" id="id-1.9.4.4.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-dropdb.html" title="dropdb"><span class="refentrytitle"><span class="application">dropdb</span></span></a>, <a class="xref" href="sql-createdatabase.html" title="CREATE DATABASE"><span class="refentrytitle">CREATE DATABASE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-clusterdb.html" title="clusterdb">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-createuser.html" title="createuser">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">clusterdb</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">createuser</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-createuser.html
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>createuser</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-createdb.html" title="createdb" /><link rel="next" href="app-dropdb.html" title="dropdb" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">createuser</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-createdb.html" title="createdb">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-dropdb.html" title="dropdb">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-CREATEUSER"><div class="titlepage"></div><a id="id-1.9.4.5.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">createuser</span></span></h2><p>createuser — define a new <span class="productname">PostgreSQL</span> user account</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.5.4.1"><code class="command">createuser</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>username</code></em>]</p></div></div><div class="refsect1" id="id-1.9.4.5.5"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">createuser</span> creates a
|
| 4 |
+
new <span class="productname">PostgreSQL</span> user (or more precisely, a role).
|
| 5 |
+
Only superusers and users with <code class="literal">CREATEROLE</code> privilege can create
|
| 6 |
+
new users, so <span class="application">createuser</span> must be
|
| 7 |
+
invoked by someone who can connect as a superuser or a user with
|
| 8 |
+
<code class="literal">CREATEROLE</code> privilege.
|
| 9 |
+
</p><p>
|
| 10 |
+
If you wish to create a role with the <code class="literal">SUPERUSER</code>,
|
| 11 |
+
<code class="literal">REPLICATION</code>, or <code class="literal">BYPASSRLS</code> privilege,
|
| 12 |
+
you must connect as a superuser, not merely with
|
| 13 |
+
<code class="literal">CREATEROLE</code> privilege.
|
| 14 |
+
Being a superuser implies the ability to bypass all access permission
|
| 15 |
+
checks within the database, so superuser access should not be granted
|
| 16 |
+
lightly. <code class="literal">CREATEROLE</code> also conveys
|
| 17 |
+
<a class="link" href="role-attributes.html#ROLE-CREATION">very extensive privileges</a>.
|
| 18 |
+
</p><p>
|
| 19 |
+
<span class="application">createuser</span> is a wrapper around the
|
| 20 |
+
<acronym class="acronym">SQL</acronym> command <a class="link" href="sql-createrole.html" title="CREATE ROLE"><code class="command">CREATE ROLE</code></a>.
|
| 21 |
+
There is no effective difference between creating users via
|
| 22 |
+
this utility and via other methods for accessing the server.
|
| 23 |
+
</p></div><div class="refsect1" id="id-1.9.4.5.6"><h2>Options</h2><p>
|
| 24 |
+
<span class="application">createuser</span> accepts the following command-line arguments:
|
| 25 |
+
|
| 26 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>username</code></em></span></dt><dd><p>
|
| 27 |
+
Specifies the name of the <span class="productname">PostgreSQL</span> user
|
| 28 |
+
to be created.
|
| 29 |
+
This name must be different from all existing roles in this
|
| 30 |
+
<span class="productname">PostgreSQL</span> installation.
|
| 31 |
+
</p></dd><dt><span class="term"><code class="option">-a <em class="replaceable"><code>role</code></em></code><br /></span><span class="term"><code class="option">--with-admin=<em class="replaceable"><code>role</code></em></code></span></dt><dd><p>
|
| 32 |
+
Specifies an existing role that will be automatically added as a member of the new
|
| 33 |
+
role with admin option, giving it the right to grant membership in the
|
| 34 |
+
new role to others. Multiple existing roles can be specified by
|
| 35 |
+
writing multiple <code class="option">-a</code> switches.
|
| 36 |
+
</p></dd><dt><span class="term"><code class="option">-c <em class="replaceable"><code>number</code></em></code><br /></span><span class="term"><code class="option">--connection-limit=<em class="replaceable"><code>number</code></em></code></span></dt><dd><p>
|
| 37 |
+
Set a maximum number of connections for the new user.
|
| 38 |
+
The default is to set no limit.
|
| 39 |
+
</p></dd><dt><span class="term"><code class="option">-d</code><br /></span><span class="term"><code class="option">--createdb</code></span></dt><dd><p>
|
| 40 |
+
The new user will be allowed to create databases.
|
| 41 |
+
</p></dd><dt><span class="term"><code class="option">-D</code><br /></span><span class="term"><code class="option">--no-createdb</code></span></dt><dd><p>
|
| 42 |
+
The new user will not be allowed to create databases. This is the
|
| 43 |
+
default.
|
| 44 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
|
| 45 |
+
Echo the commands that <span class="application">createuser</span> generates
|
| 46 |
+
and sends to the server.
|
| 47 |
+
</p></dd><dt><span class="term"><code class="option">-E</code><br /></span><span class="term"><code class="option">--encrypted</code></span></dt><dd><p>
|
| 48 |
+
This option is obsolete but still accepted for backward
|
| 49 |
+
compatibility.
|
| 50 |
+
</p></dd><dt><span class="term"><code class="option">-g <em class="replaceable"><code>role</code></em></code><br /></span><span class="term"><code class="option">--member-of=<em class="replaceable"><code>role</code></em></code><br /></span><span class="term"><code class="option">--role=<em class="replaceable"><code>role</code></em></code> (deprecated)</span></dt><dd><p>
|
| 51 |
+
Specifies the new role should be automatically added as a member
|
| 52 |
+
of the specified existing role. Multiple existing roles can be
|
| 53 |
+
specified by writing multiple <code class="option">-g</code> switches.
|
| 54 |
+
</p></dd><dt><span class="term"><code class="option">-i</code><br /></span><span class="term"><code class="option">--inherit</code></span></dt><dd><p>
|
| 55 |
+
The new role will automatically inherit privileges of roles
|
| 56 |
+
it is a member of.
|
| 57 |
+
This is the default.
|
| 58 |
+
</p></dd><dt><span class="term"><code class="option">-I</code><br /></span><span class="term"><code class="option">--no-inherit</code></span></dt><dd><p>
|
| 59 |
+
The new role will not automatically inherit privileges of roles
|
| 60 |
+
it is a member of.
|
| 61 |
+
</p></dd><dt><span class="term"><code class="option">--interactive</code></span></dt><dd><p>
|
| 62 |
+
Prompt for the user name if none is specified on the command line, and
|
| 63 |
+
also prompt for whichever of the options
|
| 64 |
+
<code class="option">-d</code>/<code class="option">-D</code>,
|
| 65 |
+
<code class="option">-r</code>/<code class="option">-R</code>,
|
| 66 |
+
<code class="option">-s</code>/<code class="option">-S</code> is not specified on the command
|
| 67 |
+
line. (This was the default behavior up to PostgreSQL 9.1.)
|
| 68 |
+
</p></dd><dt><span class="term"><code class="option">-l</code><br /></span><span class="term"><code class="option">--login</code></span></dt><dd><p>
|
| 69 |
+
The new user will be allowed to log in (that is, the user name
|
| 70 |
+
can be used as the initial session user identifier).
|
| 71 |
+
This is the default.
|
| 72 |
+
</p></dd><dt><span class="term"><code class="option">-L</code><br /></span><span class="term"><code class="option">--no-login</code></span></dt><dd><p>
|
| 73 |
+
The new user will not be allowed to log in.
|
| 74 |
+
(A role without login privilege is still useful as a means of
|
| 75 |
+
managing database permissions.)
|
| 76 |
+
</p></dd><dt><span class="term"><code class="option">-m <em class="replaceable"><code>role</code></em></code><br /></span><span class="term"><code class="option">--with-member=<em class="replaceable"><code>role</code></em></code></span></dt><dd><p>
|
| 77 |
+
Specifies an existing role that will be automatically
|
| 78 |
+
added as a member of the new role. Multiple existing roles can
|
| 79 |
+
be specified by writing multiple <code class="option">-m</code> switches.
|
| 80 |
+
</p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--pwprompt</code></span></dt><dd><p>
|
| 81 |
+
If given, <span class="application">createuser</span> will issue a prompt for
|
| 82 |
+
the password of the new user. This is not necessary if you do not plan
|
| 83 |
+
on using password authentication.
|
| 84 |
+
</p></dd><dt><span class="term"><code class="option">-r</code><br /></span><span class="term"><code class="option">--createrole</code></span></dt><dd><p>
|
| 85 |
+
The new user will be allowed to create, alter, drop, comment on,
|
| 86 |
+
change the security label for other roles; that is,
|
| 87 |
+
this user will have <code class="literal">CREATEROLE</code> privilege.
|
| 88 |
+
See <a class="xref" href="role-attributes.html#ROLE-CREATION">role creation</a> for more details about what
|
| 89 |
+
capabilities are conferred by this privilege.
|
| 90 |
+
</p></dd><dt><span class="term"><code class="option">-R</code><br /></span><span class="term"><code class="option">--no-createrole</code></span></dt><dd><p>
|
| 91 |
+
The new user will not be allowed to create new roles. This is the
|
| 92 |
+
default.
|
| 93 |
+
</p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--superuser</code></span></dt><dd><p>
|
| 94 |
+
The new user will be a superuser.
|
| 95 |
+
</p></dd><dt><span class="term"><code class="option">-S</code><br /></span><span class="term"><code class="option">--no-superuser</code></span></dt><dd><p>
|
| 96 |
+
The new user will not be a superuser. This is the default.
|
| 97 |
+
</p></dd><dt><span class="term"><code class="option">-v <em class="replaceable"><code>timestamp</code></em></code><br /></span><span class="term"><code class="option">--valid-until=<em class="replaceable"><code>timestamp</code></em></code></span></dt><dd><p>
|
| 98 |
+
Set a date and time after which the role's password is no longer valid.
|
| 99 |
+
The default is to set no password expiry date.
|
| 100 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 101 |
+
Print the <span class="application">createuser</span> version and exit.
|
| 102 |
+
</p></dd><dt><span class="term"><code class="option">--bypassrls</code></span></dt><dd><p>
|
| 103 |
+
The new user will bypass every row-level security (RLS) policy.
|
| 104 |
+
</p></dd><dt><span class="term"><code class="option">--no-bypassrls</code></span></dt><dd><p>
|
| 105 |
+
The new user will not bypass row-level security (RLS) policies. This is
|
| 106 |
+
the default.
|
| 107 |
+
</p></dd><dt><span class="term"><code class="option">--replication</code></span></dt><dd><p>
|
| 108 |
+
The new user will have the <code class="literal">REPLICATION</code> privilege,
|
| 109 |
+
which is described more fully in the documentation for <a class="xref" href="sql-createrole.html" title="CREATE ROLE"><span class="refentrytitle">CREATE ROLE</span></a>.
|
| 110 |
+
</p></dd><dt><span class="term"><code class="option">--no-replication</code></span></dt><dd><p>
|
| 111 |
+
The new user will not have the <code class="literal">REPLICATION</code>
|
| 112 |
+
privilege, which is described more fully in the documentation for <a class="xref" href="sql-createrole.html" title="CREATE ROLE"><span class="refentrytitle">CREATE ROLE</span></a>. This is the default.
|
| 113 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 114 |
+
Show help about <span class="application">createuser</span> command line
|
| 115 |
+
arguments, and exit.
|
| 116 |
+
</p></dd></dl></div><p>
|
| 117 |
+
</p><p>
|
| 118 |
+
<span class="application">createuser</span> also accepts the following
|
| 119 |
+
command-line arguments for connection parameters:
|
| 120 |
+
|
| 121 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 122 |
+
Specifies the host name of the machine on which the
|
| 123 |
+
server
|
| 124 |
+
is running. If the value begins with a slash, it is used
|
| 125 |
+
as the directory for the Unix domain socket.
|
| 126 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 127 |
+
Specifies the TCP port or local Unix domain socket file
|
| 128 |
+
extension on which the server
|
| 129 |
+
is listening for connections.
|
| 130 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 131 |
+
User name to connect as (not the user name to create).
|
| 132 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 133 |
+
Never issue a password prompt. If the server requires
|
| 134 |
+
password authentication and a password is not available by
|
| 135 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 136 |
+
connection attempt will fail. This option can be useful in
|
| 137 |
+
batch jobs and scripts where no user is present to enter a
|
| 138 |
+
password.
|
| 139 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 140 |
+
Force <span class="application">createuser</span> to prompt for a
|
| 141 |
+
password (for connecting to the server, not for the
|
| 142 |
+
password of the new user).
|
| 143 |
+
</p><p>
|
| 144 |
+
This option is never essential, since
|
| 145 |
+
<span class="application">createuser</span> will automatically prompt
|
| 146 |
+
for a password if the server demands password authentication.
|
| 147 |
+
However, <span class="application">createuser</span> will waste a
|
| 148 |
+
connection attempt finding out that the server wants a password.
|
| 149 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 150 |
+
connection attempt.
|
| 151 |
+
</p></dd></dl></div><p>
|
| 152 |
+
</p></div><div class="refsect1" id="id-1.9.4.5.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 153 |
+
Default connection parameters
|
| 154 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 155 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 156 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 157 |
+
<code class="literal">never</code>.
|
| 158 |
+
</p></dd></dl></div><p>
|
| 159 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 160 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 161 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 162 |
+
</p></div><div class="refsect1" id="id-1.9.4.5.8"><h2>Diagnostics</h2><p>
|
| 163 |
+
In case of difficulty, see <a class="xref" href="sql-createrole.html" title="CREATE ROLE"><span class="refentrytitle">CREATE ROLE</span></a>
|
| 164 |
+
and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for
|
| 165 |
+
discussions of potential problems and error messages.
|
| 166 |
+
The database server must be running at the
|
| 167 |
+
targeted host. Also, any default connection settings and environment
|
| 168 |
+
variables used by the <span class="application">libpq</span> front-end
|
| 169 |
+
library will apply.
|
| 170 |
+
</p></div><div class="refsect1" id="id-1.9.4.5.9"><h2>Examples</h2><p>
|
| 171 |
+
To create a user <code class="literal">joe</code> on the default database
|
| 172 |
+
server:
|
| 173 |
+
</p><pre class="screen">
|
| 174 |
+
<code class="prompt">$ </code><strong class="userinput"><code>createuser joe</code></strong>
|
| 175 |
+
</pre><p>
|
| 176 |
+
</p><p>
|
| 177 |
+
To create a user <code class="literal">joe</code> on the default database
|
| 178 |
+
server with prompting for some additional attributes:
|
| 179 |
+
</p><pre class="screen">
|
| 180 |
+
<code class="prompt">$ </code><strong class="userinput"><code>createuser --interactive joe</code></strong>
|
| 181 |
+
<code class="computeroutput">Shall the new role be a superuser? (y/n) </code><strong class="userinput"><code>n</code></strong>
|
| 182 |
+
<code class="computeroutput">Shall the new role be allowed to create databases? (y/n) </code><strong class="userinput"><code>n</code></strong>
|
| 183 |
+
<code class="computeroutput">Shall the new role be allowed to create more new roles? (y/n) </code><strong class="userinput"><code>n</code></strong>
|
| 184 |
+
</pre><p>
|
| 185 |
+
</p><p>
|
| 186 |
+
To create the same user <code class="literal">joe</code> using the
|
| 187 |
+
server on host <code class="literal">eden</code>, port 5000, with attributes explicitly specified,
|
| 188 |
+
taking a look at the underlying command:
|
| 189 |
+
</p><pre class="screen">
|
| 190 |
+
<code class="prompt">$ </code><strong class="userinput"><code>createuser -h eden -p 5000 -S -D -R -e joe</code></strong>
|
| 191 |
+
<code class="computeroutput">CREATE ROLE joe NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;</code>
|
| 192 |
+
</pre><p>
|
| 193 |
+
</p><p>
|
| 194 |
+
To create the user <code class="literal">joe</code> as a superuser,
|
| 195 |
+
and assign a password immediately:
|
| 196 |
+
</p><pre class="screen">
|
| 197 |
+
<code class="prompt">$ </code><strong class="userinput"><code>createuser -P -s -e joe</code></strong>
|
| 198 |
+
<code class="computeroutput">Enter password for new role: </code><strong class="userinput"><code>xyzzy</code></strong>
|
| 199 |
+
<code class="computeroutput">Enter it again: </code><strong class="userinput"><code>xyzzy</code></strong>
|
| 200 |
+
<code class="computeroutput">CREATE ROLE joe PASSWORD 'md5b5f5ba1a423792b526f799ae4eb3d59e' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;</code>
|
| 201 |
+
</pre><p>
|
| 202 |
+
In the above example, the new password isn't actually echoed when typed,
|
| 203 |
+
but we show what was typed for clarity. As you see, the password is
|
| 204 |
+
encrypted before it is sent to the client.
|
| 205 |
+
</p></div><div class="refsect1" id="id-1.9.4.5.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-dropuser.html" title="dropuser"><span class="refentrytitle"><span class="application">dropuser</span></span></a>, <a class="xref" href="sql-createrole.html" title="CREATE ROLE"><span class="refentrytitle">CREATE ROLE</span></a>, <a class="xref" href="runtime-config-client.html#GUC-CREATEROLE-SELF-GRANT">createrole_self_grant</a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-createdb.html" title="createdb">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-dropdb.html" title="dropdb">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">createdb</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">dropdb</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-dropdb.html
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>dropdb</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-createuser.html" title="createuser" /><link rel="next" href="app-dropuser.html" title="dropuser" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">dropdb</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-createuser.html" title="createuser">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-dropuser.html" title="dropuser">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-DROPDB"><div class="titlepage"></div><a id="id-1.9.4.6.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">dropdb</span></span></h2><p>dropdb — remove a <span class="productname">PostgreSQL</span> database</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.6.4.1"><code class="command">dropdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] <em class="replaceable"><code>dbname</code></em> </p></div></div><div class="refsect1" id="id-1.9.4.6.5"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">dropdb</span> destroys an existing
|
| 4 |
+
<span class="productname">PostgreSQL</span> database.
|
| 5 |
+
The user who executes this command must be a database
|
| 6 |
+
superuser or the owner of the database.
|
| 7 |
+
</p><p>
|
| 8 |
+
<span class="application">dropdb</span> is a wrapper around the
|
| 9 |
+
<acronym class="acronym">SQL</acronym> command <a class="link" href="sql-dropdatabase.html" title="DROP DATABASE"><code class="command">DROP DATABASE</code></a>.
|
| 10 |
+
There is no effective difference between dropping databases via
|
| 11 |
+
this utility and via other methods for accessing the server.
|
| 12 |
+
</p></div><div class="refsect1" id="id-1.9.4.6.6"><h2>Options</h2><p>
|
| 13 |
+
<span class="application">dropdb</span> accepts the following command-line arguments:
|
| 14 |
+
|
| 15 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>dbname</code></em></span></dt><dd><p>
|
| 16 |
+
Specifies the name of the database to be removed.
|
| 17 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
|
| 18 |
+
Echo the commands that <span class="application">dropdb</span> generates
|
| 19 |
+
and sends to the server.
|
| 20 |
+
</p></dd><dt><span class="term"><code class="option">-f</code><br /></span><span class="term"><code class="option">--force</code></span></dt><dd><p>
|
| 21 |
+
Attempt to terminate all existing connections to the target database
|
| 22 |
+
before dropping it. See <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a> for more
|
| 23 |
+
information on this option.
|
| 24 |
+
</p></dd><dt><span class="term"><code class="option">-i</code><br /></span><span class="term"><code class="option">--interactive</code></span></dt><dd><p>
|
| 25 |
+
Issues a verification prompt before doing anything destructive.
|
| 26 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 27 |
+
Print the <span class="application">dropdb</span> version and exit.
|
| 28 |
+
</p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>
|
| 29 |
+
Do not throw an error if the database does not exist. A notice is issued
|
| 30 |
+
in this case.
|
| 31 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 32 |
+
Show help about <span class="application">dropdb</span> command line
|
| 33 |
+
arguments, and exit.
|
| 34 |
+
</p></dd></dl></div><p>
|
| 35 |
+
|
| 36 |
+
</p><p>
|
| 37 |
+
<span class="application">dropdb</span> also accepts the following
|
| 38 |
+
command-line arguments for connection parameters:
|
| 39 |
+
|
| 40 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 41 |
+
Specifies the host name of the machine on which the
|
| 42 |
+
server
|
| 43 |
+
is running. If the value begins with a slash, it is used
|
| 44 |
+
as the directory for the Unix domain socket.
|
| 45 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 46 |
+
Specifies the TCP port or local Unix domain socket file
|
| 47 |
+
extension on which the server
|
| 48 |
+
is listening for connections.
|
| 49 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 50 |
+
User name to connect as.
|
| 51 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 52 |
+
Never issue a password prompt. If the server requires
|
| 53 |
+
password authentication and a password is not available by
|
| 54 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 55 |
+
connection attempt will fail. This option can be useful in
|
| 56 |
+
batch jobs and scripts where no user is present to enter a
|
| 57 |
+
password.
|
| 58 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 59 |
+
Force <span class="application">dropdb</span> to prompt for a
|
| 60 |
+
password before connecting to a database.
|
| 61 |
+
</p><p>
|
| 62 |
+
This option is never essential, since
|
| 63 |
+
<span class="application">dropdb</span> will automatically prompt
|
| 64 |
+
for a password if the server demands password authentication.
|
| 65 |
+
However, <span class="application">dropdb</span> will waste a
|
| 66 |
+
connection attempt finding out that the server wants a password.
|
| 67 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 68 |
+
connection attempt.
|
| 69 |
+
</p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 70 |
+
Specifies the name of the database to connect to in order to drop the
|
| 71 |
+
target database. If not specified, the <code class="literal">postgres</code>
|
| 72 |
+
database will be used; if that does not exist (or is the database
|
| 73 |
+
being dropped), <code class="literal">template1</code> will be used.
|
| 74 |
+
This can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection
|
| 75 |
+
string</a>. If so, connection string parameters will override any
|
| 76 |
+
conflicting command line options.
|
| 77 |
+
</p></dd></dl></div><p>
|
| 78 |
+
</p></div><div class="refsect1" id="id-1.9.4.6.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 79 |
+
Default connection parameters
|
| 80 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 81 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 82 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 83 |
+
<code class="literal">never</code>.
|
| 84 |
+
</p></dd></dl></div><p>
|
| 85 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 86 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 87 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 88 |
+
</p></div><div class="refsect1" id="id-1.9.4.6.8"><h2>Diagnostics</h2><p>
|
| 89 |
+
In case of difficulty, see <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a>
|
| 90 |
+
and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for
|
| 91 |
+
discussions of potential problems and error messages.
|
| 92 |
+
The database server must be running at the
|
| 93 |
+
targeted host. Also, any default connection settings and environment
|
| 94 |
+
variables used by the <span class="application">libpq</span> front-end
|
| 95 |
+
library will apply.
|
| 96 |
+
</p></div><div class="refsect1" id="id-1.9.4.6.9"><h2>Examples</h2><p>
|
| 97 |
+
To destroy the database <code class="literal">demo</code> on the default
|
| 98 |
+
database server:
|
| 99 |
+
</p><pre class="screen">
|
| 100 |
+
<code class="prompt">$ </code><strong class="userinput"><code>dropdb demo</code></strong>
|
| 101 |
+
</pre><p>
|
| 102 |
+
</p><p>
|
| 103 |
+
To destroy the database <code class="literal">demo</code> using the
|
| 104 |
+
server on host <code class="literal">eden</code>, port 5000, with verification and a peek
|
| 105 |
+
at the underlying command:
|
| 106 |
+
</p><pre class="screen">
|
| 107 |
+
<code class="prompt">$ </code><strong class="userinput"><code>dropdb -p 5000 -h eden -i -e demo</code></strong>
|
| 108 |
+
<code class="computeroutput">Database "demo" will be permanently deleted.
|
| 109 |
+
Are you sure? (y/n) </code><strong class="userinput"><code>y</code></strong>
|
| 110 |
+
<code class="computeroutput">DROP DATABASE demo;</code>
|
| 111 |
+
</pre></div><div class="refsect1" id="id-1.9.4.6.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-createdb.html" title="createdb"><span class="refentrytitle"><span class="application">createdb</span></span></a>, <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-createuser.html" title="createuser">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-dropuser.html" title="dropuser">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">createuser</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">dropuser</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-dropuser.html
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>dropuser</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-dropdb.html" title="dropdb" /><link rel="next" href="app-ecpg.html" title="ecpg" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">dropuser</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-dropdb.html" title="dropdb">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-ecpg.html" title="ecpg">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-DROPUSER"><div class="titlepage"></div><a id="id-1.9.4.7.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">dropuser</span></span></h2><p>dropuser — remove a <span class="productname">PostgreSQL</span> user account</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.7.4.1"><code class="command">dropuser</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>username</code></em>]</p></div></div><div class="refsect1" id="id-1.9.4.7.5"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">dropuser</span> removes an existing
|
| 4 |
+
<span class="productname">PostgreSQL</span> user.
|
| 5 |
+
Superusers can use this command to remove any role; otherwise, only
|
| 6 |
+
non-superuser roles can be removed, and only by a user who possesses
|
| 7 |
+
the <code class="literal">CREATEROLE</code> privilege and has been granted
|
| 8 |
+
<code class="literal">ADMIN OPTION</code> on the target role.
|
| 9 |
+
</p><p>
|
| 10 |
+
<span class="application">dropuser</span> is a wrapper around the
|
| 11 |
+
<acronym class="acronym">SQL</acronym> command <a class="link" href="sql-droprole.html" title="DROP ROLE"><code class="command">DROP ROLE</code></a>.
|
| 12 |
+
There is no effective difference between dropping users via
|
| 13 |
+
this utility and via other methods for accessing the server.
|
| 14 |
+
</p></div><div class="refsect1" id="id-1.9.4.7.6"><h2>Options</h2><p>
|
| 15 |
+
<span class="application">dropuser</span> accepts the following command-line arguments:
|
| 16 |
+
|
| 17 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>username</code></em></span></dt><dd><p>
|
| 18 |
+
Specifies the name of the <span class="productname">PostgreSQL</span> user to be removed.
|
| 19 |
+
You will be prompted for a name if none is specified on the command
|
| 20 |
+
line and the <code class="option">-i</code>/<code class="option">--interactive</code> option
|
| 21 |
+
is used.
|
| 22 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
|
| 23 |
+
Echo the commands that <span class="application">dropuser</span> generates
|
| 24 |
+
and sends to the server.
|
| 25 |
+
</p></dd><dt><span class="term"><code class="option">-i</code><br /></span><span class="term"><code class="option">--interactive</code></span></dt><dd><p>
|
| 26 |
+
Prompt for confirmation before actually removing the user, and prompt
|
| 27 |
+
for the user name if none is specified on the command line.
|
| 28 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 29 |
+
Print the <span class="application">dropuser</span> version and exit.
|
| 30 |
+
</p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>
|
| 31 |
+
Do not throw an error if the user does not exist. A notice is
|
| 32 |
+
issued in this case.
|
| 33 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 34 |
+
Show help about <span class="application">dropuser</span> command line
|
| 35 |
+
arguments, and exit.
|
| 36 |
+
</p></dd></dl></div><p>
|
| 37 |
+
</p><p>
|
| 38 |
+
<span class="application">dropuser</span> also accepts the following
|
| 39 |
+
command-line arguments for connection parameters:
|
| 40 |
+
|
| 41 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 42 |
+
Specifies the host name of the machine on which the
|
| 43 |
+
server
|
| 44 |
+
is running. If the value begins with a slash, it is used
|
| 45 |
+
as the directory for the Unix domain socket.
|
| 46 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 47 |
+
Specifies the TCP port or local Unix domain socket file
|
| 48 |
+
extension on which the server
|
| 49 |
+
is listening for connections.
|
| 50 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 51 |
+
User name to connect as (not the user name to drop).
|
| 52 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 53 |
+
Never issue a password prompt. If the server requires
|
| 54 |
+
password authentication and a password is not available by
|
| 55 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 56 |
+
connection attempt will fail. This option can be useful in
|
| 57 |
+
batch jobs and scripts where no user is present to enter a
|
| 58 |
+
password.
|
| 59 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 60 |
+
Force <span class="application">dropuser</span> to prompt for a
|
| 61 |
+
password before connecting to a database.
|
| 62 |
+
</p><p>
|
| 63 |
+
This option is never essential, since
|
| 64 |
+
<span class="application">dropuser</span> will automatically prompt
|
| 65 |
+
for a password if the server demands password authentication.
|
| 66 |
+
However, <span class="application">dropuser</span> will waste a
|
| 67 |
+
connection attempt finding out that the server wants a password.
|
| 68 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 69 |
+
connection attempt.
|
| 70 |
+
</p></dd></dl></div><p>
|
| 71 |
+
</p></div><div class="refsect1" id="id-1.9.4.7.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 72 |
+
Default connection parameters
|
| 73 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 74 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 75 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 76 |
+
<code class="literal">never</code>.
|
| 77 |
+
</p></dd></dl></div><p>
|
| 78 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 79 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 80 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 81 |
+
</p></div><div class="refsect1" id="id-1.9.4.7.8"><h2>Diagnostics</h2><p>
|
| 82 |
+
In case of difficulty, see <a class="xref" href="sql-droprole.html" title="DROP ROLE"><span class="refentrytitle">DROP ROLE</span></a>
|
| 83 |
+
and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for
|
| 84 |
+
discussions of potential problems and error messages.
|
| 85 |
+
The database server must be running at the
|
| 86 |
+
targeted host. Also, any default connection settings and environment
|
| 87 |
+
variables used by the <span class="application">libpq</span> front-end
|
| 88 |
+
library will apply.
|
| 89 |
+
</p></div><div class="refsect1" id="id-1.9.4.7.9"><h2>Examples</h2><p>
|
| 90 |
+
To remove user <code class="literal">joe</code> from the default database
|
| 91 |
+
server:
|
| 92 |
+
</p><pre class="screen">
|
| 93 |
+
<code class="prompt">$ </code><strong class="userinput"><code>dropuser joe</code></strong>
|
| 94 |
+
</pre><p>
|
| 95 |
+
</p><p>
|
| 96 |
+
To remove user <code class="literal">joe</code> using the server on host
|
| 97 |
+
<code class="literal">eden</code>, port 5000, with verification and a peek at the underlying
|
| 98 |
+
command:
|
| 99 |
+
</p><pre class="screen">
|
| 100 |
+
<code class="prompt">$ </code><strong class="userinput"><code>dropuser -p 5000 -h eden -i -e joe</code></strong>
|
| 101 |
+
<code class="computeroutput">Role "joe" will be permanently removed.
|
| 102 |
+
Are you sure? (y/n) </code><strong class="userinput"><code>y</code></strong>
|
| 103 |
+
<code class="computeroutput">DROP ROLE joe;</code>
|
| 104 |
+
</pre></div><div class="refsect1" id="id-1.9.4.7.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-createuser.html" title="createuser"><span class="refentrytitle"><span class="application">createuser</span></span></a>, <a class="xref" href="sql-droprole.html" title="DROP ROLE"><span class="refentrytitle">DROP ROLE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-dropdb.html" title="dropdb">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-ecpg.html" title="ecpg">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">dropdb</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">ecpg</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-ecpg.html
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ecpg</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-dropuser.html" title="dropuser" /><link rel="next" href="app-pgamcheck.html" title="pg_amcheck" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">ecpg</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-dropuser.html" title="dropuser">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgamcheck.html" title="pg_amcheck">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-ECPG"><div class="titlepage"></div><a id="id-1.9.4.8.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">ecpg</span></span></h2><p><span class="application">ecpg</span> — embedded SQL C preprocessor</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.8.4.1"><code class="command">ecpg</code> [<em class="replaceable"><code>option</code></em>...] <em class="replaceable"><code>file</code></em>... </p></div></div><div class="refsect1" id="APP-ECPG-DESCRIPTION"><h2>Description</h2><p>
|
| 3 |
+
<code class="command">ecpg</code> is the embedded SQL preprocessor for C
|
| 4 |
+
programs. It converts C programs with embedded SQL statements to
|
| 5 |
+
normal C code by replacing the SQL invocations with special
|
| 6 |
+
function calls. The output files can then be processed with any C
|
| 7 |
+
compiler tool chain.
|
| 8 |
+
</p><p>
|
| 9 |
+
<code class="command">ecpg</code> will convert each input file given on the
|
| 10 |
+
command line to the corresponding C output file. If an input file
|
| 11 |
+
name does not have any extension, <code class="filename">.pgc</code> is
|
| 12 |
+
assumed. The file's extension will be replaced
|
| 13 |
+
by <code class="filename">.c</code> to construct the output file name.
|
| 14 |
+
But the output file name can be overridden using the
|
| 15 |
+
<code class="option">-o</code> option.
|
| 16 |
+
</p><p>
|
| 17 |
+
If an input file name is just <code class="literal">-</code>,
|
| 18 |
+
<code class="command">ecpg</code> reads the program from standard input
|
| 19 |
+
(and writes to standard output, unless that is overridden
|
| 20 |
+
with <code class="option">-o</code>).
|
| 21 |
+
</p><p>
|
| 22 |
+
This reference page does not describe the embedded SQL language.
|
| 23 |
+
See <a class="xref" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Chapter 36</a> for more information on that topic.
|
| 24 |
+
</p></div><div class="refsect1" id="id-1.9.4.8.6"><h2>Options</h2><p>
|
| 25 |
+
<code class="command">ecpg</code> accepts the following command-line
|
| 26 |
+
arguments:
|
| 27 |
+
|
| 28 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-c</code></span></dt><dd><p>
|
| 29 |
+
Automatically generate certain C code from SQL code. Currently, this
|
| 30 |
+
works for <code class="literal">EXEC SQL TYPE</code>.
|
| 31 |
+
</p></dd><dt><span class="term"><code class="option">-C <em class="replaceable"><code>mode</code></em></code></span></dt><dd><p>
|
| 32 |
+
Set a compatibility mode. <em class="replaceable"><code>mode</code></em> can
|
| 33 |
+
be <code class="literal">INFORMIX</code>,
|
| 34 |
+
<code class="literal">INFORMIX_SE</code>, or <code class="literal">ORACLE</code>.
|
| 35 |
+
</p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>symbol</code></em>[=<em class="replaceable"><code>value</code></em>]</code></span></dt><dd><p>
|
| 36 |
+
Define a preprocessor symbol, equivalently to the <code class="command">EXEC SQL
|
| 37 |
+
DEFINE</code> directive. If no <em class="replaceable"><code>value</code></em> is
|
| 38 |
+
specified, the symbol is defined with the value <code class="literal">1</code>.
|
| 39 |
+
</p></dd><dt><span class="term"><code class="option">-h</code></span></dt><dd><p>
|
| 40 |
+
Process header files. When this option is specified, the output file
|
| 41 |
+
extension becomes <code class="literal">.h</code> not <code class="literal">.c</code>,
|
| 42 |
+
and the default input file extension is <code class="literal">.pgh</code>
|
| 43 |
+
not <code class="literal">.pgc</code>. Also, the <code class="option">-c</code> option is
|
| 44 |
+
forced on.
|
| 45 |
+
</p></dd><dt><span class="term"><code class="option">-i</code></span></dt><dd><p>
|
| 46 |
+
Parse system include files as well.
|
| 47 |
+
</p></dd><dt><span class="term"><code class="option">-I <em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
|
| 48 |
+
Specify an additional include path, used to find files included
|
| 49 |
+
via <code class="literal">EXEC SQL INCLUDE</code>. Defaults are
|
| 50 |
+
<code class="filename">.</code> (current directory),
|
| 51 |
+
<code class="filename">/usr/local/include</code>, the
|
| 52 |
+
<span class="productname">PostgreSQL</span> include directory which
|
| 53 |
+
is defined at compile time (default:
|
| 54 |
+
<code class="filename">/usr/local/pgsql/include</code>), and
|
| 55 |
+
<code class="filename">/usr/include</code>, in that order.
|
| 56 |
+
</p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
|
| 57 |
+
Specifies that <code class="command">ecpg</code> should write all
|
| 58 |
+
its output to the given <em class="replaceable"><code>filename</code></em>.
|
| 59 |
+
Write <code class="literal">-o -</code> to send all output to standard output.
|
| 60 |
+
</p></dd><dt><span class="term"><code class="option">-r <em class="replaceable"><code>option</code></em></code></span></dt><dd><p>
|
| 61 |
+
Selects run-time behavior. <em class="replaceable"><code>Option</code></em> can be
|
| 62 |
+
one of the following:
|
| 63 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">no_indicator</code></span></dt><dd><p>
|
| 64 |
+
Do not use indicators but instead use special values to represent
|
| 65 |
+
null values. Historically there have been databases using this approach.
|
| 66 |
+
</p></dd><dt><span class="term"><code class="option">prepare</code></span></dt><dd><p>
|
| 67 |
+
Prepare all statements before using them. Libecpg will keep a cache of
|
| 68 |
+
prepared statements and reuse a statement if it gets executed again. If the
|
| 69 |
+
cache runs full, libecpg will free the least used statement.
|
| 70 |
+
</p></dd><dt><span class="term"><code class="option">questionmarks</code></span></dt><dd><p>
|
| 71 |
+
Allow question mark as placeholder for compatibility reasons.
|
| 72 |
+
This used to be the default long ago.
|
| 73 |
+
</p></dd></dl></div></dd><dt><span class="term"><code class="option">-t</code></span></dt><dd><p>
|
| 74 |
+
Turn on autocommit of transactions. In this mode, each SQL command is
|
| 75 |
+
automatically committed unless it is inside an explicit
|
| 76 |
+
transaction block. In the default mode, commands are committed
|
| 77 |
+
only when <code class="command">EXEC SQL COMMIT</code> is issued.
|
| 78 |
+
</p></dd><dt><span class="term"><code class="option">-v</code></span></dt><dd><p>
|
| 79 |
+
Print additional information including the version and the
|
| 80 |
+
"include" path.
|
| 81 |
+
</p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 82 |
+
Print the <span class="application">ecpg</span> version and exit.
|
| 83 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 84 |
+
Show help about <span class="application">ecpg</span> command line
|
| 85 |
+
arguments, and exit.
|
| 86 |
+
</p></dd></dl></div><p>
|
| 87 |
+
</p></div><div class="refsect1" id="id-1.9.4.8.7"><h2>Notes</h2><p>
|
| 88 |
+
When compiling the preprocessed C code files, the compiler needs to
|
| 89 |
+
be able to find the <span class="application">ECPG</span> header files in the
|
| 90 |
+
<span class="productname">PostgreSQL</span> include directory. Therefore, you might
|
| 91 |
+
have to use the <code class="option">-I</code> option when invoking the compiler
|
| 92 |
+
(e.g., <code class="literal">-I/usr/local/pgsql/include</code>).
|
| 93 |
+
</p><p>
|
| 94 |
+
Programs using C code with embedded SQL have to be linked against
|
| 95 |
+
the <code class="filename">libecpg</code> library, for example using the
|
| 96 |
+
linker options <code class="literal">-L/usr/local/pgsql/lib -lecpg</code>.
|
| 97 |
+
</p><p>
|
| 98 |
+
The value of either of these directories that is appropriate for
|
| 99 |
+
the installation can be found out using <a class="xref" href="app-pgconfig.html" title="pg_config"><span class="refentrytitle"><span class="application">pg_config</span></span></a>.
|
| 100 |
+
</p></div><div class="refsect1" id="id-1.9.4.8.8"><h2>Examples</h2><p>
|
| 101 |
+
If you have an embedded SQL C source file named
|
| 102 |
+
<code class="filename">prog1.pgc</code>, you can create an executable
|
| 103 |
+
program using the following sequence of commands:
|
| 104 |
+
</p><pre class="programlisting">
|
| 105 |
+
ecpg prog1.pgc
|
| 106 |
+
cc -I/usr/local/pgsql/include -c prog1.c
|
| 107 |
+
cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg
|
| 108 |
+
</pre></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-dropuser.html" title="dropuser">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgamcheck.html" title="pg_amcheck">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">dropuser</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_amcheck</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-initdb.html
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>initdb</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="reference-server.html" title="PostgreSQL Server Applications" /><link rel="next" href="pgarchivecleanup.html" title="pg_archivecleanup" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">initdb</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="reference-server.html" title="PostgreSQL Server Applications">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="pgarchivecleanup.html" title="pg_archivecleanup">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-INITDB"><div class="titlepage"></div><a id="id-1.9.5.3.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">initdb</span></span></h2><p>initdb — create a new <span class="productname">PostgreSQL</span> database cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.3.4.1"><code class="command">initdb</code> [<em class="replaceable"><code>option</code></em>...] [ <code class="option">--pgdata</code> | <code class="option">-D</code> ]<em class="replaceable"><code> directory</code></em> </p></div></div><div class="refsect1" id="R1-APP-INITDB-1"><h2>Description</h2><p>
|
| 3 |
+
<code class="command">initdb</code> creates a new
|
| 4 |
+
<span class="productname">PostgreSQL</span> <a class="glossterm" href="glossary.html#GLOSSARY-DB-CLUSTER"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-DB-CLUSTER" title="Database cluster">database cluster</a></em></a>.
|
| 5 |
+
</p><p>
|
| 6 |
+
Creating a database cluster consists of creating the
|
| 7 |
+
<a class="glossterm" href="glossary.html#GLOSSARY-DATA-DIRECTORY"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-DATA-DIRECTORY" title="Data directory">directories</a></em></a> in
|
| 8 |
+
which the cluster data will live, generating the shared catalog
|
| 9 |
+
tables (tables that belong to the whole cluster rather than to any
|
| 10 |
+
particular database), and creating the <code class="literal">postgres</code>,
|
| 11 |
+
<code class="literal">template1</code>, and <code class="literal">template0</code> databases.
|
| 12 |
+
The <code class="literal">postgres</code> database is a default database meant
|
| 13 |
+
for use by users, utilities and third party applications.
|
| 14 |
+
<code class="literal">template1</code> and <code class="literal">template0</code> are
|
| 15 |
+
meant as source databases to be copied by later <code class="command">CREATE
|
| 16 |
+
DATABASE</code> commands. <code class="literal">template0</code> should never
|
| 17 |
+
be modified, but you can add objects to <code class="literal">template1</code>,
|
| 18 |
+
which by default will be copied into databases created later. See
|
| 19 |
+
<a class="xref" href="manage-ag-templatedbs.html" title="23.3. Template Databases">Section 23.3</a> for more details.
|
| 20 |
+
</p><p>
|
| 21 |
+
Although <code class="command">initdb</code> will attempt to create the
|
| 22 |
+
specified data directory, it might not have permission if the parent
|
| 23 |
+
directory of the desired data directory is root-owned. To initialize
|
| 24 |
+
in such a setup, create an empty data directory as root, then use
|
| 25 |
+
<code class="command">chown</code> to assign ownership of that directory to the
|
| 26 |
+
database user account, then <code class="command">su</code> to become the
|
| 27 |
+
database user to run <code class="command">initdb</code>.
|
| 28 |
+
</p><p>
|
| 29 |
+
<code class="command">initdb</code> must be run as the user that will own the
|
| 30 |
+
server process, because the server needs to have access to the
|
| 31 |
+
files and directories that <code class="command">initdb</code> creates.
|
| 32 |
+
Since the server cannot be run as root, you must not run
|
| 33 |
+
<code class="command">initdb</code> as root either. (It will in fact refuse
|
| 34 |
+
to do so.)
|
| 35 |
+
</p><p>
|
| 36 |
+
For security reasons the new cluster created by <code class="command">initdb</code>
|
| 37 |
+
will only be accessible by the cluster owner by default. The
|
| 38 |
+
<code class="option">--allow-group-access</code> option allows any user in the same
|
| 39 |
+
group as the cluster owner to read files in the cluster. This is useful
|
| 40 |
+
for performing backups as a non-privileged user.
|
| 41 |
+
</p><p>
|
| 42 |
+
<code class="command">initdb</code> initializes the database cluster's default locale
|
| 43 |
+
and character set encoding. These can also be set separately for each
|
| 44 |
+
database when it is created. <code class="command">initdb</code> determines those
|
| 45 |
+
settings for the template databases, which will serve as the default for
|
| 46 |
+
all other databases.
|
| 47 |
+
</p><p>
|
| 48 |
+
By default, <code class="command">initdb</code> uses the locale provider
|
| 49 |
+
<code class="literal">libc</code> (see <a class="xref" href="locale.html#LOCALE-PROVIDERS" title="24.1.4. Locale Providers">Section 24.1.4</a>). The
|
| 50 |
+
<code class="literal">libc</code> locale provider takes the locale settings from the
|
| 51 |
+
environment, and determines the encoding from the locale settings.
|
| 52 |
+
</p><p>
|
| 53 |
+
To choose a different locale for the cluster, use the option
|
| 54 |
+
<code class="option">--locale</code>. There are also individual options
|
| 55 |
+
<code class="option">--lc-*</code> and <code class="option">--icu-locale</code> (see below) to
|
| 56 |
+
set values for the individual locale categories. Note that inconsistent
|
| 57 |
+
settings for different locale categories can give nonsensical results, so
|
| 58 |
+
this should be used with care.
|
| 59 |
+
</p><p>
|
| 60 |
+
Alternatively, <code class="command">initdb</code> can use the ICU library to provide
|
| 61 |
+
locale services by specifying <code class="literal">--locale-provider=icu</code>. The
|
| 62 |
+
server must be built with ICU support. To choose the specific ICU locale ID
|
| 63 |
+
to apply, use the option <code class="option">--icu-locale</code>. Note that for
|
| 64 |
+
implementation reasons and to support legacy code,
|
| 65 |
+
<code class="command">initdb</code> will still select and initialize libc locale
|
| 66 |
+
settings when the ICU locale provider is used.
|
| 67 |
+
</p><p>
|
| 68 |
+
When <code class="command">initdb</code> runs, it will print out the locale settings
|
| 69 |
+
it has chosen. If you have complex requirements or specified multiple
|
| 70 |
+
options, it is advisable to check that the result matches what was
|
| 71 |
+
intended.
|
| 72 |
+
</p><p>
|
| 73 |
+
More details about locale settings can be found in <a class="xref" href="locale.html" title="24.1. Locale Support">Section 24.1</a>.
|
| 74 |
+
</p><p>
|
| 75 |
+
To alter the default encoding, use the <code class="option">--encoding</code>.
|
| 76 |
+
More details can be found in <a class="xref" href="multibyte.html" title="24.3. Character Set Support">Section 24.3</a>.
|
| 77 |
+
</p></div><div class="refsect1" id="id-1.9.5.3.6"><h2>Options</h2><p>
|
| 78 |
+
</p><div class="variablelist"><dl class="variablelist"><dt id="APP-INITDB-OPTION-AUTH"><span class="term"><code class="option">-A <em class="replaceable"><code>authmethod</code></em></code><br /></span><span class="term"><code class="option">--auth=<em class="replaceable"><code>authmethod</code></em></code></span> <a href="#APP-INITDB-OPTION-AUTH" class="id_link">#</a></dt><dd><p>
|
| 79 |
+
This option specifies the default authentication method for local
|
| 80 |
+
users used in <code class="filename">pg_hba.conf</code> (<code class="literal">host</code>
|
| 81 |
+
and <code class="literal">local</code> lines). See <a class="xref" href="auth-pg-hba-conf.html" title="21.1. The pg_hba.conf File">Section 21.1</a>
|
| 82 |
+
for an overview of valid values.
|
| 83 |
+
</p><p>
|
| 84 |
+
<code class="command">initdb</code> will
|
| 85 |
+
prepopulate <code class="filename">pg_hba.conf</code> entries using the
|
| 86 |
+
specified authentication method for non-replication as well as
|
| 87 |
+
replication connections.
|
| 88 |
+
</p><p>
|
| 89 |
+
Do not use <code class="literal">trust</code> unless you trust all local users on your
|
| 90 |
+
system. <code class="literal">trust</code> is the default for ease of installation.
|
| 91 |
+
</p></dd><dt id="APP-INITDB-OPTION-AUTH-HOST"><span class="term"><code class="option">--auth-host=<em class="replaceable"><code>authmethod</code></em></code></span> <a href="#APP-INITDB-OPTION-AUTH-HOST" class="id_link">#</a></dt><dd><p>
|
| 92 |
+
This option specifies the authentication method for local users via
|
| 93 |
+
TCP/IP connections used in <code class="filename">pg_hba.conf</code>
|
| 94 |
+
(<code class="literal">host</code> lines).
|
| 95 |
+
</p></dd><dt id="APP-INITDB-OPTION-AUTH-LOCAL"><span class="term"><code class="option">--auth-local=<em class="replaceable"><code>authmethod</code></em></code></span> <a href="#APP-INITDB-OPTION-AUTH-LOCAL" class="id_link">#</a></dt><dd><p>
|
| 96 |
+
This option specifies the authentication method for local users via
|
| 97 |
+
Unix-domain socket connections used in <code class="filename">pg_hba.conf</code>
|
| 98 |
+
(<code class="literal">local</code> lines).
|
| 99 |
+
</p></dd><dt id="APP-INITDB-OPTION-PGDATA"><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>directory</code></em></code></span> <a href="#APP-INITDB-OPTION-PGDATA" class="id_link">#</a></dt><dd><p>
|
| 100 |
+
This option specifies the directory where the database cluster
|
| 101 |
+
should be stored. This is the only information required by
|
| 102 |
+
<code class="command">initdb</code>, but you can avoid writing it by
|
| 103 |
+
setting the <code class="envar">PGDATA</code> environment variable, which
|
| 104 |
+
can be convenient since the database server
|
| 105 |
+
(<code class="command">postgres</code>) can find the data
|
| 106 |
+
directory later by the same variable.
|
| 107 |
+
</p></dd><dt id="APP-INITDB-OPTION-ENCODING"><span class="term"><code class="option">-E <em class="replaceable"><code>encoding</code></em></code><br /></span><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span> <a href="#APP-INITDB-OPTION-ENCODING" class="id_link">#</a></dt><dd><p>
|
| 108 |
+
Selects the encoding of the template databases. This will also be the
|
| 109 |
+
default encoding of any database you create later, unless you override
|
| 110 |
+
it then. The character sets supported by the
|
| 111 |
+
<span class="productname">PostgreSQL</span> server are described in <a class="xref" href="multibyte.html#MULTIBYTE-CHARSET-SUPPORTED" title="24.3.1. Supported Character Sets">Section 24.3.1</a>.
|
| 112 |
+
</p><p>
|
| 113 |
+
By default, the template database encoding is derived from the
|
| 114 |
+
locale. If <a class="xref" href="app-initdb.html#APP-INITDB-OPTION-NO-LOCALE"><code class="option">--no-locale</code></a> is specified
|
| 115 |
+
(or equivalently, if the locale is <code class="literal">C</code> or
|
| 116 |
+
<code class="literal">POSIX</code>), then the default is <code class="literal">UTF8</code>
|
| 117 |
+
for the ICU provider and <code class="literal">SQL_ASCII</code> for the
|
| 118 |
+
<code class="literal">libc</code> provider.
|
| 119 |
+
</p></dd><dt id="APP-INITDB-ALLOW-GROUP-ACCESS"><span class="term"><code class="option">-g</code><br /></span><span class="term"><code class="option">--allow-group-access</code></span> <a href="#APP-INITDB-ALLOW-GROUP-ACCESS" class="id_link">#</a></dt><dd><p>
|
| 120 |
+
Allows users in the same group as the cluster owner to read all cluster
|
| 121 |
+
files created by <code class="command">initdb</code>. This option is ignored
|
| 122 |
+
on <span class="productname">Windows</span> as it does not support
|
| 123 |
+
<acronym class="acronym">POSIX</acronym>-style group permissions.
|
| 124 |
+
</p></dd><dt id="APP-INITDB-ICU-LOCALE"><span class="term"><code class="option">--icu-locale=<em class="replaceable"><code>locale</code></em></code></span> <a href="#APP-INITDB-ICU-LOCALE" class="id_link">#</a></dt><dd><p>
|
| 125 |
+
Specifies the ICU locale when the ICU provider is used. Locale support
|
| 126 |
+
is described in <a class="xref" href="locale.html" title="24.1. Locale Support">Section 24.1</a>.
|
| 127 |
+
</p></dd><dt id="APP-INITDB-ICU-RULES"><span class="term"><code class="option">--icu-rules=<em class="replaceable"><code>rules</code></em></code></span> <a href="#APP-INITDB-ICU-RULES" class="id_link">#</a></dt><dd><p>
|
| 128 |
+
Specifies additional collation rules to customize the behavior of the
|
| 129 |
+
default collation. This is supported for ICU only.
|
| 130 |
+
</p></dd><dt id="APP-INITDB-DATA-CHECKSUMS"><span class="term"><code class="option">-k</code><br /></span><span class="term"><code class="option">--data-checksums</code></span> <a href="#APP-INITDB-DATA-CHECKSUMS" class="id_link">#</a></dt><dd><p>
|
| 131 |
+
Use checksums on data pages to help detect corruption by the
|
| 132 |
+
I/O system that would otherwise be silent. Enabling checksums
|
| 133 |
+
may incur a noticeable performance penalty. If set, checksums
|
| 134 |
+
are calculated for all objects, in all databases. All checksum
|
| 135 |
+
failures will be reported in the
|
| 136 |
+
<a class="link" href="monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW" title="28.2.16. pg_stat_database">
|
| 137 |
+
<code class="structname">pg_stat_database</code></a> view.
|
| 138 |
+
See <a class="xref" href="checksums.html" title="30.2. Data Checksums">Section 30.2</a> for details.
|
| 139 |
+
</p></dd><dt id="APP-INITDB-OPTION-LOCALE"><span class="term"><code class="option">--locale=<em class="replaceable"><code>locale</code></em></code></span> <a href="#APP-INITDB-OPTION-LOCALE" class="id_link">#</a></dt><dd><p>
|
| 140 |
+
Sets the default locale for the database cluster. If this
|
| 141 |
+
option is not specified, the locale is inherited from the
|
| 142 |
+
environment that <code class="command">initdb</code> runs in. Locale
|
| 143 |
+
support is described in <a class="xref" href="locale.html" title="24.1. Locale Support">Section 24.1</a>.
|
| 144 |
+
</p></dd><dt id="APP-INITDB-OPTION-LC-COLLATE"><span class="term"><code class="option">--lc-collate=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-ctype=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-messages=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-monetary=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-numeric=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-time=<em class="replaceable"><code>locale</code></em></code></span> <a href="#APP-INITDB-OPTION-LC-COLLATE" class="id_link">#</a></dt><dd><p>
|
| 145 |
+
Like <code class="option">--locale</code>, but only sets the locale in
|
| 146 |
+
the specified category.
|
| 147 |
+
</p></dd><dt id="APP-INITDB-OPTION-NO-LOCALE"><span class="term"><code class="option">--no-locale</code></span> <a href="#APP-INITDB-OPTION-NO-LOCALE" class="id_link">#</a></dt><dd><p>
|
| 148 |
+
Equivalent to <code class="option">--locale=C</code>.
|
| 149 |
+
</p></dd><dt id="APP-INITDB-OPTION-LOCALE-PROVIDER"><span class="term"><code class="option">--locale-provider={<code class="literal">libc</code>|<code class="literal">icu</code>}</code></span> <a href="#APP-INITDB-OPTION-LOCALE-PROVIDER" class="id_link">#</a></dt><dd><p>
|
| 150 |
+
This option sets the locale provider for databases created in the new
|
| 151 |
+
cluster. It can be overridden in the <code class="command">CREATE
|
| 152 |
+
DATABASE</code> command when new databases are subsequently
|
| 153 |
+
created. The default is <code class="literal">libc</code> (see <a class="xref" href="locale.html#LOCALE-PROVIDERS" title="24.1.4. Locale Providers">Section 24.1.4</a>).
|
| 154 |
+
</p></dd><dt id="APP-INITDB-OPTION-NO-SYNC"><span class="term"><code class="option">-N</code><br /></span><span class="term"><code class="option">--no-sync</code></span> <a href="#APP-INITDB-OPTION-NO-SYNC" class="id_link">#</a></dt><dd><p>
|
| 155 |
+
By default, <code class="command">initdb</code> will wait for all files to be
|
| 156 |
+
written safely to disk. This option causes <code class="command">initdb</code>
|
| 157 |
+
to return without waiting, which is faster, but means that a
|
| 158 |
+
subsequent operating system crash can leave the data directory
|
| 159 |
+
corrupt. Generally, this option is useful for testing, but should not
|
| 160 |
+
be used when creating a production installation.
|
| 161 |
+
</p></dd><dt id="APP-INITDB-OPTION-NO-INSTRUCTIONS"><span class="term"><code class="option">--no-instructions</code></span> <a href="#APP-INITDB-OPTION-NO-INSTRUCTIONS" class="id_link">#</a></dt><dd><p>
|
| 162 |
+
By default, <code class="command">initdb</code> will write instructions for how
|
| 163 |
+
to start the cluster at the end of its output. This option causes
|
| 164 |
+
those instructions to be left out. This is primarily intended for use
|
| 165 |
+
by tools that wrap <code class="command">initdb</code> in platform-specific
|
| 166 |
+
behavior, where those instructions are likely to be incorrect.
|
| 167 |
+
</p></dd><dt id="APP-INITDB-OPTION-PWFILE"><span class="term"><code class="option">--pwfile=<em class="replaceable"><code>filename</code></em></code></span> <a href="#APP-INITDB-OPTION-PWFILE" class="id_link">#</a></dt><dd><p>
|
| 168 |
+
Makes <code class="command">initdb</code> read the bootstrap superuser's password
|
| 169 |
+
from a file. The first line of the file is taken as the password.
|
| 170 |
+
</p></dd><dt id="APP-INITDB-OPTION-SYNC-ONLY"><span class="term"><code class="option">-S</code><br /></span><span class="term"><code class="option">--sync-only</code></span> <a href="#APP-INITDB-OPTION-SYNC-ONLY" class="id_link">#</a></dt><dd><p>
|
| 171 |
+
Safely write all database files to disk and exit. This does not
|
| 172 |
+
perform any of the normal <span class="application">initdb</span> operations.
|
| 173 |
+
Generally, this option is useful for ensuring reliable recovery after
|
| 174 |
+
changing <a class="xref" href="runtime-config-wal.html#GUC-FSYNC">fsync</a> from <code class="literal">off</code> to
|
| 175 |
+
<code class="literal">on</code>.
|
| 176 |
+
</p></dd><dt id="APP-INITDB-OPTION-TEXT-SEARCH-CONFIG"><span class="term"><code class="option">-T <em class="replaceable"><code>config</code></em></code><br /></span><span class="term"><code class="option">--text-search-config=<em class="replaceable"><code>config</code></em></code></span> <a href="#APP-INITDB-OPTION-TEXT-SEARCH-CONFIG" class="id_link">#</a></dt><dd><p>
|
| 177 |
+
Sets the default text search configuration.
|
| 178 |
+
See <a class="xref" href="runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG">default_text_search_config</a> for further information.
|
| 179 |
+
</p></dd><dt id="APP-INITDB-OPTION-USERNAME"><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span> <a href="#APP-INITDB-OPTION-USERNAME" class="id_link">#</a></dt><dd><p>
|
| 180 |
+
Sets the user name of the
|
| 181 |
+
<a class="glossterm" href="glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER" title="Bootstrap superuser">bootstrap superuser</a></em></a>.
|
| 182 |
+
This defaults to the name of the operating-system user running
|
| 183 |
+
<code class="command">initdb</code>.
|
| 184 |
+
</p></dd><dt id="APP-INITDB-OPTION-PWPROMPT"><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--pwprompt</code></span> <a href="#APP-INITDB-OPTION-PWPROMPT" class="id_link">#</a></dt><dd><p>
|
| 185 |
+
Makes <code class="command">initdb</code> prompt for a password
|
| 186 |
+
to give the bootstrap superuser. If you don't plan on using password
|
| 187 |
+
authentication, this is not important. Otherwise you won't be
|
| 188 |
+
able to use password authentication until you have a password
|
| 189 |
+
set up.
|
| 190 |
+
</p></dd><dt id="APP-INITDB-OPTION-WALDIR"><span class="term"><code class="option">-X <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--waldir=<em class="replaceable"><code>directory</code></em></code></span> <a href="#APP-INITDB-OPTION-WALDIR" class="id_link">#</a></dt><dd><p>
|
| 191 |
+
This option specifies the directory where the write-ahead log
|
| 192 |
+
should be stored.
|
| 193 |
+
</p></dd><dt id="APP-INITDB-OPTION-WAL-SEGSIZE"><span class="term"><code class="option">--wal-segsize=<em class="replaceable"><code>size</code></em></code></span> <a href="#APP-INITDB-OPTION-WAL-SEGSIZE" class="id_link">#</a></dt><dd><p>
|
| 194 |
+
Set the <em class="firstterm">WAL segment size</em>, in megabytes. This
|
| 195 |
+
is the size of each individual file in the WAL log. The default size
|
| 196 |
+
is 16 megabytes. The value must be a power of 2 between 1 and 1024
|
| 197 |
+
(megabytes). This option can only be set during initialization, and
|
| 198 |
+
cannot be changed later.
|
| 199 |
+
</p><p>
|
| 200 |
+
It may be useful to adjust this size to control the granularity of
|
| 201 |
+
WAL log shipping or archiving. Also, in databases with a high volume
|
| 202 |
+
of WAL, the sheer number of WAL files per directory can become a
|
| 203 |
+
performance and management problem. Increasing the WAL file size
|
| 204 |
+
will reduce the number of WAL files.
|
| 205 |
+
</p></dd></dl></div><p>
|
| 206 |
+
</p><p>
|
| 207 |
+
Other, less commonly used, options are also available:
|
| 208 |
+
|
| 209 |
+
</p><div class="variablelist"><dl class="variablelist"><dt id="APP-INITDB-OPTION-SET"><span class="term"><code class="option">-c <em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></code><br /></span><span class="term"><code class="option">--set <em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></code></span> <a href="#APP-INITDB-OPTION-SET" class="id_link">#</a></dt><dd><p>
|
| 210 |
+
Forcibly set the server parameter <em class="replaceable"><code>name</code></em>
|
| 211 |
+
to <em class="replaceable"><code>value</code></em> during <code class="command">initdb</code>,
|
| 212 |
+
and also install that setting in the
|
| 213 |
+
generated <code class="filename">postgresql.conf</code> file,
|
| 214 |
+
so that it will apply during future server runs.
|
| 215 |
+
This option can be given more than once to set several parameters.
|
| 216 |
+
It is primarily useful when the environment is such that the server
|
| 217 |
+
will not start at all using the default parameters.
|
| 218 |
+
</p></dd><dt id="APP-INITDB-OPTION-DEBUG"><span class="term"><code class="option">-d</code><br /></span><span class="term"><code class="option">--debug</code></span> <a href="#APP-INITDB-OPTION-DEBUG" class="id_link">#</a></dt><dd><p>
|
| 219 |
+
Print debugging output from the bootstrap backend and a few other
|
| 220 |
+
messages of lesser interest for the general public.
|
| 221 |
+
The bootstrap backend is the program <code class="command">initdb</code>
|
| 222 |
+
uses to create the catalog tables. This option generates a tremendous
|
| 223 |
+
amount of extremely boring output.
|
| 224 |
+
</p></dd><dt id="APP-INITDB-OPTION-DISCARD-CACHES"><span class="term"><code class="option">--discard-caches</code></span> <a href="#APP-INITDB-OPTION-DISCARD-CACHES" class="id_link">#</a></dt><dd><p>
|
| 225 |
+
Run the bootstrap backend with the
|
| 226 |
+
<code class="literal">debug_discard_caches=1</code> option.
|
| 227 |
+
This takes a very long time and is only of use for deep debugging.
|
| 228 |
+
</p></dd><dt id="APP-INITDB-OPTION-L"><span class="term"><code class="option">-L <em class="replaceable"><code>directory</code></em></code></span> <a href="#APP-INITDB-OPTION-L" class="id_link">#</a></dt><dd><p>
|
| 229 |
+
Specifies where <code class="command">initdb</code> should find
|
| 230 |
+
its input files to initialize the database cluster. This is
|
| 231 |
+
normally not necessary. You will be told if you need to
|
| 232 |
+
specify their location explicitly.
|
| 233 |
+
</p></dd><dt id="APP-INITDB-OPTION-NO-CLEAN"><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-clean</code></span> <a href="#APP-INITDB-OPTION-NO-CLEAN" class="id_link">#</a></dt><dd><p>
|
| 234 |
+
By default, when <code class="command">initdb</code>
|
| 235 |
+
determines that an error prevented it from completely creating the database
|
| 236 |
+
cluster, it removes any files it might have created before discovering
|
| 237 |
+
that it cannot finish the job. This option inhibits tidying-up and is
|
| 238 |
+
thus useful for debugging.
|
| 239 |
+
</p></dd></dl></div><p>
|
| 240 |
+
</p><p>
|
| 241 |
+
Other options:
|
| 242 |
+
|
| 243 |
+
</p><div class="variablelist"><dl class="variablelist"><dt id="APP-INITDB-OPTION-VERSION"><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span> <a href="#APP-INITDB-OPTION-VERSION" class="id_link">#</a></dt><dd><p>
|
| 244 |
+
Print the <span class="application">initdb</span> version and exit.
|
| 245 |
+
</p></dd><dt id="APP-INITDB-OPTION-HELP"><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span> <a href="#APP-INITDB-OPTION-HELP" class="id_link">#</a></dt><dd><p>
|
| 246 |
+
Show help about <span class="application">initdb</span> command line
|
| 247 |
+
arguments, and exit.
|
| 248 |
+
</p></dd></dl></div><p>
|
| 249 |
+
</p></div><div class="refsect1" id="id-1.9.5.3.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt id="APP-INITDB-ENVIRONMENT-PGDATA"><span class="term"><code class="envar">PGDATA</code></span> <a href="#APP-INITDB-ENVIRONMENT-PGDATA" class="id_link">#</a></dt><dd><p>
|
| 250 |
+
Specifies the directory where the database cluster is to be
|
| 251 |
+
stored; can be overridden using the <code class="option">-D</code> option.
|
| 252 |
+
</p></dd><dt id="APP-INITDB-ENVIRONMENT-PG-COLOR"><span class="term"><code class="envar">PG_COLOR</code></span> <a href="#APP-INITDB-ENVIRONMENT-PG-COLOR" class="id_link">#</a></dt><dd><p>
|
| 253 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 254 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 255 |
+
<code class="literal">never</code>.
|
| 256 |
+
</p></dd><dt id="APP-INITDB-ENVIRONMENT-TZ"><span class="term"><code class="envar">TZ</code></span> <a href="#APP-INITDB-ENVIRONMENT-TZ" class="id_link">#</a></dt><dd><p>
|
| 257 |
+
Specifies the default time zone of the created database cluster. The
|
| 258 |
+
value should be a full time zone name
|
| 259 |
+
(see <a class="xref" href="datatype-datetime.html#DATATYPE-TIMEZONES" title="8.5.3. Time Zones">Section 8.5.3</a>).
|
| 260 |
+
</p></dd></dl></div><p>
|
| 261 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 262 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 263 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 264 |
+
</p></div><div class="refsect1" id="id-1.9.5.3.8"><h2>Notes</h2><p>
|
| 265 |
+
<code class="command">initdb</code> can also be invoked via
|
| 266 |
+
<code class="command">pg_ctl initdb</code>.
|
| 267 |
+
</p></div><div class="refsect1" id="id-1.9.5.3.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a>, <a class="xref" href="app-postgres.html" title="postgres"><span class="refentrytitle"><span class="application">postgres</span></span></a>, <a class="xref" href="auth-pg-hba-conf.html" title="21.1. The pg_hba.conf File">Section 21.1</a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="reference-server.html" title="PostgreSQL Server Applications">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pgarchivecleanup.html" title="pg_archivecleanup">Next</a></td></tr><tr><td width="40%" align="left" valign="top">PostgreSQL Server Applications </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_archivecleanup</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pg-ctl.html
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_ctl</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgcontroldata.html" title="pg_controldata" /><link rel="next" href="app-pgresetwal.html" title="pg_resetwal" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_ctl</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgcontroldata.html" title="pg_controldata">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgresetwal.html" title="pg_resetwal">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PG-CTL"><div class="titlepage"></div><a id="id-1.9.5.7.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_ctl</span></span></h2><p>pg_ctl — initialize, start, stop, or control a <span class="productname">PostgreSQL</span> server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.7.4.1"><code class="command">pg_ctl</code> <code class="option">init[db]</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-s</code>] [<code class="option">-o</code> <em class="replaceable"><code>initdb-options</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.2"><code class="command">pg_ctl</code> <code class="option">start</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-l</code> <em class="replaceable"><code>filename</code></em>] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>] [<code class="option">-o</code> <em class="replaceable"><code>options</code></em>] [<code class="option">-p</code> <em class="replaceable"><code>path</code></em>] [<code class="option">-c</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.3"><code class="command">pg_ctl</code> <code class="option">stop</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-m</code>
|
| 3 |
+
<code class="option">s[mart]</code> | <code class="option">f[ast]</code> | <code class="option">i[mmediate]</code>
|
| 4 |
+
] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.4"><code class="command">pg_ctl</code> <code class="option">restart</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-m</code>
|
| 5 |
+
<code class="option">s[mart]</code> | <code class="option">f[ast]</code> | <code class="option">i[mmediate]</code>
|
| 6 |
+
] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>] [<code class="option">-o</code> <em class="replaceable"><code>options</code></em>] [<code class="option">-c</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.5"><code class="command">pg_ctl</code> <code class="option">reload</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-s</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.6"><code class="command">pg_ctl</code> <code class="option">status</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.7"><code class="command">pg_ctl</code> <code class="option">promote</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.8"><code class="command">pg_ctl</code> <code class="option">logrotate</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-s</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.9"><code class="command">pg_ctl</code> <code class="option">kill</code> <em class="replaceable"><code>signal_name</code></em> <em class="replaceable"><code>process_id</code></em> </p></div><p>On Microsoft Windows, also:</p><div class="cmdsynopsis"><p id="id-1.9.5.7.4.11"><code class="command">pg_ctl</code> <code class="option">register</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-N</code> <em class="replaceable"><code>servicename</code></em>] [<code class="option">-U</code> <em class="replaceable"><code>username</code></em>] [<code class="option">-P</code> <em class="replaceable"><code>password</code></em>] [<code class="option">-S</code>
|
| 7 |
+
<code class="option">a[uto]</code> | <code class="option">d[emand]</code>
|
| 8 |
+
] [<code class="option">-e</code> <em class="replaceable"><code>source</code></em>] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>] [<code class="option">-o</code> <em class="replaceable"><code>options</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.12"><code class="command">pg_ctl</code> <code class="option">unregister</code> [<code class="option">-N</code> <em class="replaceable"><code>servicename</code></em>]</p></div></div><div class="refsect1" id="APP-PG-CTL-DESCRIPTION"><h2>Description</h2><p>
|
| 9 |
+
<span class="application">pg_ctl</span> is a utility for initializing a
|
| 10 |
+
<span class="productname">PostgreSQL</span> database cluster, starting,
|
| 11 |
+
stopping, or restarting the <span class="productname">PostgreSQL</span>
|
| 12 |
+
database server (<a class="xref" href="app-postgres.html" title="postgres"><span class="refentrytitle"><span class="application">postgres</span></span></a>), or displaying the
|
| 13 |
+
status of a running server. Although the server can be started
|
| 14 |
+
manually, <span class="application">pg_ctl</span> encapsulates tasks such
|
| 15 |
+
as redirecting log output and properly detaching from the terminal
|
| 16 |
+
and process group. It also provides convenient options for
|
| 17 |
+
controlled shutdown.
|
| 18 |
+
</p><p>
|
| 19 |
+
The <code class="option">init</code> or <code class="option">initdb</code> mode creates a new
|
| 20 |
+
<span class="productname">PostgreSQL</span> database cluster, that is,
|
| 21 |
+
a collection of databases that will be managed by a single
|
| 22 |
+
server instance. This mode invokes the <code class="command">initdb</code>
|
| 23 |
+
command. See <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a> for details.
|
| 24 |
+
</p><p>
|
| 25 |
+
<code class="option">start</code> mode launches a new server. The
|
| 26 |
+
server is started in the background, and its standard input is attached
|
| 27 |
+
to <code class="filename">/dev/null</code> (or <code class="literal">nul</code> on Windows).
|
| 28 |
+
On Unix-like systems, by default, the server's standard output and
|
| 29 |
+
standard error are sent to <span class="application">pg_ctl</span>'s
|
| 30 |
+
standard output (not standard error). The standard output of
|
| 31 |
+
<span class="application">pg_ctl</span> should then be redirected to a
|
| 32 |
+
file or piped to another process such as a log rotating program
|
| 33 |
+
like <span class="application">rotatelogs</span>; otherwise <code class="command">postgres</code>
|
| 34 |
+
will write its output to the controlling terminal (from the
|
| 35 |
+
background) and will not leave the shell's process group. On
|
| 36 |
+
Windows, by default the server's standard output and standard error
|
| 37 |
+
are sent to the terminal. These default behaviors can be changed
|
| 38 |
+
by using <code class="option">-l</code> to append the server's output to a log file.
|
| 39 |
+
Use of either <code class="option">-l</code> or output redirection is recommended.
|
| 40 |
+
</p><p>
|
| 41 |
+
<code class="option">stop</code> mode shuts down the server that is running in
|
| 42 |
+
the specified data directory. Three different
|
| 43 |
+
shutdown methods can be selected with the <code class="option">-m</code>
|
| 44 |
+
option. <span class="quote">“<span class="quote">Smart</span>”</span> mode disallows new connections, then waits
|
| 45 |
+
for all existing clients to disconnect.
|
| 46 |
+
If the server is in hot standby, recovery and streaming replication
|
| 47 |
+
will be terminated once all clients have disconnected.
|
| 48 |
+
<span class="quote">“<span class="quote">Fast</span>”</span> mode (the default) does not wait for clients to disconnect.
|
| 49 |
+
All active transactions are
|
| 50 |
+
rolled back and clients are forcibly disconnected, then the
|
| 51 |
+
server is shut down. <span class="quote">“<span class="quote">Immediate</span>”</span> mode will abort
|
| 52 |
+
all server processes immediately, without a clean shutdown. This choice
|
| 53 |
+
will lead to a crash-recovery cycle during the next server start.
|
| 54 |
+
</p><p>
|
| 55 |
+
<code class="option">restart</code> mode effectively executes a stop followed
|
| 56 |
+
by a start. This allows changing the <code class="command">postgres</code>
|
| 57 |
+
command-line options, or changing configuration-file options that
|
| 58 |
+
cannot be changed without restarting the server.
|
| 59 |
+
If relative paths were used on the command line during server
|
| 60 |
+
start, <code class="option">restart</code> might fail unless
|
| 61 |
+
<span class="application">pg_ctl</span> is executed in the same current
|
| 62 |
+
directory as it was during server start.
|
| 63 |
+
</p><p>
|
| 64 |
+
<code class="option">reload</code> mode simply sends the
|
| 65 |
+
<code class="command">postgres</code> server process a <span class="systemitem">SIGHUP</span>
|
| 66 |
+
signal, causing it to reread its configuration files
|
| 67 |
+
(<code class="filename">postgresql.conf</code>,
|
| 68 |
+
<code class="filename">pg_hba.conf</code>, etc.). This allows changing
|
| 69 |
+
configuration-file options that do not require a full server restart
|
| 70 |
+
to take effect.
|
| 71 |
+
</p><p>
|
| 72 |
+
<code class="option">status</code> mode checks whether a server is running in
|
| 73 |
+
the specified data directory. If it is, the server's <acronym class="acronym">PID</acronym>
|
| 74 |
+
and the command line options that were used to invoke it are displayed.
|
| 75 |
+
If the server is not running, <span class="application">pg_ctl</span> returns
|
| 76 |
+
an exit status of 3. If an accessible data directory is not
|
| 77 |
+
specified, <span class="application">pg_ctl</span> returns an exit status of 4.
|
| 78 |
+
</p><p>
|
| 79 |
+
<code class="option">promote</code> mode commands the standby server that is
|
| 80 |
+
running in the specified data directory to end standby mode
|
| 81 |
+
and begin read-write operations.
|
| 82 |
+
</p><p>
|
| 83 |
+
<code class="option">logrotate</code> mode rotates the server log file.
|
| 84 |
+
For details on how to use this mode with external log rotation tools, see
|
| 85 |
+
<a class="xref" href="logfile-maintenance.html" title="25.3. Log File Maintenance">Section 25.3</a>.
|
| 86 |
+
</p><p>
|
| 87 |
+
<code class="option">kill</code> mode sends a signal to a specified process.
|
| 88 |
+
This is primarily valuable on <span class="productname">Microsoft Windows</span>
|
| 89 |
+
which does not have a built-in <span class="application">kill</span> command. Use
|
| 90 |
+
<code class="literal">--help</code> to see a list of supported signal names.
|
| 91 |
+
</p><p>
|
| 92 |
+
<code class="option">register</code> mode registers the <span class="productname">PostgreSQL</span>
|
| 93 |
+
server as a system service on <span class="productname">Microsoft Windows</span>.
|
| 94 |
+
The <code class="option">-S</code> option allows selection of service start type,
|
| 95 |
+
either <span class="quote">“<span class="quote">auto</span>”</span> (start service automatically on system startup)
|
| 96 |
+
or <span class="quote">“<span class="quote">demand</span>”</span> (start service on demand).
|
| 97 |
+
</p><p>
|
| 98 |
+
<code class="option">unregister</code> mode unregisters a system service
|
| 99 |
+
on <span class="productname">Microsoft Windows</span>. This undoes the effects of the
|
| 100 |
+
<code class="option">register</code> command.
|
| 101 |
+
</p></div><div class="refsect1" id="APP-PG-CTL-OPTIONS"><h2>Options</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--core-files</code></span></dt><dd><p>
|
| 102 |
+
Attempt to allow server crashes to produce core files, on platforms
|
| 103 |
+
where this is possible, by lifting any soft resource limit placed on
|
| 104 |
+
core files.
|
| 105 |
+
This is useful in debugging or diagnosing problems by allowing a
|
| 106 |
+
stack trace to be obtained from a failed server process.
|
| 107 |
+
</p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>datadir</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>datadir</code></em></code></span></dt><dd><p>
|
| 108 |
+
Specifies the file system location of the database configuration files. If
|
| 109 |
+
this option is omitted, the environment variable
|
| 110 |
+
<code class="envar">PGDATA</code> is used.
|
| 111 |
+
</p></dd><dt><span class="term"><code class="option">-l <em class="replaceable"><code>filename</code></em></code><br /></span><span class="term"><code class="option">--log=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
|
| 112 |
+
Append the server log output to
|
| 113 |
+
<em class="replaceable"><code>filename</code></em>. If the file does not
|
| 114 |
+
exist, it is created. The <span class="systemitem">umask</span> is set to 077,
|
| 115 |
+
so access to the log file is disallowed to other users by default.
|
| 116 |
+
</p></dd><dt><span class="term"><code class="option">-m <em class="replaceable"><code>mode</code></em></code><br /></span><span class="term"><code class="option">--mode=<em class="replaceable"><code>mode</code></em></code></span></dt><dd><p>
|
| 117 |
+
Specifies the shutdown mode. <em class="replaceable"><code>mode</code></em>
|
| 118 |
+
can be <code class="literal">smart</code>, <code class="literal">fast</code>, or
|
| 119 |
+
<code class="literal">immediate</code>, or the first letter of one of
|
| 120 |
+
these three. If this option is omitted, <code class="literal">fast</code> is
|
| 121 |
+
the default.
|
| 122 |
+
</p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>options</code></em></code><br /></span><span class="term"><code class="option">--options=<em class="replaceable"><code>options</code></em></code></span></dt><dd><p>
|
| 123 |
+
Specifies options to be passed directly to the
|
| 124 |
+
<code class="command">postgres</code> command.
|
| 125 |
+
<code class="option">-o</code> can be specified multiple times, with all the given
|
| 126 |
+
options being passed through.
|
| 127 |
+
</p><p>
|
| 128 |
+
The <em class="replaceable"><code>options</code></em> should usually be surrounded by single or
|
| 129 |
+
double quotes to ensure that they are passed through as a group.
|
| 130 |
+
</p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>initdb-options</code></em></code><br /></span><span class="term"><code class="option">--options=<em class="replaceable"><code>initdb-options</code></em></code></span></dt><dd><p>
|
| 131 |
+
Specifies options to be passed directly to the
|
| 132 |
+
<code class="command">initdb</code> command.
|
| 133 |
+
<code class="option">-o</code> can be specified multiple times, with all the given
|
| 134 |
+
options being passed through.
|
| 135 |
+
</p><p>
|
| 136 |
+
The <em class="replaceable"><code>initdb-options</code></em> should usually be surrounded by single or
|
| 137 |
+
double quotes to ensure that they are passed through as a group.
|
| 138 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>path</code></em></code></span></dt><dd><p>
|
| 139 |
+
Specifies the location of the <code class="filename">postgres</code>
|
| 140 |
+
executable. By default the <code class="filename">postgres</code> executable is taken from the same
|
| 141 |
+
directory as <code class="command">pg_ctl</code>, or failing that, the hard-wired
|
| 142 |
+
installation directory. It is not necessary to use this
|
| 143 |
+
option unless you are doing something unusual and get errors
|
| 144 |
+
that the <code class="filename">postgres</code> executable was not found.
|
| 145 |
+
</p><p>
|
| 146 |
+
In <code class="literal">init</code> mode, this option analogously
|
| 147 |
+
specifies the location of the <code class="filename">initdb</code>
|
| 148 |
+
executable.
|
| 149 |
+
</p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--silent</code></span></dt><dd><p>
|
| 150 |
+
Print only errors, no informational messages.
|
| 151 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>seconds</code></em></code><br /></span><span class="term"><code class="option">--timeout=<em class="replaceable"><code>seconds</code></em></code></span></dt><dd><p>
|
| 152 |
+
Specifies the maximum number of seconds to wait when waiting for an
|
| 153 |
+
operation to complete (see option <code class="option">-w</code>). Defaults to
|
| 154 |
+
the value of the <code class="envar">PGCTLTIMEOUT</code> environment variable or, if
|
| 155 |
+
not set, to 60 seconds.
|
| 156 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 157 |
+
Print the <span class="application">pg_ctl</span> version and exit.
|
| 158 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--wait</code></span></dt><dd><p>
|
| 159 |
+
Wait for the operation to complete. This is supported for the
|
| 160 |
+
modes <code class="literal">start</code>, <code class="literal">stop</code>,
|
| 161 |
+
<code class="literal">restart</code>, <code class="literal">promote</code>,
|
| 162 |
+
and <code class="literal">register</code>, and is the default for those modes.
|
| 163 |
+
</p><p>
|
| 164 |
+
When waiting, <code class="command">pg_ctl</code> repeatedly checks the
|
| 165 |
+
server's <acronym class="acronym">PID</acronym> file, sleeping for a short amount
|
| 166 |
+
of time between checks. Startup is considered complete when
|
| 167 |
+
the <acronym class="acronym">PID</acronym> file indicates that the server is ready to
|
| 168 |
+
accept connections. Shutdown is considered complete when the server
|
| 169 |
+
removes the <acronym class="acronym">PID</acronym> file.
|
| 170 |
+
<code class="command">pg_ctl</code> returns an exit code based on the
|
| 171 |
+
success of the startup or shutdown.
|
| 172 |
+
</p><p>
|
| 173 |
+
If the operation does not complete within the timeout (see
|
| 174 |
+
option <code class="option">-t</code>), then <code class="command">pg_ctl</code> exits with
|
| 175 |
+
a nonzero exit status. But note that the operation might continue in
|
| 176 |
+
the background and eventually succeed.
|
| 177 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--no-wait</code></span></dt><dd><p>
|
| 178 |
+
Do not wait for the operation to complete. This is the opposite of
|
| 179 |
+
the option <code class="option">-w</code>.
|
| 180 |
+
</p><p>
|
| 181 |
+
If waiting is disabled, the requested action is triggered, but there
|
| 182 |
+
is no feedback about its success. In that case, the server log file
|
| 183 |
+
or an external monitoring system would have to be used to check the
|
| 184 |
+
progress and success of the operation.
|
| 185 |
+
</p><p>
|
| 186 |
+
In prior releases of PostgreSQL, this was the default except for
|
| 187 |
+
the <code class="literal">stop</code> mode.
|
| 188 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 189 |
+
Show help about <span class="application">pg_ctl</span> command line
|
| 190 |
+
arguments, and exit.
|
| 191 |
+
</p></dd></dl></div><p>
|
| 192 |
+
If an option is specified that is valid, but not relevant to the selected
|
| 193 |
+
operating mode, <span class="application">pg_ctl</span> ignores it.
|
| 194 |
+
</p><div class="refsect2" id="APP-PG-CTL-WINDOWS-OPTIONS"><h3>Options for Windows</h3><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-e <em class="replaceable"><code>source</code></em></code></span></dt><dd><p>
|
| 195 |
+
Name of the event source for <span class="application">pg_ctl</span> to use
|
| 196 |
+
for logging to the event log when running as a Windows service. The
|
| 197 |
+
default is <code class="literal">PostgreSQL</code>. Note that this only controls
|
| 198 |
+
messages sent from <span class="application">pg_ctl</span> itself; once
|
| 199 |
+
started, the server will use the event source specified
|
| 200 |
+
by its <a class="xref" href="runtime-config-logging.html#GUC-EVENT-SOURCE">event_source</a> parameter. Should the server
|
| 201 |
+
fail very early in startup, before that parameter has been set,
|
| 202 |
+
it might also log using the default event
|
| 203 |
+
source name <code class="literal">PostgreSQL</code>.
|
| 204 |
+
</p></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>servicename</code></em></code></span></dt><dd><p>
|
| 205 |
+
Name of the system service to register. This name will be used
|
| 206 |
+
as both the service name and the display name.
|
| 207 |
+
The default is <code class="literal">PostgreSQL</code>.
|
| 208 |
+
</p></dd><dt><span class="term"><code class="option">-P <em class="replaceable"><code>password</code></em></code></span></dt><dd><p>
|
| 209 |
+
Password for the user to run the service as.
|
| 210 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>start-type</code></em></code></span></dt><dd><p>
|
| 211 |
+
Start type of the system service. <em class="replaceable"><code>start-type</code></em> can
|
| 212 |
+
be <code class="literal">auto</code>, or <code class="literal">demand</code>, or
|
| 213 |
+
the first letter of one of these two. If this option is omitted,
|
| 214 |
+
<code class="literal">auto</code> is the default.
|
| 215 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 216 |
+
User name for the user to run the service as. For domain users, use the
|
| 217 |
+
format <code class="literal">DOMAIN\username</code>.
|
| 218 |
+
</p></dd></dl></div></div></div><div class="refsect1" id="id-1.9.5.7.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGCTLTIMEOUT</code></span></dt><dd><p>
|
| 219 |
+
Default limit on the number of seconds to wait when waiting for startup
|
| 220 |
+
or shutdown to complete. If not set, the default is 60 seconds.
|
| 221 |
+
</p></dd><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>
|
| 222 |
+
Default data directory location.
|
| 223 |
+
</p></dd></dl></div><p>
|
| 224 |
+
Most <code class="command">pg_ctl</code> modes require knowing the data directory
|
| 225 |
+
location; therefore, the <code class="option">-D</code> option is required
|
| 226 |
+
unless <code class="envar">PGDATA</code> is set.
|
| 227 |
+
</p><p>
|
| 228 |
+
<code class="command">pg_ctl</code>, like most other <span class="productname">PostgreSQL</span>
|
| 229 |
+
utilities,
|
| 230 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 231 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 232 |
+
</p><p>
|
| 233 |
+
For additional variables that affect the server,
|
| 234 |
+
see <a class="xref" href="app-postgres.html" title="postgres"><span class="refentrytitle"><span class="application">postgres</span></span></a>.
|
| 235 |
+
</p></div><div class="refsect1" id="id-1.9.5.7.8"><h2>Files</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="filename">postmaster.pid</code></span></dt><dd><p>
|
| 236 |
+
<span class="application">pg_ctl</span> examines this file in the data
|
| 237 |
+
directory to determine whether the server is currently running.
|
| 238 |
+
</p></dd><dt><span class="term"><code class="filename">postmaster.opts</code></span></dt><dd><p>If this file exists in the data directory,
|
| 239 |
+
<span class="application">pg_ctl</span> (in <code class="option">restart</code> mode)
|
| 240 |
+
will pass the contents of the file as options to
|
| 241 |
+
<span class="application">postgres</span>, unless overridden
|
| 242 |
+
by the <code class="option">-o</code> option. The contents of this file
|
| 243 |
+
are also displayed in <code class="option">status</code> mode.
|
| 244 |
+
</p></dd></dl></div></div><div class="refsect1" id="R1-APP-PGCTL-2"><h2>Examples</h2><div class="refsect2" id="R2-APP-PGCTL-3"><h3>Starting the Server</h3><p>
|
| 245 |
+
To start the server, waiting until the server is
|
| 246 |
+
accepting connections:
|
| 247 |
+
</p><pre class="screen">
|
| 248 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_ctl start</code></strong>
|
| 249 |
+
</pre><p>
|
| 250 |
+
</p><p>
|
| 251 |
+
To start the server using port 5433, and
|
| 252 |
+
running without <code class="function">fsync</code>, use:
|
| 253 |
+
</p><pre class="screen">
|
| 254 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_ctl -o "-F -p 5433" start</code></strong>
|
| 255 |
+
</pre></div><div class="refsect2" id="R2-APP-PGCTL-4"><h3>Stopping the Server</h3><p>
|
| 256 |
+
To stop the server, use:
|
| 257 |
+
</p><pre class="screen">
|
| 258 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_ctl stop</code></strong>
|
| 259 |
+
</pre><p>
|
| 260 |
+
The <code class="option">-m</code> option allows control over
|
| 261 |
+
<span class="emphasis"><em>how</em></span> the server shuts down:
|
| 262 |
+
</p><pre class="screen">
|
| 263 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_ctl stop -m smart</code></strong>
|
| 264 |
+
</pre></div><div class="refsect2" id="R2-APP-PGCTL-5"><h3>Restarting the Server</h3><p>
|
| 265 |
+
Restarting the server is almost equivalent to stopping the
|
| 266 |
+
server and starting it again, except that by default,
|
| 267 |
+
<code class="command">pg_ctl</code> saves and reuses the command line options that
|
| 268 |
+
were passed to the previously-running instance. To restart
|
| 269 |
+
the server using the same options as before, use:
|
| 270 |
+
</p><pre class="screen">
|
| 271 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_ctl restart</code></strong>
|
| 272 |
+
</pre><p>
|
| 273 |
+
</p><p>
|
| 274 |
+
But if <code class="option">-o</code> is specified, that replaces any previous options.
|
| 275 |
+
To restart using port 5433, disabling <code class="function">fsync</code> upon restart:
|
| 276 |
+
</p><pre class="screen">
|
| 277 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_ctl -o "-F -p 5433" restart</code></strong>
|
| 278 |
+
</pre></div><div class="refsect2" id="R2-APP-PGCTL-6"><h3>Showing the Server Status</h3><p>
|
| 279 |
+
Here is sample status output from
|
| 280 |
+
<span class="application">pg_ctl</span>:
|
| 281 |
+
</p><pre class="screen">
|
| 282 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_ctl status</code></strong>
|
| 283 |
+
<code class="computeroutput">
|
| 284 |
+
pg_ctl: server is running (PID: 13718)
|
| 285 |
+
/usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data" "-p" "5433" "-B" "128"
|
| 286 |
+
</code></pre><p>
|
| 287 |
+
The second line is the command that would be invoked in restart mode.
|
| 288 |
+
</p></div></div><div class="refsect1" id="id-1.9.5.7.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a>, <a class="xref" href="app-postgres.html" title="postgres"><span class="refentrytitle"><span class="application">postgres</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgcontroldata.html" title="pg_controldata">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgresetwal.html" title="pg_resetwal">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_controldata</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_resetwal</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pg-dumpall.html
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_dumpall</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgdump.html" title="pg_dump" /><link rel="next" href="app-pg-isready.html" title="pg_isready" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_dumpall</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgdump.html" title="pg_dump">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pg-isready.html" title="pg_isready">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PG-DUMPALL"><div class="titlepage"></div><a id="id-1.9.4.14.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_dumpall</span></span></h2><p>pg_dumpall — extract a <span class="productname">PostgreSQL</span> database cluster into a script file</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.14.4.1"><code class="command">pg_dumpall</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="APP-PG-DUMPALL-DESCRIPTION"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">pg_dumpall</span> is a utility for writing out
|
| 4 |
+
(<span class="quote">“<span class="quote">dumping</span>”</span>) all <span class="productname">PostgreSQL</span> databases
|
| 5 |
+
of a cluster into one script file. The script file contains
|
| 6 |
+
<acronym class="acronym">SQL</acronym> commands that can be used as input to <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> to restore the databases. It does this by
|
| 7 |
+
calling <a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a> for each database in the cluster.
|
| 8 |
+
<span class="application">pg_dumpall</span> also dumps global objects
|
| 9 |
+
that are common to all databases, namely database roles, tablespaces,
|
| 10 |
+
and privilege grants for configuration parameters.
|
| 11 |
+
(<span class="application">pg_dump</span> does not save these objects.)
|
| 12 |
+
</p><p>
|
| 13 |
+
Since <span class="application">pg_dumpall</span> reads tables from all
|
| 14 |
+
databases you will most likely have to connect as a database
|
| 15 |
+
superuser in order to produce a complete dump. Also you will need
|
| 16 |
+
superuser privileges to execute the saved script in order to be
|
| 17 |
+
allowed to add roles and create databases.
|
| 18 |
+
</p><p>
|
| 19 |
+
The SQL script will be written to the standard output. Use the
|
| 20 |
+
<code class="option">-f</code>/<code class="option">--file</code> option or shell operators to
|
| 21 |
+
redirect it into a file.
|
| 22 |
+
</p><p>
|
| 23 |
+
<span class="application">pg_dumpall</span> needs to connect several
|
| 24 |
+
times to the <span class="productname">PostgreSQL</span> server (once per
|
| 25 |
+
database). If you use password authentication it will ask for
|
| 26 |
+
a password each time. It is convenient to have a
|
| 27 |
+
<code class="filename">~/.pgpass</code> file in such cases. See <a class="xref" href="libpq-pgpass.html" title="34.16. The Password File">Section 34.16</a> for more information.
|
| 28 |
+
</p></div><div class="refsect1" id="id-1.9.4.14.6"><h2>Options</h2><p>
|
| 29 |
+
The following command-line options control the content and
|
| 30 |
+
format of the output.
|
| 31 |
+
|
| 32 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--data-only</code></span></dt><dd><p>
|
| 33 |
+
Dump only the data, not the schema (data definitions).
|
| 34 |
+
</p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--clean</code></span></dt><dd><p>
|
| 35 |
+
Emit SQL commands to <code class="command">DROP</code> all the dumped
|
| 36 |
+
databases, roles, and tablespaces before recreating them.
|
| 37 |
+
This option is useful when the restore is to overwrite an existing
|
| 38 |
+
cluster. If any of the objects do not exist in the destination
|
| 39 |
+
cluster, ignorable error messages will be reported during
|
| 40 |
+
restore, unless <code class="option">--if-exists</code> is also specified.
|
| 41 |
+
</p></dd><dt><span class="term"><code class="option">-E <em class="replaceable"><code>encoding</code></em></code><br /></span><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span></dt><dd><p>
|
| 42 |
+
Create the dump in the specified character set encoding. By default,
|
| 43 |
+
the dump is created in the database encoding. (Another way to get the
|
| 44 |
+
same result is to set the <code class="envar">PGCLIENTENCODING</code> environment
|
| 45 |
+
variable to the desired dump encoding.)
|
| 46 |
+
</p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>filename</code></em></code><br /></span><span class="term"><code class="option">--file=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
|
| 47 |
+
Send output to the specified file. If this is omitted, the
|
| 48 |
+
standard output is used.
|
| 49 |
+
</p></dd><dt><span class="term"><code class="option">-g</code><br /></span><span class="term"><code class="option">--globals-only</code></span></dt><dd><p>
|
| 50 |
+
Dump only global objects (roles and tablespaces), no databases.
|
| 51 |
+
</p></dd><dt><span class="term"><code class="option">-O</code><br /></span><span class="term"><code class="option">--no-owner</code></span></dt><dd><p>
|
| 52 |
+
Do not output commands to set
|
| 53 |
+
ownership of objects to match the original database.
|
| 54 |
+
By default, <span class="application">pg_dumpall</span> issues
|
| 55 |
+
<code class="command">ALTER OWNER</code> or
|
| 56 |
+
<code class="command">SET SESSION AUTHORIZATION</code>
|
| 57 |
+
statements to set ownership of created schema elements.
|
| 58 |
+
These statements
|
| 59 |
+
will fail when the script is run unless it is started by a superuser
|
| 60 |
+
(or the same user that owns all of the objects in the script).
|
| 61 |
+
To make a script that can be restored by any user, but will give
|
| 62 |
+
that user ownership of all the objects, specify <code class="option">-O</code>.
|
| 63 |
+
</p></dd><dt><span class="term"><code class="option">-r</code><br /></span><span class="term"><code class="option">--roles-only</code></span></dt><dd><p>
|
| 64 |
+
Dump only roles, no databases or tablespaces.
|
| 65 |
+
</p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--schema-only</code></span></dt><dd><p>
|
| 66 |
+
Dump only the object definitions (schema), not data.
|
| 67 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--superuser=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 68 |
+
Specify the superuser user name to use when disabling triggers.
|
| 69 |
+
This is relevant only if <code class="option">--disable-triggers</code> is used.
|
| 70 |
+
(Usually, it's better to leave this out, and instead start the
|
| 71 |
+
resulting script as superuser.)
|
| 72 |
+
</p></dd><dt><span class="term"><code class="option">-t</code><br /></span><span class="term"><code class="option">--tablespaces-only</code></span></dt><dd><p>
|
| 73 |
+
Dump only tablespaces, no databases or roles.
|
| 74 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 75 |
+
Specifies verbose mode. This will cause
|
| 76 |
+
<span class="application">pg_dumpall</span> to output start/stop
|
| 77 |
+
times to the dump file, and progress messages to standard error.
|
| 78 |
+
Repeating the option causes additional debug-level messages
|
| 79 |
+
to appear on standard error.
|
| 80 |
+
The option is also passed down to <span class="application">pg_dump</span>.
|
| 81 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 82 |
+
Print the <span class="application">pg_dumpall</span> version and exit.
|
| 83 |
+
</p></dd><dt><span class="term"><code class="option">-x</code><br /></span><span class="term"><code class="option">--no-privileges</code><br /></span><span class="term"><code class="option">--no-acl</code></span></dt><dd><p>
|
| 84 |
+
Prevent dumping of access privileges (grant/revoke commands).
|
| 85 |
+
</p></dd><dt><span class="term"><code class="option">--binary-upgrade</code></span></dt><dd><p>
|
| 86 |
+
This option is for use by in-place upgrade utilities. Its use
|
| 87 |
+
for other purposes is not recommended or supported. The
|
| 88 |
+
behavior of the option may change in future releases without
|
| 89 |
+
notice.
|
| 90 |
+
</p></dd><dt><span class="term"><code class="option">--column-inserts</code><br /></span><span class="term"><code class="option">--attribute-inserts</code></span></dt><dd><p>
|
| 91 |
+
Dump data as <code class="command">INSERT</code> commands with explicit
|
| 92 |
+
column names (<code class="literal">INSERT INTO
|
| 93 |
+
<em class="replaceable"><code>table</code></em>
|
| 94 |
+
(<em class="replaceable"><code>column</code></em>, ...) VALUES
|
| 95 |
+
...</code>). This will make restoration very slow; it is mainly
|
| 96 |
+
useful for making dumps that can be loaded into
|
| 97 |
+
non-<span class="productname">PostgreSQL</span> databases.
|
| 98 |
+
</p></dd><dt><span class="term"><code class="option">--disable-dollar-quoting</code></span></dt><dd><p>
|
| 99 |
+
This option disables the use of dollar quoting for function bodies,
|
| 100 |
+
and forces them to be quoted using SQL standard string syntax.
|
| 101 |
+
</p></dd><dt><span class="term"><code class="option">--disable-triggers</code></span></dt><dd><p>
|
| 102 |
+
This option is relevant only when creating a data-only dump.
|
| 103 |
+
It instructs <span class="application">pg_dumpall</span> to include commands
|
| 104 |
+
to temporarily disable triggers on the target tables while
|
| 105 |
+
the data is restored. Use this if you have referential
|
| 106 |
+
integrity checks or other triggers on the tables that you
|
| 107 |
+
do not want to invoke during data restore.
|
| 108 |
+
</p><p>
|
| 109 |
+
Presently, the commands emitted for <code class="option">--disable-triggers</code>
|
| 110 |
+
must be done as superuser. So, you should also specify
|
| 111 |
+
a superuser name with <code class="option">-S</code>, or preferably be careful to
|
| 112 |
+
start the resulting script as a superuser.
|
| 113 |
+
</p></dd><dt><span class="term"><code class="option">--exclude-database=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 114 |
+
Do not dump databases whose name matches
|
| 115 |
+
<em class="replaceable"><code>pattern</code></em>.
|
| 116 |
+
Multiple patterns can be excluded by writing multiple
|
| 117 |
+
<code class="option">--exclude-database</code> switches. The
|
| 118 |
+
<em class="replaceable"><code>pattern</code></em> parameter is
|
| 119 |
+
interpreted as a pattern according to the same rules used by
|
| 120 |
+
<span class="application">psql</span>'s <code class="literal">\d</code>
|
| 121 |
+
commands (see <a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns">Patterns</a>),
|
| 122 |
+
so multiple databases can also be excluded by writing wildcard
|
| 123 |
+
characters in the pattern. When using wildcards, be careful to
|
| 124 |
+
quote the pattern if needed to prevent shell wildcard expansion.
|
| 125 |
+
</p></dd><dt><span class="term"><code class="option">--extra-float-digits=<em class="replaceable"><code>ndigits</code></em></code></span></dt><dd><p>
|
| 126 |
+
Use the specified value of extra_float_digits when dumping
|
| 127 |
+
floating-point data, instead of the maximum available precision.
|
| 128 |
+
Routine dumps made for backup purposes should not use this option.
|
| 129 |
+
</p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>
|
| 130 |
+
Use <code class="literal">DROP ... IF EXISTS</code> commands to drop objects
|
| 131 |
+
in <code class="option">--clean</code> mode. This suppresses <span class="quote">“<span class="quote">does not
|
| 132 |
+
exist</span>”</span> errors that might otherwise be reported. This
|
| 133 |
+
option is not valid unless <code class="option">--clean</code> is also
|
| 134 |
+
specified.
|
| 135 |
+
</p></dd><dt><span class="term"><code class="option">--inserts</code></span></dt><dd><p>
|
| 136 |
+
Dump data as <code class="command">INSERT</code> commands (rather
|
| 137 |
+
than <code class="command">COPY</code>). This will make restoration very slow;
|
| 138 |
+
it is mainly useful for making dumps that can be loaded into
|
| 139 |
+
non-<span class="productname">PostgreSQL</span> databases. Note that
|
| 140 |
+
the restore might fail altogether if you have rearranged column order.
|
| 141 |
+
The <code class="option">--column-inserts</code> option is safer, though even
|
| 142 |
+
slower.
|
| 143 |
+
</p></dd><dt><span class="term"><code class="option">--load-via-partition-root</code></span></dt><dd><p>
|
| 144 |
+
When dumping data for a table partition, make
|
| 145 |
+
the <code class="command">COPY</code> or <code class="command">INSERT</code> statements
|
| 146 |
+
target the root of the partitioning hierarchy that contains it, rather
|
| 147 |
+
than the partition itself. This causes the appropriate partition to
|
| 148 |
+
be re-determined for each row when the data is loaded. This may be
|
| 149 |
+
useful when restoring data on a server where rows do not always fall
|
| 150 |
+
into the same partitions as they did on the original server. That
|
| 151 |
+
could happen, for example, if the partitioning column is of type text
|
| 152 |
+
and the two systems have different definitions of the collation used
|
| 153 |
+
to sort the partitioning column.
|
| 154 |
+
</p></dd><dt><span class="term"><code class="option">--lock-wait-timeout=<em class="replaceable"><code>timeout</code></em></code></span></dt><dd><p>
|
| 155 |
+
Do not wait forever to acquire shared table locks at the beginning of
|
| 156 |
+
the dump. Instead, fail if unable to lock a table within the specified
|
| 157 |
+
<em class="replaceable"><code>timeout</code></em>. The timeout may be
|
| 158 |
+
specified in any of the formats accepted by <code class="command">SET
|
| 159 |
+
statement_timeout</code>.
|
| 160 |
+
</p></dd><dt><span class="term"><code class="option">--no-comments</code></span></dt><dd><p>
|
| 161 |
+
Do not dump comments.
|
| 162 |
+
</p></dd><dt><span class="term"><code class="option">--no-publications</code></span></dt><dd><p>
|
| 163 |
+
Do not dump publications.
|
| 164 |
+
</p></dd><dt><span class="term"><code class="option">--no-role-passwords</code></span></dt><dd><p>
|
| 165 |
+
Do not dump passwords for roles. When restored, roles will have a
|
| 166 |
+
null password, and password authentication will always fail until the
|
| 167 |
+
password is set. Since password values aren't needed when this option
|
| 168 |
+
is specified, the role information is read from the catalog
|
| 169 |
+
view <code class="structname">pg_roles</code> instead
|
| 170 |
+
of <code class="structname">pg_authid</code>. Therefore, this option also
|
| 171 |
+
helps if access to <code class="structname">pg_authid</code> is restricted by
|
| 172 |
+
some security policy.
|
| 173 |
+
</p></dd><dt><span class="term"><code class="option">--no-security-labels</code></span></dt><dd><p>
|
| 174 |
+
Do not dump security labels.
|
| 175 |
+
</p></dd><dt><span class="term"><code class="option">--no-subscriptions</code></span></dt><dd><p>
|
| 176 |
+
Do not dump subscriptions.
|
| 177 |
+
</p></dd><dt><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>
|
| 178 |
+
By default, <code class="command">pg_dumpall</code> will wait for all files
|
| 179 |
+
to be written safely to disk. This option causes
|
| 180 |
+
<code class="command">pg_dumpall</code> to return without waiting, which is
|
| 181 |
+
faster, but means that a subsequent operating system crash can leave
|
| 182 |
+
the dump corrupt. Generally, this option is useful for testing
|
| 183 |
+
but should not be used when dumping data from production installation.
|
| 184 |
+
</p></dd><dt><span class="term"><code class="option">--no-table-access-method</code></span></dt><dd><p>
|
| 185 |
+
Do not output commands to select table access methods.
|
| 186 |
+
With this option, all objects will be created with whichever
|
| 187 |
+
table access method is the default during restore.
|
| 188 |
+
</p></dd><dt><span class="term"><code class="option">--no-tablespaces</code></span></dt><dd><p>
|
| 189 |
+
Do not output commands to create tablespaces nor select tablespaces
|
| 190 |
+
for objects.
|
| 191 |
+
With this option, all objects will be created in whichever
|
| 192 |
+
tablespace is the default during restore.
|
| 193 |
+
</p></dd><dt><span class="term"><code class="option">--no-toast-compression</code></span></dt><dd><p>
|
| 194 |
+
Do not output commands to set <acronym class="acronym">TOAST</acronym> compression
|
| 195 |
+
methods.
|
| 196 |
+
With this option, all columns will be restored with the default
|
| 197 |
+
compression setting.
|
| 198 |
+
</p></dd><dt><span class="term"><code class="option">--no-unlogged-table-data</code></span></dt><dd><p>
|
| 199 |
+
Do not dump the contents of unlogged tables. This option has no
|
| 200 |
+
effect on whether or not the table definitions (schema) are dumped;
|
| 201 |
+
it only suppresses dumping the table data.
|
| 202 |
+
</p></dd><dt><span class="term"><code class="option">--on-conflict-do-nothing</code></span></dt><dd><p>
|
| 203 |
+
Add <code class="literal">ON CONFLICT DO NOTHING</code> to
|
| 204 |
+
<code class="command">INSERT</code> commands.
|
| 205 |
+
This option is not valid unless <code class="option">--inserts</code> or
|
| 206 |
+
<code class="option">--column-inserts</code> is also specified.
|
| 207 |
+
</p></dd><dt><span class="term"><code class="option">--quote-all-identifiers</code></span></dt><dd><p>
|
| 208 |
+
Force quoting of all identifiers. This option is recommended when
|
| 209 |
+
dumping a database from a server whose <span class="productname">PostgreSQL</span>
|
| 210 |
+
major version is different from <span class="application">pg_dumpall</span>'s, or when
|
| 211 |
+
the output is intended to be loaded into a server of a different
|
| 212 |
+
major version. By default, <span class="application">pg_dumpall</span> quotes only
|
| 213 |
+
identifiers that are reserved words in its own major version.
|
| 214 |
+
This sometimes results in compatibility issues when dealing with
|
| 215 |
+
servers of other versions that may have slightly different sets
|
| 216 |
+
of reserved words. Using <code class="option">--quote-all-identifiers</code> prevents
|
| 217 |
+
such issues, at the price of a harder-to-read dump script.
|
| 218 |
+
</p></dd><dt><span class="term"><code class="option">--rows-per-insert=<em class="replaceable"><code>nrows</code></em></code></span></dt><dd><p>
|
| 219 |
+
Dump data as <code class="command">INSERT</code> commands (rather than
|
| 220 |
+
<code class="command">COPY</code>). Controls the maximum number of rows per
|
| 221 |
+
<code class="command">INSERT</code> command. The value specified must be a
|
| 222 |
+
number greater than zero. Any error during restoring will cause only
|
| 223 |
+
rows that are part of the problematic <code class="command">INSERT</code> to be
|
| 224 |
+
lost, rather than the entire table contents.
|
| 225 |
+
</p></dd><dt><span class="term"><code class="option">--use-set-session-authorization</code></span></dt><dd><p>
|
| 226 |
+
Output SQL-standard <code class="command">SET SESSION AUTHORIZATION</code> commands
|
| 227 |
+
instead of <code class="command">ALTER OWNER</code> commands to determine object
|
| 228 |
+
ownership. This makes the dump more standards compatible, but
|
| 229 |
+
depending on the history of the objects in the dump, might not restore
|
| 230 |
+
properly.
|
| 231 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 232 |
+
Show help about <span class="application">pg_dumpall</span> command line
|
| 233 |
+
arguments, and exit.
|
| 234 |
+
</p></dd></dl></div><p>
|
| 235 |
+
</p><p>
|
| 236 |
+
The following command-line options control the database connection parameters.
|
| 237 |
+
|
| 238 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d <em class="replaceable"><code>connstr</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>connstr</code></em></code></span></dt><dd><p>
|
| 239 |
+
Specifies parameters used to connect to the server, as a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>; these
|
| 240 |
+
will override any conflicting command line options.
|
| 241 |
+
</p><p>
|
| 242 |
+
The option is called <code class="literal">--dbname</code> for consistency with other
|
| 243 |
+
client applications, but because <span class="application">pg_dumpall</span>
|
| 244 |
+
needs to connect to many databases, the database name in the
|
| 245 |
+
connection string will be ignored. Use the <code class="literal">-l</code>
|
| 246 |
+
option to specify the name of the database used for the initial
|
| 247 |
+
connection, which will dump global objects and discover what other
|
| 248 |
+
databases should be dumped.
|
| 249 |
+
</p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 250 |
+
Specifies the host name of the machine on which the database
|
| 251 |
+
server is running. If the value begins with a slash, it is
|
| 252 |
+
used as the directory for the Unix domain socket. The default
|
| 253 |
+
is taken from the <code class="envar">PGHOST</code> environment variable,
|
| 254 |
+
if set, else a Unix domain socket connection is attempted.
|
| 255 |
+
</p></dd><dt><span class="term"><code class="option">-l <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--database=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 256 |
+
Specifies the name of the database to connect to for dumping global
|
| 257 |
+
objects and discovering what other databases should be dumped. If
|
| 258 |
+
not specified, the <code class="literal">postgres</code> database will be used,
|
| 259 |
+
and if that does not exist, <code class="literal">template1</code> will be used.
|
| 260 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 261 |
+
Specifies the TCP port or local Unix domain socket file
|
| 262 |
+
extension on which the server is listening for connections.
|
| 263 |
+
Defaults to the <code class="envar">PGPORT</code> environment variable, if
|
| 264 |
+
set, or a compiled-in default.
|
| 265 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 266 |
+
User name to connect as.
|
| 267 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 268 |
+
Never issue a password prompt. If the server requires
|
| 269 |
+
password authentication and a password is not available by
|
| 270 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 271 |
+
connection attempt will fail. This option can be useful in
|
| 272 |
+
batch jobs and scripts where no user is present to enter a
|
| 273 |
+
password.
|
| 274 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 275 |
+
Force <span class="application">pg_dumpall</span> to prompt for a
|
| 276 |
+
password before connecting to a database.
|
| 277 |
+
</p><p>
|
| 278 |
+
This option is never essential, since
|
| 279 |
+
<span class="application">pg_dumpall</span> will automatically prompt
|
| 280 |
+
for a password if the server demands password authentication.
|
| 281 |
+
However, <span class="application">pg_dumpall</span> will waste a
|
| 282 |
+
connection attempt finding out that the server wants a password.
|
| 283 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 284 |
+
connection attempt.
|
| 285 |
+
</p><p>
|
| 286 |
+
Note that the password prompt will occur again for each database
|
| 287 |
+
to be dumped. Usually, it's better to set up a
|
| 288 |
+
<code class="filename">~/.pgpass</code> file than to rely on manual password entry.
|
| 289 |
+
</p></dd><dt><span class="term"><code class="option">--role=<em class="replaceable"><code>rolename</code></em></code></span></dt><dd><p>
|
| 290 |
+
Specifies a role name to be used to create the dump.
|
| 291 |
+
This option causes <span class="application">pg_dumpall</span> to issue a
|
| 292 |
+
<code class="command">SET ROLE</code> <em class="replaceable"><code>rolename</code></em>
|
| 293 |
+
command after connecting to the database. It is useful when the
|
| 294 |
+
authenticated user (specified by <code class="option">-U</code>) lacks privileges
|
| 295 |
+
needed by <span class="application">pg_dumpall</span>, but can switch to a role with
|
| 296 |
+
the required rights. Some installations have a policy against
|
| 297 |
+
logging in directly as a superuser, and use of this option allows
|
| 298 |
+
dumps to be made without violating the policy.
|
| 299 |
+
</p></dd></dl></div><p>
|
| 300 |
+
</p></div><div class="refsect1" id="id-1.9.4.14.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGOPTIONS</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 301 |
+
Default connection parameters
|
| 302 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 303 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 304 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 305 |
+
<code class="literal">never</code>.
|
| 306 |
+
</p></dd></dl></div><p>
|
| 307 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 308 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 309 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 310 |
+
</p></div><div class="refsect1" id="id-1.9.4.14.8"><h2>Notes</h2><p>
|
| 311 |
+
Since <span class="application">pg_dumpall</span> calls
|
| 312 |
+
<span class="application">pg_dump</span> internally, some diagnostic
|
| 313 |
+
messages will refer to <span class="application">pg_dump</span>.
|
| 314 |
+
</p><p>
|
| 315 |
+
The <code class="option">--clean</code> option can be useful even when your
|
| 316 |
+
intention is to restore the dump script into a fresh cluster. Use of
|
| 317 |
+
<code class="option">--clean</code> authorizes the script to drop and re-create the
|
| 318 |
+
built-in <code class="literal">postgres</code> and <code class="literal">template1</code>
|
| 319 |
+
databases, ensuring that those databases will retain the same properties
|
| 320 |
+
(for instance, locale and encoding) that they had in the source cluster.
|
| 321 |
+
Without the option, those databases will retain their existing
|
| 322 |
+
database-level properties, as well as any pre-existing contents.
|
| 323 |
+
</p><p>
|
| 324 |
+
Once restored, it is wise to run <code class="command">ANALYZE</code> on each
|
| 325 |
+
database so the optimizer has useful statistics. You
|
| 326 |
+
can also run <code class="command">vacuumdb -a -z</code> to analyze all
|
| 327 |
+
databases.
|
| 328 |
+
</p><p>
|
| 329 |
+
The dump script should not be expected to run completely without errors.
|
| 330 |
+
In particular, because the script will issue <code class="command">CREATE ROLE</code>
|
| 331 |
+
for every role existing in the source cluster, it is certain to get a
|
| 332 |
+
<span class="quote">“<span class="quote">role already exists</span>”</span> error for the bootstrap superuser,
|
| 333 |
+
unless the destination cluster was initialized with a different bootstrap
|
| 334 |
+
superuser name. This error is harmless and should be ignored. Use of
|
| 335 |
+
the <code class="option">--clean</code> option is likely to produce additional
|
| 336 |
+
harmless error messages about non-existent objects, although you can
|
| 337 |
+
minimize those by adding <code class="option">--if-exists</code>.
|
| 338 |
+
</p><p>
|
| 339 |
+
<span class="application">pg_dumpall</span> requires all needed
|
| 340 |
+
tablespace directories to exist before the restore; otherwise,
|
| 341 |
+
database creation will fail for databases in non-default
|
| 342 |
+
locations.
|
| 343 |
+
</p></div><div class="refsect1" id="APP-PG-DUMPALL-EX"><h2>Examples</h2><p>
|
| 344 |
+
To dump all databases:
|
| 345 |
+
|
| 346 |
+
</p><pre class="screen">
|
| 347 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dumpall > db.out</code></strong>
|
| 348 |
+
</pre><p>
|
| 349 |
+
</p><p>
|
| 350 |
+
To restore database(s) from this file, you can use:
|
| 351 |
+
</p><pre class="screen">
|
| 352 |
+
<code class="prompt">$</code> <strong class="userinput"><code>psql -f db.out postgres</code></strong>
|
| 353 |
+
</pre><p>
|
| 354 |
+
It is not important to which database you connect here since the
|
| 355 |
+
script file created by <span class="application">pg_dumpall</span> will
|
| 356 |
+
contain the appropriate commands to create and connect to the saved
|
| 357 |
+
databases. An exception is that if you specified <code class="option">--clean</code>,
|
| 358 |
+
you must connect to the <code class="literal">postgres</code> database initially;
|
| 359 |
+
the script will attempt to drop other databases immediately, and that
|
| 360 |
+
will fail for the database you are connected to.
|
| 361 |
+
</p></div><div class="refsect1" id="id-1.9.4.14.10"><h2>See Also</h2><p>
|
| 362 |
+
Check <a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a> for details on possible
|
| 363 |
+
error conditions.
|
| 364 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgdump.html" title="pg_dump">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pg-isready.html" title="pg_isready">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_dump</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_isready</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pg-isready.html
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_isready</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pg-dumpall.html" title="pg_dumpall" /><link rel="next" href="app-pgreceivewal.html" title="pg_receivewal" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_isready</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pg-dumpall.html" title="pg_dumpall">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgreceivewal.html" title="pg_receivewal">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PG-ISREADY"><div class="titlepage"></div><a id="id-1.9.4.15.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_isready</span></span></h2><p>pg_isready — check the connection status of a <span class="productname">PostgreSQL</span> server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.15.4.1"><code class="command">pg_isready</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="APP-PG-ISREADY-DESCRIPTION"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">pg_isready</span> is a utility for checking the connection
|
| 4 |
+
status of a <span class="productname">PostgreSQL</span> database server. The exit
|
| 5 |
+
status specifies the result of the connection check.
|
| 6 |
+
</p></div><div class="refsect1" id="APP-PG-ISREADY-OPTIONS"><h2>Options</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 7 |
+
Specifies the name of the database to connect to. The
|
| 8 |
+
<em class="replaceable"><code>dbname</code></em> can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>. If so,
|
| 9 |
+
connection string parameters will override any conflicting command
|
| 10 |
+
line options.
|
| 11 |
+
</p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>hostname</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>hostname</code></em></code></span></dt><dd><p>
|
| 12 |
+
Specifies the host name of the machine on which the
|
| 13 |
+
server is running. If the value begins
|
| 14 |
+
with a slash, it is used as the directory for the Unix-domain
|
| 15 |
+
socket.
|
| 16 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 17 |
+
Specifies the TCP port or the local Unix-domain
|
| 18 |
+
socket file extension on which the server is listening for
|
| 19 |
+
connections. Defaults to the value of the <code class="envar">PGPORT</code>
|
| 20 |
+
environment variable or, if not set, to the port specified at
|
| 21 |
+
compile time, usually 5432.
|
| 22 |
+
</p></dd><dt><span class="term"><code class="option">-q</code><br /></span><span class="term"><code class="option">--quiet</code></span></dt><dd><p>
|
| 23 |
+
Do not display status message. This is useful when scripting.
|
| 24 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>seconds</code></em></code><br /></span><span class="term"><code class="option">--timeout=<em class="replaceable"><code>seconds</code></em></code></span></dt><dd><p>
|
| 25 |
+
The maximum number of seconds to wait when attempting connection before
|
| 26 |
+
returning that the server is not responding. Setting to 0 disables. The
|
| 27 |
+
default is 3 seconds.
|
| 28 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 29 |
+
Connect to the database as the user <em class="replaceable"><code>username</code></em> instead of the default.
|
| 30 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 31 |
+
Print the <span class="application">pg_isready</span> version and exit.
|
| 32 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 33 |
+
Show help about <span class="application">pg_isready</span> command line
|
| 34 |
+
arguments, and exit.
|
| 35 |
+
</p></dd></dl></div></div><div class="refsect1" id="id-1.9.4.15.7"><h2>Exit Status</h2><p>
|
| 36 |
+
<span class="application">pg_isready</span> returns <code class="literal">0</code> to the shell if the server
|
| 37 |
+
is accepting connections normally, <code class="literal">1</code> if the server is rejecting
|
| 38 |
+
connections (for example during startup), <code class="literal">2</code> if there was no response to the
|
| 39 |
+
connection attempt, and <code class="literal">3</code> if no attempt was made (for example due to invalid
|
| 40 |
+
parameters).
|
| 41 |
+
</p></div><div class="refsect1" id="id-1.9.4.15.8"><h2>Environment</h2><p>
|
| 42 |
+
<code class="command">pg_isready</code>, like most other <span class="productname">PostgreSQL</span>
|
| 43 |
+
utilities,
|
| 44 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 45 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 46 |
+
</p><p>
|
| 47 |
+
The environment variable <code class="envar">PG_COLOR</code> specifies whether to use
|
| 48 |
+
color in diagnostic messages. Possible values are
|
| 49 |
+
<code class="literal">always</code>, <code class="literal">auto</code> and
|
| 50 |
+
<code class="literal">never</code>.
|
| 51 |
+
</p></div><div class="refsect1" id="APP-PG-ISREADY-NOTES"><h2>Notes</h2><p>
|
| 52 |
+
It is not necessary to supply correct user name, password, or database
|
| 53 |
+
name values to obtain the server status; however, if incorrect values
|
| 54 |
+
are provided, the server will log a failed connection attempt.
|
| 55 |
+
</p></div><div class="refsect1" id="APP-PG-ISREADY-EXAMPLES"><h2>Examples</h2><p>
|
| 56 |
+
Standard Usage:
|
| 57 |
+
</p><pre class="screen">
|
| 58 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_isready</code></strong>
|
| 59 |
+
<code class="computeroutput">/tmp:5432 - accepting connections</code>
|
| 60 |
+
<code class="prompt">$</code> <strong class="userinput"><code>echo $?</code></strong>
|
| 61 |
+
<code class="computeroutput">0</code>
|
| 62 |
+
</pre><p>
|
| 63 |
+
</p><p>
|
| 64 |
+
Running with connection parameters to a <span class="productname">PostgreSQL</span> cluster in startup:
|
| 65 |
+
</p><pre class="screen">
|
| 66 |
+
<code class="prompt">$ </code><strong class="userinput"><code>pg_isready -h localhost -p 5433</code></strong>
|
| 67 |
+
<code class="computeroutput">localhost:5433 - rejecting connections</code>
|
| 68 |
+
<code class="prompt">$</code> <strong class="userinput"><code>echo $?</code></strong>
|
| 69 |
+
<code class="computeroutput">1</code>
|
| 70 |
+
</pre><p>
|
| 71 |
+
</p><p>
|
| 72 |
+
Running with connection parameters to a non-responsive <span class="productname">PostgreSQL</span> cluster:
|
| 73 |
+
</p><pre class="screen">
|
| 74 |
+
<code class="prompt">$ </code><strong class="userinput"><code>pg_isready -h someremotehost</code></strong>
|
| 75 |
+
<code class="computeroutput">someremotehost:5432 - no response</code>
|
| 76 |
+
<code class="prompt">$</code> <strong class="userinput"><code>echo $?</code></strong>
|
| 77 |
+
<code class="computeroutput">2</code>
|
| 78 |
+
</pre><p>
|
| 79 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pg-dumpall.html" title="pg_dumpall">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgreceivewal.html" title="pg_receivewal">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_dumpall</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_receivewal</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgamcheck.html
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_amcheck</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-ecpg.html" title="ecpg" /><link rel="next" href="app-pgbasebackup.html" title="pg_basebackup" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_amcheck</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-ecpg.html" title="ecpg">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgbasebackup.html" title="pg_basebackup">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGAMCHECK"><div class="titlepage"></div><a id="id-1.9.4.9.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_amcheck</span></span></h2><p>pg_amcheck — checks for corruption in one or more
|
| 3 |
+
<span class="productname">PostgreSQL</span> databases</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.9.4.1"><code class="command">pg_amcheck</code> [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>dbname</code></em>]</p></div></div><div class="refsect1" id="id-1.9.4.9.5"><h2>Description</h2><p>
|
| 4 |
+
<span class="application">pg_amcheck</span> supports running
|
| 5 |
+
<a class="xref" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">amcheck</a>'s corruption checking functions against one or
|
| 6 |
+
more databases, with options to select which schemas, tables and indexes to
|
| 7 |
+
check, which kinds of checking to perform, and whether to perform the checks
|
| 8 |
+
in parallel, and if so, the number of parallel connections to establish and
|
| 9 |
+
use.
|
| 10 |
+
</p><p>
|
| 11 |
+
Only ordinary and toast table relations, materialized views, sequences, and
|
| 12 |
+
btree indexes are currently supported. Other relation types are silently
|
| 13 |
+
skipped.
|
| 14 |
+
</p><p>
|
| 15 |
+
If <code class="literal">dbname</code> is specified, it should be the name of a
|
| 16 |
+
single database to check, and no other database selection options should
|
| 17 |
+
be present. Otherwise, if any database selection options are present,
|
| 18 |
+
all matching databases will be checked. If no such options are present,
|
| 19 |
+
the default database will be checked. Database selection options include
|
| 20 |
+
<code class="option">--all</code>, <code class="option">--database</code> and
|
| 21 |
+
<code class="option">--exclude-database</code>. They also include
|
| 22 |
+
<code class="option">--relation</code>, <code class="option">--exclude-relation</code>,
|
| 23 |
+
<code class="option">--table</code>, <code class="option">--exclude-table</code>,
|
| 24 |
+
<code class="option">--index</code>, and <code class="option">--exclude-index</code>,
|
| 25 |
+
but only when such options are used with a three-part pattern
|
| 26 |
+
(e.g. <code class="option">mydb*.myschema*.myrel*</code>). Finally, they include
|
| 27 |
+
<code class="option">--schema</code> and <code class="option">--exclude-schema</code>
|
| 28 |
+
when such options are used with a two-part pattern
|
| 29 |
+
(e.g. <code class="option">mydb*.myschema*</code>).
|
| 30 |
+
</p><p>
|
| 31 |
+
<em class="replaceable"><code>dbname</code></em> can also be a
|
| 32 |
+
<a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>.
|
| 33 |
+
</p></div><div class="refsect1" id="id-1.9.4.9.6"><h2>Options</h2><p>
|
| 34 |
+
The following command-line options control what is checked:
|
| 35 |
+
|
| 36 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--all</code></span></dt><dd><p>
|
| 37 |
+
Check all databases, except for any excluded via
|
| 38 |
+
<code class="option">--exclude-database</code>.
|
| 39 |
+
</p></dd><dt><span class="term"><code class="option">-d <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--database=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 40 |
+
Check databases matching the specified
|
| 41 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>,
|
| 42 |
+
except for any excluded by <code class="option">--exclude-database</code>.
|
| 43 |
+
This option can be specified more than once.
|
| 44 |
+
</p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-database=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 45 |
+
Exclude databases matching the given
|
| 46 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>.
|
| 47 |
+
This option can be specified more than once.
|
| 48 |
+
</p></dd><dt><span class="term"><code class="option">-i <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--index=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 49 |
+
Check indexes matching the specified
|
| 50 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>,
|
| 51 |
+
unless they are otherwise excluded.
|
| 52 |
+
This option can be specified more than once.
|
| 53 |
+
</p><p>
|
| 54 |
+
This is similar to the <code class="option">--relation</code> option, except that
|
| 55 |
+
it applies only to indexes, not to other relation types.
|
| 56 |
+
</p></dd><dt><span class="term"><code class="option">-I <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-index=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 57 |
+
Exclude indexes matching the specified
|
| 58 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>.
|
| 59 |
+
This option can be specified more than once.
|
| 60 |
+
</p><p>
|
| 61 |
+
This is similar to the <code class="option">--exclude-relation</code> option,
|
| 62 |
+
except that it applies only to indexes, not other relation types.
|
| 63 |
+
</p></dd><dt><span class="term"><code class="option">-r <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--relation=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 64 |
+
Check relations matching the specified
|
| 65 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>,
|
| 66 |
+
unless they are otherwise excluded.
|
| 67 |
+
This option can be specified more than once.
|
| 68 |
+
</p><p>
|
| 69 |
+
Patterns may be unqualified, e.g. <code class="literal">myrel*</code>, or they
|
| 70 |
+
may be schema-qualified, e.g. <code class="literal">myschema*.myrel*</code> or
|
| 71 |
+
database-qualified and schema-qualified, e.g.
|
| 72 |
+
<code class="literal">mydb*.myschema*.myrel*</code>. A database-qualified
|
| 73 |
+
pattern will add matching databases to the list of databases to be
|
| 74 |
+
checked.
|
| 75 |
+
</p></dd><dt><span class="term"><code class="option">-R <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-relation=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 76 |
+
Exclude relations matching the specified
|
| 77 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>.
|
| 78 |
+
This option can be specified more than once.
|
| 79 |
+
</p><p>
|
| 80 |
+
As with <code class="option">--relation</code>, the
|
| 81 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a> may be unqualified, schema-qualified,
|
| 82 |
+
or database- and schema-qualified.
|
| 83 |
+
</p></dd><dt><span class="term"><code class="option">-s <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--schema=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 84 |
+
Check tables and indexes in schemas matching the specified
|
| 85 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>, unless they are otherwise excluded.
|
| 86 |
+
This option can be specified more than once.
|
| 87 |
+
</p><p>
|
| 88 |
+
To select only tables in schemas matching a particular pattern,
|
| 89 |
+
consider using something like
|
| 90 |
+
<code class="literal">--table=SCHEMAPAT.* --no-dependent-indexes</code>.
|
| 91 |
+
To select only indexes, consider using something like
|
| 92 |
+
<code class="literal">--index=SCHEMAPAT.*</code>.
|
| 93 |
+
</p><p>
|
| 94 |
+
A schema pattern may be database-qualified. For example, you may
|
| 95 |
+
write <code class="literal">--schema=mydb*.myschema*</code> to select
|
| 96 |
+
schemas matching <code class="literal">myschema*</code> in databases matching
|
| 97 |
+
<code class="literal">mydb*</code>.
|
| 98 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-schema=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 99 |
+
Exclude tables and indexes in schemas matching the specified
|
| 100 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>.
|
| 101 |
+
This option can be specified more than once.
|
| 102 |
+
</p><p>
|
| 103 |
+
As with <code class="option">--schema</code>, the pattern may be
|
| 104 |
+
database-qualified.
|
| 105 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--table=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 106 |
+
Check tables matching the specified
|
| 107 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>,
|
| 108 |
+
unless they are otherwise excluded.
|
| 109 |
+
This option can be specified more than once.
|
| 110 |
+
</p><p>
|
| 111 |
+
This is similar to the <code class="option">--relation</code> option, except that
|
| 112 |
+
it applies only to tables, materialized views, and sequences, not to
|
| 113 |
+
indexes.
|
| 114 |
+
</p></dd><dt><span class="term"><code class="option">-T <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-table=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 115 |
+
Exclude tables matching the specified
|
| 116 |
+
<a class="link" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns"><em class="replaceable"><code>pattern</code></em></a>.
|
| 117 |
+
This option can be specified more than once.
|
| 118 |
+
</p><p>
|
| 119 |
+
This is similar to the <code class="option">--exclude-relation</code> option,
|
| 120 |
+
except that it applies only to tables, materialized views, and
|
| 121 |
+
sequences, not to indexes.
|
| 122 |
+
</p></dd><dt><span class="term"><code class="option">--no-dependent-indexes</code></span></dt><dd><p>
|
| 123 |
+
By default, if a table is checked, any btree indexes of that table
|
| 124 |
+
will also be checked, even if they are not explicitly selected by
|
| 125 |
+
an option such as <code class="literal">--index</code> or
|
| 126 |
+
<code class="literal">--relation</code>. This option suppresses that behavior.
|
| 127 |
+
</p></dd><dt><span class="term"><code class="option">--no-dependent-toast</code></span></dt><dd><p>
|
| 128 |
+
By default, if a table is checked, its toast table, if any, will also
|
| 129 |
+
be checked, even if it is not explicitly selected by an option
|
| 130 |
+
such as <code class="literal">--table</code> or <code class="literal">--relation</code>.
|
| 131 |
+
This option suppresses that behavior.
|
| 132 |
+
</p></dd><dt><span class="term"><code class="option">--no-strict-names</code></span></dt><dd><p>
|
| 133 |
+
By default, if an argument to <code class="literal">--database</code>,
|
| 134 |
+
<code class="literal">--table</code>, <code class="literal">--index</code>,
|
| 135 |
+
or <code class="literal">--relation</code> matches no objects, it is a fatal
|
| 136 |
+
error. This option downgrades that error to a warning.
|
| 137 |
+
</p></dd></dl></div><p>
|
| 138 |
+
</p><p>
|
| 139 |
+
The following command-line options control checking of tables:
|
| 140 |
+
|
| 141 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--exclude-toast-pointers</code></span></dt><dd><p>
|
| 142 |
+
By default, whenever a toast pointer is encountered in a table,
|
| 143 |
+
a lookup is performed to ensure that it references apparently-valid
|
| 144 |
+
entries in the toast table. These checks can be quite slow, and this
|
| 145 |
+
option can be used to skip them.
|
| 146 |
+
</p></dd><dt><span class="term"><code class="option">--on-error-stop</code></span></dt><dd><p>
|
| 147 |
+
After reporting all corruptions on the first page of a table where
|
| 148 |
+
corruption is found, stop processing that table relation and move on
|
| 149 |
+
to the next table or index.
|
| 150 |
+
</p><p>
|
| 151 |
+
Note that index checking always stops after the first corrupt page.
|
| 152 |
+
This option only has meaning relative to table relations.
|
| 153 |
+
</p></dd><dt><span class="term"><code class="option">--skip=<em class="replaceable"><code>option</code></em></code></span></dt><dd><p>
|
| 154 |
+
If <code class="literal">all-frozen</code> is given, table corruption checks
|
| 155 |
+
will skip over pages in all tables that are marked as all frozen.
|
| 156 |
+
</p><p>
|
| 157 |
+
If <code class="literal">all-visible</code> is given, table corruption checks
|
| 158 |
+
will skip over pages in all tables that are marked as all visible.
|
| 159 |
+
</p><p>
|
| 160 |
+
By default, no pages are skipped. This can be specified as
|
| 161 |
+
<code class="literal">none</code>, but since this is the default, it need not be
|
| 162 |
+
mentioned.
|
| 163 |
+
</p></dd><dt><span class="term"><code class="option">--startblock=<em class="replaceable"><code>block</code></em></code></span></dt><dd><p>
|
| 164 |
+
Start checking at the specified block number. An error will occur if
|
| 165 |
+
the table relation being checked has fewer than this number of blocks.
|
| 166 |
+
This option does not apply to indexes, and is probably only useful
|
| 167 |
+
when checking a single table relation. See <code class="literal">--endblock</code>
|
| 168 |
+
for further caveats.
|
| 169 |
+
</p></dd><dt><span class="term"><code class="option">--endblock=<em class="replaceable"><code>block</code></em></code></span></dt><dd><p>
|
| 170 |
+
End checking at the specified block number. An error will occur if the
|
| 171 |
+
table relation being checked has fewer than this number of blocks.
|
| 172 |
+
This option does not apply to indexes, and is probably only useful when
|
| 173 |
+
checking a single table relation. If both a regular table and a toast
|
| 174 |
+
table are checked, this option will apply to both, but higher-numbered
|
| 175 |
+
toast blocks may still be accessed while validating toast pointers,
|
| 176 |
+
unless that is suppressed using
|
| 177 |
+
<code class="option">--exclude-toast-pointers</code>.
|
| 178 |
+
</p></dd></dl></div><p>
|
| 179 |
+
</p><p>
|
| 180 |
+
The following command-line options control checking of B-tree indexes:
|
| 181 |
+
|
| 182 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--heapallindexed</code></span></dt><dd><p>
|
| 183 |
+
For each index checked, verify the presence of all heap tuples as index
|
| 184 |
+
tuples in the index using <a class="xref" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">amcheck</a>'s
|
| 185 |
+
<code class="option">heapallindexed</code> option.
|
| 186 |
+
</p></dd><dt><span class="term"><code class="option">--parent-check</code></span></dt><dd><p>
|
| 187 |
+
For each btree index checked, use <a class="xref" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">amcheck</a>'s
|
| 188 |
+
<code class="function">bt_index_parent_check</code> function, which performs
|
| 189 |
+
additional checks of parent/child relationships during index checking.
|
| 190 |
+
</p><p>
|
| 191 |
+
The default is to use <span class="application">amcheck</span>'s
|
| 192 |
+
<code class="function">bt_index_check</code> function, but note that use of the
|
| 193 |
+
<code class="option">--rootdescend</code> option implicitly selects
|
| 194 |
+
<code class="function">bt_index_parent_check</code>.
|
| 195 |
+
</p></dd><dt><span class="term"><code class="option">--rootdescend</code></span></dt><dd><p>
|
| 196 |
+
For each index checked, re-find tuples on the leaf level by performing a
|
| 197 |
+
new search from the root page for each tuple using
|
| 198 |
+
<a class="xref" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">amcheck</a>'s <code class="option">rootdescend</code> option.
|
| 199 |
+
</p><p>
|
| 200 |
+
Use of this option implicitly also selects the
|
| 201 |
+
<code class="option">--parent-check</code> option.
|
| 202 |
+
</p><p>
|
| 203 |
+
This form of verification was originally written to help in the
|
| 204 |
+
development of btree index features. It may be of limited use or even
|
| 205 |
+
of no use in helping detect the kinds of corruption that occur in
|
| 206 |
+
practice. It may also cause corruption checking to take considerably
|
| 207 |
+
longer and consume considerably more resources on the server.
|
| 208 |
+
</p></dd></dl></div><p>
|
| 209 |
+
</p><div class="warning"><h3 class="title">Warning</h3><p>
|
| 210 |
+
The extra checks performed against B-tree indexes when the
|
| 211 |
+
<code class="option">--parent-check</code> option or the
|
| 212 |
+
<code class="option">--rootdescend</code> option is specified require
|
| 213 |
+
relatively strong relation-level locks. These checks are the only
|
| 214 |
+
checks that will block concurrent data modification from
|
| 215 |
+
<code class="command">INSERT</code>, <code class="command">UPDATE</code>, and
|
| 216 |
+
<code class="command">DELETE</code> commands.
|
| 217 |
+
</p></div><p>
|
| 218 |
+
The following command-line options control the connection to the server:
|
| 219 |
+
|
| 220 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>hostname</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>hostname</code></em></code></span></dt><dd><p>
|
| 221 |
+
Specifies the host name of the machine on which the server is running.
|
| 222 |
+
If the value begins with a slash, it is used as the directory for the
|
| 223 |
+
Unix domain socket.
|
| 224 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 225 |
+
Specifies the TCP port or local Unix domain socket file extension on
|
| 226 |
+
which the server is listening for connections.
|
| 227 |
+
</p></dd><dt><span class="term"><code class="option">-U</code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 228 |
+
User name to connect as.
|
| 229 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 230 |
+
Never issue a password prompt. If the server requires password
|
| 231 |
+
authentication and a password is not available by other means such as
|
| 232 |
+
a <code class="filename">.pgpass</code> file, the connection attempt will fail.
|
| 233 |
+
This option can be useful in batch jobs and scripts where no user is
|
| 234 |
+
present to enter a password.
|
| 235 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 236 |
+
Force <span class="application">pg_amcheck</span> to prompt for a password
|
| 237 |
+
before connecting to a database.
|
| 238 |
+
</p><p>
|
| 239 |
+
This option is never essential, since
|
| 240 |
+
<span class="application">pg_amcheck</span> will automatically prompt for a
|
| 241 |
+
password if the server demands password authentication. However,
|
| 242 |
+
<span class="application">pg_amcheck</span> will waste a connection attempt
|
| 243 |
+
finding out that the server wants a password. In some cases it is
|
| 244 |
+
worth typing <code class="option">-W</code> to avoid the extra connection attempt.
|
| 245 |
+
</p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 246 |
+
Specifies a database or
|
| 247 |
+
<a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a> to be
|
| 248 |
+
used to discover the list of databases to be checked. If neither
|
| 249 |
+
<code class="option">--all</code> nor any option including a database pattern is
|
| 250 |
+
used, no such connection is required and this option does nothing.
|
| 251 |
+
Otherwise, any connection string parameters other than
|
| 252 |
+
the database name which are included in the value for this option
|
| 253 |
+
will also be used when connecting to the databases
|
| 254 |
+
being checked. If this option is omitted, the default is
|
| 255 |
+
<code class="literal">postgres</code> or, if that fails,
|
| 256 |
+
<code class="literal">template1</code>.
|
| 257 |
+
</p></dd></dl></div><p>
|
| 258 |
+
</p><p>
|
| 259 |
+
Other options are also available:
|
| 260 |
+
|
| 261 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
|
| 262 |
+
Echo to stdout all SQL sent to the server.
|
| 263 |
+
</p></dd><dt><span class="term"><code class="option">-j <em class="replaceable"><code>num</code></em></code><br /></span><span class="term"><code class="option">--jobs=<em class="replaceable"><code>num</code></em></code></span></dt><dd><p>
|
| 264 |
+
Use <em class="replaceable"><code>num</code></em> concurrent connections to the server,
|
| 265 |
+
or one per object to be checked, whichever is less.
|
| 266 |
+
</p><p>
|
| 267 |
+
The default is to use a single connection.
|
| 268 |
+
</p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--progress</code></span></dt><dd><p>
|
| 269 |
+
Show progress information. Progress information includes the number
|
| 270 |
+
of relations for which checking has been completed, and the total
|
| 271 |
+
size of those relations. It also includes the total number of relations
|
| 272 |
+
that will eventually be checked, and the estimated size of those
|
| 273 |
+
relations.
|
| 274 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 275 |
+
Print more messages. In particular, this will print a message for
|
| 276 |
+
each relation being checked, and will increase the level of detail
|
| 277 |
+
shown for server errors.
|
| 278 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 279 |
+
Print the <span class="application">pg_amcheck</span> version and exit.
|
| 280 |
+
</p></dd><dt><span class="term"><code class="option">--install-missing</code><br /></span><span class="term"><code class="option">--install-missing=<em class="replaceable"><code>schema</code></em></code></span></dt><dd><p>
|
| 281 |
+
Install any missing extensions that are required to check the
|
| 282 |
+
database(s). If not yet installed, each extension's objects will be
|
| 283 |
+
installed into the given
|
| 284 |
+
<em class="replaceable"><code>schema</code></em>, or if not specified
|
| 285 |
+
into schema <code class="literal">pg_catalog</code>.
|
| 286 |
+
</p><p>
|
| 287 |
+
At present, the only required extension is <a class="xref" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">amcheck</a>.
|
| 288 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 289 |
+
Show help about <span class="application">pg_amcheck</span> command line
|
| 290 |
+
arguments, and exit.
|
| 291 |
+
</p></dd></dl></div><p>
|
| 292 |
+
</p></div><div class="refsect1" id="id-1.9.4.9.7"><h2>Notes</h2><p>
|
| 293 |
+
<span class="application">pg_amcheck</span> is designed to work with
|
| 294 |
+
<span class="productname">PostgreSQL</span> 14.0 and later.
|
| 295 |
+
</p></div><div class="refsect1" id="id-1.9.4.9.8"><h2>See Also</h2><span class="simplelist"><a class="xref" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">amcheck</a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-ecpg.html" title="ecpg">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgbasebackup.html" title="pg_basebackup">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">ecpg</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_basebackup</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgbasebackup.html
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_basebackup</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgamcheck.html" title="pg_amcheck" /><link rel="next" href="pgbench.html" title="pgbench" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_basebackup</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgamcheck.html" title="pg_amcheck">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="pgbench.html" title="pgbench">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGBASEBACKUP"><div class="titlepage"></div><a id="id-1.9.4.10.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_basebackup</span></span></h2><p>pg_basebackup — take a base backup of a <span class="productname">PostgreSQL</span> cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.10.4.1"><code class="command">pg_basebackup</code> [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="id-1.9.4.10.5"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">pg_basebackup</span> is used to take a base backup of
|
| 4 |
+
a running <span class="productname">PostgreSQL</span> database cluster. The backup
|
| 5 |
+
is taken without affecting other clients of the database, and can be used
|
| 6 |
+
both for point-in-time recovery (see <a class="xref" href="continuous-archiving.html" title="26.3. Continuous Archiving and Point-in-Time Recovery (PITR)">Section 26.3</a>)
|
| 7 |
+
and as the starting point for a log-shipping or streaming-replication standby
|
| 8 |
+
server (see <a class="xref" href="warm-standby.html" title="27.2. Log-Shipping Standby Servers">Section 27.2</a>).
|
| 9 |
+
</p><p>
|
| 10 |
+
<span class="application">pg_basebackup</span> makes an exact copy of the database
|
| 11 |
+
cluster's files, while making sure the server is put into and
|
| 12 |
+
out of backup mode automatically. Backups are always taken of the entire
|
| 13 |
+
database cluster; it is not possible to back up individual databases or
|
| 14 |
+
database objects. For selective backups, another tool such as
|
| 15 |
+
<a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a> must be used.
|
| 16 |
+
</p><p>
|
| 17 |
+
The backup is made over a regular <span class="productname">PostgreSQL</span>
|
| 18 |
+
connection that uses the replication protocol. The connection must be made
|
| 19 |
+
with a user ID that has <code class="literal">REPLICATION</code> permissions
|
| 20 |
+
(see <a class="xref" href="role-attributes.html" title="22.2. Role Attributes">Section 22.2</a>) or is a superuser,
|
| 21 |
+
and <a class="link" href="auth-pg-hba-conf.html" title="21.1. The pg_hba.conf File"><code class="filename">pg_hba.conf</code></a>
|
| 22 |
+
must permit the replication connection. The server must also be configured
|
| 23 |
+
with <a class="xref" href="runtime-config-replication.html#GUC-MAX-WAL-SENDERS">max_wal_senders</a> set high enough to provide at
|
| 24 |
+
least one walsender for the backup plus one for WAL streaming (if used).
|
| 25 |
+
</p><p>
|
| 26 |
+
There can be multiple <code class="command">pg_basebackup</code>s running at the same time, but it is usually
|
| 27 |
+
better from a performance point of view to take only one backup, and copy
|
| 28 |
+
the result.
|
| 29 |
+
</p><p>
|
| 30 |
+
<span class="application">pg_basebackup</span> can make a base backup from
|
| 31 |
+
not only a primary server but also a standby. To take a backup from a standby,
|
| 32 |
+
set up the standby so that it can accept replication connections (that is, set
|
| 33 |
+
<code class="varname">max_wal_senders</code> and <a class="xref" href="runtime-config-replication.html#GUC-HOT-STANDBY">hot_standby</a>,
|
| 34 |
+
and configure its <code class="filename">pg_hba.conf</code> appropriately).
|
| 35 |
+
You will also need to enable <a class="xref" href="runtime-config-wal.html#GUC-FULL-PAGE-WRITES">full_page_writes</a> on the primary.
|
| 36 |
+
</p><p>
|
| 37 |
+
Note that there are some limitations in taking a backup from a standby:
|
| 38 |
+
|
| 39 |
+
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
| 40 |
+
The backup history file is not created in the database cluster backed up.
|
| 41 |
+
</p></li><li class="listitem"><p>
|
| 42 |
+
<span class="application">pg_basebackup</span> cannot force the standby
|
| 43 |
+
to switch to a new WAL file at the end of backup.
|
| 44 |
+
When you are using <code class="literal">-X none</code>, if write activity on
|
| 45 |
+
the primary is low, <span class="application">pg_basebackup</span> may
|
| 46 |
+
need to wait a long time for the last WAL file required for the backup
|
| 47 |
+
to be switched and archived. In this case, it may be useful to run
|
| 48 |
+
<code class="function">pg_switch_wal</code> on the primary in order to
|
| 49 |
+
trigger an immediate WAL file switch.
|
| 50 |
+
</p></li><li class="listitem"><p>
|
| 51 |
+
If the standby is promoted to be primary during backup, the backup fails.
|
| 52 |
+
</p></li><li class="listitem"><p>
|
| 53 |
+
All WAL records required for the backup must contain sufficient full-page writes,
|
| 54 |
+
which requires you to enable <code class="varname">full_page_writes</code> on the primary.
|
| 55 |
+
</p></li></ul></div><p>
|
| 56 |
+
</p><p>
|
| 57 |
+
Whenever <span class="application">pg_basebackup</span> is taking a base
|
| 58 |
+
backup, the server's <code class="structname">pg_stat_progress_basebackup</code>
|
| 59 |
+
view will report the progress of the backup.
|
| 60 |
+
See <a class="xref" href="progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING" title="28.4.6. Base Backup Progress Reporting">Section 28.4.6</a> for details.
|
| 61 |
+
</p></div><div class="refsect1" id="id-1.9.4.10.6"><h2>Options</h2><p>
|
| 62 |
+
The following command-line options control the location and format of the
|
| 63 |
+
output:
|
| 64 |
+
|
| 65 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
|
| 66 |
+
Sets the target directory to write the output to.
|
| 67 |
+
<span class="application">pg_basebackup</span> will create this directory
|
| 68 |
+
(and any missing parent directories) if it does not exist. If it
|
| 69 |
+
already exists, it must be empty.
|
| 70 |
+
</p><p>
|
| 71 |
+
When the backup is in tar format, the target directory may be
|
| 72 |
+
specified as <code class="literal">-</code> (dash), causing the tar file to be
|
| 73 |
+
written to <code class="literal">stdout</code>.
|
| 74 |
+
</p><p>
|
| 75 |
+
This option is required.
|
| 76 |
+
</p></dd><dt><span class="term"><code class="option">-F <em class="replaceable"><code>format</code></em></code><br /></span><span class="term"><code class="option">--format=<em class="replaceable"><code>format</code></em></code></span></dt><dd><p>
|
| 77 |
+
Selects the format for the output. <em class="replaceable"><code>format</code></em>
|
| 78 |
+
can be one of the following:
|
| 79 |
+
|
| 80 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">p</code><br /></span><span class="term"><code class="literal">plain</code></span></dt><dd><p>
|
| 81 |
+
Write the output as plain files, with the same layout as the
|
| 82 |
+
source server's data directory and tablespaces. When the cluster has
|
| 83 |
+
no additional tablespaces, the whole database will be placed in
|
| 84 |
+
the target directory. If the cluster contains additional
|
| 85 |
+
tablespaces, the main data directory will be placed in the
|
| 86 |
+
target directory, but all other tablespaces will be placed
|
| 87 |
+
in the same absolute path as they have on the source server.
|
| 88 |
+
(See <code class="option">--tablespace-mapping</code> to change that.)
|
| 89 |
+
</p><p>
|
| 90 |
+
This is the default format.
|
| 91 |
+
</p></dd><dt><span class="term"><code class="literal">t</code><br /></span><span class="term"><code class="literal">tar</code></span></dt><dd><p>
|
| 92 |
+
Write the output as tar files in the target directory. The main
|
| 93 |
+
data directory's contents will be written to a file named
|
| 94 |
+
<code class="filename">base.tar</code>, and each other tablespace will be
|
| 95 |
+
written to a separate tar file named after that tablespace's OID.
|
| 96 |
+
</p><p>
|
| 97 |
+
If the target directory is specified as <code class="literal">-</code>
|
| 98 |
+
(dash), the tar contents will be written to
|
| 99 |
+
standard output, suitable for piping to (for example)
|
| 100 |
+
<span class="productname">gzip</span>. This is only allowed if
|
| 101 |
+
the cluster has no additional tablespaces and WAL
|
| 102 |
+
streaming is not used.
|
| 103 |
+
</p></dd></dl></div></dd><dt><span class="term"><code class="option">-R</code><br /></span><span class="term"><code class="option">--write-recovery-conf</code></span></dt><dd><p>
|
| 104 |
+
Creates a
|
| 105 |
+
<a class="link" href="warm-standby.html#FILE-STANDBY-SIGNAL"><code class="filename">standby.signal</code></a>
|
| 106 |
+
<a id="id-1.9.4.10.6.2.1.3.3.1.2" class="indexterm"></a>
|
| 107 |
+
file and appends
|
| 108 |
+
connection settings to the <code class="filename">postgresql.auto.conf</code>
|
| 109 |
+
file in the target directory (or within the base archive file when
|
| 110 |
+
using tar format). This eases setting up a standby server using the
|
| 111 |
+
results of the backup.
|
| 112 |
+
</p><p>
|
| 113 |
+
The <code class="filename">postgresql.auto.conf</code> file will record the connection
|
| 114 |
+
settings and, if specified, the replication slot
|
| 115 |
+
that <span class="application">pg_basebackup</span> is using, so that
|
| 116 |
+
streaming replication will use the same settings later on.
|
| 117 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>target</code></em></code><br /></span><span class="term"><code class="option">--target=<em class="replaceable"><code>target</code></em></code></span></dt><dd><p>
|
| 118 |
+
Instructs the server where to place the base backup. The default target
|
| 119 |
+
is <code class="literal">client</code>, which specifies that the backup should
|
| 120 |
+
be sent to the machine where <span class="application">pg_basebackup</span>
|
| 121 |
+
is running. If the target is instead set to
|
| 122 |
+
<code class="literal">server:/some/path</code>, the backup will be stored on
|
| 123 |
+
the machine where the server is running in the
|
| 124 |
+
<code class="literal">/some/path</code> directory. Storing a backup on the
|
| 125 |
+
server requires superuser privileges or having privileges of the
|
| 126 |
+
<code class="literal">pg_write_server_files</code> role. If the target is set to
|
| 127 |
+
<code class="literal">blackhole</code>, the contents are discarded and not
|
| 128 |
+
stored anywhere. This should only be used for testing purposes, as you
|
| 129 |
+
will not end up with an actual backup.
|
| 130 |
+
</p><p>
|
| 131 |
+
Since WAL streaming is implemented by
|
| 132 |
+
<span class="application">pg_basebackup</span> rather than by the server,
|
| 133 |
+
this option cannot be used together with <code class="literal">-Xstream</code>.
|
| 134 |
+
Since that is the default, when this option is specified, you must also
|
| 135 |
+
specify either <code class="literal">-Xfetch</code> or <code class="literal">-Xnone</code>.
|
| 136 |
+
</p></dd><dt><span class="term"><code class="option">-T <em class="replaceable"><code>olddir</code></em>=<em class="replaceable"><code>newdir</code></em></code><br /></span><span class="term"><code class="option">--tablespace-mapping=<em class="replaceable"><code>olddir</code></em>=<em class="replaceable"><code>newdir</code></em></code></span></dt><dd><p>
|
| 137 |
+
Relocates the tablespace in directory <em class="replaceable"><code>olddir</code></em>
|
| 138 |
+
to <em class="replaceable"><code>newdir</code></em> during the backup. To be
|
| 139 |
+
effective, <em class="replaceable"><code>olddir</code></em> must exactly match the
|
| 140 |
+
path specification of the tablespace as it is defined on the source
|
| 141 |
+
server. (But it is not an error if there is no tablespace
|
| 142 |
+
in <em class="replaceable"><code>olddir</code></em> on the source server.)
|
| 143 |
+
Meanwhile <em class="replaceable"><code>newdir</code></em> is a directory in the
|
| 144 |
+
receiving host's filesystem. As with the main target directory,
|
| 145 |
+
<em class="replaceable"><code>newdir</code></em> need not exist already, but if
|
| 146 |
+
it does exist it must be empty.
|
| 147 |
+
Both <em class="replaceable"><code>olddir</code></em>
|
| 148 |
+
and <em class="replaceable"><code>newdir</code></em> must be absolute paths. If
|
| 149 |
+
either path needs to contain an equal sign (<code class="literal">=</code>),
|
| 150 |
+
precede that with a backslash. This option can be specified multiple
|
| 151 |
+
times for multiple tablespaces.
|
| 152 |
+
</p><p>
|
| 153 |
+
If a tablespace is relocated in this way, the symbolic links inside
|
| 154 |
+
the main data directory are updated to point to the new location. So
|
| 155 |
+
the new data directory is ready to be used for a new server instance
|
| 156 |
+
with all tablespaces in the updated locations.
|
| 157 |
+
</p><p>
|
| 158 |
+
Currently, this option only works with plain output format; it is
|
| 159 |
+
ignored if tar format is selected.
|
| 160 |
+
</p></dd><dt><span class="term"><code class="option">--waldir=<em class="replaceable"><code>waldir</code></em></code></span></dt><dd><p>
|
| 161 |
+
Sets the directory to write WAL (write-ahead log) files to.
|
| 162 |
+
By default WAL files will be placed in
|
| 163 |
+
the <code class="filename">pg_wal</code> subdirectory of the target
|
| 164 |
+
directory, but this option can be used to place them elsewhere.
|
| 165 |
+
<em class="replaceable"><code>waldir</code></em> must be an absolute path.
|
| 166 |
+
As with the main target directory,
|
| 167 |
+
<em class="replaceable"><code>waldir</code></em> need not exist already, but if
|
| 168 |
+
it does exist it must be empty.
|
| 169 |
+
This option can only be specified when
|
| 170 |
+
the backup is in plain format.
|
| 171 |
+
</p></dd><dt><span class="term"><code class="option">-X <em class="replaceable"><code>method</code></em></code><br /></span><span class="term"><code class="option">--wal-method=<em class="replaceable"><code>method</code></em></code></span></dt><dd><p>
|
| 172 |
+
Includes the required WAL (write-ahead log) files in the
|
| 173 |
+
backup. This will include all write-ahead logs generated during
|
| 174 |
+
the backup. Unless the method <code class="literal">none</code> is specified,
|
| 175 |
+
it is possible to start a postmaster in the target
|
| 176 |
+
directory without the need to consult the WAL archive, thus
|
| 177 |
+
making the output a completely standalone backup.
|
| 178 |
+
</p><p>
|
| 179 |
+
The following <em class="replaceable"><code>method</code></em>s for collecting the
|
| 180 |
+
write-ahead logs are supported:
|
| 181 |
+
|
| 182 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">n</code><br /></span><span class="term"><code class="literal">none</code></span></dt><dd><p>
|
| 183 |
+
Don't include write-ahead logs in the backup.
|
| 184 |
+
</p></dd><dt><span class="term"><code class="literal">f</code><br /></span><span class="term"><code class="literal">fetch</code></span></dt><dd><p>
|
| 185 |
+
The write-ahead log files are collected at the end of the backup.
|
| 186 |
+
Therefore, it is necessary for the source server's
|
| 187 |
+
<a class="xref" href="runtime-config-replication.html#GUC-WAL-KEEP-SIZE">wal_keep_size</a> parameter to be set high
|
| 188 |
+
enough that the required log data is not removed before the end
|
| 189 |
+
of the backup. If the required log data has been recycled
|
| 190 |
+
before it's time to transfer it, the backup will fail and be
|
| 191 |
+
unusable.
|
| 192 |
+
</p><p>
|
| 193 |
+
When tar format is used, the write-ahead log files will be
|
| 194 |
+
included in the <code class="filename">base.tar</code> file.
|
| 195 |
+
</p></dd><dt><span class="term"><code class="literal">s</code><br /></span><span class="term"><code class="literal">stream</code></span></dt><dd><p>
|
| 196 |
+
Stream write-ahead log data while the backup is being taken.
|
| 197 |
+
This method will open a second connection to the server and
|
| 198 |
+
start streaming the write-ahead log in parallel while running
|
| 199 |
+
the backup. Therefore, it will require two replication
|
| 200 |
+
connections not just one. As long as the client can keep up
|
| 201 |
+
with the write-ahead log data, using this method requires no
|
| 202 |
+
extra write-ahead logs to be saved on the source server.
|
| 203 |
+
</p><p>
|
| 204 |
+
When tar format is used, the write-ahead log files will be
|
| 205 |
+
written to a separate file named <code class="filename">pg_wal.tar</code>
|
| 206 |
+
(if the server is a version earlier than 10, the file will be named
|
| 207 |
+
<code class="filename">pg_xlog.tar</code>).
|
| 208 |
+
</p><p>
|
| 209 |
+
This value is the default.
|
| 210 |
+
</p></dd></dl></div></dd><dt><span class="term"><code class="option">-z</code><br /></span><span class="term"><code class="option">--gzip</code></span></dt><dd><p>
|
| 211 |
+
Enables gzip compression of tar file output, with the default
|
| 212 |
+
compression level. Compression is only available when using
|
| 213 |
+
the tar format, and the suffix <code class="filename">.gz</code> will
|
| 214 |
+
automatically be added to all tar filenames.
|
| 215 |
+
</p></dd><dt><span class="term"><code class="option">-Z <em class="replaceable"><code>level</code></em></code><br /></span><span class="term"><code class="option">-Z [{client|server}-]<em class="replaceable"><code>method</code></em>[:<em class="replaceable"><code>detail</code></em>]</code><br /></span><span class="term"><code class="option">--compress=<em class="replaceable"><code>level</code></em></code><br /></span><span class="term"><code class="option">--compress=[{client|server}-]<em class="replaceable"><code>method</code></em>[:<em class="replaceable"><code>detail</code></em>]</code></span></dt><dd><p>
|
| 216 |
+
Requests compression of the backup. If <code class="literal">client</code> or
|
| 217 |
+
<code class="literal">server</code> is included, it specifies where the
|
| 218 |
+
compression is to be performed. Compressing on the server will reduce
|
| 219 |
+
transfer bandwidth but will increase server CPU consumption. The
|
| 220 |
+
default is <code class="literal">client</code> except when
|
| 221 |
+
<code class="literal">--target</code> is used. In that case, the backup is not
|
| 222 |
+
being sent to the client, so only server compression is sensible.
|
| 223 |
+
When <code class="literal">-Xstream</code>, which is the default, is used,
|
| 224 |
+
server-side compression will not be applied to the WAL. To compress
|
| 225 |
+
the WAL, use client-side compression, or
|
| 226 |
+
specify <code class="literal">-Xfetch</code>.
|
| 227 |
+
</p><p>
|
| 228 |
+
The compression method can be set to <code class="literal">gzip</code>,
|
| 229 |
+
<code class="literal">lz4</code>, <code class="literal">zstd</code>,
|
| 230 |
+
<code class="literal">none</code> for no compression or an integer (no
|
| 231 |
+
compression if 0, <code class="literal">gzip</code> if greater than 0).
|
| 232 |
+
A compression detail string can optionally be specified.
|
| 233 |
+
If the detail string is an integer, it specifies the compression
|
| 234 |
+
level. Otherwise, it should be a comma-separated list of items,
|
| 235 |
+
each of the form <code class="literal">keyword</code> or
|
| 236 |
+
<code class="literal">keyword=value</code>.
|
| 237 |
+
Currently, the supported keywords are <code class="literal">level</code>,
|
| 238 |
+
<code class="literal">long</code>, and <code class="literal">workers</code>.
|
| 239 |
+
The detail string cannot be used when the compression method
|
| 240 |
+
is specified as a plain integer.
|
| 241 |
+
</p><p>
|
| 242 |
+
If no compression level is specified, the default compression level
|
| 243 |
+
will be used. If only a level is specified without mentioning an
|
| 244 |
+
algorithm, <code class="literal">gzip</code> compression will be used if the
|
| 245 |
+
level is greater than 0, and no compression will be used if the level
|
| 246 |
+
is 0.
|
| 247 |
+
</p><p>
|
| 248 |
+
When the tar format is used with <code class="literal">gzip</code>,
|
| 249 |
+
<code class="literal">lz4</code>, or <code class="literal">zstd</code>, the suffix
|
| 250 |
+
<code class="filename">.gz</code>, <code class="filename">.lz4</code>, or
|
| 251 |
+
<code class="filename">.zst</code>, respectively, will be automatically added to
|
| 252 |
+
all tar filenames. When the plain format is used, client-side
|
| 253 |
+
compression may not be specified, but it is still possible to request
|
| 254 |
+
server-side compression. If this is done, the server will compress the
|
| 255 |
+
backup for transmission, and the client will decompress and extract it.
|
| 256 |
+
</p><p>
|
| 257 |
+
When this option is used in combination with
|
| 258 |
+
<code class="literal">-Xstream</code>, <code class="literal">pg_wal.tar</code> will
|
| 259 |
+
be compressed using <code class="literal">gzip</code> if client-side gzip
|
| 260 |
+
compression is selected, but will not be compressed if any other
|
| 261 |
+
compression algorithm is selected, or if server-side compression
|
| 262 |
+
is selected.
|
| 263 |
+
</p></dd></dl></div><p>
|
| 264 |
+
</p><p>
|
| 265 |
+
The following command-line options control the generation of the
|
| 266 |
+
backup and the invocation of the program:
|
| 267 |
+
|
| 268 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-c {fast|spread}</code><br /></span><span class="term"><code class="option">--checkpoint={fast|spread}</code></span></dt><dd><p>
|
| 269 |
+
Sets checkpoint mode to fast (immediate) or spread (the default)
|
| 270 |
+
(see <a class="xref" href="continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP" title="26.3.3. Making a Base Backup Using the Low Level API">Section 26.3.3</a>).
|
| 271 |
+
</p></dd><dt><span class="term"><code class="option">-C</code><br /></span><span class="term"><code class="option">--create-slot</code></span></dt><dd><p>
|
| 272 |
+
Specifies that the replication slot named by the
|
| 273 |
+
<code class="literal">--slot</code> option should be created before starting
|
| 274 |
+
the backup. An error is raised if the slot already exists.
|
| 275 |
+
</p></dd><dt><span class="term"><code class="option">-l <em class="replaceable"><code>label</code></em></code><br /></span><span class="term"><code class="option">--label=<em class="replaceable"><code>label</code></em></code></span></dt><dd><p>
|
| 276 |
+
Sets the label for the backup. If none is specified, a default value of
|
| 277 |
+
<span class="quote">“<span class="quote"><code class="literal">pg_basebackup base backup</code></span>”</span> will be used.
|
| 278 |
+
</p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-clean</code></span></dt><dd><p>
|
| 279 |
+
By default, when <code class="command">pg_basebackup</code> aborts with an
|
| 280 |
+
error, it removes any directories it might have created before
|
| 281 |
+
discovering that it cannot finish the job (for example, the target
|
| 282 |
+
directory and write-ahead log directory). This option inhibits
|
| 283 |
+
tidying-up and is thus useful for debugging.
|
| 284 |
+
</p><p>
|
| 285 |
+
Note that tablespace directories are not cleaned up either way.
|
| 286 |
+
</p></dd><dt><span class="term"><code class="option">-N</code><br /></span><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>
|
| 287 |
+
By default, <code class="command">pg_basebackup</code> will wait for all files
|
| 288 |
+
to be written safely to disk. This option causes
|
| 289 |
+
<code class="command">pg_basebackup</code> to return without waiting, which is
|
| 290 |
+
faster, but means that a subsequent operating system crash can leave
|
| 291 |
+
the base backup corrupt. Generally, this option is useful for testing
|
| 292 |
+
but should not be used when creating a production installation.
|
| 293 |
+
</p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--progress</code></span></dt><dd><p>
|
| 294 |
+
Enables progress reporting. Turning this on will deliver an approximate
|
| 295 |
+
progress report during the backup. Since the database may change during
|
| 296 |
+
the backup, this is only an approximation and may not end at exactly
|
| 297 |
+
<code class="literal">100%</code>. In particular, when WAL log is included in the
|
| 298 |
+
backup, the total amount of data cannot be estimated in advance, and
|
| 299 |
+
in this case the estimated target size will increase once it passes the
|
| 300 |
+
total estimate without WAL.
|
| 301 |
+
</p></dd><dt><span class="term"><code class="option">-r <em class="replaceable"><code>rate</code></em></code><br /></span><span class="term"><code class="option">--max-rate=<em class="replaceable"><code>rate</code></em></code></span></dt><dd><p>
|
| 302 |
+
Sets the maximum transfer rate at which data is collected from the
|
| 303 |
+
source server. This can be useful to limit the impact
|
| 304 |
+
of <span class="application">pg_basebackup</span> on the server. Values
|
| 305 |
+
are in kilobytes per second. Use a suffix of <code class="literal">M</code>
|
| 306 |
+
to indicate megabytes per second. A suffix of <code class="literal">k</code>
|
| 307 |
+
is also accepted, and has no effect. Valid values are between 32
|
| 308 |
+
kilobytes per second and 1024 megabytes per second.
|
| 309 |
+
</p><p>
|
| 310 |
+
This option always affects transfer of the data directory. Transfer of
|
| 311 |
+
WAL files is only affected if the collection method
|
| 312 |
+
is <code class="literal">fetch</code>.
|
| 313 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>slotname</code></em></code><br /></span><span class="term"><code class="option">--slot=<em class="replaceable"><code>slotname</code></em></code></span></dt><dd><p>
|
| 314 |
+
This option can only be used together with <code class="literal">-X
|
| 315 |
+
stream</code>. It causes WAL streaming to use the specified
|
| 316 |
+
replication slot. If the base backup is intended to be used as a
|
| 317 |
+
streaming-replication standby using a replication slot, the standby
|
| 318 |
+
should then use the same replication slot name as
|
| 319 |
+
<a class="xref" href="runtime-config-replication.html#GUC-PRIMARY-SLOT-NAME">primary_slot_name</a>. This ensures that the
|
| 320 |
+
primary server does not remove any necessary WAL data in the time
|
| 321 |
+
between the end of the base backup and the start of streaming
|
| 322 |
+
replication on the new standby.
|
| 323 |
+
</p><p>
|
| 324 |
+
The specified replication slot has to exist unless the
|
| 325 |
+
option <code class="option">-C</code> is also used.
|
| 326 |
+
</p><p>
|
| 327 |
+
If this option is not specified and the server supports temporary
|
| 328 |
+
replication slots (version 10 and later), then a temporary replication
|
| 329 |
+
slot is automatically used for WAL streaming.
|
| 330 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 331 |
+
Enables verbose mode. Will output some extra steps during startup and
|
| 332 |
+
shutdown, as well as show the exact file name that is currently being
|
| 333 |
+
processed if progress reporting is also enabled.
|
| 334 |
+
</p></dd><dt><span class="term"><code class="option">--manifest-checksums=<em class="replaceable"><code>algorithm</code></em></code></span></dt><dd><p>
|
| 335 |
+
Specifies the checksum algorithm that should be applied to each file
|
| 336 |
+
included in the backup manifest. Currently, the available
|
| 337 |
+
algorithms are <code class="literal">NONE</code>, <code class="literal">CRC32C</code>,
|
| 338 |
+
<code class="literal">SHA224</code>, <code class="literal">SHA256</code>,
|
| 339 |
+
<code class="literal">SHA384</code>, and <code class="literal">SHA512</code>.
|
| 340 |
+
The default is <code class="literal">CRC32C</code>.
|
| 341 |
+
</p><p>
|
| 342 |
+
If <code class="literal">NONE</code> is selected, the backup manifest will
|
| 343 |
+
not contain any checksums. Otherwise, it will contain a checksum
|
| 344 |
+
of each file in the backup using the specified algorithm. In addition,
|
| 345 |
+
the manifest will always contain a <code class="literal">SHA256</code>
|
| 346 |
+
checksum of its own contents. The <code class="literal">SHA</code> algorithms
|
| 347 |
+
are significantly more CPU-intensive than <code class="literal">CRC32C</code>,
|
| 348 |
+
so selecting one of them may increase the time required to complete
|
| 349 |
+
the backup.
|
| 350 |
+
</p><p>
|
| 351 |
+
Using a SHA hash function provides a cryptographically secure digest
|
| 352 |
+
of each file for users who wish to verify that the backup has not been
|
| 353 |
+
tampered with, while the CRC32C algorithm provides a checksum that is
|
| 354 |
+
much faster to calculate; it is good at catching errors due to accidental
|
| 355 |
+
changes but is not resistant to malicious modifications. Note that, to
|
| 356 |
+
be useful against an adversary who has access to the backup, the backup
|
| 357 |
+
manifest would need to be stored securely elsewhere or otherwise
|
| 358 |
+
verified not to have been modified since the backup was taken.
|
| 359 |
+
</p><p>
|
| 360 |
+
<a class="xref" href="app-pgverifybackup.html" title="pg_verifybackup"><span class="refentrytitle"><span class="application">pg_verifybackup</span></span></a> can be used to check the
|
| 361 |
+
integrity of a backup against the backup manifest.
|
| 362 |
+
</p></dd><dt><span class="term"><code class="option">--manifest-force-encode</code></span></dt><dd><p>
|
| 363 |
+
Forces all filenames in the backup manifest to be hex-encoded.
|
| 364 |
+
If this option is not specified, only non-UTF8 filenames are
|
| 365 |
+
hex-encoded. This option is mostly intended to test that tools which
|
| 366 |
+
read a backup manifest file properly handle this case.
|
| 367 |
+
</p></dd><dt><span class="term"><code class="option">--no-estimate-size</code></span></dt><dd><p>
|
| 368 |
+
Prevents the server from estimating the total
|
| 369 |
+
amount of backup data that will be streamed, resulting in the
|
| 370 |
+
<code class="structfield">backup_total</code> column in the
|
| 371 |
+
<code class="structname">pg_stat_progress_basebackup</code> view
|
| 372 |
+
always being <code class="literal">NULL</code>.
|
| 373 |
+
</p><p>
|
| 374 |
+
Without this option, the backup will start by enumerating
|
| 375 |
+
the size of the entire database, and then go back and send
|
| 376 |
+
the actual contents. This may make the backup take slightly
|
| 377 |
+
longer, and in particular it will take longer before the first
|
| 378 |
+
data is sent. This option is useful to avoid such estimation
|
| 379 |
+
time if it's too long.
|
| 380 |
+
</p><p>
|
| 381 |
+
This option is not allowed when using <code class="option">--progress</code>.
|
| 382 |
+
</p></dd><dt><span class="term"><code class="option">--no-manifest</code></span></dt><dd><p>
|
| 383 |
+
Disables generation of a backup manifest. If this option is not
|
| 384 |
+
specified, the server will generate and send a backup manifest
|
| 385 |
+
which can be verified using <a class="xref" href="app-pgverifybackup.html" title="pg_verifybackup"><span class="refentrytitle"><span class="application">pg_verifybackup</span></span></a>.
|
| 386 |
+
The manifest is a list of every file present in the backup with the
|
| 387 |
+
exception of any WAL files that may be included. It also stores the
|
| 388 |
+
size, last modification time, and an optional checksum for each file.
|
| 389 |
+
</p></dd><dt><span class="term"><code class="option">--no-slot</code></span></dt><dd><p>
|
| 390 |
+
Prevents the creation of a temporary replication slot
|
| 391 |
+
for the backup.
|
| 392 |
+
</p><p>
|
| 393 |
+
By default, if log streaming is selected but no slot name is given
|
| 394 |
+
with the <code class="option">-S</code> option, then a temporary replication
|
| 395 |
+
slot is created (if supported by the source server).
|
| 396 |
+
</p><p>
|
| 397 |
+
The main purpose of this option is to allow taking a base backup when
|
| 398 |
+
the server has no free replication slots. Using a replication slot
|
| 399 |
+
is almost always preferred, because it prevents needed WAL from being
|
| 400 |
+
removed by the server during the backup.
|
| 401 |
+
</p></dd><dt><span class="term"><code class="option">--no-verify-checksums</code></span></dt><dd><p>
|
| 402 |
+
Disables verification of checksums, if they are enabled on the server
|
| 403 |
+
the base backup is taken from.
|
| 404 |
+
</p><p>
|
| 405 |
+
By default, checksums are verified and checksum failures will result
|
| 406 |
+
in a non-zero exit status. However, the base backup will not be
|
| 407 |
+
removed in such a case, as if the <code class="option">--no-clean</code> option
|
| 408 |
+
had been used. Checksum verification failures will also be reported
|
| 409 |
+
in the <a class="link" href="monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW" title="28.2.16. pg_stat_database">
|
| 410 |
+
<code class="structname">pg_stat_database</code></a> view.
|
| 411 |
+
</p></dd></dl></div><p>
|
| 412 |
+
</p><p>
|
| 413 |
+
The following command-line options control the connection to the source
|
| 414 |
+
server:
|
| 415 |
+
|
| 416 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d <em class="replaceable"><code>connstr</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>connstr</code></em></code></span></dt><dd><p>
|
| 417 |
+
Specifies parameters used to connect to the server, as a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>; these
|
| 418 |
+
will override any conflicting command line options.
|
| 419 |
+
</p><p>
|
| 420 |
+
The option is called <code class="literal">--dbname</code> for consistency with other
|
| 421 |
+
client applications, but because <span class="application">pg_basebackup</span>
|
| 422 |
+
doesn't connect to any particular database in the cluster, any database
|
| 423 |
+
name in the connection string will be ignored.
|
| 424 |
+
</p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 425 |
+
Specifies the host name of the machine on which the server is
|
| 426 |
+
running. If the value begins with a slash, it is used as the
|
| 427 |
+
directory for a Unix domain socket. The default is taken
|
| 428 |
+
from the <code class="envar">PGHOST</code> environment variable, if set,
|
| 429 |
+
else a Unix domain socket connection is attempted.
|
| 430 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 431 |
+
Specifies the TCP port or local Unix domain socket file
|
| 432 |
+
extension on which the server is listening for connections.
|
| 433 |
+
Defaults to the <code class="envar">PGPORT</code> environment variable, if
|
| 434 |
+
set, or a compiled-in default.
|
| 435 |
+
</p></dd><dt><span class="term"><code class="option">-s <em class="replaceable"><code>interval</code></em></code><br /></span><span class="term"><code class="option">--status-interval=<em class="replaceable"><code>interval</code></em></code></span></dt><dd><p>
|
| 436 |
+
Specifies the number of seconds between status packets sent back to
|
| 437 |
+
the source server. Smaller values allow more accurate monitoring of
|
| 438 |
+
backup progress from the server.
|
| 439 |
+
A value of zero disables periodic status updates completely,
|
| 440 |
+
although an update will still be sent when requested by the server, to
|
| 441 |
+
avoid timeout-based disconnects. The default value is 10 seconds.
|
| 442 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 443 |
+
Specifies the user name to connect as.
|
| 444 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 445 |
+
Prevents issuing a password prompt. If the server requires
|
| 446 |
+
password authentication and a password is not available by
|
| 447 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 448 |
+
connection attempt will fail. This option can be useful in
|
| 449 |
+
batch jobs and scripts where no user is present to enter a
|
| 450 |
+
password.
|
| 451 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 452 |
+
Forces <span class="application">pg_basebackup</span> to prompt for a
|
| 453 |
+
password before connecting to the source server.
|
| 454 |
+
</p><p>
|
| 455 |
+
This option is never essential, since
|
| 456 |
+
<span class="application">pg_basebackup</span> will automatically prompt
|
| 457 |
+
for a password if the server demands password authentication.
|
| 458 |
+
However, <span class="application">pg_basebackup</span> will waste a
|
| 459 |
+
connection attempt finding out that the server wants a password.
|
| 460 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 461 |
+
connection attempt.
|
| 462 |
+
</p></dd></dl></div><p>
|
| 463 |
+
</p><p>
|
| 464 |
+
Other options are also available:
|
| 465 |
+
|
| 466 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 467 |
+
Prints the <span class="application">pg_basebackup</span> version and exits.
|
| 468 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 469 |
+
Shows help about <span class="application">pg_basebackup</span> command line
|
| 470 |
+
arguments, and exits.
|
| 471 |
+
</p></dd></dl></div><p>
|
| 472 |
+
</p></div><div class="refsect1" id="id-1.9.4.10.7"><h2>Environment</h2><p>
|
| 473 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 474 |
+
uses the environment variables supported by <span class="application">libpq</span>
|
| 475 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 476 |
+
</p><p>
|
| 477 |
+
The environment variable <code class="envar">PG_COLOR</code> specifies whether to use
|
| 478 |
+
color in diagnostic messages. Possible values are
|
| 479 |
+
<code class="literal">always</code>, <code class="literal">auto</code> and
|
| 480 |
+
<code class="literal">never</code>.
|
| 481 |
+
</p></div><div class="refsect1" id="id-1.9.4.10.8"><h2>Notes</h2><p>
|
| 482 |
+
At the beginning of the backup, a checkpoint needs to be performed on the
|
| 483 |
+
source server. This can take some time (especially if the option
|
| 484 |
+
<code class="literal">--checkpoint=fast</code> is not used), during
|
| 485 |
+
which <span class="application">pg_basebackup</span> will appear to be idle.
|
| 486 |
+
</p><p>
|
| 487 |
+
The backup will include all files in the data directory and tablespaces,
|
| 488 |
+
including the configuration files and any additional files placed in the
|
| 489 |
+
directory by third parties, except certain temporary files managed by
|
| 490 |
+
PostgreSQL and operating system files. But only regular files and
|
| 491 |
+
directories are copied, except that
|
| 492 |
+
symbolic links used for tablespaces are preserved. Symbolic links pointing
|
| 493 |
+
to certain directories known to PostgreSQL are copied as empty directories.
|
| 494 |
+
Other symbolic links and special device files are skipped.
|
| 495 |
+
See <a class="xref" href="protocol-replication.html" title="55.4. Streaming Replication Protocol">Section 55.4</a> for the precise details.
|
| 496 |
+
</p><p>
|
| 497 |
+
In plain format, tablespaces will be backed up to the same path
|
| 498 |
+
they have on the source server, unless the
|
| 499 |
+
option <code class="literal">--tablespace-mapping</code> is used. Without
|
| 500 |
+
this option, running a plain format base backup on the same host as the
|
| 501 |
+
server will not work if tablespaces are in use, because the backup would
|
| 502 |
+
have to be written to the same directory locations as the original
|
| 503 |
+
tablespaces.
|
| 504 |
+
</p><p>
|
| 505 |
+
When tar format is used, it is the user's responsibility to unpack each
|
| 506 |
+
tar file before starting a PostgreSQL server that uses the data. If there
|
| 507 |
+
are additional tablespaces, the
|
| 508 |
+
tar files for them need to be unpacked in the correct locations. In this
|
| 509 |
+
case the symbolic links for those tablespaces will be created by the server
|
| 510 |
+
according to the contents of the <code class="filename">tablespace_map</code> file that is
|
| 511 |
+
included in the <code class="filename">base.tar</code> file.
|
| 512 |
+
</p><p>
|
| 513 |
+
<span class="application">pg_basebackup</span> works with servers of the same
|
| 514 |
+
or an older major version, down to 9.1. However, WAL streaming mode (<code class="literal">-X
|
| 515 |
+
stream</code>) only works with server version 9.3 and later, and tar format
|
| 516 |
+
(<code class="literal">--format=tar</code>) only works with server version 9.5
|
| 517 |
+
and later.
|
| 518 |
+
</p><p>
|
| 519 |
+
<span class="application">pg_basebackup</span> will preserve group permissions
|
| 520 |
+
for data files if group permissions are enabled on the source cluster.
|
| 521 |
+
</p></div><div class="refsect1" id="id-1.9.4.10.9"><h2>Examples</h2><p>
|
| 522 |
+
To create a base backup of the server at <code class="literal">mydbserver</code>
|
| 523 |
+
and store it in the local directory
|
| 524 |
+
<code class="filename">/usr/local/pgsql/data</code>:
|
| 525 |
+
</p><pre class="screen">
|
| 526 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</code></strong>
|
| 527 |
+
</pre><p>
|
| 528 |
+
</p><p>
|
| 529 |
+
To create a backup of the local server with one compressed
|
| 530 |
+
tar file for each tablespace, and store it in the directory
|
| 531 |
+
<code class="filename">backup</code>, showing a progress report while running:
|
| 532 |
+
</p><pre class="screen">
|
| 533 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -D backup -Ft -z -P</code></strong>
|
| 534 |
+
</pre><p>
|
| 535 |
+
</p><p>
|
| 536 |
+
To create a backup of a single-tablespace local database and compress
|
| 537 |
+
this with <span class="productname">bzip2</span>:
|
| 538 |
+
</p><pre class="screen">
|
| 539 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -D - -Ft -X fetch | bzip2 > backup.tar.bz2</code></strong>
|
| 540 |
+
</pre><p>
|
| 541 |
+
(This command will fail if there are multiple tablespaces in the
|
| 542 |
+
database.)
|
| 543 |
+
</p><p>
|
| 544 |
+
To create a backup of a local database where the tablespace in
|
| 545 |
+
<code class="filename">/opt/ts</code> is relocated
|
| 546 |
+
to <code class="filename">./backup/ts</code>:
|
| 547 |
+
</p><pre class="screen">
|
| 548 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -D backup/data -T /opt/ts=$(pwd)/backup/ts</code></strong>
|
| 549 |
+
</pre><p>
|
| 550 |
+
To create a backup of a local server with one tar file for each tablespace
|
| 551 |
+
compressed with <span class="application">gzip</span> at level 9, stored in the
|
| 552 |
+
directory <code class="filename">backup</code>:
|
| 553 |
+
</p><pre class="screen">
|
| 554 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -D backup -Ft --compress=gzip:9</code></strong>
|
| 555 |
+
</pre></div><div class="refsect1" id="id-1.9.4.10.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a>, <a class="xref" href="progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING" title="28.4.6. Base Backup Progress Reporting">Section 28.4.6</a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgamcheck.html" title="pg_amcheck">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pgbench.html" title="pgbench">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_amcheck</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pgbench</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgchecksums.html
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_checksums</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="pgarchivecleanup.html" title="pg_archivecleanup" /><link rel="next" href="app-pgcontroldata.html" title="pg_controldata" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_checksums</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgarchivecleanup.html" title="pg_archivecleanup">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgcontroldata.html" title="pg_controldata">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGCHECKSUMS"><div class="titlepage"></div><a id="id-1.9.5.5.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_checksums</span></span></h2><p>pg_checksums — enable, disable or check data checksums in a <span class="productname">PostgreSQL</span> database cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.5.4.1"><code class="command">pg_checksums</code> [<em class="replaceable"><code>option</code></em>...] [[ <code class="option">-D</code> | <code class="option">--pgdata</code> ]<em class="replaceable"><code>datadir</code></em>]</p></div></div><div class="refsect1" id="R1-APP-PGCHECKSUMS-1"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">pg_checksums</span> checks, enables or disables data
|
| 4 |
+
checksums in a <span class="productname">PostgreSQL</span> cluster. The server
|
| 5 |
+
must be shut down cleanly before running
|
| 6 |
+
<span class="application">pg_checksums</span>. When verifying checksums, the exit
|
| 7 |
+
status is zero if there are no checksum errors, and nonzero if at least one
|
| 8 |
+
checksum failure is detected. When enabling or disabling checksums, the
|
| 9 |
+
exit status is nonzero if the operation failed.
|
| 10 |
+
</p><p>
|
| 11 |
+
When verifying checksums, every file in the cluster is scanned. When
|
| 12 |
+
enabling checksums, each relation file block with a changed checksum is
|
| 13 |
+
rewritten in-place.
|
| 14 |
+
Disabling checksums only updates the file <code class="filename">pg_control</code>.
|
| 15 |
+
</p></div><div class="refsect1" id="id-1.9.5.5.6"><h2>Options</h2><p>
|
| 16 |
+
The following command-line options are available:
|
| 17 |
+
|
| 18 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
|
| 19 |
+
Specifies the directory where the database cluster is stored.
|
| 20 |
+
</p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--check</code></span></dt><dd><p>
|
| 21 |
+
Checks checksums. This is the default mode if nothing else is
|
| 22 |
+
specified.
|
| 23 |
+
</p></dd><dt><span class="term"><code class="option">-d</code><br /></span><span class="term"><code class="option">--disable</code></span></dt><dd><p>
|
| 24 |
+
Disables checksums.
|
| 25 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--enable</code></span></dt><dd><p>
|
| 26 |
+
Enables checksums.
|
| 27 |
+
</p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>filenode</code></em></code><br /></span><span class="term"><code class="option">--filenode=<em class="replaceable"><code>filenode</code></em></code></span></dt><dd><p>
|
| 28 |
+
Only validate checksums in the relation with filenode
|
| 29 |
+
<em class="replaceable"><code>filenode</code></em>.
|
| 30 |
+
</p></dd><dt><span class="term"><code class="option">-N</code><br /></span><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>
|
| 31 |
+
By default, <code class="command">pg_checksums</code> will wait for all files
|
| 32 |
+
to be written safely to disk. This option causes
|
| 33 |
+
<code class="command">pg_checksums</code> to return without waiting, which is
|
| 34 |
+
faster, but means that a subsequent operating system crash can leave
|
| 35 |
+
the updated data directory corrupt. Generally, this option is useful
|
| 36 |
+
for testing but should not be used on a production installation.
|
| 37 |
+
This option has no effect when using <code class="literal">--check</code>.
|
| 38 |
+
</p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--progress</code></span></dt><dd><p>
|
| 39 |
+
Enable progress reporting. Turning this on will deliver a progress
|
| 40 |
+
report while checking or enabling checksums.
|
| 41 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 42 |
+
Enable verbose output. Lists all checked files.
|
| 43 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 44 |
+
Print the <span class="application">pg_checksums</span> version and exit.
|
| 45 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 46 |
+
Show help about <span class="application">pg_checksums</span> command line
|
| 47 |
+
arguments, and exit.
|
| 48 |
+
</p></dd></dl></div><p>
|
| 49 |
+
</p></div><div class="refsect1" id="id-1.9.5.5.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>
|
| 50 |
+
Specifies the directory where the database cluster is
|
| 51 |
+
stored; can be overridden using the <code class="option">-D</code> option.
|
| 52 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 53 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 54 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 55 |
+
<code class="literal">never</code>.
|
| 56 |
+
</p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.5.8"><h2>Notes</h2><p>
|
| 57 |
+
Enabling checksums in a large cluster can potentially take a long time.
|
| 58 |
+
During this operation, the cluster or other programs that write to the
|
| 59 |
+
data directory must not be started or else data loss may occur.
|
| 60 |
+
</p><p>
|
| 61 |
+
When using a replication setup with tools which perform direct copies
|
| 62 |
+
of relation file blocks (for example <a class="xref" href="app-pgrewind.html" title="pg_rewind"><span class="refentrytitle"><span class="application">pg_rewind</span></span></a>),
|
| 63 |
+
enabling or disabling checksums can lead to page corruptions in the
|
| 64 |
+
shape of incorrect checksums if the operation is not done consistently
|
| 65 |
+
across all nodes. When enabling or disabling checksums in a replication
|
| 66 |
+
setup, it is thus recommended to stop all the clusters before switching
|
| 67 |
+
them all consistently. Destroying all standbys, performing the operation
|
| 68 |
+
on the primary and finally recreating the standbys from scratch is also
|
| 69 |
+
safe.
|
| 70 |
+
</p><p>
|
| 71 |
+
If <span class="application">pg_checksums</span> is aborted or killed while
|
| 72 |
+
enabling or disabling checksums, the cluster's data checksum configuration
|
| 73 |
+
remains unchanged, and <span class="application">pg_checksums</span> can be
|
| 74 |
+
re-run to perform the same operation.
|
| 75 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgarchivecleanup.html" title="pg_archivecleanup">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgcontroldata.html" title="pg_controldata">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_archivecleanup</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_controldata</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgconfig.html
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_config</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="pgbench.html" title="pgbench" /><link rel="next" href="app-pgdump.html" title="pg_dump" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_config</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgbench.html" title="pgbench">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgdump.html" title="pg_dump">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGCONFIG"><div class="titlepage"></div><a id="id-1.9.4.12.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_config</span></span></h2><p>pg_config — retrieve information about the installed version of <span class="productname">PostgreSQL</span></p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.12.4.1"><code class="command">pg_config</code> [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="id-1.9.4.12.5"><h2>Description</h2><p>
|
| 3 |
+
The <span class="application">pg_config</span> utility prints configuration parameters
|
| 4 |
+
of the currently installed version of <span class="productname">PostgreSQL</span>. It is
|
| 5 |
+
intended, for example, to be used by software packages that want to interface
|
| 6 |
+
to <span class="productname">PostgreSQL</span> to facilitate finding the required header files
|
| 7 |
+
and libraries.
|
| 8 |
+
</p></div><div class="refsect1" id="id-1.9.4.12.6"><h2>Options</h2><p>
|
| 9 |
+
To use <span class="application">pg_config</span>, supply one or more of the following
|
| 10 |
+
options:
|
| 11 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--bindir</code></span></dt><dd><p>
|
| 12 |
+
Print the location of user executables. Use this, for example, to find
|
| 13 |
+
the <code class="command">psql</code> program. This is normally also the location
|
| 14 |
+
where the <code class="filename">pg_config</code> program resides.
|
| 15 |
+
</p></dd><dt><span class="term"><code class="option">--docdir</code></span></dt><dd><p>
|
| 16 |
+
Print the location of documentation files.
|
| 17 |
+
</p></dd><dt><span class="term"><code class="option">--htmldir</code></span></dt><dd><p>
|
| 18 |
+
Print the location of HTML documentation files.
|
| 19 |
+
</p></dd><dt><span class="term"><code class="option">--includedir</code></span></dt><dd><p>
|
| 20 |
+
Print the location of C header files of the client interfaces.
|
| 21 |
+
</p></dd><dt><span class="term"><code class="option">--pkgincludedir</code></span></dt><dd><p>
|
| 22 |
+
Print the location of other C header files.
|
| 23 |
+
</p></dd><dt><span class="term"><code class="option">--includedir-server</code></span></dt><dd><p>
|
| 24 |
+
Print the location of C header files for server programming.
|
| 25 |
+
</p></dd><dt><span class="term"><code class="option">--libdir</code></span></dt><dd><p>
|
| 26 |
+
Print the location of object code libraries.
|
| 27 |
+
</p></dd><dt><span class="term"><code class="option">--pkglibdir</code></span></dt><dd><p>
|
| 28 |
+
Print the location of dynamically loadable modules, or where
|
| 29 |
+
the server would search for them. (Other
|
| 30 |
+
architecture-dependent data files might also be installed in this
|
| 31 |
+
directory.)
|
| 32 |
+
</p></dd><dt><span class="term"><code class="option">--localedir</code></span></dt><dd><p>
|
| 33 |
+
Print the location of locale support files. (This will be an empty
|
| 34 |
+
string if locale support was not configured when
|
| 35 |
+
<span class="productname">PostgreSQL</span> was built.)
|
| 36 |
+
</p></dd><dt><span class="term"><code class="option">--mandir</code></span></dt><dd><p>
|
| 37 |
+
Print the location of manual pages.
|
| 38 |
+
</p></dd><dt><span class="term"><code class="option">--sharedir</code></span></dt><dd><p>
|
| 39 |
+
Print the location of architecture-independent support files.
|
| 40 |
+
</p></dd><dt><span class="term"><code class="option">--sysconfdir</code></span></dt><dd><p>
|
| 41 |
+
Print the location of system-wide configuration files.
|
| 42 |
+
</p></dd><dt><span class="term"><code class="option">--pgxs</code></span></dt><dd><p>
|
| 43 |
+
Print the location of extension makefiles.
|
| 44 |
+
</p></dd><dt><span class="term"><code class="option">--configure</code></span></dt><dd><p>
|
| 45 |
+
Print the options that were given to the <code class="filename">configure</code>
|
| 46 |
+
script when <span class="productname">PostgreSQL</span> was configured for building.
|
| 47 |
+
This can be used to reproduce the identical configuration, or
|
| 48 |
+
to find out with what options a binary package was built. (Note
|
| 49 |
+
however that binary packages often contain vendor-specific custom
|
| 50 |
+
patches.) See also the examples below.
|
| 51 |
+
</p></dd><dt><span class="term"><code class="option">--cc</code></span></dt><dd><p>
|
| 52 |
+
Print the value of the <code class="varname">CC</code> variable that was used for building
|
| 53 |
+
<span class="productname">PostgreSQL</span>. This shows the C compiler used.
|
| 54 |
+
</p></dd><dt><span class="term"><code class="option">--cppflags</code></span></dt><dd><p>
|
| 55 |
+
Print the value of the <code class="varname">CPPFLAGS</code> variable that was used for building
|
| 56 |
+
<span class="productname">PostgreSQL</span>. This shows C compiler switches needed
|
| 57 |
+
at preprocessing time (typically, <code class="literal">-I</code> switches).
|
| 58 |
+
</p></dd><dt><span class="term"><code class="option">--cflags</code></span></dt><dd><p>
|
| 59 |
+
Print the value of the <code class="varname">CFLAGS</code> variable that was used for building
|
| 60 |
+
<span class="productname">PostgreSQL</span>. This shows C compiler switches.
|
| 61 |
+
</p></dd><dt><span class="term"><code class="option">--cflags_sl</code></span></dt><dd><p>
|
| 62 |
+
Print the value of the <code class="varname">CFLAGS_SL</code> variable that was used for building
|
| 63 |
+
<span class="productname">PostgreSQL</span>. This shows extra C compiler switches
|
| 64 |
+
used for building shared libraries.
|
| 65 |
+
</p></dd><dt><span class="term"><code class="option">--ldflags</code></span></dt><dd><p>
|
| 66 |
+
Print the value of the <code class="varname">LDFLAGS</code> variable that was used for building
|
| 67 |
+
<span class="productname">PostgreSQL</span>. This shows linker switches.
|
| 68 |
+
</p></dd><dt><span class="term"><code class="option">--ldflags_ex</code></span></dt><dd><p>
|
| 69 |
+
Print the value of the <code class="varname">LDFLAGS_EX</code> variable that was used for building
|
| 70 |
+
<span class="productname">PostgreSQL</span>. This shows linker switches
|
| 71 |
+
used for building executables only.
|
| 72 |
+
</p></dd><dt><span class="term"><code class="option">--ldflags_sl</code></span></dt><dd><p>
|
| 73 |
+
Print the value of the <code class="varname">LDFLAGS_SL</code> variable that was used for building
|
| 74 |
+
<span class="productname">PostgreSQL</span>. This shows linker switches
|
| 75 |
+
used for building shared libraries only.
|
| 76 |
+
</p></dd><dt><span class="term"><code class="option">--libs</code></span></dt><dd><p>
|
| 77 |
+
Print the value of the <code class="varname">LIBS</code> variable that was used for building
|
| 78 |
+
<span class="productname">PostgreSQL</span>. This normally contains <code class="literal">-l</code>
|
| 79 |
+
switches for external libraries linked into <span class="productname">PostgreSQL</span>.
|
| 80 |
+
</p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 81 |
+
Print the version of <span class="productname">PostgreSQL</span>.
|
| 82 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 83 |
+
Show help about <span class="application">pg_config</span> command line
|
| 84 |
+
arguments, and exit.
|
| 85 |
+
</p></dd></dl></div><p>
|
| 86 |
+
|
| 87 |
+
If more than one option is given, the information is printed in that order,
|
| 88 |
+
one item per line. If no options are given, all available information
|
| 89 |
+
is printed, with labels.
|
| 90 |
+
</p></div><div class="refsect1" id="id-1.9.4.12.7"><h2>Notes</h2><p>
|
| 91 |
+
The options <code class="option">--docdir</code>, <code class="option">--pkgincludedir</code>,
|
| 92 |
+
<code class="option">--localedir</code>, <code class="option">--mandir</code>,
|
| 93 |
+
<code class="option">--sharedir</code>, <code class="option">--sysconfdir</code>,
|
| 94 |
+
<code class="option">--cc</code>, <code class="option">--cppflags</code>,
|
| 95 |
+
<code class="option">--cflags</code>, <code class="option">--cflags_sl</code>,
|
| 96 |
+
<code class="option">--ldflags</code>, <code class="option">--ldflags_sl</code>,
|
| 97 |
+
and <code class="option">--libs</code> were added in <span class="productname">PostgreSQL</span> 8.1.
|
| 98 |
+
The option <code class="option">--htmldir</code> was added in <span class="productname">PostgreSQL</span> 8.4.
|
| 99 |
+
The option <code class="option">--ldflags_ex</code> was added in <span class="productname">PostgreSQL</span> 9.0.
|
| 100 |
+
</p></div><div class="refsect1" id="id-1.9.4.12.8"><h2>Example</h2><p>
|
| 101 |
+
To reproduce the build configuration of the current PostgreSQL
|
| 102 |
+
installation, run the following command:
|
| 103 |
+
</p><pre class="programlisting">
|
| 104 |
+
eval ./configure `pg_config --configure`
|
| 105 |
+
</pre><p>
|
| 106 |
+
The output of <code class="literal">pg_config --configure</code> contains
|
| 107 |
+
shell quotation marks so arguments with spaces are represented
|
| 108 |
+
correctly. Therefore, using <code class="literal">eval</code> is required
|
| 109 |
+
for proper results.
|
| 110 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgbench.html" title="pgbench">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgdump.html" title="pg_dump">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pgbench</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_dump</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgcontroldata.html
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_controldata</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgchecksums.html" title="pg_checksums" /><link rel="next" href="app-pg-ctl.html" title="pg_ctl" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_controldata</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgchecksums.html" title="pg_checksums">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pg-ctl.html" title="pg_ctl">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGCONTROLDATA"><div class="titlepage"></div><a id="id-1.9.5.6.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_controldata</span></span></h2><p>pg_controldata — display control information of a <span class="productname">PostgreSQL</span> database cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.6.4.1"><code class="command">pg_controldata</code> [<em class="replaceable"><code>option</code></em>] [[ <code class="option">-D</code> | <code class="option">--pgdata</code> ]<em class="replaceable"><code>datadir</code></em>]</p></div></div><div class="refsect1" id="R1-APP-PGCONTROLDATA-1"><h2>Description</h2><p>
|
| 3 |
+
<code class="command">pg_controldata</code> prints information initialized during
|
| 4 |
+
<code class="command">initdb</code>, such as the catalog version.
|
| 5 |
+
It also shows information about write-ahead logging and checkpoint
|
| 6 |
+
processing. This information is cluster-wide, and not specific to any one
|
| 7 |
+
database.
|
| 8 |
+
</p><p>
|
| 9 |
+
This utility can only be run by the user who initialized the cluster because
|
| 10 |
+
it requires read access to the data directory.
|
| 11 |
+
You can specify the data directory on the command line, or use
|
| 12 |
+
the environment variable <code class="envar">PGDATA</code>. This utility supports the options
|
| 13 |
+
<code class="option">-V</code> and <code class="option">--version</code>, which print the
|
| 14 |
+
<span class="application">pg_controldata</span> version and exit. It also
|
| 15 |
+
supports options <code class="option">-?</code> and <code class="option">--help</code>, which output the
|
| 16 |
+
supported arguments.
|
| 17 |
+
</p></div><div class="refsect1" id="id-1.9.5.6.6"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>
|
| 18 |
+
Default data directory location
|
| 19 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 20 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 21 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 22 |
+
<code class="literal">never</code>.
|
| 23 |
+
</p></dd></dl></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgchecksums.html" title="pg_checksums">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pg-ctl.html" title="pg_ctl">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_checksums</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_ctl</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgdump.html
ADDED
|
@@ -0,0 +1,863 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_dump</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgconfig.html" title="pg_config" /><link rel="next" href="app-pg-dumpall.html" title="pg_dumpall" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_dump</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgconfig.html" title="pg_config">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pg-dumpall.html" title="pg_dumpall">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGDUMP"><div class="titlepage"></div><a id="id-1.9.4.13.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_dump</span></span></h2><p>pg_dump —
|
| 3 |
+
extract a <span class="productname">PostgreSQL</span> database into a script file or other archive file
|
| 4 |
+
</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.13.4.1"><code class="command">pg_dump</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>dbname</code></em>]</p></div></div><div class="refsect1" id="PG-DUMP-DESCRIPTION"><h2>Description</h2><p>
|
| 5 |
+
<span class="application">pg_dump</span> is a utility for backing up a
|
| 6 |
+
<span class="productname">PostgreSQL</span> database. It makes consistent
|
| 7 |
+
backups even if the database is being used concurrently.
|
| 8 |
+
<span class="application">pg_dump</span> does not block other users
|
| 9 |
+
accessing the database (readers or writers).
|
| 10 |
+
</p><p>
|
| 11 |
+
<span class="application">pg_dump</span> only dumps a single database.
|
| 12 |
+
To back up an entire cluster, or to back up global objects that are
|
| 13 |
+
common to all databases in a cluster (such as roles and tablespaces),
|
| 14 |
+
use <a class="xref" href="app-pg-dumpall.html" title="pg_dumpall"><span class="refentrytitle"><span class="application">pg_dumpall</span></span></a>.
|
| 15 |
+
</p><p>
|
| 16 |
+
Dumps can be output in script or archive file formats. Script
|
| 17 |
+
dumps are plain-text files containing the SQL commands required
|
| 18 |
+
to reconstruct the database to the state it was in at the time it was
|
| 19 |
+
saved. To restore from such a script, feed it to <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a>. Script files
|
| 20 |
+
can be used to reconstruct the database even on other machines and
|
| 21 |
+
other architectures; with some modifications, even on other SQL
|
| 22 |
+
database products.
|
| 23 |
+
</p><p>
|
| 24 |
+
The alternative archive file formats must be used with
|
| 25 |
+
<a class="xref" href="app-pgrestore.html" title="pg_restore"><span class="refentrytitle"><span class="application">pg_restore</span></span></a> to rebuild the database. They
|
| 26 |
+
allow <span class="application">pg_restore</span> to be selective about
|
| 27 |
+
what is restored, or even to reorder the items prior to being
|
| 28 |
+
restored.
|
| 29 |
+
The archive file formats are designed to be portable across
|
| 30 |
+
architectures.
|
| 31 |
+
</p><p>
|
| 32 |
+
When used with one of the archive file formats and combined with
|
| 33 |
+
<span class="application">pg_restore</span>,
|
| 34 |
+
<span class="application">pg_dump</span> provides a flexible archival and
|
| 35 |
+
transfer mechanism. <span class="application">pg_dump</span> can be used to
|
| 36 |
+
backup an entire database, then <span class="application">pg_restore</span>
|
| 37 |
+
can be used to examine the archive and/or select which parts of the
|
| 38 |
+
database are to be restored. The most flexible output file formats are
|
| 39 |
+
the <span class="quote">“<span class="quote">custom</span>”</span> format (<code class="option">-Fc</code>) and the
|
| 40 |
+
<span class="quote">“<span class="quote">directory</span>”</span> format (<code class="option">-Fd</code>). They allow
|
| 41 |
+
for selection and reordering of all archived items, support parallel
|
| 42 |
+
restoration, and are compressed by default. The <span class="quote">“<span class="quote">directory</span>”</span>
|
| 43 |
+
format is the only format that supports parallel dumps.
|
| 44 |
+
</p><p>
|
| 45 |
+
While running <span class="application">pg_dump</span>, one should examine the
|
| 46 |
+
output for any warnings (printed on standard error), especially in
|
| 47 |
+
light of the limitations listed below.
|
| 48 |
+
</p></div><div class="refsect1" id="PG-DUMP-OPTIONS"><h2>Options</h2><p>
|
| 49 |
+
The following command-line options control the content and
|
| 50 |
+
format of the output.
|
| 51 |
+
|
| 52 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>dbname</code></em></span></dt><dd><p>
|
| 53 |
+
Specifies the name of the database to be dumped. If this is
|
| 54 |
+
not specified, the environment variable
|
| 55 |
+
<code class="envar">PGDATABASE</code> is used. If that is not set, the
|
| 56 |
+
user name specified for the connection is used.
|
| 57 |
+
</p></dd><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--data-only</code></span></dt><dd><p>
|
| 58 |
+
Dump only the data, not the schema (data definitions).
|
| 59 |
+
Table data, large objects, and sequence values are dumped.
|
| 60 |
+
</p><p>
|
| 61 |
+
This option is similar to, but for historical reasons not identical
|
| 62 |
+
to, specifying <code class="option">--section=data</code>.
|
| 63 |
+
</p></dd><dt><span class="term"><code class="option">-b</code><br /></span><span class="term"><code class="option">--large-objects</code><br /></span><span class="term"><code class="option">--blobs</code> (deprecated)</span></dt><dd><p>
|
| 64 |
+
Include large objects in the dump. This is the default behavior
|
| 65 |
+
except when <code class="option">--schema</code>, <code class="option">--table</code>, or
|
| 66 |
+
<code class="option">--schema-only</code> is specified. The <code class="option">-b</code>
|
| 67 |
+
switch is therefore only useful to add large objects to dumps
|
| 68 |
+
where a specific schema or table has been requested. Note that
|
| 69 |
+
large objects are considered data and therefore will be included when
|
| 70 |
+
<code class="option">--data-only</code> is used, but not
|
| 71 |
+
when <code class="option">--schema-only</code> is.
|
| 72 |
+
</p></dd><dt><span class="term"><code class="option">-B</code><br /></span><span class="term"><code class="option">--no-large-objects</code><br /></span><span class="term"><code class="option">--no-blobs</code> (deprecated)</span></dt><dd><p>
|
| 73 |
+
Exclude large objects in the dump.
|
| 74 |
+
</p><p>
|
| 75 |
+
When both <code class="option">-b</code> and <code class="option">-B</code> are given, the behavior
|
| 76 |
+
is to output large objects, when data is being dumped, see the
|
| 77 |
+
<code class="option">-b</code> documentation.
|
| 78 |
+
</p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--clean</code></span></dt><dd><p>
|
| 79 |
+
Output commands to <code class="command">DROP</code> all the dumped
|
| 80 |
+
database objects prior to outputting the commands for creating them.
|
| 81 |
+
This option is useful when the restore is to overwrite an existing
|
| 82 |
+
database. If any of the objects do not exist in the destination
|
| 83 |
+
database, ignorable error messages will be reported during
|
| 84 |
+
restore, unless <code class="option">--if-exists</code> is also specified.
|
| 85 |
+
</p><p>
|
| 86 |
+
This option is ignored when emitting an archive (non-text) output
|
| 87 |
+
file. For the archive formats, you can specify the option when you
|
| 88 |
+
call <code class="command">pg_restore</code>.
|
| 89 |
+
</p></dd><dt><span class="term"><code class="option">-C</code><br /></span><span class="term"><code class="option">--create</code></span></dt><dd><p>
|
| 90 |
+
Begin the output with a command to create the
|
| 91 |
+
database itself and reconnect to the created database. (With a
|
| 92 |
+
script of this form, it doesn't matter which database in the
|
| 93 |
+
destination installation you connect to before running the script.)
|
| 94 |
+
If <code class="option">--clean</code> is also specified, the script drops and
|
| 95 |
+
recreates the target database before reconnecting to it.
|
| 96 |
+
</p><p>
|
| 97 |
+
With <code class="option">--create</code>, the output also includes the
|
| 98 |
+
database's comment if any, and any configuration variable settings
|
| 99 |
+
that are specific to this database, that is,
|
| 100 |
+
any <code class="command">ALTER DATABASE ... SET ...</code>
|
| 101 |
+
and <code class="command">ALTER ROLE ... IN DATABASE ... SET ...</code>
|
| 102 |
+
commands that mention this database.
|
| 103 |
+
Access privileges for the database itself are also dumped,
|
| 104 |
+
unless <code class="option">--no-acl</code> is specified.
|
| 105 |
+
</p><p>
|
| 106 |
+
This option is ignored when emitting an archive (non-text) output
|
| 107 |
+
file. For the archive formats, you can specify the option when you
|
| 108 |
+
call <code class="command">pg_restore</code>.
|
| 109 |
+
</p></dd><dt><span class="term"><code class="option">-e <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--extension=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 110 |
+
Dump only extensions matching <em class="replaceable"><code>pattern</code></em>. When this option is not
|
| 111 |
+
specified, all non-system extensions in the target database will be
|
| 112 |
+
dumped. Multiple extensions can be selected by writing multiple
|
| 113 |
+
<code class="option">-e</code> switches. The <em class="replaceable"><code>pattern</code></em> parameter is interpreted as a
|
| 114 |
+
pattern according to the same rules used by
|
| 115 |
+
<span class="application">psql</span>'s <code class="literal">\d</code> commands (see
|
| 116 |
+
<a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns">Patterns</a>), so multiple extensions can also
|
| 117 |
+
be selected by writing wildcard characters in the pattern. When using
|
| 118 |
+
wildcards, be careful to quote the pattern if needed to prevent the
|
| 119 |
+
shell from expanding the wildcards.
|
| 120 |
+
</p><p>
|
| 121 |
+
Any configuration relation registered by
|
| 122 |
+
<code class="function">pg_extension_config_dump</code> is included in the
|
| 123 |
+
dump if its extension is specified by <code class="option">--extension</code>.
|
| 124 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 125 |
+
When <code class="option">-e</code> is specified,
|
| 126 |
+
<span class="application">pg_dump</span> makes no attempt to dump any other
|
| 127 |
+
database objects that the selected extension(s) might depend upon.
|
| 128 |
+
Therefore, there is no guarantee that the results of a
|
| 129 |
+
specific-extension dump can be successfully restored by themselves
|
| 130 |
+
into a clean database.
|
| 131 |
+
</p></div></dd><dt><span class="term"><code class="option">-E <em class="replaceable"><code>encoding</code></em></code><br /></span><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span></dt><dd><p>
|
| 132 |
+
Create the dump in the specified character set encoding. By default,
|
| 133 |
+
the dump is created in the database encoding. (Another way to get the
|
| 134 |
+
same result is to set the <code class="envar">PGCLIENTENCODING</code> environment
|
| 135 |
+
variable to the desired dump encoding.) The supported encodings are
|
| 136 |
+
described in <a class="xref" href="multibyte.html#MULTIBYTE-CHARSET-SUPPORTED" title="24.3.1. Supported Character Sets">Section 24.3.1</a>.
|
| 137 |
+
</p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>file</code></em></code><br /></span><span class="term"><code class="option">--file=<em class="replaceable"><code>file</code></em></code></span></dt><dd><p>
|
| 138 |
+
Send output to the specified file. This parameter can be omitted for
|
| 139 |
+
file based output formats, in which case the standard output is used.
|
| 140 |
+
It must be given for the directory output format however, where it
|
| 141 |
+
specifies the target directory instead of a file. In this case the
|
| 142 |
+
directory is created by <code class="command">pg_dump</code> and must not exist
|
| 143 |
+
before.
|
| 144 |
+
</p></dd><dt><span class="term"><code class="option">-F <em class="replaceable"><code>format</code></em></code><br /></span><span class="term"><code class="option">--format=<em class="replaceable"><code>format</code></em></code></span></dt><dd><p>
|
| 145 |
+
Selects the format of the output.
|
| 146 |
+
<em class="replaceable"><code>format</code></em> can be one of the following:
|
| 147 |
+
|
| 148 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">p</code><br /></span><span class="term"><code class="literal">plain</code></span></dt><dd><p>
|
| 149 |
+
Output a plain-text <acronym class="acronym">SQL</acronym> script file (the default).
|
| 150 |
+
</p></dd><dt><span class="term"><code class="literal">c</code><br /></span><span class="term"><code class="literal">custom</code></span></dt><dd><p>
|
| 151 |
+
Output a custom-format archive suitable for input into
|
| 152 |
+
<span class="application">pg_restore</span>.
|
| 153 |
+
Together with the directory output format, this is the most flexible
|
| 154 |
+
output format in that it allows manual selection and reordering of
|
| 155 |
+
archived items during restore. This format is also compressed by
|
| 156 |
+
default.
|
| 157 |
+
</p></dd><dt><span class="term"><code class="literal">d</code><br /></span><span class="term"><code class="literal">directory</code></span></dt><dd><p>
|
| 158 |
+
Output a directory-format archive suitable for input into
|
| 159 |
+
<span class="application">pg_restore</span>. This will create a directory
|
| 160 |
+
with one file for each table and large object being dumped, plus a
|
| 161 |
+
so-called Table of Contents file describing the dumped objects in a
|
| 162 |
+
machine-readable format that <span class="application">pg_restore</span>
|
| 163 |
+
can read. A directory format archive can be manipulated with
|
| 164 |
+
standard Unix tools; for example, files in an uncompressed archive
|
| 165 |
+
can be compressed with the <span class="application">gzip</span>,
|
| 166 |
+
<span class="application">lz4</span>, or
|
| 167 |
+
<span class="application">zstd</span> tools.
|
| 168 |
+
This format is compressed by default using <code class="literal">gzip</code>
|
| 169 |
+
and also supports parallel dumps.
|
| 170 |
+
</p></dd><dt><span class="term"><code class="literal">t</code><br /></span><span class="term"><code class="literal">tar</code></span></dt><dd><p>
|
| 171 |
+
Output a <code class="command">tar</code>-format archive suitable for input
|
| 172 |
+
into <span class="application">pg_restore</span>. The tar format is
|
| 173 |
+
compatible with the directory format: extracting a tar-format
|
| 174 |
+
archive produces a valid directory-format archive.
|
| 175 |
+
However, the tar format does not support compression. Also, when
|
| 176 |
+
using tar format the relative order of table data items cannot be
|
| 177 |
+
changed during restore.
|
| 178 |
+
</p></dd></dl></div></dd><dt><span class="term"><code class="option">-j <em class="replaceable"><code>njobs</code></em></code><br /></span><span class="term"><code class="option">--jobs=<em class="replaceable"><code>njobs</code></em></code></span></dt><dd><p>
|
| 179 |
+
Run the dump in parallel by dumping <em class="replaceable"><code>njobs</code></em>
|
| 180 |
+
tables simultaneously. This option may reduce the time needed to perform the dump but it also
|
| 181 |
+
increases the load on the database server. You can only use this option with the
|
| 182 |
+
directory output format because this is the only output format where multiple processes
|
| 183 |
+
can write their data at the same time.
|
| 184 |
+
</p><p><span class="application">pg_dump</span> will open <em class="replaceable"><code>njobs</code></em>
|
| 185 |
+
+ 1 connections to the database, so make sure your <a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a>
|
| 186 |
+
setting is high enough to accommodate all connections.
|
| 187 |
+
</p><p>
|
| 188 |
+
Requesting exclusive locks on database objects while running a parallel dump could
|
| 189 |
+
cause the dump to fail. The reason is that the <span class="application">pg_dump</span> leader process
|
| 190 |
+
requests shared locks (<a class="link" href="explicit-locking.html#LOCKING-TABLES" title="13.3.1. Table-Level Locks">ACCESS SHARE</a>) on the
|
| 191 |
+
objects that the worker processes are going to dump later in order to
|
| 192 |
+
make sure that nobody deletes them and makes them go away while the dump is running.
|
| 193 |
+
If another client then requests an exclusive lock on a table, that lock will not be
|
| 194 |
+
granted but will be queued waiting for the shared lock of the leader process to be
|
| 195 |
+
released. Consequently any other access to the table will not be granted either and
|
| 196 |
+
will queue after the exclusive lock request. This includes the worker process trying
|
| 197 |
+
to dump the table. Without any precautions this would be a classic deadlock situation.
|
| 198 |
+
To detect this conflict, the <span class="application">pg_dump</span> worker process requests another
|
| 199 |
+
shared lock using the <code class="literal">NOWAIT</code> option. If the worker process is not granted
|
| 200 |
+
this shared lock, somebody else must have requested an exclusive lock in the meantime
|
| 201 |
+
and there is no way to continue with the dump, so <span class="application">pg_dump</span> has no choice
|
| 202 |
+
but to abort the dump.
|
| 203 |
+
</p><p>
|
| 204 |
+
To perform a parallel dump, the database server needs to support
|
| 205 |
+
synchronized snapshots, a feature that was introduced in
|
| 206 |
+
<span class="productname">PostgreSQL</span> 9.2 for primary servers and 10
|
| 207 |
+
for standbys. With this feature, database clients can ensure they see
|
| 208 |
+
the same data set even though they use different connections.
|
| 209 |
+
<code class="command">pg_dump -j</code> uses multiple database connections; it
|
| 210 |
+
connects to the database once with the leader process and once again
|
| 211 |
+
for each worker job. Without the synchronized snapshot feature, the
|
| 212 |
+
different worker jobs wouldn't be guaranteed to see the same data in
|
| 213 |
+
each connection, which could lead to an inconsistent backup.
|
| 214 |
+
</p></dd><dt><span class="term"><code class="option">-n <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--schema=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 215 |
+
Dump only schemas matching <em class="replaceable"><code>pattern</code></em>; this selects both the
|
| 216 |
+
schema itself, and all its contained objects. When this option is
|
| 217 |
+
not specified, all non-system schemas in the target database will be
|
| 218 |
+
dumped. Multiple schemas can be
|
| 219 |
+
selected by writing multiple <code class="option">-n</code> switches. The
|
| 220 |
+
<em class="replaceable"><code>pattern</code></em> parameter is
|
| 221 |
+
interpreted as a pattern according to the same rules used by
|
| 222 |
+
<span class="application">psql</span>'s <code class="literal">\d</code> commands
|
| 223 |
+
(see <a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns">Patterns</a>),
|
| 224 |
+
so multiple schemas can also be selected by writing wildcard characters
|
| 225 |
+
in the pattern. When using wildcards, be careful to quote the pattern
|
| 226 |
+
if needed to prevent the shell from expanding the wildcards; see
|
| 227 |
+
<a class="xref" href="app-pgdump.html#PG-DUMP-EXAMPLES" title="Examples">Examples</a> below.
|
| 228 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 229 |
+
When <code class="option">-n</code> is specified, <span class="application">pg_dump</span>
|
| 230 |
+
makes no attempt to dump any other database objects that the selected
|
| 231 |
+
schema(s) might depend upon. Therefore, there is no guarantee
|
| 232 |
+
that the results of a specific-schema dump can be successfully
|
| 233 |
+
restored by themselves into a clean database.
|
| 234 |
+
</p></div><div class="note"><h3 class="title">Note</h3><p>
|
| 235 |
+
Non-schema objects such as large objects are not dumped when <code class="option">-n</code> is
|
| 236 |
+
specified. You can add large objects back to the dump with the
|
| 237 |
+
<code class="option">--large-objects</code> switch.
|
| 238 |
+
</p></div></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-schema=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 239 |
+
Do not dump any schemas matching <em class="replaceable"><code>pattern</code></em>. The pattern is
|
| 240 |
+
interpreted according to the same rules as for <code class="option">-n</code>.
|
| 241 |
+
<code class="option">-N</code> can be given more than once to exclude schemas
|
| 242 |
+
matching any of several patterns.
|
| 243 |
+
</p><p>
|
| 244 |
+
When both <code class="option">-n</code> and <code class="option">-N</code> are given, the behavior
|
| 245 |
+
is to dump just the schemas that match at least one <code class="option">-n</code>
|
| 246 |
+
switch but no <code class="option">-N</code> switches. If <code class="option">-N</code> appears
|
| 247 |
+
without <code class="option">-n</code>, then schemas matching <code class="option">-N</code> are
|
| 248 |
+
excluded from what is otherwise a normal dump.
|
| 249 |
+
</p></dd><dt><span class="term"><code class="option">-O</code><br /></span><span class="term"><code class="option">--no-owner</code></span></dt><dd><p>
|
| 250 |
+
Do not output commands to set
|
| 251 |
+
ownership of objects to match the original database.
|
| 252 |
+
By default, <span class="application">pg_dump</span> issues
|
| 253 |
+
<code class="command">ALTER OWNER</code> or
|
| 254 |
+
<code class="command">SET SESSION AUTHORIZATION</code>
|
| 255 |
+
statements to set ownership of created database objects.
|
| 256 |
+
These statements
|
| 257 |
+
will fail when the script is run unless it is started by a superuser
|
| 258 |
+
(or the same user that owns all of the objects in the script).
|
| 259 |
+
To make a script that can be restored by any user, but will give
|
| 260 |
+
that user ownership of all the objects, specify <code class="option">-O</code>.
|
| 261 |
+
</p><p>
|
| 262 |
+
This option is ignored when emitting an archive (non-text) output
|
| 263 |
+
file. For the archive formats, you can specify the option when you
|
| 264 |
+
call <code class="command">pg_restore</code>.
|
| 265 |
+
</p></dd><dt><span class="term"><code class="option">-R</code><br /></span><span class="term"><code class="option">--no-reconnect</code></span></dt><dd><p>
|
| 266 |
+
This option is obsolete but still accepted for backwards
|
| 267 |
+
compatibility.
|
| 268 |
+
</p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--schema-only</code></span></dt><dd><p>
|
| 269 |
+
Dump only the object definitions (schema), not data.
|
| 270 |
+
</p><p>
|
| 271 |
+
This option is the inverse of <code class="option">--data-only</code>.
|
| 272 |
+
It is similar to, but for historical reasons not identical to,
|
| 273 |
+
specifying
|
| 274 |
+
<code class="option">--section=pre-data --section=post-data</code>.
|
| 275 |
+
</p><p>
|
| 276 |
+
(Do not confuse this with the <code class="option">--schema</code> option, which
|
| 277 |
+
uses the word <span class="quote">“<span class="quote">schema</span>”</span> in a different meaning.)
|
| 278 |
+
</p><p>
|
| 279 |
+
To exclude table data for only a subset of tables in the database,
|
| 280 |
+
see <code class="option">--exclude-table-data</code>.
|
| 281 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--superuser=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 282 |
+
Specify the superuser user name to use when disabling triggers.
|
| 283 |
+
This is relevant only if <code class="option">--disable-triggers</code> is used.
|
| 284 |
+
(Usually, it's better to leave this out, and instead start the
|
| 285 |
+
resulting script as superuser.)
|
| 286 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--table=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 287 |
+
Dump only tables with names matching
|
| 288 |
+
<em class="replaceable"><code>pattern</code></em>. Multiple tables
|
| 289 |
+
can be selected by writing multiple <code class="option">-t</code> switches. The
|
| 290 |
+
<em class="replaceable"><code>pattern</code></em> parameter is
|
| 291 |
+
interpreted as a pattern according to the same rules used by
|
| 292 |
+
<span class="application">psql</span>'s <code class="literal">\d</code> commands
|
| 293 |
+
(see <a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns">Patterns</a>),
|
| 294 |
+
so multiple tables can also be selected by writing wildcard characters
|
| 295 |
+
in the pattern. When using wildcards, be careful to quote the pattern
|
| 296 |
+
if needed to prevent the shell from expanding the wildcards; see
|
| 297 |
+
<a class="xref" href="app-pgdump.html#PG-DUMP-EXAMPLES" title="Examples">Examples</a> below.
|
| 298 |
+
</p><p>
|
| 299 |
+
As well as tables, this option can be used to dump the definition of matching
|
| 300 |
+
views, materialized views, foreign tables, and sequences. It will not dump the
|
| 301 |
+
contents of views or materialized views, and the contents of foreign tables will
|
| 302 |
+
only be dumped if the corresponding foreign server is specified with
|
| 303 |
+
<code class="option">--include-foreign-data</code>.
|
| 304 |
+
</p><p>
|
| 305 |
+
The <code class="option">-n</code> and <code class="option">-N</code> switches have no effect when
|
| 306 |
+
<code class="option">-t</code> is used, because tables selected by <code class="option">-t</code> will
|
| 307 |
+
be dumped regardless of those switches, and non-table objects will not
|
| 308 |
+
be dumped.
|
| 309 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 310 |
+
When <code class="option">-t</code> is specified, <span class="application">pg_dump</span>
|
| 311 |
+
makes no attempt to dump any other database objects that the selected
|
| 312 |
+
table(s) might depend upon. Therefore, there is no guarantee
|
| 313 |
+
that the results of a specific-table dump can be successfully
|
| 314 |
+
restored by themselves into a clean database.
|
| 315 |
+
</p></div></dd><dt><span class="term"><code class="option">-T <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-table=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 316 |
+
Do not dump any tables matching <em class="replaceable"><code>pattern</code></em>. The pattern is
|
| 317 |
+
interpreted according to the same rules as for <code class="option">-t</code>.
|
| 318 |
+
<code class="option">-T</code> can be given more than once to exclude tables
|
| 319 |
+
matching any of several patterns.
|
| 320 |
+
</p><p>
|
| 321 |
+
When both <code class="option">-t</code> and <code class="option">-T</code> are given, the behavior
|
| 322 |
+
is to dump just the tables that match at least one <code class="option">-t</code>
|
| 323 |
+
switch but no <code class="option">-T</code> switches. If <code class="option">-T</code> appears
|
| 324 |
+
without <code class="option">-t</code>, then tables matching <code class="option">-T</code> are
|
| 325 |
+
excluded from what is otherwise a normal dump.
|
| 326 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 327 |
+
Specifies verbose mode. This will cause
|
| 328 |
+
<span class="application">pg_dump</span> to output detailed object
|
| 329 |
+
comments and start/stop times to the dump file, and progress
|
| 330 |
+
messages to standard error.
|
| 331 |
+
Repeating the option causes additional debug-level messages
|
| 332 |
+
to appear on standard error.
|
| 333 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 334 |
+
Print the <span class="application">pg_dump</span> version and exit.
|
| 335 |
+
</p></dd><dt><span class="term"><code class="option">-x</code><br /></span><span class="term"><code class="option">--no-privileges</code><br /></span><span class="term"><code class="option">--no-acl</code></span></dt><dd><p>
|
| 336 |
+
Prevent dumping of access privileges (grant/revoke commands).
|
| 337 |
+
</p></dd><dt><span class="term"><code class="option">-Z <em class="replaceable"><code>level</code></em></code><br /></span><span class="term"><code class="option">-Z <em class="replaceable"><code>method</code></em></code>[:<em class="replaceable"><code>detail</code></em>]<br /></span><span class="term"><code class="option">--compress=<em class="replaceable"><code>level</code></em></code><br /></span><span class="term"><code class="option">--compress=<em class="replaceable"><code>method</code></em></code>[:<em class="replaceable"><code>detail</code></em>]</span></dt><dd><p>
|
| 338 |
+
Specify the compression method and/or the compression level to use.
|
| 339 |
+
The compression method can be set to <code class="literal">gzip</code>,
|
| 340 |
+
<code class="literal">lz4</code>, <code class="literal">zstd</code>,
|
| 341 |
+
or <code class="literal">none</code> for no compression.
|
| 342 |
+
A compression detail string can optionally be specified. If the
|
| 343 |
+
detail string is an integer, it specifies the compression level.
|
| 344 |
+
Otherwise, it should be a comma-separated list of items, each of the
|
| 345 |
+
form <code class="literal">keyword</code> or <code class="literal">keyword=value</code>.
|
| 346 |
+
Currently, the supported keywords are <code class="literal">level</code> and
|
| 347 |
+
<code class="literal">long</code>.
|
| 348 |
+
</p><p>
|
| 349 |
+
If no compression level is specified, the default compression
|
| 350 |
+
level will be used. If only a level is specified without mentioning
|
| 351 |
+
an algorithm, <code class="literal">gzip</code> compression will be used if
|
| 352 |
+
the level is greater than <code class="literal">0</code>, and no compression
|
| 353 |
+
will be used if the level is <code class="literal">0</code>.
|
| 354 |
+
</p><p>
|
| 355 |
+
For the custom and directory archive formats, this specifies compression of
|
| 356 |
+
individual table-data segments, and the default is to compress using
|
| 357 |
+
<code class="literal">gzip</code> at a moderate level. For plain text output,
|
| 358 |
+
setting a nonzero compression level causes the entire output file to be compressed,
|
| 359 |
+
as though it had been fed through <span class="application">gzip</span>,
|
| 360 |
+
<span class="application">lz4</span>, or <span class="application">zstd</span>;
|
| 361 |
+
but the default is not to compress.
|
| 362 |
+
With zstd compression, <code class="literal">long</code> mode may improve the
|
| 363 |
+
compression ratio, at the cost of increased memory use.
|
| 364 |
+
</p><p>
|
| 365 |
+
The tar archive format currently does not support compression at all.
|
| 366 |
+
</p></dd><dt><span class="term"><code class="option">--binary-upgrade</code></span></dt><dd><p>
|
| 367 |
+
This option is for use by in-place upgrade utilities. Its use
|
| 368 |
+
for other purposes is not recommended or supported. The
|
| 369 |
+
behavior of the option may change in future releases without
|
| 370 |
+
notice.
|
| 371 |
+
</p></dd><dt><span class="term"><code class="option">--column-inserts</code><br /></span><span class="term"><code class="option">--attribute-inserts</code></span></dt><dd><p>
|
| 372 |
+
Dump data as <code class="command">INSERT</code> commands with explicit
|
| 373 |
+
column names (<code class="literal">INSERT INTO
|
| 374 |
+
<em class="replaceable"><code>table</code></em>
|
| 375 |
+
(<em class="replaceable"><code>column</code></em>, ...) VALUES
|
| 376 |
+
...</code>). This will make restoration very slow; it is mainly
|
| 377 |
+
useful for making dumps that can be loaded into
|
| 378 |
+
non-<span class="productname">PostgreSQL</span> databases.
|
| 379 |
+
Any error during restoring will cause only rows that are part of the
|
| 380 |
+
problematic <code class="command">INSERT</code> to be lost, rather than the
|
| 381 |
+
entire table contents.
|
| 382 |
+
</p></dd><dt><span class="term"><code class="option">--disable-dollar-quoting</code></span></dt><dd><p>
|
| 383 |
+
This option disables the use of dollar quoting for function bodies,
|
| 384 |
+
and forces them to be quoted using SQL standard string syntax.
|
| 385 |
+
</p></dd><dt><span class="term"><code class="option">--disable-triggers</code></span></dt><dd><p>
|
| 386 |
+
This option is relevant only when creating a data-only dump.
|
| 387 |
+
It instructs <span class="application">pg_dump</span> to include commands
|
| 388 |
+
to temporarily disable triggers on the target tables while
|
| 389 |
+
the data is restored. Use this if you have referential
|
| 390 |
+
integrity checks or other triggers on the tables that you
|
| 391 |
+
do not want to invoke during data restore.
|
| 392 |
+
</p><p>
|
| 393 |
+
Presently, the commands emitted for <code class="option">--disable-triggers</code>
|
| 394 |
+
must be done as superuser. So, you should also specify
|
| 395 |
+
a superuser name with <code class="option">-S</code>, or preferably be careful to
|
| 396 |
+
start the resulting script as a superuser.
|
| 397 |
+
</p><p>
|
| 398 |
+
This option is ignored when emitting an archive (non-text) output
|
| 399 |
+
file. For the archive formats, you can specify the option when you
|
| 400 |
+
call <code class="command">pg_restore</code>.
|
| 401 |
+
</p></dd><dt><span class="term"><code class="option">--enable-row-security</code></span></dt><dd><p>
|
| 402 |
+
This option is relevant only when dumping the contents of a table
|
| 403 |
+
which has row security. By default, <span class="application">pg_dump</span> will set
|
| 404 |
+
<a class="xref" href="runtime-config-client.html#GUC-ROW-SECURITY">row_security</a> to off, to ensure
|
| 405 |
+
that all data is dumped from the table. If the user does not have
|
| 406 |
+
sufficient privileges to bypass row security, then an error is thrown.
|
| 407 |
+
This parameter instructs <span class="application">pg_dump</span> to set
|
| 408 |
+
<a class="xref" href="runtime-config-client.html#GUC-ROW-SECURITY">row_security</a> to on instead, allowing the user
|
| 409 |
+
to dump the parts of the contents of the table that they have access to.
|
| 410 |
+
</p><p>
|
| 411 |
+
Note that if you use this option currently, you probably also want
|
| 412 |
+
the dump be in <code class="command">INSERT</code> format, as the
|
| 413 |
+
<code class="command">COPY FROM</code> during restore does not support row security.
|
| 414 |
+
</p></dd><dt><span class="term"><code class="option">--exclude-table-and-children=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 415 |
+
This is the same as
|
| 416 |
+
the <code class="option">-T</code>/<code class="option">--exclude-table</code> option,
|
| 417 |
+
except that it also excludes any partitions or inheritance child
|
| 418 |
+
tables of the table(s) matching the
|
| 419 |
+
<em class="replaceable"><code>pattern</code></em>.
|
| 420 |
+
</p></dd><dt><span class="term"><code class="option">--exclude-table-data=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 421 |
+
Do not dump data for any tables matching <em class="replaceable"><code>pattern</code></em>. The pattern is
|
| 422 |
+
interpreted according to the same rules as for <code class="option">-t</code>.
|
| 423 |
+
<code class="option">--exclude-table-data</code> can be given more than once to
|
| 424 |
+
exclude tables matching any of several patterns. This option is
|
| 425 |
+
useful when you need the definition of a particular table even
|
| 426 |
+
though you do not need the data in it.
|
| 427 |
+
</p><p>
|
| 428 |
+
To exclude data for all tables in the database, see <code class="option">--schema-only</code>.
|
| 429 |
+
</p></dd><dt><span class="term"><code class="option">--exclude-table-data-and-children=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 430 |
+
This is the same as the <code class="option">--exclude-table-data</code> option,
|
| 431 |
+
except that it also excludes data of any partitions or inheritance
|
| 432 |
+
child tables of the table(s) matching the
|
| 433 |
+
<em class="replaceable"><code>pattern</code></em>.
|
| 434 |
+
</p></dd><dt><span class="term"><code class="option">--extra-float-digits=<em class="replaceable"><code>ndigits</code></em></code></span></dt><dd><p>
|
| 435 |
+
Use the specified value of <code class="option">extra_float_digits</code> when dumping
|
| 436 |
+
floating-point data, instead of the maximum available precision.
|
| 437 |
+
Routine dumps made for backup purposes should not use this option.
|
| 438 |
+
</p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>
|
| 439 |
+
Use <code class="literal">DROP ... IF EXISTS</code> commands to drop objects
|
| 440 |
+
in <code class="option">--clean</code> mode. This suppresses <span class="quote">“<span class="quote">does not
|
| 441 |
+
exist</span>”</span> errors that might otherwise be reported. This
|
| 442 |
+
option is not valid unless <code class="option">--clean</code> is also
|
| 443 |
+
specified.
|
| 444 |
+
</p></dd><dt><span class="term"><code class="option">--include-foreign-data=<em class="replaceable"><code>foreignserver</code></em></code></span></dt><dd><p>
|
| 445 |
+
Dump the data for any foreign table with a foreign server
|
| 446 |
+
matching <em class="replaceable"><code>foreignserver</code></em>
|
| 447 |
+
pattern. Multiple foreign servers can be selected by writing multiple
|
| 448 |
+
<code class="option">--include-foreign-data</code> switches.
|
| 449 |
+
Also, the <em class="replaceable"><code>foreignserver</code></em> parameter is
|
| 450 |
+
interpreted as a pattern according to the same rules used by
|
| 451 |
+
<span class="application">psql</span>'s <code class="literal">\d</code> commands
|
| 452 |
+
(see <a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns">Patterns</a>),
|
| 453 |
+
so multiple foreign servers can also be selected by writing wildcard characters
|
| 454 |
+
in the pattern. When using wildcards, be careful to quote the pattern
|
| 455 |
+
if needed to prevent the shell from expanding the wildcards; see
|
| 456 |
+
<a class="xref" href="app-pgdump.html#PG-DUMP-EXAMPLES" title="Examples">Examples</a> below.
|
| 457 |
+
The only exception is that an empty pattern is disallowed.
|
| 458 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 459 |
+
When <code class="option">--include-foreign-data</code> is specified,
|
| 460 |
+
<span class="application">pg_dump</span> does not check that the foreign
|
| 461 |
+
table is writable. Therefore, there is no guarantee that the
|
| 462 |
+
results of a foreign table dump can be successfully restored.
|
| 463 |
+
</p></div></dd><dt><span class="term"><code class="option">--inserts</code></span></dt><dd><p>
|
| 464 |
+
Dump data as <code class="command">INSERT</code> commands (rather
|
| 465 |
+
than <code class="command">COPY</code>). This will make restoration very slow;
|
| 466 |
+
it is mainly useful for making dumps that can be loaded into
|
| 467 |
+
non-<span class="productname">PostgreSQL</span> databases.
|
| 468 |
+
Any error during restoring will cause only rows that are part of the
|
| 469 |
+
problematic <code class="command">INSERT</code> to be lost, rather than the
|
| 470 |
+
entire table contents. Note that the restore might fail altogether if
|
| 471 |
+
you have rearranged column order. The
|
| 472 |
+
<code class="option">--column-inserts</code> option is safe against column order
|
| 473 |
+
changes, though even slower.
|
| 474 |
+
</p></dd><dt><span class="term"><code class="option">--load-via-partition-root</code></span></dt><dd><p>
|
| 475 |
+
When dumping data for a table partition, make
|
| 476 |
+
the <code class="command">COPY</code> or <code class="command">INSERT</code> statements
|
| 477 |
+
target the root of the partitioning hierarchy that contains it, rather
|
| 478 |
+
than the partition itself. This causes the appropriate partition to
|
| 479 |
+
be re-determined for each row when the data is loaded. This may be
|
| 480 |
+
useful when restoring data on a server where rows do not always fall
|
| 481 |
+
into the same partitions as they did on the original server. That
|
| 482 |
+
could happen, for example, if the partitioning column is of type text
|
| 483 |
+
and the two systems have different definitions of the collation used
|
| 484 |
+
to sort the partitioning column.
|
| 485 |
+
</p></dd><dt><span class="term"><code class="option">--lock-wait-timeout=<em class="replaceable"><code>timeout</code></em></code></span></dt><dd><p>
|
| 486 |
+
Do not wait forever to acquire shared table locks at the beginning of
|
| 487 |
+
the dump. Instead fail if unable to lock a table within the specified
|
| 488 |
+
<em class="replaceable"><code>timeout</code></em>. The timeout may be
|
| 489 |
+
specified in any of the formats accepted by <code class="command">SET
|
| 490 |
+
statement_timeout</code>. (Allowed formats vary depending on the server
|
| 491 |
+
version you are dumping from, but an integer number of milliseconds
|
| 492 |
+
is accepted by all versions.)
|
| 493 |
+
</p></dd><dt><span class="term"><code class="option">--no-comments</code></span></dt><dd><p>
|
| 494 |
+
Do not dump comments.
|
| 495 |
+
</p></dd><dt><span class="term"><code class="option">--no-publications</code></span></dt><dd><p>
|
| 496 |
+
Do not dump publications.
|
| 497 |
+
</p></dd><dt><span class="term"><code class="option">--no-security-labels</code></span></dt><dd><p>
|
| 498 |
+
Do not dump security labels.
|
| 499 |
+
</p></dd><dt><span class="term"><code class="option">--no-subscriptions</code></span></dt><dd><p>
|
| 500 |
+
Do not dump subscriptions.
|
| 501 |
+
</p></dd><dt><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>
|
| 502 |
+
By default, <code class="command">pg_dump</code> will wait for all files
|
| 503 |
+
to be written safely to disk. This option causes
|
| 504 |
+
<code class="command">pg_dump</code> to return without waiting, which is
|
| 505 |
+
faster, but means that a subsequent operating system crash can leave
|
| 506 |
+
the dump corrupt. Generally, this option is useful for testing
|
| 507 |
+
but should not be used when dumping data from production installation.
|
| 508 |
+
</p></dd><dt><span class="term"><code class="option">--no-table-access-method</code></span></dt><dd><p>
|
| 509 |
+
Do not output commands to select table access methods.
|
| 510 |
+
With this option, all objects will be created with whichever
|
| 511 |
+
table access method is the default during restore.
|
| 512 |
+
</p><p>
|
| 513 |
+
This option is ignored when emitting an archive (non-text) output
|
| 514 |
+
file. For the archive formats, you can specify the option when you
|
| 515 |
+
call <code class="command">pg_restore</code>.
|
| 516 |
+
</p></dd><dt><span class="term"><code class="option">--no-tablespaces</code></span></dt><dd><p>
|
| 517 |
+
Do not output commands to select tablespaces.
|
| 518 |
+
With this option, all objects will be created in whichever
|
| 519 |
+
tablespace is the default during restore.
|
| 520 |
+
</p><p>
|
| 521 |
+
This option is ignored when emitting an archive (non-text) output
|
| 522 |
+
file. For the archive formats, you can specify the option when you
|
| 523 |
+
call <code class="command">pg_restore</code>.
|
| 524 |
+
</p></dd><dt><span class="term"><code class="option">--no-toast-compression</code></span></dt><dd><p>
|
| 525 |
+
Do not output commands to set <acronym class="acronym">TOAST</acronym> compression
|
| 526 |
+
methods.
|
| 527 |
+
With this option, all columns will be restored with the default
|
| 528 |
+
compression setting.
|
| 529 |
+
</p></dd><dt><span class="term"><code class="option">--no-unlogged-table-data</code></span></dt><dd><p>
|
| 530 |
+
Do not dump the contents of unlogged tables and sequences. This
|
| 531 |
+
option has no effect on whether or not the table and sequence
|
| 532 |
+
definitions (schema) are dumped; it only suppresses dumping the table
|
| 533 |
+
and sequence data. Data in unlogged tables and sequences
|
| 534 |
+
is always excluded when dumping from a standby server.
|
| 535 |
+
</p></dd><dt><span class="term"><code class="option">--on-conflict-do-nothing</code></span></dt><dd><p>
|
| 536 |
+
Add <code class="literal">ON CONFLICT DO NOTHING</code> to
|
| 537 |
+
<code class="command">INSERT</code> commands.
|
| 538 |
+
This option is not valid unless <code class="option">--inserts</code>,
|
| 539 |
+
<code class="option">--column-inserts</code> or
|
| 540 |
+
<code class="option">--rows-per-insert</code> is also specified.
|
| 541 |
+
</p></dd><dt><span class="term"><code class="option">--quote-all-identifiers</code></span></dt><dd><p>
|
| 542 |
+
Force quoting of all identifiers. This option is recommended when
|
| 543 |
+
dumping a database from a server whose <span class="productname">PostgreSQL</span>
|
| 544 |
+
major version is different from <span class="application">pg_dump</span>'s, or when
|
| 545 |
+
the output is intended to be loaded into a server of a different
|
| 546 |
+
major version. By default, <span class="application">pg_dump</span> quotes only
|
| 547 |
+
identifiers that are reserved words in its own major version.
|
| 548 |
+
This sometimes results in compatibility issues when dealing with
|
| 549 |
+
servers of other versions that may have slightly different sets
|
| 550 |
+
of reserved words. Using <code class="option">--quote-all-identifiers</code> prevents
|
| 551 |
+
such issues, at the price of a harder-to-read dump script.
|
| 552 |
+
</p></dd><dt><span class="term"><code class="option">--rows-per-insert=<em class="replaceable"><code>nrows</code></em></code></span></dt><dd><p>
|
| 553 |
+
Dump data as <code class="command">INSERT</code> commands (rather than
|
| 554 |
+
<code class="command">COPY</code>). Controls the maximum number of rows per
|
| 555 |
+
<code class="command">INSERT</code> command. The value specified must be a
|
| 556 |
+
number greater than zero. Any error during restoring will cause only
|
| 557 |
+
rows that are part of the problematic <code class="command">INSERT</code> to be
|
| 558 |
+
lost, rather than the entire table contents.
|
| 559 |
+
</p></dd><dt><span class="term"><code class="option">--section=<em class="replaceable"><code>sectionname</code></em></code></span></dt><dd><p>
|
| 560 |
+
Only dump the named section. The section name can be
|
| 561 |
+
<code class="option">pre-data</code>, <code class="option">data</code>, or <code class="option">post-data</code>.
|
| 562 |
+
This option can be specified more than once to select multiple
|
| 563 |
+
sections. The default is to dump all sections.
|
| 564 |
+
</p><p>
|
| 565 |
+
The data section contains actual table data, large-object
|
| 566 |
+
contents, and sequence values.
|
| 567 |
+
Post-data items include definitions of indexes, triggers, rules,
|
| 568 |
+
and constraints other than validated check constraints.
|
| 569 |
+
Pre-data items include all other data definition items.
|
| 570 |
+
</p></dd><dt><span class="term"><code class="option">--serializable-deferrable</code></span></dt><dd><p>
|
| 571 |
+
Use a <code class="literal">serializable</code> transaction for the dump, to
|
| 572 |
+
ensure that the snapshot used is consistent with later database
|
| 573 |
+
states; but do this by waiting for a point in the transaction stream
|
| 574 |
+
at which no anomalies can be present, so that there isn't a risk of
|
| 575 |
+
the dump failing or causing other transactions to roll back with a
|
| 576 |
+
<code class="literal">serialization_failure</code>. See <a class="xref" href="mvcc.html" title="Chapter 13. Concurrency Control">Chapter 13</a>
|
| 577 |
+
for more information about transaction isolation and concurrency
|
| 578 |
+
control.
|
| 579 |
+
</p><p>
|
| 580 |
+
This option is not beneficial for a dump which is intended only for
|
| 581 |
+
disaster recovery. It could be useful for a dump used to load a
|
| 582 |
+
copy of the database for reporting or other read-only load sharing
|
| 583 |
+
while the original database continues to be updated. Without it the
|
| 584 |
+
dump may reflect a state which is not consistent with any serial
|
| 585 |
+
execution of the transactions eventually committed. For example, if
|
| 586 |
+
batch processing techniques are used, a batch may show as closed in
|
| 587 |
+
the dump without all of the items which are in the batch appearing.
|
| 588 |
+
</p><p>
|
| 589 |
+
This option will make no difference if there are no read-write
|
| 590 |
+
transactions active when pg_dump is started. If read-write
|
| 591 |
+
transactions are active, the start of the dump may be delayed for an
|
| 592 |
+
indeterminate length of time. Once running, performance with or
|
| 593 |
+
without the switch is the same.
|
| 594 |
+
</p></dd><dt><span class="term"><code class="option">--snapshot=<em class="replaceable"><code>snapshotname</code></em></code></span></dt><dd><p>
|
| 595 |
+
Use the specified synchronized snapshot when making a dump of the
|
| 596 |
+
database (see
|
| 597 |
+
<a class="xref" href="functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE" title="Table 9.94. Snapshot Synchronization Functions">Table 9.94</a> for more
|
| 598 |
+
details).
|
| 599 |
+
</p><p>
|
| 600 |
+
This option is useful when needing to synchronize the dump with
|
| 601 |
+
a logical replication slot (see <a class="xref" href="logicaldecoding.html" title="Chapter 49. Logical Decoding">Chapter 49</a>)
|
| 602 |
+
or with a concurrent session.
|
| 603 |
+
</p><p>
|
| 604 |
+
In the case of a parallel dump, the snapshot name defined by this
|
| 605 |
+
option is used rather than taking a new snapshot.
|
| 606 |
+
</p></dd><dt><span class="term"><code class="option">--strict-names</code></span></dt><dd><p>
|
| 607 |
+
Require that each
|
| 608 |
+
extension (<code class="option">-e</code>/<code class="option">--extension</code>),
|
| 609 |
+
schema (<code class="option">-n</code>/<code class="option">--schema</code>) and
|
| 610 |
+
table (<code class="option">-t</code>/<code class="option">--table</code>) pattern
|
| 611 |
+
match at least one extension/schema/table in the database to be dumped.
|
| 612 |
+
Note that if none of the extension/schema/table patterns find
|
| 613 |
+
matches, <span class="application">pg_dump</span> will generate an error
|
| 614 |
+
even without <code class="option">--strict-names</code>.
|
| 615 |
+
</p><p>
|
| 616 |
+
This option has no effect
|
| 617 |
+
on <code class="option">-N</code>/<code class="option">--exclude-schema</code>,
|
| 618 |
+
<code class="option">-T</code>/<code class="option">--exclude-table</code>,
|
| 619 |
+
or <code class="option">--exclude-table-data</code>. An exclude pattern failing
|
| 620 |
+
to match any objects is not considered an error.
|
| 621 |
+
</p></dd><dt><span class="term"><code class="option">--table-and-children=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
|
| 622 |
+
This is the same as
|
| 623 |
+
the <code class="option">-t</code>/<code class="option">--table</code> option,
|
| 624 |
+
except that it also includes any partitions or inheritance child
|
| 625 |
+
tables of the table(s) matching the
|
| 626 |
+
<em class="replaceable"><code>pattern</code></em>.
|
| 627 |
+
</p></dd><dt><span class="term"><code class="option">--use-set-session-authorization</code></span></dt><dd><p>
|
| 628 |
+
Output SQL-standard <code class="command">SET SESSION AUTHORIZATION</code> commands
|
| 629 |
+
instead of <code class="command">ALTER OWNER</code> commands to determine object
|
| 630 |
+
ownership. This makes the dump more standards-compatible, but
|
| 631 |
+
depending on the history of the objects in the dump, might not restore
|
| 632 |
+
properly. Also, a dump using <code class="command">SET SESSION AUTHORIZATION</code>
|
| 633 |
+
will certainly require superuser privileges to restore correctly,
|
| 634 |
+
whereas <code class="command">ALTER OWNER</code> requires lesser privileges.
|
| 635 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 636 |
+
Show help about <span class="application">pg_dump</span> command line
|
| 637 |
+
arguments, and exit.
|
| 638 |
+
</p></dd></dl></div><p>
|
| 639 |
+
</p><p>
|
| 640 |
+
The following command-line options control the database connection parameters.
|
| 641 |
+
|
| 642 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 643 |
+
Specifies the name of the database to connect to. This is
|
| 644 |
+
equivalent to specifying <em class="replaceable"><code>dbname</code></em> as the first non-option
|
| 645 |
+
argument on the command line. The <em class="replaceable"><code>dbname</code></em>
|
| 646 |
+
can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>.
|
| 647 |
+
If so, connection string parameters will override any conflicting
|
| 648 |
+
command line options.
|
| 649 |
+
</p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 650 |
+
Specifies the host name of the machine on which the server is
|
| 651 |
+
running. If the value begins with a slash, it is used as the
|
| 652 |
+
directory for the Unix domain socket. The default is taken
|
| 653 |
+
from the <code class="envar">PGHOST</code> environment variable, if set,
|
| 654 |
+
else a Unix domain socket connection is attempted.
|
| 655 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 656 |
+
Specifies the TCP port or local Unix domain socket file
|
| 657 |
+
extension on which the server is listening for connections.
|
| 658 |
+
Defaults to the <code class="envar">PGPORT</code> environment variable, if
|
| 659 |
+
set, or a compiled-in default.
|
| 660 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 661 |
+
User name to connect as.
|
| 662 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 663 |
+
Never issue a password prompt. If the server requires
|
| 664 |
+
password authentication and a password is not available by
|
| 665 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 666 |
+
connection attempt will fail. This option can be useful in
|
| 667 |
+
batch jobs and scripts where no user is present to enter a
|
| 668 |
+
password.
|
| 669 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 670 |
+
Force <span class="application">pg_dump</span> to prompt for a
|
| 671 |
+
password before connecting to a database.
|
| 672 |
+
</p><p>
|
| 673 |
+
This option is never essential, since
|
| 674 |
+
<span class="application">pg_dump</span> will automatically prompt
|
| 675 |
+
for a password if the server demands password authentication.
|
| 676 |
+
However, <span class="application">pg_dump</span> will waste a
|
| 677 |
+
connection attempt finding out that the server wants a password.
|
| 678 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 679 |
+
connection attempt.
|
| 680 |
+
</p></dd><dt><span class="term"><code class="option">--role=<em class="replaceable"><code>rolename</code></em></code></span></dt><dd><p>
|
| 681 |
+
Specifies a role name to be used to create the dump.
|
| 682 |
+
This option causes <span class="application">pg_dump</span> to issue a
|
| 683 |
+
<code class="command">SET ROLE</code> <em class="replaceable"><code>rolename</code></em>
|
| 684 |
+
command after connecting to the database. It is useful when the
|
| 685 |
+
authenticated user (specified by <code class="option">-U</code>) lacks privileges
|
| 686 |
+
needed by <span class="application">pg_dump</span>, but can switch to a role with
|
| 687 |
+
the required rights. Some installations have a policy against
|
| 688 |
+
logging in directly as a superuser, and use of this option allows
|
| 689 |
+
dumps to be made without violating the policy.
|
| 690 |
+
</p></dd></dl></div><p>
|
| 691 |
+
</p></div><div class="refsect1" id="id-1.9.4.13.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATABASE</code><br /></span><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGOPTIONS</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 692 |
+
Default connection parameters.
|
| 693 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 694 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 695 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 696 |
+
<code class="literal">never</code>.
|
| 697 |
+
</p></dd></dl></div><p>
|
| 698 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 699 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 700 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 701 |
+
</p></div><div class="refsect1" id="APP-PGDUMP-DIAGNOSTICS"><h2>Diagnostics</h2><p>
|
| 702 |
+
<span class="application">pg_dump</span> internally executes
|
| 703 |
+
<code class="command">SELECT</code> statements. If you have problems running
|
| 704 |
+
<span class="application">pg_dump</span>, make sure you are able to
|
| 705 |
+
select information from the database using, for example, <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a>. Also, any default connection settings and environment
|
| 706 |
+
variables used by the <span class="application">libpq</span> front-end
|
| 707 |
+
library will apply.
|
| 708 |
+
</p><p>
|
| 709 |
+
The database activity of <span class="application">pg_dump</span> is
|
| 710 |
+
normally collected by the cumulative statistics system. If this is
|
| 711 |
+
undesirable, you can set parameter <code class="varname">track_counts</code>
|
| 712 |
+
to false via <code class="envar">PGOPTIONS</code> or the <code class="literal">ALTER
|
| 713 |
+
USER</code> command.
|
| 714 |
+
</p></div><div class="refsect1" id="PG-DUMP-NOTES"><h2>Notes</h2><p>
|
| 715 |
+
If your database cluster has any local additions to the <code class="literal">template1</code> database,
|
| 716 |
+
be careful to restore the output of <span class="application">pg_dump</span> into a
|
| 717 |
+
truly empty database; otherwise you are likely to get errors due to
|
| 718 |
+
duplicate definitions of the added objects. To make an empty database
|
| 719 |
+
without any local additions, copy from <code class="literal">template0</code> not <code class="literal">template1</code>,
|
| 720 |
+
for example:
|
| 721 |
+
</p><pre class="programlisting">
|
| 722 |
+
CREATE DATABASE foo WITH TEMPLATE template0;
|
| 723 |
+
</pre><p>
|
| 724 |
+
</p><p>
|
| 725 |
+
When a data-only dump is chosen and the option <code class="option">--disable-triggers</code>
|
| 726 |
+
is used, <span class="application">pg_dump</span> emits commands
|
| 727 |
+
to disable triggers on user tables before inserting the data,
|
| 728 |
+
and then commands to re-enable them after the data has been
|
| 729 |
+
inserted. If the restore is stopped in the middle, the system
|
| 730 |
+
catalogs might be left in the wrong state.
|
| 731 |
+
</p><p>
|
| 732 |
+
The dump file produced by <span class="application">pg_dump</span>
|
| 733 |
+
does not contain the statistics used by the optimizer to make
|
| 734 |
+
query planning decisions. Therefore, it is wise to run
|
| 735 |
+
<code class="command">ANALYZE</code> after restoring from a dump file
|
| 736 |
+
to ensure optimal performance; see <a class="xref" href="routine-vacuuming.html#VACUUM-FOR-STATISTICS" title="25.1.3. Updating Planner Statistics">Section 25.1.3</a>
|
| 737 |
+
and <a class="xref" href="routine-vacuuming.html#AUTOVACUUM" title="25.1.6. The Autovacuum Daemon">Section 25.1.6</a> for more information.
|
| 738 |
+
</p><p>
|
| 739 |
+
Because <span class="application">pg_dump</span> is used to transfer data
|
| 740 |
+
to newer versions of <span class="productname">PostgreSQL</span>, the output of
|
| 741 |
+
<span class="application">pg_dump</span> can be expected to load into
|
| 742 |
+
<span class="productname">PostgreSQL</span> server versions newer than
|
| 743 |
+
<span class="application">pg_dump</span>'s version. <span class="application">pg_dump</span> can also
|
| 744 |
+
dump from <span class="productname">PostgreSQL</span> servers older than its own version.
|
| 745 |
+
(Currently, servers back to version 9.2 are supported.)
|
| 746 |
+
However, <span class="application">pg_dump</span> cannot dump from
|
| 747 |
+
<span class="productname">PostgreSQL</span> servers newer than its own major version;
|
| 748 |
+
it will refuse to even try, rather than risk making an invalid dump.
|
| 749 |
+
Also, it is not guaranteed that <span class="application">pg_dump</span>'s output can
|
| 750 |
+
be loaded into a server of an older major version — not even if the
|
| 751 |
+
dump was taken from a server of that version. Loading a dump file
|
| 752 |
+
into an older server may require manual editing of the dump file
|
| 753 |
+
to remove syntax not understood by the older server.
|
| 754 |
+
Use of the <code class="option">--quote-all-identifiers</code> option is recommended
|
| 755 |
+
in cross-version cases, as it can prevent problems arising from varying
|
| 756 |
+
reserved-word lists in different <span class="productname">PostgreSQL</span> versions.
|
| 757 |
+
</p><p>
|
| 758 |
+
When dumping logical replication subscriptions,
|
| 759 |
+
<span class="application">pg_dump</span> will generate <code class="command">CREATE
|
| 760 |
+
SUBSCRIPTION</code> commands that use the <code class="literal">connect = false</code>
|
| 761 |
+
option, so that restoring the subscription does not make remote connections
|
| 762 |
+
for creating a replication slot or for initial table copy. That way, the
|
| 763 |
+
dump can be restored without requiring network access to the remote
|
| 764 |
+
servers. It is then up to the user to reactivate the subscriptions in a
|
| 765 |
+
suitable way. If the involved hosts have changed, the connection
|
| 766 |
+
information might have to be changed. It might also be appropriate to
|
| 767 |
+
truncate the target tables before initiating a new full table copy. If users
|
| 768 |
+
intend to copy initial data during refresh they must create the slot with
|
| 769 |
+
<code class="literal">two_phase = false</code>. After the initial sync, the
|
| 770 |
+
<a class="link" href="sql-createsubscription.html#SQL-CREATESUBSCRIPTION-WITH-TWO-PHASE"><code class="literal">two_phase</code></a>
|
| 771 |
+
option will be automatically enabled by the subscriber if the subscription
|
| 772 |
+
had been originally created with <code class="literal">two_phase = true</code> option.
|
| 773 |
+
</p></div><div class="refsect1" id="PG-DUMP-EXAMPLES"><h2>Examples</h2><p>
|
| 774 |
+
To dump a database called <code class="literal">mydb</code> into an SQL-script file:
|
| 775 |
+
</p><pre class="screen">
|
| 776 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump mydb > db.sql</code></strong>
|
| 777 |
+
</pre><p>
|
| 778 |
+
</p><p>
|
| 779 |
+
To reload such a script into a (freshly created) database named
|
| 780 |
+
<code class="literal">newdb</code>:
|
| 781 |
+
|
| 782 |
+
</p><pre class="screen">
|
| 783 |
+
<code class="prompt">$</code> <strong class="userinput"><code>psql -d newdb -f db.sql</code></strong>
|
| 784 |
+
</pre><p>
|
| 785 |
+
</p><p>
|
| 786 |
+
To dump a database into a custom-format archive file:
|
| 787 |
+
|
| 788 |
+
</p><pre class="screen">
|
| 789 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -Fc mydb > db.dump</code></strong>
|
| 790 |
+
</pre><p>
|
| 791 |
+
</p><p>
|
| 792 |
+
To dump a database into a directory-format archive:
|
| 793 |
+
|
| 794 |
+
</p><pre class="screen">
|
| 795 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -Fd mydb -f dumpdir</code></strong>
|
| 796 |
+
</pre><p>
|
| 797 |
+
</p><p>
|
| 798 |
+
To dump a database into a directory-format archive in parallel with
|
| 799 |
+
5 worker jobs:
|
| 800 |
+
|
| 801 |
+
</p><pre class="screen">
|
| 802 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>
|
| 803 |
+
</pre><p>
|
| 804 |
+
</p><p>
|
| 805 |
+
To reload an archive file into a (freshly created) database named
|
| 806 |
+
<code class="literal">newdb</code>:
|
| 807 |
+
|
| 808 |
+
</p><pre class="screen">
|
| 809 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_restore -d newdb db.dump</code></strong>
|
| 810 |
+
</pre><p>
|
| 811 |
+
</p><p>
|
| 812 |
+
To reload an archive file into the same database it was dumped from,
|
| 813 |
+
discarding the current contents of that database:
|
| 814 |
+
|
| 815 |
+
</p><pre class="screen">
|
| 816 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_restore -d postgres --clean --create db.dump</code></strong>
|
| 817 |
+
</pre><p>
|
| 818 |
+
</p><p>
|
| 819 |
+
To dump a single table named <code class="literal">mytab</code>:
|
| 820 |
+
|
| 821 |
+
</p><pre class="screen">
|
| 822 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -t mytab mydb > db.sql</code></strong>
|
| 823 |
+
</pre><p>
|
| 824 |
+
</p><p>
|
| 825 |
+
To dump all tables whose names start with <code class="literal">emp</code> in the
|
| 826 |
+
<code class="literal">detroit</code> schema, except for the table named
|
| 827 |
+
<code class="literal">employee_log</code>:
|
| 828 |
+
|
| 829 |
+
</p><pre class="screen">
|
| 830 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb > db.sql</code></strong>
|
| 831 |
+
</pre><p>
|
| 832 |
+
</p><p>
|
| 833 |
+
To dump all schemas whose names start with <code class="literal">east</code> or
|
| 834 |
+
<code class="literal">west</code> and end in <code class="literal">gsm</code>, excluding any schemas whose
|
| 835 |
+
names contain the word <code class="literal">test</code>:
|
| 836 |
+
|
| 837 |
+
</p><pre class="screen">
|
| 838 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb > db.sql</code></strong>
|
| 839 |
+
</pre><p>
|
| 840 |
+
</p><p>
|
| 841 |
+
The same, using regular expression notation to consolidate the switches:
|
| 842 |
+
|
| 843 |
+
</p><pre class="screen">
|
| 844 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb > db.sql</code></strong>
|
| 845 |
+
</pre><p>
|
| 846 |
+
</p><p>
|
| 847 |
+
To dump all database objects except for tables whose names begin with
|
| 848 |
+
<code class="literal">ts_</code>:
|
| 849 |
+
|
| 850 |
+
</p><pre class="screen">
|
| 851 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -T 'ts_*' mydb > db.sql</code></strong>
|
| 852 |
+
</pre><p>
|
| 853 |
+
</p><p>
|
| 854 |
+
To specify an upper-case or mixed-case name in <code class="option">-t</code> and related
|
| 855 |
+
switches, you need to double-quote the name; else it will be folded to
|
| 856 |
+
lower case (see <a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns">Patterns</a>). But
|
| 857 |
+
double quotes are special to the shell, so in turn they must be quoted.
|
| 858 |
+
Thus, to dump a single table with a mixed-case name, you need something
|
| 859 |
+
like
|
| 860 |
+
|
| 861 |
+
</p><pre class="screen">
|
| 862 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -t "\"MixedCaseName\"" mydb > mytab.sql</code></strong>
|
| 863 |
+
</pre></div><div class="refsect1" id="id-1.9.4.13.11"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pg-dumpall.html" title="pg_dumpall"><span class="refentrytitle"><span class="application">pg_dumpall</span></span></a>, <a class="xref" href="app-pgrestore.html" title="pg_restore"><span class="refentrytitle"><span class="application">pg_restore</span></span></a>, <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgconfig.html" title="pg_config">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pg-dumpall.html" title="pg_dumpall">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_config</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_dumpall</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgreceivewal.html
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_receivewal</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pg-isready.html" title="pg_isready" /><link rel="next" href="app-pgrecvlogical.html" title="pg_recvlogical" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_receivewal</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pg-isready.html" title="pg_isready">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgrecvlogical.html" title="pg_recvlogical">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGRECEIVEWAL"><div class="titlepage"></div><a id="id-1.9.4.16.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_receivewal</span></span></h2><p>pg_receivewal — stream write-ahead logs from a <span class="productname">PostgreSQL</span> server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.16.4.1"><code class="command">pg_receivewal</code> [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="id-1.9.4.16.5"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">pg_receivewal</span> is used to stream the write-ahead log
|
| 4 |
+
from a running <span class="productname">PostgreSQL</span> cluster. The write-ahead
|
| 5 |
+
log is streamed using the streaming replication protocol, and is written
|
| 6 |
+
to a local directory of files. This directory can be used as the archive
|
| 7 |
+
location for doing a restore using point-in-time recovery (see
|
| 8 |
+
<a class="xref" href="continuous-archiving.html" title="26.3. Continuous Archiving and Point-in-Time Recovery (PITR)">Section 26.3</a>).
|
| 9 |
+
</p><p>
|
| 10 |
+
<span class="application">pg_receivewal</span> streams the write-ahead
|
| 11 |
+
log in real time as it's being generated on the server, and does not wait
|
| 12 |
+
for segments to complete like <a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-COMMAND">archive_command</a> and
|
| 13 |
+
<a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-LIBRARY">archive_library</a> do.
|
| 14 |
+
For this reason, it is not necessary to set
|
| 15 |
+
<a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT">archive_timeout</a> when using
|
| 16 |
+
<span class="application">pg_receivewal</span>.
|
| 17 |
+
</p><p>
|
| 18 |
+
Unlike the WAL receiver of a PostgreSQL standby server, <span class="application">pg_receivewal</span>
|
| 19 |
+
by default flushes WAL data only when a WAL file is closed.
|
| 20 |
+
The option <code class="option">--synchronous</code> must be specified to flush WAL data
|
| 21 |
+
in real time. Since <span class="application">pg_receivewal</span> does not
|
| 22 |
+
apply WAL, you should not allow it to become a synchronous standby when
|
| 23 |
+
<a class="xref" href="runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT">synchronous_commit</a> equals
|
| 24 |
+
<code class="literal">remote_apply</code>. If it does, it will appear to be a
|
| 25 |
+
standby that never catches up, and will cause transaction commits to
|
| 26 |
+
block. To avoid this, you should either configure an appropriate value
|
| 27 |
+
for <a class="xref" href="runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES">synchronous_standby_names</a>, or specify
|
| 28 |
+
<code class="varname">application_name</code> for
|
| 29 |
+
<span class="application">pg_receivewal</span> that does not match it, or
|
| 30 |
+
change the value of <code class="varname">synchronous_commit</code> to
|
| 31 |
+
something other than <code class="literal">remote_apply</code>.
|
| 32 |
+
</p><p>
|
| 33 |
+
The write-ahead log is streamed over a regular
|
| 34 |
+
<span class="productname">PostgreSQL</span> connection and uses the replication
|
| 35 |
+
protocol. The connection must be made with a user having
|
| 36 |
+
<code class="literal">REPLICATION</code> permissions (see
|
| 37 |
+
<a class="xref" href="role-attributes.html" title="22.2. Role Attributes">Section 22.2</a>) or a superuser, and
|
| 38 |
+
<code class="filename">pg_hba.conf</code> must permit the replication connection.
|
| 39 |
+
The server must also be configured with
|
| 40 |
+
<a class="xref" href="runtime-config-replication.html#GUC-MAX-WAL-SENDERS">max_wal_senders</a> set high enough to leave at least
|
| 41 |
+
one session available for the stream.
|
| 42 |
+
</p><p>
|
| 43 |
+
The starting point of the write-ahead log streaming is calculated when
|
| 44 |
+
<span class="application">pg_receivewal</span> starts:
|
| 45 |
+
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
|
| 46 |
+
First, scan the directory where the WAL segment files are written and
|
| 47 |
+
find the newest completed segment file, using as the starting point the
|
| 48 |
+
beginning of the next WAL segment file.
|
| 49 |
+
</p></li><li class="listitem"><p>
|
| 50 |
+
If a starting point cannot be calculated with the previous method,
|
| 51 |
+
and if a replication slot is used, an extra
|
| 52 |
+
<code class="command">READ_REPLICATION_SLOT</code> command is issued to retrieve
|
| 53 |
+
the slot's <code class="literal">restart_lsn</code> to use as the starting point.
|
| 54 |
+
This option is only available when streaming write-ahead logs from
|
| 55 |
+
<span class="productname">PostgreSQL</span> 15 and up.
|
| 56 |
+
</p></li><li class="listitem"><p>
|
| 57 |
+
If a starting point cannot be calculated with the previous method,
|
| 58 |
+
the latest WAL flush location is used as reported by the server from
|
| 59 |
+
an <code class="literal">IDENTIFY_SYSTEM</code> command.
|
| 60 |
+
</p></li></ol></div><p>
|
| 61 |
+
</p><p>
|
| 62 |
+
If the connection is lost, or if it cannot be initially established,
|
| 63 |
+
with a non-fatal error, <span class="application">pg_receivewal</span> will
|
| 64 |
+
retry the connection indefinitely, and reestablish streaming as soon
|
| 65 |
+
as possible. To avoid this behavior, use the <code class="literal">-n</code>
|
| 66 |
+
parameter.
|
| 67 |
+
</p><p>
|
| 68 |
+
In the absence of fatal errors, <span class="application">pg_receivewal</span>
|
| 69 |
+
will run until terminated by the <span class="systemitem">SIGINT</span>
|
| 70 |
+
(<span class="keycap"><strong>Control</strong></span>+<span class="keycap"><strong>C</strong></span>)
|
| 71 |
+
or <span class="systemitem">SIGTERM</span> signal.
|
| 72 |
+
</p></div><div class="refsect1" id="id-1.9.4.16.6"><h2>Options</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--directory=<em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
|
| 73 |
+
Directory to write the output to.
|
| 74 |
+
</p><p>
|
| 75 |
+
This parameter is required.
|
| 76 |
+
</p></dd><dt><span class="term"><code class="option">-E <em class="replaceable"><code>lsn</code></em></code><br /></span><span class="term"><code class="option">--endpos=<em class="replaceable"><code>lsn</code></em></code></span></dt><dd><p>
|
| 77 |
+
Automatically stop replication and exit with normal exit status 0 when
|
| 78 |
+
receiving reaches the specified LSN.
|
| 79 |
+
</p><p>
|
| 80 |
+
If there is a record with LSN exactly equal to <em class="replaceable"><code>lsn</code></em>,
|
| 81 |
+
the record will be processed.
|
| 82 |
+
</p></dd><dt><span class="term"><code class="option">--if-not-exists</code></span></dt><dd><p>
|
| 83 |
+
Do not error out when <code class="option">--create-slot</code> is specified
|
| 84 |
+
and a slot with the specified name already exists.
|
| 85 |
+
</p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-loop</code></span></dt><dd><p>
|
| 86 |
+
Don't loop on connection errors. Instead, exit right away with
|
| 87 |
+
an error.
|
| 88 |
+
</p></dd><dt><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>
|
| 89 |
+
This option causes <code class="command">pg_receivewal</code> to not force WAL
|
| 90 |
+
data to be flushed to disk. This is faster, but means that a
|
| 91 |
+
subsequent operating system crash can leave the WAL segments corrupt.
|
| 92 |
+
Generally, this option is useful for testing but should not be used
|
| 93 |
+
when doing WAL archiving on a production deployment.
|
| 94 |
+
</p><p>
|
| 95 |
+
This option is incompatible with <code class="literal">--synchronous</code>.
|
| 96 |
+
</p></dd><dt><span class="term"><code class="option">-s <em class="replaceable"><code>interval</code></em></code><br /></span><span class="term"><code class="option">--status-interval=<em class="replaceable"><code>interval</code></em></code></span></dt><dd><p>
|
| 97 |
+
Specifies the number of seconds between status packets sent back to the
|
| 98 |
+
server. This allows for easier monitoring of the progress from server.
|
| 99 |
+
A value of zero disables the periodic status updates completely,
|
| 100 |
+
although an update will still be sent when requested by the server, to
|
| 101 |
+
avoid timeout disconnect. The default value is 10 seconds.
|
| 102 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>slotname</code></em></code><br /></span><span class="term"><code class="option">--slot=<em class="replaceable"><code>slotname</code></em></code></span></dt><dd><p>
|
| 103 |
+
Require <span class="application">pg_receivewal</span> to use an existing
|
| 104 |
+
replication slot (see <a class="xref" href="warm-standby.html#STREAMING-REPLICATION-SLOTS" title="27.2.6. Replication Slots">Section 27.2.6</a>).
|
| 105 |
+
When this option is used, <span class="application">pg_receivewal</span> will report
|
| 106 |
+
a flush position to the server, indicating when each segment has been
|
| 107 |
+
synchronized to disk so that the server can remove that segment if it
|
| 108 |
+
is not otherwise needed.
|
| 109 |
+
</p><p>
|
| 110 |
+
When the replication client
|
| 111 |
+
of <span class="application">pg_receivewal</span> is configured on the
|
| 112 |
+
server as a synchronous standby, then using a replication slot will
|
| 113 |
+
report the flush position to the server, but only when a WAL file is
|
| 114 |
+
closed. Therefore, that configuration will cause transactions on the
|
| 115 |
+
primary to wait for a long time and effectively not work
|
| 116 |
+
satisfactorily. The option <code class="literal">--synchronous</code> (see
|
| 117 |
+
below) must be specified in addition to make this work correctly.
|
| 118 |
+
</p></dd><dt><span class="term"><code class="option">--synchronous</code></span></dt><dd><p>
|
| 119 |
+
Flush the WAL data to disk immediately after it has been received. Also
|
| 120 |
+
send a status packet back to the server immediately after flushing,
|
| 121 |
+
regardless of <code class="literal">--status-interval</code>.
|
| 122 |
+
</p><p>
|
| 123 |
+
This option should be specified if the replication client
|
| 124 |
+
of <span class="application">pg_receivewal</span> is configured on the
|
| 125 |
+
server as a synchronous standby, to ensure that timely feedback is
|
| 126 |
+
sent to the server.
|
| 127 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 128 |
+
Enables verbose mode.
|
| 129 |
+
</p></dd><dt><span class="term"><code class="option">-Z <em class="replaceable"><code>level</code></em></code><br /></span><span class="term"><code class="option">-Z <em class="replaceable"><code>method</code></em>[:<em class="replaceable"><code>detail</code></em>]</code><br /></span><span class="term"><code class="option">--compress=<em class="replaceable"><code>level</code></em></code><br /></span><span class="term"><code class="option">--compress=<em class="replaceable"><code>method</code></em>[:<em class="replaceable"><code>detail</code></em>]</code></span></dt><dd><p>
|
| 130 |
+
Enables compression of write-ahead logs.
|
| 131 |
+
</p><p>
|
| 132 |
+
The compression method can be set to <code class="literal">gzip</code>,
|
| 133 |
+
<code class="literal">lz4</code> (if <span class="productname">PostgreSQL</span>
|
| 134 |
+
was compiled with <code class="option">--with-lz4</code>) or
|
| 135 |
+
<code class="literal">none</code> for no compression.
|
| 136 |
+
A compression detail string can optionally be specified. If the
|
| 137 |
+
detail string is an integer, it specifies the compression level.
|
| 138 |
+
Otherwise, it should be a comma-separated list of items, each of the
|
| 139 |
+
form <code class="literal">keyword</code> or <code class="literal">keyword=value</code>.
|
| 140 |
+
Currently, the only supported keyword is <code class="literal">level</code>.
|
| 141 |
+
</p><p>
|
| 142 |
+
If no compression level is specified, the default compression level
|
| 143 |
+
will be used. If only a level is specified without mentioning an
|
| 144 |
+
algorithm, <code class="literal">gzip</code> compression will be used if the
|
| 145 |
+
level is greater than 0, and no compression will be used if the level
|
| 146 |
+
is 0.
|
| 147 |
+
</p><p>
|
| 148 |
+
The suffix <code class="filename">.gz</code> will automatically be added to
|
| 149 |
+
all filenames when using <code class="literal">gzip</code>, and the suffix
|
| 150 |
+
<code class="filename">.lz4</code> is added when using <code class="literal">lz4</code>.
|
| 151 |
+
</p></dd></dl></div><p>
|
| 152 |
+
The following command-line options control the database connection parameters.
|
| 153 |
+
|
| 154 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d <em class="replaceable"><code>connstr</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>connstr</code></em></code></span></dt><dd><p>
|
| 155 |
+
Specifies parameters used to connect to the server, as a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>; these
|
| 156 |
+
will override any conflicting command line options.
|
| 157 |
+
</p><p>
|
| 158 |
+
The option is called <code class="literal">--dbname</code> for consistency with other
|
| 159 |
+
client applications, but because <span class="application">pg_receivewal</span>
|
| 160 |
+
doesn't connect to any particular database in the cluster, database
|
| 161 |
+
name in the connection string will be ignored.
|
| 162 |
+
</p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 163 |
+
Specifies the host name of the machine on which the server is
|
| 164 |
+
running. If the value begins with a slash, it is used as the
|
| 165 |
+
directory for the Unix domain socket. The default is taken
|
| 166 |
+
from the <code class="envar">PGHOST</code> environment variable, if set,
|
| 167 |
+
else a Unix domain socket connection is attempted.
|
| 168 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 169 |
+
Specifies the TCP port or local Unix domain socket file
|
| 170 |
+
extension on which the server is listening for connections.
|
| 171 |
+
Defaults to the <code class="envar">PGPORT</code> environment variable, if
|
| 172 |
+
set, or a compiled-in default.
|
| 173 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 174 |
+
User name to connect as.
|
| 175 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 176 |
+
Never issue a password prompt. If the server requires
|
| 177 |
+
password authentication and a password is not available by
|
| 178 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 179 |
+
connection attempt will fail. This option can be useful in
|
| 180 |
+
batch jobs and scripts where no user is present to enter a
|
| 181 |
+
password.
|
| 182 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 183 |
+
Force <span class="application">pg_receivewal</span> to prompt for a
|
| 184 |
+
password before connecting to a database.
|
| 185 |
+
</p><p>
|
| 186 |
+
This option is never essential, since
|
| 187 |
+
<span class="application">pg_receivewal</span> will automatically prompt
|
| 188 |
+
for a password if the server demands password authentication.
|
| 189 |
+
However, <span class="application">pg_receivewal</span> will waste a
|
| 190 |
+
connection attempt finding out that the server wants a password.
|
| 191 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 192 |
+
connection attempt.
|
| 193 |
+
</p></dd></dl></div><p>
|
| 194 |
+
</p><p>
|
| 195 |
+
<span class="application">pg_receivewal</span> can perform one of the two
|
| 196 |
+
following actions in order to control physical replication slots:
|
| 197 |
+
|
| 198 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--create-slot</code></span></dt><dd><p>
|
| 199 |
+
Create a new physical replication slot with the name specified in
|
| 200 |
+
<code class="option">--slot</code>, then exit.
|
| 201 |
+
</p></dd><dt><span class="term"><code class="option">--drop-slot</code></span></dt><dd><p>
|
| 202 |
+
Drop the replication slot with the name specified in
|
| 203 |
+
<code class="option">--slot</code>, then exit.
|
| 204 |
+
</p></dd></dl></div><p>
|
| 205 |
+
</p><p>
|
| 206 |
+
Other options are also available:
|
| 207 |
+
|
| 208 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 209 |
+
Print the <span class="application">pg_receivewal</span> version and exit.
|
| 210 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 211 |
+
Show help about <span class="application">pg_receivewal</span> command line
|
| 212 |
+
arguments, and exit.
|
| 213 |
+
</p></dd></dl></div><p>
|
| 214 |
+
</p></div><div class="refsect1" id="id-1.9.4.16.7"><h2>Exit Status</h2><p>
|
| 215 |
+
<span class="application">pg_receivewal</span> will exit with status 0 when
|
| 216 |
+
terminated by the <span class="systemitem">SIGINT</span> or
|
| 217 |
+
<span class="systemitem">SIGTERM</span> signal. (That is the
|
| 218 |
+
normal way to end it. Hence it is not an error.) For fatal errors or
|
| 219 |
+
other signals, the exit status will be nonzero.
|
| 220 |
+
</p></div><div class="refsect1" id="id-1.9.4.16.8"><h2>Environment</h2><p>
|
| 221 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 222 |
+
uses the environment variables supported by <span class="application">libpq</span>
|
| 223 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 224 |
+
</p><p>
|
| 225 |
+
The environment variable <code class="envar">PG_COLOR</code> specifies whether to use
|
| 226 |
+
color in diagnostic messages. Possible values are
|
| 227 |
+
<code class="literal">always</code>, <code class="literal">auto</code> and
|
| 228 |
+
<code class="literal">never</code>.
|
| 229 |
+
</p></div><div class="refsect1" id="id-1.9.4.16.9"><h2>Notes</h2><p>
|
| 230 |
+
When using <span class="application">pg_receivewal</span> instead of
|
| 231 |
+
<a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-COMMAND">archive_command</a> or
|
| 232 |
+
<a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-LIBRARY">archive_library</a> as the main WAL backup method, it is
|
| 233 |
+
strongly recommended to use replication slots. Otherwise, the server is
|
| 234 |
+
free to recycle or remove write-ahead log files before they are backed up,
|
| 235 |
+
because it does not have any information, either
|
| 236 |
+
from <a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-COMMAND">archive_command</a> or
|
| 237 |
+
<a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-LIBRARY">archive_library</a> or the replication slots, about
|
| 238 |
+
how far the WAL stream has been archived. Note, however, that a
|
| 239 |
+
replication slot will fill up the server's disk space if the receiver does
|
| 240 |
+
not keep up with fetching the WAL data.
|
| 241 |
+
</p><p>
|
| 242 |
+
<span class="application">pg_receivewal</span> will preserve group permissions on
|
| 243 |
+
the received WAL files if group permissions are enabled on the source
|
| 244 |
+
cluster.
|
| 245 |
+
</p></div><div class="refsect1" id="id-1.9.4.16.10"><h2>Examples</h2><p>
|
| 246 |
+
To stream the write-ahead log from the server at
|
| 247 |
+
<code class="literal">mydbserver</code> and store it in the local directory
|
| 248 |
+
<code class="filename">/usr/local/pgsql/archive</code>:
|
| 249 |
+
</p><pre class="screen">
|
| 250 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_receivewal -h mydbserver -D /usr/local/pgsql/archive</code></strong>
|
| 251 |
+
</pre></div><div class="refsect1" id="id-1.9.4.16.11"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pgbasebackup.html" title="pg_basebackup"><span class="refentrytitle"><span class="application">pg_basebackup</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pg-isready.html" title="pg_isready">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgrecvlogical.html" title="pg_recvlogical">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_isready</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_recvlogical</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgreceivexlog.html
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>O.5. pg_receivexlog renamed to pg_receivewal</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgresetxlog.html" title="O.4. pg_resetxlog renamed to pg_resetwal" /><link rel="next" href="biblio.html" title="Bibliography" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">O.5. <code class="command">pg_receivexlog</code> renamed to <code class="command">pg_receivewal</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgresetxlog.html" title="O.4. pg_resetxlog renamed to pg_resetwal">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="appendix-obsolete.html" title="Appendix O. Obsolete or Renamed Features">Up</a></td><th width="60%" align="center">Appendix O. Obsolete or Renamed Features</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="biblio.html" title="Bibliography">Next</a></td></tr></table><hr /></div><div class="sect1" id="APP-PGRECEIVEXLOG"><div class="titlepage"><div><div><h2 class="title" style="clear: both">O.5. <code class="command">pg_receivexlog</code> renamed to <code class="command">pg_receivewal</code> <a href="#APP-PGRECEIVEXLOG" class="id_link">#</a></h2></div></div></div><a id="id-1.11.16.7.2" class="indexterm"></a><p>
|
| 3 |
+
PostgreSQL 9.6 and below provided a command named
|
| 4 |
+
<code class="command">pg_receivexlog</code>
|
| 5 |
+
<a id="id-1.11.16.7.3.2" class="indexterm"></a>
|
| 6 |
+
to fetch write-ahead-log (WAL) files. This command was renamed to <code class="command">pg_receivewal</code>, see
|
| 7 |
+
<a class="xref" href="app-pgreceivewal.html" title="pg_receivewal"><span class="refentrytitle"><span class="application">pg_receivewal</span></span></a> for documentation of <code class="command">pg_receivewal</code> and see
|
| 8 |
+
<a class="link" href="release-prior.html" title="E.5. Prior Releases">the release notes for PostgreSQL 10</a> for details
|
| 9 |
+
on this change.
|
| 10 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgresetxlog.html" title="O.4. pg_resetxlog renamed to pg_resetwal">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix-obsolete.html" title="Appendix O. Obsolete or Renamed Features">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="biblio.html" title="Bibliography">Next</a></td></tr><tr><td width="40%" align="left" valign="top">O.4. <code class="command">pg_resetxlog</code> renamed to <code class="command">pg_resetwal</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Bibliography</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgrecvlogical.html
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_recvlogical</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgreceivewal.html" title="pg_receivewal" /><link rel="next" href="app-pgrestore.html" title="pg_restore" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_recvlogical</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgreceivewal.html" title="pg_receivewal">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgrestore.html" title="pg_restore">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGRECVLOGICAL"><div class="titlepage"></div><a id="id-1.9.4.17.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_recvlogical</span></span></h2><p>pg_recvlogical — control <span class="productname">PostgreSQL</span> logical decoding streams</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.17.4.1"><code class="command">pg_recvlogical</code> [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="id-1.9.4.17.5"><h2>Description</h2><p>
|
| 3 |
+
<code class="command">pg_recvlogical</code> controls logical decoding replication
|
| 4 |
+
slots and streams data from such replication slots.
|
| 5 |
+
</p><p>
|
| 6 |
+
It creates a replication-mode connection, so it is subject to the same
|
| 7 |
+
constraints as <a class="xref" href="app-pgreceivewal.html" title="pg_receivewal"><span class="refentrytitle"><span class="application">pg_receivewal</span></span></a>, plus those for logical
|
| 8 |
+
replication (see <a class="xref" href="logicaldecoding.html" title="Chapter 49. Logical Decoding">Chapter 49</a>).
|
| 9 |
+
</p><p>
|
| 10 |
+
<code class="command">pg_recvlogical</code> has no equivalent to the logical decoding
|
| 11 |
+
SQL interface's peek and get modes. It sends replay confirmations for
|
| 12 |
+
data lazily as it receives it and on clean exit. To examine pending data on
|
| 13 |
+
a slot without consuming it, use
|
| 14 |
+
<a class="link" href="functions-admin.html#FUNCTIONS-REPLICATION" title="9.27.6. Replication Management Functions"><code class="function">pg_logical_slot_peek_changes</code></a>.
|
| 15 |
+
</p><p>
|
| 16 |
+
In the absence of fatal errors, <span class="application">pg_recvlogical</span>
|
| 17 |
+
will run until terminated by the <span class="systemitem">SIGINT</span>
|
| 18 |
+
(<span class="keycap"><strong>Control</strong></span>+<span class="keycap"><strong>C</strong></span>)
|
| 19 |
+
or <span class="systemitem">SIGTERM</span> signal.
|
| 20 |
+
</p></div><div class="refsect1" id="id-1.9.4.17.6"><h2>Options</h2><p>
|
| 21 |
+
At least one of the following options must be specified to select an action:
|
| 22 |
+
|
| 23 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--create-slot</code></span></dt><dd><p>
|
| 24 |
+
Create a new logical replication slot with the name specified by
|
| 25 |
+
<code class="option">--slot</code>, using the output plugin specified by
|
| 26 |
+
<code class="option">--plugin</code>, for the database specified
|
| 27 |
+
by <code class="option">--dbname</code>.
|
| 28 |
+
</p><p>
|
| 29 |
+
The <code class="option">--two-phase</code> can be specified with
|
| 30 |
+
<code class="option">--create-slot</code> to enable decoding of prepared transactions.
|
| 31 |
+
</p></dd><dt><span class="term"><code class="option">--drop-slot</code></span></dt><dd><p>
|
| 32 |
+
Drop the replication slot with the name specified
|
| 33 |
+
by <code class="option">--slot</code>, then exit.
|
| 34 |
+
</p></dd><dt><span class="term"><code class="option">--start</code></span></dt><dd><p>
|
| 35 |
+
Begin streaming changes from the logical replication slot specified
|
| 36 |
+
by <code class="option">--slot</code>, continuing until terminated by a
|
| 37 |
+
signal. If the server side change stream ends with a server shutdown
|
| 38 |
+
or disconnect, retry in a loop unless
|
| 39 |
+
<code class="option">--no-loop</code> is specified.
|
| 40 |
+
</p><p>
|
| 41 |
+
The stream format is determined by the output plugin specified when
|
| 42 |
+
the slot was created.
|
| 43 |
+
</p><p>
|
| 44 |
+
The connection must be to the same database used to create the slot.
|
| 45 |
+
</p></dd></dl></div><p>
|
| 46 |
+
</p><p>
|
| 47 |
+
<code class="option">--create-slot</code> and <code class="option">--start</code> can be
|
| 48 |
+
specified together. <code class="option">--drop-slot</code> cannot be combined with
|
| 49 |
+
another action.
|
| 50 |
+
</p><p>
|
| 51 |
+
The following command-line options control the location and format of the
|
| 52 |
+
output and other replication behavior:
|
| 53 |
+
|
| 54 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-E <em class="replaceable"><code>lsn</code></em></code><br /></span><span class="term"><code class="option">--endpos=<em class="replaceable"><code>lsn</code></em></code></span></dt><dd><p>
|
| 55 |
+
In <code class="option">--start</code> mode, automatically stop replication
|
| 56 |
+
and exit with normal exit status 0 when receiving reaches the
|
| 57 |
+
specified LSN. If specified when not in <code class="option">--start</code>
|
| 58 |
+
mode, an error is raised.
|
| 59 |
+
</p><p>
|
| 60 |
+
If there's a record with LSN exactly equal to <em class="replaceable"><code>lsn</code></em>,
|
| 61 |
+
the record will be output.
|
| 62 |
+
</p><p>
|
| 63 |
+
The <code class="option">--endpos</code> option is not aware of transaction
|
| 64 |
+
boundaries and may truncate output partway through a transaction.
|
| 65 |
+
Any partially output transaction will not be consumed and will be
|
| 66 |
+
replayed again when the slot is next read from. Individual messages
|
| 67 |
+
are never truncated.
|
| 68 |
+
</p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>filename</code></em></code><br /></span><span class="term"><code class="option">--file=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
|
| 69 |
+
Write received and decoded transaction data into this
|
| 70 |
+
file. Use <code class="literal">-</code> for <span class="systemitem">stdout</span>.
|
| 71 |
+
</p></dd><dt><span class="term"><code class="option">-F <em class="replaceable"><code>interval_seconds</code></em></code><br /></span><span class="term"><code class="option">--fsync-interval=<em class="replaceable"><code>interval_seconds</code></em></code></span></dt><dd><p>
|
| 72 |
+
Specifies how often <span class="application">pg_recvlogical</span> should
|
| 73 |
+
issue <code class="function">fsync()</code> calls to ensure the output file is
|
| 74 |
+
safely flushed to disk.
|
| 75 |
+
</p><p>
|
| 76 |
+
The server will occasionally request the client to perform a flush and
|
| 77 |
+
report the flush position to the server. This setting is in addition
|
| 78 |
+
to that, to perform flushes more frequently.
|
| 79 |
+
</p><p>
|
| 80 |
+
Specifying an interval of <code class="literal">0</code> disables
|
| 81 |
+
issuing <code class="function">fsync()</code> calls altogether, while still
|
| 82 |
+
reporting progress to the server. In this case, data could be lost in
|
| 83 |
+
the event of a crash.
|
| 84 |
+
</p></dd><dt><span class="term"><code class="option">-I <em class="replaceable"><code>lsn</code></em></code><br /></span><span class="term"><code class="option">--startpos=<em class="replaceable"><code>lsn</code></em></code></span></dt><dd><p>
|
| 85 |
+
In <code class="option">--start</code> mode, start replication from the given
|
| 86 |
+
LSN. For details on the effect of this, see the documentation
|
| 87 |
+
in <a class="xref" href="logicaldecoding.html" title="Chapter 49. Logical Decoding">Chapter 49</a>
|
| 88 |
+
and <a class="xref" href="protocol-replication.html" title="55.4. Streaming Replication Protocol">Section 55.4</a>. Ignored in other modes.
|
| 89 |
+
</p></dd><dt><span class="term"><code class="option">--if-not-exists</code></span></dt><dd><p>
|
| 90 |
+
Do not error out when <code class="option">--create-slot</code> is specified
|
| 91 |
+
and a slot with the specified name already exists.
|
| 92 |
+
</p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-loop</code></span></dt><dd><p>
|
| 93 |
+
When the connection to the server is lost, do not retry in a loop, just exit.
|
| 94 |
+
</p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>name</code></em>[=<em class="replaceable"><code>value</code></em>]</code><br /></span><span class="term"><code class="option">--option=<em class="replaceable"><code>name</code></em>[=<em class="replaceable"><code>value</code></em>]</code></span></dt><dd><p>
|
| 95 |
+
Pass the option <em class="replaceable"><code>name</code></em> to the output plugin with,
|
| 96 |
+
if specified, the option value <em class="replaceable"><code>value</code></em>. Which
|
| 97 |
+
options exist and their effects depends on the used output plugin.
|
| 98 |
+
</p></dd><dt><span class="term"><code class="option">-P <em class="replaceable"><code>plugin</code></em></code><br /></span><span class="term"><code class="option">--plugin=<em class="replaceable"><code>plugin</code></em></code></span></dt><dd><p>
|
| 99 |
+
When creating a slot, use the specified logical decoding output
|
| 100 |
+
plugin. See <a class="xref" href="logicaldecoding.html" title="Chapter 49. Logical Decoding">Chapter 49</a>. This option has no
|
| 101 |
+
effect if the slot already exists.
|
| 102 |
+
</p></dd><dt><span class="term"><code class="option">-s <em class="replaceable"><code>interval_seconds</code></em></code><br /></span><span class="term"><code class="option">--status-interval=<em class="replaceable"><code>interval_seconds</code></em></code></span></dt><dd><p>
|
| 103 |
+
This option has the same effect as the option of the same name
|
| 104 |
+
in <a class="xref" href="app-pgreceivewal.html" title="pg_receivewal"><span class="refentrytitle"><span class="application">pg_receivewal</span></span></a>. See the description there.
|
| 105 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>slot_name</code></em></code><br /></span><span class="term"><code class="option">--slot=<em class="replaceable"><code>slot_name</code></em></code></span></dt><dd><p>
|
| 106 |
+
In <code class="option">--start</code> mode, use the existing logical replication slot named
|
| 107 |
+
<em class="replaceable"><code>slot_name</code></em>. In <code class="option">--create-slot</code>
|
| 108 |
+
mode, create the slot with this name. In <code class="option">--drop-slot</code>
|
| 109 |
+
mode, delete the slot with this name.
|
| 110 |
+
</p></dd><dt><span class="term"><code class="option">-t</code><br /></span><span class="term"><code class="option">--two-phase</code></span></dt><dd><p>
|
| 111 |
+
Enables decoding of prepared transactions. This option may only be specified with
|
| 112 |
+
<code class="option">--create-slot</code>
|
| 113 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 114 |
+
Enables verbose mode.
|
| 115 |
+
</p></dd></dl></div><p>
|
| 116 |
+
</p><p>
|
| 117 |
+
The following command-line options control the database connection parameters.
|
| 118 |
+
|
| 119 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 120 |
+
The database to connect to. See the description
|
| 121 |
+
of the actions for what this means in detail.
|
| 122 |
+
The <em class="replaceable"><code>dbname</code></em> can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>. If so,
|
| 123 |
+
connection string parameters will override any conflicting
|
| 124 |
+
command line options. Defaults to the user name.
|
| 125 |
+
</p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>hostname-or-ip</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>hostname-or-ip</code></em></code></span></dt><dd><p>
|
| 126 |
+
Specifies the host name of the machine on which the server is
|
| 127 |
+
running. If the value begins with a slash, it is used as the
|
| 128 |
+
directory for the Unix domain socket. The default is taken
|
| 129 |
+
from the <code class="envar">PGHOST</code> environment variable, if set,
|
| 130 |
+
else a Unix domain socket connection is attempted.
|
| 131 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 132 |
+
Specifies the TCP port or local Unix domain socket file
|
| 133 |
+
extension on which the server is listening for connections.
|
| 134 |
+
Defaults to the <code class="envar">PGPORT</code> environment variable, if
|
| 135 |
+
set, or a compiled-in default.
|
| 136 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>user</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>user</code></em></code></span></dt><dd><p>
|
| 137 |
+
User name to connect as. Defaults to current operating system user
|
| 138 |
+
name.
|
| 139 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 140 |
+
Never issue a password prompt. If the server requires
|
| 141 |
+
password authentication and a password is not available by
|
| 142 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 143 |
+
connection attempt will fail. This option can be useful in
|
| 144 |
+
batch jobs and scripts where no user is present to enter a
|
| 145 |
+
password.
|
| 146 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 147 |
+
Force <span class="application">pg_recvlogical</span> to prompt for a
|
| 148 |
+
password before connecting to a database.
|
| 149 |
+
</p><p>
|
| 150 |
+
This option is never essential, since
|
| 151 |
+
<span class="application">pg_recvlogical</span> will automatically prompt
|
| 152 |
+
for a password if the server demands password authentication.
|
| 153 |
+
However, <span class="application">pg_recvlogical</span> will waste a
|
| 154 |
+
connection attempt finding out that the server wants a password.
|
| 155 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 156 |
+
connection attempt.
|
| 157 |
+
</p></dd></dl></div><p>
|
| 158 |
+
</p><p>
|
| 159 |
+
The following additional options are available:
|
| 160 |
+
|
| 161 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 162 |
+
Print the <span class="application">pg_recvlogical</span> version and exit.
|
| 163 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 164 |
+
Show help about <span class="application">pg_recvlogical</span> command line
|
| 165 |
+
arguments, and exit.
|
| 166 |
+
</p></dd></dl></div><p>
|
| 167 |
+
</p></div><div class="refsect1" id="id-1.9.4.17.7"><h2>Exit Status</h2><p>
|
| 168 |
+
<span class="application">pg_recvlogical</span> will exit with status 0 when
|
| 169 |
+
terminated by the <span class="systemitem">SIGINT</span> or
|
| 170 |
+
<span class="systemitem">SIGTERM</span> signal. (That is the
|
| 171 |
+
normal way to end it. Hence it is not an error.) For fatal errors or
|
| 172 |
+
other signals, the exit status will be nonzero.
|
| 173 |
+
</p></div><div class="refsect1" id="id-1.9.4.17.8"><h2>Environment</h2><p>
|
| 174 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 175 |
+
uses the environment variables supported by <span class="application">libpq</span>
|
| 176 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 177 |
+
</p><p>
|
| 178 |
+
The environment variable <code class="envar">PG_COLOR</code> specifies whether to use
|
| 179 |
+
color in diagnostic messages. Possible values are
|
| 180 |
+
<code class="literal">always</code>, <code class="literal">auto</code> and
|
| 181 |
+
<code class="literal">never</code>.
|
| 182 |
+
</p></div><div class="refsect1" id="id-1.9.4.17.9"><h2>Notes</h2><p>
|
| 183 |
+
<span class="application">pg_recvlogical</span> will preserve group permissions on
|
| 184 |
+
the received WAL files if group permissions are enabled on the source
|
| 185 |
+
cluster.
|
| 186 |
+
</p></div><div class="refsect1" id="id-1.9.4.17.10"><h2>Examples</h2><p>
|
| 187 |
+
See <a class="xref" href="logicaldecoding-example.html" title="49.1. Logical Decoding Examples">Section 49.1</a> for an example.
|
| 188 |
+
</p></div><div class="refsect1" id="id-1.9.4.17.11"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pgreceivewal.html" title="pg_receivewal"><span class="refentrytitle"><span class="application">pg_receivewal</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgreceivewal.html" title="pg_receivewal">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgrestore.html" title="pg_restore">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_receivewal</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_restore</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgresetwal.html
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_resetwal</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pg-ctl.html" title="pg_ctl" /><link rel="next" href="app-pgrewind.html" title="pg_rewind" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_resetwal</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pg-ctl.html" title="pg_ctl">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgrewind.html" title="pg_rewind">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGRESETWAL"><div class="titlepage"></div><a id="id-1.9.5.8.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_resetwal</span></span></h2><p>pg_resetwal — reset the write-ahead log and other control information of a <span class="productname">PostgreSQL</span> database cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.8.4.1"><code class="command">pg_resetwal</code> [ <code class="option">-f</code> | <code class="option">--force</code> ] [ <code class="option">-n</code> | <code class="option">--dry-run</code> ] [<em class="replaceable"><code>option</code></em>...] [ <code class="option">-D</code> | <code class="option">--pgdata</code> ]<em class="replaceable"><code>datadir</code></em> </p></div></div><div class="refsect1" id="R1-APP-PGRESETWAL-1"><h2>Description</h2><p>
|
| 3 |
+
<code class="command">pg_resetwal</code> clears the write-ahead log (WAL) and
|
| 4 |
+
optionally resets some other control information stored in the
|
| 5 |
+
<code class="filename">pg_control</code> file. This function is sometimes needed
|
| 6 |
+
if these files have become corrupted. It should be used only as a
|
| 7 |
+
last resort, when the server will not start due to such corruption.
|
| 8 |
+
</p><p>
|
| 9 |
+
After running this command, it should be possible to start the server,
|
| 10 |
+
but bear in mind that the database might contain inconsistent data due to
|
| 11 |
+
partially-committed transactions. You should immediately dump your data,
|
| 12 |
+
run <code class="command">initdb</code>, and restore. After restore, check for
|
| 13 |
+
inconsistencies and repair as needed.
|
| 14 |
+
</p><p>
|
| 15 |
+
This utility can only be run by the user who installed the server, because
|
| 16 |
+
it requires read/write access to the data directory.
|
| 17 |
+
For safety reasons, you must specify the data directory on the command line.
|
| 18 |
+
<code class="command">pg_resetwal</code> does not use the environment variable
|
| 19 |
+
<code class="envar">PGDATA</code>.
|
| 20 |
+
</p><p>
|
| 21 |
+
If <code class="command">pg_resetwal</code> complains that it cannot determine
|
| 22 |
+
valid data for <code class="filename">pg_control</code>, you can force it to proceed anyway
|
| 23 |
+
by specifying the <code class="option">-f</code> (force) option. In this case plausible
|
| 24 |
+
values will be substituted for the missing data. Most of the fields can be
|
| 25 |
+
expected to match, but manual assistance might be needed for the next OID,
|
| 26 |
+
next transaction ID and epoch, next multitransaction ID and offset, and
|
| 27 |
+
WAL starting location fields. These fields can be set using the options
|
| 28 |
+
discussed below. If you are not able to determine correct values for all
|
| 29 |
+
these fields, <code class="option">-f</code> can still be used, but
|
| 30 |
+
the recovered database must be treated with even more suspicion than
|
| 31 |
+
usual: an immediate dump and restore is imperative. <span class="emphasis"><em>Do not</em></span>
|
| 32 |
+
execute any data-modifying operations in the database before you dump,
|
| 33 |
+
as any such action is likely to make the corruption worse.
|
| 34 |
+
</p></div><div class="refsect1" id="id-1.9.5.8.6"><h2>Options</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-f</code><br /></span><span class="term"><code class="option">--force</code></span></dt><dd><p>
|
| 35 |
+
Force <code class="command">pg_resetwal</code> to proceed even if it cannot determine
|
| 36 |
+
valid data for <code class="filename">pg_control</code>, as explained above.
|
| 37 |
+
</p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--dry-run</code></span></dt><dd><p>
|
| 38 |
+
The <code class="option">-n</code>/<code class="option">--dry-run</code> option instructs
|
| 39 |
+
<code class="command">pg_resetwal</code> to print the values reconstructed from
|
| 40 |
+
<code class="filename">pg_control</code> and values about to be changed, and then exit
|
| 41 |
+
without modifying anything. This is mainly a debugging tool, but can be
|
| 42 |
+
useful as a sanity check before allowing <code class="command">pg_resetwal</code>
|
| 43 |
+
to proceed for real.
|
| 44 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>Display version information, then exit.</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>Show help, then exit.</p></dd></dl></div><p>
|
| 45 |
+
The following options are only needed when
|
| 46 |
+
<code class="command">pg_resetwal</code> is unable to determine appropriate values
|
| 47 |
+
by reading <code class="filename">pg_control</code>. Safe values can be determined as
|
| 48 |
+
described below. For values that take numeric arguments, hexadecimal
|
| 49 |
+
values can be specified by using the prefix <code class="literal">0x</code>.
|
| 50 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-c <em class="replaceable"><code>xid</code></em>,<em class="replaceable"><code>xid</code></em></code><br /></span><span class="term"><code class="option">--commit-timestamp-ids=<em class="replaceable"><code>xid</code></em>,<em class="replaceable"><code>xid</code></em></code></span></dt><dd><p>
|
| 51 |
+
Manually set the oldest and newest transaction IDs for which the commit
|
| 52 |
+
time can be retrieved.
|
| 53 |
+
</p><p>
|
| 54 |
+
A safe value for the oldest transaction ID for which the commit time can
|
| 55 |
+
be retrieved (first part) can be determined by looking
|
| 56 |
+
for the numerically smallest file name in the directory
|
| 57 |
+
<code class="filename">pg_commit_ts</code> under the data directory. Conversely, a safe
|
| 58 |
+
value for the newest transaction ID for which the commit time can be
|
| 59 |
+
retrieved (second part) can be determined by looking for the numerically
|
| 60 |
+
greatest file name in the same directory. The file names are in
|
| 61 |
+
hexadecimal.
|
| 62 |
+
</p></dd><dt><span class="term"><code class="option">-e <em class="replaceable"><code>xid_epoch</code></em></code><br /></span><span class="term"><code class="option">--epoch=<em class="replaceable"><code>xid_epoch</code></em></code></span></dt><dd><p>
|
| 63 |
+
Manually set the next transaction ID's epoch.
|
| 64 |
+
</p><p>
|
| 65 |
+
The transaction ID epoch is not actually stored anywhere in the database
|
| 66 |
+
except in the field that is set by <code class="command">pg_resetwal</code>,
|
| 67 |
+
so any value will work so far as the database itself is concerned.
|
| 68 |
+
You might need to adjust this value to ensure that replication
|
| 69 |
+
systems such as <span class="application">Slony-I</span> and
|
| 70 |
+
<span class="application">Skytools</span> work correctly —
|
| 71 |
+
if so, an appropriate value should be obtainable from the state of
|
| 72 |
+
the downstream replicated database.
|
| 73 |
+
</p></dd><dt><span class="term"><code class="option">-l <em class="replaceable"><code>walfile</code></em></code><br /></span><span class="term"><code class="option">--next-wal-file=<em class="replaceable"><code>walfile</code></em></code></span></dt><dd><p>
|
| 74 |
+
Manually set the WAL starting location by specifying the name of the
|
| 75 |
+
next WAL segment file.
|
| 76 |
+
</p><p>
|
| 77 |
+
The name of next WAL segment file should be
|
| 78 |
+
larger than any WAL segment file name currently existing in
|
| 79 |
+
the directory <code class="filename">pg_wal</code> under the data directory.
|
| 80 |
+
These names are also in hexadecimal and have three parts. The first
|
| 81 |
+
part is the <span class="quote">“<span class="quote">timeline ID</span>”</span> and should usually be kept the same.
|
| 82 |
+
For example, if <code class="filename">00000001000000320000004A</code> is the
|
| 83 |
+
largest entry in <code class="filename">pg_wal</code>, use <code class="literal">-l 00000001000000320000004B</code> or higher.
|
| 84 |
+
</p><p>
|
| 85 |
+
Note that when using nondefault WAL segment sizes, the numbers in the WAL
|
| 86 |
+
file names are different from the LSNs that are reported by system
|
| 87 |
+
functions and system views. This option takes a WAL file name, not an
|
| 88 |
+
LSN.
|
| 89 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 90 |
+
<code class="command">pg_resetwal</code> itself looks at the files in
|
| 91 |
+
<code class="filename">pg_wal</code> and chooses a default <code class="option">-l</code> setting
|
| 92 |
+
beyond the last existing file name. Therefore, manual adjustment of
|
| 93 |
+
<code class="option">-l</code> should only be needed if you are aware of WAL segment
|
| 94 |
+
files that are not currently present in <code class="filename">pg_wal</code>, such as
|
| 95 |
+
entries in an offline archive; or if the contents of
|
| 96 |
+
<code class="filename">pg_wal</code> have been lost entirely.
|
| 97 |
+
</p></div></dd><dt><span class="term"><code class="option">-m <em class="replaceable"><code>mxid</code></em>,<em class="replaceable"><code>mxid</code></em></code><br /></span><span class="term"><code class="option">--multixact-ids=<em class="replaceable"><code>mxid</code></em>,<em class="replaceable"><code>mxid</code></em></code></span></dt><dd><p>
|
| 98 |
+
Manually set the next and oldest multitransaction ID.
|
| 99 |
+
</p><p>
|
| 100 |
+
A safe value for the next multitransaction ID (first part) can be
|
| 101 |
+
determined by looking for the numerically largest file name in the
|
| 102 |
+
directory <code class="filename">pg_multixact/offsets</code> under the data directory,
|
| 103 |
+
adding one, and then multiplying by 65536 (0x10000). Conversely, a safe
|
| 104 |
+
value for the oldest multitransaction ID (second part of
|
| 105 |
+
<code class="option">-m</code>) can be determined by looking for the numerically smallest
|
| 106 |
+
file name in the same directory and multiplying by 65536. The file
|
| 107 |
+
names are in hexadecimal, so the easiest way to do this is to specify
|
| 108 |
+
the option value in hexadecimal and append four zeroes.
|
| 109 |
+
</p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>oid</code></em></code><br /></span><span class="term"><code class="option">--next-oid=<em class="replaceable"><code>oid</code></em></code></span></dt><dd><p>
|
| 110 |
+
Manually set the next OID.
|
| 111 |
+
</p><p>
|
| 112 |
+
There is no comparably easy way to determine a next OID that's beyond
|
| 113 |
+
the largest one in the database, but fortunately it is not critical to
|
| 114 |
+
get the next-OID setting right.
|
| 115 |
+
</p></dd><dt><span class="term"><code class="option">-O <em class="replaceable"><code>mxoff</code></em></code><br /></span><span class="term"><code class="option">--multixact-offset=<em class="replaceable"><code>mxoff</code></em></code></span></dt><dd><p>
|
| 116 |
+
Manually set the next multitransaction offset.
|
| 117 |
+
</p><p>
|
| 118 |
+
A safe value can be determined by looking for the numerically largest
|
| 119 |
+
file name in the directory <code class="filename">pg_multixact/members</code> under the
|
| 120 |
+
data directory, adding one, and then multiplying by 52352 (0xCC80).
|
| 121 |
+
The file names are in hexadecimal. There is no simple recipe such as
|
| 122 |
+
the ones for other options of appending zeroes.
|
| 123 |
+
</p></dd><dt><span class="term"><code class="option">--wal-segsize=<em class="replaceable"><code>wal_segment_size</code></em></code></span></dt><dd><p>
|
| 124 |
+
Set the new WAL segment size, in megabytes. The value must be set to a
|
| 125 |
+
power of 2 between 1 and 1024 (megabytes). See the same option of <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a> for more information.
|
| 126 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 127 |
+
While <code class="command">pg_resetwal</code> will set the WAL starting address
|
| 128 |
+
beyond the latest existing WAL segment file, some segment size changes
|
| 129 |
+
can cause previous WAL file names to be reused. It is recommended to
|
| 130 |
+
use <code class="option">-l</code> together with this option to manually set the
|
| 131 |
+
WAL starting address if WAL file name overlap will cause problems with
|
| 132 |
+
your archiving strategy.
|
| 133 |
+
</p></div></dd><dt><span class="term"><code class="option">-u <em class="replaceable"><code>xid</code></em></code><br /></span><span class="term"><code class="option">--oldest-transaction-id=<em class="replaceable"><code>xid</code></em></code></span></dt><dd><p>
|
| 134 |
+
Manually set the oldest unfrozen transaction ID.
|
| 135 |
+
</p><p>
|
| 136 |
+
A safe value can be determined by looking for the numerically smallest
|
| 137 |
+
file name in the directory <code class="filename">pg_xact</code> under the data directory
|
| 138 |
+
and then multiplying by 1048576 (0x100000). Note that the file names are in
|
| 139 |
+
hexadecimal. It is usually easiest to specify the option value in
|
| 140 |
+
hexadecimal too. For example, if <code class="filename">0007</code> is the smallest entry
|
| 141 |
+
in <code class="filename">pg_xact</code>, <code class="literal">-u 0x700000</code> will work (five
|
| 142 |
+
trailing zeroes provide the proper multiplier).
|
| 143 |
+
</p></dd><dt><span class="term"><code class="option">-x <em class="replaceable"><code>xid</code></em></code><br /></span><span class="term"><code class="option">--next-transaction-id=<em class="replaceable"><code>xid</code></em></code></span></dt><dd><p>
|
| 144 |
+
Manually set the next transaction ID.
|
| 145 |
+
</p><p>
|
| 146 |
+
A safe value can be determined by looking for the numerically largest
|
| 147 |
+
file name in the directory <code class="filename">pg_xact</code> under the data directory,
|
| 148 |
+
adding one,
|
| 149 |
+
and then multiplying by 1048576 (0x100000). Note that the file names are in
|
| 150 |
+
hexadecimal. It is usually easiest to specify the option value in
|
| 151 |
+
hexadecimal too. For example, if <code class="filename">0011</code> is the largest entry
|
| 152 |
+
in <code class="filename">pg_xact</code>, <code class="literal">-x 0x1200000</code> will work (five
|
| 153 |
+
trailing zeroes provide the proper multiplier).
|
| 154 |
+
</p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.8.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 155 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 156 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 157 |
+
<code class="literal">never</code>.
|
| 158 |
+
</p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.8.8"><h2>Notes</h2><p>
|
| 159 |
+
This command must not be used when the server is
|
| 160 |
+
running. <code class="command">pg_resetwal</code> will refuse to start up if
|
| 161 |
+
it finds a server lock file in the data directory. If the
|
| 162 |
+
server crashed then a lock file might have been left
|
| 163 |
+
behind; in that case you can remove the lock file to allow
|
| 164 |
+
<code class="command">pg_resetwal</code> to run. But before you do
|
| 165 |
+
so, make doubly certain that there is no server process still alive.
|
| 166 |
+
</p><p>
|
| 167 |
+
<code class="command">pg_resetwal</code> works only with servers of the same
|
| 168 |
+
major version.
|
| 169 |
+
</p></div><div class="refsect1" id="id-1.9.5.8.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pgcontroldata.html" title="pg_controldata"><span class="refentrytitle"><span class="application">pg_controldata</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pg-ctl.html" title="pg_ctl">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgrewind.html" title="pg_rewind">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_ctl</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_rewind</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgresetxlog.html
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>O.4. pg_resetxlog renamed to pg_resetwal</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="pgxlogdump.html" title="O.3. pg_xlogdump renamed to pg_waldump" /><link rel="next" href="app-pgreceivexlog.html" title="O.5. pg_receivexlog renamed to pg_receivewal" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">O.4. <code class="command">pg_resetxlog</code> renamed to <code class="command">pg_resetwal</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgxlogdump.html" title="O.3. pg_xlogdump renamed to pg_waldump">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="appendix-obsolete.html" title="Appendix O. Obsolete or Renamed Features">Up</a></td><th width="60%" align="center">Appendix O. Obsolete or Renamed Features</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgreceivexlog.html" title="O.5. pg_receivexlog renamed to pg_receivewal">Next</a></td></tr></table><hr /></div><div class="sect1" id="APP-PGRESETXLOG"><div class="titlepage"><div><div><h2 class="title" style="clear: both">O.4. <code class="command">pg_resetxlog</code> renamed to <code class="command">pg_resetwal</code> <a href="#APP-PGRESETXLOG" class="id_link">#</a></h2></div></div></div><a id="id-1.11.16.6.2" class="indexterm"></a><p>
|
| 3 |
+
PostgreSQL 9.6 and below provided a command named
|
| 4 |
+
<code class="command">pg_resetxlog</code>
|
| 5 |
+
<a id="id-1.11.16.6.3.2" class="indexterm"></a>
|
| 6 |
+
to reset the write-ahead-log (WAL) files. This command was renamed to <code class="command">pg_resetwal</code>, see
|
| 7 |
+
<a class="xref" href="app-pgresetwal.html" title="pg_resetwal"><span class="refentrytitle"><span class="application">pg_resetwal</span></span></a> for documentation of <code class="command">pg_resetwal</code> and see
|
| 8 |
+
<a class="link" href="release-prior.html" title="E.5. Prior Releases">the release notes for PostgreSQL 10</a> for details
|
| 9 |
+
on this change.
|
| 10 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgxlogdump.html" title="O.3. pg_xlogdump renamed to pg_waldump">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix-obsolete.html" title="Appendix O. Obsolete or Renamed Features">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgreceivexlog.html" title="O.5. pg_receivexlog renamed to pg_receivewal">Next</a></td></tr><tr><td width="40%" align="left" valign="top">O.3. <code class="command">pg_xlogdump</code> renamed to <code class="command">pg_waldump</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> O.5. <code class="command">pg_receivexlog</code> renamed to <code class="command">pg_receivewal</code></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgrestore.html
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_restore</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgrecvlogical.html" title="pg_recvlogical" /><link rel="next" href="app-pgverifybackup.html" title="pg_verifybackup" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_restore</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgrecvlogical.html" title="pg_recvlogical">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgverifybackup.html" title="pg_verifybackup">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGRESTORE"><div class="titlepage"></div><a id="id-1.9.4.18.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_restore</span></span></h2><p>pg_restore —
|
| 3 |
+
restore a <span class="productname">PostgreSQL</span> database from an
|
| 4 |
+
archive file created by <span class="application">pg_dump</span>
|
| 5 |
+
</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.18.4.1"><code class="command">pg_restore</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>filename</code></em>]</p></div></div><div class="refsect1" id="APP-PGRESTORE-DESCRIPTION"><h2>Description</h2><p>
|
| 6 |
+
<span class="application">pg_restore</span> is a utility for restoring a
|
| 7 |
+
<span class="productname">PostgreSQL</span> database from an archive
|
| 8 |
+
created by <a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a> in one of the non-plain-text
|
| 9 |
+
formats. It will issue the commands necessary to reconstruct the
|
| 10 |
+
database to the state it was in at the time it was saved. The
|
| 11 |
+
archive files also allow <span class="application">pg_restore</span> to
|
| 12 |
+
be selective about what is restored, or even to reorder the items
|
| 13 |
+
prior to being restored. The archive files are designed to be
|
| 14 |
+
portable across architectures.
|
| 15 |
+
</p><p>
|
| 16 |
+
<span class="application">pg_restore</span> can operate in two modes.
|
| 17 |
+
If a database name is specified, <span class="application">pg_restore</span>
|
| 18 |
+
connects to that database and restores archive contents directly into
|
| 19 |
+
the database. Otherwise, a script containing the SQL
|
| 20 |
+
commands necessary to rebuild the database is created and written
|
| 21 |
+
to a file or standard output. This script output is equivalent to
|
| 22 |
+
the plain text output format of <span class="application">pg_dump</span>.
|
| 23 |
+
Some of the options controlling the output are therefore analogous to
|
| 24 |
+
<span class="application">pg_dump</span> options.
|
| 25 |
+
</p><p>
|
| 26 |
+
Obviously, <span class="application">pg_restore</span> cannot restore information
|
| 27 |
+
that is not present in the archive file. For instance, if the
|
| 28 |
+
archive was made using the <span class="quote">“<span class="quote">dump data as
|
| 29 |
+
<code class="command">INSERT</code> commands</span>”</span> option,
|
| 30 |
+
<span class="application">pg_restore</span> will not be able to load the data
|
| 31 |
+
using <code class="command">COPY</code> statements.
|
| 32 |
+
</p></div><div class="refsect1" id="APP-PGRESTORE-OPTIONS"><h2>Options</h2><p>
|
| 33 |
+
<span class="application">pg_restore</span> accepts the following command
|
| 34 |
+
line arguments.
|
| 35 |
+
|
| 36 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>filename</code></em></span></dt><dd><p>
|
| 37 |
+
Specifies the location of the archive file (or directory, for a
|
| 38 |
+
directory-format archive) to be restored.
|
| 39 |
+
If not specified, the standard input is used.
|
| 40 |
+
</p></dd><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--data-only</code></span></dt><dd><p>
|
| 41 |
+
Restore only the data, not the schema (data definitions).
|
| 42 |
+
Table data, large objects, and sequence values are restored,
|
| 43 |
+
if present in the archive.
|
| 44 |
+
</p><p>
|
| 45 |
+
This option is similar to, but for historical reasons not identical
|
| 46 |
+
to, specifying <code class="option">--section=data</code>.
|
| 47 |
+
</p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--clean</code></span></dt><dd><p>
|
| 48 |
+
Before restoring database objects, issue commands
|
| 49 |
+
to <code class="command">DROP</code> all the objects that will be restored.
|
| 50 |
+
This option is useful for overwriting an existing database.
|
| 51 |
+
If any of the objects do not exist in the destination database,
|
| 52 |
+
ignorable error messages will be reported,
|
| 53 |
+
unless <code class="option">--if-exists</code> is also specified.
|
| 54 |
+
</p></dd><dt><span class="term"><code class="option">-C</code><br /></span><span class="term"><code class="option">--create</code></span></dt><dd><p>
|
| 55 |
+
Create the database before restoring into it.
|
| 56 |
+
If <code class="option">--clean</code> is also specified, drop and
|
| 57 |
+
recreate the target database before connecting to it.
|
| 58 |
+
</p><p>
|
| 59 |
+
With <code class="option">--create</code>, <span class="application">pg_restore</span>
|
| 60 |
+
also restores the database's comment if any, and any configuration
|
| 61 |
+
variable settings that are specific to this database, that is,
|
| 62 |
+
any <code class="command">ALTER DATABASE ... SET ...</code>
|
| 63 |
+
and <code class="command">ALTER ROLE ... IN DATABASE ... SET ...</code>
|
| 64 |
+
commands that mention this database.
|
| 65 |
+
Access privileges for the database itself are also restored,
|
| 66 |
+
unless <code class="option">--no-acl</code> is specified.
|
| 67 |
+
</p><p>
|
| 68 |
+
When this option is used, the database named with <code class="option">-d</code>
|
| 69 |
+
is used only to issue the initial <code class="command">DROP DATABASE</code> and
|
| 70 |
+
<code class="command">CREATE DATABASE</code> commands. All data is restored into the
|
| 71 |
+
database name that appears in the archive.
|
| 72 |
+
</p></dd><dt><span class="term"><code class="option">-d <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 73 |
+
Connect to database <em class="replaceable"><code>dbname</code></em> and restore directly
|
| 74 |
+
into the database. The <em class="replaceable"><code>dbname</code></em> can
|
| 75 |
+
be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>.
|
| 76 |
+
If so, connection string parameters will override any conflicting
|
| 77 |
+
command line options.
|
| 78 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--exit-on-error</code></span></dt><dd><p>
|
| 79 |
+
Exit if an error is encountered while sending SQL commands to
|
| 80 |
+
the database. The default is to continue and to display a count of
|
| 81 |
+
errors at the end of the restoration.
|
| 82 |
+
</p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>filename</code></em></code><br /></span><span class="term"><code class="option">--file=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
|
| 83 |
+
Specify output file for generated script, or for the listing
|
| 84 |
+
when used with <code class="option">-l</code>. Use <code class="literal">-</code>
|
| 85 |
+
for <span class="systemitem">stdout</span>.
|
| 86 |
+
</p></dd><dt><span class="term"><code class="option">-F <em class="replaceable"><code>format</code></em></code><br /></span><span class="term"><code class="option">--format=<em class="replaceable"><code>format</code></em></code></span></dt><dd><p>
|
| 87 |
+
Specify format of the archive. It is not necessary to specify
|
| 88 |
+
the format, since <span class="application">pg_restore</span> will
|
| 89 |
+
determine the format automatically. If specified, it can be
|
| 90 |
+
one of the following:
|
| 91 |
+
|
| 92 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">c</code><br /></span><span class="term"><code class="literal">custom</code></span></dt><dd><p>
|
| 93 |
+
The archive is in the custom format of
|
| 94 |
+
<span class="application">pg_dump</span>.
|
| 95 |
+
</p></dd><dt><span class="term"><code class="literal">d</code><br /></span><span class="term"><code class="literal">directory</code></span></dt><dd><p>
|
| 96 |
+
The archive is a directory archive.
|
| 97 |
+
</p></dd><dt><span class="term"><code class="literal">t</code><br /></span><span class="term"><code class="literal">tar</code></span></dt><dd><p>
|
| 98 |
+
The archive is a <code class="command">tar</code> archive.
|
| 99 |
+
</p></dd></dl></div></dd><dt><span class="term"><code class="option">-I <em class="replaceable"><code>index</code></em></code><br /></span><span class="term"><code class="option">--index=<em class="replaceable"><code>index</code></em></code></span></dt><dd><p>
|
| 100 |
+
Restore definition of named index only. Multiple indexes
|
| 101 |
+
may be specified with multiple <code class="option">-I</code> switches.
|
| 102 |
+
</p></dd><dt><span class="term"><code class="option">-j <em class="replaceable"><code>number-of-jobs</code></em></code><br /></span><span class="term"><code class="option">--jobs=<em class="replaceable"><code>number-of-jobs</code></em></code></span></dt><dd><p>
|
| 103 |
+
Run the most time-consuming steps
|
| 104 |
+
of <span class="application">pg_restore</span> — those that load data,
|
| 105 |
+
create indexes, or create constraints — concurrently, using up
|
| 106 |
+
to <em class="replaceable"><code>number-of-jobs</code></em>
|
| 107 |
+
concurrent sessions. This option can dramatically reduce the time
|
| 108 |
+
to restore a large database to a server running on a
|
| 109 |
+
multiprocessor machine. This option is ignored when emitting a script
|
| 110 |
+
rather than connecting directly to a database server.
|
| 111 |
+
</p><p>
|
| 112 |
+
Each job is one process or one thread, depending on the
|
| 113 |
+
operating system, and uses a separate connection to the
|
| 114 |
+
server.
|
| 115 |
+
</p><p>
|
| 116 |
+
The optimal value for this option depends on the hardware
|
| 117 |
+
setup of the server, of the client, and of the network.
|
| 118 |
+
Factors include the number of CPU cores and the disk setup. A
|
| 119 |
+
good place to start is the number of CPU cores on the server,
|
| 120 |
+
but values larger than that can also lead to faster restore
|
| 121 |
+
times in many cases. Of course, values that are too high will
|
| 122 |
+
lead to decreased performance because of thrashing.
|
| 123 |
+
</p><p>
|
| 124 |
+
Only the custom and directory archive formats are supported
|
| 125 |
+
with this option.
|
| 126 |
+
The input must be a regular file or directory (not, for example, a
|
| 127 |
+
pipe or standard input). Also, multiple
|
| 128 |
+
jobs cannot be used together with the
|
| 129 |
+
option <code class="option">--single-transaction</code>.
|
| 130 |
+
</p></dd><dt><span class="term"><code class="option">-l</code><br /></span><span class="term"><code class="option">--list</code></span></dt><dd><p>
|
| 131 |
+
List the table of contents of the archive. The output of this operation
|
| 132 |
+
can be used as input to the <code class="option">-L</code> option. Note that
|
| 133 |
+
if filtering switches such as <code class="option">-n</code> or <code class="option">-t</code> are
|
| 134 |
+
used with <code class="option">-l</code>, they will restrict the items listed.
|
| 135 |
+
</p></dd><dt><span class="term"><code class="option">-L <em class="replaceable"><code>list-file</code></em></code><br /></span><span class="term"><code class="option">--use-list=<em class="replaceable"><code>list-file</code></em></code></span></dt><dd><p>
|
| 136 |
+
Restore only those archive elements that are listed in <em class="replaceable"><code>list-file</code></em>, and restore them in the
|
| 137 |
+
order they appear in the file. Note that
|
| 138 |
+
if filtering switches such as <code class="option">-n</code> or <code class="option">-t</code> are
|
| 139 |
+
used with <code class="option">-L</code>, they will further restrict the items restored.
|
| 140 |
+
</p><p><em class="replaceable"><code>list-file</code></em> is normally created by
|
| 141 |
+
editing the output of a previous <code class="option">-l</code> operation.
|
| 142 |
+
Lines can be moved or removed, and can also
|
| 143 |
+
be commented out by placing a semicolon (<code class="literal">;</code>) at the
|
| 144 |
+
start of the line. See below for examples.
|
| 145 |
+
</p></dd><dt><span class="term"><code class="option">-n <em class="replaceable"><code>schema</code></em></code><br /></span><span class="term"><code class="option">--schema=<em class="replaceable"><code>schema</code></em></code></span></dt><dd><p>
|
| 146 |
+
Restore only objects that are in the named schema. Multiple schemas
|
| 147 |
+
may be specified with multiple <code class="option">-n</code> switches. This can be
|
| 148 |
+
combined with the <code class="option">-t</code> option to restore just a
|
| 149 |
+
specific table.
|
| 150 |
+
</p></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>schema</code></em></code><br /></span><span class="term"><code class="option">--exclude-schema=<em class="replaceable"><code>schema</code></em></code></span></dt><dd><p>
|
| 151 |
+
Do not restore objects that are in the named schema. Multiple schemas
|
| 152 |
+
to be excluded may be specified with multiple <code class="option">-N</code> switches.
|
| 153 |
+
</p><p>
|
| 154 |
+
When both <code class="option">-n</code> and <code class="option">-N</code> are given for the same
|
| 155 |
+
schema name, the <code class="option">-N</code> switch wins and the schema is excluded.
|
| 156 |
+
</p></dd><dt><span class="term"><code class="option">-O</code><br /></span><span class="term"><code class="option">--no-owner</code></span></dt><dd><p>
|
| 157 |
+
Do not output commands to set
|
| 158 |
+
ownership of objects to match the original database.
|
| 159 |
+
By default, <span class="application">pg_restore</span> issues
|
| 160 |
+
<code class="command">ALTER OWNER</code> or
|
| 161 |
+
<code class="command">SET SESSION AUTHORIZATION</code>
|
| 162 |
+
statements to set ownership of created schema elements.
|
| 163 |
+
These statements will fail unless the initial connection to the
|
| 164 |
+
database is made by a superuser
|
| 165 |
+
(or the same user that owns all of the objects in the script).
|
| 166 |
+
With <code class="option">-O</code>, any user name can be used for the
|
| 167 |
+
initial connection, and this user will own all the created objects.
|
| 168 |
+
</p></dd><dt><span class="term"><code class="option">-P <em class="replaceable"><code>function-name(argtype [, ...])</code></em></code><br /></span><span class="term"><code class="option">--function=<em class="replaceable"><code>function-name(argtype [, ...])</code></em></code></span></dt><dd><p>
|
| 169 |
+
Restore the named function only. Be careful to spell the function
|
| 170 |
+
name and arguments exactly as they appear in the dump file's table
|
| 171 |
+
of contents. Multiple functions may be specified with multiple
|
| 172 |
+
<code class="option">-P</code> switches.
|
| 173 |
+
</p></dd><dt><span class="term"><code class="option">-R</code><br /></span><span class="term"><code class="option">--no-reconnect</code></span></dt><dd><p>
|
| 174 |
+
This option is obsolete but still accepted for backwards
|
| 175 |
+
compatibility.
|
| 176 |
+
</p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--schema-only</code></span></dt><dd><p>
|
| 177 |
+
Restore only the schema (data definitions), not data,
|
| 178 |
+
to the extent that schema entries are present in the archive.
|
| 179 |
+
</p><p>
|
| 180 |
+
This option is the inverse of <code class="option">--data-only</code>.
|
| 181 |
+
It is similar to, but for historical reasons not identical to,
|
| 182 |
+
specifying
|
| 183 |
+
<code class="option">--section=pre-data --section=post-data</code>.
|
| 184 |
+
</p><p>
|
| 185 |
+
(Do not confuse this with the <code class="option">--schema</code> option, which
|
| 186 |
+
uses the word <span class="quote">“<span class="quote">schema</span>”</span> in a different meaning.)
|
| 187 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--superuser=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 188 |
+
Specify the superuser user name to use when disabling triggers.
|
| 189 |
+
This is relevant only if <code class="option">--disable-triggers</code> is used.
|
| 190 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>table</code></em></code><br /></span><span class="term"><code class="option">--table=<em class="replaceable"><code>table</code></em></code></span></dt><dd><p>
|
| 191 |
+
Restore definition and/or data of only the named table.
|
| 192 |
+
For this purpose, <span class="quote">“<span class="quote">table</span>”</span> includes views, materialized views,
|
| 193 |
+
sequences, and foreign tables. Multiple tables
|
| 194 |
+
can be selected by writing multiple <code class="option">-t</code> switches.
|
| 195 |
+
This option can be combined with the <code class="option">-n</code> option to
|
| 196 |
+
specify table(s) in a particular schema.
|
| 197 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 198 |
+
When <code class="option">-t</code> is specified, <span class="application">pg_restore</span>
|
| 199 |
+
makes no attempt to restore any other database objects that the
|
| 200 |
+
selected table(s) might depend upon. Therefore, there is no
|
| 201 |
+
guarantee that a specific-table restore into a clean database will
|
| 202 |
+
succeed.
|
| 203 |
+
</p></div><div class="note"><h3 class="title">Note</h3><p>
|
| 204 |
+
This flag does not behave identically to the <code class="option">-t</code>
|
| 205 |
+
flag of <span class="application">pg_dump</span>. There is not currently
|
| 206 |
+
any provision for wild-card matching in <span class="application">pg_restore</span>,
|
| 207 |
+
nor can you include a schema name within its <code class="option">-t</code>.
|
| 208 |
+
And, while <span class="application">pg_dump</span>'s <code class="option">-t</code>
|
| 209 |
+
flag will also dump subsidiary objects (such as indexes) of the
|
| 210 |
+
selected table(s),
|
| 211 |
+
<span class="application">pg_restore</span>'s <code class="option">-t</code>
|
| 212 |
+
flag does not include such subsidiary objects.
|
| 213 |
+
</p></div><div class="note"><h3 class="title">Note</h3><p>
|
| 214 |
+
In versions prior to <span class="productname">PostgreSQL</span> 9.6, this flag
|
| 215 |
+
matched only tables, not any other type of relation.
|
| 216 |
+
</p></div></dd><dt><span class="term"><code class="option">-T <em class="replaceable"><code>trigger</code></em></code><br /></span><span class="term"><code class="option">--trigger=<em class="replaceable"><code>trigger</code></em></code></span></dt><dd><p>
|
| 217 |
+
Restore named trigger only. Multiple triggers may be specified with
|
| 218 |
+
multiple <code class="option">-T</code> switches.
|
| 219 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 220 |
+
Specifies verbose mode. This will cause
|
| 221 |
+
<span class="application">pg_restore</span> to output detailed object
|
| 222 |
+
comments and start/stop times to the output file, and progress
|
| 223 |
+
messages to standard error.
|
| 224 |
+
Repeating the option causes additional debug-level messages
|
| 225 |
+
to appear on standard error.
|
| 226 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 227 |
+
Print the <span class="application">pg_restore</span> version and exit.
|
| 228 |
+
</p></dd><dt><span class="term"><code class="option">-x</code><br /></span><span class="term"><code class="option">--no-privileges</code><br /></span><span class="term"><code class="option">--no-acl</code></span></dt><dd><p>
|
| 229 |
+
Prevent restoration of access privileges (grant/revoke commands).
|
| 230 |
+
</p></dd><dt><span class="term"><code class="option">-1</code><br /></span><span class="term"><code class="option">--single-transaction</code></span></dt><dd><p>
|
| 231 |
+
Execute the restore as a single transaction (that is, wrap the
|
| 232 |
+
emitted commands in <code class="command">BEGIN</code>/<code class="command">COMMIT</code>). This
|
| 233 |
+
ensures that either all the commands complete successfully, or no
|
| 234 |
+
changes are applied. This option implies
|
| 235 |
+
<code class="option">--exit-on-error</code>.
|
| 236 |
+
</p></dd><dt><span class="term"><code class="option">--disable-triggers</code></span></dt><dd><p>
|
| 237 |
+
This option is relevant only when performing a data-only restore.
|
| 238 |
+
It instructs <span class="application">pg_restore</span> to execute commands
|
| 239 |
+
to temporarily disable triggers on the target tables while
|
| 240 |
+
the data is restored. Use this if you have referential
|
| 241 |
+
integrity checks or other triggers on the tables that you
|
| 242 |
+
do not want to invoke during data restore.
|
| 243 |
+
</p><p>
|
| 244 |
+
Presently, the commands emitted for
|
| 245 |
+
<code class="option">--disable-triggers</code> must be done as superuser. So you
|
| 246 |
+
should also specify a superuser name with <code class="option">-S</code> or,
|
| 247 |
+
preferably, run <span class="application">pg_restore</span> as a
|
| 248 |
+
<span class="productname">PostgreSQL</span> superuser.
|
| 249 |
+
</p></dd><dt><span class="term"><code class="option">--enable-row-security</code></span></dt><dd><p>
|
| 250 |
+
This option is relevant only when restoring the contents of a table
|
| 251 |
+
which has row security. By default, <span class="application">pg_restore</span> will set
|
| 252 |
+
<a class="xref" href="runtime-config-client.html#GUC-ROW-SECURITY">row_security</a> to off, to ensure
|
| 253 |
+
that all data is restored in to the table. If the user does not have
|
| 254 |
+
sufficient privileges to bypass row security, then an error is thrown.
|
| 255 |
+
This parameter instructs <span class="application">pg_restore</span> to set
|
| 256 |
+
<a class="xref" href="runtime-config-client.html#GUC-ROW-SECURITY">row_security</a> to on instead, allowing the user to attempt to restore
|
| 257 |
+
the contents of the table with row security enabled. This might still
|
| 258 |
+
fail if the user does not have the right to insert the rows from the
|
| 259 |
+
dump into the table.
|
| 260 |
+
</p><p>
|
| 261 |
+
Note that this option currently also requires the dump be in <code class="command">INSERT</code>
|
| 262 |
+
format, as <code class="command">COPY FROM</code> does not support row security.
|
| 263 |
+
</p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>
|
| 264 |
+
Use <code class="literal">DROP ... IF EXISTS</code> commands to drop objects
|
| 265 |
+
in <code class="option">--clean</code> mode. This suppresses <span class="quote">“<span class="quote">does not
|
| 266 |
+
exist</span>”</span> errors that might otherwise be reported. This
|
| 267 |
+
option is not valid unless <code class="option">--clean</code> is also
|
| 268 |
+
specified.
|
| 269 |
+
</p></dd><dt><span class="term"><code class="option">--no-comments</code></span></dt><dd><p>
|
| 270 |
+
Do not output commands to restore comments, even if the archive
|
| 271 |
+
contains them.
|
| 272 |
+
</p></dd><dt><span class="term"><code class="option">--no-data-for-failed-tables</code></span></dt><dd><p>
|
| 273 |
+
By default, table data is restored even if the creation command
|
| 274 |
+
for the table failed (e.g., because it already exists).
|
| 275 |
+
With this option, data for such a table is skipped.
|
| 276 |
+
This behavior is useful if the target database already
|
| 277 |
+
contains the desired table contents. For example,
|
| 278 |
+
auxiliary tables for <span class="productname">PostgreSQL</span> extensions
|
| 279 |
+
such as <span class="productname">PostGIS</span> might already be loaded in
|
| 280 |
+
the target database; specifying this option prevents duplicate
|
| 281 |
+
or obsolete data from being loaded into them.
|
| 282 |
+
</p><p>
|
| 283 |
+
This option is effective only when restoring directly into a
|
| 284 |
+
database, not when producing SQL script output.
|
| 285 |
+
</p></dd><dt><span class="term"><code class="option">--no-publications</code></span></dt><dd><p>
|
| 286 |
+
Do not output commands to restore publications, even if the archive
|
| 287 |
+
contains them.
|
| 288 |
+
</p></dd><dt><span class="term"><code class="option">--no-security-labels</code></span></dt><dd><p>
|
| 289 |
+
Do not output commands to restore security labels,
|
| 290 |
+
even if the archive contains them.
|
| 291 |
+
</p></dd><dt><span class="term"><code class="option">--no-subscriptions</code></span></dt><dd><p>
|
| 292 |
+
Do not output commands to restore subscriptions, even if the archive
|
| 293 |
+
contains them.
|
| 294 |
+
</p></dd><dt><span class="term"><code class="option">--no-table-access-method</code></span></dt><dd><p>
|
| 295 |
+
Do not output commands to select table access methods.
|
| 296 |
+
With this option, all objects will be created with whichever
|
| 297 |
+
access method is the default during restore.
|
| 298 |
+
</p></dd><dt><span class="term"><code class="option">--no-tablespaces</code></span></dt><dd><p>
|
| 299 |
+
Do not output commands to select tablespaces.
|
| 300 |
+
With this option, all objects will be created in whichever
|
| 301 |
+
tablespace is the default during restore.
|
| 302 |
+
</p></dd><dt><span class="term"><code class="option">--section=<em class="replaceable"><code>sectionname</code></em></code></span></dt><dd><p>
|
| 303 |
+
Only restore the named section. The section name can be
|
| 304 |
+
<code class="option">pre-data</code>, <code class="option">data</code>, or <code class="option">post-data</code>.
|
| 305 |
+
This option can be specified more than once to select multiple
|
| 306 |
+
sections. The default is to restore all sections.
|
| 307 |
+
</p><p>
|
| 308 |
+
The data section contains actual table data as well as large-object
|
| 309 |
+
definitions.
|
| 310 |
+
Post-data items consist of definitions of indexes, triggers, rules
|
| 311 |
+
and constraints other than validated check constraints.
|
| 312 |
+
Pre-data items consist of all other data definition items.
|
| 313 |
+
</p></dd><dt><span class="term"><code class="option">--strict-names</code></span></dt><dd><p>
|
| 314 |
+
Require that each schema
|
| 315 |
+
(<code class="option">-n</code>/<code class="option">--schema</code>) and table
|
| 316 |
+
(<code class="option">-t</code>/<code class="option">--table</code>) qualifier match at
|
| 317 |
+
least one schema/table in the backup file.
|
| 318 |
+
</p></dd><dt><span class="term"><code class="option">--use-set-session-authorization</code></span></dt><dd><p>
|
| 319 |
+
Output SQL-standard <code class="command">SET SESSION AUTHORIZATION</code> commands
|
| 320 |
+
instead of <code class="command">ALTER OWNER</code> commands to determine object
|
| 321 |
+
ownership. This makes the dump more standards-compatible, but
|
| 322 |
+
depending on the history of the objects in the dump, might not restore
|
| 323 |
+
properly.
|
| 324 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 325 |
+
Show help about <span class="application">pg_restore</span> command line
|
| 326 |
+
arguments, and exit.
|
| 327 |
+
</p></dd></dl></div><p>
|
| 328 |
+
</p><p>
|
| 329 |
+
<span class="application">pg_restore</span> also accepts
|
| 330 |
+
the following command line arguments for connection parameters:
|
| 331 |
+
|
| 332 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 333 |
+
Specifies the host name of the machine on which the server is
|
| 334 |
+
running. If the value begins with a slash, it is used as the
|
| 335 |
+
directory for the Unix domain socket. The default is taken
|
| 336 |
+
from the <code class="envar">PGHOST</code> environment variable, if set,
|
| 337 |
+
else a Unix domain socket connection is attempted.
|
| 338 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 339 |
+
Specifies the TCP port or local Unix domain socket file
|
| 340 |
+
extension on which the server is listening for connections.
|
| 341 |
+
Defaults to the <code class="envar">PGPORT</code> environment variable, if
|
| 342 |
+
set, or a compiled-in default.
|
| 343 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 344 |
+
User name to connect as.
|
| 345 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 346 |
+
Never issue a password prompt. If the server requires
|
| 347 |
+
password authentication and a password is not available by
|
| 348 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 349 |
+
connection attempt will fail. This option can be useful in
|
| 350 |
+
batch jobs and scripts where no user is present to enter a
|
| 351 |
+
password.
|
| 352 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 353 |
+
Force <span class="application">pg_restore</span> to prompt for a
|
| 354 |
+
password before connecting to a database.
|
| 355 |
+
</p><p>
|
| 356 |
+
This option is never essential, since
|
| 357 |
+
<span class="application">pg_restore</span> will automatically prompt
|
| 358 |
+
for a password if the server demands password authentication.
|
| 359 |
+
However, <span class="application">pg_restore</span> will waste a
|
| 360 |
+
connection attempt finding out that the server wants a password.
|
| 361 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 362 |
+
connection attempt.
|
| 363 |
+
</p></dd><dt><span class="term"><code class="option">--role=<em class="replaceable"><code>rolename</code></em></code></span></dt><dd><p>
|
| 364 |
+
Specifies a role name to be used to perform the restore.
|
| 365 |
+
This option causes <span class="application">pg_restore</span> to issue a
|
| 366 |
+
<code class="command">SET ROLE</code> <em class="replaceable"><code>rolename</code></em>
|
| 367 |
+
command after connecting to the database. It is useful when the
|
| 368 |
+
authenticated user (specified by <code class="option">-U</code>) lacks privileges
|
| 369 |
+
needed by <span class="application">pg_restore</span>, but can switch to a role with
|
| 370 |
+
the required rights. Some installations have a policy against
|
| 371 |
+
logging in directly as a superuser, and use of this option allows
|
| 372 |
+
restores to be performed without violating the policy.
|
| 373 |
+
</p></dd></dl></div><p>
|
| 374 |
+
</p></div><div class="refsect1" id="id-1.9.4.18.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGOPTIONS</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 375 |
+
Default connection parameters
|
| 376 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 377 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 378 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 379 |
+
<code class="literal">never</code>.
|
| 380 |
+
</p></dd></dl></div><p>
|
| 381 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 382 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 383 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>). However, it does not read
|
| 384 |
+
<code class="envar">PGDATABASE</code> when a database name is not supplied.
|
| 385 |
+
</p></div><div class="refsect1" id="APP-PGRESTORE-DIAGNOSTICS"><h2>Diagnostics</h2><p>
|
| 386 |
+
When a direct database connection is specified using the
|
| 387 |
+
<code class="option">-d</code> option, <span class="application">pg_restore</span>
|
| 388 |
+
internally executes <acronym class="acronym">SQL</acronym> statements. If you have
|
| 389 |
+
problems running <span class="application">pg_restore</span>, make sure
|
| 390 |
+
you are able to select information from the database using, for
|
| 391 |
+
example, <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a>. Also, any default connection
|
| 392 |
+
settings and environment variables used by the
|
| 393 |
+
<span class="application">libpq</span> front-end library will apply.
|
| 394 |
+
</p></div><div class="refsect1" id="APP-PGRESTORE-NOTES"><h2>Notes</h2><p>
|
| 395 |
+
If your installation has any local additions to the
|
| 396 |
+
<code class="literal">template1</code> database, be careful to load the output of
|
| 397 |
+
<span class="application">pg_restore</span> into a truly empty database;
|
| 398 |
+
otherwise you are likely to get errors due to duplicate definitions
|
| 399 |
+
of the added objects. To make an empty database without any local
|
| 400 |
+
additions, copy from <code class="literal">template0</code> not <code class="literal">template1</code>, for example:
|
| 401 |
+
</p><pre class="programlisting">
|
| 402 |
+
CREATE DATABASE foo WITH TEMPLATE template0;
|
| 403 |
+
</pre><p>
|
| 404 |
+
</p><p>
|
| 405 |
+
The limitations of <span class="application">pg_restore</span> are detailed below.
|
| 406 |
+
|
| 407 |
+
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
| 408 |
+
When restoring data to a pre-existing table and the option
|
| 409 |
+
<code class="option">--disable-triggers</code> is used,
|
| 410 |
+
<span class="application">pg_restore</span> emits commands
|
| 411 |
+
to disable triggers on user tables before inserting the data, then emits commands to
|
| 412 |
+
re-enable them after the data has been inserted. If the restore is stopped in the
|
| 413 |
+
middle, the system catalogs might be left in the wrong state.
|
| 414 |
+
</p></li><li class="listitem"><p><span class="application">pg_restore</span> cannot restore large objects
|
| 415 |
+
selectively; for instance, only those for a specific table. If
|
| 416 |
+
an archive contains large objects, then all large objects will be
|
| 417 |
+
restored, or none of them if they are excluded via <code class="option">-L</code>,
|
| 418 |
+
<code class="option">-t</code>, or other options.
|
| 419 |
+
</p></li></ul></div><p>
|
| 420 |
+
</p><p>
|
| 421 |
+
See also the <a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a> documentation for details on
|
| 422 |
+
limitations of <span class="application">pg_dump</span>.
|
| 423 |
+
</p><p>
|
| 424 |
+
Once restored, it is wise to run <code class="command">ANALYZE</code> on each
|
| 425 |
+
restored table so the optimizer has useful statistics; see
|
| 426 |
+
<a class="xref" href="routine-vacuuming.html#VACUUM-FOR-STATISTICS" title="25.1.3. Updating Planner Statistics">Section 25.1.3</a> and
|
| 427 |
+
<a class="xref" href="routine-vacuuming.html#AUTOVACUUM" title="25.1.6. The Autovacuum Daemon">Section 25.1.6</a> for more information.
|
| 428 |
+
</p></div><div class="refsect1" id="APP-PGRESTORE-EXAMPLES"><h2>Examples</h2><p>
|
| 429 |
+
Assume we have dumped a database called <code class="literal">mydb</code> into a
|
| 430 |
+
custom-format dump file:
|
| 431 |
+
|
| 432 |
+
</p><pre class="screen">
|
| 433 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -Fc mydb > db.dump</code></strong>
|
| 434 |
+
</pre><p>
|
| 435 |
+
</p><p>
|
| 436 |
+
To drop the database and recreate it from the dump:
|
| 437 |
+
|
| 438 |
+
</p><pre class="screen">
|
| 439 |
+
<code class="prompt">$</code> <strong class="userinput"><code>dropdb mydb</code></strong>
|
| 440 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_restore -C -d postgres db.dump</code></strong>
|
| 441 |
+
</pre><p>
|
| 442 |
+
|
| 443 |
+
The database named in the <code class="option">-d</code> switch can be any database existing
|
| 444 |
+
in the cluster; <span class="application">pg_restore</span> only uses it to issue the
|
| 445 |
+
<code class="command">CREATE DATABASE</code> command for <code class="literal">mydb</code>. With
|
| 446 |
+
<code class="option">-C</code>, data is always restored into the database name that appears
|
| 447 |
+
in the dump file.
|
| 448 |
+
</p><p>
|
| 449 |
+
To restore the dump into a new database called <code class="literal">newdb</code>:
|
| 450 |
+
|
| 451 |
+
</p><pre class="screen">
|
| 452 |
+
<code class="prompt">$</code> <strong class="userinput"><code>createdb -T template0 newdb</code></strong>
|
| 453 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_restore -d newdb db.dump</code></strong>
|
| 454 |
+
</pre><p>
|
| 455 |
+
|
| 456 |
+
Notice we don't use <code class="option">-C</code>, and instead connect directly to the
|
| 457 |
+
database to be restored into. Also note that we clone the new database
|
| 458 |
+
from <code class="literal">template0</code> not <code class="literal">template1</code>, to ensure it is
|
| 459 |
+
initially empty.
|
| 460 |
+
</p><p>
|
| 461 |
+
To reorder database items, it is first necessary to dump the table of
|
| 462 |
+
contents of the archive:
|
| 463 |
+
</p><pre class="screen">
|
| 464 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_restore -l db.dump > db.list</code></strong>
|
| 465 |
+
</pre><p>
|
| 466 |
+
The listing file consists of a header and one line for each item, e.g.:
|
| 467 |
+
</p><pre class="programlisting">
|
| 468 |
+
;
|
| 469 |
+
; Archive created at Mon Sep 14 13:55:39 2009
|
| 470 |
+
; dbname: DBDEMOS
|
| 471 |
+
; TOC Entries: 81
|
| 472 |
+
; Compression: 9
|
| 473 |
+
; Dump Version: 1.10-0
|
| 474 |
+
; Format: CUSTOM
|
| 475 |
+
; Integer: 4 bytes
|
| 476 |
+
; Offset: 8 bytes
|
| 477 |
+
; Dumped from database version: 8.3.5
|
| 478 |
+
; Dumped by pg_dump version: 8.3.8
|
| 479 |
+
;
|
| 480 |
+
;
|
| 481 |
+
; Selected TOC Entries:
|
| 482 |
+
;
|
| 483 |
+
3; 2615 2200 SCHEMA - public pasha
|
| 484 |
+
1861; 0 0 COMMENT - SCHEMA public pasha
|
| 485 |
+
1862; 0 0 ACL - public pasha
|
| 486 |
+
317; 1247 17715 TYPE public composite pasha
|
| 487 |
+
319; 1247 25899 DOMAIN public domain0 pasha
|
| 488 |
+
</pre><p>
|
| 489 |
+
Semicolons start a comment, and the numbers at the start of lines refer to the
|
| 490 |
+
internal archive ID assigned to each item.
|
| 491 |
+
</p><p>
|
| 492 |
+
Lines in the file can be commented out, deleted, and reordered. For example:
|
| 493 |
+
</p><pre class="programlisting">
|
| 494 |
+
10; 145433 TABLE map_resolutions postgres
|
| 495 |
+
;2; 145344 TABLE species postgres
|
| 496 |
+
;4; 145359 TABLE nt_header postgres
|
| 497 |
+
6; 145402 TABLE species_records postgres
|
| 498 |
+
;8; 145416 TABLE ss_old postgres
|
| 499 |
+
</pre><p>
|
| 500 |
+
could be used as input to <span class="application">pg_restore</span> and would only restore
|
| 501 |
+
items 10 and 6, in that order:
|
| 502 |
+
</p><pre class="screen">
|
| 503 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_restore -L db.list db.dump</code></strong>
|
| 504 |
+
</pre></div><div class="refsect1" id="id-1.9.4.18.11"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a>, <a class="xref" href="app-pg-dumpall.html" title="pg_dumpall"><span class="refentrytitle"><span class="application">pg_dumpall</span></span></a>, <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgrecvlogical.html" title="pg_recvlogical">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgverifybackup.html" title="pg_verifybackup">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_recvlogical</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_verifybackup</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgrewind.html
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_rewind</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgresetwal.html" title="pg_resetwal" /><link rel="next" href="pgtestfsync.html" title="pg_test_fsync" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_rewind</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgresetwal.html" title="pg_resetwal">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="pgtestfsync.html" title="pg_test_fsync">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGREWIND"><div class="titlepage"></div><a id="id-1.9.5.9.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_rewind</span></span></h2><p>pg_rewind — synchronize a <span class="productname">PostgreSQL</span> data directory with another data directory that was forked from it</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.9.4.1"><code class="command">pg_rewind</code> [<em class="replaceable"><code>option</code></em>...] { <code class="option">-D</code> | <code class="option">--target-pgdata</code> }<em class="replaceable"><code> directory</code></em> { <code class="option">--source-pgdata=<em class="replaceable"><code>directory</code></em></code> | <code class="option">--source-server=<em class="replaceable"><code>connstr</code></em></code> } </p></div></div><div class="refsect1" id="id-1.9.5.9.5"><h2>Description</h2><p>
|
| 3 |
+
<span class="application">pg_rewind</span> is a tool for synchronizing a PostgreSQL cluster
|
| 4 |
+
with another copy of the same cluster, after the clusters' timelines have
|
| 5 |
+
diverged. A typical scenario is to bring an old primary server back online
|
| 6 |
+
after failover as a standby that follows the new primary.
|
| 7 |
+
</p><p>
|
| 8 |
+
After a successful rewind, the state of the target data directory is
|
| 9 |
+
analogous to a base backup of the source data directory. Unlike taking
|
| 10 |
+
a new base backup or using a tool like <span class="application">rsync</span>,
|
| 11 |
+
<span class="application">pg_rewind</span> does not require comparing or copying
|
| 12 |
+
unchanged relation blocks in the cluster. Only changed blocks from existing
|
| 13 |
+
relation files are copied; all other files, including new relation files,
|
| 14 |
+
configuration files, and WAL segments, are copied in full. As such the
|
| 15 |
+
rewind operation is significantly faster than other approaches when the
|
| 16 |
+
database is large and only a small fraction of blocks differ between the
|
| 17 |
+
clusters.
|
| 18 |
+
</p><p>
|
| 19 |
+
<span class="application">pg_rewind</span> examines the timeline histories of the source
|
| 20 |
+
and target clusters to determine the point where they diverged, and
|
| 21 |
+
expects to find WAL in the target cluster's <code class="filename">pg_wal</code> directory
|
| 22 |
+
reaching all the way back to the point of divergence. The point of divergence
|
| 23 |
+
can be found either on the target timeline, the source timeline, or their common
|
| 24 |
+
ancestor. In the typical failover scenario where the target cluster was
|
| 25 |
+
shut down soon after the divergence, this is not a problem, but if the
|
| 26 |
+
target cluster ran for a long time after the divergence, its old WAL
|
| 27 |
+
files might no longer be present. In this case, you can manually copy them
|
| 28 |
+
from the WAL archive to the <code class="filename">pg_wal</code> directory, or run
|
| 29 |
+
<span class="application">pg_rewind</span> with the <code class="literal">-c</code> option to
|
| 30 |
+
automatically retrieve them from the WAL archive. The use of
|
| 31 |
+
<span class="application">pg_rewind</span> is not limited to failover, e.g., a standby
|
| 32 |
+
server can be promoted, run some write transactions, and then rewound
|
| 33 |
+
to become a standby again.
|
| 34 |
+
</p><p>
|
| 35 |
+
After running <span class="application">pg_rewind</span>, WAL replay needs to
|
| 36 |
+
complete for the data directory to be in a consistent state. When the
|
| 37 |
+
target server is started again it will enter archive recovery and replay
|
| 38 |
+
all WAL generated in the source server from the last checkpoint before
|
| 39 |
+
the point of divergence. If some of the WAL was no longer available in the
|
| 40 |
+
source server when <span class="application">pg_rewind</span> was run, and
|
| 41 |
+
therefore could not be copied by the <span class="application">pg_rewind</span>
|
| 42 |
+
session, it must be made available when the target server is started.
|
| 43 |
+
This can be done by creating a <code class="filename">recovery.signal</code> file
|
| 44 |
+
in the target data directory and by configuring a suitable
|
| 45 |
+
<a class="xref" href="runtime-config-wal.html#GUC-RESTORE-COMMAND">restore_command</a> in
|
| 46 |
+
<code class="filename">postgresql.conf</code>.
|
| 47 |
+
</p><p>
|
| 48 |
+
<span class="application">pg_rewind</span> requires that the target server either has
|
| 49 |
+
the <a class="xref" href="runtime-config-wal.html#GUC-WAL-LOG-HINTS">wal_log_hints</a> option enabled
|
| 50 |
+
in <code class="filename">postgresql.conf</code> or data checksums enabled when
|
| 51 |
+
the cluster was initialized with <span class="application">initdb</span>. Neither of these
|
| 52 |
+
are currently on by default. <a class="xref" href="runtime-config-wal.html#GUC-FULL-PAGE-WRITES">full_page_writes</a>
|
| 53 |
+
must also be set to <code class="literal">on</code>, but is enabled by default.
|
| 54 |
+
</p><div class="warning"><h3 class="title">Warning: Failures While Rewinding</h3><p>
|
| 55 |
+
If <span class="application">pg_rewind</span> fails while processing, then
|
| 56 |
+
the data folder of the target is likely not in a state that can be
|
| 57 |
+
recovered. In such a case, taking a new fresh backup is recommended.
|
| 58 |
+
</p><p>
|
| 59 |
+
As <span class="application">pg_rewind</span> copies configuration files
|
| 60 |
+
entirely from the source, it may be required to correct the configuration
|
| 61 |
+
used for recovery before restarting the target server, especially if
|
| 62 |
+
the target is reintroduced as a standby of the source. If you restart
|
| 63 |
+
the server after the rewind operation has finished but without configuring
|
| 64 |
+
recovery, the target may again diverge from the primary.
|
| 65 |
+
</p><p>
|
| 66 |
+
<span class="application">pg_rewind</span> will fail immediately if it finds
|
| 67 |
+
files it cannot write directly to. This can happen for example when
|
| 68 |
+
the source and the target server use the same file mapping for read-only
|
| 69 |
+
SSL keys and certificates. If such files are present on the target server
|
| 70 |
+
it is recommended to remove them before running
|
| 71 |
+
<span class="application">pg_rewind</span>. After doing the rewind, some of
|
| 72 |
+
those files may have been copied from the source, in which case it may
|
| 73 |
+
be necessary to remove the data copied and restore back the set of links
|
| 74 |
+
used before the rewind.
|
| 75 |
+
</p></div></div><div class="refsect1" id="id-1.9.5.9.6"><h2>Options</h2><p>
|
| 76 |
+
<span class="application">pg_rewind</span> accepts the following command-line
|
| 77 |
+
arguments:
|
| 78 |
+
|
| 79 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--target-pgdata=<em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
|
| 80 |
+
This option specifies the target data directory that is synchronized
|
| 81 |
+
with the source. The target server must be shut down cleanly before
|
| 82 |
+
running <span class="application">pg_rewind</span>
|
| 83 |
+
</p></dd><dt><span class="term"><code class="option">--source-pgdata=<em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
|
| 84 |
+
Specifies the file system path to the data directory of the source
|
| 85 |
+
server to synchronize the target with. This option requires the
|
| 86 |
+
source server to be cleanly shut down.
|
| 87 |
+
</p></dd><dt><span class="term"><code class="option">--source-server=<em class="replaceable"><code>connstr</code></em></code></span></dt><dd><p>
|
| 88 |
+
Specifies a libpq connection string to connect to the source
|
| 89 |
+
<span class="productname">PostgreSQL</span> server to synchronize the target
|
| 90 |
+
with. The connection must be a normal (non-replication) connection
|
| 91 |
+
with a role having sufficient permissions to execute the functions
|
| 92 |
+
used by <span class="application">pg_rewind</span> on the source server
|
| 93 |
+
(see Notes section for details) or a superuser role. This option
|
| 94 |
+
requires the source server to be running and accepting connections.
|
| 95 |
+
</p></dd><dt><span class="term"><code class="option">-R</code><br /></span><span class="term"><code class="option">--write-recovery-conf</code></span></dt><dd><p>
|
| 96 |
+
Create <code class="filename">standby.signal</code> and append connection
|
| 97 |
+
settings to <code class="filename">postgresql.auto.conf</code> in the output
|
| 98 |
+
directory. <code class="literal">--source-server</code> is mandatory with
|
| 99 |
+
this option.
|
| 100 |
+
</p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--dry-run</code></span></dt><dd><p>
|
| 101 |
+
Do everything except actually modifying the target directory.
|
| 102 |
+
</p></dd><dt><span class="term"><code class="option">-N</code><br /></span><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>
|
| 103 |
+
By default, <code class="command">pg_rewind</code> will wait for all files
|
| 104 |
+
to be written safely to disk. This option causes
|
| 105 |
+
<code class="command">pg_rewind</code> to return without waiting, which is
|
| 106 |
+
faster, but means that a subsequent operating system crash can leave
|
| 107 |
+
the data directory corrupt. Generally, this option is useful for
|
| 108 |
+
testing but should not be used on a production
|
| 109 |
+
installation.
|
| 110 |
+
</p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--progress</code></span></dt><dd><p>
|
| 111 |
+
Enables progress reporting. Turning this on will deliver an approximate
|
| 112 |
+
progress report while copying data from the source cluster.
|
| 113 |
+
</p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--restore-target-wal</code></span></dt><dd><p>
|
| 114 |
+
Use <code class="varname">restore_command</code> defined in the target cluster
|
| 115 |
+
configuration to retrieve WAL files from the WAL archive if these
|
| 116 |
+
files are no longer available in the <code class="filename">pg_wal</code>
|
| 117 |
+
directory.
|
| 118 |
+
</p></dd><dt><span class="term"><code class="option">--config-file=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
|
| 119 |
+
Use the specified main server configuration file for the target
|
| 120 |
+
cluster. This affects <span class="application">pg_rewind</span> when
|
| 121 |
+
it uses internally the <span class="application">postgres</span> command
|
| 122 |
+
for the rewind operation on this cluster (when retrieving
|
| 123 |
+
<code class="varname">restore_command</code> with the option
|
| 124 |
+
<code class="option">-c/--restore-target-wal</code> and when forcing a
|
| 125 |
+
completion of crash recovery).
|
| 126 |
+
</p></dd><dt><span class="term"><code class="option">--debug</code></span></dt><dd><p>
|
| 127 |
+
Print verbose debugging output that is mostly useful for developers
|
| 128 |
+
debugging <span class="application">pg_rewind</span>.
|
| 129 |
+
</p></dd><dt><span class="term"><code class="option">--no-ensure-shutdown</code></span></dt><dd><p>
|
| 130 |
+
<span class="application">pg_rewind</span> requires that the target server
|
| 131 |
+
is cleanly shut down before rewinding. By default, if the target server
|
| 132 |
+
is not shut down cleanly, <span class="application">pg_rewind</span> starts
|
| 133 |
+
the target server in single-user mode to complete crash recovery first,
|
| 134 |
+
and stops it.
|
| 135 |
+
By passing this option, <span class="application">pg_rewind</span> skips
|
| 136 |
+
this and errors out immediately if the server is not cleanly shut
|
| 137 |
+
down. Users are expected to handle the situation themselves in that
|
| 138 |
+
case.
|
| 139 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>Display version information, then exit.</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>Show help, then exit.</p></dd></dl></div><p>
|
| 140 |
+
</p></div><div class="refsect1" id="id-1.9.5.9.7"><h2>Environment</h2><p>
|
| 141 |
+
When <code class="option">--source-server</code> option is used,
|
| 142 |
+
<span class="application">pg_rewind</span> also uses the environment variables
|
| 143 |
+
supported by <span class="application">libpq</span> (see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 144 |
+
</p><p>
|
| 145 |
+
The environment variable <code class="envar">PG_COLOR</code> specifies whether to use
|
| 146 |
+
color in diagnostic messages. Possible values are
|
| 147 |
+
<code class="literal">always</code>, <code class="literal">auto</code> and
|
| 148 |
+
<code class="literal">never</code>.
|
| 149 |
+
</p></div><div class="refsect1" id="id-1.9.5.9.8"><h2>Notes</h2><p>
|
| 150 |
+
When executing <span class="application">pg_rewind</span> using an online
|
| 151 |
+
cluster as source, a role having sufficient permissions to execute the
|
| 152 |
+
functions used by <span class="application">pg_rewind</span> on the source
|
| 153 |
+
cluster can be used instead of a superuser. Here is how to create such
|
| 154 |
+
a role, named <code class="literal">rewind_user</code> here:
|
| 155 |
+
</p><pre class="programlisting">
|
| 156 |
+
CREATE USER rewind_user LOGIN;
|
| 157 |
+
GRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;
|
| 158 |
+
GRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;
|
| 159 |
+
GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;
|
| 160 |
+
GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;
|
| 161 |
+
</pre><p>
|
| 162 |
+
</p><div class="refsect2" id="id-1.9.5.9.8.3"><h3>How It Works</h3><p>
|
| 163 |
+
The basic idea is to copy all file system-level changes from the source
|
| 164 |
+
cluster to the target cluster:
|
| 165 |
+
</p><div class="procedure"><ol class="procedure" type="1"><li class="step"><p>
|
| 166 |
+
Scan the WAL log of the target cluster, starting from the last
|
| 167 |
+
checkpoint before the point where the source cluster's timeline
|
| 168 |
+
history forked off from the target cluster. For each WAL record,
|
| 169 |
+
record each data block that was touched. This yields a list of all
|
| 170 |
+
the data blocks that were changed in the target cluster, after the
|
| 171 |
+
source cluster forked off. If some of the WAL files are no longer
|
| 172 |
+
available, try re-running <span class="application">pg_rewind</span> with
|
| 173 |
+
the <code class="option">-c</code> option to search for the missing files in
|
| 174 |
+
the WAL archive.
|
| 175 |
+
</p></li><li class="step"><p>
|
| 176 |
+
Copy all those changed blocks from the source cluster to
|
| 177 |
+
the target cluster, either using direct file system access
|
| 178 |
+
(<code class="option">--source-pgdata</code>) or SQL (<code class="option">--source-server</code>).
|
| 179 |
+
Relation files are now in a state equivalent to the moment of the last
|
| 180 |
+
completed checkpoint prior to the point at which the WAL timelines of the
|
| 181 |
+
source and target diverged plus the current state on the source of any
|
| 182 |
+
blocks changed on the target after that divergence.
|
| 183 |
+
</p></li><li class="step"><p>
|
| 184 |
+
Copy all other files, including new relation files, WAL segments,
|
| 185 |
+
<code class="filename">pg_xact</code>, and configuration files from the source
|
| 186 |
+
cluster to the target cluster. Similarly to base backups, the contents
|
| 187 |
+
of the directories <code class="filename">pg_dynshmem/</code>,
|
| 188 |
+
<code class="filename">pg_notify/</code>, <code class="filename">pg_replslot/</code>,
|
| 189 |
+
<code class="filename">pg_serial/</code>, <code class="filename">pg_snapshots/</code>,
|
| 190 |
+
<code class="filename">pg_stat_tmp/</code>, and <code class="filename">pg_subtrans/</code>
|
| 191 |
+
are omitted from the data copied from the source cluster. The files
|
| 192 |
+
<code class="filename">backup_label</code>,
|
| 193 |
+
<code class="filename">tablespace_map</code>,
|
| 194 |
+
<code class="filename">pg_internal.init</code>,
|
| 195 |
+
<code class="filename">postmaster.opts</code>,
|
| 196 |
+
<code class="filename">postmaster.pid</code> and
|
| 197 |
+
<code class="filename">.DS_Store</code> as well as any file or directory
|
| 198 |
+
beginning with <code class="filename">pgsql_tmp</code>, are omitted.
|
| 199 |
+
</p></li><li class="step"><p>
|
| 200 |
+
Create a <code class="filename">backup_label</code> file to begin WAL replay at
|
| 201 |
+
the checkpoint created at failover and configure the
|
| 202 |
+
<code class="filename">pg_control</code> file with a minimum consistency LSN
|
| 203 |
+
defined as the result of <code class="literal">pg_current_wal_insert_lsn()</code>
|
| 204 |
+
when rewinding from a live source or the last checkpoint LSN when
|
| 205 |
+
rewinding from a stopped source.
|
| 206 |
+
</p></li><li class="step"><p>
|
| 207 |
+
When starting the target, <span class="productname">PostgreSQL</span> replays
|
| 208 |
+
all the required WAL, resulting in a data directory in a consistent
|
| 209 |
+
state.
|
| 210 |
+
</p></li></ol></div></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgresetwal.html" title="pg_resetwal">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pgtestfsync.html" title="pg_test_fsync">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_resetwal</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_test_fsync</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-pgverifybackup.html
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_verifybackup</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgrestore.html" title="pg_restore" /><link rel="next" href="app-psql.html" title="psql" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_verifybackup</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgrestore.html" title="pg_restore">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-psql.html" title="psql">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGVERIFYBACKUP"><div class="titlepage"></div><a id="id-1.9.4.19.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_verifybackup</span></span></h2><p>pg_verifybackup — verify the integrity of a base backup of a
|
| 3 |
+
<span class="productname">PostgreSQL</span> cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.19.4.1"><code class="command">pg_verifybackup</code> [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="id-1.9.4.19.5"><h2>Description</h2><p>
|
| 4 |
+
<span class="application">pg_verifybackup</span> is used to check the
|
| 5 |
+
integrity of a database cluster backup taken using
|
| 6 |
+
<code class="command">pg_basebackup</code> against a
|
| 7 |
+
<code class="literal">backup_manifest</code> generated by the server at the time
|
| 8 |
+
of the backup. The backup must be stored in the "plain"
|
| 9 |
+
format; a "tar" format backup can be checked after extracting it.
|
| 10 |
+
</p><p>
|
| 11 |
+
It is important to note that the validation which is performed by
|
| 12 |
+
<span class="application">pg_verifybackup</span> does not and cannot include
|
| 13 |
+
every check which will be performed by a running server when attempting
|
| 14 |
+
to make use of the backup. Even if you use this tool, you should still
|
| 15 |
+
perform test restores and verify that the resulting databases work as
|
| 16 |
+
expected and that they appear to contain the correct data. However,
|
| 17 |
+
<span class="application">pg_verifybackup</span> can detect many problems
|
| 18 |
+
that commonly occur due to storage problems or user error.
|
| 19 |
+
</p><p>
|
| 20 |
+
Backup verification proceeds in four stages. First,
|
| 21 |
+
<code class="literal">pg_verifybackup</code> reads the
|
| 22 |
+
<code class="literal">backup_manifest</code> file. If that file
|
| 23 |
+
does not exist, cannot be read, is malformed, or fails verification
|
| 24 |
+
against its own internal checksum, <code class="literal">pg_verifybackup</code>
|
| 25 |
+
will terminate with a fatal error.
|
| 26 |
+
</p><p>
|
| 27 |
+
Second, <code class="literal">pg_verifybackup</code> will attempt to verify that
|
| 28 |
+
the data files currently stored on disk are exactly the same as the data
|
| 29 |
+
files which the server intended to send, with some exceptions that are
|
| 30 |
+
described below. Extra and missing files will be detected, with a few
|
| 31 |
+
exceptions. This step will ignore the presence or absence of, or any
|
| 32 |
+
modifications to, <code class="literal">postgresql.auto.conf</code>,
|
| 33 |
+
<code class="literal">standby.signal</code>, and <code class="literal">recovery.signal</code>,
|
| 34 |
+
because it is expected that these files may have been created or modified
|
| 35 |
+
as part of the process of taking the backup. It also won't complain about
|
| 36 |
+
a <code class="literal">backup_manifest</code> file in the target directory or
|
| 37 |
+
about anything inside <code class="literal">pg_wal</code>, even though these
|
| 38 |
+
files won't be listed in the backup manifest. Only files are checked;
|
| 39 |
+
the presence or absence of directories is not verified, except
|
| 40 |
+
indirectly: if a directory is missing, any files it should have contained
|
| 41 |
+
will necessarily also be missing.
|
| 42 |
+
</p><p>
|
| 43 |
+
Next, <code class="literal">pg_verifybackup</code> will checksum all the files,
|
| 44 |
+
compare the checksums against the values in the manifest, and emit errors
|
| 45 |
+
for any files for which the computed checksum does not match the
|
| 46 |
+
checksum stored in the manifest. This step is not performed for any files
|
| 47 |
+
which produced errors in the previous step, since they are already known
|
| 48 |
+
to have problems. Files which were ignored in the previous step are also
|
| 49 |
+
ignored in this step.
|
| 50 |
+
</p><p>
|
| 51 |
+
Finally, <code class="literal">pg_verifybackup</code> will use the manifest to
|
| 52 |
+
verify that the write-ahead log records which will be needed to recover
|
| 53 |
+
the backup are present and that they can be read and parsed. The
|
| 54 |
+
<code class="literal">backup_manifest</code> contains information about which
|
| 55 |
+
write-ahead log records will be needed, and
|
| 56 |
+
<code class="literal">pg_verifybackup</code> will use that information to
|
| 57 |
+
invoke <code class="literal">pg_waldump</code> to parse those write-ahead log
|
| 58 |
+
records. The <code class="literal">--quiet</code> flag will be used, so that
|
| 59 |
+
<code class="literal">pg_waldump</code> will only report errors, without producing
|
| 60 |
+
any other output. While this level of verification is sufficient to
|
| 61 |
+
detect obvious problems such as a missing file or one whose internal
|
| 62 |
+
checksums do not match, they aren't extensive enough to detect every
|
| 63 |
+
possible problem that might occur when attempting to recover. For
|
| 64 |
+
instance, a server bug that produces write-ahead log records that have
|
| 65 |
+
the correct checksums but specify nonsensical actions can't be detected
|
| 66 |
+
by this method.
|
| 67 |
+
</p><p>
|
| 68 |
+
Note that if extra WAL files which are not required to recover the backup
|
| 69 |
+
are present, they will not be checked by this tool, although
|
| 70 |
+
a separate invocation of <code class="literal">pg_waldump</code> could be used for
|
| 71 |
+
that purpose. Also note that WAL verification is version-specific: you
|
| 72 |
+
must use the version of <code class="literal">pg_verifybackup</code>, and thus of
|
| 73 |
+
<code class="literal">pg_waldump</code>, which pertains to the backup being checked.
|
| 74 |
+
In contrast, the data file integrity checks should work with any version
|
| 75 |
+
of the server that generates a <code class="literal">backup_manifest</code> file.
|
| 76 |
+
</p></div><div class="refsect1" id="id-1.9.4.19.6"><h2>Options</h2><p>
|
| 77 |
+
<span class="application">pg_verifybackup</span> accepts the following
|
| 78 |
+
command-line arguments:
|
| 79 |
+
|
| 80 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--exit-on-error</code></span></dt><dd><p>
|
| 81 |
+
Exit as soon as a problem with the backup is detected. If this option
|
| 82 |
+
is not specified, <code class="literal">pg_verifybackup</code> will continue
|
| 83 |
+
checking the backup even after a problem has been detected, and will
|
| 84 |
+
report all problems detected as errors.
|
| 85 |
+
</p></dd><dt><span class="term"><code class="option">-i <em class="replaceable"><code>path</code></em></code><br /></span><span class="term"><code class="option">--ignore=<em class="replaceable"><code>path</code></em></code></span></dt><dd><p>
|
| 86 |
+
Ignore the specified file or directory, which should be expressed
|
| 87 |
+
as a relative path name, when comparing the list of data files
|
| 88 |
+
actually present in the backup to those listed in the
|
| 89 |
+
<code class="literal">backup_manifest</code> file. If a directory is
|
| 90 |
+
specified, this option affects the entire subtree rooted at that
|
| 91 |
+
location. Complaints about extra files, missing files, file size
|
| 92 |
+
differences, or checksum mismatches will be suppressed if the
|
| 93 |
+
relative path name matches the specified path name. This option
|
| 94 |
+
can be specified multiple times.
|
| 95 |
+
</p></dd><dt><span class="term"><code class="option">-m <em class="replaceable"><code>path</code></em></code><br /></span><span class="term"><code class="option">--manifest-path=<em class="replaceable"><code>path</code></em></code></span></dt><dd><p>
|
| 96 |
+
Use the manifest file at the specified path, rather than one located
|
| 97 |
+
in the root of the backup directory.
|
| 98 |
+
</p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-parse-wal</code></span></dt><dd><p>
|
| 99 |
+
Don't attempt to parse write-ahead log data that will be needed
|
| 100 |
+
to recover from this backup.
|
| 101 |
+
</p></dd><dt><span class="term"><code class="option">-P</code><br /></span><span class="term"><code class="option">--progress</code></span></dt><dd><p>
|
| 102 |
+
Enable progress reporting. Turning this on will deliver a progress
|
| 103 |
+
report while verifying checksums.
|
| 104 |
+
</p><p>
|
| 105 |
+
This option cannot be used together with the option
|
| 106 |
+
<code class="option">--quiet</code>.
|
| 107 |
+
</p></dd><dt><span class="term"><code class="option">-q</code><br /></span><span class="term"><code class="option">--quiet</code></span></dt><dd><p>
|
| 108 |
+
Don't print anything when a backup is successfully verified.
|
| 109 |
+
</p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--skip-checksums</code></span></dt><dd><p>
|
| 110 |
+
Do not verify data file checksums. The presence or absence of
|
| 111 |
+
files and the sizes of those files will still be checked. This is
|
| 112 |
+
much faster, because the files themselves do not need to be read.
|
| 113 |
+
</p></dd><dt><span class="term"><code class="option">-w <em class="replaceable"><code>path</code></em></code><br /></span><span class="term"><code class="option">--wal-directory=<em class="replaceable"><code>path</code></em></code></span></dt><dd><p>
|
| 114 |
+
Try to parse WAL files stored in the specified directory, rather than
|
| 115 |
+
in <code class="literal">pg_wal</code>. This may be useful if the backup is
|
| 116 |
+
stored in a separate location from the WAL archive.
|
| 117 |
+
</p></dd></dl></div><p>
|
| 118 |
+
</p><p>
|
| 119 |
+
Other options are also available:
|
| 120 |
+
|
| 121 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 122 |
+
Print the <span class="application">pg_verifybackup</span> version and exit.
|
| 123 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 124 |
+
Show help about <span class="application">pg_verifybackup</span> command
|
| 125 |
+
line arguments, and exit.
|
| 126 |
+
</p></dd></dl></div><p>
|
| 127 |
+
</p></div><div class="refsect1" id="id-1.9.4.19.7"><h2>Examples</h2><p>
|
| 128 |
+
To create a base backup of the server at <code class="literal">mydbserver</code> and
|
| 129 |
+
verify the integrity of the backup:
|
| 130 |
+
</p><pre class="screen">
|
| 131 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</code></strong>
|
| 132 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_verifybackup /usr/local/pgsql/data</code></strong>
|
| 133 |
+
</pre><p>
|
| 134 |
+
</p><p>
|
| 135 |
+
To create a base backup of the server at <code class="literal">mydbserver</code>, move
|
| 136 |
+
the manifest somewhere outside the backup directory, and verify the
|
| 137 |
+
backup:
|
| 138 |
+
</p><pre class="screen">
|
| 139 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -h mydbserver -D /usr/local/pgsql/backup1234</code></strong>
|
| 140 |
+
<code class="prompt">$</code> <strong class="userinput"><code>mv /usr/local/pgsql/backup1234/backup_manifest /my/secure/location/backup_manifest.1234</code></strong>
|
| 141 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_verifybackup -m /my/secure/location/backup_manifest.1234 /usr/local/pgsql/backup1234</code></strong>
|
| 142 |
+
</pre><p>
|
| 143 |
+
</p><p>
|
| 144 |
+
To verify a backup while ignoring a file that was added manually to the
|
| 145 |
+
backup directory, and also skipping checksum verification:
|
| 146 |
+
</p><pre class="screen">
|
| 147 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</code></strong>
|
| 148 |
+
<code class="prompt">$</code> <strong class="userinput"><code>edit /usr/local/pgsql/data/note.to.self</code></strong>
|
| 149 |
+
<code class="prompt">$</code> <strong class="userinput"><code>pg_verifybackup --ignore=note.to.self --skip-checksums /usr/local/pgsql/data</code></strong>
|
| 150 |
+
</pre></div><div class="refsect1" id="id-1.9.4.19.8"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pgbasebackup.html" title="pg_basebackup"><span class="refentrytitle"><span class="application">pg_basebackup</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgrestore.html" title="pg_restore">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-psql.html" title="psql">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_restore</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">psql</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-postgres.html
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>postgres</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="pgwaldump.html" title="pg_waldump" /><link rel="next" href="internals.html" title="Part VII. Internals" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">postgres</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgwaldump.html" title="pg_waldump">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="internals.html" title="Part VII. Internals">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-POSTGRES"><div class="titlepage"></div><a id="id-1.9.5.14.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">postgres</span></span></h2><p>postgres — <span class="productname">PostgreSQL</span> database server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.14.4.1"><code class="command">postgres</code> [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="id-1.9.5.14.5"><h2>Description</h2><p>
|
| 3 |
+
<code class="command">postgres</code> is the
|
| 4 |
+
<span class="productname">PostgreSQL</span> database server. In order
|
| 5 |
+
for a client application to access a database it connects (over a
|
| 6 |
+
network or locally) to a running <code class="command">postgres</code> instance.
|
| 7 |
+
The <code class="command">postgres</code> instance then starts a separate server
|
| 8 |
+
process to handle the connection.
|
| 9 |
+
</p><p>
|
| 10 |
+
One <code class="command">postgres</code> instance always manages the data of
|
| 11 |
+
exactly one database cluster. A database cluster is a collection
|
| 12 |
+
of databases that is stored at a common file system location (the
|
| 13 |
+
<span class="quote">“<span class="quote">data area</span>”</span>). More than one
|
| 14 |
+
<code class="command">postgres</code> instance can run on a system at one
|
| 15 |
+
time, so long as they use different data areas and different
|
| 16 |
+
communication ports (see below). When
|
| 17 |
+
<code class="command">postgres</code> starts it needs to know the location
|
| 18 |
+
of the data area. The location must be specified by the
|
| 19 |
+
<code class="option">-D</code> option or the <code class="envar">PGDATA</code> environment
|
| 20 |
+
variable; there is no default. Typically, <code class="option">-D</code> or
|
| 21 |
+
<code class="envar">PGDATA</code> points directly to the data area directory
|
| 22 |
+
created by <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a>. Other possible file layouts are
|
| 23 |
+
discussed in <a class="xref" href="runtime-config-file-locations.html" title="20.2. File Locations">Section 20.2</a>.
|
| 24 |
+
</p><p>
|
| 25 |
+
By default <code class="command">postgres</code> starts in the
|
| 26 |
+
foreground and prints log messages to the standard error stream. In
|
| 27 |
+
practical applications <code class="command">postgres</code>
|
| 28 |
+
should be started as a background process, perhaps at boot time.
|
| 29 |
+
</p><p>
|
| 30 |
+
The <code class="command">postgres</code> command can also be called in
|
| 31 |
+
single-user mode. The primary use for this mode is during
|
| 32 |
+
bootstrapping by <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a>. Sometimes it is used
|
| 33 |
+
for debugging or disaster recovery; note that running a single-user
|
| 34 |
+
server is not truly suitable for debugging the server, since no
|
| 35 |
+
realistic interprocess communication and locking will happen.
|
| 36 |
+
When invoked in single-user
|
| 37 |
+
mode from the shell, the user can enter queries and the results
|
| 38 |
+
will be printed to the screen, but in a form that is more useful
|
| 39 |
+
for developers than end users. In the single-user mode,
|
| 40 |
+
the session user will be set to the user with ID 1, and implicit
|
| 41 |
+
superuser powers are granted to this user.
|
| 42 |
+
This user does not actually have to exist, so the single-user mode
|
| 43 |
+
can be used to manually recover from certain
|
| 44 |
+
kinds of accidental damage to the system catalogs.
|
| 45 |
+
</p></div><div class="refsect1" id="APP-POSTGRES-OPTIONS"><h2>Options</h2><p>
|
| 46 |
+
<code class="command">postgres</code> accepts the following command-line
|
| 47 |
+
arguments. For a detailed discussion of the options consult <a class="xref" href="runtime-config.html" title="Chapter 20. Server Configuration">Chapter 20</a>. You can save typing most of these
|
| 48 |
+
options by setting up a configuration file. Some (safe) options
|
| 49 |
+
can also be set from the connecting client in an
|
| 50 |
+
application-dependent way to apply only for that session. For
|
| 51 |
+
example, if the environment variable <code class="envar">PGOPTIONS</code> is
|
| 52 |
+
set, then <span class="application">libpq</span>-based clients will pass that
|
| 53 |
+
string to the server, which will interpret it as
|
| 54 |
+
<code class="command">postgres</code> command-line options.
|
| 55 |
+
</p><div class="refsect2" id="id-1.9.5.14.6.3"><h3>General Purpose</h3><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-B <em class="replaceable"><code>nbuffers</code></em></code></span></dt><dd><p>
|
| 56 |
+
Sets the number of shared buffers for use by the server
|
| 57 |
+
processes. The default value of this parameter is chosen
|
| 58 |
+
automatically by <span class="application">initdb</span>.
|
| 59 |
+
Specifying this option is equivalent to setting the
|
| 60 |
+
<a class="xref" href="runtime-config-resource.html#GUC-SHARED-BUFFERS">shared_buffers</a> configuration parameter.
|
| 61 |
+
</p></dd><dt><span class="term"><code class="option">-c <em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></code></span></dt><dd><p>
|
| 62 |
+
Sets a named run-time parameter. The configuration parameters
|
| 63 |
+
supported by <span class="productname">PostgreSQL</span> are
|
| 64 |
+
described in <a class="xref" href="runtime-config.html" title="Chapter 20. Server Configuration">Chapter 20</a>. Most of the
|
| 65 |
+
other command line options are in fact short forms of such a
|
| 66 |
+
parameter assignment. <code class="option">-c</code> can appear multiple times
|
| 67 |
+
to set multiple parameters.
|
| 68 |
+
</p></dd><dt><span class="term"><code class="option">-C <em class="replaceable"><code>name</code></em></code></span></dt><dd><p>
|
| 69 |
+
Prints the value of the named run-time parameter, and exits.
|
| 70 |
+
(See the <code class="option">-c</code> option above for details.) This
|
| 71 |
+
returns values from
|
| 72 |
+
<code class="filename">postgresql.conf</code>, modified by any parameters
|
| 73 |
+
supplied in this invocation. It does not reflect parameters
|
| 74 |
+
supplied when the cluster was started.
|
| 75 |
+
</p><p>
|
| 76 |
+
This can be used on a running server for most parameters. However,
|
| 77 |
+
the server must be shut down for some runtime-computed parameters
|
| 78 |
+
(e.g., <a class="xref" href="runtime-config-preset.html#GUC-SHARED-MEMORY-SIZE">shared_memory_size</a>,
|
| 79 |
+
<a class="xref" href="runtime-config-preset.html#GUC-SHARED-MEMORY-SIZE-IN-HUGE-PAGES">shared_memory_size_in_huge_pages</a>, and
|
| 80 |
+
<a class="xref" href="runtime-config-preset.html#GUC-WAL-SEGMENT-SIZE">wal_segment_size</a>).
|
| 81 |
+
</p><p>
|
| 82 |
+
This option is meant for other programs that interact with a server
|
| 83 |
+
instance, such as <a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a>, to query configuration
|
| 84 |
+
parameter values. User-facing applications should instead use <a class="link" href="sql-show.html" title="SHOW"><code class="command">SHOW</code></a> or the <code class="structname">pg_settings</code> view.
|
| 85 |
+
</p></dd><dt><span class="term"><code class="option">-d <em class="replaceable"><code>debug-level</code></em></code></span></dt><dd><p>
|
| 86 |
+
Sets the debug level. The higher this value is set, the more
|
| 87 |
+
debugging output is written to the server log. Values are
|
| 88 |
+
from 1 to 5. It is also possible to pass <code class="literal">-d
|
| 89 |
+
0</code> for a specific session, which will prevent the
|
| 90 |
+
server log level of the parent <code class="command">postgres</code> process from being
|
| 91 |
+
propagated to this session.
|
| 92 |
+
</p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>datadir</code></em></code></span></dt><dd><p>
|
| 93 |
+
Specifies the file system location of the database
|
| 94 |
+
configuration files. See
|
| 95 |
+
<a class="xref" href="runtime-config-file-locations.html" title="20.2. File Locations">Section 20.2</a> for details.
|
| 96 |
+
</p></dd><dt><span class="term"><code class="option">-e</code></span></dt><dd><p>
|
| 97 |
+
Sets the default date style to <span class="quote">“<span class="quote">European</span>”</span>, that is
|
| 98 |
+
<code class="literal">DMY</code> ordering of input date fields. This also causes
|
| 99 |
+
the day to be printed before the month in certain date output formats.
|
| 100 |
+
See <a class="xref" href="datatype-datetime.html" title="8.5. Date/Time Types">Section 8.5</a> for more information.
|
| 101 |
+
</p></dd><dt><span class="term"><code class="option">-F</code></span></dt><dd><p>
|
| 102 |
+
Disables <code class="function">fsync</code> calls for improved
|
| 103 |
+
performance, at the risk of data corruption in the event of a
|
| 104 |
+
system crash. Specifying this option is equivalent to
|
| 105 |
+
disabling the <a class="xref" href="runtime-config-wal.html#GUC-FSYNC">fsync</a> configuration
|
| 106 |
+
parameter. Read the detailed documentation before using this!
|
| 107 |
+
</p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>hostname</code></em></code></span></dt><dd><p>
|
| 108 |
+
Specifies the IP host name or address on which
|
| 109 |
+
<code class="command">postgres</code> is to listen for TCP/IP
|
| 110 |
+
connections from client applications. The value can also be a
|
| 111 |
+
comma-separated list of addresses, or <code class="literal">*</code> to specify
|
| 112 |
+
listening on all available interfaces. An empty value
|
| 113 |
+
specifies not listening on any IP addresses, in which case
|
| 114 |
+
only Unix-domain sockets can be used to connect to the
|
| 115 |
+
server. Defaults to listening only on
|
| 116 |
+
<span class="systemitem">localhost</span>.
|
| 117 |
+
Specifying this option is equivalent to setting the <a class="xref" href="runtime-config-connection.html#GUC-LISTEN-ADDRESSES">listen_addresses</a> configuration parameter.
|
| 118 |
+
</p></dd><dt><span class="term"><code class="option">-i</code></span></dt><dd><p>
|
| 119 |
+
Allows remote clients to connect via TCP/IP (Internet domain)
|
| 120 |
+
connections. Without this option, only local connections are
|
| 121 |
+
accepted. This option is equivalent to setting
|
| 122 |
+
<code class="varname">listen_addresses</code> to <code class="literal">*</code> in
|
| 123 |
+
<code class="filename">postgresql.conf</code> or via <code class="option">-h</code>.
|
| 124 |
+
</p><p>
|
| 125 |
+
This option is deprecated since it does not allow access to the
|
| 126 |
+
full functionality of <a class="xref" href="runtime-config-connection.html#GUC-LISTEN-ADDRESSES">listen_addresses</a>.
|
| 127 |
+
It's usually better to set <code class="varname">listen_addresses</code> directly.
|
| 128 |
+
</p></dd><dt><span class="term"><code class="option">-k <em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
|
| 129 |
+
Specifies the directory of the Unix-domain socket on which
|
| 130 |
+
<code class="command">postgres</code> is to listen for
|
| 131 |
+
connections from client applications. The value can also be a
|
| 132 |
+
comma-separated list of directories. An empty value
|
| 133 |
+
specifies not listening on any Unix-domain sockets, in which case
|
| 134 |
+
only TCP/IP sockets can be used to connect to the server.
|
| 135 |
+
The default value is normally
|
| 136 |
+
<code class="filename">/tmp</code>, but that can be changed at build time.
|
| 137 |
+
Specifying this option is equivalent to setting the <a class="xref" href="runtime-config-connection.html#GUC-UNIX-SOCKET-DIRECTORIES">unix_socket_directories</a> configuration parameter.
|
| 138 |
+
</p></dd><dt><span class="term"><code class="option">-l</code></span></dt><dd><p>
|
| 139 |
+
Enables secure connections using <acronym class="acronym">SSL</acronym>.
|
| 140 |
+
<span class="productname">PostgreSQL</span> must have been compiled with
|
| 141 |
+
support for <acronym class="acronym">SSL</acronym> for this option to be
|
| 142 |
+
available. For more information on using <acronym class="acronym">SSL</acronym>,
|
| 143 |
+
refer to <a class="xref" href="ssl-tcp.html" title="19.9. Secure TCP/IP Connections with SSL">Section 19.9</a>.
|
| 144 |
+
</p></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>max-connections</code></em></code></span></dt><dd><p>
|
| 145 |
+
Sets the maximum number of client connections that this
|
| 146 |
+
server will accept. The default value of this parameter is chosen
|
| 147 |
+
automatically by <span class="application">initdb</span>.
|
| 148 |
+
Specifying this option is equivalent to setting the
|
| 149 |
+
<a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a> configuration parameter.
|
| 150 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 151 |
+
Specifies the TCP/IP port or local Unix domain socket file
|
| 152 |
+
extension on which <code class="command">postgres</code>
|
| 153 |
+
is to listen for connections from client applications.
|
| 154 |
+
Defaults to the value of the <code class="envar">PGPORT</code> environment
|
| 155 |
+
variable, or if <code class="envar">PGPORT</code> is not set, then
|
| 156 |
+
defaults to the value established during compilation (normally
|
| 157 |
+
5432). If you specify a port other than the default port,
|
| 158 |
+
then all client applications must specify the same port using
|
| 159 |
+
either command-line options or <code class="envar">PGPORT</code>.
|
| 160 |
+
</p></dd><dt><span class="term"><code class="option">-s</code></span></dt><dd><p>
|
| 161 |
+
Print time information and other statistics at the end of each command.
|
| 162 |
+
This is useful for benchmarking or for use in tuning the number of
|
| 163 |
+
buffers.
|
| 164 |
+
</p></dd><dt><span class="term"><code class="option">-S</code> <em class="replaceable"><code>work-mem</code></em></span></dt><dd><p>
|
| 165 |
+
Specifies the base amount of memory to be used by sorts and
|
| 166 |
+
hash tables before resorting to temporary disk files. See the
|
| 167 |
+
description of the <code class="varname">work_mem</code> configuration
|
| 168 |
+
parameter in <a class="xref" href="runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-MEMORY" title="20.4.1. Memory">Section 20.4.1</a>.
|
| 169 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 170 |
+
Print the <span class="application">postgres</span> version and exit.
|
| 171 |
+
</p></dd><dt><span class="term"><code class="option">--<em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></code></span></dt><dd><p>
|
| 172 |
+
Sets a named run-time parameter; a shorter form of
|
| 173 |
+
<code class="option">-c</code>.
|
| 174 |
+
</p></dd><dt><span class="term"><code class="option">--describe-config</code></span></dt><dd><p>
|
| 175 |
+
This option dumps out the server's internal configuration variables,
|
| 176 |
+
descriptions, and defaults in tab-delimited <code class="command">COPY</code> format.
|
| 177 |
+
It is designed primarily for use by administration tools.
|
| 178 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 179 |
+
Show help about <span class="application">postgres</span> command line
|
| 180 |
+
arguments, and exit.
|
| 181 |
+
</p></dd></dl></div></div><div class="refsect2" id="id-1.9.5.14.6.4"><h3>Semi-Internal Options</h3><p>
|
| 182 |
+
The options described here are used
|
| 183 |
+
mainly for debugging purposes, and in some cases to assist with
|
| 184 |
+
recovery of severely damaged databases. There should be no reason
|
| 185 |
+
to use them in a production database setup. They are listed
|
| 186 |
+
here only for use by <span class="productname">PostgreSQL</span>
|
| 187 |
+
system developers. Furthermore, these options might
|
| 188 |
+
change or be removed in a future release without notice.
|
| 189 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-f</code> <code class="literal">{ s | i | o | b | t | n | m | h }</code></span></dt><dd><p>
|
| 190 |
+
Forbids the use of particular scan and join methods:
|
| 191 |
+
<code class="literal">s</code> and <code class="literal">i</code>
|
| 192 |
+
disable sequential and index scans respectively,
|
| 193 |
+
<code class="literal">o</code>, <code class="literal">b</code> and <code class="literal">t</code>
|
| 194 |
+
disable index-only scans, bitmap index scans, and TID scans
|
| 195 |
+
respectively, while
|
| 196 |
+
<code class="literal">n</code>, <code class="literal">m</code>, and <code class="literal">h</code>
|
| 197 |
+
disable nested-loop, merge and hash joins respectively.
|
| 198 |
+
</p><p>
|
| 199 |
+
Neither sequential scans nor nested-loop joins can be disabled
|
| 200 |
+
completely; the <code class="literal">-fs</code> and
|
| 201 |
+
<code class="literal">-fn</code> options simply discourage the optimizer
|
| 202 |
+
from using those plan types if it has any other alternative.
|
| 203 |
+
</p></dd><dt><span class="term"><code class="option">-O</code></span></dt><dd><p>
|
| 204 |
+
Allows the structure of system tables to be modified. This is
|
| 205 |
+
used by <code class="command">initdb</code>.
|
| 206 |
+
</p></dd><dt><span class="term"><code class="option">-P</code></span></dt><dd><p>
|
| 207 |
+
Ignore system indexes when reading system tables, but still update
|
| 208 |
+
the indexes when modifying the tables. This is useful when
|
| 209 |
+
recovering from damaged system indexes.
|
| 210 |
+
</p></dd><dt><span class="term"><code class="option">-t</code> <code class="literal">pa[rser] | pl[anner] | e[xecutor]</code></span></dt><dd><p>
|
| 211 |
+
Print timing statistics for each query relating to each of the
|
| 212 |
+
major system modules. This option cannot be used together
|
| 213 |
+
with the <code class="option">-s</code> option.
|
| 214 |
+
</p></dd><dt><span class="term"><code class="option">-T</code></span></dt><dd><p>
|
| 215 |
+
This option is for debugging problems that cause a server
|
| 216 |
+
process to die abnormally. The ordinary strategy in this
|
| 217 |
+
situation is to notify all other server processes that they
|
| 218 |
+
must terminate, by sending them <span class="systemitem">SIGQUIT</span>
|
| 219 |
+
signals. With this option, <span class="systemitem">SIGABRT</span>
|
| 220 |
+
will be sent instead, resulting in production of core dump files.
|
| 221 |
+
</p></dd><dt><span class="term"><code class="option">-v</code> <em class="replaceable"><code>protocol</code></em></span></dt><dd><p>
|
| 222 |
+
Specifies the version number of the frontend/backend protocol
|
| 223 |
+
to be used for a particular session. This option is for
|
| 224 |
+
internal use only.
|
| 225 |
+
</p></dd><dt><span class="term"><code class="option">-W</code> <em class="replaceable"><code>seconds</code></em></span></dt><dd><p>
|
| 226 |
+
A delay of this many seconds occurs when a new server process
|
| 227 |
+
is started, after it conducts the authentication procedure.
|
| 228 |
+
This is intended to give an opportunity to attach to the
|
| 229 |
+
server process with a debugger.
|
| 230 |
+
</p></dd></dl></div></div><div class="refsect2" id="id-1.9.5.14.6.5"><h3>Options for Single-User Mode</h3><a id="id-1.9.5.14.6.5.2" class="indexterm"></a><p>
|
| 231 |
+
The following options only apply to the single-user mode
|
| 232 |
+
(see <a class="xref" href="app-postgres.html#APP-POSTGRES-SINGLE-USER" title="Single-User Mode">Single-User Mode</a> below).
|
| 233 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--single</code></span></dt><dd><p>
|
| 234 |
+
Selects the single-user mode. This must be the first argument
|
| 235 |
+
on the command line.
|
| 236 |
+
</p></dd><dt><span class="term"><em class="replaceable"><code>database</code></em></span></dt><dd><p>
|
| 237 |
+
Specifies the name of the database to be accessed. This must be
|
| 238 |
+
the last argument on the command line. If it is
|
| 239 |
+
omitted it defaults to the user name.
|
| 240 |
+
</p></dd><dt><span class="term"><code class="option">-E</code></span></dt><dd><p>
|
| 241 |
+
Echo all commands to standard output before executing them.
|
| 242 |
+
</p></dd><dt><span class="term"><code class="option">-j</code></span></dt><dd><p>
|
| 243 |
+
Use semicolon followed by two newlines, rather than just newline,
|
| 244 |
+
as the command entry terminator.
|
| 245 |
+
</p></dd><dt><span class="term"><code class="option">-r</code> <em class="replaceable"><code>filename</code></em></span></dt><dd><p>
|
| 246 |
+
Send all server log output to <em class="replaceable"><code>filename</code></em>. This option is only
|
| 247 |
+
honored when supplied as a command-line option.
|
| 248 |
+
</p></dd></dl></div></div></div><div class="refsect1" id="id-1.9.5.14.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGCLIENTENCODING</code></span></dt><dd><p>
|
| 249 |
+
Default character encoding used by clients. (The clients can
|
| 250 |
+
override this individually.) This value can also be set in the
|
| 251 |
+
configuration file.
|
| 252 |
+
</p></dd><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>
|
| 253 |
+
Default data directory location
|
| 254 |
+
</p></dd><dt><span class="term"><code class="envar">PGDATESTYLE</code></span></dt><dd><p>
|
| 255 |
+
Default value of the <a class="xref" href="runtime-config-client.html#GUC-DATESTYLE">DateStyle</a> run-time
|
| 256 |
+
parameter. (The use of this environment variable is deprecated.)
|
| 257 |
+
</p></dd><dt><span class="term"><code class="envar">PGPORT</code></span></dt><dd><p>
|
| 258 |
+
Default port number (preferably set in the configuration file)
|
| 259 |
+
</p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.14.8"><h2>Diagnostics</h2><p>
|
| 260 |
+
A failure message mentioning <code class="literal">semget</code> or
|
| 261 |
+
<code class="literal">shmget</code> probably indicates you need to configure your
|
| 262 |
+
kernel to provide adequate shared memory and semaphores. For more
|
| 263 |
+
discussion see <a class="xref" href="kernel-resources.html" title="19.4. Managing Kernel Resources">Section 19.4</a>. You might be able
|
| 264 |
+
to postpone reconfiguring your kernel by decreasing <a class="xref" href="runtime-config-resource.html#GUC-SHARED-BUFFERS">shared_buffers</a> to reduce the shared memory
|
| 265 |
+
consumption of <span class="productname">PostgreSQL</span>, and/or by reducing
|
| 266 |
+
<a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a> to reduce the semaphore
|
| 267 |
+
consumption.
|
| 268 |
+
</p><p>
|
| 269 |
+
A failure message suggesting that another server is already running
|
| 270 |
+
should be checked carefully, for example by using the command
|
| 271 |
+
</p><pre class="screen">
|
| 272 |
+
<code class="prompt">$</code> <strong class="userinput"><code>ps ax | grep postgres</code></strong>
|
| 273 |
+
</pre><p>
|
| 274 |
+
or
|
| 275 |
+
</p><pre class="screen">
|
| 276 |
+
<code class="prompt">$</code> <strong class="userinput"><code>ps -ef | grep postgres</code></strong>
|
| 277 |
+
</pre><p>
|
| 278 |
+
depending on your system. If you are certain that no conflicting
|
| 279 |
+
server is running, you can remove the lock file mentioned in the
|
| 280 |
+
message and try again.
|
| 281 |
+
</p><p>
|
| 282 |
+
A failure message indicating inability to bind to a port might
|
| 283 |
+
indicate that that port is already in use by some
|
| 284 |
+
non-<span class="productname">PostgreSQL</span> process. You might also
|
| 285 |
+
get this error if you terminate <code class="command">postgres</code>
|
| 286 |
+
and immediately restart it using the same port; in this case, you
|
| 287 |
+
must simply wait a few seconds until the operating system closes
|
| 288 |
+
the port before trying again. Finally, you might get this error if
|
| 289 |
+
you specify a port number that your operating system considers to
|
| 290 |
+
be reserved. For example, many versions of Unix consider port
|
| 291 |
+
numbers under 1024 to be <span class="quote">“<span class="quote">trusted</span>”</span> and only permit
|
| 292 |
+
the Unix superuser to access them.
|
| 293 |
+
</p></div><div class="refsect1" id="id-1.9.5.14.9"><h2>Notes</h2><p>
|
| 294 |
+
The utility command <a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a> can be used to
|
| 295 |
+
start and shut down the <code class="command">postgres</code> server
|
| 296 |
+
safely and comfortably.
|
| 297 |
+
</p><p>
|
| 298 |
+
If at all possible, <span class="emphasis"><em>do not</em></span> use
|
| 299 |
+
<code class="literal">SIGKILL</code> to kill the main
|
| 300 |
+
<code class="command">postgres</code> server. Doing so will prevent
|
| 301 |
+
<code class="command">postgres</code> from freeing the system
|
| 302 |
+
resources (e.g., shared memory and semaphores) that it holds before
|
| 303 |
+
terminating. This might cause problems for starting a fresh
|
| 304 |
+
<code class="command">postgres</code> run.
|
| 305 |
+
</p><p>
|
| 306 |
+
To terminate the <code class="command">postgres</code> server normally, the
|
| 307 |
+
signals <code class="literal">SIGTERM</code>, <code class="literal">SIGINT</code>, or
|
| 308 |
+
<code class="literal">SIGQUIT</code> can be used. The first will wait for
|
| 309 |
+
all clients to terminate before quitting, the second will
|
| 310 |
+
forcefully disconnect all clients, and the third will quit
|
| 311 |
+
immediately without proper shutdown, resulting in a recovery run
|
| 312 |
+
during restart.
|
| 313 |
+
</p><p>
|
| 314 |
+
The <code class="literal">SIGHUP</code> signal will reload
|
| 315 |
+
the server configuration files. It is also possible to send
|
| 316 |
+
<code class="literal">SIGHUP</code> to an individual server process, but that
|
| 317 |
+
is usually not sensible.
|
| 318 |
+
</p><p>
|
| 319 |
+
To cancel a running query, send the <code class="literal">SIGINT</code> signal
|
| 320 |
+
to the process running that command. To terminate a backend process
|
| 321 |
+
cleanly, send <code class="literal">SIGTERM</code> to that process. See
|
| 322 |
+
also <code class="function">pg_cancel_backend</code> and <code class="function">pg_terminate_backend</code>
|
| 323 |
+
in <a class="xref" href="functions-admin.html#FUNCTIONS-ADMIN-SIGNAL" title="9.27.2. Server Signaling Functions">Section 9.27.2</a> for the SQL-callable equivalents
|
| 324 |
+
of these two actions.
|
| 325 |
+
</p><p>
|
| 326 |
+
The <code class="command">postgres</code> server uses <code class="literal">SIGQUIT</code>
|
| 327 |
+
to tell subordinate server processes to terminate without normal
|
| 328 |
+
cleanup.
|
| 329 |
+
This signal <span class="emphasis"><em>should not</em></span> be used by users. It
|
| 330 |
+
is also unwise to send <code class="literal">SIGKILL</code> to a server
|
| 331 |
+
process — the main <code class="command">postgres</code> process will
|
| 332 |
+
interpret this as a crash and will force all the sibling processes
|
| 333 |
+
to quit as part of its standard crash-recovery procedure.
|
| 334 |
+
</p></div><div class="refsect1" id="APP-POSTGRES-BUGS"><h2>Bugs</h2><p>
|
| 335 |
+
The <code class="option">--</code> options will not work on <span class="systemitem">FreeBSD</span> or <span class="systemitem">OpenBSD</span>.
|
| 336 |
+
Use <code class="option">-c</code> instead. This is a bug in the affected operating
|
| 337 |
+
systems; a future release of <span class="productname">PostgreSQL</span>
|
| 338 |
+
will provide a workaround if this is not fixed.
|
| 339 |
+
</p></div><div class="refsect1" id="APP-POSTGRES-SINGLE-USER"><h2>Single-User Mode</h2><p>
|
| 340 |
+
To start a single-user mode server, use a command like
|
| 341 |
+
</p><pre class="screen">
|
| 342 |
+
<strong class="userinput"><code>postgres --single -D /usr/local/pgsql/data <em class="replaceable"><code>other-options</code></em> my_database</code></strong>
|
| 343 |
+
</pre><p>
|
| 344 |
+
Provide the correct path to the database directory with <code class="option">-D</code>, or
|
| 345 |
+
make sure that the environment variable <code class="envar">PGDATA</code> is set.
|
| 346 |
+
Also specify the name of the particular database you want to work in.
|
| 347 |
+
</p><p>
|
| 348 |
+
Normally, the single-user mode server treats newline as the command
|
| 349 |
+
entry terminator; there is no intelligence about semicolons,
|
| 350 |
+
as there is in <span class="application">psql</span>. To continue a command
|
| 351 |
+
across multiple lines, you must type backslash just before each
|
| 352 |
+
newline except the last one. The backslash and adjacent newline are
|
| 353 |
+
both dropped from the input command. Note that this will happen even
|
| 354 |
+
when within a string literal or comment.
|
| 355 |
+
</p><p>
|
| 356 |
+
But if you use the <code class="option">-j</code> command line switch, a single newline
|
| 357 |
+
does not terminate command entry; instead, the sequence
|
| 358 |
+
semicolon-newline-newline does. That is, type a semicolon immediately
|
| 359 |
+
followed by a completely empty line. Backslash-newline is not
|
| 360 |
+
treated specially in this mode. Again, there is no intelligence about
|
| 361 |
+
such a sequence appearing within a string literal or comment.
|
| 362 |
+
</p><p>
|
| 363 |
+
In either input mode, if you type a semicolon that is not just before or
|
| 364 |
+
part of a command entry terminator, it is considered a command separator.
|
| 365 |
+
When you do type a command entry terminator, the multiple statements
|
| 366 |
+
you've entered will be executed as a single transaction.
|
| 367 |
+
</p><p>
|
| 368 |
+
To quit the session, type <acronym class="acronym">EOF</acronym>
|
| 369 |
+
(<span class="keycap"><strong>Control</strong></span>+<span class="keycap"><strong>D</strong></span>, usually).
|
| 370 |
+
If you've entered any text since the last command entry terminator,
|
| 371 |
+
then <acronym class="acronym">EOF</acronym> will be taken as a command entry terminator,
|
| 372 |
+
and another <acronym class="acronym">EOF</acronym> will be needed to exit.
|
| 373 |
+
</p><p>
|
| 374 |
+
Note that the single-user mode server does not provide sophisticated
|
| 375 |
+
line-editing features (no command history, for example).
|
| 376 |
+
Single-user mode also does not do any background processing, such as
|
| 377 |
+
automatic checkpoints or replication.
|
| 378 |
+
</p></div><div class="refsect1" id="APP-POSTGRES-EXAMPLES"><h2>Examples</h2><p>
|
| 379 |
+
To start <code class="command">postgres</code> in the background
|
| 380 |
+
using default values, type:
|
| 381 |
+
|
| 382 |
+
</p><pre class="screen">
|
| 383 |
+
<code class="prompt">$</code> <strong class="userinput"><code>nohup postgres >logfile 2>&1 </dev/null &</code></strong>
|
| 384 |
+
</pre><p>
|
| 385 |
+
</p><p>
|
| 386 |
+
To start <code class="command">postgres</code> with a specific
|
| 387 |
+
port, e.g., 1234:
|
| 388 |
+
</p><pre class="screen">
|
| 389 |
+
<code class="prompt">$</code> <strong class="userinput"><code>postgres -p 1234</code></strong>
|
| 390 |
+
</pre><p>
|
| 391 |
+
To connect to this server using <span class="application">psql</span>, specify this port with the -p option:
|
| 392 |
+
</p><pre class="screen">
|
| 393 |
+
<code class="prompt">$</code> <strong class="userinput"><code>psql -p 1234</code></strong>
|
| 394 |
+
</pre><p>
|
| 395 |
+
or set the environment variable <code class="envar">PGPORT</code>:
|
| 396 |
+
</p><pre class="screen">
|
| 397 |
+
<code class="prompt">$</code> <strong class="userinput"><code>export PGPORT=1234</code></strong>
|
| 398 |
+
<code class="prompt">$</code> <strong class="userinput"><code>psql</code></strong>
|
| 399 |
+
</pre><p>
|
| 400 |
+
</p><p>
|
| 401 |
+
Named run-time parameters can be set in either of these styles:
|
| 402 |
+
</p><pre class="screen">
|
| 403 |
+
<code class="prompt">$</code> <strong class="userinput"><code>postgres -c work_mem=1234</code></strong>
|
| 404 |
+
<code class="prompt">$</code> <strong class="userinput"><code>postgres --work-mem=1234</code></strong>
|
| 405 |
+
</pre><p>
|
| 406 |
+
Either form overrides whatever setting might exist for
|
| 407 |
+
<code class="varname">work_mem</code> in <code class="filename">postgresql.conf</code>. Notice that
|
| 408 |
+
underscores in parameter names can be written as either underscore
|
| 409 |
+
or dash on the command line. Except for short-term experiments,
|
| 410 |
+
it's probably better practice to edit the setting in
|
| 411 |
+
<code class="filename">postgresql.conf</code> than to rely on a command-line switch
|
| 412 |
+
to set a parameter.
|
| 413 |
+
</p></div><div class="refsect1" id="id-1.9.5.14.13"><h2>See Also</h2><p>
|
| 414 |
+
<a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a>,
|
| 415 |
+
<a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a>
|
| 416 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgwaldump.html" title="pg_waldump">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="internals.html" title="Part VII. Internals">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_waldump</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Part VII. Internals</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-psql.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
pgsql/doc/postgresql/html/app-reindexdb.html
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>reindexdb</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-psql.html" title="psql" /><link rel="next" href="app-vacuumdb.html" title="vacuumdb" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">reindexdb</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-psql.html" title="psql">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-vacuumdb.html" title="vacuumdb">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-REINDEXDB"><div class="titlepage"></div><a id="id-1.9.4.21.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">reindexdb</span></span></h2><p>reindexdb — reindex a <span class="productname">PostgreSQL</span> database</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.21.4.1"><code class="command">reindexdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...]
|
| 3 |
+
[
|
| 4 |
+
<code class="option">-S</code> | <code class="option">--schema</code>
|
| 5 |
+
<em class="replaceable"><code>schema</code></em>
|
| 6 |
+
]
|
| 7 |
+
...
|
| 8 |
+
[
|
| 9 |
+
<code class="option">-t</code> | <code class="option">--table</code>
|
| 10 |
+
<em class="replaceable"><code>table</code></em>
|
| 11 |
+
]
|
| 12 |
+
...
|
| 13 |
+
[
|
| 14 |
+
<code class="option">-i</code> | <code class="option">--index</code>
|
| 15 |
+
<em class="replaceable"><code>index</code></em>
|
| 16 |
+
]
|
| 17 |
+
... [<em class="replaceable"><code>dbname</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.4.21.4.2"><code class="command">reindexdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] <code class="option">-a</code> | <code class="option">--all</code> </p></div><div class="cmdsynopsis"><p id="id-1.9.4.21.4.3"><code class="command">reindexdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] <code class="option">-s</code> | <code class="option">--system</code> [<em class="replaceable"><code>dbname</code></em>]</p></div></div><div class="refsect1" id="id-1.9.4.21.5"><h2>Description</h2><p>
|
| 18 |
+
<span class="application">reindexdb</span> is a utility for rebuilding indexes
|
| 19 |
+
in a <span class="productname">PostgreSQL</span> database.
|
| 20 |
+
</p><p>
|
| 21 |
+
<span class="application">reindexdb</span> is a wrapper around the SQL
|
| 22 |
+
command <a class="link" href="sql-reindex.html" title="REINDEX"><code class="command">REINDEX</code></a>.
|
| 23 |
+
There is no effective difference between reindexing databases via
|
| 24 |
+
this utility and via other methods for accessing the server.
|
| 25 |
+
</p></div><div class="refsect1" id="id-1.9.4.21.6"><h2>Options</h2><p>
|
| 26 |
+
<span class="application">reindexdb</span> accepts the following command-line arguments:
|
| 27 |
+
|
| 28 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--all</code></span></dt><dd><p>
|
| 29 |
+
Reindex all databases.
|
| 30 |
+
</p></dd><dt><span class="term"><code class="option">--concurrently</code></span></dt><dd><p>
|
| 31 |
+
Use the <code class="literal">CONCURRENTLY</code> option. See
|
| 32 |
+
<a class="xref" href="sql-reindex.html" title="REINDEX"><span class="refentrytitle">REINDEX</span></a>, where all the caveats of this option
|
| 33 |
+
are explained in detail.
|
| 34 |
+
</p></dd><dt><span class="term"><code class="option">[<span class="optional">-d</span>] <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">[<span class="optional">--dbname=</span>]<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 35 |
+
Specifies the name of the database to be reindexed,
|
| 36 |
+
when <code class="option">-a</code>/<code class="option">--all</code> is not used.
|
| 37 |
+
If this is not specified, the database name is read
|
| 38 |
+
from the environment variable <code class="envar">PGDATABASE</code>. If
|
| 39 |
+
that is not set, the user name specified for the connection is
|
| 40 |
+
used. The <em class="replaceable"><code>dbname</code></em> can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>. If so,
|
| 41 |
+
connection string parameters will override any conflicting command
|
| 42 |
+
line options.
|
| 43 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
|
| 44 |
+
Echo the commands that <span class="application">reindexdb</span> generates
|
| 45 |
+
and sends to the server.
|
| 46 |
+
</p></dd><dt><span class="term"><code class="option">-i <em class="replaceable"><code>index</code></em></code><br /></span><span class="term"><code class="option">--index=<em class="replaceable"><code>index</code></em></code></span></dt><dd><p>
|
| 47 |
+
Recreate <em class="replaceable"><code>index</code></em> only.
|
| 48 |
+
Multiple indexes can be recreated by writing multiple
|
| 49 |
+
<code class="option">-i</code> switches.
|
| 50 |
+
</p></dd><dt><span class="term"><code class="option">-j <em class="replaceable"><code>njobs</code></em></code><br /></span><span class="term"><code class="option">--jobs=<em class="replaceable"><code>njobs</code></em></code></span></dt><dd><p>
|
| 51 |
+
Execute the reindex commands in parallel by running
|
| 52 |
+
<em class="replaceable"><code>njobs</code></em>
|
| 53 |
+
commands simultaneously. This option may reduce the processing time
|
| 54 |
+
but it also increases the load on the database server.
|
| 55 |
+
</p><p>
|
| 56 |
+
<span class="application">reindexdb</span> will open
|
| 57 |
+
<em class="replaceable"><code>njobs</code></em> connections to the
|
| 58 |
+
database, so make sure your <a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a>
|
| 59 |
+
setting is high enough to accommodate all connections.
|
| 60 |
+
</p><p>
|
| 61 |
+
Note that this option is incompatible with the <code class="option">--index</code>
|
| 62 |
+
and <code class="option">--system</code> options.
|
| 63 |
+
</p></dd><dt><span class="term"><code class="option">-q</code><br /></span><span class="term"><code class="option">--quiet</code></span></dt><dd><p>
|
| 64 |
+
Do not display progress messages.
|
| 65 |
+
</p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--system</code></span></dt><dd><p>
|
| 66 |
+
Reindex database's system catalogs only.
|
| 67 |
+
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>schema</code></em></code><br /></span><span class="term"><code class="option">--schema=<em class="replaceable"><code>schema</code></em></code></span></dt><dd><p>
|
| 68 |
+
Reindex <em class="replaceable"><code>schema</code></em> only.
|
| 69 |
+
Multiple schemas can be reindexed by writing multiple
|
| 70 |
+
<code class="option">-S</code> switches.
|
| 71 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>table</code></em></code><br /></span><span class="term"><code class="option">--table=<em class="replaceable"><code>table</code></em></code></span></dt><dd><p>
|
| 72 |
+
Reindex <em class="replaceable"><code>table</code></em> only.
|
| 73 |
+
Multiple tables can be reindexed by writing multiple
|
| 74 |
+
<code class="option">-t</code> switches.
|
| 75 |
+
</p></dd><dt><span class="term"><code class="option">--tablespace=<em class="replaceable"><code>tablespace</code></em></code></span></dt><dd><p>
|
| 76 |
+
Specifies the tablespace where indexes are rebuilt. (This name is
|
| 77 |
+
processed as a double-quoted identifier.)
|
| 78 |
+
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 79 |
+
Print detailed information during processing.
|
| 80 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 81 |
+
Print the <span class="application">reindexdb</span> version and exit.
|
| 82 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 83 |
+
Show help about <span class="application">reindexdb</span> command line
|
| 84 |
+
arguments, and exit.
|
| 85 |
+
</p></dd></dl></div><p>
|
| 86 |
+
|
| 87 |
+
</p><p>
|
| 88 |
+
<span class="application">reindexdb</span> also accepts
|
| 89 |
+
the following command-line arguments for connection parameters:
|
| 90 |
+
|
| 91 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 92 |
+
Specifies the host name of the machine on which the server is
|
| 93 |
+
running. If the value begins with a slash, it is used as the
|
| 94 |
+
directory for the Unix domain socket.
|
| 95 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 96 |
+
Specifies the TCP port or local Unix domain socket file
|
| 97 |
+
extension on which the server
|
| 98 |
+
is listening for connections.
|
| 99 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 100 |
+
User name to connect as.
|
| 101 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 102 |
+
Never issue a password prompt. If the server requires
|
| 103 |
+
password authentication and a password is not available by
|
| 104 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 105 |
+
connection attempt will fail. This option can be useful in
|
| 106 |
+
batch jobs and scripts where no user is present to enter a
|
| 107 |
+
password.
|
| 108 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 109 |
+
Force <span class="application">reindexdb</span> to prompt for a
|
| 110 |
+
password before connecting to a database.
|
| 111 |
+
</p><p>
|
| 112 |
+
This option is never essential, since
|
| 113 |
+
<span class="application">reindexdb</span> will automatically prompt
|
| 114 |
+
for a password if the server demands password authentication.
|
| 115 |
+
However, <span class="application">reindexdb</span> will waste a
|
| 116 |
+
connection attempt finding out that the server wants a password.
|
| 117 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 118 |
+
connection attempt.
|
| 119 |
+
</p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 120 |
+
Specifies the name of the database to connect to to discover which
|
| 121 |
+
databases should be reindexed,
|
| 122 |
+
when <code class="option">-a</code>/<code class="option">--all</code> is used.
|
| 123 |
+
If not specified, the <code class="literal">postgres</code> database will be used,
|
| 124 |
+
or if that does not exist, <code class="literal">template1</code> will be used.
|
| 125 |
+
This can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection
|
| 126 |
+
string</a>. If so, connection string parameters will override any
|
| 127 |
+
conflicting command line options. Also, connection string parameters
|
| 128 |
+
other than the database name itself will be re-used when connecting
|
| 129 |
+
to other databases.
|
| 130 |
+
</p></dd></dl></div><p>
|
| 131 |
+
</p></div><div class="refsect1" id="id-1.9.4.21.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATABASE</code><br /></span><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 132 |
+
Default connection parameters
|
| 133 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 134 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 135 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 136 |
+
<code class="literal">never</code>.
|
| 137 |
+
</p></dd></dl></div><p>
|
| 138 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 139 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 140 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 141 |
+
</p></div><div class="refsect1" id="id-1.9.4.21.8"><h2>Diagnostics</h2><p>
|
| 142 |
+
In case of difficulty, see <a class="xref" href="sql-reindex.html" title="REINDEX"><span class="refentrytitle">REINDEX</span></a>
|
| 143 |
+
and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for
|
| 144 |
+
discussions of potential problems and error messages.
|
| 145 |
+
The database server must be running at the
|
| 146 |
+
targeted host. Also, any default connection settings and environment
|
| 147 |
+
variables used by the <span class="application">libpq</span> front-end
|
| 148 |
+
library will apply.
|
| 149 |
+
</p></div><div class="refsect1" id="id-1.9.4.21.9"><h2>Notes</h2><p>
|
| 150 |
+
<span class="application">reindexdb</span> might need to connect several
|
| 151 |
+
times to the <span class="productname">PostgreSQL</span> server, asking
|
| 152 |
+
for a password each time. It is convenient to have a
|
| 153 |
+
<code class="filename">~/.pgpass</code> file in such cases. See <a class="xref" href="libpq-pgpass.html" title="34.16. The Password File">Section 34.16</a> for more information.
|
| 154 |
+
</p></div><div class="refsect1" id="id-1.9.4.21.10"><h2>Examples</h2><p>
|
| 155 |
+
To reindex the database <code class="literal">test</code>:
|
| 156 |
+
</p><pre class="screen">
|
| 157 |
+
<code class="prompt">$ </code><strong class="userinput"><code>reindexdb test</code></strong>
|
| 158 |
+
</pre><p>
|
| 159 |
+
</p><p>
|
| 160 |
+
To reindex the table <code class="literal">foo</code> and the index
|
| 161 |
+
<code class="literal">bar</code> in a database named <code class="literal">abcd</code>:
|
| 162 |
+
</p><pre class="screen">
|
| 163 |
+
<code class="prompt">$ </code><strong class="userinput"><code>reindexdb --table=foo --index=bar abcd</code></strong>
|
| 164 |
+
</pre></div><div class="refsect1" id="id-1.9.4.21.11"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-reindex.html" title="REINDEX"><span class="refentrytitle">REINDEX</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-psql.html" title="psql">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-vacuumdb.html" title="vacuumdb">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">psql</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">vacuumdb</span></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/app-vacuumdb.html
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>vacuumdb</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-reindexdb.html" title="reindexdb" /><link rel="next" href="reference-server.html" title="PostgreSQL Server Applications" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">vacuumdb</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-reindexdb.html" title="reindexdb">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="reference-server.html" title="PostgreSQL Server Applications">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-VACUUMDB"><div class="titlepage"></div><a id="id-1.9.4.22.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">vacuumdb</span></span></h2><p>vacuumdb — garbage-collect and analyze a <span class="productname">PostgreSQL</span> database</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.22.4.1"><code class="command">vacuumdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...]
|
| 3 |
+
[
|
| 4 |
+
<code class="option">-t</code> | <code class="option">--table</code>
|
| 5 |
+
<em class="replaceable"><code>table</code></em>
|
| 6 |
+
[( <em class="replaceable"><code>column</code></em> [,...] )]
|
| 7 |
+
]
|
| 8 |
+
... [<em class="replaceable"><code>dbname</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.4.22.4.2"><code class="command">vacuumdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...]
|
| 9 |
+
[
|
| 10 |
+
|
| 11 |
+
[
|
| 12 |
+
<code class="option">-n</code> | <code class="option">--schema</code>
|
| 13 |
+
<em class="replaceable"><code>schema</code></em>
|
| 14 |
+
]
|
| 15 |
+
|
|
| 16 |
+
[
|
| 17 |
+
<code class="option">-N</code> | <code class="option">--exclude-schema</code>
|
| 18 |
+
<em class="replaceable"><code>schema</code></em>
|
| 19 |
+
]
|
| 20 |
+
|
| 21 |
+
]
|
| 22 |
+
... [<em class="replaceable"><code>dbname</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.4.22.4.3"><code class="command">vacuumdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] <code class="option">-a</code> | <code class="option">--all</code> </p></div></div><div class="refsect1" id="id-1.9.4.22.5"><h2>Description</h2><p>
|
| 23 |
+
<span class="application">vacuumdb</span> is a utility for cleaning a
|
| 24 |
+
<span class="productname">PostgreSQL</span> database.
|
| 25 |
+
<span class="application">vacuumdb</span> will also generate internal statistics
|
| 26 |
+
used by the <span class="productname">PostgreSQL</span> query optimizer.
|
| 27 |
+
</p><p>
|
| 28 |
+
<span class="application">vacuumdb</span> is a wrapper around the SQL
|
| 29 |
+
command <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>.
|
| 30 |
+
There is no effective difference between vacuuming and analyzing
|
| 31 |
+
databases via this utility and via other methods for accessing the
|
| 32 |
+
server.
|
| 33 |
+
</p></div><div class="refsect1" id="id-1.9.4.22.6"><h2>Options</h2><p>
|
| 34 |
+
<span class="application">vacuumdb</span> accepts the following command-line arguments:
|
| 35 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--all</code></span></dt><dd><p>
|
| 36 |
+
Vacuum all databases.
|
| 37 |
+
</p></dd><dt><span class="term"><code class="option">--buffer-usage-limit <em class="replaceable"><code>size</code></em></code></span></dt><dd><p>
|
| 38 |
+
Specifies the
|
| 39 |
+
<a class="glossterm" href="glossary.html#GLOSSARY-BUFFER-ACCESS-STRATEGY"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-BUFFER-ACCESS-STRATEGY" title="Buffer Access Strategy">Buffer Access Strategy</a></em></a>
|
| 40 |
+
ring buffer size for a given invocation of <span class="application">vacuumdb</span>.
|
| 41 |
+
This size is used to calculate the number of shared buffers which will
|
| 42 |
+
be reused as part of this strategy. See <a class="xref" href="sql-vacuum.html" title="VACUUM"><span class="refentrytitle">VACUUM</span></a>.
|
| 43 |
+
</p></dd><dt><span class="term"><code class="option">[<span class="optional">-d</span>] <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">[<span class="optional">--dbname=</span>]<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 44 |
+
Specifies the name of the database to be cleaned or analyzed,
|
| 45 |
+
when <code class="option">-a</code>/<code class="option">--all</code> is not used.
|
| 46 |
+
If this is not specified, the database name is read
|
| 47 |
+
from the environment variable <code class="envar">PGDATABASE</code>. If
|
| 48 |
+
that is not set, the user name specified for the connection is
|
| 49 |
+
used. The <em class="replaceable"><code>dbname</code></em> can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>. If so,
|
| 50 |
+
connection string parameters will override any conflicting command
|
| 51 |
+
line options.
|
| 52 |
+
</p></dd><dt><span class="term"><code class="option">--disable-page-skipping</code></span></dt><dd><p>
|
| 53 |
+
Disable skipping pages based on the contents of the visibility map.
|
| 54 |
+
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
|
| 55 |
+
Echo the commands that <span class="application">vacuumdb</span> generates
|
| 56 |
+
and sends to the server.
|
| 57 |
+
</p></dd><dt><span class="term"><code class="option">-f</code><br /></span><span class="term"><code class="option">--full</code></span></dt><dd><p>
|
| 58 |
+
Perform <span class="quote">“<span class="quote">full</span>”</span> vacuuming.
|
| 59 |
+
</p></dd><dt><span class="term"><code class="option">-F</code><br /></span><span class="term"><code class="option">--freeze</code></span></dt><dd><p>
|
| 60 |
+
Aggressively <span class="quote">“<span class="quote">freeze</span>”</span> tuples.
|
| 61 |
+
</p></dd><dt><span class="term"><code class="option">--force-index-cleanup</code></span></dt><dd><p>
|
| 62 |
+
Always remove index entries pointing to dead tuples.
|
| 63 |
+
</p></dd><dt><span class="term"><code class="option">-j <em class="replaceable"><code>njobs</code></em></code><br /></span><span class="term"><code class="option">--jobs=<em class="replaceable"><code>njobs</code></em></code></span></dt><dd><p>
|
| 64 |
+
Execute the vacuum or analyze commands in parallel by running
|
| 65 |
+
<em class="replaceable"><code>njobs</code></em>
|
| 66 |
+
commands simultaneously. This option may reduce the processing time
|
| 67 |
+
but it also increases the load on the database server.
|
| 68 |
+
</p><p>
|
| 69 |
+
<span class="application">vacuumdb</span> will open
|
| 70 |
+
<em class="replaceable"><code>njobs</code></em> connections to the
|
| 71 |
+
database, so make sure your <a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a>
|
| 72 |
+
setting is high enough to accommodate all connections.
|
| 73 |
+
</p><p>
|
| 74 |
+
Note that using this mode together with the <code class="option">-f</code>
|
| 75 |
+
(<code class="literal">FULL</code>) option might cause deadlock failures if
|
| 76 |
+
certain system catalogs are processed in parallel.
|
| 77 |
+
</p></dd><dt><span class="term"><code class="option">--min-mxid-age <em class="replaceable"><code>mxid_age</code></em></code></span></dt><dd><p>
|
| 78 |
+
Only execute the vacuum or analyze commands on tables with a multixact
|
| 79 |
+
ID age of at least <em class="replaceable"><code>mxid_age</code></em>.
|
| 80 |
+
This setting is useful for prioritizing tables to process to prevent
|
| 81 |
+
multixact ID wraparound (see
|
| 82 |
+
<a class="xref" href="routine-vacuuming.html#VACUUM-FOR-MULTIXACT-WRAPAROUND" title="25.1.5.1. Multixacts and Wraparound">Section 25.1.5.1</a>).
|
| 83 |
+
</p><p>
|
| 84 |
+
For the purposes of this option, the multixact ID age of a relation is
|
| 85 |
+
the greatest of the ages of the main relation and its associated
|
| 86 |
+
<acronym class="acronym">TOAST</acronym> table, if one exists. Since the commands
|
| 87 |
+
issued by <span class="application">vacuumdb</span> will also process the
|
| 88 |
+
<acronym class="acronym">TOAST</acronym> table for the relation if necessary, it does
|
| 89 |
+
not need to be considered separately.
|
| 90 |
+
</p></dd><dt><span class="term"><code class="option">--min-xid-age <em class="replaceable"><code>xid_age</code></em></code></span></dt><dd><p>
|
| 91 |
+
Only execute the vacuum or analyze commands on tables with a
|
| 92 |
+
transaction ID age of at least
|
| 93 |
+
<em class="replaceable"><code>xid_age</code></em>. This setting
|
| 94 |
+
is useful for prioritizing tables to process to prevent transaction
|
| 95 |
+
ID wraparound (see <a class="xref" href="routine-vacuuming.html#VACUUM-FOR-WRAPAROUND" title="25.1.5. Preventing Transaction ID Wraparound Failures">Section 25.1.5</a>).
|
| 96 |
+
</p><p>
|
| 97 |
+
For the purposes of this option, the transaction ID age of a relation
|
| 98 |
+
is the greatest of the ages of the main relation and its associated
|
| 99 |
+
<acronym class="acronym">TOAST</acronym> table, if one exists. Since the commands
|
| 100 |
+
issued by <span class="application">vacuumdb</span> will also process the
|
| 101 |
+
<acronym class="acronym">TOAST</acronym> table for the relation if necessary, it does
|
| 102 |
+
not need to be considered separately.
|
| 103 |
+
</p></dd><dt><span class="term"><code class="option">-n <em class="replaceable"><code>schema</code></em></code><br /></span><span class="term"><code class="option">--schema=<em class="replaceable"><code>schema</code></em></code></span></dt><dd><p>
|
| 104 |
+
Clean or analyze all tables in
|
| 105 |
+
<em class="replaceable"><code>schema</code></em> only. Multiple
|
| 106 |
+
schemas can be vacuumed by writing multiple <code class="option">-n</code> switches.
|
| 107 |
+
</p></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>schema</code></em></code><br /></span><span class="term"><code class="option">--exclude-schema=<em class="replaceable"><code>schema</code></em></code></span></dt><dd><p>
|
| 108 |
+
Do not clean or analyze any tables in
|
| 109 |
+
<em class="replaceable"><code>schema</code></em>. Multiple schemas
|
| 110 |
+
can be excluded by writing multiple <code class="option">-N</code> switches.
|
| 111 |
+
</p></dd><dt><span class="term"><code class="option">--no-index-cleanup</code></span></dt><dd><p>
|
| 112 |
+
Do not remove index entries pointing to dead tuples.
|
| 113 |
+
</p></dd><dt><span class="term"><code class="option">--no-process-main</code></span></dt><dd><p>
|
| 114 |
+
Skip the main relation.
|
| 115 |
+
</p></dd><dt><span class="term"><code class="option">--no-process-toast</code></span></dt><dd><p>
|
| 116 |
+
Skip the TOAST table associated with the table to vacuum, if any.
|
| 117 |
+
</p></dd><dt><span class="term"><code class="option">--no-truncate</code></span></dt><dd><p>
|
| 118 |
+
Do not truncate empty pages at the end of the table.
|
| 119 |
+
</p></dd><dt><span class="term"><code class="option">-P <em class="replaceable"><code>parallel_workers</code></em></code><br /></span><span class="term"><code class="option">--parallel=<em class="replaceable"><code>parallel_workers</code></em></code></span></dt><dd><p>
|
| 120 |
+
Specify the number of parallel workers for <em class="firstterm">parallel vacuum</em>.
|
| 121 |
+
This allows the vacuum to leverage multiple CPUs to process indexes.
|
| 122 |
+
See <a class="xref" href="sql-vacuum.html" title="VACUUM"><span class="refentrytitle">VACUUM</span></a>.
|
| 123 |
+
</p></dd><dt><span class="term"><code class="option">-q</code><br /></span><span class="term"><code class="option">--quiet</code></span></dt><dd><p>
|
| 124 |
+
Do not display progress messages.
|
| 125 |
+
</p></dd><dt><span class="term"><code class="option">--skip-locked</code></span></dt><dd><p>
|
| 126 |
+
Skip relations that cannot be immediately locked for processing.
|
| 127 |
+
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>table</code></em> [ (<em class="replaceable"><code>column</code></em> [,...]) ]</code><br /></span><span class="term"><code class="option">--table=<em class="replaceable"><code>table</code></em> [ (<em class="replaceable"><code>column</code></em> [,...]) ]</code></span></dt><dd><p>
|
| 128 |
+
Clean or analyze <em class="replaceable"><code>table</code></em> only.
|
| 129 |
+
Column names can be specified only in conjunction with
|
| 130 |
+
the <code class="option">--analyze</code> or <code class="option">--analyze-only</code> options.
|
| 131 |
+
Multiple tables can be vacuumed by writing multiple
|
| 132 |
+
<code class="option">-t</code> switches.
|
| 133 |
+
</p><div class="tip"><h3 class="title">Tip</h3><p>
|
| 134 |
+
If you specify columns, you probably have to escape the parentheses
|
| 135 |
+
from the shell. (See examples below.)
|
| 136 |
+
</p></div></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
|
| 137 |
+
Print detailed information during processing.
|
| 138 |
+
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
| 139 |
+
Print the <span class="application">vacuumdb</span> version and exit.
|
| 140 |
+
</p></dd><dt><span class="term"><code class="option">-z</code><br /></span><span class="term"><code class="option">--analyze</code></span></dt><dd><p>
|
| 141 |
+
Also calculate statistics for use by the optimizer.
|
| 142 |
+
</p></dd><dt><span class="term"><code class="option">-Z</code><br /></span><span class="term"><code class="option">--analyze-only</code></span></dt><dd><p>
|
| 143 |
+
Only calculate statistics for use by the optimizer (no vacuum).
|
| 144 |
+
</p></dd><dt><span class="term"><code class="option">--analyze-in-stages</code></span></dt><dd><p>
|
| 145 |
+
Only calculate statistics for use by the optimizer (no vacuum),
|
| 146 |
+
like <code class="option">--analyze-only</code>. Run three
|
| 147 |
+
stages of analyze; the first stage uses the lowest possible statistics
|
| 148 |
+
target (see <a class="xref" href="runtime-config-query.html#GUC-DEFAULT-STATISTICS-TARGET">default_statistics_target</a>)
|
| 149 |
+
to produce usable statistics faster, and subsequent stages build the
|
| 150 |
+
full statistics.
|
| 151 |
+
</p><p>
|
| 152 |
+
This option is only useful to analyze a database that currently has
|
| 153 |
+
no statistics or has wholly incorrect ones, such as if it is newly
|
| 154 |
+
populated from a restored dump or by <code class="command">pg_upgrade</code>.
|
| 155 |
+
Be aware that running with this option in a database with existing
|
| 156 |
+
statistics may cause the query optimizer choices to become
|
| 157 |
+
transiently worse due to the low statistics targets of the early
|
| 158 |
+
stages.
|
| 159 |
+
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
|
| 160 |
+
Show help about <span class="application">vacuumdb</span> command line
|
| 161 |
+
arguments, and exit.
|
| 162 |
+
</p></dd></dl></div><p>
|
| 163 |
+
</p><p>
|
| 164 |
+
<span class="application">vacuumdb</span> also accepts
|
| 165 |
+
the following command-line arguments for connection parameters:
|
| 166 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
|
| 167 |
+
Specifies the host name of the machine on which the server
|
| 168 |
+
is running. If the value begins with a slash, it is used
|
| 169 |
+
as the directory for the Unix domain socket.
|
| 170 |
+
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
|
| 171 |
+
Specifies the TCP port or local Unix domain socket file
|
| 172 |
+
extension on which the server
|
| 173 |
+
is listening for connections.
|
| 174 |
+
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
|
| 175 |
+
User name to connect as.
|
| 176 |
+
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
|
| 177 |
+
Never issue a password prompt. If the server requires
|
| 178 |
+
password authentication and a password is not available by
|
| 179 |
+
other means such as a <code class="filename">.pgpass</code> file, the
|
| 180 |
+
connection attempt will fail. This option can be useful in
|
| 181 |
+
batch jobs and scripts where no user is present to enter a
|
| 182 |
+
password.
|
| 183 |
+
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
|
| 184 |
+
Force <span class="application">vacuumdb</span> to prompt for a
|
| 185 |
+
password before connecting to a database.
|
| 186 |
+
</p><p>
|
| 187 |
+
This option is never essential, since
|
| 188 |
+
<span class="application">vacuumdb</span> will automatically prompt
|
| 189 |
+
for a password if the server demands password authentication.
|
| 190 |
+
However, <span class="application">vacuumdb</span> will waste a
|
| 191 |
+
connection attempt finding out that the server wants a password.
|
| 192 |
+
In some cases it is worth typing <code class="option">-W</code> to avoid the extra
|
| 193 |
+
connection attempt.
|
| 194 |
+
</p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
|
| 195 |
+
Specifies the name of the database to connect to to discover which
|
| 196 |
+
databases should be vacuumed,
|
| 197 |
+
when <code class="option">-a</code>/<code class="option">--all</code> is used.
|
| 198 |
+
If not specified, the <code class="literal">postgres</code> database will be used,
|
| 199 |
+
or if that does not exist, <code class="literal">template1</code> will be used.
|
| 200 |
+
This can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection
|
| 201 |
+
string</a>. If so, connection string parameters will override any
|
| 202 |
+
conflicting command line options. Also, connection string parameters
|
| 203 |
+
other than the database name itself will be re-used when connecting
|
| 204 |
+
to other databases.
|
| 205 |
+
</p></dd></dl></div><p>
|
| 206 |
+
</p></div><div class="refsect1" id="id-1.9.4.22.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATABASE</code><br /></span><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
|
| 207 |
+
Default connection parameters
|
| 208 |
+
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
|
| 209 |
+
Specifies whether to use color in diagnostic messages. Possible values
|
| 210 |
+
are <code class="literal">always</code>, <code class="literal">auto</code> and
|
| 211 |
+
<code class="literal">never</code>.
|
| 212 |
+
</p></dd></dl></div><p>
|
| 213 |
+
This utility, like most other <span class="productname">PostgreSQL</span> utilities,
|
| 214 |
+
also uses the environment variables supported by <span class="application">libpq</span>
|
| 215 |
+
(see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).
|
| 216 |
+
</p></div><div class="refsect1" id="id-1.9.4.22.8"><h2>Diagnostics</h2><p>
|
| 217 |
+
In case of difficulty, see <a class="xref" href="sql-vacuum.html" title="VACUUM"><span class="refentrytitle">VACUUM</span></a>
|
| 218 |
+
and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for
|
| 219 |
+
discussions of potential problems and error messages.
|
| 220 |
+
The database server must be running at the
|
| 221 |
+
targeted host. Also, any default connection settings and environment
|
| 222 |
+
variables used by the <span class="application">libpq</span> front-end
|
| 223 |
+
library will apply.
|
| 224 |
+
</p></div><div class="refsect1" id="id-1.9.4.22.9"><h2>Notes</h2><p>
|
| 225 |
+
<span class="application">vacuumdb</span> might need to connect several
|
| 226 |
+
times to the <span class="productname">PostgreSQL</span> server, asking
|
| 227 |
+
for a password each time. It is convenient to have a
|
| 228 |
+
<code class="filename">~/.pgpass</code> file in such cases. See <a class="xref" href="libpq-pgpass.html" title="34.16. The Password File">Section 34.16</a> for more information.
|
| 229 |
+
</p></div><div class="refsect1" id="id-1.9.4.22.10"><h2>Examples</h2><p>
|
| 230 |
+
To clean the database <code class="literal">test</code>:
|
| 231 |
+
</p><pre class="screen">
|
| 232 |
+
<code class="prompt">$ </code><strong class="userinput"><code>vacuumdb test</code></strong>
|
| 233 |
+
</pre><p>
|
| 234 |
+
</p><p>
|
| 235 |
+
To clean and analyze for the optimizer a database named
|
| 236 |
+
<code class="literal">bigdb</code>:
|
| 237 |
+
</p><pre class="screen">
|
| 238 |
+
<code class="prompt">$ </code><strong class="userinput"><code>vacuumdb --analyze bigdb</code></strong>
|
| 239 |
+
</pre><p>
|
| 240 |
+
</p><p>
|
| 241 |
+
To clean a single table
|
| 242 |
+
<code class="literal">foo</code> in a database named
|
| 243 |
+
<code class="literal">xyzzy</code>, and analyze a single column
|
| 244 |
+
<code class="literal">bar</code> of the table for the optimizer:
|
| 245 |
+
</p><pre class="screen">
|
| 246 |
+
<code class="prompt">$ </code><strong class="userinput"><code>vacuumdb --analyze --verbose --table='foo(bar)' xyzzy</code></strong>
|
| 247 |
+
</pre><p>
|
| 248 |
+
To clean all tables in the <code class="literal">foo</code> and <code class="literal">bar</code> schemas
|
| 249 |
+
in a database named <code class="literal">xyzzy</code>:
|
| 250 |
+
</p><pre class="screen">
|
| 251 |
+
<code class="prompt">$ </code><strong class="userinput"><code>vacuumdb --schema='foo' --schema='bar' xyzzy</code></strong>
|
| 252 |
+
</pre></div><div class="refsect1" id="id-1.9.4.22.11"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-vacuum.html" title="VACUUM"><span class="refentrytitle">VACUUM</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-reindexdb.html" title="reindexdb">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="reference-server.html" title="PostgreSQL Server Applications">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">reindexdb</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> PostgreSQL Server Applications</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/appendix-obsolete.html
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Appendix O. Obsolete or Renamed Features</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="color-which.html" title="N.2. Configuring the Colors" /><link rel="next" href="recovery-config.html" title="O.1. recovery.conf file merged into postgresql.conf" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Appendix O. Obsolete or Renamed Features</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="color-which.html" title="N.2. Configuring the Colors">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="appendixes.html" title="Part VIII. Appendixes">Up</a></td><th width="60%" align="center">Part VIII. Appendixes</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="recovery-config.html" title="O.1. recovery.conf file merged into postgresql.conf">Next</a></td></tr></table><hr /></div><div class="appendix" id="APPENDIX-OBSOLETE"><div class="titlepage"><div><div><h2 class="title">Appendix O. Obsolete or Renamed Features</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="recovery-config.html">O.1. <code class="filename">recovery.conf</code> file merged into <code class="filename">postgresql.conf</code></a></span></dt><dt><span class="sect1"><a href="default-roles.html">O.2. Default Roles Renamed to Predefined Roles</a></span></dt><dt><span class="sect1"><a href="pgxlogdump.html">O.3. <code class="command">pg_xlogdump</code> renamed to <code class="command">pg_waldump</code></a></span></dt><dt><span class="sect1"><a href="app-pgresetxlog.html">O.4. <code class="command">pg_resetxlog</code> renamed to <code class="command">pg_resetwal</code></a></span></dt><dt><span class="sect1"><a href="app-pgreceivexlog.html">O.5. <code class="command">pg_receivexlog</code> renamed to <code class="command">pg_receivewal</code></a></span></dt></dl></div><p>
|
| 3 |
+
Functionality is sometimes removed from PostgreSQL, feature, setting
|
| 4 |
+
and file names sometimes change, or documentation moves to different
|
| 5 |
+
places. This section directs users coming from old versions of the
|
| 6 |
+
documentation or from external links to the appropriate new location
|
| 7 |
+
for the information they need.
|
| 8 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="color-which.html" title="N.2. Configuring the Colors">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendixes.html" title="Part VIII. Appendixes">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="recovery-config.html" title="O.1. recovery.conf file merged into postgresql.conf">Next</a></td></tr><tr><td width="40%" align="left" valign="top">N.2. Configuring the Colors </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> O.1. <code class="filename">recovery.conf</code> file merged into <code class="filename">postgresql.conf</code></td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/appendixes.html
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Part VIII. Appendixes</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="backup-manifest-wal-ranges.html" title="77.3. Backup Manifest WAL Range Object" /><link rel="next" href="errcodes-appendix.html" title="Appendix A. PostgreSQL Error Codes" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Part VIII. Appendixes</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="backup-manifest-wal-ranges.html" title="77.3. Backup Manifest WAL Range Object">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="index.html" title="PostgreSQL 16.3 Documentation">Up</a></td><th width="60%" align="center">PostgreSQL 16.3 Documentation</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="errcodes-appendix.html" title="Appendix A. PostgreSQL Error Codes">Next</a></td></tr></table><hr /></div><div class="part" id="APPENDIXES"><div class="titlepage"><div><div><h1 class="title">Part VIII. Appendixes</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="appendix"><a href="errcodes-appendix.html">A. <span class="productname">PostgreSQL</span> Error Codes</a></span></dt><dt><span class="appendix"><a href="datetime-appendix.html">B. Date/Time Support</a></span></dt><dd><dl><dt><span class="sect1"><a href="datetime-input-rules.html">B.1. Date/Time Input Interpretation</a></span></dt><dt><span class="sect1"><a href="datetime-invalid-input.html">B.2. Handling of Invalid or Ambiguous Timestamps</a></span></dt><dt><span class="sect1"><a href="datetime-keywords.html">B.3. Date/Time Key Words</a></span></dt><dt><span class="sect1"><a href="datetime-config-files.html">B.4. Date/Time Configuration Files</a></span></dt><dt><span class="sect1"><a href="datetime-posix-timezone-specs.html">B.5. <acronym class="acronym">POSIX</acronym> Time Zone Specifications</a></span></dt><dt><span class="sect1"><a href="datetime-units-history.html">B.6. History of Units</a></span></dt><dt><span class="sect1"><a href="datetime-julian-dates.html">B.7. Julian Dates</a></span></dt></dl></dd><dt><span class="appendix"><a href="sql-keywords-appendix.html">C. <acronym class="acronym">SQL</acronym> Key Words</a></span></dt><dt><span class="appendix"><a href="features.html">D. SQL Conformance</a></span></dt><dd><dl><dt><span class="sect1"><a href="features-sql-standard.html">D.1. Supported Features</a></span></dt><dt><span class="sect1"><a href="unsupported-features-sql-standard.html">D.2. Unsupported Features</a></span></dt><dt><span class="sect1"><a href="xml-limits-conformance.html">D.3. XML Limits and Conformance to SQL/XML</a></span></dt></dl></dd><dt><span class="appendix"><a href="release.html">E. Release Notes</a></span></dt><dd><dl><dt><span class="sect1"><a href="release-16-3.html">E.1. Release 16.3</a></span></dt><dt><span class="sect1"><a href="release-16-2.html">E.2. Release 16.2</a></span></dt><dt><span class="sect1"><a href="release-16-1.html">E.3. Release 16.1</a></span></dt><dt><span class="sect1"><a href="release-16.html">E.4. Release 16</a></span></dt><dt><span class="sect1"><a href="release-prior.html">E.5. Prior Releases</a></span></dt></dl></dd><dt><span class="appendix"><a href="contrib.html">F. Additional Supplied Modules and Extensions</a></span></dt><dd><dl><dt><span class="sect1"><a href="adminpack.html">F.1. adminpack — pgAdmin support toolpack</a></span></dt><dt><span class="sect1"><a href="amcheck.html">F.2. amcheck — tools to verify table and index consistency</a></span></dt><dt><span class="sect1"><a href="auth-delay.html">F.3. auth_delay — pause on authentication failure</a></span></dt><dt><span class="sect1"><a href="auto-explain.html">F.4. auto_explain — log execution plans of slow queries</a></span></dt><dt><span class="sect1"><a href="basebackup-to-shell.html">F.5. basebackup_to_shell — example "shell" pg_basebackup module</a></span></dt><dt><span class="sect1"><a href="basic-archive.html">F.6. basic_archive — an example WAL archive module</a></span></dt><dt><span class="sect1"><a href="bloom.html">F.7. bloom — bloom filter index access method</a></span></dt><dt><span class="sect1"><a href="btree-gin.html">F.8. btree_gin — GIN operator classes with B-tree behavior</a></span></dt><dt><span class="sect1"><a href="btree-gist.html">F.9. btree_gist — GiST operator classes with B-tree behavior</a></span></dt><dt><span class="sect1"><a href="citext.html">F.10. citext — a case-insensitive character string type</a></span></dt><dt><span class="sect1"><a href="cube.html">F.11. cube — a multi-dimensional cube data type</a></span></dt><dt><span class="sect1"><a href="dblink.html">F.12. dblink — connect to other PostgreSQL databases</a></span></dt><dt><span class="sect1"><a href="dict-int.html">F.13. dict_int —
|
| 3 |
+
example full-text search dictionary for integers</a></span></dt><dt><span class="sect1"><a href="dict-xsyn.html">F.14. dict_xsyn — example synonym full-text search dictionary</a></span></dt><dt><span class="sect1"><a href="earthdistance.html">F.15. earthdistance — calculate great-circle distances</a></span></dt><dt><span class="sect1"><a href="file-fdw.html">F.16. file_fdw — access data files in the server's file system</a></span></dt><dt><span class="sect1"><a href="fuzzystrmatch.html">F.17. fuzzystrmatch — determine string similarities and distance</a></span></dt><dt><span class="sect1"><a href="hstore.html">F.18. hstore — hstore key/value datatype</a></span></dt><dt><span class="sect1"><a href="intagg.html">F.19. intagg — integer aggregator and enumerator</a></span></dt><dt><span class="sect1"><a href="intarray.html">F.20. intarray — manipulate arrays of integers</a></span></dt><dt><span class="sect1"><a href="isn.html">F.21. isn — data types for international standard numbers (ISBN, EAN, UPC, etc.)</a></span></dt><dt><span class="sect1"><a href="lo.html">F.22. lo — manage large objects</a></span></dt><dt><span class="sect1"><a href="ltree.html">F.23. ltree — hierarchical tree-like data type</a></span></dt><dt><span class="sect1"><a href="oldsnapshot.html">F.24. old_snapshot — inspect <code class="literal">old_snapshot_threshold</code> state</a></span></dt><dt><span class="sect1"><a href="pageinspect.html">F.25. pageinspect — low-level inspection of database pages</a></span></dt><dt><span class="sect1"><a href="passwordcheck.html">F.26. passwordcheck — verify password strength</a></span></dt><dt><span class="sect1"><a href="pgbuffercache.html">F.27. pg_buffercache — inspect <span class="productname">PostgreSQL</span>
|
| 4 |
+
buffer cache state</a></span></dt><dt><span class="sect1"><a href="pgcrypto.html">F.28. pgcrypto — cryptographic functions</a></span></dt><dt><span class="sect1"><a href="pgfreespacemap.html">F.29. pg_freespacemap — examine the free space map</a></span></dt><dt><span class="sect1"><a href="pgprewarm.html">F.30. pg_prewarm — preload relation data into buffer caches</a></span></dt><dt><span class="sect1"><a href="pgrowlocks.html">F.31. pgrowlocks — show a table's row locking information</a></span></dt><dt><span class="sect1"><a href="pgstatstatements.html">F.32. pg_stat_statements — track statistics of SQL planning and execution</a></span></dt><dt><span class="sect1"><a href="pgstattuple.html">F.33. pgstattuple — obtain tuple-level statistics</a></span></dt><dt><span class="sect1"><a href="pgsurgery.html">F.34. pg_surgery — perform low-level surgery on relation data</a></span></dt><dt><span class="sect1"><a href="pgtrgm.html">F.35. pg_trgm —
|
| 5 |
+
support for similarity of text using trigram matching</a></span></dt><dt><span class="sect1"><a href="pgvisibility.html">F.36. pg_visibility — visibility map information and utilities</a></span></dt><dt><span class="sect1"><a href="pgwalinspect.html">F.37. pg_walinspect — low-level WAL inspection</a></span></dt><dt><span class="sect1"><a href="postgres-fdw.html">F.38. postgres_fdw —
|
| 6 |
+
access data stored in external <span class="productname">PostgreSQL</span>
|
| 7 |
+
servers</a></span></dt><dt><span class="sect1"><a href="seg.html">F.39. seg — a datatype for line segments or floating point intervals</a></span></dt><dt><span class="sect1"><a href="sepgsql.html">F.40. sepgsql —
|
| 8 |
+
SELinux-, label-based mandatory access control (MAC) security module</a></span></dt><dt><span class="sect1"><a href="contrib-spi.html">F.41. spi — Server Programming Interface features/examples</a></span></dt><dt><span class="sect1"><a href="sslinfo.html">F.42. sslinfo — obtain client SSL information</a></span></dt><dt><span class="sect1"><a href="tablefunc.html">F.43. tablefunc — functions that return tables (<code class="function">crosstab</code> and others)</a></span></dt><dt><span class="sect1"><a href="tcn.html">F.44. tcn — a trigger function to notify listeners of changes to table content</a></span></dt><dt><span class="sect1"><a href="test-decoding.html">F.45. test_decoding — SQL-based test/example module for WAL logical decoding</a></span></dt><dt><span class="sect1"><a href="tsm-system-rows.html">F.46. tsm_system_rows —
|
| 9 |
+
the <code class="literal">SYSTEM_ROWS</code> sampling method for <code class="literal">TABLESAMPLE</code></a></span></dt><dt><span class="sect1"><a href="tsm-system-time.html">F.47. tsm_system_time —
|
| 10 |
+
the <code class="literal">SYSTEM_TIME</code> sampling method for <code class="literal">TABLESAMPLE</code></a></span></dt><dt><span class="sect1"><a href="unaccent.html">F.48. unaccent — a text search dictionary which removes diacritics</a></span></dt><dt><span class="sect1"><a href="uuid-ossp.html">F.49. uuid-ossp — a UUID generator</a></span></dt><dt><span class="sect1"><a href="xml2.html">F.50. xml2 — XPath querying and XSLT functionality</a></span></dt></dl></dd><dt><span class="appendix"><a href="contrib-prog.html">G. Additional Supplied Programs</a></span></dt><dd><dl><dt><span class="sect1"><a href="contrib-prog-client.html">G.1. Client Applications</a></span></dt><dt><span class="sect1"><a href="contrib-prog-server.html">G.2. Server Applications</a></span></dt></dl></dd><dt><span class="appendix"><a href="external-projects.html">H. External Projects</a></span></dt><dd><dl><dt><span class="sect1"><a href="external-interfaces.html">H.1. Client Interfaces</a></span></dt><dt><span class="sect1"><a href="external-admin-tools.html">H.2. Administration Tools</a></span></dt><dt><span class="sect1"><a href="external-pl.html">H.3. Procedural Languages</a></span></dt><dt><span class="sect1"><a href="external-extensions.html">H.4. Extensions</a></span></dt></dl></dd><dt><span class="appendix"><a href="sourcerepo.html">I. The Source Code Repository</a></span></dt><dd><dl><dt><span class="sect1"><a href="git.html">I.1. Getting the Source via <span class="productname">Git</span></a></span></dt></dl></dd><dt><span class="appendix"><a href="docguide.html">J. Documentation</a></span></dt><dd><dl><dt><span class="sect1"><a href="docguide-docbook.html">J.1. DocBook</a></span></dt><dt><span class="sect1"><a href="docguide-toolsets.html">J.2. Tool Sets</a></span></dt><dt><span class="sect1"><a href="docguide-build.html">J.3. Building the Documentation with Make</a></span></dt><dt><span class="sect1"><a href="docguide-build-meson.html">J.4. Building the Documentation with Meson</a></span></dt><dt><span class="sect1"><a href="docguide-authoring.html">J.5. Documentation Authoring</a></span></dt><dt><span class="sect1"><a href="docguide-style.html">J.6. Style Guide</a></span></dt></dl></dd><dt><span class="appendix"><a href="limits.html">K. <span class="productname">PostgreSQL</span> Limits</a></span></dt><dt><span class="appendix"><a href="acronyms.html">L. Acronyms</a></span></dt><dt><span class="appendix"><a href="glossary.html">M. Glossary</a></span></dt><dt><span class="appendix"><a href="color.html">N. Color Support</a></span></dt><dd><dl><dt><span class="sect1"><a href="color-when.html">N.1. When Color is Used</a></span></dt><dt><span class="sect1"><a href="color-which.html">N.2. Configuring the Colors</a></span></dt></dl></dd><dt><span class="appendix"><a href="appendix-obsolete.html">O. Obsolete or Renamed Features</a></span></dt><dd><dl><dt><span class="sect1"><a href="recovery-config.html">O.1. <code class="filename">recovery.conf</code> file merged into <code class="filename">postgresql.conf</code></a></span></dt><dt><span class="sect1"><a href="default-roles.html">O.2. Default Roles Renamed to Predefined Roles</a></span></dt><dt><span class="sect1"><a href="pgxlogdump.html">O.3. <code class="command">pg_xlogdump</code> renamed to <code class="command">pg_waldump</code></a></span></dt><dt><span class="sect1"><a href="app-pgresetxlog.html">O.4. <code class="command">pg_resetxlog</code> renamed to <code class="command">pg_resetwal</code></a></span></dt><dt><span class="sect1"><a href="app-pgreceivexlog.html">O.5. <code class="command">pg_receivexlog</code> renamed to <code class="command">pg_receivewal</code></a></span></dt></dl></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="backup-manifest-wal-ranges.html" title="77.3. Backup Manifest WAL Range Object">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html" title="PostgreSQL 16.3 Documentation">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="errcodes-appendix.html" title="Appendix A. PostgreSQL Error Codes">Next</a></td></tr><tr><td width="40%" align="left" valign="top">77.3. Backup Manifest WAL Range Object </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Appendix A. <span class="productname">PostgreSQL</span> Error Codes</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/applevel-consistency.html
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>13.4. Data Consistency Checks at the Application Level</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="explicit-locking.html" title="13.3. Explicit Locking" /><link rel="next" href="mvcc-serialization-failure-handling.html" title="13.5. Serialization Failure Handling" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">13.4. Data Consistency Checks at the Application Level</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="explicit-locking.html" title="13.3. Explicit Locking">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="mvcc.html" title="Chapter 13. Concurrency Control">Up</a></td><th width="60%" align="center">Chapter 13. Concurrency Control</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="mvcc-serialization-failure-handling.html" title="13.5. Serialization Failure Handling">Next</a></td></tr></table><hr /></div><div class="sect1" id="APPLEVEL-CONSISTENCY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">13.4. Data Consistency Checks at the Application Level <a href="#APPLEVEL-CONSISTENCY" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="applevel-consistency.html#SERIALIZABLE-CONSISTENCY">13.4.1. Enforcing Consistency with Serializable Transactions</a></span></dt><dt><span class="sect2"><a href="applevel-consistency.html#NON-SERIALIZABLE-CONSISTENCY">13.4.2. Enforcing Consistency with Explicit Blocking Locks</a></span></dt></dl></div><p>
|
| 3 |
+
It is very difficult to enforce business rules regarding data integrity
|
| 4 |
+
using Read Committed transactions because the view of the data is
|
| 5 |
+
shifting with each statement, and even a single statement may not
|
| 6 |
+
restrict itself to the statement's snapshot if a write conflict occurs.
|
| 7 |
+
</p><p>
|
| 8 |
+
While a Repeatable Read transaction has a stable view of the data
|
| 9 |
+
throughout its execution, there is a subtle issue with using
|
| 10 |
+
<acronym class="acronym">MVCC</acronym> snapshots for data consistency checks, involving
|
| 11 |
+
something known as <em class="firstterm">read/write conflicts</em>.
|
| 12 |
+
If one transaction writes data and a concurrent transaction attempts
|
| 13 |
+
to read the same data (whether before or after the write), it cannot
|
| 14 |
+
see the work of the other transaction. The reader then appears to have
|
| 15 |
+
executed first regardless of which started first or which committed
|
| 16 |
+
first. If that is as far as it goes, there is no problem, but
|
| 17 |
+
if the reader also writes data which is read by a concurrent transaction
|
| 18 |
+
there is now a transaction which appears to have run before either of
|
| 19 |
+
the previously mentioned transactions. If the transaction which appears
|
| 20 |
+
to have executed last actually commits first, it is very easy for a
|
| 21 |
+
cycle to appear in a graph of the order of execution of the transactions.
|
| 22 |
+
When such a cycle appears, integrity checks will not work correctly
|
| 23 |
+
without some help.
|
| 24 |
+
</p><p>
|
| 25 |
+
As mentioned in <a class="xref" href="transaction-iso.html#XACT-SERIALIZABLE" title="13.2.3. Serializable Isolation Level">Section 13.2.3</a>, Serializable
|
| 26 |
+
transactions are just Repeatable Read transactions which add
|
| 27 |
+
nonblocking monitoring for dangerous patterns of read/write conflicts.
|
| 28 |
+
When a pattern is detected which could cause a cycle in the apparent
|
| 29 |
+
order of execution, one of the transactions involved is rolled back to
|
| 30 |
+
break the cycle.
|
| 31 |
+
</p><div class="sect2" id="SERIALIZABLE-CONSISTENCY"><div class="titlepage"><div><div><h3 class="title">13.4.1. Enforcing Consistency with Serializable Transactions <a href="#SERIALIZABLE-CONSISTENCY" class="id_link">#</a></h3></div></div></div><p>
|
| 32 |
+
If the Serializable transaction isolation level is used for all writes
|
| 33 |
+
and for all reads which need a consistent view of the data, no other
|
| 34 |
+
effort is required to ensure consistency. Software from other
|
| 35 |
+
environments which is written to use serializable transactions to
|
| 36 |
+
ensure consistency should <span class="quote">“<span class="quote">just work</span>”</span> in this regard in
|
| 37 |
+
<span class="productname">PostgreSQL</span>.
|
| 38 |
+
</p><p>
|
| 39 |
+
When using this technique, it will avoid creating an unnecessary burden
|
| 40 |
+
for application programmers if the application software goes through a
|
| 41 |
+
framework which automatically retries transactions which are rolled
|
| 42 |
+
back with a serialization failure. It may be a good idea to set
|
| 43 |
+
<code class="literal">default_transaction_isolation</code> to <code class="literal">serializable</code>.
|
| 44 |
+
It would also be wise to take some action to ensure that no other
|
| 45 |
+
transaction isolation level is used, either inadvertently or to
|
| 46 |
+
subvert integrity checks, through checks of the transaction isolation
|
| 47 |
+
level in triggers.
|
| 48 |
+
</p><p>
|
| 49 |
+
See <a class="xref" href="transaction-iso.html#XACT-SERIALIZABLE" title="13.2.3. Serializable Isolation Level">Section 13.2.3</a> for performance suggestions.
|
| 50 |
+
</p><div class="warning"><h3 class="title">Warning: Serializable Transactions and Data Replication</h3><p>
|
| 51 |
+
This level of integrity protection using Serializable transactions
|
| 52 |
+
does not yet extend to hot standby mode (<a class="xref" href="hot-standby.html" title="27.4. Hot Standby">Section 27.4</a>)
|
| 53 |
+
or logical replicas.
|
| 54 |
+
Because of that, those using hot standby or logical replication
|
| 55 |
+
may want to use Repeatable Read and explicit locking on the primary.
|
| 56 |
+
</p></div></div><div class="sect2" id="NON-SERIALIZABLE-CONSISTENCY"><div class="titlepage"><div><div><h3 class="title">13.4.2. Enforcing Consistency with Explicit Blocking Locks <a href="#NON-SERIALIZABLE-CONSISTENCY" class="id_link">#</a></h3></div></div></div><p>
|
| 57 |
+
When non-serializable writes are possible,
|
| 58 |
+
to ensure the current validity of a row and protect it against
|
| 59 |
+
concurrent updates one must use <code class="command">SELECT FOR UPDATE</code>,
|
| 60 |
+
<code class="command">SELECT FOR SHARE</code>, or an appropriate <code class="command">LOCK
|
| 61 |
+
TABLE</code> statement. (<code class="command">SELECT FOR UPDATE</code>
|
| 62 |
+
and <code class="command">SELECT FOR SHARE</code> lock just the
|
| 63 |
+
returned rows against concurrent updates, while <code class="command">LOCK
|
| 64 |
+
TABLE</code> locks the whole table.) This should be taken into
|
| 65 |
+
account when porting applications to
|
| 66 |
+
<span class="productname">PostgreSQL</span> from other environments.
|
| 67 |
+
</p><p>
|
| 68 |
+
Also of note to those converting from other environments is the fact
|
| 69 |
+
that <code class="command">SELECT FOR UPDATE</code> does not ensure that a
|
| 70 |
+
concurrent transaction will not update or delete a selected row.
|
| 71 |
+
To do that in <span class="productname">PostgreSQL</span> you must actually
|
| 72 |
+
update the row, even if no values need to be changed.
|
| 73 |
+
<code class="command">SELECT FOR UPDATE</code> <span class="emphasis"><em>temporarily blocks</em></span>
|
| 74 |
+
other transactions from acquiring the same lock or executing an
|
| 75 |
+
<code class="command">UPDATE</code> or <code class="command">DELETE</code> which would
|
| 76 |
+
affect the locked row, but once the transaction holding this lock
|
| 77 |
+
commits or rolls back, a blocked transaction will proceed with the
|
| 78 |
+
conflicting operation unless an actual <code class="command">UPDATE</code> of
|
| 79 |
+
the row was performed while the lock was held.
|
| 80 |
+
</p><p>
|
| 81 |
+
Global validity checks require extra thought under
|
| 82 |
+
non-serializable <acronym class="acronym">MVCC</acronym>.
|
| 83 |
+
For example, a banking application might wish to check that the sum of
|
| 84 |
+
all credits in one table equals the sum of debits in another table,
|
| 85 |
+
when both tables are being actively updated. Comparing the results of two
|
| 86 |
+
successive <code class="literal">SELECT sum(...)</code> commands will not work reliably in
|
| 87 |
+
Read Committed mode, since the second query will likely include the results
|
| 88 |
+
of transactions not counted by the first. Doing the two sums in a
|
| 89 |
+
single repeatable read transaction will give an accurate picture of only the
|
| 90 |
+
effects of transactions that committed before the repeatable read transaction
|
| 91 |
+
started — but one might legitimately wonder whether the answer is still
|
| 92 |
+
relevant by the time it is delivered. If the repeatable read transaction
|
| 93 |
+
itself applied some changes before trying to make the consistency check,
|
| 94 |
+
the usefulness of the check becomes even more debatable, since now it
|
| 95 |
+
includes some but not all post-transaction-start changes. In such cases
|
| 96 |
+
a careful person might wish to lock all tables needed for the check,
|
| 97 |
+
in order to get an indisputable picture of current reality. A
|
| 98 |
+
<code class="literal">SHARE</code> mode (or higher) lock guarantees that there are no
|
| 99 |
+
uncommitted changes in the locked table, other than those of the current
|
| 100 |
+
transaction.
|
| 101 |
+
</p><p>
|
| 102 |
+
Note also that if one is relying on explicit locking to prevent concurrent
|
| 103 |
+
changes, one should either use Read Committed mode, or in Repeatable Read
|
| 104 |
+
mode be careful to obtain
|
| 105 |
+
locks before performing queries. A lock obtained by a
|
| 106 |
+
repeatable read transaction guarantees that no other transactions modifying
|
| 107 |
+
the table are still running, but if the snapshot seen by the
|
| 108 |
+
transaction predates obtaining the lock, it might predate some now-committed
|
| 109 |
+
changes in the table. A repeatable read transaction's snapshot is actually
|
| 110 |
+
frozen at the start of its first query or data-modification command
|
| 111 |
+
(<code class="literal">SELECT</code>, <code class="literal">INSERT</code>,
|
| 112 |
+
<code class="literal">UPDATE</code>, <code class="literal">DELETE</code>, or
|
| 113 |
+
<code class="literal">MERGE</code>), so it is possible to obtain locks explicitly
|
| 114 |
+
before the snapshot is frozen.
|
| 115 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="explicit-locking.html" title="13.3. Explicit Locking">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="mvcc.html" title="Chapter 13. Concurrency Control">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="mvcc-serialization-failure-handling.html" title="13.5. Serialization Failure Handling">Next</a></td></tr><tr><td width="40%" align="left" valign="top">13.3. Explicit Locking </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 13.5. Serialization Failure Handling</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/archive-module-callbacks.html
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>51.2. Archive Module Callbacks</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="archive-module-init.html" title="51.1. Initialization Functions" /><link rel="next" href="reference.html" title="Part VI. Reference" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">51.2. Archive Module Callbacks</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="archive-module-init.html" title="51.1. Initialization Functions">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="archive-modules.html" title="Chapter 51. Archive Modules">Up</a></td><th width="60%" align="center">Chapter 51. Archive Modules</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="reference.html" title="Part VI. Reference">Next</a></td></tr></table><hr /></div><div class="sect1" id="ARCHIVE-MODULE-CALLBACKS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">51.2. Archive Module Callbacks <a href="#ARCHIVE-MODULE-CALLBACKS" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="archive-module-callbacks.html#ARCHIVE-MODULE-STARTUP">51.2.1. Startup Callback</a></span></dt><dt><span class="sect2"><a href="archive-module-callbacks.html#ARCHIVE-MODULE-CHECK">51.2.2. Check Callback</a></span></dt><dt><span class="sect2"><a href="archive-module-callbacks.html#ARCHIVE-MODULE-ARCHIVE">51.2.3. Archive Callback</a></span></dt><dt><span class="sect2"><a href="archive-module-callbacks.html#ARCHIVE-MODULE-SHUTDOWN">51.2.4. Shutdown Callback</a></span></dt></dl></div><p>
|
| 3 |
+
The archive callbacks define the actual archiving behavior of the module.
|
| 4 |
+
The server will call them as required to process each individual WAL file.
|
| 5 |
+
</p><div class="sect2" id="ARCHIVE-MODULE-STARTUP"><div class="titlepage"><div><div><h3 class="title">51.2.1. Startup Callback <a href="#ARCHIVE-MODULE-STARTUP" class="id_link">#</a></h3></div></div></div><p>
|
| 6 |
+
The <code class="function">startup_cb</code> callback is called shortly after the
|
| 7 |
+
module is loaded. This callback can be used to perform any additional
|
| 8 |
+
initialization required. If the archive module has any state, it can use
|
| 9 |
+
<code class="structfield">state->private_data</code> to store it.
|
| 10 |
+
|
| 11 |
+
</p><pre class="programlisting">
|
| 12 |
+
typedef void (*ArchiveStartupCB) (ArchiveModuleState *state);
|
| 13 |
+
</pre><p>
|
| 14 |
+
</p></div><div class="sect2" id="ARCHIVE-MODULE-CHECK"><div class="titlepage"><div><div><h3 class="title">51.2.2. Check Callback <a href="#ARCHIVE-MODULE-CHECK" class="id_link">#</a></h3></div></div></div><p>
|
| 15 |
+
The <code class="function">check_configured_cb</code> callback is called to determine
|
| 16 |
+
whether the module is fully configured and ready to accept WAL files (e.g.,
|
| 17 |
+
its configuration parameters are set to valid values). If no
|
| 18 |
+
<code class="function">check_configured_cb</code> is defined, the server always
|
| 19 |
+
assumes the module is configured.
|
| 20 |
+
|
| 21 |
+
</p><pre class="programlisting">
|
| 22 |
+
typedef bool (*ArchiveCheckConfiguredCB) (ArchiveModuleState *state);
|
| 23 |
+
</pre><p>
|
| 24 |
+
|
| 25 |
+
If <code class="literal">true</code> is returned, the server will proceed with
|
| 26 |
+
archiving the file by calling the <code class="function">archive_file_cb</code>
|
| 27 |
+
callback. If <code class="literal">false</code> is returned, archiving will not
|
| 28 |
+
proceed, and the archiver will emit the following message to the server log:
|
| 29 |
+
</p><pre class="screen">
|
| 30 |
+
WARNING: archive_mode enabled, yet archiving is not configured
|
| 31 |
+
</pre><p>
|
| 32 |
+
In the latter case, the server will periodically call this function, and
|
| 33 |
+
archiving will proceed only when it returns <code class="literal">true</code>.
|
| 34 |
+
</p></div><div class="sect2" id="ARCHIVE-MODULE-ARCHIVE"><div class="titlepage"><div><div><h3 class="title">51.2.3. Archive Callback <a href="#ARCHIVE-MODULE-ARCHIVE" class="id_link">#</a></h3></div></div></div><p>
|
| 35 |
+
The <code class="function">archive_file_cb</code> callback is called to archive a
|
| 36 |
+
single WAL file.
|
| 37 |
+
|
| 38 |
+
</p><pre class="programlisting">
|
| 39 |
+
typedef bool (*ArchiveFileCB) (ArchiveModuleState *state, const char *file, const char *path);
|
| 40 |
+
</pre><p>
|
| 41 |
+
|
| 42 |
+
If <code class="literal">true</code> is returned, the server proceeds as if the file
|
| 43 |
+
was successfully archived, which may include recycling or removing the
|
| 44 |
+
original WAL file. If <code class="literal">false</code> is returned, the server will
|
| 45 |
+
keep the original WAL file and retry archiving later.
|
| 46 |
+
<em class="replaceable"><code>file</code></em> will contain just the file name of the WAL
|
| 47 |
+
file to archive, while <em class="replaceable"><code>path</code></em> contains the full
|
| 48 |
+
path of the WAL file (including the file name).
|
| 49 |
+
</p></div><div class="sect2" id="ARCHIVE-MODULE-SHUTDOWN"><div class="titlepage"><div><div><h3 class="title">51.2.4. Shutdown Callback <a href="#ARCHIVE-MODULE-SHUTDOWN" class="id_link">#</a></h3></div></div></div><p>
|
| 50 |
+
The <code class="function">shutdown_cb</code> callback is called when the archiver
|
| 51 |
+
process exits (e.g., after an error) or the value of
|
| 52 |
+
<a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-LIBRARY">archive_library</a> changes. If no
|
| 53 |
+
<code class="function">shutdown_cb</code> is defined, no special action is taken in
|
| 54 |
+
these situations. If the archive module has any state, this callback should
|
| 55 |
+
free it to avoid leaks.
|
| 56 |
+
|
| 57 |
+
</p><pre class="programlisting">
|
| 58 |
+
typedef void (*ArchiveShutdownCB) (ArchiveModuleState *state);
|
| 59 |
+
</pre><p>
|
| 60 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="archive-module-init.html" title="51.1. Initialization Functions">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="archive-modules.html" title="Chapter 51. Archive Modules">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="reference.html" title="Part VI. Reference">Next</a></td></tr><tr><td width="40%" align="left" valign="top">51.1. Initialization Functions </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Part VI. Reference</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/archive-module-init.html
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>51.1. Initialization Functions</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="archive-modules.html" title="Chapter 51. Archive Modules" /><link rel="next" href="archive-module-callbacks.html" title="51.2. Archive Module Callbacks" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">51.1. Initialization Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="archive-modules.html" title="Chapter 51. Archive Modules">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="archive-modules.html" title="Chapter 51. Archive Modules">Up</a></td><th width="60%" align="center">Chapter 51. Archive Modules</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="archive-module-callbacks.html" title="51.2. Archive Module Callbacks">Next</a></td></tr></table><hr /></div><div class="sect1" id="ARCHIVE-MODULE-INIT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">51.1. Initialization Functions <a href="#ARCHIVE-MODULE-INIT" class="id_link">#</a></h2></div></div></div><a id="id-1.8.16.7.2" class="indexterm"></a><p>
|
| 3 |
+
An archive library is loaded by dynamically loading a shared library with the
|
| 4 |
+
<a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-LIBRARY">archive_library</a>'s name as the library base name. The
|
| 5 |
+
normal library search path is used to locate the library. To provide the
|
| 6 |
+
required archive module callbacks and to indicate that the library is
|
| 7 |
+
actually an archive module, it needs to provide a function named
|
| 8 |
+
<code class="function">_PG_archive_module_init</code>. The result of the function
|
| 9 |
+
must be a pointer to a struct of type
|
| 10 |
+
<code class="structname">ArchiveModuleCallbacks</code>, which contains everything
|
| 11 |
+
that the core code needs to know to make use of the archive module. The
|
| 12 |
+
return value needs to be of server lifetime, which is typically achieved by
|
| 13 |
+
defining it as a <code class="literal">static const</code> variable in global scope.
|
| 14 |
+
|
| 15 |
+
</p><pre class="programlisting">
|
| 16 |
+
typedef struct ArchiveModuleCallbacks
|
| 17 |
+
{
|
| 18 |
+
ArchiveStartupCB startup_cb;
|
| 19 |
+
ArchiveCheckConfiguredCB check_configured_cb;
|
| 20 |
+
ArchiveFileCB archive_file_cb;
|
| 21 |
+
ArchiveShutdownCB shutdown_cb;
|
| 22 |
+
} ArchiveModuleCallbacks;
|
| 23 |
+
typedef const ArchiveModuleCallbacks *(*ArchiveModuleInit) (void);
|
| 24 |
+
</pre><p>
|
| 25 |
+
|
| 26 |
+
Only the <code class="function">archive_file_cb</code> callback is required. The
|
| 27 |
+
others are optional.
|
| 28 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="archive-modules.html" title="Chapter 51. Archive Modules">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="archive-modules.html" title="Chapter 51. Archive Modules">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="archive-module-callbacks.html" title="51.2. Archive Module Callbacks">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 51. Archive Modules </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 51.2. Archive Module Callbacks</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/archive-modules.html
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 51. Archive Modules</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="replication-origins.html" title="Chapter 50. Replication Progress Tracking" /><link rel="next" href="archive-module-init.html" title="51.1. Initialization Functions" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Chapter 51. Archive Modules</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="replication-origins.html" title="Chapter 50. Replication Progress Tracking">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="server-programming.html" title="Part V. Server Programming">Up</a></td><th width="60%" align="center">Part V. Server Programming</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="archive-module-init.html" title="51.1. Initialization Functions">Next</a></td></tr></table><hr /></div><div class="chapter" id="ARCHIVE-MODULES"><div class="titlepage"><div><div><h2 class="title">Chapter 51. Archive Modules</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="archive-module-init.html">51.1. Initialization Functions</a></span></dt><dt><span class="sect1"><a href="archive-module-callbacks.html">51.2. Archive Module Callbacks</a></span></dt><dd><dl><dt><span class="sect2"><a href="archive-module-callbacks.html#ARCHIVE-MODULE-STARTUP">51.2.1. Startup Callback</a></span></dt><dt><span class="sect2"><a href="archive-module-callbacks.html#ARCHIVE-MODULE-CHECK">51.2.2. Check Callback</a></span></dt><dt><span class="sect2"><a href="archive-module-callbacks.html#ARCHIVE-MODULE-ARCHIVE">51.2.3. Archive Callback</a></span></dt><dt><span class="sect2"><a href="archive-module-callbacks.html#ARCHIVE-MODULE-SHUTDOWN">51.2.4. Shutdown Callback</a></span></dt></dl></dd></dl></div><a id="id-1.8.16.2" class="indexterm"></a><p>
|
| 3 |
+
PostgreSQL provides infrastructure to create custom modules for continuous
|
| 4 |
+
archiving (see <a class="xref" href="continuous-archiving.html" title="26.3. Continuous Archiving and Point-in-Time Recovery (PITR)">Section 26.3</a>). While archiving via
|
| 5 |
+
a shell command (i.e., <a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-COMMAND">archive_command</a>) is much
|
| 6 |
+
simpler, a custom archive module will often be considerably more robust and
|
| 7 |
+
performant.
|
| 8 |
+
</p><p>
|
| 9 |
+
When a custom <a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-LIBRARY">archive_library</a> is configured, PostgreSQL
|
| 10 |
+
will submit completed WAL files to the module, and the server will avoid
|
| 11 |
+
recycling or removing these WAL files until the module indicates that the files
|
| 12 |
+
were successfully archived. It is ultimately up to the module to decide what
|
| 13 |
+
to do with each WAL file, but many recommendations are listed at
|
| 14 |
+
<a class="xref" href="continuous-archiving.html#BACKUP-ARCHIVING-WAL" title="26.3.1. Setting Up WAL Archiving">Section 26.3.1</a>.
|
| 15 |
+
</p><p>
|
| 16 |
+
Archiving modules must at least consist of an initialization function (see
|
| 17 |
+
<a class="xref" href="archive-module-init.html" title="51.1. Initialization Functions">Section 51.1</a>) and the required callbacks (see
|
| 18 |
+
<a class="xref" href="archive-module-callbacks.html" title="51.2. Archive Module Callbacks">Section 51.2</a>). However, archive modules are
|
| 19 |
+
also permitted to do much more (e.g., declare GUCs and register background
|
| 20 |
+
workers).
|
| 21 |
+
</p><p>
|
| 22 |
+
The <code class="filename">contrib/basic_archive</code> module contains a working
|
| 23 |
+
example, which demonstrates some useful techniques.
|
| 24 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="replication-origins.html" title="Chapter 50. Replication Progress Tracking">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="server-programming.html" title="Part V. Server Programming">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="archive-module-init.html" title="51.1. Initialization Functions">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 50. Replication Progress Tracking </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 51.1. Initialization Functions</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/arrays.html
ADDED
|
@@ -0,0 +1,647 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>8.15. Arrays</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="datatype-json.html" title="8.14. JSON Types" /><link rel="next" href="rowtypes.html" title="8.16. Composite Types" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">8.15. Arrays</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="datatype-json.html" title="8.14. JSON Types">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="datatype.html" title="Chapter 8. Data Types">Up</a></td><th width="60%" align="center">Chapter 8. Data Types</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="rowtypes.html" title="8.16. Composite Types">Next</a></td></tr></table><hr /></div><div class="sect1" id="ARRAYS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">8.15. Arrays <a href="#ARRAYS" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="arrays.html#ARRAYS-DECLARATION">8.15.1. Declaration of Array Types</a></span></dt><dt><span class="sect2"><a href="arrays.html#ARRAYS-INPUT">8.15.2. Array Value Input</a></span></dt><dt><span class="sect2"><a href="arrays.html#ARRAYS-ACCESSING">8.15.3. Accessing Arrays</a></span></dt><dt><span class="sect2"><a href="arrays.html#ARRAYS-MODIFYING">8.15.4. Modifying Arrays</a></span></dt><dt><span class="sect2"><a href="arrays.html#ARRAYS-SEARCHING">8.15.5. Searching in Arrays</a></span></dt><dt><span class="sect2"><a href="arrays.html#ARRAYS-IO">8.15.6. Array Input and Output Syntax</a></span></dt></dl></div><a id="id-1.5.7.23.2" class="indexterm"></a><p>
|
| 3 |
+
<span class="productname">PostgreSQL</span> allows columns of a table to be
|
| 4 |
+
defined as variable-length multidimensional arrays. Arrays of any
|
| 5 |
+
built-in or user-defined base type, enum type, composite type, range type,
|
| 6 |
+
or domain can be created.
|
| 7 |
+
</p><div class="sect2" id="ARRAYS-DECLARATION"><div class="titlepage"><div><div><h3 class="title">8.15.1. Declaration of Array Types <a href="#ARRAYS-DECLARATION" class="id_link">#</a></h3></div></div></div><a id="id-1.5.7.23.4.2" class="indexterm"></a><p>
|
| 8 |
+
To illustrate the use of array types, we create this table:
|
| 9 |
+
</p><pre class="programlisting">
|
| 10 |
+
CREATE TABLE sal_emp (
|
| 11 |
+
name text,
|
| 12 |
+
pay_by_quarter integer[],
|
| 13 |
+
schedule text[][]
|
| 14 |
+
);
|
| 15 |
+
</pre><p>
|
| 16 |
+
As shown, an array data type is named by appending square brackets
|
| 17 |
+
(<code class="literal">[]</code>) to the data type name of the array elements. The
|
| 18 |
+
above command will create a table named
|
| 19 |
+
<code class="structname">sal_emp</code> with a column of type
|
| 20 |
+
<code class="type">text</code> (<code class="structfield">name</code>), a
|
| 21 |
+
one-dimensional array of type <code class="type">integer</code>
|
| 22 |
+
(<code class="structfield">pay_by_quarter</code>), which represents the
|
| 23 |
+
employee's salary by quarter, and a two-dimensional array of
|
| 24 |
+
<code class="type">text</code> (<code class="structfield">schedule</code>), which
|
| 25 |
+
represents the employee's weekly schedule.
|
| 26 |
+
</p><p>
|
| 27 |
+
The syntax for <code class="command">CREATE TABLE</code> allows the exact size of
|
| 28 |
+
arrays to be specified, for example:
|
| 29 |
+
|
| 30 |
+
</p><pre class="programlisting">
|
| 31 |
+
CREATE TABLE tictactoe (
|
| 32 |
+
squares integer[3][3]
|
| 33 |
+
);
|
| 34 |
+
</pre><p>
|
| 35 |
+
|
| 36 |
+
However, the current implementation ignores any supplied array size
|
| 37 |
+
limits, i.e., the behavior is the same as for arrays of unspecified
|
| 38 |
+
length.
|
| 39 |
+
</p><p>
|
| 40 |
+
The current implementation does not enforce the declared
|
| 41 |
+
number of dimensions either. Arrays of a particular element type are
|
| 42 |
+
all considered to be of the same type, regardless of size or number
|
| 43 |
+
of dimensions. So, declaring the array size or number of dimensions in
|
| 44 |
+
<code class="command">CREATE TABLE</code> is simply documentation; it does not
|
| 45 |
+
affect run-time behavior.
|
| 46 |
+
</p><p>
|
| 47 |
+
An alternative syntax, which conforms to the SQL standard by using
|
| 48 |
+
the keyword <code class="literal">ARRAY</code>, can be used for one-dimensional arrays.
|
| 49 |
+
<code class="structfield">pay_by_quarter</code> could have been defined
|
| 50 |
+
as:
|
| 51 |
+
</p><pre class="programlisting">
|
| 52 |
+
pay_by_quarter integer ARRAY[4],
|
| 53 |
+
</pre><p>
|
| 54 |
+
Or, if no array size is to be specified:
|
| 55 |
+
</p><pre class="programlisting">
|
| 56 |
+
pay_by_quarter integer ARRAY,
|
| 57 |
+
</pre><p>
|
| 58 |
+
As before, however, <span class="productname">PostgreSQL</span> does not enforce the
|
| 59 |
+
size restriction in any case.
|
| 60 |
+
</p></div><div class="sect2" id="ARRAYS-INPUT"><div class="titlepage"><div><div><h3 class="title">8.15.2. Array Value Input <a href="#ARRAYS-INPUT" class="id_link">#</a></h3></div></div></div><a id="id-1.5.7.23.5.2" class="indexterm"></a><p>
|
| 61 |
+
To write an array value as a literal constant, enclose the element
|
| 62 |
+
values within curly braces and separate them by commas. (If you
|
| 63 |
+
know C, this is not unlike the C syntax for initializing
|
| 64 |
+
structures.) You can put double quotes around any element value,
|
| 65 |
+
and must do so if it contains commas or curly braces. (More
|
| 66 |
+
details appear below.) Thus, the general format of an array
|
| 67 |
+
constant is the following:
|
| 68 |
+
</p><pre class="synopsis">
|
| 69 |
+
'{ <em class="replaceable"><code>val1</code></em> <em class="replaceable"><code>delim</code></em> <em class="replaceable"><code>val2</code></em> <em class="replaceable"><code>delim</code></em> ... }'
|
| 70 |
+
</pre><p>
|
| 71 |
+
where <em class="replaceable"><code>delim</code></em> is the delimiter character
|
| 72 |
+
for the type, as recorded in its <code class="literal">pg_type</code> entry.
|
| 73 |
+
Among the standard data types provided in the
|
| 74 |
+
<span class="productname">PostgreSQL</span> distribution, all use a comma
|
| 75 |
+
(<code class="literal">,</code>), except for type <code class="type">box</code> which uses a semicolon
|
| 76 |
+
(<code class="literal">;</code>). Each <em class="replaceable"><code>val</code></em> is
|
| 77 |
+
either a constant of the array element type, or a subarray. An example
|
| 78 |
+
of an array constant is:
|
| 79 |
+
</p><pre class="programlisting">
|
| 80 |
+
'{{1,2,3},{4,5,6},{7,8,9}}'
|
| 81 |
+
</pre><p>
|
| 82 |
+
This constant is a two-dimensional, 3-by-3 array consisting of
|
| 83 |
+
three subarrays of integers.
|
| 84 |
+
</p><p>
|
| 85 |
+
To set an element of an array constant to NULL, write <code class="literal">NULL</code>
|
| 86 |
+
for the element value. (Any upper- or lower-case variant of
|
| 87 |
+
<code class="literal">NULL</code> will do.) If you want an actual string value
|
| 88 |
+
<span class="quote">“<span class="quote">NULL</span>”</span>, you must put double quotes around it.
|
| 89 |
+
</p><p>
|
| 90 |
+
(These kinds of array constants are actually only a special case of
|
| 91 |
+
the generic type constants discussed in <a class="xref" href="sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS-GENERIC" title="4.1.2.7. Constants of Other Types">Section 4.1.2.7</a>. The constant is initially
|
| 92 |
+
treated as a string and passed to the array input conversion
|
| 93 |
+
routine. An explicit type specification might be necessary.)
|
| 94 |
+
</p><p>
|
| 95 |
+
Now we can show some <code class="command">INSERT</code> statements:
|
| 96 |
+
|
| 97 |
+
</p><pre class="programlisting">
|
| 98 |
+
INSERT INTO sal_emp
|
| 99 |
+
VALUES ('Bill',
|
| 100 |
+
'{10000, 10000, 10000, 10000}',
|
| 101 |
+
'{{"meeting", "lunch"}, {"training", "presentation"}}');
|
| 102 |
+
|
| 103 |
+
INSERT INTO sal_emp
|
| 104 |
+
VALUES ('Carol',
|
| 105 |
+
'{20000, 25000, 25000, 25000}',
|
| 106 |
+
'{{"breakfast", "consulting"}, {"meeting", "lunch"}}');
|
| 107 |
+
</pre><p>
|
| 108 |
+
</p><p>
|
| 109 |
+
The result of the previous two inserts looks like this:
|
| 110 |
+
|
| 111 |
+
</p><pre class="programlisting">
|
| 112 |
+
SELECT * FROM sal_emp;
|
| 113 |
+
name | pay_by_quarter | schedule
|
| 114 |
+
-------+---------------------------+-------------------------------------------
|
| 115 |
+
Bill | {10000,10000,10000,10000} | {{meeting,lunch},{training,presentation}}
|
| 116 |
+
Carol | {20000,25000,25000,25000} | {{breakfast,consulting},{meeting,lunch}}
|
| 117 |
+
(2 rows)
|
| 118 |
+
</pre><p>
|
| 119 |
+
</p><p>
|
| 120 |
+
Multidimensional arrays must have matching extents for each
|
| 121 |
+
dimension. A mismatch causes an error, for example:
|
| 122 |
+
|
| 123 |
+
</p><pre class="programlisting">
|
| 124 |
+
INSERT INTO sal_emp
|
| 125 |
+
VALUES ('Bill',
|
| 126 |
+
'{10000, 10000, 10000, 10000}',
|
| 127 |
+
'{{"meeting", "lunch"}, {"meeting"}}');
|
| 128 |
+
ERROR: multidimensional arrays must have array expressions with matching dimensions
|
| 129 |
+
</pre><p>
|
| 130 |
+
</p><p>
|
| 131 |
+
The <code class="literal">ARRAY</code> constructor syntax can also be used:
|
| 132 |
+
</p><pre class="programlisting">
|
| 133 |
+
INSERT INTO sal_emp
|
| 134 |
+
VALUES ('Bill',
|
| 135 |
+
ARRAY[10000, 10000, 10000, 10000],
|
| 136 |
+
ARRAY[['meeting', 'lunch'], ['training', 'presentation']]);
|
| 137 |
+
|
| 138 |
+
INSERT INTO sal_emp
|
| 139 |
+
VALUES ('Carol',
|
| 140 |
+
ARRAY[20000, 25000, 25000, 25000],
|
| 141 |
+
ARRAY[['breakfast', 'consulting'], ['meeting', 'lunch']]);
|
| 142 |
+
</pre><p>
|
| 143 |
+
Notice that the array elements are ordinary SQL constants or
|
| 144 |
+
expressions; for instance, string literals are single quoted, instead of
|
| 145 |
+
double quoted as they would be in an array literal. The <code class="literal">ARRAY</code>
|
| 146 |
+
constructor syntax is discussed in more detail in
|
| 147 |
+
<a class="xref" href="sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS" title="4.2.12. Array Constructors">Section 4.2.12</a>.
|
| 148 |
+
</p></div><div class="sect2" id="ARRAYS-ACCESSING"><div class="titlepage"><div><div><h3 class="title">8.15.3. Accessing Arrays <a href="#ARRAYS-ACCESSING" class="id_link">#</a></h3></div></div></div><a id="id-1.5.7.23.6.2" class="indexterm"></a><p>
|
| 149 |
+
Now, we can run some queries on the table.
|
| 150 |
+
First, we show how to access a single element of an array.
|
| 151 |
+
This query retrieves the names of the employees whose pay changed in
|
| 152 |
+
the second quarter:
|
| 153 |
+
|
| 154 |
+
</p><pre class="programlisting">
|
| 155 |
+
SELECT name FROM sal_emp WHERE pay_by_quarter[1] <> pay_by_quarter[2];
|
| 156 |
+
|
| 157 |
+
name
|
| 158 |
+
-------
|
| 159 |
+
Carol
|
| 160 |
+
(1 row)
|
| 161 |
+
</pre><p>
|
| 162 |
+
|
| 163 |
+
The array subscript numbers are written within square brackets.
|
| 164 |
+
By default <span class="productname">PostgreSQL</span> uses a
|
| 165 |
+
one-based numbering convention for arrays, that is,
|
| 166 |
+
an array of <em class="replaceable"><code>n</code></em> elements starts with <code class="literal">array[1]</code> and
|
| 167 |
+
ends with <code class="literal">array[<em class="replaceable"><code>n</code></em>]</code>.
|
| 168 |
+
</p><p>
|
| 169 |
+
This query retrieves the third quarter pay of all employees:
|
| 170 |
+
|
| 171 |
+
</p><pre class="programlisting">
|
| 172 |
+
SELECT pay_by_quarter[3] FROM sal_emp;
|
| 173 |
+
|
| 174 |
+
pay_by_quarter
|
| 175 |
+
----------------
|
| 176 |
+
10000
|
| 177 |
+
25000
|
| 178 |
+
(2 rows)
|
| 179 |
+
</pre><p>
|
| 180 |
+
</p><p>
|
| 181 |
+
We can also access arbitrary rectangular slices of an array, or
|
| 182 |
+
subarrays. An array slice is denoted by writing
|
| 183 |
+
<code class="literal"><em class="replaceable"><code>lower-bound</code></em>:<em class="replaceable"><code>upper-bound</code></em></code>
|
| 184 |
+
for one or more array dimensions. For example, this query retrieves the first
|
| 185 |
+
item on Bill's schedule for the first two days of the week:
|
| 186 |
+
|
| 187 |
+
</p><pre class="programlisting">
|
| 188 |
+
SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill';
|
| 189 |
+
|
| 190 |
+
schedule
|
| 191 |
+
------------------------
|
| 192 |
+
{{meeting},{training}}
|
| 193 |
+
(1 row)
|
| 194 |
+
</pre><p>
|
| 195 |
+
|
| 196 |
+
If any dimension is written as a slice, i.e., contains a colon, then all
|
| 197 |
+
dimensions are treated as slices. Any dimension that has only a single
|
| 198 |
+
number (no colon) is treated as being from 1
|
| 199 |
+
to the number specified. For example, <code class="literal">[2]</code> is treated as
|
| 200 |
+
<code class="literal">[1:2]</code>, as in this example:
|
| 201 |
+
|
| 202 |
+
</p><pre class="programlisting">
|
| 203 |
+
SELECT schedule[1:2][2] FROM sal_emp WHERE name = 'Bill';
|
| 204 |
+
|
| 205 |
+
schedule
|
| 206 |
+
-------------------------------------------
|
| 207 |
+
{{meeting,lunch},{training,presentation}}
|
| 208 |
+
(1 row)
|
| 209 |
+
</pre><p>
|
| 210 |
+
|
| 211 |
+
To avoid confusion with the non-slice case, it's best to use slice syntax
|
| 212 |
+
for all dimensions, e.g., <code class="literal">[1:2][1:1]</code>, not <code class="literal">[2][1:1]</code>.
|
| 213 |
+
</p><p>
|
| 214 |
+
It is possible to omit the <em class="replaceable"><code>lower-bound</code></em> and/or
|
| 215 |
+
<em class="replaceable"><code>upper-bound</code></em> of a slice specifier; the missing
|
| 216 |
+
bound is replaced by the lower or upper limit of the array's subscripts.
|
| 217 |
+
For example:
|
| 218 |
+
|
| 219 |
+
</p><pre class="programlisting">
|
| 220 |
+
SELECT schedule[:2][2:] FROM sal_emp WHERE name = 'Bill';
|
| 221 |
+
|
| 222 |
+
schedule
|
| 223 |
+
------------------------
|
| 224 |
+
{{lunch},{presentation}}
|
| 225 |
+
(1 row)
|
| 226 |
+
|
| 227 |
+
SELECT schedule[:][1:1] FROM sal_emp WHERE name = 'Bill';
|
| 228 |
+
|
| 229 |
+
schedule
|
| 230 |
+
------------------------
|
| 231 |
+
{{meeting},{training}}
|
| 232 |
+
(1 row)
|
| 233 |
+
</pre><p>
|
| 234 |
+
</p><p>
|
| 235 |
+
An array subscript expression will return null if either the array itself or
|
| 236 |
+
any of the subscript expressions are null. Also, null is returned if a
|
| 237 |
+
subscript is outside the array bounds (this case does not raise an error).
|
| 238 |
+
For example, if <code class="literal">schedule</code>
|
| 239 |
+
currently has the dimensions <code class="literal">[1:3][1:2]</code> then referencing
|
| 240 |
+
<code class="literal">schedule[3][3]</code> yields NULL. Similarly, an array reference
|
| 241 |
+
with the wrong number of subscripts yields a null rather than an error.
|
| 242 |
+
</p><p>
|
| 243 |
+
An array slice expression likewise yields null if the array itself or
|
| 244 |
+
any of the subscript expressions are null. However, in other
|
| 245 |
+
cases such as selecting an array slice that
|
| 246 |
+
is completely outside the current array bounds, a slice expression
|
| 247 |
+
yields an empty (zero-dimensional) array instead of null. (This
|
| 248 |
+
does not match non-slice behavior and is done for historical reasons.)
|
| 249 |
+
If the requested slice partially overlaps the array bounds, then it
|
| 250 |
+
is silently reduced to just the overlapping region instead of
|
| 251 |
+
returning null.
|
| 252 |
+
</p><p>
|
| 253 |
+
The current dimensions of any array value can be retrieved with the
|
| 254 |
+
<code class="function">array_dims</code> function:
|
| 255 |
+
|
| 256 |
+
</p><pre class="programlisting">
|
| 257 |
+
SELECT array_dims(schedule) FROM sal_emp WHERE name = 'Carol';
|
| 258 |
+
|
| 259 |
+
array_dims
|
| 260 |
+
------------
|
| 261 |
+
[1:2][1:2]
|
| 262 |
+
(1 row)
|
| 263 |
+
</pre><p>
|
| 264 |
+
|
| 265 |
+
<code class="function">array_dims</code> produces a <code class="type">text</code> result,
|
| 266 |
+
which is convenient for people to read but perhaps inconvenient
|
| 267 |
+
for programs. Dimensions can also be retrieved with
|
| 268 |
+
<code class="function">array_upper</code> and <code class="function">array_lower</code>,
|
| 269 |
+
which return the upper and lower bound of a
|
| 270 |
+
specified array dimension, respectively:
|
| 271 |
+
|
| 272 |
+
</p><pre class="programlisting">
|
| 273 |
+
SELECT array_upper(schedule, 1) FROM sal_emp WHERE name = 'Carol';
|
| 274 |
+
|
| 275 |
+
array_upper
|
| 276 |
+
-------------
|
| 277 |
+
2
|
| 278 |
+
(1 row)
|
| 279 |
+
</pre><p>
|
| 280 |
+
|
| 281 |
+
<code class="function">array_length</code> will return the length of a specified
|
| 282 |
+
array dimension:
|
| 283 |
+
|
| 284 |
+
</p><pre class="programlisting">
|
| 285 |
+
SELECT array_length(schedule, 1) FROM sal_emp WHERE name = 'Carol';
|
| 286 |
+
|
| 287 |
+
array_length
|
| 288 |
+
--------------
|
| 289 |
+
2
|
| 290 |
+
(1 row)
|
| 291 |
+
</pre><p>
|
| 292 |
+
|
| 293 |
+
<code class="function">cardinality</code> returns the total number of elements in an
|
| 294 |
+
array across all dimensions. It is effectively the number of rows a call to
|
| 295 |
+
<code class="function">unnest</code> would yield:
|
| 296 |
+
|
| 297 |
+
</p><pre class="programlisting">
|
| 298 |
+
SELECT cardinality(schedule) FROM sal_emp WHERE name = 'Carol';
|
| 299 |
+
|
| 300 |
+
cardinality
|
| 301 |
+
-------------
|
| 302 |
+
4
|
| 303 |
+
(1 row)
|
| 304 |
+
</pre><p>
|
| 305 |
+
</p></div><div class="sect2" id="ARRAYS-MODIFYING"><div class="titlepage"><div><div><h3 class="title">8.15.4. Modifying Arrays <a href="#ARRAYS-MODIFYING" class="id_link">#</a></h3></div></div></div><a id="id-1.5.7.23.7.2" class="indexterm"></a><p>
|
| 306 |
+
An array value can be replaced completely:
|
| 307 |
+
|
| 308 |
+
</p><pre class="programlisting">
|
| 309 |
+
UPDATE sal_emp SET pay_by_quarter = '{25000,25000,27000,27000}'
|
| 310 |
+
WHERE name = 'Carol';
|
| 311 |
+
</pre><p>
|
| 312 |
+
|
| 313 |
+
or using the <code class="literal">ARRAY</code> expression syntax:
|
| 314 |
+
|
| 315 |
+
</p><pre class="programlisting">
|
| 316 |
+
UPDATE sal_emp SET pay_by_quarter = ARRAY[25000,25000,27000,27000]
|
| 317 |
+
WHERE name = 'Carol';
|
| 318 |
+
</pre><p>
|
| 319 |
+
|
| 320 |
+
An array can also be updated at a single element:
|
| 321 |
+
|
| 322 |
+
</p><pre class="programlisting">
|
| 323 |
+
UPDATE sal_emp SET pay_by_quarter[4] = 15000
|
| 324 |
+
WHERE name = 'Bill';
|
| 325 |
+
</pre><p>
|
| 326 |
+
|
| 327 |
+
or updated in a slice:
|
| 328 |
+
|
| 329 |
+
</p><pre class="programlisting">
|
| 330 |
+
UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
|
| 331 |
+
WHERE name = 'Carol';
|
| 332 |
+
</pre><p>
|
| 333 |
+
|
| 334 |
+
The slice syntaxes with omitted <em class="replaceable"><code>lower-bound</code></em> and/or
|
| 335 |
+
<em class="replaceable"><code>upper-bound</code></em> can be used too, but only when
|
| 336 |
+
updating an array value that is not NULL or zero-dimensional (otherwise,
|
| 337 |
+
there is no existing subscript limit to substitute).
|
| 338 |
+
</p><p>
|
| 339 |
+
A stored array value can be enlarged by assigning to elements not already
|
| 340 |
+
present. Any positions between those previously present and the newly
|
| 341 |
+
assigned elements will be filled with nulls. For example, if array
|
| 342 |
+
<code class="literal">myarray</code> currently has 4 elements, it will have six
|
| 343 |
+
elements after an update that assigns to <code class="literal">myarray[6]</code>;
|
| 344 |
+
<code class="literal">myarray[5]</code> will contain null.
|
| 345 |
+
Currently, enlargement in this fashion is only allowed for one-dimensional
|
| 346 |
+
arrays, not multidimensional arrays.
|
| 347 |
+
</p><p>
|
| 348 |
+
Subscripted assignment allows creation of arrays that do not use one-based
|
| 349 |
+
subscripts. For example one might assign to <code class="literal">myarray[-2:7]</code> to
|
| 350 |
+
create an array with subscript values from -2 to 7.
|
| 351 |
+
</p><p>
|
| 352 |
+
New array values can also be constructed using the concatenation operator,
|
| 353 |
+
<code class="literal">||</code>:
|
| 354 |
+
</p><pre class="programlisting">
|
| 355 |
+
SELECT ARRAY[1,2] || ARRAY[3,4];
|
| 356 |
+
?column?
|
| 357 |
+
-----------
|
| 358 |
+
{1,2,3,4}
|
| 359 |
+
(1 row)
|
| 360 |
+
|
| 361 |
+
SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];
|
| 362 |
+
?column?
|
| 363 |
+
---------------------
|
| 364 |
+
{{5,6},{1,2},{3,4}}
|
| 365 |
+
(1 row)
|
| 366 |
+
</pre><p>
|
| 367 |
+
</p><p>
|
| 368 |
+
The concatenation operator allows a single element to be pushed onto the
|
| 369 |
+
beginning or end of a one-dimensional array. It also accepts two
|
| 370 |
+
<em class="replaceable"><code>N</code></em>-dimensional arrays, or an <em class="replaceable"><code>N</code></em>-dimensional
|
| 371 |
+
and an <em class="replaceable"><code>N+1</code></em>-dimensional array.
|
| 372 |
+
</p><p>
|
| 373 |
+
When a single element is pushed onto either the beginning or end of a
|
| 374 |
+
one-dimensional array, the result is an array with the same lower bound
|
| 375 |
+
subscript as the array operand. For example:
|
| 376 |
+
</p><pre class="programlisting">
|
| 377 |
+
SELECT array_dims(1 || '[0:1]={2,3}'::int[]);
|
| 378 |
+
array_dims
|
| 379 |
+
------------
|
| 380 |
+
[0:2]
|
| 381 |
+
(1 row)
|
| 382 |
+
|
| 383 |
+
SELECT array_dims(ARRAY[1,2] || 3);
|
| 384 |
+
array_dims
|
| 385 |
+
------------
|
| 386 |
+
[1:3]
|
| 387 |
+
(1 row)
|
| 388 |
+
</pre><p>
|
| 389 |
+
</p><p>
|
| 390 |
+
When two arrays with an equal number of dimensions are concatenated, the
|
| 391 |
+
result retains the lower bound subscript of the left-hand operand's outer
|
| 392 |
+
dimension. The result is an array comprising every element of the left-hand
|
| 393 |
+
operand followed by every element of the right-hand operand. For example:
|
| 394 |
+
</p><pre class="programlisting">
|
| 395 |
+
SELECT array_dims(ARRAY[1,2] || ARRAY[3,4,5]);
|
| 396 |
+
array_dims
|
| 397 |
+
------------
|
| 398 |
+
[1:5]
|
| 399 |
+
(1 row)
|
| 400 |
+
|
| 401 |
+
SELECT array_dims(ARRAY[[1,2],[3,4]] || ARRAY[[5,6],[7,8],[9,0]]);
|
| 402 |
+
array_dims
|
| 403 |
+
------------
|
| 404 |
+
[1:5][1:2]
|
| 405 |
+
(1 row)
|
| 406 |
+
</pre><p>
|
| 407 |
+
</p><p>
|
| 408 |
+
When an <em class="replaceable"><code>N</code></em>-dimensional array is pushed onto the beginning
|
| 409 |
+
or end of an <em class="replaceable"><code>N+1</code></em>-dimensional array, the result is
|
| 410 |
+
analogous to the element-array case above. Each <em class="replaceable"><code>N</code></em>-dimensional
|
| 411 |
+
sub-array is essentially an element of the <em class="replaceable"><code>N+1</code></em>-dimensional
|
| 412 |
+
array's outer dimension. For example:
|
| 413 |
+
</p><pre class="programlisting">
|
| 414 |
+
SELECT array_dims(ARRAY[1,2] || ARRAY[[3,4],[5,6]]);
|
| 415 |
+
array_dims
|
| 416 |
+
------------
|
| 417 |
+
[1:3][1:2]
|
| 418 |
+
(1 row)
|
| 419 |
+
</pre><p>
|
| 420 |
+
</p><p>
|
| 421 |
+
An array can also be constructed by using the functions
|
| 422 |
+
<code class="function">array_prepend</code>, <code class="function">array_append</code>,
|
| 423 |
+
or <code class="function">array_cat</code>. The first two only support one-dimensional
|
| 424 |
+
arrays, but <code class="function">array_cat</code> supports multidimensional arrays.
|
| 425 |
+
Some examples:
|
| 426 |
+
|
| 427 |
+
</p><pre class="programlisting">
|
| 428 |
+
SELECT array_prepend(1, ARRAY[2,3]);
|
| 429 |
+
array_prepend
|
| 430 |
+
---------------
|
| 431 |
+
{1,2,3}
|
| 432 |
+
(1 row)
|
| 433 |
+
|
| 434 |
+
SELECT array_append(ARRAY[1,2], 3);
|
| 435 |
+
array_append
|
| 436 |
+
--------------
|
| 437 |
+
{1,2,3}
|
| 438 |
+
(1 row)
|
| 439 |
+
|
| 440 |
+
SELECT array_cat(ARRAY[1,2], ARRAY[3,4]);
|
| 441 |
+
array_cat
|
| 442 |
+
-----------
|
| 443 |
+
{1,2,3,4}
|
| 444 |
+
(1 row)
|
| 445 |
+
|
| 446 |
+
SELECT array_cat(ARRAY[[1,2],[3,4]], ARRAY[5,6]);
|
| 447 |
+
array_cat
|
| 448 |
+
---------------------
|
| 449 |
+
{{1,2},{3,4},{5,6}}
|
| 450 |
+
(1 row)
|
| 451 |
+
|
| 452 |
+
SELECT array_cat(ARRAY[5,6], ARRAY[[1,2],[3,4]]);
|
| 453 |
+
array_cat
|
| 454 |
+
---------------------
|
| 455 |
+
{{5,6},{1,2},{3,4}}
|
| 456 |
+
</pre><p>
|
| 457 |
+
</p><p>
|
| 458 |
+
In simple cases, the concatenation operator discussed above is preferred
|
| 459 |
+
over direct use of these functions. However, because the concatenation
|
| 460 |
+
operator is overloaded to serve all three cases, there are situations where
|
| 461 |
+
use of one of the functions is helpful to avoid ambiguity. For example
|
| 462 |
+
consider:
|
| 463 |
+
|
| 464 |
+
</p><pre class="programlisting">
|
| 465 |
+
SELECT ARRAY[1, 2] || '{3, 4}'; -- the untyped literal is taken as an array
|
| 466 |
+
?column?
|
| 467 |
+
-----------
|
| 468 |
+
{1,2,3,4}
|
| 469 |
+
|
| 470 |
+
SELECT ARRAY[1, 2] || '7'; -- so is this one
|
| 471 |
+
ERROR: malformed array literal: "7"
|
| 472 |
+
|
| 473 |
+
SELECT ARRAY[1, 2] || NULL; -- so is an undecorated NULL
|
| 474 |
+
?column?
|
| 475 |
+
----------
|
| 476 |
+
{1,2}
|
| 477 |
+
(1 row)
|
| 478 |
+
|
| 479 |
+
SELECT array_append(ARRAY[1, 2], NULL); -- this might have been meant
|
| 480 |
+
array_append
|
| 481 |
+
--------------
|
| 482 |
+
{1,2,NULL}
|
| 483 |
+
</pre><p>
|
| 484 |
+
|
| 485 |
+
In the examples above, the parser sees an integer array on one side of the
|
| 486 |
+
concatenation operator, and a constant of undetermined type on the other.
|
| 487 |
+
The heuristic it uses to resolve the constant's type is to assume it's of
|
| 488 |
+
the same type as the operator's other input — in this case,
|
| 489 |
+
integer array. So the concatenation operator is presumed to
|
| 490 |
+
represent <code class="function">array_cat</code>, not <code class="function">array_append</code>. When
|
| 491 |
+
that's the wrong choice, it could be fixed by casting the constant to the
|
| 492 |
+
array's element type; but explicit use of <code class="function">array_append</code> might
|
| 493 |
+
be a preferable solution.
|
| 494 |
+
</p></div><div class="sect2" id="ARRAYS-SEARCHING"><div class="titlepage"><div><div><h3 class="title">8.15.5. Searching in Arrays <a href="#ARRAYS-SEARCHING" class="id_link">#</a></h3></div></div></div><a id="id-1.5.7.23.8.2" class="indexterm"></a><p>
|
| 495 |
+
To search for a value in an array, each value must be checked.
|
| 496 |
+
This can be done manually, if you know the size of the array.
|
| 497 |
+
For example:
|
| 498 |
+
|
| 499 |
+
</p><pre class="programlisting">
|
| 500 |
+
SELECT * FROM sal_emp WHERE pay_by_quarter[1] = 10000 OR
|
| 501 |
+
pay_by_quarter[2] = 10000 OR
|
| 502 |
+
pay_by_quarter[3] = 10000 OR
|
| 503 |
+
pay_by_quarter[4] = 10000;
|
| 504 |
+
</pre><p>
|
| 505 |
+
|
| 506 |
+
However, this quickly becomes tedious for large arrays, and is not
|
| 507 |
+
helpful if the size of the array is unknown. An alternative method is
|
| 508 |
+
described in <a class="xref" href="functions-comparisons.html" title="9.24. Row and Array Comparisons">Section 9.24</a>. The above
|
| 509 |
+
query could be replaced by:
|
| 510 |
+
|
| 511 |
+
</p><pre class="programlisting">
|
| 512 |
+
SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);
|
| 513 |
+
</pre><p>
|
| 514 |
+
|
| 515 |
+
In addition, you can find rows where the array has all values
|
| 516 |
+
equal to 10000 with:
|
| 517 |
+
|
| 518 |
+
</p><pre class="programlisting">
|
| 519 |
+
SELECT * FROM sal_emp WHERE 10000 = ALL (pay_by_quarter);
|
| 520 |
+
</pre><p>
|
| 521 |
+
|
| 522 |
+
</p><p>
|
| 523 |
+
Alternatively, the <code class="function">generate_subscripts</code> function can be used.
|
| 524 |
+
For example:
|
| 525 |
+
|
| 526 |
+
</p><pre class="programlisting">
|
| 527 |
+
SELECT * FROM
|
| 528 |
+
(SELECT pay_by_quarter,
|
| 529 |
+
generate_subscripts(pay_by_quarter, 1) AS s
|
| 530 |
+
FROM sal_emp) AS foo
|
| 531 |
+
WHERE pay_by_quarter[s] = 10000;
|
| 532 |
+
</pre><p>
|
| 533 |
+
|
| 534 |
+
This function is described in <a class="xref" href="functions-srf.html#FUNCTIONS-SRF-SUBSCRIPTS" title="Table 9.66. Subscript Generating Functions">Table 9.66</a>.
|
| 535 |
+
</p><p>
|
| 536 |
+
You can also search an array using the <code class="literal">&&</code> operator,
|
| 537 |
+
which checks whether the left operand overlaps with the right operand.
|
| 538 |
+
For instance:
|
| 539 |
+
|
| 540 |
+
</p><pre class="programlisting">
|
| 541 |
+
SELECT * FROM sal_emp WHERE pay_by_quarter && ARRAY[10000];
|
| 542 |
+
</pre><p>
|
| 543 |
+
|
| 544 |
+
This and other array operators are further described in
|
| 545 |
+
<a class="xref" href="functions-array.html" title="9.19. Array Functions and Operators">Section 9.19</a>. It can be accelerated by an appropriate
|
| 546 |
+
index, as described in <a class="xref" href="indexes-types.html" title="11.2. Index Types">Section 11.2</a>.
|
| 547 |
+
</p><p>
|
| 548 |
+
You can also search for specific values in an array using the <code class="function">array_position</code>
|
| 549 |
+
and <code class="function">array_positions</code> functions. The former returns the subscript of
|
| 550 |
+
the first occurrence of a value in an array; the latter returns an array with the
|
| 551 |
+
subscripts of all occurrences of the value in the array. For example:
|
| 552 |
+
|
| 553 |
+
</p><pre class="programlisting">
|
| 554 |
+
SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'mon');
|
| 555 |
+
array_position
|
| 556 |
+
----------------
|
| 557 |
+
2
|
| 558 |
+
(1 row)
|
| 559 |
+
|
| 560 |
+
SELECT array_positions(ARRAY[1, 4, 3, 1, 3, 4, 2, 1], 1);
|
| 561 |
+
array_positions
|
| 562 |
+
-----------------
|
| 563 |
+
{1,4,8}
|
| 564 |
+
(1 row)
|
| 565 |
+
</pre><p>
|
| 566 |
+
</p><div class="tip"><h3 class="title">Tip</h3><p>
|
| 567 |
+
Arrays are not sets; searching for specific array elements
|
| 568 |
+
can be a sign of database misdesign. Consider
|
| 569 |
+
using a separate table with a row for each item that would be an
|
| 570 |
+
array element. This will be easier to search, and is likely to
|
| 571 |
+
scale better for a large number of elements.
|
| 572 |
+
</p></div></div><div class="sect2" id="ARRAYS-IO"><div class="titlepage"><div><div><h3 class="title">8.15.6. Array Input and Output Syntax <a href="#ARRAYS-IO" class="id_link">#</a></h3></div></div></div><a id="id-1.5.7.23.9.2" class="indexterm"></a><p>
|
| 573 |
+
The external text representation of an array value consists of items that
|
| 574 |
+
are interpreted according to the I/O conversion rules for the array's
|
| 575 |
+
element type, plus decoration that indicates the array structure.
|
| 576 |
+
The decoration consists of curly braces (<code class="literal">{</code> and <code class="literal">}</code>)
|
| 577 |
+
around the array value plus delimiter characters between adjacent items.
|
| 578 |
+
The delimiter character is usually a comma (<code class="literal">,</code>) but can be
|
| 579 |
+
something else: it is determined by the <code class="literal">typdelim</code> setting
|
| 580 |
+
for the array's element type. Among the standard data types provided
|
| 581 |
+
in the <span class="productname">PostgreSQL</span> distribution, all use a comma,
|
| 582 |
+
except for type <code class="type">box</code>, which uses a semicolon (<code class="literal">;</code>).
|
| 583 |
+
In a multidimensional array, each dimension (row, plane,
|
| 584 |
+
cube, etc.) gets its own level of curly braces, and delimiters
|
| 585 |
+
must be written between adjacent curly-braced entities of the same level.
|
| 586 |
+
</p><p>
|
| 587 |
+
The array output routine will put double quotes around element values
|
| 588 |
+
if they are empty strings, contain curly braces, delimiter characters,
|
| 589 |
+
double quotes, backslashes, or white space, or match the word
|
| 590 |
+
<code class="literal">NULL</code>. Double quotes and backslashes
|
| 591 |
+
embedded in element values will be backslash-escaped. For numeric
|
| 592 |
+
data types it is safe to assume that double quotes will never appear, but
|
| 593 |
+
for textual data types one should be prepared to cope with either the presence
|
| 594 |
+
or absence of quotes.
|
| 595 |
+
</p><p>
|
| 596 |
+
By default, the lower bound index value of an array's dimensions is
|
| 597 |
+
set to one. To represent arrays with other lower bounds, the array
|
| 598 |
+
subscript ranges can be specified explicitly before writing the
|
| 599 |
+
array contents.
|
| 600 |
+
This decoration consists of square brackets (<code class="literal">[]</code>)
|
| 601 |
+
around each array dimension's lower and upper bounds, with
|
| 602 |
+
a colon (<code class="literal">:</code>) delimiter character in between. The
|
| 603 |
+
array dimension decoration is followed by an equal sign (<code class="literal">=</code>).
|
| 604 |
+
For example:
|
| 605 |
+
</p><pre class="programlisting">
|
| 606 |
+
SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
|
| 607 |
+
FROM (SELECT '[1:1][-2:-1][3:5]={{{1,2,3},{4,5,6}}}'::int[] AS f1) AS ss;
|
| 608 |
+
|
| 609 |
+
e1 | e2
|
| 610 |
+
----+----
|
| 611 |
+
1 | 6
|
| 612 |
+
(1 row)
|
| 613 |
+
</pre><p>
|
| 614 |
+
The array output routine will include explicit dimensions in its result
|
| 615 |
+
only when there are one or more lower bounds different from one.
|
| 616 |
+
</p><p>
|
| 617 |
+
If the value written for an element is <code class="literal">NULL</code> (in any case
|
| 618 |
+
variant), the element is taken to be NULL. The presence of any quotes
|
| 619 |
+
or backslashes disables this and allows the literal string value
|
| 620 |
+
<span class="quote">“<span class="quote">NULL</span>”</span> to be entered. Also, for backward compatibility with
|
| 621 |
+
pre-8.2 versions of <span class="productname">PostgreSQL</span>, the <a class="xref" href="runtime-config-compatible.html#GUC-ARRAY-NULLS">array_nulls</a> configuration parameter can be turned
|
| 622 |
+
<code class="literal">off</code> to suppress recognition of <code class="literal">NULL</code> as a NULL.
|
| 623 |
+
</p><p>
|
| 624 |
+
As shown previously, when writing an array value you can use double
|
| 625 |
+
quotes around any individual array element. You <span class="emphasis"><em>must</em></span> do so
|
| 626 |
+
if the element value would otherwise confuse the array-value parser.
|
| 627 |
+
For example, elements containing curly braces, commas (or the data type's
|
| 628 |
+
delimiter character), double quotes, backslashes, or leading or trailing
|
| 629 |
+
whitespace must be double-quoted. Empty strings and strings matching the
|
| 630 |
+
word <code class="literal">NULL</code> must be quoted, too. To put a double
|
| 631 |
+
quote or backslash in a quoted array element value, precede it
|
| 632 |
+
with a backslash. Alternatively, you can avoid quotes and use
|
| 633 |
+
backslash-escaping to protect all data characters that would otherwise
|
| 634 |
+
be taken as array syntax.
|
| 635 |
+
</p><p>
|
| 636 |
+
You can add whitespace before a left brace or after a right
|
| 637 |
+
brace. You can also add whitespace before or after any individual item
|
| 638 |
+
string. In all of these cases the whitespace will be ignored. However,
|
| 639 |
+
whitespace within double-quoted elements, or surrounded on both sides by
|
| 640 |
+
non-whitespace characters of an element, is not ignored.
|
| 641 |
+
</p><div class="tip"><h3 class="title">Tip</h3><p>
|
| 642 |
+
The <code class="literal">ARRAY</code> constructor syntax (see
|
| 643 |
+
<a class="xref" href="sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS" title="4.2.12. Array Constructors">Section 4.2.12</a>) is often easier to work
|
| 644 |
+
with than the array-literal syntax when writing array values in SQL
|
| 645 |
+
commands. In <code class="literal">ARRAY</code>, individual element values are written the
|
| 646 |
+
same way they would be written when not members of an array.
|
| 647 |
+
</p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="datatype-json.html" title="8.14. JSON Types">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="datatype.html" title="Chapter 8. Data Types">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="rowtypes.html" title="8.16. Composite Types">Next</a></td></tr><tr><td width="40%" align="left" valign="top">8.14. <acronym class="acronym">JSON</acronym> Types </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 8.16. Composite Types</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/auth-bsd.html
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>21.14. BSD Authentication</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="auth-pam.html" title="21.13. PAM Authentication" /><link rel="next" href="client-authentication-problems.html" title="21.15. Authentication Problems" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">21.14. BSD Authentication</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="auth-pam.html" title="21.13. PAM Authentication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><th width="60%" align="center">Chapter 21. Client Authentication</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="client-authentication-problems.html" title="21.15. Authentication Problems">Next</a></td></tr></table><hr /></div><div class="sect1" id="AUTH-BSD"><div class="titlepage"><div><div><h2 class="title" style="clear: both">21.14. BSD Authentication <a href="#AUTH-BSD" class="id_link">#</a></h2></div></div></div><a id="id-1.6.8.21.2" class="indexterm"></a><p>
|
| 3 |
+
This authentication method operates similarly to
|
| 4 |
+
<code class="literal">password</code> except that it uses BSD Authentication
|
| 5 |
+
to verify the password. BSD Authentication is used only
|
| 6 |
+
to validate user name/password pairs. Therefore the user's role must
|
| 7 |
+
already exist in the database before BSD Authentication can be used
|
| 8 |
+
for authentication. The BSD Authentication framework is currently
|
| 9 |
+
only available on OpenBSD.
|
| 10 |
+
</p><p>
|
| 11 |
+
BSD Authentication in <span class="productname">PostgreSQL</span> uses
|
| 12 |
+
the <code class="literal">auth-postgresql</code> login type and authenticates with
|
| 13 |
+
the <code class="literal">postgresql</code> login class if that's defined
|
| 14 |
+
in <code class="filename">login.conf</code>. By default that login class does not
|
| 15 |
+
exist, and <span class="productname">PostgreSQL</span> will use the default login class.
|
| 16 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 17 |
+
To use BSD Authentication, the PostgreSQL user account (that is, the
|
| 18 |
+
operating system user running the server) must first be added to
|
| 19 |
+
the <code class="literal">auth</code> group. The <code class="literal">auth</code> group
|
| 20 |
+
exists by default on OpenBSD systems.
|
| 21 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="auth-pam.html" title="21.13. PAM Authentication">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="client-authentication-problems.html" title="21.15. Authentication Problems">Next</a></td></tr><tr><td width="40%" align="left" valign="top">21.13. PAM Authentication </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 21.15. Authentication Problems</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/auth-cert.html
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>21.12. Certificate Authentication</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="auth-radius.html" title="21.11. RADIUS Authentication" /><link rel="next" href="auth-pam.html" title="21.13. PAM Authentication" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">21.12. Certificate Authentication</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="auth-radius.html" title="21.11. RADIUS Authentication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><th width="60%" align="center">Chapter 21. Client Authentication</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="auth-pam.html" title="21.13. PAM Authentication">Next</a></td></tr></table><hr /></div><div class="sect1" id="AUTH-CERT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">21.12. Certificate Authentication <a href="#AUTH-CERT" class="id_link">#</a></h2></div></div></div><a id="id-1.6.8.19.2" class="indexterm"></a><p>
|
| 3 |
+
This authentication method uses SSL client certificates to perform
|
| 4 |
+
authentication. It is therefore only available for SSL connections;
|
| 5 |
+
see <a class="xref" href="ssl-tcp.html#SSL-OPENSSL-CONFIG" title="19.9.2. OpenSSL Configuration">Section 19.9.2</a> for SSL configuration instructions.
|
| 6 |
+
When using this authentication method, the server will require that
|
| 7 |
+
the client provide a valid, trusted certificate. No password prompt
|
| 8 |
+
will be sent to the client. The <code class="literal">cn</code> (Common Name)
|
| 9 |
+
attribute of the certificate
|
| 10 |
+
will be compared to the requested database user name, and if they match
|
| 11 |
+
the login will be allowed. User name mapping can be used to allow
|
| 12 |
+
<code class="literal">cn</code> to be different from the database user name.
|
| 13 |
+
</p><p>
|
| 14 |
+
The following configuration options are supported for SSL certificate
|
| 15 |
+
authentication:
|
| 16 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">map</code></span></dt><dd><p>
|
| 17 |
+
Allows for mapping between system and database user names. See
|
| 18 |
+
<a class="xref" href="auth-username-maps.html" title="21.2. User Name Maps">Section 21.2</a> for details.
|
| 19 |
+
</p></dd></dl></div><p>
|
| 20 |
+
</p><p>
|
| 21 |
+
It is redundant to use the <code class="literal">clientcert</code> option with
|
| 22 |
+
<code class="literal">cert</code> authentication because <code class="literal">cert</code>
|
| 23 |
+
authentication is effectively <code class="literal">trust</code> authentication
|
| 24 |
+
with <code class="literal">clientcert=verify-full</code>.
|
| 25 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="auth-radius.html" title="21.11. RADIUS Authentication">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="auth-pam.html" title="21.13. PAM Authentication">Next</a></td></tr><tr><td width="40%" align="left" valign="top">21.11. RADIUS Authentication </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 21.13. PAM Authentication</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/auth-delay.html
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.3. auth_delay — pause on authentication failure</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency" /><link rel="next" href="auto-explain.html" title="F.4. auto_explain — log execution plans of slow queries" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.3. auth_delay — pause on authentication failure</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules and Extensions</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="auto-explain.html" title="F.4. auto_explain — log execution plans of slow queries">Next</a></td></tr></table><hr /></div><div class="sect1" id="AUTH-DELAY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.3. auth_delay — pause on authentication failure <a href="#AUTH-DELAY" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="auth-delay.html#AUTH-DELAY-CONFIGURATION-PARAMETERS">F.3.1. Configuration Parameters</a></span></dt><dt><span class="sect2"><a href="auth-delay.html#AUTH-DELAY-AUTHOR">F.3.2. Author</a></span></dt></dl></div><a id="id-1.11.7.13.2" class="indexterm"></a><p>
|
| 3 |
+
<code class="filename">auth_delay</code> causes the server to pause briefly before
|
| 4 |
+
reporting authentication failure, to make brute-force attacks on database
|
| 5 |
+
passwords more difficult. Note that it does nothing to prevent
|
| 6 |
+
denial-of-service attacks, and may even exacerbate them, since processes
|
| 7 |
+
that are waiting before reporting authentication failure will still consume
|
| 8 |
+
connection slots.
|
| 9 |
+
</p><p>
|
| 10 |
+
In order to function, this module must be loaded via
|
| 11 |
+
<a class="xref" href="runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES">shared_preload_libraries</a> in <code class="filename">postgresql.conf</code>.
|
| 12 |
+
</p><div class="sect2" id="AUTH-DELAY-CONFIGURATION-PARAMETERS"><div class="titlepage"><div><div><h3 class="title">F.3.1. Configuration Parameters <a href="#AUTH-DELAY-CONFIGURATION-PARAMETERS" class="id_link">#</a></h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">
|
| 13 |
+
<code class="varname">auth_delay.milliseconds</code> (<code class="type">integer</code>)
|
| 14 |
+
<a id="id-1.11.7.13.5.2.1.1.3" class="indexterm"></a>
|
| 15 |
+
</span></dt><dd><p>
|
| 16 |
+
The number of milliseconds to wait before reporting an authentication
|
| 17 |
+
failure. The default is 0.
|
| 18 |
+
</p></dd></dl></div><p>
|
| 19 |
+
These parameters must be set in <code class="filename">postgresql.conf</code>.
|
| 20 |
+
Typical usage might be:
|
| 21 |
+
</p><pre class="programlisting">
|
| 22 |
+
# postgresql.conf
|
| 23 |
+
shared_preload_libraries = 'auth_delay'
|
| 24 |
+
|
| 25 |
+
auth_delay.milliseconds = '500'
|
| 26 |
+
</pre></div><div class="sect2" id="AUTH-DELAY-AUTHOR"><div class="titlepage"><div><div><h3 class="title">F.3.2. Author <a href="#AUTH-DELAY-AUTHOR" class="id_link">#</a></h3></div></div></div><p>
|
| 27 |
+
KaiGai Kohei <code class="email"><<a class="email" href="mailto:kaigai@ak.jp.nec.com">kaigai@ak.jp.nec.com</a>></code>
|
| 28 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="amcheck.html" title="F.2. amcheck — tools to verify table and index consistency">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="auto-explain.html" title="F.4. auto_explain — log execution plans of slow queries">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.2. amcheck — tools to verify table and index consistency </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.4. auto_explain — log execution plans of slow queries</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/auth-ident.html
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>21.8. Ident Authentication</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sspi-auth.html" title="21.7. SSPI Authentication" /><link rel="next" href="auth-peer.html" title="21.9. Peer Authentication" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">21.8. Ident Authentication</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sspi-auth.html" title="21.7. SSPI Authentication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><th width="60%" align="center">Chapter 21. Client Authentication</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="auth-peer.html" title="21.9. Peer Authentication">Next</a></td></tr></table><hr /></div><div class="sect1" id="AUTH-IDENT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">21.8. Ident Authentication <a href="#AUTH-IDENT" class="id_link">#</a></h2></div></div></div><a id="id-1.6.8.15.2" class="indexterm"></a><p>
|
| 3 |
+
The ident authentication method works by obtaining the client's
|
| 4 |
+
operating system user name from an ident server and using it as
|
| 5 |
+
the allowed database user name (with an optional user name mapping).
|
| 6 |
+
This is only supported on TCP/IP connections.
|
| 7 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 8 |
+
When ident is specified for a local (non-TCP/IP) connection,
|
| 9 |
+
peer authentication (see <a class="xref" href="auth-peer.html" title="21.9. Peer Authentication">Section 21.9</a>) will be
|
| 10 |
+
used instead.
|
| 11 |
+
</p></div><p>
|
| 12 |
+
The following configuration options are supported for <code class="literal">ident</code>:
|
| 13 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">map</code></span></dt><dd><p>
|
| 14 |
+
Allows for mapping between system and database user names. See
|
| 15 |
+
<a class="xref" href="auth-username-maps.html" title="21.2. User Name Maps">Section 21.2</a> for details.
|
| 16 |
+
</p></dd></dl></div><p>
|
| 17 |
+
</p><p>
|
| 18 |
+
The <span class="quote">“<span class="quote">Identification Protocol</span>”</span> is described in
|
| 19 |
+
<a class="ulink" href="https://datatracker.ietf.org/doc/html/rfc1413" target="_top">RFC 1413</a>.
|
| 20 |
+
Virtually every Unix-like
|
| 21 |
+
operating system ships with an ident server that listens on TCP
|
| 22 |
+
port 113 by default. The basic functionality of an ident server
|
| 23 |
+
is to answer questions like <span class="quote">“<span class="quote">What user initiated the
|
| 24 |
+
connection that goes out of your port <em class="replaceable"><code>X</code></em>
|
| 25 |
+
and connects to my port <em class="replaceable"><code>Y</code></em>?</span>”</span>.
|
| 26 |
+
Since <span class="productname">PostgreSQL</span> knows both <em class="replaceable"><code>X</code></em> and
|
| 27 |
+
<em class="replaceable"><code>Y</code></em> when a physical connection is established, it
|
| 28 |
+
can interrogate the ident server on the host of the connecting
|
| 29 |
+
client and can theoretically determine the operating system user
|
| 30 |
+
for any given connection.
|
| 31 |
+
</p><p>
|
| 32 |
+
The drawback of this procedure is that it depends on the integrity
|
| 33 |
+
of the client: if the client machine is untrusted or compromised,
|
| 34 |
+
an attacker could run just about any program on port 113 and
|
| 35 |
+
return any user name they choose. This authentication method is
|
| 36 |
+
therefore only appropriate for closed networks where each client
|
| 37 |
+
machine is under tight control and where the database and system
|
| 38 |
+
administrators operate in close contact. In other words, you must
|
| 39 |
+
trust the machine running the ident server.
|
| 40 |
+
Heed the warning:
|
| 41 |
+
</p><div class="blockquote"><table border="0" class="blockquote" style="width: 100%; cellspacing: 0; cellpadding: 0;" summary="Block quote"><tr><td width="10%" valign="top"> </td><td width="80%" valign="top"><p>
|
| 42 |
+
The Identification Protocol is not intended as an authorization
|
| 43 |
+
or access control protocol.
|
| 44 |
+
</p></td><td width="10%" valign="top"> </td></tr><tr><td width="10%" valign="top"> </td><td colspan="2" align="right" valign="top">--<span class="attribution">RFC 1413</span></td></tr></table></div><p>
|
| 45 |
+
</p><p>
|
| 46 |
+
Some ident servers have a nonstandard option that causes the returned
|
| 47 |
+
user name to be encrypted, using a key that only the originating
|
| 48 |
+
machine's administrator knows. This option <span class="emphasis"><em>must not</em></span> be
|
| 49 |
+
used when using the ident server with <span class="productname">PostgreSQL</span>,
|
| 50 |
+
since <span class="productname">PostgreSQL</span> does not have any way to decrypt the
|
| 51 |
+
returned string to determine the actual user name.
|
| 52 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sspi-auth.html" title="21.7. SSPI Authentication">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="auth-peer.html" title="21.9. Peer Authentication">Next</a></td></tr><tr><td width="40%" align="left" valign="top">21.7. SSPI Authentication </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 21.9. Peer Authentication</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/auth-ldap.html
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>21.10. LDAP Authentication</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="auth-peer.html" title="21.9. Peer Authentication" /><link rel="next" href="auth-radius.html" title="21.11. RADIUS Authentication" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">21.10. LDAP Authentication</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="auth-peer.html" title="21.9. Peer Authentication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><th width="60%" align="center">Chapter 21. Client Authentication</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="auth-radius.html" title="21.11. RADIUS Authentication">Next</a></td></tr></table><hr /></div><div class="sect1" id="AUTH-LDAP"><div class="titlepage"><div><div><h2 class="title" style="clear: both">21.10. LDAP Authentication <a href="#AUTH-LDAP" class="id_link">#</a></h2></div></div></div><a id="id-1.6.8.17.2" class="indexterm"></a><p>
|
| 3 |
+
This authentication method operates similarly to
|
| 4 |
+
<code class="literal">password</code> except that it uses LDAP
|
| 5 |
+
as the password verification method. LDAP is used only to validate
|
| 6 |
+
the user name/password pairs. Therefore the user must already
|
| 7 |
+
exist in the database before LDAP can be used for
|
| 8 |
+
authentication.
|
| 9 |
+
</p><p>
|
| 10 |
+
LDAP authentication can operate in two modes. In the first mode,
|
| 11 |
+
which we will call the simple bind mode,
|
| 12 |
+
the server will bind to the distinguished name constructed as
|
| 13 |
+
<em class="replaceable"><code>prefix</code></em> <em class="replaceable"><code>username</code></em> <em class="replaceable"><code>suffix</code></em>.
|
| 14 |
+
Typically, the <em class="replaceable"><code>prefix</code></em> parameter is used to specify
|
| 15 |
+
<code class="literal">cn=</code>, or <em class="replaceable"><code>DOMAIN</code></em><code class="literal">\</code> in an Active
|
| 16 |
+
Directory environment. <em class="replaceable"><code>suffix</code></em> is used to specify the
|
| 17 |
+
remaining part of the DN in a non-Active Directory environment.
|
| 18 |
+
</p><p>
|
| 19 |
+
In the second mode, which we will call the search+bind mode,
|
| 20 |
+
the server first binds to the LDAP directory with
|
| 21 |
+
a fixed user name and password, specified with <em class="replaceable"><code>ldapbinddn</code></em>
|
| 22 |
+
and <em class="replaceable"><code>ldapbindpasswd</code></em>, and performs a search for the user trying
|
| 23 |
+
to log in to the database. If no user and password is configured, an
|
| 24 |
+
anonymous bind will be attempted to the directory. The search will be
|
| 25 |
+
performed over the subtree at <em class="replaceable"><code>ldapbasedn</code></em>, and will try to
|
| 26 |
+
do an exact match of the attribute specified in
|
| 27 |
+
<em class="replaceable"><code>ldapsearchattribute</code></em>.
|
| 28 |
+
Once the user has been found in
|
| 29 |
+
this search, the server disconnects and re-binds to the directory as
|
| 30 |
+
this user, using the password specified by the client, to verify that the
|
| 31 |
+
login is correct. This mode is the same as that used by LDAP authentication
|
| 32 |
+
schemes in other software, such as Apache <code class="literal">mod_authnz_ldap</code> and <code class="literal">pam_ldap</code>.
|
| 33 |
+
This method allows for significantly more flexibility
|
| 34 |
+
in where the user objects are located in the directory, but will cause
|
| 35 |
+
two separate connections to the LDAP server to be made.
|
| 36 |
+
</p><p>
|
| 37 |
+
The following configuration options are used in both modes:
|
| 38 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">ldapserver</code></span></dt><dd><p>
|
| 39 |
+
Names or IP addresses of LDAP servers to connect to. Multiple
|
| 40 |
+
servers may be specified, separated by spaces.
|
| 41 |
+
</p></dd><dt><span class="term"><code class="literal">ldapport</code></span></dt><dd><p>
|
| 42 |
+
Port number on LDAP server to connect to. If no port is specified,
|
| 43 |
+
the LDAP library's default port setting will be used.
|
| 44 |
+
</p></dd><dt><span class="term"><code class="literal">ldapscheme</code></span></dt><dd><p>
|
| 45 |
+
Set to <code class="literal">ldaps</code> to use LDAPS. This is a non-standard
|
| 46 |
+
way of using LDAP over SSL, supported by some LDAP server
|
| 47 |
+
implementations. See also the <code class="literal">ldaptls</code> option for
|
| 48 |
+
an alternative.
|
| 49 |
+
</p></dd><dt><span class="term"><code class="literal">ldaptls</code></span></dt><dd><p>
|
| 50 |
+
Set to 1 to make the connection between PostgreSQL and the LDAP server
|
| 51 |
+
use TLS encryption. This uses the <code class="literal">StartTLS</code>
|
| 52 |
+
operation per <a class="ulink" href="https://datatracker.ietf.org/doc/html/rfc4513" target="_top">RFC 4513</a>.
|
| 53 |
+
See also the <code class="literal">ldapscheme</code> option for an alternative.
|
| 54 |
+
</p></dd></dl></div><p>
|
| 55 |
+
</p><p>
|
| 56 |
+
Note that using <code class="literal">ldapscheme</code> or
|
| 57 |
+
<code class="literal">ldaptls</code> only encrypts the traffic between the
|
| 58 |
+
PostgreSQL server and the LDAP server. The connection between the
|
| 59 |
+
PostgreSQL server and the PostgreSQL client will still be unencrypted
|
| 60 |
+
unless SSL is used there as well.
|
| 61 |
+
</p><p>
|
| 62 |
+
The following options are used in simple bind mode only:
|
| 63 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">ldapprefix</code></span></dt><dd><p>
|
| 64 |
+
String to prepend to the user name when forming the DN to bind as,
|
| 65 |
+
when doing simple bind authentication.
|
| 66 |
+
</p></dd><dt><span class="term"><code class="literal">ldapsuffix</code></span></dt><dd><p>
|
| 67 |
+
String to append to the user name when forming the DN to bind as,
|
| 68 |
+
when doing simple bind authentication.
|
| 69 |
+
</p></dd></dl></div><p>
|
| 70 |
+
</p><p>
|
| 71 |
+
The following options are used in search+bind mode only:
|
| 72 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">ldapbasedn</code></span></dt><dd><p>
|
| 73 |
+
Root DN to begin the search for the user in, when doing search+bind
|
| 74 |
+
authentication.
|
| 75 |
+
</p></dd><dt><span class="term"><code class="literal">ldapbinddn</code></span></dt><dd><p>
|
| 76 |
+
DN of user to bind to the directory with to perform the search when
|
| 77 |
+
doing search+bind authentication.
|
| 78 |
+
</p></dd><dt><span class="term"><code class="literal">ldapbindpasswd</code></span></dt><dd><p>
|
| 79 |
+
Password for user to bind to the directory with to perform the search
|
| 80 |
+
when doing search+bind authentication.
|
| 81 |
+
</p></dd><dt><span class="term"><code class="literal">ldapsearchattribute</code></span></dt><dd><p>
|
| 82 |
+
Attribute to match against the user name in the search when doing
|
| 83 |
+
search+bind authentication. If no attribute is specified, the
|
| 84 |
+
<code class="literal">uid</code> attribute will be used.
|
| 85 |
+
</p></dd><dt><span class="term"><code class="literal">ldapsearchfilter</code></span></dt><dd><p>
|
| 86 |
+
The search filter to use when doing search+bind authentication.
|
| 87 |
+
Occurrences of <code class="literal">$username</code> will be replaced with the
|
| 88 |
+
user name. This allows for more flexible search filters than
|
| 89 |
+
<code class="literal">ldapsearchattribute</code>.
|
| 90 |
+
</p></dd><dt><span class="term"><code class="literal">ldapurl</code></span></dt><dd><p>
|
| 91 |
+
An <a class="ulink" href="https://datatracker.ietf.org/doc/html/rfc4516" target="_top">RFC 4516</a>
|
| 92 |
+
LDAP URL. This is an alternative way to write some of the
|
| 93 |
+
other LDAP options in a more compact and standard form. The format is
|
| 94 |
+
</p><pre class="synopsis">
|
| 95 |
+
ldap[s]://<em class="replaceable"><code>host</code></em>[:<em class="replaceable"><code>port</code></em>]/<em class="replaceable"><code>basedn</code></em>[?[<em class="replaceable"><code>attribute</code></em>][?[<em class="replaceable"><code>scope</code></em>][?[<em class="replaceable"><code>filter</code></em>]]]]
|
| 96 |
+
</pre><p>
|
| 97 |
+
<em class="replaceable"><code>scope</code></em> must be one
|
| 98 |
+
of <code class="literal">base</code>, <code class="literal">one</code>, <code class="literal">sub</code>,
|
| 99 |
+
typically the last. (The default is <code class="literal">base</code>, which
|
| 100 |
+
is normally not useful in this application.) <em class="replaceable"><code>attribute</code></em> can
|
| 101 |
+
nominate a single attribute, in which case it is used as a value for
|
| 102 |
+
<code class="literal">ldapsearchattribute</code>. If
|
| 103 |
+
<em class="replaceable"><code>attribute</code></em> is empty then
|
| 104 |
+
<em class="replaceable"><code>filter</code></em> can be used as a value for
|
| 105 |
+
<code class="literal">ldapsearchfilter</code>.
|
| 106 |
+
</p><p>
|
| 107 |
+
The URL scheme <code class="literal">ldaps</code> chooses the LDAPS method for
|
| 108 |
+
making LDAP connections over SSL, equivalent to using
|
| 109 |
+
<code class="literal">ldapscheme=ldaps</code>. To use encrypted LDAP
|
| 110 |
+
connections using the <code class="literal">StartTLS</code> operation, use the
|
| 111 |
+
normal URL scheme <code class="literal">ldap</code> and specify the
|
| 112 |
+
<code class="literal">ldaptls</code> option in addition to
|
| 113 |
+
<code class="literal">ldapurl</code>.
|
| 114 |
+
</p><p>
|
| 115 |
+
For non-anonymous binds, <code class="literal">ldapbinddn</code>
|
| 116 |
+
and <code class="literal">ldapbindpasswd</code> must be specified as separate
|
| 117 |
+
options.
|
| 118 |
+
</p><p>
|
| 119 |
+
LDAP URLs are currently only supported with
|
| 120 |
+
<span class="productname">OpenLDAP</span>, not on Windows.
|
| 121 |
+
</p></dd></dl></div><p>
|
| 122 |
+
</p><p>
|
| 123 |
+
It is an error to mix configuration options for simple bind with options
|
| 124 |
+
for search+bind.
|
| 125 |
+
</p><p>
|
| 126 |
+
When using search+bind mode, the search can be performed using a single
|
| 127 |
+
attribute specified with <code class="literal">ldapsearchattribute</code>, or using
|
| 128 |
+
a custom search filter specified with
|
| 129 |
+
<code class="literal">ldapsearchfilter</code>.
|
| 130 |
+
Specifying <code class="literal">ldapsearchattribute=foo</code> is equivalent to
|
| 131 |
+
specifying <code class="literal">ldapsearchfilter="(foo=$username)"</code>. If neither
|
| 132 |
+
option is specified the default is
|
| 133 |
+
<code class="literal">ldapsearchattribute=uid</code>.
|
| 134 |
+
</p><p>
|
| 135 |
+
If <span class="productname">PostgreSQL</span> was compiled with
|
| 136 |
+
<span class="productname">OpenLDAP</span> as the LDAP client library, the
|
| 137 |
+
<code class="literal">ldapserver</code> setting may be omitted. In that case, a
|
| 138 |
+
list of host names and ports is looked up via
|
| 139 |
+
<a class="ulink" href="https://datatracker.ietf.org/doc/html/rfc2782" target="_top">RFC 2782</a> DNS SRV records.
|
| 140 |
+
The name <code class="literal">_ldap._tcp.DOMAIN</code> is looked up, where
|
| 141 |
+
<code class="literal">DOMAIN</code> is extracted from <code class="literal">ldapbasedn</code>.
|
| 142 |
+
</p><p>
|
| 143 |
+
Here is an example for a simple-bind LDAP configuration:
|
| 144 |
+
</p><pre class="programlisting">
|
| 145 |
+
host ... ldap ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
|
| 146 |
+
</pre><p>
|
| 147 |
+
When a connection to the database server as database
|
| 148 |
+
user <code class="literal">someuser</code> is requested, PostgreSQL will attempt to
|
| 149 |
+
bind to the LDAP server using the DN <code class="literal">cn=someuser, dc=example,
|
| 150 |
+
dc=net</code> and the password provided by the client. If that connection
|
| 151 |
+
succeeds, the database access is granted.
|
| 152 |
+
</p><p>
|
| 153 |
+
Here is an example for a search+bind configuration:
|
| 154 |
+
</p><pre class="programlisting">
|
| 155 |
+
host ... ldap ldapserver=ldap.example.net ldapbasedn="dc=example, dc=net" ldapsearchattribute=uid
|
| 156 |
+
</pre><p>
|
| 157 |
+
When a connection to the database server as database
|
| 158 |
+
user <code class="literal">someuser</code> is requested, PostgreSQL will attempt to
|
| 159 |
+
bind anonymously (since <code class="literal">ldapbinddn</code> was not specified) to
|
| 160 |
+
the LDAP server, perform a search for <code class="literal">(uid=someuser)</code>
|
| 161 |
+
under the specified base DN. If an entry is found, it will then attempt to
|
| 162 |
+
bind using that found information and the password supplied by the client.
|
| 163 |
+
If that second connection succeeds, the database access is granted.
|
| 164 |
+
</p><p>
|
| 165 |
+
Here is the same search+bind configuration written as a URL:
|
| 166 |
+
</p><pre class="programlisting">
|
| 167 |
+
host ... ldap ldapurl="ldap://ldap.example.net/dc=example,dc=net?uid?sub"
|
| 168 |
+
</pre><p>
|
| 169 |
+
Some other software that supports authentication against LDAP uses the
|
| 170 |
+
same URL format, so it will be easier to share the configuration.
|
| 171 |
+
</p><p>
|
| 172 |
+
Here is an example for a search+bind configuration that uses
|
| 173 |
+
<code class="literal">ldapsearchfilter</code> instead of
|
| 174 |
+
<code class="literal">ldapsearchattribute</code> to allow authentication by
|
| 175 |
+
user ID or email address:
|
| 176 |
+
</p><pre class="programlisting">
|
| 177 |
+
host ... ldap ldapserver=ldap.example.net ldapbasedn="dc=example, dc=net" ldapsearchfilter="(|(uid=$username)(mail=$username))"
|
| 178 |
+
</pre><p>
|
| 179 |
+
</p><p>
|
| 180 |
+
Here is an example for a search+bind configuration that uses DNS SRV
|
| 181 |
+
discovery to find the host name(s) and port(s) for the LDAP service for the
|
| 182 |
+
domain name <code class="literal">example.net</code>:
|
| 183 |
+
</p><pre class="programlisting">
|
| 184 |
+
host ... ldap ldapbasedn="dc=example,dc=net"
|
| 185 |
+
</pre><p>
|
| 186 |
+
</p><div class="tip"><h3 class="title">Tip</h3><p>
|
| 187 |
+
Since LDAP often uses commas and spaces to separate the different
|
| 188 |
+
parts of a DN, it is often necessary to use double-quoted parameter
|
| 189 |
+
values when configuring LDAP options, as shown in the examples.
|
| 190 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="auth-peer.html" title="21.9. Peer Authentication">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="auth-radius.html" title="21.11. RADIUS Authentication">Next</a></td></tr><tr><td width="40%" align="left" valign="top">21.9. Peer Authentication </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 21.11. RADIUS Authentication</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/auth-methods.html
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>21.3. Authentication Methods</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="auth-username-maps.html" title="21.2. User Name Maps" /><link rel="next" href="auth-trust.html" title="21.4. Trust Authentication" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">21.3. Authentication Methods</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="auth-username-maps.html" title="21.2. User Name Maps">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><th width="60%" align="center">Chapter 21. Client Authentication</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="auth-trust.html" title="21.4. Trust Authentication">Next</a></td></tr></table><hr /></div><div class="sect1" id="AUTH-METHODS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">21.3. Authentication Methods <a href="#AUTH-METHODS" class="id_link">#</a></h2></div></div></div><p>
|
| 3 |
+
<span class="productname">PostgreSQL</span> provides various methods for
|
| 4 |
+
authenticating users:
|
| 5 |
+
|
| 6 |
+
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
| 7 |
+
<a class="link" href="auth-trust.html" title="21.4. Trust Authentication">Trust authentication</a>, which
|
| 8 |
+
simply trusts that users are who they say they are.
|
| 9 |
+
</p></li><li class="listitem"><p>
|
| 10 |
+
<a class="link" href="auth-password.html" title="21.5. Password Authentication">Password authentication</a>, which
|
| 11 |
+
requires that users send a password.
|
| 12 |
+
</p></li><li class="listitem"><p>
|
| 13 |
+
<a class="link" href="gssapi-auth.html" title="21.6. GSSAPI Authentication">GSSAPI authentication</a>, which
|
| 14 |
+
relies on a GSSAPI-compatible security library. Typically this is
|
| 15 |
+
used to access an authentication server such as a Kerberos or
|
| 16 |
+
Microsoft Active Directory server.
|
| 17 |
+
</p></li><li class="listitem"><p>
|
| 18 |
+
<a class="link" href="sspi-auth.html" title="21.7. SSPI Authentication">SSPI authentication</a>, which
|
| 19 |
+
uses a Windows-specific protocol similar to GSSAPI.
|
| 20 |
+
</p></li><li class="listitem"><p>
|
| 21 |
+
<a class="link" href="auth-ident.html" title="21.8. Ident Authentication">Ident authentication</a>, which
|
| 22 |
+
relies on an <span class="quote">“<span class="quote">Identification Protocol</span>”</span>
|
| 23 |
+
(<a class="ulink" href="https://datatracker.ietf.org/doc/html/rfc1413" target="_top">RFC 1413</a>)
|
| 24 |
+
service on the client's machine. (On local Unix-socket connections,
|
| 25 |
+
this is treated as peer authentication.)
|
| 26 |
+
</p></li><li class="listitem"><p>
|
| 27 |
+
<a class="link" href="auth-peer.html" title="21.9. Peer Authentication">Peer authentication</a>, which
|
| 28 |
+
relies on operating system facilities to identify the process at the
|
| 29 |
+
other end of a local connection. This is not supported for remote
|
| 30 |
+
connections.
|
| 31 |
+
</p></li><li class="listitem"><p>
|
| 32 |
+
<a class="link" href="auth-ldap.html" title="21.10. LDAP Authentication">LDAP authentication</a>, which
|
| 33 |
+
relies on an LDAP authentication server.
|
| 34 |
+
</p></li><li class="listitem"><p>
|
| 35 |
+
<a class="link" href="auth-radius.html" title="21.11. RADIUS Authentication">RADIUS authentication</a>, which
|
| 36 |
+
relies on a RADIUS authentication server.
|
| 37 |
+
</p></li><li class="listitem"><p>
|
| 38 |
+
<a class="link" href="auth-cert.html" title="21.12. Certificate Authentication">Certificate authentication</a>, which
|
| 39 |
+
requires an SSL connection and authenticates users by checking the
|
| 40 |
+
SSL certificate they send.
|
| 41 |
+
</p></li><li class="listitem"><p>
|
| 42 |
+
<a class="link" href="auth-pam.html" title="21.13. PAM Authentication">PAM authentication</a>, which
|
| 43 |
+
relies on a PAM (Pluggable Authentication Modules) library.
|
| 44 |
+
</p></li><li class="listitem"><p>
|
| 45 |
+
<a class="link" href="auth-bsd.html" title="21.14. BSD Authentication">BSD authentication</a>, which
|
| 46 |
+
relies on the BSD Authentication framework (currently available
|
| 47 |
+
only on OpenBSD).
|
| 48 |
+
</p></li></ul></div><p>
|
| 49 |
+
</p><p>
|
| 50 |
+
Peer authentication is usually recommendable for local connections,
|
| 51 |
+
though trust authentication might be sufficient in some circumstances.
|
| 52 |
+
Password authentication is the easiest choice for remote connections.
|
| 53 |
+
All the other options require some kind of external security
|
| 54 |
+
infrastructure (usually an authentication server or a certificate
|
| 55 |
+
authority for issuing SSL certificates), or are platform-specific.
|
| 56 |
+
</p><p>
|
| 57 |
+
The following sections describe each of these authentication methods
|
| 58 |
+
in more detail.
|
| 59 |
+
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="auth-username-maps.html" title="21.2. User Name Maps">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="auth-trust.html" title="21.4. Trust Authentication">Next</a></td></tr><tr><td width="40%" align="left" valign="top">21.2. User Name Maps </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 21.4. Trust Authentication</td></tr></table></div></body></html>
|
pgsql/doc/postgresql/html/auth-pam.html
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
| 2 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>21.13. PAM Authentication</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="auth-cert.html" title="21.12. Certificate Authentication" /><link rel="next" href="auth-bsd.html" title="21.14. BSD Authentication" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">21.13. PAM Authentication</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="auth-cert.html" title="21.12. Certificate Authentication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><th width="60%" align="center">Chapter 21. Client Authentication</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="auth-bsd.html" title="21.14. BSD Authentication">Next</a></td></tr></table><hr /></div><div class="sect1" id="AUTH-PAM"><div class="titlepage"><div><div><h2 class="title" style="clear: both">21.13. PAM Authentication <a href="#AUTH-PAM" class="id_link">#</a></h2></div></div></div><a id="id-1.6.8.20.2" class="indexterm"></a><p>
|
| 3 |
+
This authentication method operates similarly to
|
| 4 |
+
<code class="literal">password</code> except that it uses PAM (Pluggable
|
| 5 |
+
Authentication Modules) as the authentication mechanism. The
|
| 6 |
+
default PAM service name is <code class="literal">postgresql</code>.
|
| 7 |
+
PAM is used only to validate user name/password pairs and optionally the
|
| 8 |
+
connected remote host name or IP address. Therefore the user must already
|
| 9 |
+
exist in the database before PAM can be used for authentication. For more
|
| 10 |
+
information about PAM, please read the
|
| 11 |
+
<a class="ulink" href="https://www.kernel.org/pub/linux/libs/pam/" target="_top">
|
| 12 |
+
<span class="productname">Linux-PAM</span> Page</a>.
|
| 13 |
+
</p><p>
|
| 14 |
+
The following configuration options are supported for PAM:
|
| 15 |
+
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">pamservice</code></span></dt><dd><p>
|
| 16 |
+
PAM service name.
|
| 17 |
+
</p></dd><dt><span class="term"><code class="literal">pam_use_hostname</code></span></dt><dd><p>
|
| 18 |
+
Determines whether the remote IP address or the host name is provided
|
| 19 |
+
to PAM modules through the <code class="symbol">PAM_RHOST</code> item. By
|
| 20 |
+
default, the IP address is used. Set this option to 1 to use the
|
| 21 |
+
resolved host name instead. Host name resolution can lead to login
|
| 22 |
+
delays. (Most PAM configurations don't use this information, so it is
|
| 23 |
+
only necessary to consider this setting if a PAM configuration was
|
| 24 |
+
specifically created to make use of it.)
|
| 25 |
+
</p></dd></dl></div><p>
|
| 26 |
+
</p><div class="note"><h3 class="title">Note</h3><p>
|
| 27 |
+
If PAM is set up to read <code class="filename">/etc/shadow</code>, authentication
|
| 28 |
+
will fail because the PostgreSQL server is started by a non-root
|
| 29 |
+
user. However, this is not an issue when PAM is configured to use
|
| 30 |
+
LDAP or other authentication methods.
|
| 31 |
+
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="auth-cert.html" title="21.12. Certificate Authentication">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="client-authentication.html" title="Chapter 21. Client Authentication">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="auth-bsd.html" title="21.14. BSD Authentication">Next</a></td></tr><tr><td width="40%" align="left" valign="top">21.12. Certificate Authentication </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 21.14. BSD Authentication</td></tr></table></div></body></html>
|