Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4955c2

Browse files
author
Dave Cramer
committed
patch from Kris Jurka to fix large object 7.1 compatible protocol issues
modified test case from Alexey Yudichev to be part of the testsuite
1 parent95eea2d commite4955c2

File tree

4 files changed

+117
-10
lines changed

4 files changed

+117
-10
lines changed

‎src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java,v 1.17 2003/11/29 19:52:09 pgsql Exp $
9+
* $PostgreSQL: pgsql/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java,v 1.18 2003/12/17 15:38:42 davec Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -63,7 +63,7 @@ public Fastpath(BaseConnection conn, PGStream stream)
6363
*/
6464
publicObjectfastpath(intfnid,booleanresulttype,FastpathArg[]args)throwsSQLException
6565
{
66-
if (conn.haveMinimumServerVersion("7.4")) {
66+
if (conn.haveMinimumCompatibleVersion("7.4")) {
6767
returnfastpathV3(fnid,resulttype,args);
6868
}else {
6969
returnfastpathV2(fnid,resulttype,args);
@@ -78,19 +78,22 @@ private Object fastpathV3(int fnid, boolean resulttype, FastpathArg[] args) thro
7878
// send the function call
7979
try
8080
{
81-
intl_msgLen =0;
82-
l_msgLen +=16;
83-
for (inti=0;i <args.length;i++)
81+
intl_msgLen =14;
82+
for (inti=0;i <args.length;i++) {
83+
l_msgLen +=2;
8484
l_msgLen +=args[i].sendSize();
85+
}
8586

8687
stream.SendChar('F');
8788
stream.SendInteger(l_msgLen,4);
8889
stream.SendInteger(fnid,4);
89-
stream.SendInteger(1,2);
90-
stream.SendInteger(1,2);
90+
9191
stream.SendInteger(args.length,2);
92+
for (inti=0;i <args.length;i++)
93+
stream.SendInteger(1,2);
9294

93-
for (inti =0;i <args.length;i++)
95+
stream.SendInteger(args.length,2);
96+
for (inti =0;i <args.length;i++)
9497
args[i].send(stream);
9598

9699
stream.SendInteger(1,2);

‎src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2003, PostgreSQL Global Development Group
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java,v 1.11 2003/11/29 19:52:11 pgsql Exp $
14+
* $PostgreSQL: pgsql/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java,v 1.12 2003/12/17 15:38:42 davec Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -116,7 +116,7 @@ public LargeObjectManager(BaseConnection conn) throws SQLException
116116
if (conn.getMetaData().supportsSchemasInTableDefinitions()) {
117117
sql ="SELECT p.proname,p.oid "+
118118
" FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n "+
119-
" WHERE p.pronamespace=n.oid AND n.nspname='pg_catalog' AND ";
119+
" WHERE p.pronamespace=n.oid AND n.nspname='pg_catalog' AND(";
120120
}else {
121121
sql ="SELECT proname,oid FROM pg_proc WHERE ";
122122
}
@@ -129,6 +129,10 @@ public LargeObjectManager(BaseConnection conn) throws SQLException
129129
" or proname = 'loread'" +
130130
" or proname = 'lowrite'";
131131

132+
if (conn.getMetaData().supportsSchemasInTableDefinitions()) {
133+
sql +=")";
134+
}
135+
132136
ResultSetres =conn.createStatement().executeQuery(sql);
133137

134138
if (res ==null)

‎src/interfaces/jdbc/org/postgresql/test/jdbc2/Jdbc2TestSuite.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public static TestSuite suite()
5757

5858
// Fastpath/LargeObject
5959
suite.addTestSuite(BlobTest.class);
60+
suite.addTestSuite(OID74Test.class);
6061

6162
suite.addTestSuite(UpdateableResultTest.class );
6263

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
packageorg.postgresql.test.jdbc2;
2+
3+
importorg.postgresql.test.TestUtil;
4+
importjunit.framework.TestCase;
5+
importjava.io.*;
6+
importjava.sql.*;
7+
8+
importjava.io.ByteArrayInputStream;
9+
importjava.io.InputStream;
10+
importjava.sql.*;
11+
12+
/**
13+
* User: alexei
14+
* Date: 17-Dec-2003
15+
* Time: 11:01:44
16+
* @version $Id: OID74Test.java,v 1.1 2003/12/17 15:38:42 davec Exp $
17+
*/
18+
publicclassOID74TestextendsTestCase
19+
{
20+
privateConnectioncon;
21+
22+
23+
publicOID74Test(Stringname )
24+
{
25+
super(name);
26+
}
27+
publicvoidsetUp()throwsException
28+
{
29+
}
30+
publicvoidtearDown()throwsException
31+
{
32+
}
33+
publicvoidtestBinaryStream()
34+
{
35+
//set up conection here
36+
Connectionc =null;
37+
38+
Statementst =null;
39+
try
40+
{
41+
c =DriverManager.getConnection("jdbc:postgresql://localhost/test?compatible=7.1&user=test");
42+
c.setAutoCommit(false);
43+
st =c.createStatement();
44+
st.execute("CREATE TABLE temp (col oid)");
45+
}
46+
catch (SQLExceptione)
47+
{
48+
//another issue: when connecting to 7.3 database and this exception occurs because the table already exists,
49+
//st.setBinaryStream throws internal error in LargeObjectManager initialisation code
50+
fail("table creating error, probably already exists, code=" +e.getErrorCode());
51+
}
52+
finally
53+
{
54+
try{if (st !=null)st.close(); }catch(SQLExceptionex){};
55+
}
56+
57+
PreparedStatementpstmt =null;
58+
try
59+
{
60+
61+
pstmt =c.prepareStatement("INSERT INTO temp VALUES (?)");
62+
//in case of 7.4 server, should block here
63+
pstmt.setBinaryStream(1,newByteArrayInputStream(newbyte[]{1,2,3,4,5}),5);
64+
assertTrue( (pstmt.executeUpdate() ==1) );
65+
pstmt.close();
66+
67+
pstmt =c.prepareStatement("SELECT col FROM temp LIMIT 1");
68+
ResultSetrs =pstmt.executeQuery();
69+
70+
assertTrue("No results from query",rs.next() );
71+
72+
//in case of 7.4 server, should block here
73+
InputStreamin =rs.getBinaryStream(1);
74+
intdata;
75+
while ((data =in.read()) != -1)
76+
System.out.println(data);
77+
rs.close();
78+
st.close();
79+
c.createStatement().executeUpdate("DELETE FROM temp");
80+
c.commit();
81+
}
82+
catch (IOExceptionioex )
83+
{
84+
fail(ioex.getMessage() );
85+
}
86+
catch (SQLExceptionex)
87+
{
88+
fail(ex.getMessage() );
89+
}
90+
finally
91+
{
92+
try
93+
{
94+
if (c!=null)c.close();
95+
}
96+
catch(SQLExceptione1){}
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp