agora inbox for postgres@postgres.berkeley.edu  
help / color / mirror / Atom feed
From: Paul M. Aoki <aoki@CS.Berkeley.EDU>
To: Bruce Thomson <bruce@comu11.auckland.ac.nz>
Cc: postgres@postgres.Berkeley.EDU
Subject: Re: PQExec inside a C function?
Date: Mon, 27 Jun 94 23:48:46 -0700
Message-ID: <199406280648.XAA11001@faerie.CS.Berkeley.EDU> (raw)
In-Reply-To: <9406280331.AA21637@comu11.auckland.ac.nz>

bruce@comu11.auckland.ac.nz (Bruce Thomson) writes:
> I am trying to call a user function from within the monitor that should
> do some PQExec'd insertions into a table.

> PQsetdb ("external");
> PQexec("begin");
          ^^^^^
> sprintf(append_line,"append twovals(x1=%d,x2=%d)",x,x*2);
> PQexec(append_line);
> PQexec("end");
          ^^^

if this is postgres 4.x, x<2, this won't work at all.

if this is 4.2, you stand some chance but you don't want to use begin/end.
(all backend "libpq" calls are executed in the same transaction already.)
you also don't want to link your function with libpq, *ever*, if it's going
to be used in the backend -- there are equivalent functions in the backend.
i don't think you need to do PQsetdb since you're already in a backend
that is attached to a database.

in general this interface has a lot of problems.  i don't particularly
recommend it though the alternative (direct access method calls) isn't
very nice either.
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  aoki@CS.Berkeley.EDU
                |  Berkeley, CA 94720-1776      |  ...!uunet!ucbvax!aoki

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: postgres@postgres.berkeley.edu
  Cc: aoki@CS.Berkeley.EDU, bruce@comu11.auckland.ac.nz
  Subject: Re: PQExec inside a C function?
  In-Reply-To: <199406280648.XAA11001@faerie.CS.Berkeley.EDU>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox