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

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
kerrywales
Posts: 52
Joined: Tue 05 Jan 2010 12:26

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

Post by kerrywales » Sat 24 Sep 2011 09:17

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

kerrywales
Posts: 52
Joined: Tue 05 Jan 2010 12:26

Post by kerrywales » Sun 25 Sep 2011 08:32

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();
,,

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 27 Sep 2011 16:23

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.

Post Reply