Page 1 of 1

PgSqlDump

Posted: Tue 09 Jun 2015 13:31
by damon.cognito
Running into two problems with PgSqlDump. First I want to dump the schema, tables and views only but it also includes sequences which I am pretty sure the code below shouldn't:

Code: Select all

                        using (var schemaBackup = new PgSqlDump()
                        {
                            Connection = myConnection.getConnection(),
                            QuoteIdentifier = true,
                            Mode = DumpMode.Schema,
                            GenerateHeader = false,
                            ObjectTypes = PgSqlDumpObjects.Schemas ^ PgSqlDumpObjects.Tables ^ PgSqlDumpObjects.Views 
                        })
                        { .... }
Secondly, the sequences have owners set whereas the Tables do not. We are a little behind (7.3.342.0) but not too far.

cheers!

Re: PgSqlDump

Posted: Wed 10 Jun 2015 13:28
by Pinturiccio
damon.cognito wrote:First I want to dump the schema, tables and views only but it also includes sequences which I am pretty sure the code below shouldn't:
Your code adds the sequences that are used for table serial columns to a dump file. Other sequences are not added. If you want to add all the sequences, also add PgSqlDumpObjects.Sequences to ObjectTypes.
damon.cognito wrote:ObjectTypes = PgSqlDumpObjects.Schemas ^ PgSqlDumpObjects.Tables ^ PgSqlDumpObjects.Views
Please also note that you use the XOR (^) operator for specifying several PgSqlDumpObjects. This does not cause errors in this example, but this is incorrect and potentially leads to errors in other cases. It's better to use the OR (|) operator for this purpose:

Code: Select all

ObjectTypes = PgSqlDumpObjects.Schemas | PgSqlDumpObjects.Tables | PgSqlDumpObjects.Views
damon.cognito wrote:Secondly, the sequences have owners set whereas the Tables do not.
We have reproduced the issue. Starting from next public build of dotConnect for PostgreSQL "OWNER TO" statements for sequences will not be added to the backup script. We will post here when the corresponding build of dotConnect for PostgreSQL is available for download.

Re: PgSqlDump

Posted: Wed 10 Jun 2015 14:12
by damon.cognito
Okay, thanks for the advice. I think on the final point I would prefer to have a choice to have owners set for all objects or not set (I actually want the tables and sequences to have their owners set).

Re: PgSqlDump

Posted: Wed 10 Jun 2015 15:10
by Pinturiccio
We will investigate the possibility to implement an option determining whether to generate statements with "OWNER TO" and post here about the results as soon as possible.