Re: Executing \i of psql command using libpq library

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Edmundo Robles L(dot)" <erobles(at)sensacd(dot)com(dot)mx>, pgsql-general(at)postgresql(dot)org
Subject: Re: Executing \i of psql command using libpq library
Date: 2011-06-15 02:35:45
Message-ID: BANLkTikdqw4KoOZ5mfE6yN1v_tn8m-Pbdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jun 14, 2011 at 11:51 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Edmundo Robles L." <erobles(at)sensacd(dot)com(dot)mx> writes:
>> How can i get the same behavior of psql -c "\\i './a_lot_of_sentences'" bd user, using the libpq library???
>
> libpq does not contain any such behavior, so you can't.

You can take a look at process_file() in psql's command.c if you're
interested to see how psql, which itself uses libpq to talk to
Postgres, implements the \i backslash command.

You haven't really explained why just having your application call out
to psql won't work. You could, of course, attempt to duplicate the
functionality of process_file() but frankly I suspect doing so would
result in a poorly implemented subset of psql.

Josh

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andy Chambers 2011-06-15 04:54:05 Cursors
Previous Message Bruce Momjian 2011-06-15 02:08:44 Re: Why security-definer functions are executable by public by default?