473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

libpq on the server

Hi,

For various reasons (parallel structure with existing code, commonality of concepts, etc), we have C language functions implemented that use libpq to make a new connection to the same Postgres server. Yes, I realize libpq is meant for clients and SPI for backends. The question is, are there any technical problems with this? Will using libpq in the backend do Bad Things in unexpected areas/ways?

The environment ranges from:
Postgres 7.4.2, 7.4.3
RedHat 7.3, 9.0

Thanks,
Wayne
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #1
4 1577
Wayne Fang <wa***@barrodale.com> writes:
For various reasons (parallel structure with existing code,
commonality of concepts, etc), we have C language functions
implemented that use libpq to make a new connection to the same
Postgres server. Yes, I realize libpq is meant for clients and SPI
for backends. The question is, are there any technical problems with
this? Will using libpq in the backend do Bad Things in unexpected
areas/ways?


dblink does that, and I've not heard of problems, though there are
certain specific areas where you'd need to be careful due to overlap of
symbols between libpq and backend (the DLxxx functions used for
listen/notify are one such place, and there are conflicts in the
pg_wchar stuff as well). It'd be a good idea to make sure that your
custom functions will bind first to libpq and only second to the main
backend's symbols.

By the same token, don't try to link libpq statically into the backend.
But it should be possible to make it work as a dynamic link.

Realize also that this is *fundamentally* different from SPI, in that
you are controlling a separate session rather than issuing commands in
your own session. This has implications for data visibility, error
recovery, and so on. But you probably knew that already.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #2
Thanks for the reply.

At 12:10 PM 8/23/04, Tom Lane wrote:
Wayne Fang <wa***@barrodale.com> writes:
For various reasons (parallel structure with existing code,
commonality of concepts, etc), we have C language functions
implemented that use libpq to make a new connection to the same
Postgres server. Yes, I realize libpq is meant for clients and SPI
for backends. The question is, are there any technical problems with
this? Will using libpq in the backend do Bad Things in unexpected
areas/ways?
dblink does that, and I've not heard of problems, though there are
certain specific areas where you'd need to be careful due to overlap of
symbols between libpq and backend (the DLxxx functions used for
listen/notify are one such place, and there are conflicts in the
pg_wchar stuff as well). It'd be a good idea to make sure that your
custom functions will bind first to libpq and only second to the main
backend's symbols.


I haven't run into any symbol conflicts, so this shouldn't be a problem,
but I'll keep this around if it does come up.

By the same token, don't try to link libpq statically into the backend.
But it should be possible to make it work as a dynamic link.

Realize also that this is *fundamentally* different from SPI, in that
you are controlling a separate session rather than issuing commands in
your own session. This has implications for data visibility, error
recovery, and so on. But you probably knew that already.


Yes I did, but confirmation is always good.
There is a possible issue of libpq requiring a new backend process,
but the overall performance impact needs more thorough testing.
In theory, the size of information and amount of processing we deal
with will help hide the overhead involved.
As another consideration, SPI doesn't yet support transactions. Any idea
when this support might come about?

Thanks,
Wayne
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3
Wayne Fang <wa***@barrodale.com> writes:
As another consideration, SPI doesn't yet support transactions. Any idea
when this support might come about?


You can run subtransactions (savepoints) through SPI in 8.0. The API
for this could be a bit cleaner perhaps :-( but it's doable --- plpgsql
does it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #4
On Mon, Aug 23, 2004 at 12:28:26PM -0700, Wayne Fang wrote:
As another consideration, SPI doesn't yet support transactions. Any idea
when this support might come about?


Not soon. Any action that goes through SPI is using the same
transaction that it was initiated in. There's no way to meaningfully
close said transaction and keep the SPI function running.

In 8.0 you are able to use the savepoint feature through SPI, so you can
partially rollback if there is an error, take appropiate action and keep
going without having to start everything again. But it will be within
one transaction.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marco Vezzoli | last post by:
Hi all, I'm using solaris 8 gcc 3.0.1 postgres 7.3.4 psycopg 1.1.2 apache 1.3.19 python 2.1.1 mod_python 2.7.8 compiled with DSO
1
by: Phil Campaigne | last post by:
Hi All, Took a break from developing on pgsql 7.3 to set up network printing where I added another host(localhost 193.168.1.2) in red hat network settings. Later, I could start postmaster but...
1
by: Karam Chand | last post by:
Hello I have postgresql latest version running on RH 9. I want to write a windows based application to interact with postgresql server. For that I plan to use libpq i.e. using C. I can work...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
1
by: jbi130 | last post by:
I have a 3 tier client/server application where the client connection to the server which then uses PostgreSQL. I'd like to extend the client to have direct access to PostgreSQL but do not want to...
2
by: Jim Crate | last post by:
I'm trying to build a client program to access a database using the libpq interface on MacOS X 10.3.3 using CodeWarrior 9. PostgreSQL is at version 7.4.2. It compiles ok, but I get a link...
2
by: Adam Smith | last post by:
Installation of 7.4.2, even with just ./configure : gmake step ==> _________________________________________________ gmake: Leaving directory...
2
by: alltest1 | last post by:
Hi, I am wondering if it is thread-safe to use both JDBC and libpq simultaneously. On a Linux, JDBC is used by Tomcat and libpq is used by a client software written in C language. So JDBC and...
15
by: Dino Vliet | last post by:
Hi folks, probably this is a question you've heard so many times but I wasn't able to find a solution to it. I'm using a shell script to create a textfile for me. It looks like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.