Menu

#371 (ok 3.1.3) Insert as new row BLOB is lost

closed-fixed
None
1
2009-02-28
2007-07-25
popshed
No

MySQL version 5.0.22
PHP 5.2.0

Select an existing row containing a BLOB field and change to "Insert as new row". The BLOB contents are not duplicated.

I've looked back through previous bug reports and it seems this bug has been fixed several times in the past but is recurring now.

Discussion

  • Marc Delisle

    Marc Delisle - 2007-07-27
    • assigned_to: nobody --> lem9
     
  • Marc Delisle

    Marc Delisle - 2007-07-31

    Logged In: YES
    user_id=210714
    Originator: NO

    I don't remember having seen this bug report. There were other reports about a BLOB being lost on editing. Please show me the reference for other bug reports you found.

    P.S. I confirm this problem.

     
  • popshed

    popshed - 2007-08-01

    Logged In: YES
    user_id=1853116
    Originator: YES

    Before reporting the bug I did a search to see if it had been reported in the past. I've just done that search again and have come up with 722629 and 441689. These bugs were fixed at the time they were reported but seem to have been resurrected since.

    I know for certain that the previous version we had installed also suffered from this bug but at the time we just attributed it to the same bug which nullified a BLOB entry on editing a record. Seeing that bug fixed, we assumed this one would be too but as it is obviously not the same bug thought it worth reporting.

     
  • Marc Delisle

    Marc Delisle - 2007-08-02
    • assigned_to: lem9 --> nobody
     
  • Herman van Rink

    Herman van Rink - 2009-02-14

    This seems to related to Revision 9795 (by cybot_tm, dec 2006), in which he 'removed unused code;'.

    I've restored the lost lines of code in the patch below and did some testing.
    When "Insert as new row" is used the BLOB value is now preserved.

    In addition to the original code I added an additional check for $is_insert.

    One downside of this code is that the 'protected' value is fetched even is a new file is uploaded.
    It might therefore be an option to move this piece to the case 'protected' block in tbl_replace_fields.inc.php

    Index: tbl_replace.php

    --- tbl_replace.php (revision 12236)
    +++ tbl_replace.php (working copy)
    @@ -203,6 +203,15 @@

    $primary_field = PMA_BS_GetPrimaryField($GLOBALS['db'], $GLOBALS['table']);

    + // Fetch the current value's of a row to use incase we have a protected field
    + // @todo possibly move to ./libraries/tbl_replace_fields.inc.php
    + if ($is_insert && $using_key && isset($me_fields_type) && is_array($me_fields_type) && isset($primary_key)) {
    + $prot_result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';');
    + $prot_row = PMA_DBI_fetch_assoc($prot_result);
    + PMA_DBI_free_result($prot_result);
    + unset($prot_result);
    + }
    +
    foreach ($me_fields as $key => $val) {

    require './libraries/tbl_replace_fields.inc.php';

     
  • Marc Delisle

    Marc Delisle - 2009-02-16

    Moved to patches.

     
  • Marc Delisle

    Marc Delisle - 2009-02-16
    • milestone: 741410 -->
    • labels: 509096 -->
     
  • Marc Delisle

    Marc Delisle - 2009-02-22
    • assigned_to: nobody --> lem9
     
  • Herman van Rink

    Herman van Rink - 2009-02-22

    Marc,

    It seems that all that is required is the extra single line patch below.

    Herman

    Index: libraries/tbl_replace_fields.inc.php

    --- libraries/tbl_replace_fields.inc.php (revision 12244)
    +++ libraries/tbl_replace_fields.inc.php (working copy)
    @@ -96,7 +96,7 @@
    // garvin: when in UPDATE mode, do not alter field's contents. When in INSERT
    // mode, insert empty field because no values were submitted. If protected
    // blobs where set, insert original fields content.
    - if (! empty($prot_row[$key])) {
    + if (! empty($prot_row[$me_fields_name[$key]])) {
    $val = '0x' . bin2hex($prot_row[$me_fields_name[$key]]);
    } else {
    $val = '';

     
  • Marc Delisle

    Marc Delisle - 2009-02-23
    • summary: Insert as new row BLOB is lost --> (ok 3.1.3) Insert as new row BLOB is lost
    • priority: 5 --> 1
    • status: open --> open-fixed
     
  • Marc Delisle

    Marc Delisle - 2009-02-23

    Merged in subversion, thanks.

     
  • Marc Delisle

    Marc Delisle - 2009-02-28
    • status: open-fixed --> closed-fixed