pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
getTypeMap() returns null - bug?
14+ messages / 5 participants
[nested] [flat]

* getTypeMap() returns null - bug?
@ 2020-05-11 05:03 javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 07:20 ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 2 replies; 14+ messages in thread

From: javadesigner @ 2020-05-11 05:03 UTC (permalink / raw)
  To: pgsql-jdbc

Hi all:

I'm playing around with customized Type Mappings and have the following 
snipped of code:

====
Connection con = getConnection();  /*get connection from driver - util 
method*/
System.out.println("GOT CONNECTION:" + con);
java.util.Map map = con.getTypeMap();
System.out.println("map:"+map);
====

When I run this I get:

GOT CONNECTION:org.postgresql.jdbc.PgConnection@3f8f9dd6
map:null

getTypeMap should return a map but it returns null !

I don't see any pending issues/bug on the mailing list archives.

I'm using the following (up-to-date) setup:

postgres 11.7
driver: postgresql-42.2.12.jar
java: 1.8.x

Best,
-J





^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
@ 2020-05-11 06:20 ` rob stone <floriparob@gmail.com>
  2020-05-11 06:28   ` Re: getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 07:44   ` Re: getTypeMap() returns null - bug? Mark Rotteveel <mark@lawinegevaar.nl>
  2020-05-11 09:54   ` Re: getTypeMap() returns null - bug? Dave Cramer <davecramer@postgres.rocks>
  1 sibling, 3 replies; 14+ messages in thread

From: rob stone @ 2020-05-11 06:20 UTC (permalink / raw)
  To: javadesigner <javadesigner@yahoo.com>; pgsql-jdbc

Hi,

On Mon, 2020-05-11 at 01:03 -0400, javadesigner wrote:
> Hi all:
> 
> I'm playing around with customized Type Mappings and have the
> following 
> snipped of code:
> 
> ====
> Connection con = getConnection();  /*get connection from driver -
> util 
> method*/
> System.out.println("GOT CONNECTION:" + con);
> java.util.Map map = con.getTypeMap();
> System.out.println("map:"+map);
> ====
> 
> When I run this I get:
> 
> GOT CONNECTION:org.postgresql.jdbc.PgConnection@3f8f9dd6
> map:null
> 
> getTypeMap should return a map but it returns null !
> 
> I don't see any pending issues/bug on the mailing list archives.
> 
> I'm using the following (up-to-date) setup:
> 
> postgres 11.7
> driver: postgresql-42.2.12.jar
> java: 1.8.x
> 
> Best,
> -J
> 
> 



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
@ 2020-05-11 06:28   ` javadesigner <javadesigner@yahoo.com>
  2020-05-12 04:10     ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2 siblings, 1 reply; 14+ messages in thread

From: javadesigner @ 2020-05-11 06:28 UTC (permalink / raw)
  To: pgsql-jdbc

empty is not the same as null in java. this is a java specific 
discussion btw.

rob stone wrote on 5/11/20 2:20 AM:
> Hi,
>
> On Mon, 2020-05-11 at 01:03 -0400, javadesigner wrote:
>> Hi all:
>>
>>
>>  From the doco:-
>> [..]
>>
>> Note this paragraph:- "Retrieves the Map object associated with this
>> Connection object. Unless the application has added an entry, the type
>> map returned will be empty." I.e., null.
>>
>>
>>
>>
>>






^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 06:28   ` Re: getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
@ 2020-05-12 04:10     ` rob stone <floriparob@gmail.com>
  2020-05-12 04:26       ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
  2020-05-12 12:42       ` Re: getTypeMap() returns null - bug? Mark Rotteveel <mark@lawinegevaar.nl>
  0 siblings, 2 replies; 14+ messages in thread

From: rob stone @ 2020-05-12 04:10 UTC (permalink / raw)
  To: javadesigner <javadesigner@yahoo.com>; pgsql-jdbc



On Mon, 2020-05-11 at 02:28 -0400, javadesigner wrote:
> empty is not the same as null in java. this is a java specific 
> discussion btw.
> 

Vraimente.

java.util.Map map = con.getTypeMap();

So, the variable "map" is now an empty map object. Highly likely it
contains hex zeroes. It could contain the string "empty" but that does
not sound reasonable. Maybe there is no memory address and memory is
only allocated with the first "put".

System.out.println("map:"+map);

So, println accesses the memory occupied by the object and assuming it
contains unprintable hex zeroes, it can either display "null", or
convert to printable zeroes or ignore it and display nothing.

What output did you expect from  "System.out.println("map:"+map);"??
That is the question.








^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 06:28   ` Re: getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-12 04:10     ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
@ 2020-05-12 04:26       ` David G. Johnston <david.g.johnston@gmail.com>
  2020-05-12 10:00         ` Re: getTypeMap() returns null - bug? Dave Cramer <davecramer@postgres.rocks>
  1 sibling, 1 reply; 14+ messages in thread

From: David G. Johnston @ 2020-05-12 04:26 UTC (permalink / raw)
  To: rob stone <floriparob@gmail.com>; +Cc: javadesigner <javadesigner@yahoo.com>; pgsql-jdbc

On Monday, May 11, 2020, rob stone <floriparob@gmail.com> wrote:

>
>
> On Mon, 2020-05-11 at 02:28 -0400, javadesigner wrote:
> > empty is not the same as null in java. this is a java specific
> > discussion btw.
> >
>
> Vraimente.
>
> java.util.Map map = con.getTypeMap();
>
> So, the variable "map" is now an empty map object.


>
No, it wasn’t (its since been modified in between your two posts - you
should skim the whole thread). Feel free to read the source code if you
don’t believe the OP.


> Highly likely it
> contains hex zeroes. It could contain the string "empty" but that does
> not sound reasonable


>
This would be the English idiom “speaking out of one’s a**” :)


> Maybe there is no memory address and memory is
> only allocated with the first "put".
>
> System.out.println("map:"+map);
>
> So, println accesses the memory occupied by the object and assuming it
> contains unprintable hex zeroes, it can either display "null", or
> convert to printable zeroes or ignore it and display nothing.
>
> What output did you expect from  "System.out.println("map:"+map);"??
> That is the question.
>

Create an empty HashMap in Java and then print it out - that’s what we
expected.  Not “null” which only prints if the variable being printed is
null.

David J.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 06:28   ` Re: getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-12 04:10     ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-12 04:26       ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
@ 2020-05-12 10:00         ` Dave Cramer <davecramer@postgres.rocks>
  0 siblings, 0 replies; 14+ messages in thread

From: Dave Cramer @ 2020-05-12 10:00 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: rob stone <floriparob@gmail.com>; javadesigner <javadesigner@yahoo.com>; pgsql-jdbc

On Tue, 12 May 2020 at 00:26, David G. Johnston <david.g.johnston@gmail.com>
wrote:

> On Monday, May 11, 2020, rob stone <floriparob@gmail.com> wrote:
>
>>
>>
>> On Mon, 2020-05-11 at 02:28 -0400, javadesigner wrote:
>> > empty is not the same as null in java. this is a java specific
>> > discussion btw.
>> >
>>
>> Vraimente.
>>
>> java.util.Map map = con.getTypeMap();
>>
>> So, the variable "map" is now an empty map object.
>
>
>>
> No, it wasn’t (its since been modified in between your two posts - you
> should skim the whole thread). Feel free to read the source code if you
> don’t believe the OP.
>
>
>> Highly likely it
>> contains hex zeroes. It could contain the string "empty" but that does
>> not sound reasonable
>
>
>>
> This would be the English idiom “speaking out of one’s a**” :)
>
>
>> Maybe there is no memory address and memory is
>> only allocated with the first "put".
>>
>> System.out.println("map:"+map);
>>
>> So, println accesses the memory occupied by the object and assuming it
>> contains unprintable hex zeroes, it can either display "null", or
>> convert to printable zeroes or ignore it and display nothing.
>>
>> What output did you expect from  "System.out.println("map:"+map);"??
>> That is the question.
>>
>
> Create an empty HashMap in Java and then print it out - that’s what we
> expected.  Not “null” which only prints if the variable being printed is
> null.
>
> David J.
>

David,

Apparently you were correct. Throwing a notImplemented exception would be
better as this whole discussion is moot until being able to actually do
something with the typemap is implemented.


Dave Cramer
www.postgres.rocks

>
>
>

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 06:28   ` Re: getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-12 04:10     ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
@ 2020-05-12 12:42       ` Mark Rotteveel <mark@lawinegevaar.nl>
  1 sibling, 0 replies; 14+ messages in thread

From: Mark Rotteveel @ 2020-05-12 12:42 UTC (permalink / raw)
  To: pgsql-jdbc@lists.postgresql.org

On 2020-05-12 06:10, rob stone wrote:
> On Mon, 2020-05-11 at 02:28 -0400, javadesigner wrote:
>> empty is not the same as null in java. this is a java specific
>> discussion btw.
>> 
> 
> Vraimente.
> 
> java.util.Map map = con.getTypeMap();
> 
> So, the variable "map" is now an empty map object. Highly likely it
> contains hex zeroes. It could contain the string "empty" but that does
> not sound reasonable. Maybe there is no memory address and memory is
> only allocated with the first "put".

That is not how maps work in Java. A map is a collection of keys and 
values (aka a hashtable or dictionary), an empty map has no keys (and 
thus no values).

> System.out.println("map:"+map);
> 
> So, println accesses the memory occupied by the object and assuming it
> contains unprintable hex zeroes, it can either display "null", or
> convert to printable zeroes or ignore it and display nothing.
> 
> What output did you expect from  "System.out.println("map:"+map);"??
> That is the question.

Printing out a map is not what you'd normally do in Java, but if you do, 
an empty map will print (without quotes): '{}', assuming the 
java.util.HashMap implementation or the value of 
java.util.Collections.emptyMap().

Mark





^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
@ 2020-05-11 07:44   ` Mark Rotteveel <mark@lawinegevaar.nl>
  2 siblings, 0 replies; 14+ messages in thread

From: Mark Rotteveel @ 2020-05-11 07:44 UTC (permalink / raw)
  To: pgsql-jdbc@lists.postgresql.org

On 2020-05-11 08:20, rob stone wrote:
> Note this paragraph:- "Retrieves the Map object associated with this
> Connection object. Unless the application has added an entry, the type
> map returned will be empty." I.e., null.

No, empty does not mean null, it means returning an empty map (eg 
Collections.emptyMap()) or an empty instance of a Map implementation). 
If the PostgreSQL JDBC driver doesn't support type maps, then it should 
throw a SQLFeatureNotSupportedException instead.

Mark





^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
@ 2020-05-11 09:54   ` Dave Cramer <davecramer@postgres.rocks>
  2020-05-11 14:00     ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
  2 siblings, 1 reply; 14+ messages in thread

From: Dave Cramer @ 2020-05-11 09:54 UTC (permalink / raw)
  To: rob stone <floriparob@gmail.com>; +Cc: javadesigner <javadesigner@yahoo.com>; pgsql-jdbc

On Mon, 11 May 2020 at 02:21, rob stone <floriparob@gmail.com> wrote:

> Hi,
>
> On Mon, 2020-05-11 at 01:03 -0400, javadesigner wrote:
> > Hi all:
> >
> > I'm playing around with customized Type Mappings and have the
> > following
> > snipped of code:
> >
> > ====
> > Connection con = getConnection();  /*get connection from driver -
> > util
> > method*/
> > System.out.println("GOT CONNECTION:" + con);
> > java.util.Map map = con.getTypeMap();
> > System.out.println("map:"+map);
> > ====
> >
> > When I run this I get:
> >
> > GOT CONNECTION:org.postgresql.jdbc.PgConnection@3f8f9dd6
> > map:null
> >
> > getTypeMap should return a map but it returns null !
> >
> > I don't see any pending issues/bug on the mailing list archives.
> >
> > I'm using the following (up-to-date) setup:
> >
> > postgres 11.7
> > driver: postgresql-42.2.12.jar
> > java: 1.8.x
> >
> > Best,
> > -J
> >
> >
>
> From the doco:-
>
> Map<String,Class<?>> getTypeMap() throws SQLException
>
> Retrieves the Map object associated with this Connection object. Unless
> the application has added an entry, the type map returned will be
> empty.
>
> You must invoke setTypeMap after making changes to the Map object
> returned from getTypeMap as a JDBC driver may create an internal copy
> of the Map object passed to setTypeMap:
>
>       Map<String,Class<?>> myMap = con.getTypeMap();
>       myMap.put("mySchemaName.ATHLETES", Athletes.class);
>       con.setTypeMap(myMap);
>
>
> Returns:
>     the java.util.Map object associated with this Connection object
> Throws:
>     SQLException - if a database access error occurs or this method is
> called on a closed connection
>     SQLFeatureNotSupportedException - if the JDBC driver does not
> support this method
> Since:
>     1.2
>
>
>
> Note this paragraph:- "Retrieves the Map object associated with this
> Connection object. Unless the application has added an entry, the type
> map returned will be empty." I.e., null.
>
> Yes, it is a bug. It should return an empty typemap


Dave Cramer
www.postgres.rocks

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 09:54   ` Re: getTypeMap() returns null - bug? Dave Cramer <davecramer@postgres.rocks>
@ 2020-05-11 14:00     ` David G. Johnston <david.g.johnston@gmail.com>
  2020-05-11 14:04       ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 14+ messages in thread

From: David G. Johnston @ 2020-05-11 14:00 UTC (permalink / raw)
  To: Dave Cramer <davecramer@postgres.rocks>; +Cc: rob stone <floriparob@gmail.com>; javadesigner <javadesigner@yahoo.com>; pgsql-jdbc

On Monday, May 11, 2020, Dave Cramer <davecramer@postgres.rocks> wrote:

>
>
> On Mon, 11 May 2020 at 02:21, rob stone <floriparob@gmail.com> wrote:
>
>> Hi,
>>
>> On Mon, 2020-05-11 at 01:03 -0400, javadesigner wrote:
>> > Hi all:
>> >
>> > I'm playing around with customized Type Mappings and have the
>> > following
>> > snipped of code:
>> >
>> > ====
>> > Connection con = getConnection();  /*get connection from driver -
>> > util
>> > method*/
>> > System.out.println("GOT CONNECTION:" + con);
>> > java.util.Map map = con.getTypeMap();
>> > System.out.println("map:"+map);
>> > ====
>> >
>> > When I run this I get:
>> >
>> > GOT CONNECTION:org.postgresql.jdbc.PgConnection@3f8f9dd6
>> > map:null
>> >
>> > getTypeMap should return a map but it returns null !
>> >
>> > I don't see any pending issues/bug on the mailing list archives.
>> >
>> > I'm using the following (up-to-date) setup:
>> >
>> > postgres 11.7
>> > driver: postgresql-42.2.12.jar
>> > java: 1.8.x
>> >
>> > Best,
>> > -J
>> >
>> >
>>
>> From the doco:-
>>
>> Map<String,Class<?>> getTypeMap() throws SQLException
>>
>> Retrieves the Map object associated with this Connection object. Unless
>> the application has added an entry, the type map returned will be
>> empty.
>>
>> You must invoke setTypeMap after making changes to the Map object
>> returned from getTypeMap as a JDBC driver may create an internal copy
>> of the Map object passed to setTypeMap:
>>
>>       Map<String,Class<?>> myMap = con.getTypeMap();
>>       myMap.put("mySchemaName.ATHLETES", Athletes.class);
>>       con.setTypeMap(myMap);
>>
>>
>> Returns:
>>     the java.util.Map object associated with this Connection object
>> Throws:
>>     SQLException - if a database access error occurs or this method is
>> called on a closed connection
>>     SQLFeatureNotSupportedException - if the JDBC driver does not
>> support this method
>> Since:
>>     1.2
>>
>>
>>
>> Note this paragraph:- "Retrieves the Map object associated with this
>> Connection object. Unless the application has added an entry, the type
>> map returned will be empty." I.e., null.
>>
>> Yes, it is a bug. It should return an empty typemap
>


Given the code in getObject and lack of use anywhere else I’d say it should
return the unsupported exception.  Not reason to delay the error until
later.

David J.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 09:54   ` Re: getTypeMap() returns null - bug? Dave Cramer <davecramer@postgres.rocks>
  2020-05-11 14:00     ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
@ 2020-05-11 14:04       ` David G. Johnston <david.g.johnston@gmail.com>
  2020-05-11 14:05         ` Re: getTypeMap() returns null - bug? Dave Cramer <davecramer@postgres.rocks>
  0 siblings, 1 reply; 14+ messages in thread

From: David G. Johnston @ 2020-05-11 14:04 UTC (permalink / raw)
  To: Dave Cramer <davecramer@postgres.rocks>; +Cc: rob stone <floriparob@gmail.com>; javadesigner <javadesigner@yahoo.com>; pgsql-jdbc

On Monday, May 11, 2020, David G. Johnston <david.g.johnston@gmail.com>
wrote:

>
>>> Yes, it is a bug. It should return an empty typemap
>>
>
>
> Given the code in getObject and lack of use anywhere else I’d say it
> should return the unsupported exception.  Not reason to delay the error
> until later.
>

Actually...I’ll srick with my original thought that making it an exception
now is not desirable as it could break working code (though not likely...)
for no real gain.

David J.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 09:54   ` Re: getTypeMap() returns null - bug? Dave Cramer <davecramer@postgres.rocks>
  2020-05-11 14:00     ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
  2020-05-11 14:04       ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
@ 2020-05-11 14:05         ` Dave Cramer <davecramer@postgres.rocks>
  2020-05-11 14:14           ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 14+ messages in thread

From: Dave Cramer @ 2020-05-11 14:05 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: rob stone <floriparob@gmail.com>; javadesigner <javadesigner@yahoo.com>; pgsql-jdbc

On Mon, 11 May 2020 at 10:04, David G. Johnston <david.g.johnston@gmail.com>
wrote:

> On Monday, May 11, 2020, David G. Johnston <david.g.johnston@gmail.com>
> wrote:
>
>>
>>>> Yes, it is a bug. It should return an empty typemap
>>>
>>
>>
>> Given the code in getObject and lack of use anywhere else I’d say it
>> should return the unsupported exception.  Not reason to delay the error
>> until later.
>>
>
> Actually...I’ll srick with my original thought that making it an exception
> now is not desirable as it could break working code (though not likely...)
> for no real gain.
>
> David J.
>

Using it will throw an exception later in getObject()
Dave Cramer
www.postgres.rocks

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
  2020-05-11 06:20 ` Re: getTypeMap() returns null - bug? rob stone <floriparob@gmail.com>
  2020-05-11 09:54   ` Re: getTypeMap() returns null - bug? Dave Cramer <davecramer@postgres.rocks>
  2020-05-11 14:00     ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
  2020-05-11 14:04       ` Re: getTypeMap() returns null - bug? David G. Johnston <david.g.johnston@gmail.com>
  2020-05-11 14:05         ` Re: getTypeMap() returns null - bug? Dave Cramer <davecramer@postgres.rocks>
@ 2020-05-11 14:14           ` David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 14+ messages in thread

From: David G. Johnston @ 2020-05-11 14:14 UTC (permalink / raw)
  To: Dave Cramer <davecramer@postgres.rocks>; +Cc: rob stone <floriparob@gmail.com>; javadesigner <javadesigner@yahoo.com>; pgsql-jdbc

On Monday, May 11, 2020, Dave Cramer <davecramer@postgres.rocks> wrote:

>
>
> On Mon, 11 May 2020 at 10:04, David G. Johnston <
> david.g.johnston@gmail.com> wrote:
>
>> On Monday, May 11, 2020, David G. Johnston <david.g.johnston@gmail.com>
>> wrote:
>>
>>>
>>>>> Yes, it is a bug. It should return an empty typemap
>>>>
>>>
>>>
>>> Given the code in getObject and lack of use anywhere else I’d say it
>>> should return the unsupported exception.  Not reason to delay the error
>>> until later.
>>>
>>
>> Actually...I’ll srick with my original thought that making it an
>> exception now is not desirable as it could break working code (though not
>> likely...) for no real gain.
>>
>> David J.
>>
>
> Using it will throw an exception later in getObject()
>

I know...IMO that whole block in getObject should be tossed, the protected
variable removed, and the getter and setter made to throw exceptions.
Having the exception happen in getObject is what i’m opposed to but accept
as a matter of backward compatibility.

David J.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: getTypeMap() returns null - bug?
  2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
@ 2020-05-11 07:20 ` David G. Johnston <david.g.johnston@gmail.com>
  1 sibling, 0 replies; 14+ messages in thread

From: David G. Johnston @ 2020-05-11 07:20 UTC (permalink / raw)
  To: javadesigner <javadesigner@yahoo.com>; +Cc: pgsql-jdbc

On Sunday, May 10, 2020, javadesigner <javadesigner@yahoo.com> wrote:

> Hi all:
>
> I'm playing around with customized Type Mappings and have the following
> snipped of code:
>
> ====
> Connection con = getConnection();  /*get connection from driver - util
> method*/
> System.out.println("GOT CONNECTION:" + con);
> java.util.Map map = con.getTypeMap();
> System.out.println("map:"+map);
> ====
>
> When I run this I get:
>
> GOT CONNECTION:org.postgresql.jdbc.PgConnection@3f8f9dd6
> map:null
>
> getTypeMap should return a map but it returns null !


While I agree, the feature is effectively not supported.

https://github.com/pgjdbc/pgjdbc/blob/14576f4bca3a2484fd4f81a0d8276ae5cab9a419/pgjdbc/src/main/java/...

I can’t see changing it to throw a runtime exception and returning an empty
map doesn’t make it any more usable so I don’t see the point there either.
The documentation could better reflect reality though.

David J.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread


end of thread, other threads:[~2020-05-12 12:42 UTC | newest]

Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 05:03 getTypeMap() returns null - bug? javadesigner <javadesigner@yahoo.com>
2020-05-11 06:20 ` rob stone <floriparob@gmail.com>
2020-05-11 06:28   ` javadesigner <javadesigner@yahoo.com>
2020-05-12 04:10     ` rob stone <floriparob@gmail.com>
2020-05-12 04:26       ` David G. Johnston <david.g.johnston@gmail.com>
2020-05-12 10:00         ` Dave Cramer <davecramer@postgres.rocks>
2020-05-12 12:42       ` Mark Rotteveel <mark@lawinegevaar.nl>
2020-05-11 07:44   ` Mark Rotteveel <mark@lawinegevaar.nl>
2020-05-11 09:54   ` Dave Cramer <davecramer@postgres.rocks>
2020-05-11 14:00     ` David G. Johnston <david.g.johnston@gmail.com>
2020-05-11 14:04       ` David G. Johnston <david.g.johnston@gmail.com>
2020-05-11 14:05         ` Dave Cramer <davecramer@postgres.rocks>
2020-05-11 14:14           ` David G. Johnston <david.g.johnston@gmail.com>
2020-05-11 07:20 ` David G. Johnston <david.g.johnston@gmail.com>

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