Re: [HACKERS] pg_restore: show object schema name in verbose output

2013-08-04 Thread Erik Rijkers
On Sun, August 4, 2013 04:51, Ian Lawrence Barwick wrote:
 I just noticed that pg_restore executing in verbose mode displays the
 name of the object being restored, but not its schema.


Good idea.  We have many schemata with tables of the same name and
reporting the schema name certainly improves the readability and error
trackdown during restore.

I notice 2 things:


1.  pg_restore now outputs reports about COMMENT like this:
pg_restore: creating COMMENT restore_verbose_test.TABLE t
pg_restore: creating COMMENT restore_verbose_test.COLUMN t.c
pg_restore: creating COMMENT restore_verbose_test.COLUMN t.i

I assume the .TABLE and .COLUMN here is a bug; it should just be:

pg_restore: creating COMMENT restore_verbose_test t

as it used to be.


2.  Several of the lines that are output by pg_restore now mention
the schema, but not the processing line:

pg_restore: processing data for table t

Could it be added there too?


Thanks,

Erik Rijkers



#!/bin/sh

schema=restore_verbose_test
 table=t
 t=$schema.$table

rm -rf $schema.dump
echo

echo 
drop schema if exists $schema cascade;
create schema $schema;
drop table if exists $t;
create table $t(c text, i serial primary key);
comment on table $t is 'table $t is a table';
comment on column $t.c is 'column c is a column text in table $t';
comment on column $t.i is 'column i is a column serial (pk) in table $t';
insert into $t select chr(i) from generate_series(65,70) f(i);
 | psql -X

echo table $t limit 5; \\d+ $t | psql -X

time pg_dump -v -F d -n $schema -f $schema.dump testdb

echo drop schema if exists $schema cascade; | psql -X

echo '\dn '$schema | psql -X

pg_restore -v -d testdb $schema.dump

echo '\dn '$schema | psql -X
echo table $t limit 5; \\d+ $t | psql -X




-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pg_restore: show object schema name in verbose output

2013-08-04 Thread Ian Lawrence Barwick
2013/8/4 Erik Rijkers e...@xs4all.nl:
 On Sun, August 4, 2013 04:51, Ian Lawrence Barwick wrote:
 I just noticed that pg_restore executing in verbose mode displays the
 name of the object being restored, but not its schema.


 Good idea.  We have many schemata with tables of the same name and
 reporting the schema name certainly improves the readability and error
 trackdown during restore.

 I notice 2 things:


 1.  pg_restore now outputs reports about COMMENT like this:
 pg_restore: creating COMMENT restore_verbose_test.TABLE t
 pg_restore: creating COMMENT restore_verbose_test.COLUMN t.c
 pg_restore: creating COMMENT restore_verbose_test.COLUMN t.i

 I assume the .TABLE and .COLUMN here is a bug; it should just be:

 pg_restore: creating COMMENT restore_verbose_test t

 as it used to be.


 2.  Several of the lines that are output by pg_restore now mention
 the schema, but not the processing line:

 pg_restore: processing data for table t

 Could it be added there too?

Thanks for the feedback and test case. I'll submit a revised patch.

Regards

Ian Barwick


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pg_restore: show object schema name in verbose output

2013-08-04 Thread Ian Lawrence Barwick
2013/8/4 Ian Lawrence Barwick barw...@gmail.com:
 2013/8/4 Erik Rijkers e...@xs4all.nl:
 On Sun, August 4, 2013 04:51, Ian Lawrence Barwick wrote:
 I just noticed that pg_restore executing in verbose mode displays the
 name of the object being restored, but not its schema.


 Good idea.  We have many schemata with tables of the same name and
 reporting the schema name certainly improves the readability and error
 trackdown during restore.

 I notice 2 things:


 1.  pg_restore now outputs reports about COMMENT like this:
 pg_restore: creating COMMENT restore_verbose_test.TABLE t
 pg_restore: creating COMMENT restore_verbose_test.COLUMN t.c
 pg_restore: creating COMMENT restore_verbose_test.COLUMN t.i

 I assume the .TABLE and .COLUMN here is a bug; it should just be:

 pg_restore: creating COMMENT restore_verbose_test t

 as it used to be.

Actually the current output would be:

  pg_restore: creating COMMENT TABLE t

Anyway this is a bit trickier than I originally thought, but I understand
the inner workings of pg_restore et al better now anyway :)

 2.  Several of the lines that are output by pg_restore now mention
 the schema, but not the processing line:

 pg_restore: processing data for table t

 Could it be added there too?

That looks quite straightforward.

 Thanks for the feedback and test case. I'll submit a revised patch.

The attached patch should work somewhat better, but methinks I'll need
to work on it a bit more. Also, for the sake of consistency it would
be useful to show the schema (where appropriate) in the owner/privileges
setting output, e.g.:

  pg_restore: setting owner and privileges for TABLE t


Regards

Ian Barwick


pg-restore-verbose-output-schema-2013-08-04.patch
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] pg_restore: show object schema name in verbose output

2013-08-03 Thread Ian Lawrence Barwick
I just noticed that pg_restore executing in verbose mode displays the
name of the object being restored, but not its schema.

I'd like to be able to see the fully-qualified object name because
if pg_restore spits out a warning like this:

  $ pg_restore -d somedb  /path/to/dumpfile.pgd
  pg_restore: WARNING:  column session_id has type unknown
  DETAIL:  Proceeding with relation creation anyway.
  $

verbose mode is useful to identify which object is at issue, e.g.:

  $ pg_restore -v -d somedb /path/to/dumpfile.pgd
  pg_restore: connecting to database for restore
(...)
  pg_restore: creating VIEW someview
  pg_restore: WARNING:  column session_id has type unknown
  DETAIL:  Proceeding with relation creation anyway.
(...)
  $

but only shows the bare object name. In the case I recently encountered,
objects with the same name existed in multiple schemas, which meant it
took longer to track down the offending object than it could have done.

The attached patch changes the output to print the schema name too, e.g.:

  $ pg_restore -v -d somedb /path/to/dumpfile.pgd
  pg_restore: connecting to database for restore
(...)
  pg_restore: creating VIEW schema94.someview
  pg_restore: WARNING:  column session_id has type unknown
  DETAIL:  Proceeding with relation creation anyway.
(...)
  $

which is more useful, IMHO.

Regards


Ian Barwick


pg-restore-verbose-output-schema-2013-08-03.patch
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers