Unix Technical Forum

SEO

vBulletin Search Engine Optimization


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 11:22 PM
Oliver Jowett
 
Posts: n/a
Default Re: jdbc cts final diff for review

Dave Cramer wrote:
> Attached is the patch for review. QueryExecutor is unchanged now.
>
> The only iffy bit is where I check for the in parameter being bound to
> void type. It could be done in checkAllParametersSet
>
> I'd like to commit this shortly.


Ok, comments from just reading the patch.. I like the approach much
better than the previous one, but the details need some cleanup.

Rather than putting knowledge of parameter direction into ParameterList,
how about just allowing access to the type OID, and the caller checks
for Oid.VOID? Then the ParameterList interface changes less and the
change to use a Parameter class is unnecessary as the list doesn't need
to store a direction value.

If you must store a direction value in the list, then another array
might be better than wrapping everything up in an object (generates less
garbage overall). Also, there are a few places that return magic values
for the direction that should be using the symbolic constants you've
defined elsewhere.

The change to checkAllParametersSet to not check OUT parameters seems
unnecessary -- won't OUT parameters be set to the (non-null) NULL_OBJECT
anyway?

> ! // this is here for the sole purpose of passing the cts
> ! if ( columnType == Types.DOUBLE && functionReturnType[i] == Types.REAL )
> ! {
> ! // return it as a float
> ! if ( callResult[i] != null)
> ! callResult[i] = new Float(((Double)callResult[i]).floatValue());
> ! }


We can't do that! If it's failing that's probably because we're not
doing the necessary implicit typecasts required by the spec..

Please explain what's going on here:

> + case Types.FLOAT: // TODO: FLOAT and REAL were FLOAT8 for the cts


> public void setFloat(int parameterIndex, float x) throws SQLException
> {
> checkClosed();
> ! bindLiteral(parameterIndex, Float.toString(x), Oid.FLOAT8);
> }
>


(the bind changed from Oid.FLOAT4 to Oid.FLOAT8..)

You seem to have reverted your earlier changes and put back the types/*
classes -- why?

adjustParamIndex() should be removed entirely if it's now always a no-op.

Why is type translation for JDBC2 types only done in the JDBC3 code (in
registerOutParameter)? -- shouldn't that be in the JDBC2 code?

There are a bunch of gratuitous changes to the test code that probably
shouldn't be committed, e.g. in BatchExecuteTest:

> + try
> + {
> + Class.forName("org.postgresql.Driver");
> + }
> + catch( Exception ex){}


similarly in many other test classes.

.....

It might be an idea to break this up into "support new-style OUT
parameters" and "other fixes necessary to pass the CTS" as currently
it's quite unclear which is which..

-O

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 11:22 PM
Dave Cramer
 
Posts: n/a
Default Re: jdbc cts final diff for review


On 29-Jun-05, at 9:17 AM, Oliver Jowett wrote:

> Dave Cramer wrote:
>
>> Attached is the patch for review. QueryExecutor is unchanged now.
>> The only iffy bit is where I check for the in parameter being
>> bound to void type. It could be done in checkAllParametersSet
>> I'd like to commit this shortly.
>>

>
> Ok, comments from just reading the patch.. I like the approach much
> better than the previous one, but the details need some cleanup.
>
> Rather than putting knowledge of parameter direction into
> ParameterList, how about just allowing access to the type OID, and
> the caller checks for Oid.VOID? Then the ParameterList interface
> changes less and the change to use a Parameter class is unnecessary
> as the list doesn't need to store a direction value.
>
> If you must store a direction value in the list, then another array
> might be better than wrapping everything up in an object (generates
> less garbage overall). Also, there are a few places that return
> magic values for the direction that should be using the symbolic
> constants you've defined elsewhere.

I thought of this, however even arrays have to be garbage collected..
Is there really much difference internally between new Parameter and
new int?

I'm ambivalent though it's not a big change either way.
>
> The change to checkAllParametersSet to not check OUT parameters
> seems unnecessary -- won't OUT parameters be set to the (non-null)
> NULL_OBJECT anyway?
>
>
>> ! // this is here for the sole purpose of
>> passing the cts
>> ! if ( columnType == Types.DOUBLE &&
>> functionReturnType[i] == Types.REAL )
>> ! {
>> ! // return it as a float
>> ! if ( callResult[i] != null)
>> ! callResult[i] = new Float(((Double)
>> callResult[i]).floatValue());
>> ! }


I'll go through my notes, but I can tell you it was a catch 22
problem mostly likely an artifact of Oracle not having a REAL type.
> We can't do that! If it's failing that's probably because we're not
> doing the necessary implicit typecasts required by the spec..
>
> Please explain what's going on here:


from an SQL point of view FLOAT, and double are FLOAT8 types, REAL is
the only one that is FLOAT4
>
>
>> + case Types.FLOAT: // TODO: FLOAT and REAL
>> were FLOAT8 for the cts
>>

>
>
>> public void setFloat(int parameterIndex, float x) throws
>> SQLException
>> {
>> checkClosed();
>> ! bindLiteral(parameterIndex, Float.toString(x), Oid.FLOAT8);
>> }
>>
>>

>
> (the bind changed from Oid.FLOAT4 to Oid.FLOAT8..)
>
> You seem to have reverted your earlier changes and put back the
> types/* classes -- why?

huh ? they should be in there in HEAD, I did remove the creation of
an object, and went to static methods
>
> adjustParamIndex() should be removed entirely if it's now always a
> no-op.

yeah
>
> Why is type translation for JDBC2 types only done in the JDBC3 code
> (in registerOutParameter)? -- shouldn't that be in the JDBC2 code?
>

Good point
> There are a bunch of gratuitous changes to the test code that
> probably shouldn't be committed, e.g. in BatchExecuteTest:
>

agreed, they are for my own testing
>
>> + try
>> + {
>> + Class.forName("org.postgresql.Driver");
>> + }
>> + catch( Exception ex){}
>>

>
> similarly in many other test classes.
>
> ....
>
> It might be an idea to break this up into "support new-style OUT
> parameters" and "other fixes necessary to pass the CTS" as
> currently it's quite unclear which is which..

Well, they are all related OUT parameters are required to support the
CTS
>
> -O
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 11:22 PM
Dave Cramer
 
Posts: n/a
Default Re: jdbc cts final diff for review

Oliver

regarding the real/double muck below

They have a "real table" which ostensibly holds REAL values, however

one test does the following

takes the max value from the int_table which is a large integer, then
stores it into the 'REAL' table and then reads it back as an integer

this was failing due to precision issues until I change the
underlying type of the REAL table to FLOAT8 (which is what Oracle,
and Mysql do )

then they have another test

which registers an out parameter as a REAL and reads from the
'REAL_TABLE' which is now uses the underlying type double

if someone else can find a way to get this to pass, I'm all ears.

Dave
On 29-Jun-05, at 10:28 AM, Dave Cramer wrote:

>
> On 29-Jun-05, at 9:17 AM, Oliver Jowett wrote:
>
>> Dave Cramer wrote:
>>
>>> Attached is the patch for review. QueryExecutor is unchanged now.
>>> The only iffy bit is where I check for the in parameter being
>>> bound to void type. It could be done in checkAllParametersSet
>>> I'd like to commit this shortly.
>>>

>>
>> Ok, comments from just reading the patch.. I like the approach
>> much better than the previous one, but the details need some cleanup.
>>
>> Rather than putting knowledge of parameter direction into
>> ParameterList, how about just allowing access to the type OID, and
>> the caller checks for Oid.VOID? Then the ParameterList interface
>> changes less and the change to use a Parameter class is
>> unnecessary as the list doesn't need to store a direction value.
>>
>> If you must store a direction value in the list, then another
>> array might be better than wrapping everything up in an object
>> (generates less garbage overall). Also, there are a few places
>> that return magic values for the direction that should be using
>> the symbolic constants you've defined elsewhere.

> I thought of this, however even arrays have to be garbage
> collected.. Is there really much difference internally between new
> Parameter and new int?
>
> I'm ambivalent though it's not a big change either way.
>>
>> The change to checkAllParametersSet to not check OUT parameters
>> seems unnecessary -- won't OUT parameters be set to the (non-null)
>> NULL_OBJECT anyway?
>>
>>
>>> ! // this is here for the sole purpose of
>>> passing the cts
>>> ! if ( columnType == Types.DOUBLE &&
>>> functionReturnType[i] == Types.REAL )
>>> ! {
>>> ! // return it as a float
>>> ! if ( callResult[i] != null)
>>> ! callResult[i] = new Float(((Double)
>>> callResult[i]).floatValue());
>>> ! }

>
> I'll go through my notes, but I can tell you it was a catch 22
> problem mostly likely an artifact of Oracle not having a REAL type.
>> We can't do that! If it's failing that's probably because we're
>> not doing the necessary implicit typecasts required by the spec..
>>
>> Please explain what's going on here:

>
> from an SQL point of view FLOAT, and double are FLOAT8 types, REAL
> is the only one that is FLOAT4
>>
>>
>>> + case Types.FLOAT: // TODO: FLOAT and
>>> REAL were FLOAT8 for the cts
>>>

>>
>>
>>> public void setFloat(int parameterIndex, float x) throws
>>> SQLException
>>> {
>>> checkClosed();
>>> ! bindLiteral(parameterIndex, Float.toString(x),
>>> Oid.FLOAT8);
>>> }
>>>
>>>

>>
>> (the bind changed from Oid.FLOAT4 to Oid.FLOAT8..)
>>
>> You seem to have reverted your earlier changes and put back the
>> types/* classes -- why?

> huh ? they should be in there in HEAD, I did remove the creation of
> an object, and went to static methods
>>
>> adjustParamIndex() should be removed entirely if it's now always a
>> no-op.

> yeah
>>
>> Why is type translation for JDBC2 types only done in the JDBC3
>> code (in registerOutParameter)? -- shouldn't that be in the JDBC2
>> code?
>>

> Good point
>> There are a bunch of gratuitous changes to the test code that
>> probably shouldn't be committed, e.g. in BatchExecuteTest:
>>

> agreed, they are for my own testing
>>
>>> + try
>>> + {
>>> + Class.forName("org.postgresql.Driver");
>>> + }
>>> + catch( Exception ex){}
>>>

>>
>> similarly in many other test classes.
>>
>> ....
>>
>> It might be an idea to break this up into "support new-style OUT
>> parameters" and "other fixes necessary to pass the CTS" as
>> currently it's quite unclear which is which..

> Well, they are all related OUT parameters are required to support
> the CTS
>>
>> -O
>>
>>

>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 11:22 PM
Oliver Jowett
 
Posts: n/a
Default Re: jdbc cts final diff for review

Dave Cramer wrote:

>> You seem to have reverted your earlier changes and put back the
>> types/* classes -- why?

>
> huh ? they should be in there in HEAD, I did remove the creation of an
> object, and went to static methods


HEAD went through this progression:

(1) no types/*
(2) you added types/PGByte, etc
(3) you removed types/* and added static methods

Your patch does things like this:

> --- 1500,1520 ----
> preparedParameters.clear();
> }
>
> ! private PGType createInternalType( Object x, int targetType ) throws PSQLException
> {
> ! if ( x instanceof Byte ) return PGByte.castToServerType((Byte)x, targetType );
> ! if ( x instanceof Short ) return PGShort.castToServerType((Short)x, targetType );
> ! if ( x instanceof Integer ) return PGInteger.castToServerType((Integer)x, targetType );
> ! if ( x instanceof Long ) return PGLong.castToServerType((Long)x, targetType );
> ! if ( x instanceof Double ) return PGDouble.castToServerType((Double)x, targetType );
> ! if ( x instanceof Float ) return PGFloat.castToServerType((Float)x, targetType );
> ! if ( x instanceof BigDecimal) return PGBigDecimal.castToServerType((BigDecimal)x, targetType );
> ! // since all of the above are instances of Number make sure this is after them
> ! if ( x instanceof Number ) return PGNumber.castToServerType((Number)x, targetType );
> ! if ( x instanceof Boolean) return PGBoolean.castToServerType((Boolean)x, targetType );
> ! return new PGUnknown(x);
>
> + }
> // Helper method for setting parameters to PGobject subclasses.
> private void setPGobject(int parameterIndex, PGobject x) throws SQLException {
> String typename = x.getType();


which seems to be reverting back to step (2)

I'm guessing you forgot to apply the changes in (3) to your working copy
of the driver, then diffed against current HEAD..

-O

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-15-2008, 11:22 PM
Oliver Jowett
 
Posts: n/a
Default Re: jdbc cts final diff for review

Dave Cramer wrote:

> I've changed direction to an array


Ok. What did you think about removing it entirely from the parameterlist
level? It just seems like extra complexity that doesn't need to be there..

> regarding the jdbc3 type conversion in registerOutParameter, an
> existing conversion (BIT to BOOLEAN) was there, do all of them need to
> be in jdbc2 ?


BOOLEAN is only defined in JDBC3, so that conversion needs to be in the
JDBC3 code or the driver won't build under JDBC2.

All the others should be in JDBC2 code.

>>>> You seem to have reverted your earlier changes and put back the
>>>> types/* classes -- why?
>>>>
>>>
>>> huh ? they should be in there in HEAD, I did remove the creation of an
>>> object, and went to static methods
>>>

> I moved them from to core/types, but they have always been there


Oh, ok, your patch didn't show those renames. I also thought you'd
removed the types/ stuff earlier, guess I misread your commit :/

I still think they are redundant and should be entirely removed. We can
do that afterwards though.

Why the repackaging?

-O

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-15-2008, 11:22 PM
Dave Cramer
 
Posts: n/a
Default Re: jdbc cts final diff for review

Did you read my reasons for the ugly if double, then float stuff ?

On 30-Jun-05, at 8:04 PM, Oliver Jowett wrote:

> Dave Cramer wrote:
>
>
>> I've changed direction to an array
>>

>
> Ok. What did you think about removing it entirely from the
> parameterlist
> level? It just seems like extra complexity that doesn't need to be
> there..


I think it can be removed, however I think sooner than later we will
be dealing
with more complex parameters when stored procedures with real IN/OUT
parms
>
>
>> regarding the jdbc3 type conversion in registerOutParameter, an
>> existing conversion (BIT to BOOLEAN) was there, do all of them
>> need to
>> be in jdbc2 ?
>>

>
> BOOLEAN is only defined in JDBC3, so that conversion needs to be in
> the
> JDBC3 code or the driver won't build under JDBC2.
>
> All the others should be in JDBC2 code.
>

Done
>
>>>>> You seem to have reverted your earlier changes and put back the
>>>>> types/* classes -- why?
>>>>>
>>>>>
>>>>
>>>> huh ? they should be in there in HEAD, I did remove the
>>>> creation of an
>>>> object, and went to static methods
>>>>
>>>>

>> I moved them from to core/types, but they have always been there
>>

>
> Oh, ok, your patch didn't show those renames. I also thought you'd
> removed the types/ stuff earlier, guess I misread your commit :/
>
> I still think they are redundant and should be entirely removed. We
> can
> do that afterwards though.


If absolutely necessary, however I don't think setObject with a
different type is
in the critical path
>
> Why the repackaging?


can't remember now.
>
> -O
>
>



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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-15-2008, 11:22 PM
Oliver Jowett
 
Posts: n/a
Default Re: jdbc cts final diff for review

Dave Cramer wrote:
> Did you read my reasons for the ugly if double, then float stuff ?


Haven't had time to get my head around that yet.. can you translate it
to an explanation of something in the JDBC spec that we don't do
correctly? It's a bit hard to understand what's going wrong without the
CTS code to hand..

> I think it can be removed, however I think sooner than later we will be
> dealing
> with more complex parameters when stored procedures with real IN/OUT parms


Well, let's add the complexity only when we need it..

>> I still think they are redundant and should be entirely removed. We can
>> do that afterwards though.

>
> If absolutely necessary, however I don't think setObject with a
> different type is
> in the critical path


I'll hack on it if I have time after this is all applied; don't worry
about it for now since it's already in HEAD.

>> Why the repackaging?

>
> can't remember now.


Can you avoid repackaging then? Less CVS churn..

-O

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-15-2008, 11:22 PM
Dave Cramer
 
Posts: n/a
Default Re: jdbc cts final diff for review


On 30-Jun-05, at 8:56 PM, Oliver Jowett wrote:

> Dave Cramer wrote:
>
>> Did you read my reasons for the ugly if double, then float stuff ?
>>

>
> Haven't had time to get my head around that yet.. can you translate it
> to an explanation of something in the JDBC spec that we don't do
> correctly? It's a bit hard to understand what's going wrong without
> the
> CTS code to hand..


If you consider that Oracle doesn't have a FLOAT4 type this is a non-
issue for them
they will always convert a FLOAT8 to a java float if that is what is
registered, and they
will never have an issue storing a large integer into a FLOAT type.

Not that "Oracle doesn't do it" is a good argument, but I would
imagine they were instrumental
in the creation of the test suite.

FWIW, the spec, and the CTS aren't always in agreement. I have
pointed out the
issues to them, and finally gave up, the CTS is the defacto standard,
regardless of it's short comings

I'll try to dig around for the actual tests that failed later

>
>
>> I think it can be removed, however I think sooner than later we
>> will be
>> dealing
>> with more complex parameters when stored procedures with real IN/
>> OUT parms
>>

>
> Well, let's add the complexity only when we need it..

I still want to push this in the way it is and we can hack on it
until 8.1 goes out
>
>
>>> I still think they are redundant and should be entirely removed.
>>> We can
>>> do that afterwards though.
>>>

>>
>> If absolutely necessary, however I don't think setObject with a
>> different type is
>> in the critical path
>>

>
> I'll hack on it if I have time after this is all applied; don't worry
> about it for now since it's already in HEAD.
>
>
>>> Why the repackaging?
>>>

>>
>> can't remember now.
>>

>
> Can you avoid repackaging then? Less CVS churn..


Absolutely
>
> -O
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that
> your
> message can get through to the mailing list cleanly
>
>



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

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 11:20 AM.


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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536