Thread

  1. Re: [HACKERS] function question yet again

    Mike Mascari <mascarm@mascari.com> — 2000-02-15T08:42:33Z

    Michael Meskes wrote:
    
    > Is it possible to define a function in language 'C' that needs more
    > libraries to work? I've got a small example of a function that works like a
    > charm when run against from a binary. However if I put this function inside
    > the server and execute it I get
    >
    > ERROR:  parser: parse error at or near ""
    >
    > Not exactly an error message that explains itself. :-)
    >
    > I have put my function into a shared library to load it, but the library
    > itself needs other libraries. Is this at all possible?
    >
    > Michael
    > --
    > Michael Meskes                         | Go SF 49ers!
    > Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
    > Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
    > Email: Michael@Fam-Meskes.De           | Use PostgreSQL!
    
    That's odd. Would it be possible for you to provide your compiliation/link
    statement as well as your CREATE FUNCTION statement? I've a host of functions
    which use external libaries that work as expected (on Linux), including doing
    some pretty weird stuff.
    
    Mike Mascari
    
    
    
    
  2. function question yet again

    Michael Meskes <meskes@postgresql.org> — 2000-02-15T12:14:39Z

    Is it possible to define a function in language 'C' that needs more
    libraries to work? I've got a small example of a function that works like a
    charm when run against from a binary. However if I put this function inside
    the server and execute it I get 
    
    ERROR:  parser: parse error at or near ""
    
    Not exactly an error message that explains itself. :-)
    
    I have put my function into a shared library to load it, but the library
    itself needs other libraries. Is this at all possible?
    
    Michael
    -- 
    Michael Meskes                         | Go SF 49ers!
    Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
    Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
    Email: Michael@Fam-Meskes.De           | Use PostgreSQL!
    
    
  3. Re: [HACKERS] function question yet again

    Sevo Stille <sevo@ip23.net> — 2000-02-15T14:14:57Z

    Michael Meskes wrote:
    > 
    > Is it possible to define a function in language 'C' that needs more
    > libraries to work? I've got a small example of a function that works like a
    > charm when run against from a binary. However if I put this function inside
    > the server and execute it I get
    > 
    > ERROR:  parser: parse error at or near ""
    > 
    > Not exactly an error message that explains itself. :-)
    
    Actually, it is very suggestive of quoting or escaping errors.
    Presumably your statement terminates somewhere where you would not
    expect it. 
     
    > I have put my function into a shared library to load it, but the library
    > itself needs other libraries. Is this at all possible?
    
    If the system knows how to find it, absolutely. That is, whatever you
    depend on will have to be in a system or pgsql library directory.  
    
    Sevo
    
    
  4. Re: [HACKERS] function question yet again

    Michael Meskes <meskes@postgresql.org> — 2000-02-15T14:24:30Z

    On Tue, Feb 15, 2000 at 04:58:49AM -0800, Alfred Perlstein wrote:
    > As a temporary hack you may want to try linking the shared object that you
    > are creating with the static versions of the third level libraries.
    
    Good idea. Unfottunately it didn't change anything. Using ldd on my shared
    library no tells me it is statically linked. But the error message remains
    the same.
    
    I tried to write a log file and it appears the function does correctly
    connect to the backend but cannot execute the select. IDK however if a
    function inside the backend is allowed to create a connection. But if not
    how can I send a query over libpq?
    
    Michael
    -- 
    Michael Meskes                         | Go SF 49ers!
    Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
    Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
    Email: Michael@Fam-Meskes.De           | Use PostgreSQL!
    
    
  5. Re: [HACKERS] function question yet again

    Michael Meskes <meskes@postgresql.org> — 2000-02-15T14:26:20Z

    On Tue, Feb 15, 2000 at 03:42:33AM -0500, Mike Mascari wrote:
    > That's odd. Would it be possible for you to provide your compiliation/link
    > statement as well as your CREATE FUNCTION statement? I've a host of functions
    > which use external libaries that work as expected (on Linux), including doing
    > some pretty weird stuff.
    
    I attach both files. My intend was to get this thing going by using ecpg.
    I'm not sure anymore if this is at all possible.
    
    Michael
    
    -- 
    Michael Meskes                         | Go SF 49ers!
    Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
    Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
    Email: Michael@Fam-Meskes.De           | Use PostgreSQL!
    
  6. Re: [HACKERS] function question yet again

    Mike Mascari <mascarm@mascari.com> — 2000-02-15T15:09:35Z

    Michael Meskes wrote:
    > 
    > I attach both files. My intend was to get this thing going by using
    > ecpg.
    > I'm not sure anymore if this is at all possible.
    > 
    > Michael
    > 
    > --
    > Michael Meskes                         | Go SF 49ers!
    > Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
    > Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
    > Email: Michael@Fam-Meskes.De           | Use PostgreSQL!
    
    Wow. I'm not quite sure why it shouldn't work, but I've never
    reconnected on the server side through libpq. Instead, I've
    always used the SPI interface sequence of:
    
    SPI_connect()
    SPI_exec()
    SPI_getvalue()
    SPI_finish()
    
    I think I've tried in the past to reconnect on the server side
    through libpq but it always resulted in a core dump of the
    running backend.
    
    Sorry I'm no more help then that, 
    
    Mike Mascari
    
    
  7. Re: [HACKERS] function question yet again

    Michael Meskes <meskes@postgresql.org> — 2000-02-15T19:21:21Z

    On Tue, Feb 15, 2000 at 03:14:57PM +0100, Sevo Stille wrote:
    > Actually, it is very suggestive of quoting or escaping errors.
    > Presumably your statement terminates somewhere where you would not
    > expect it. 
    
    Okay. But why does it work when run from outside the backend?
    
    > If the system knows how to find it, absolutely. That is, whatever you
    > depend on will have to be in a system or pgsql library directory.  
    
    I made my shared lib not depend on any other lib, but nothing changes.
    
    Michael
    -- 
    Michael Meskes                         | Go SF 49ers!
    Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
    Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
    Email: Michael@Fam-Meskes.De           | Use PostgreSQL!
    
    
  8. Re: [HACKERS] function question yet again

    Tom Lane <tgl@sss.pgh.pa.us> — 2000-02-15T21:29:25Z

    Mike Mascari <mascarm@mascari.com> writes:
    > Wow. I'm not quite sure why it shouldn't work, but I've never
    > reconnected on the server side through libpq. Instead, I've
    > always used the SPI interface sequence of:
    > SPI_connect()
    > SPI_exec()
    > SPI_getvalue()
    > SPI_finish()
    
    SPI is the recommended interface for server-side addon code, I think.
    
    > I think I've tried in the past to reconnect on the server side
    > through libpq but it always resulted in a core dump of the
    > running backend.
    
    Bear in mind that libpq is not present in the backend.  If you load
    a library containing your code + libpq and then try to do something
    via libpq, what will happen is that libpq will contact the postmaster,
    fire up a new backend, and send all your queries to that other backend.
    Probably not quite what you had in mind, and I could imagine it leading
    to deadlock problems against your own backend.  (But I don't see why it
    would cause the particular error Michael is complaining of; that still
    looks like it might be a newline-versus-carriage-return kind of bug.)
    
    I believe that long ago, there was code in the backend that presented
    a libpq-equivalent interface for queries originating from loaded
    libraries, but that facility hasn't been maintained and probably
    doesn't work at all anymore.
    
    			regards, tom lane
    
    
  9. Re: [HACKERS] function question yet again

    Michael Meskes <meskes@postgresql.org> — 2000-02-16T07:14:22Z

    On Tue, Feb 15, 2000 at 04:29:25PM -0500, Tom Lane wrote:
    > SPI is the recommended interface for server-side addon code, I think.
    
    Okay, I see. That means my try to use ECPG to create a function is not
    supposed to work. Gheez, I would have liked it.
    
    > Bear in mind that libpq is not present in the backend.  If you load
    > a library containing your code + libpq and then try to do something
    > via libpq, what will happen is that libpq will contact the postmaster,
    > fire up a new backend, and send all your queries to that other backend.
    > Probably not quite what you had in mind, and I could imagine it leading
    > to deadlock problems against your own backend.  (But I don't see why it
    > would cause the particular error Michael is complaining of; that still
    > looks like it might be a newline-versus-carriage-return kind of bug.)
    
    Right. Since the function does only a select and noone else is working on
    that database it shouldn't deadlock either.
    
    Michael
    -- 
    Michael Meskes                         | Go SF 49ers!
    Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
    Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
    Email: Michael@Fam-Meskes.De           | Use PostgreSQL!
    
    
  10. Re: [HACKERS] function question yet again

    Christof Petig <christof.petig@wtal.de> — 2000-02-17T04:08:08Z

    Michael Meskes wrote:
    > 
    > On Tue, Feb 15, 2000 at 04:29:25PM -0500, Tom Lane wrote:
    > > SPI is the recommended interface for server-side addon code, I think.
    > 
    > Okay, I see. That means my try to use ECPG to create a function is not
    > supposed to work. Gheez, I would have liked it.
    
    It should be possible to create a SPI based libecpg.so! Though I don't
    know if it is worth the effort (besides getting portable server code
    (WOW)!) Hmmm. I come to like this idea.
    
    I don't have any ideas on the deadlock, though.
    
    Christof
    
    
    
  11. Re: [HACKERS] function question yet again

    Michael Meskes <meskes@postgresql.org> — 2000-02-17T19:44:05Z

    On Thu, Feb 17, 2000 at 05:08:08AM +0100, Christof Petig wrote:
    > It should be possible to create a SPI based libecpg.so! Though I don't
    > know if it is worth the effort (besides getting portable server code
    > (WOW)!) Hmmm. I come to like this idea.
    
    I really do like this idea to. But it is not realistic to get this one
    finished before 7.0 though.
    
    Michael
    -- 
    Michael Meskes                         | Go SF 49ers!
    Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
    Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
    Email: Michael@Fam-Meskes.De           | Use PostgreSQL!