Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Prepared Statement Problem

Posted on 2004-10-28
Medium Priority
Last Modified: 2012-06-27
Hello, I'm having a problem where PostgreSQL tells that a prepared statement already exists.  The trouble is that I don't use prepared statements.  Basically I'm developing a 3 tier system.  It uses .Net remoting.  I keep getting the error Prepared Statement already exists until I shut down the remote component.  That makes since seeing as the clear when the session closes.

Why am I getting this error when I'm not using prepared statements, and how can I stop it?

Thanks in advance.
Question by:Guitarman316
  • 3
  • 2
LVL 22

Expert Comment

by:earth man2
ID: 12449287
What is .Net remoting ?
LVL 22

Assisted Solution

by:earth man2
earth man2 earned 250 total points
ID: 12454542
OK .Net Remoting is DCE/DCOM in $Soft new .net framework.  Need more detail of your implementation to replicate this problem.

Author Comment

ID: 12463441
Well, Before I discuss the implementation let me say, I found Friday that if I add something random to the end of my fields like Select *, TimeStamp as Random from table where whatever that the problem mysteriously goes away.  It seems as though PostgreSQL is trying to cache the statement.  I also found that when I got the error "Prepared Statement 'PRSTMT1182451640138' Already Exists"  That if I trapped for it, stripped off everything except the statement name and then tried to deallocate that statement it would say that the statement wasn't found.  The versions of PostgreSQL I'm using are 7.4.5 and 8.0 beta2.  The problem happens on both of them.

As far as the remoting goes here's basically the way it is set up.

1) There are 3 PC's involved.  1 for client code 1 for remote component (middle tier) and 1 for database server.
2) The remote component is setup as SingleCall using MarshalByRefObject and a TCP channel for performance.
3) In addition to the remote components dll I have a dll that handles security.  This is the first place it bombs.  If security class is removed it will bomb elsewhere with same issue.
4) The remote component is setup such that each method requires security validation before any work is done.  The component is targeted potentially at the internet.  For this reason sometimes multiple calls occur where the sql statement looks the same.  The remote component uses Core Labs PostgreSQL dataadapter.
5) The remote component is then insantiated from the client and calls to the db occur from PC number 2 with datasets or affected row counts being returned to the client pc.

The only way to clear the problem once it has occured is to physically stop the remote components host and restart it.

If you need any further information please let me know.

Thanks for the help.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions


Accepted Solution

rjkimble earned 250 total points
ID: 12464397
If you think it's a PostgreSQL problem, I'm sure they'd appreciate a bug report.

Could it be that the driver you're using is creating the prepared statement behind the scenes? Maybe it's a driver issue.

Author Comment

ID: 12464812
I just recieved an email from Core Labs to try a new driver.  It appears that that has fixed the problem.  I didn't want to send in a bug report on PostgreSQL until I was sure that it was the problem.  I know I'm not to fond of unfounded bug reports.  Also I tried to duplicate it this morning with PgAdmin3.  I ran the exact same statement over and over and never got the error.

Thanks for the help.
LVL 22

Expert Comment

by:earth man2
ID: 12464854
My gut feeling is it must be a Core Labs Issue.
What is the content of  your postgres database log file.  If it is a database problem the log file should show the error.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question