Fwd: Diffrence between 8.0.3 and 8.1.3

Lists: pgsql-bugspgsql-jdbc
From: "Yann PICHOT" <ypichot(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Diffrence between 8.0.3 and 8.1.3
Date: 2006-07-03 15:19:35
Message-ID: 6ff7932d0607030819o4775c43fr2762dd390d4cd76@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-jdbc

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


From: Kris Jurka <books(at)ejurka(dot)com>
To: Yann PICHOT <ypichot(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Diffrence between 8.0.3 and 8.1.3
Date: 2006-07-03 15:43:15
Message-ID: Pine.BSO.4.63.0607031038150.850@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-jdbc

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


From: "Yann PICHOT" <ypichot(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Fwd: Diffrence between 8.0.3 and 8.1.3
Date: 2006-07-05 06:57:00
Message-ID: 6ff7932d0607042357x4a464cdv2167c4b1ab12e775@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-jdbc

---------- Forwarded message ----------
From: Yann PICHOT <ypichot(at)gmail(dot)com>
Date: 4 juil. 2006 10:07
Subject: Re: [JDBC] Diffrence between 8.0.3 and 8.1.3
To: Kris Jurka <books(at)ejurka(dot)com>

2006/7/3, Yann PICHOT <ypichot(at)gmail(dot)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


From: Kris Jurka <books(at)ejurka(dot)com>
To: Yann PICHOT <ypichot(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Fwd: [JDBC] Diffrence between 8.0.3 and 8.1.3
Date: 2006-07-05 19:31:48
Message-ID: Pine.BSO.4.63.0607051425130.31538@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-jdbc

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


From: "Yann PICHOT" <ypichot(at)gmail(dot)com>
To: "Kris Jurka" <books(at)ejurka(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Fwd: Diffrence between 8.0.3 and 8.1.3
Date: 2006-07-06 13:17:08
Message-ID: 6ff7932d0607060617mda3ffb4sffdc8af30878a5eb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-jdbc

2006/7/5, Kris Jurka <books(at)ejurka(dot)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
>

Thanks, i'll follow the problem in the bug list.

--
Yann