More on updates with first() vs absolute()

Поиск
Список
Период
Сортировка
Искать

More on updates with first() vs absolute()

От:
Rich Cullingford <rculling@sysd.com>
Дата:
Good morning,
Yesterday I reported a crash in updateRow() when preceded by an 
absolute(1) positioning call, when preceding it with first() worked. It 
now seems the DB update was happening OK; the crash was a null pointer 
exception at the line:

     rowBuffer[columnIndex] = 
connection.getEncoding().encode(String.valueOf(valueObject));

of updateRowBuffer(). It appears the rowBuffer isn't being initialized 
properly, and, sure enough, when you compare first() with absolute(), 
the former has:

    		rowBuffer = new byte[this_row.length][];
		System.arraycopy(this_row, 0, rowBuffer, 0, 	 
this_row.length);

while the latter does not. Adding the initialization cures the crash. 
There might be other locations needing the same patch.

If this is an acceptable patch, I'll be happy to submit it if someone 
tells me how.  (It looks like a cvs diff to pgsql-jdbc is the desired 
way, but I'm not clear how to do that: do I start with the current 
pg-snapshot or something else?)

                               Rich Cullingford
                               System Detection, Inc.
                               5 W 19th St, NYC, NY 10010
                               rculling@sysd.com

Re: More on updates with first() vs absolute()

От:
Barry Lind <blind@xythos.com>
Дата:
Rich,

Thanks for debugging.  The fix is obvious enough from your description 
that a patch is unnecessary.  I will check the fix into CVS later today.

thanks,
--Barry


Rich Cullingford wrote:
> Good morning,
> Yesterday I reported a crash in updateRow() when preceded by an 
> absolute(1) positioning call, when preceding it with first() worked. It 
> now seems the DB update was happening OK; the crash was a null pointer 
> exception at the line:
> 
>     rowBuffer[columnIndex] = 
> connection.getEncoding().encode(String.valueOf(valueObject));
> 
> of updateRowBuffer(). It appears the rowBuffer isn't being initialized 
> properly, and, sure enough, when you compare first() with absolute(), 
> the former has:
> 
>            rowBuffer = new byte[this_row.length][];
>         System.arraycopy(this_row, 0, rowBuffer, 0,      this_row.length);
> 
> while the latter does not. Adding the initialization cures the crash. 
> There might be other locations needing the same patch.
> 
> If this is an acceptable patch, I'll be happy to submit it if someone 
> tells me how.  (It looks like a cvs diff to pgsql-jdbc is the desired 
> way, but I'm not clear how to do that: do I start with the current 
> pg-snapshot or something else?)
> 
>                               Rich Cullingford
>                               System Detection, Inc.
>                               5 W 19th St, NYC, NY 10010
>                               rculling@sysd.com
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> 



FAQ