[postgis-devel] Does changing deserialized data should change stored data?
Pierre.Racine at sbf.ulaval.ca
Wed Jul 28 14:33:27 PDT 2010
I'm having a nice bug with WKT Raster (#552): ST_SetValue change the pixel value of a deserialized raster. The core API code copy all the values of the raster and band headers from the deserialized data into a raster struct but it does not do it for the pixel values. It points directly to them like this:
//raster struct = deserialized data
band->data.mem = (uint8_t*)ptr;
In the core code for ST_SetValue (rt_band_set_pixel) we set the value pointed by an offset to this pointer to the requested value. I would have expect that this pointer point to a memory loaded version of the stored raster values but in some cases (when there is more than 2 bands) the stored value get also modified (when it should not) and the new value persist to a restart of the server.
Anybody have an idea why changing the deserialized data actually change the stored data? How can I avoid that? I was thinking making a copy of it, change this copy and give it to the raster/band struct instead of changing the deserialized data. But before doing so I want to know if it is normal that changing the deserialized data actually change the stored data and why it does it when the data chunk is big (3 band) and not when it's small (1 or 2 bands)?
More information about the postgis-devel