Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-511

[PHP Static] filesize is not expected after using cubrid_lob2_import

    Details

      Description

      [PHP Static] filesize is not expected after using cubrid_lob2_import
      Test case: http://svn.cubrid.org/cubridapis/php/branches/RB-9.1.0_static_cci/tests/cubrid_lob2_import.phpt

      Test Envrionment:

      PHP Driver:  http://10.34.64.219/2013-03-20/9.1.0/CUBRID-PHP5-5.3-WIN32-VC9-NTS-9.1.0.0001.bin.zip
      
      PHP Version: 5.3.13
      

      Test code:

      {code}
      $conn = cubrid_connect($host, $port, $db, $user, $passwd);

      if (!is_null($tmp = @cubrid_lob2_import())) {
      printf('[001] Expecting NULL, got %s/%s\n', gettype($tmp), $tmp);
      }

      @cubrid_execute($conn, 'DROP TABLE IF EXISTS test_lob2');
      cubrid_execute($conn, 'CREATE TABLE test_lob2 (id INT AUTO_INCREMENT, images BLOB)');

      $req = cubrid_prepare($conn, "INSERT INTO test_lob2(images) VALUES ");

      $lob = cubrid_lob2_new($conn);

      if (false !== ($tmp = @cubrid_lob2_import($lob, "file_not_exist"))) {
      printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
      }

      cubrid_lob2_import($lob, 'tests/cubrid_logo.png');

      //print filesize("tests/cubrid_logo.png");
      //print "\n";
      //print cubrid_lob2_size($lob);
      //print "\n";
      if (filesize("tests/cubrid_logo.png") != cubrid_lob2_size($lob)) {
      printf("[003] cubrid_lob2_import error, filesize is inconsistent.\n");
      }

      cubrid_lob2_bind($req, 1, $lob);

      cubrid_execute($req);

      cubrid_disconnect($conn);

      print 'done!';
      {code}

      I tried print the filesize :

      27478
      5
      [003] cubrid_lob2_import error, filesize is inconsistent.
      done!
      

        Activity

        Hide
        jinhu 李金虎 added a comment -

        Analysis:
        When opening a file use _open() with flag O_RDONLY, the default is text mode.
        When calling _read(), the Ctrl-Z in the file is considered as EOF.
        So, explicitly set the binary mode for Windows version driver.

        Fix:
        RB-9.1.0_static_cci, rev:1718
        Merge into:
        RB-9.1.0, rev:1719
        RB-8.4.1, rev:1720
        RB-8.4.3, rev:1721
        RB-8.4.4, rev:1722
        trunk, rev:1723

        Show
        jinhu 李金虎 added a comment - Analysis: When opening a file use _open() with flag O_RDONLY, the default is text mode. When calling _read(), the Ctrl-Z in the file is considered as EOF. So, explicitly set the binary mode for Windows version driver. Fix: RB-9.1.0_static_cci, rev:1718 Merge into: RB-9.1.0, rev:1719 RB-8.4.1, rev:1720 RB-8.4.3, rev:1721 RB-8.4.4, rev:1722 trunk, rev:1723
        Hide
        cn14130 欧明宝[Bom Owen] added a comment -

        Test Build: http://svn.cubrid.org/cubridapis/php/branches/RB-9.1.0_static_cci Revision: 1718
        Test Cubrid Server: RB-9.1.0.0213
        Test Result: pass

        RB-9.1.0, rev:1719
        RB-8.4.1, rev:1720
        RB-8.4.3, rev:1721
        RB-8.4.4, rev:1722 , will be validated by daily test

        Show
        cn14130 欧明宝[Bom Owen] added a comment - Test Build: http://svn.cubrid.org/cubridapis/php/branches/RB-9.1.0_static_cci Revision: 1718 Test Cubrid Server: RB-9.1.0.0213 Test Result: pass RB-9.1.0, rev:1719 RB-8.4.1, rev:1720 RB-8.4.3, rev:1721 RB-8.4.4, rev:1722 , will be validated by daily test

          People

          • Assignee:
            cn14130 欧明宝[Bom Owen]
            Reporter:
            cn14130 欧明宝[Bom Owen]
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: