Page 1 of 1

Running sql script produced by pg_dump 9.1. Is it possible?

Posted: Sat 24 Sep 2011 09:17
by kerrywales
I am looking to create a db schema using Devart calls from a script produced through pgdmin backup mechanism.

The opening lines are:
SET statement_timeout = 0;
SET client_encoding = 'LATIN1';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

--
-- TOC entry 513 (class 3079 OID 11638)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
It errors "near EXTENSION"

Does Devart support this code? Or is it possible to tell restore/pgsqlscript to ignore errors?

Thanks

Posted: Sun 25 Sep 2011 08:32
by kerrywales
Looking on the forum I came across some code and adapted it. This creates the DB. There are errors which are ignored in this code

Code: Select all

StreamReader streamReader = new StreamReader("pgDumpScript.sql");
                    string text = streamReader.ReadToEnd();
                    streamReader.Close();
                    PgSqlScript cmdScript = new PgSqlScript(text, conn);
                    
                    foreach (SqlStatement pgStatement in cmdScript.Statements)
                    {
                        try
                        {
                            pgStatement.Execute();
                         }
                        catch
                        {
                            Console.WriteLine("  Failed");
                        }
                    } 
                    conn.Close();
,,

Posted: Tue 27 Sep 2011 16:23
by Shalex
kerrywales wrote:It errors "near EXTENSION"
The reason of the error: before you can use CREATE EXTENSION to load an extension into a database, the extension's supporting files must be installed: http://developer.postgresql.org/pgdocs/ ... nsion.html.