Обсуждение: pg_dump / pg_restore - TOC.dat file

Поиск
Список
Период
Сортировка

pg_dump / pg_restore - TOC.dat file

От
Clécio Anderson
Дата:
Hi guys!

Does anyone knows the meaning of each collumn in TOC.dat file generated by pg_dump?

For example:

;
; Archive created at Thu Jan 21 18:36:25 2016
;     dbname: mydb
;     TOC Entries: 7528
;     Compression: -1
;     Dump Version: 1.12-0
;     Format: DIRECTORY
;     Integer: 4 bytes
;     Offset: 8 bytes
;     Dumped from database version: 9.3.5
;     Dumped by pg_dump version: 9.3.5
;
;
; Selected TOC Entries:
;
11471; 1262 36497111 DATABASE - mydb postgres
7; 2615 36497112 SCHEMA - acl postgres
11472; 0 0 ACL - acl postgres
179; 1259 36497634 TABLE acl tb_log postgres
11514; 0 0 ACL acl tb_log postgres
180; 1259 36497638 TABLE acl tb_paper postgres
11515; 0 0 ACL acl tb_paper postgres
181; 1259 36497643 TABLE acl tb_paper_group postgres
11516; 0 0 ACL acl tb_paper_group postgres
182; 1259 36497646 TABLE acl tb_permission postgres
11517; 0 0 ACL acl tb_permission postgres

At the first line for example.. 

11471; 1262 36497111 DATABASE - mydb postgres

What each collumn means? What 11471 means? or 1262 or 36497111.... and so on..

Thanks in advance for your help and time!

--
Tecnólogo em Redes de Computadores
Currículo Lattes

MCTS | MCITP | LPIC-2 | ITIL Foundation

Re: pg_dump / pg_restore - TOC.dat file

От
Felipe Santos
Дата:


2016-01-26 3:12 GMT-02:00 Clécio Anderson <clecioanderson@gmail.com>:
Hi guys!

Does anyone knows the meaning of each collumn in TOC.dat file generated by pg_dump?

For example:

;
; Archive created at Thu Jan 21 18:36:25 2016
;     dbname: mydb
;     TOC Entries: 7528
;     Compression: -1
;     Dump Version: 1.12-0
;     Format: DIRECTORY
;     Integer: 4 bytes
;     Offset: 8 bytes
;     Dumped from database version: 9.3.5
;     Dumped by pg_dump version: 9.3.5
;
;
; Selected TOC Entries:
;
11471; 1262 36497111 DATABASE - mydb postgres
7; 2615 36497112 SCHEMA - acl postgres
11472; 0 0 ACL - acl postgres
179; 1259 36497634 TABLE acl tb_log postgres
11514; 0 0 ACL acl tb_log postgres
180; 1259 36497638 TABLE acl tb_paper postgres
11515; 0 0 ACL acl tb_paper postgres
181; 1259 36497643 TABLE acl tb_paper_group postgres
11516; 0 0 ACL acl tb_paper_group postgres
182; 1259 36497646 TABLE acl tb_permission postgres
11517; 0 0 ACL acl tb_permission postgres

At the first line for example.. 

11471; 1262 36497111 DATABASE - mydb postgres

What each collumn means? What 11471 means? or 1262 or 36497111.... and so on..

Thanks in advance for your help and time!

--
Tecnólogo em Redes de Computadores
Currículo Lattes

MCTS | MCITP | LPIC-2 | ITIL Foundation




11471; 1262 36497111 DATABASE - mydb postgres

11471 - ?
1262 - ?
36497111 - Object ID
DATABASE - Object Type
mydb - Object Name
postgres - Object Owner

Re: pg_dump / pg_restore - TOC.dat file

От
Alvaro Herrera
Дата:
Felipe Santos wrote:

> 11471; 1262 36497111 DATABASE - mydb postgres
>
> 11471 - ?
> 1262 - ?
> 36497111 - Object ID
> DATABASE - Object Type
> mydb - Object Name
> postgres - Object Owner

The code that writes this is PrintTOCSummary() in
src/bin/pg_dump/pg_backup_archiver.c -- see that if you want more
details.  (Each object here is a TocEntry struct, which is defined in
pg_backup_archiver.h, search for _tocEntry.  Useful comments there.)

11471 is the internal ID of the object in the dump.  Note that ; is a
comment delimiter for the TOC format, so if you just write the 11471 in
a separate line, the correct object is specified.  The rest of the
entries after the ; are just commentary so that the DBA can understand
what the entry is for.

1262 is the OID of the pg_database catalog, so this identifies the entry
as a database.  This is redundant with having DATABASE in the object
type.  Similarly, 36497111 is the pg_database.oid column which is
redundant with having mydb as the database name.

The hyphen - is for the schema, if the object belongs into a schema.
A database obviously doesn't have one, hence the - in this particular
sample.

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


Re: pg_dump / pg_restore - TOC.dat file

От
Clécio Anderson
Дата:
Thanks Alvaro and Felipe for your answers. ;D

2016-01-26 14:37 GMT-03:00 Alvaro Herrera <alvherre@2ndquadrant.com>:
Felipe Santos wrote:

> 11471; 1262 36497111 DATABASE - mydb postgres
>
> 11471 - ?
> 1262 - ?
> 36497111 - Object ID
> DATABASE - Object Type
> mydb - Object Name
> postgres - Object Owner

The code that writes this is PrintTOCSummary() in
src/bin/pg_dump/pg_backup_archiver.c -- see that if you want more
details.  (Each object here is a TocEntry struct, which is defined in
pg_backup_archiver.h, search for _tocEntry.  Useful comments there.)

11471 is the internal ID of the object in the dump.  Note that ; is a
comment delimiter for the TOC format, so if you just write the 11471 in
a separate line, the correct object is specified.  The rest of the
entries after the ; are just commentary so that the DBA can understand
what the entry is for.

1262 is the OID of the pg_database catalog, so this identifies the entry
as a database.  This is redundant with having DATABASE in the object
type.  Similarly, 36497111 is the pg_database.oid column which is
redundant with having mydb as the database name.

The hyphen - is for the schema, if the object belongs into a schema.
A database obviously doesn't have one, hence the - in this particular
sample.

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



--
Tecnólogo em Redes de Computadores
Currículo Lattes

MCTS | MCITP | LPIC-2 | ITIL Foundation