pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedJDBC driver bug?
7+ messages / 6 participants
[nested] [flat]
* JDBC driver bug?
@ 2005-09-22 13:25 yoursoft@freemail.hu <yoursoft@freemail.hu>
2005-09-22 13:35 ` Re: JDBC driver bug? Csaba Nagy <nagy@ecircle-ag.com>
0 siblings, 1 reply; 7+ messages in thread
From: yoursoft@freemail.hu @ 2005-09-22 13:25 UTC (permalink / raw)
To: pgsql-jdbc
Dear Developers,
First, sorry my bad English.
My platform:
- postgresql 8.0.3 and 8.0.0 with SuSE Linux.
- java 1.5 update 4 (problem with it), java 1.4.2 (working without problem)
- jdbc 3 driver 312 (latest stable)
I found the following problem:
If I connect to the database from local host with java 1.5, or with java
1.4.2 from other box everything is good (connection time <1 sec).
When I connect to the database on other box, there is slow connection
(5-6 sec).
If you have any other question, please mail it.
Regards,
Ferenc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: JDBC driver bug?
2005-09-22 13:25 JDBC driver bug? yoursoft@freemail.hu <yoursoft@freemail.hu>
@ 2005-09-22 13:35 ` Csaba Nagy <nagy@ecircle-ag.com>
0 siblings, 0 replies; 7+ messages in thread
From: Csaba Nagy @ 2005-09-22 13:35 UTC (permalink / raw)
To: yoursoft@freemail.hu <yoursoft@freemail.hu>; +Cc: pgsql-jdbc
This kind of problems usually are caused by your network/networking code
and not postgres itself. I bet there's some DNS resolution overhead and
the different java versions you're using have different DNS
resolution/caching policies. I would take a look at DNS as a first
suspect.
HTH,
Csaba.
On Thu, 2005-09-22 at 15:25, yoursoft@freemail.hu wrote:
> Dear Developers,
>
> First, sorry my bad English.
> My platform:
> - postgresql 8.0.3 and 8.0.0 with SuSE Linux.
> - java 1.5 update 4 (problem with it), java 1.4.2 (working without problem)
> - jdbc 3 driver 312 (latest stable)
>
> I found the following problem:
> If I connect to the database from local host with java 1.5, or with java
> 1.4.2 from other box everything is good (connection time <1 sec).
> When I connect to the database on other box, there is slow connection
> (5-6 sec).
>
> If you have any other question, please mail it.
>
> Regards,
> Ferenc
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
^ permalink raw reply [nested|flat] 7+ messages in thread
* JDBC driver bug?
@ 2007-03-05 10:56 YourSoft <yoursoft@freemail.hu>
2007-03-05 11:43 ` Re: JDBC driver bug? Heikki Linnakangas <heikki@enterprisedb.com>
2007-03-05 14:35 ` Re: JDBC driver bug? Albe Laurenz <all@adv.magwien.gv.at>
0 siblings, 2 replies; 7+ messages in thread
From: YourSoft @ 2007-03-05 10:56 UTC (permalink / raw)
To: pgsql-jdbc
Dear Developers!
I found the following bug??:
When you call a pgsql stored procedure (with PreparedStatement), that
calls an other stored procedure, and you recall the stored procedure
after dropping and recreating second stored procedure, the calling will
throw an exception with:
org.postgresql.util.PSQLException: ERROR: function with OID 63315074
does not exist
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:255)
If you restart the program (create new jvm, and driver reloading), the
result will be OK.
An example program:
// ***************************************************
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
*
* @author lutischan1fb16
*/
public class Test {
public static void main(String[] args) {
Connection con = null;
try {
Class.forName("org.postgresql.Driver");
con =
DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/test",
"user", "psw");
PreparedStatement pstm = con.prepareStatement("select
test.test1(?,?)");
pstm.setInt(1, 1 );
pstm.setString(2, "2" );
ResultSet rs = pstm.executeQuery();
rs.close();
pstm.close();
// Insert Into following line a break point
System.out.println("Now you can DROP and CREATE OR REPLACE
FUNCTION test.test2");
pstm = con.prepareStatement("select test.test1(?,?)");
pstm.setInt(1, 1 );
pstm.setString(2, "2" );
rs = pstm.executeQuery();
rs.close();
System.out.println("End OK");
} catch (Exception e) {
System.out.println("End NO OK");
e.printStackTrace();
} finally {
try { con.close(); } catch (Exception e) {}
}
}
}
// ***************************************************
Database scripts:
-- DROP FUNCTION test.test1(p_a integer, p_b character varying);
CREATE OR REPLACE FUNCTION test.test1(p_a integer, p_b character varying)
RETURNS void AS
$BODY$DECLARE p_a ALIAS FOR $1;
DECLARE p_b ALIAS FOR $2;
BEGIN
PERFORM test.test2(p_a, p_b);
RETURN;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION test.test1(p_a integer, p_b character varying) OWNER TO
postgres;
GRANT EXECUTE ON FUNCTION test.test1(p_a integer, p_b character varying)
TO public;
GRANT EXECUTE ON FUNCTION test.test1(p_a integer, p_b character varying)
TO postgres;
-- DROP FUNCTION test.test2(p_a integer, p_b character varying);
CREATE OR REPLACE FUNCTION test.test2(p_a integer, p_b character varying)
RETURNS void AS
$BODY$DECLARE p_a ALIAS FOR $1;
DECLARE p_b ALIAS FOR $2;
BEGIN
RETURN;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION test.test2(p_a integer, p_b character varying) OWNER TO
postgres;
GRANT EXECUTE ON FUNCTION test.test2(p_a integer, p_b character varying)
TO public;
GRANT EXECUTE ON FUNCTION test.test2(p_a integer, p_b character varying)
TO postgres;
Best Regards:
Ferenc Lutischan
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: JDBC driver bug?
2007-03-05 10:56 JDBC driver bug? YourSoft <yoursoft@freemail.hu>
@ 2007-03-05 11:43 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-03-05 16:05 ` Re: JDBC driver bug? Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 7+ messages in thread
From: Heikki Linnakangas @ 2007-03-05 11:43 UTC (permalink / raw)
To: YourSoft <yoursoft@freemail.hu>; +Cc: pgsql-jdbc
YourSoft wrote:
> When you call a pgsql stored procedure (with PreparedStatement), that
> calls an other stored procedure, and you recall the stored procedure
> after dropping and recreating second stored procedure, the calling will
> throw an exception with:
That's a known issue. The first time you call the procedure, it's
compiled and cached. The second time you call it, the cached plan is no
longer valid because the function it depends on has been dropped and
recreated.
The good news is that Tom Lane has added support for plan invalidation
for 8.3 branch, so this should be fixed in the next major release. Until
that, you can just disconnect and reconnect, which clears the
per-connection cache, and it should work.
BTW, this problem is not specific to JDBC, another mailing list would've
been more appropriate.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: JDBC driver bug?
2007-03-05 10:56 JDBC driver bug? YourSoft <yoursoft@freemail.hu>
2007-03-05 11:43 ` Re: JDBC driver bug? Heikki Linnakangas <heikki@enterprisedb.com>
@ 2007-03-05 16:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-03-05 16:12 ` Re: JDBC driver bug? Heikki Linnakangas <heikki@enterprisedb.com>
0 siblings, 1 reply; 7+ messages in thread
From: Tom Lane @ 2007-03-05 16:05 UTC (permalink / raw)
To: Heikki Linnakangas <heikki@enterprisedb.com>; +Cc: YourSoft <yoursoft@freemail.hu>; pgsql-jdbc
Heikki Linnakangas <heikki@enterprisedb.com> writes:
> YourSoft wrote:
>> When you call a pgsql stored procedure (with PreparedStatement), that
>> calls an other stored procedure, and you recall the stored procedure
>> after dropping and recreating second stored procedure, the calling will
>> throw an exception with:
> That's a known issue. The first time you call the procedure, it's
> compiled and cached. The second time you call it, the cached plan is no
> longer valid because the function it depends on has been dropped and
> recreated.
> The good news is that Tom Lane has added support for plan invalidation
> for 8.3 branch, so this should be fixed in the next major release.
This behavior will not change in 8.3, because I have no intention of
including function invalidation in the patch. The correct answer is
"don't do that --- use CREATE OR REPLACE FUNCTION instead".
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: JDBC driver bug?
2007-03-05 10:56 JDBC driver bug? YourSoft <yoursoft@freemail.hu>
2007-03-05 11:43 ` Re: JDBC driver bug? Heikki Linnakangas <heikki@enterprisedb.com>
2007-03-05 16:05 ` Re: JDBC driver bug? Tom Lane <tgl@sss.pgh.pa.us>
@ 2007-03-05 16:12 ` Heikki Linnakangas <heikki@enterprisedb.com>
0 siblings, 0 replies; 7+ messages in thread
From: Heikki Linnakangas @ 2007-03-05 16:12 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: YourSoft <yoursoft@freemail.hu>; pgsql-jdbc
Tom Lane wrote:
> Heikki Linnakangas <heikki@enterprisedb.com> writes:
>> The good news is that Tom Lane has added support for plan invalidation
>> for 8.3 branch, so this should be fixed in the next major release.
>
> This behavior will not change in 8.3, because I have no intention of
> including function invalidation in the patch. The correct answer is
> "don't do that --- use CREATE OR REPLACE FUNCTION instead".
Oh, sorry about that.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: JDBC driver bug?
2007-03-05 10:56 JDBC driver bug? YourSoft <yoursoft@freemail.hu>
@ 2007-03-05 14:35 ` Albe Laurenz <all@adv.magwien.gv.at>
1 sibling, 0 replies; 7+ messages in thread
From: Albe Laurenz @ 2007-03-05 14:35 UTC (permalink / raw)
To: YourSoft *EXTERN* <yoursoft@freemail.hu>; pgsql-jdbc
> I found the following bug??:
> When you call a pgsql stored procedure (with PreparedStatement), that
> calls an other stored procedure, and you recall the stored procedure
> after dropping and recreating second stored procedure, the calling
will
> throw an exception with:
>
> org.postgresql.util.PSQLException: ERROR: function with OID 63315074
does not exist
Actually, that's a feature, and it has nothing to do with JDBC.
Static SQL in PL/pgSQL ist parsed when you first execute the
function, and the execution plan is retained and used in subsequent
invocations.
If you want a function to use a database object that is dropped and
recreated with the same name, you should use dynamic SQL.
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2007-03-05 16:12 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-22 13:25 JDBC driver bug? yoursoft@freemail.hu <yoursoft@freemail.hu>
2005-09-22 13:35 ` Csaba Nagy <nagy@ecircle-ag.com>
2007-03-05 10:56 JDBC driver bug? YourSoft <yoursoft@freemail.hu>
2007-03-05 11:43 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-03-05 16:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-03-05 16:12 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-03-05 14:35 ` Albe Laurenz <all@adv.magwien.gv.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox