Diffrence between 8.0.3 and 8.1.3
Hi,
I use this JDBC Driver :
JDBC driver build number : 8.1.407-JDBC3
Server version : test do on 8.0.3 (linux), 8.1.3 (linux) and 8.1.2 (windows)
I have problem with the method getColumnDisplaySize in ResultSetMetaData
class.
I have this java program:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class Test {
public static void main(String[] args) {
try {
Properties props = new Properties();
Statement stmt = null;
Class.forName("org.postgresql.Driver");
props.put("user","xxxxx");
props.put("password","xxxxx");
Connection conn =
DriverManager.getConnection("jdbc:postgresql://myhost/mydatabase",
props);
try {
String SQLselect = "SELECT col1, cast(' ' as varchar(3)) as mycol
FROM mytable";
stmt = conn.createStatement();
ResultSet res = stmt.executeQuery(SQLselect);
ResultSetMetaData resMD = res.getMetaData();
System.out.println(resMD.getColumnDisplaySize(2));
res.close();
stmt.close();
} catch ( Exception e ) {
System.out.println("Error 1 : " + e.getMessage());
e.printStackTrace();
}
finally {
conn.close();
}
} catch ( Exception e) {
System.out.println("Error 2 : " + e.getMessage());
e.printStackTrace();
}
}
}
When i connect to 8.0.3 database the methode getColumnDisplaySize return 3,
a good value
When i connect to 8.1.2 or 8.1.3 database the methode getColumnDisplaySize
return -5, a bad value.
I saw the source of the JDBC Driver and i saw the difference is in data read
on socket in the method receiveFields in QueryExecutorImpl class.
When i connect to 8.0.3 database, on this line of the method :
...
int typeModifier = pgStream.ReceiveIntegerR(4);
...
typeModifier is set to 7.
When i conenct to 8.1.2 or 8.1.3, typeModifier is set to -1
Is it normal ? Someone can explain this ?
Regards,
--
Yann
On Mon, 3 Jul 2006, Yann PICHOT wrote:
I use this JDBC Driver :
JDBC driver build number : 8.1.407-JDBC3
Server version : test do on 8.0.3 (linux), 8.1.3 (linux) and 8.1.2 (windows)I have problem with the method getColumnDisplaySize in ResultSetMetaData
class.String SQLselect = "SELECT col1, cast(' ' as varchar(3)) as mycol
FROM mytable";
stmt = conn.createStatement();
ResultSet res = stmt.executeQuery(SQLselect);
ResultSetMetaData resMD = res.getMetaData();
System.out.println(resMD.getColumnDisplaySize(2));When i connect to 8.0.3 database the methode getColumnDisplaySize return 3,
a good value
When i connect to 8.1.2 or 8.1.3 database the methode getColumnDisplaySize
return -5, a bad value.
I cannot reproduce this with a 8.1.4 database and nothing in the
8.1.3 -> 8.1.4 release notes suggest that this behavior should have
changed. Are you sure you're exactly describing your test, jdbc driver,
and server versions?
Kris Jurka
---------- Forwarded message ----------
From: Yann PICHOT <ypichot@gmail.com>
Date: 4 juil. 2006 10:07
Subject: Re: [JDBC] Diffrence between 8.0.3 and 8.1.3
To: Kris Jurka <books@ejurka.com>
2006/7/3, Yann PICHOT <ypichot@gmail.com>:
Yes i describe exactly my test. Tomorrow, i download and install 8.1.4 and
i test it again. I do my test with JDK 1.5.--
Yann
Hi,
I install 8.1.4 and i do test and i have the same problem.
When i use this SQL request : SELECT col1, cast(' ' as varchar(3)) as mycol
FROM mytable, getColumnDisplaySize return -5.
When i use this SQL request : SELECT col1, cast(' ' as varchar(3)) as mycol,
getColumnDisplaySize return 3 !!!!
I do these tests with SQL_ASCII and LATIN9 database code page.
Regards,
--
Yann
--
Yann
Import Notes
Reply to msg id not found: 6ff7932d0607040107n30227e50vc8990eefdeb03133@mail.gmail.com
On Wed, 5 Jul 2006, Yann PICHOT wrote:
When i use this SQL request : SELECT col1, cast(' ' as varchar(3)) as mycol
FROM mytable, getColumnDisplaySize return -5.
When i use this SQL request : SELECT col1, cast(' ' as varchar(3)) as mycol,
getColumnDisplaySize return 3 !!!!
OK, I misunderstood your test case and was only looking at the second
version which works. As you noted earlier the server is responding with a
different typmod value, so this is not a JDBC problem, but a server
regression and I've forwarded this on to the -bugs list. To summarize for
them:
In 8.0 "SELECT ' '::varchar(3) FROM tab" retained the typmod value
specified in the query, but in 8.1 it is lost and -1 is used instead.
Kris Jurka
2006/7/5, Kris Jurka <books@ejurka.com>:
On Wed, 5 Jul 2006, Yann PICHOT wrote:
When i use this SQL request : SELECT col1, cast(' ' as varchar(3)) as
mycol
FROM mytable, getColumnDisplaySize return -5.
When i use this SQL request : SELECT col1, cast(' ' as varchar(3)) asmycol,
getColumnDisplaySize return 3 !!!!
OK, I misunderstood your test case and was only looking at the second
version which works. As you noted earlier the server is responding with a
different typmod value, so this is not a JDBC problem, but a server
regression and I've forwarded this on to the -bugs list. To summarize for
them:In 8.0 "SELECT ' '::varchar(3) FROM tab" retained the typmod value
specified in the query, but in 8.1 it is lost and -1 is used instead.Kris Jurka
Thanks, i'll follow the problem in the bug list.
--
Yann