Unix Technical Forum

getArray() and char[]

This is a discussion on getArray() and char[] within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> While looking into updating getProcedureColumns, to appropriately return COLUMN_TYPE, ran into a 'not implemented' exception. Seems that getArray is ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:33 AM
Jeffrey Cox
 
Posts: n/a
Default getArray() and char[]

While looking into updating getProcedureColumns, to appropriately
return COLUMN_TYPE, ran into a 'not implemented' exception. Seems
that getArray is not implemented for arrays of type char. Kinda fuzzy
on all this, but walked the code and ultimately added an entry in
TypeInfoCache for 'char' and then updated AbstractJdbc2Array to
handle 'char' as a java.lang.Character[] rather than java.lang.String[]

it seems that the issue was that char[] was being identified as
Types.OTHER in TypeInfoCache. Which fixed the unimplemented error.
However, considering char[] as a String caused getArray() to return a
string containing leading and trailing curly brackets. Hence the
change to AbstractJdbc2Array.

Am I missing something, or is there another way around this?


Jeff

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:33 AM
Kris Jurka
 
Posts: n/a
Default Re: getArray() and char[]



On Thu, 1 Feb 2007, Jeffrey Cox wrote:

> While looking into updating getProcedureColumns, to appropriately return
> COLUMN_TYPE, ran into a 'not implemented' exception. Seems that getArray
> is not implemented for arrays of type char. Kinda fuzzy on all this, but
> walked the code and ultimately added an entry in TypeInfoCache for
> 'char' and then updated AbstractJdbc2Array to handle 'char' as a
> java.lang.Character[] rather than java.lang.String[]


This is not quite right. The pg_proc column you are looking at is an
array of "char" which is a special one byte datatype which is different
than something like char(N) which is implemented by the bpchar type on the
backend. The new TypeInfoCache code is correct, but the
AbstractJdbc2Array must still return String[] since it must support the
char(N) version as well.

> it seems that the issue was that char[] was being identified as
> Types.OTHER in TypeInfoCache. Which fixed the unimplemented error.
> However, considering char[] as a String caused getArray() to return a
> string containing leading and trailing curly brackets. Hence the change
> to AbstractJdbc2Array.
>


I'm not sure why that would happen, perhaps it indicates another bug?
I cannot duplicate it here with the attached test case and your
TypeInfoCache changes.

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-16-2008, 12:34 AM
Kris Jurka
 
Posts: n/a
Default Re: getArray() and char[]



On Thu, 1 Feb 2007, Jeffrey Cox wrote:

> Are you saying that the line I added in TypeInfoCache was correct with
> "java.lang.Character", but in AbstractJdbc2Array I need to do something to
> ensure the return of a string... or should the line in TypeInfoCache be a
> string?
>



I was only really thinking about the addition to TypeInfoCache mapping
"char" -> Types.CHAR, but you're right the class should be
java.lang.String. That class must be what's returned by getObject which
is driven off the Types.CHAR value.

Kris Jurka



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:33 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com