Skip to content

OC6 Oracle mimetypes table .... #5474

Closed

Description

@DeepDiver1975
An exception occurred while executing 'INSERT INTO "oc_mimetypes"("mimetype") VALUES(?)': ORA-01400: cannot insert NULL into ("OWNCLOUD6"."oc_mimetypes"."mimetype")

Activity

  1. VicDeo commented on Oct 22, 2013

    @VicDeo
    Contributor

    @DeepDiver1975
    I noticed that there is an empty mimetype:

    select * from oc_mimetypes;
    1|httpd
    2|httpd/unix-directory
    3|video
    4|application
    5|application/vnd.oasis.opendocument.text
    6|application/vnd.oasis.opendocument
    7|
    8|inode
    

    might be related

  2. ghost assigned on Oct 23, 2013
  3. bantu commented on Oct 23, 2013

    @bantu

    @DeepDiver1975 Any more details for reproduction?

  4. DeepDiver1975 commented on Oct 23, 2013

    @DeepDiver1975
    ContributorAuthor

    For me an empty mimetype ins inserted on mounting an SMB drive

    This is an Oracle fix only bug @butonic THX

  5. bantu commented on Oct 24, 2013

    @bantu

    @DeepDiver1975 Oracle considers NULL and empty string equivalent (sometimes). What do you think about removing the empty mimetype, using 0 as a no-mimetype marker and a LEFT/RIGHT join?

  6. bantu commented on Oct 24, 2013

    @bantu

    @DeepDiver1975 Okay, there does not seem to be any joining involved. Everything seems to be handled by ./lib/private/files/cache/cache.php.

    afischer@leonard:/var/www/projects/owncloud/core (master) $ grep "\*PREFIX\*mimetypes" . -Ri
    ./lib/private/files/cache/backgroundwatcher.php:        $sql = 'SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?';
    ./lib/private/files/cache/cache.php:                $result = \OC_DB::executeAudited('INSERT INTO `*PREFIX*mimetypes`(`mimetype`) VALUES(?)', array($mime));
    ./lib/private/files/cache/cache.php:                self::$mimetypeIds[$mime] = \OC_DB::insertid('*PREFIX*mimetypes');
    ./lib/private/files/cache/cache.php:            $result = \OC_DB::executeAudited('SELECT `id`, `mimetype` FROM `*PREFIX*mimetypes`', array());
    ./apps/files_sharing/lib/share/folder.php:      $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');

    The mimetype column of the mimetypes table is marked as NOT NULL, so empty string can not be used on Oracle. My suggestion would be not inserting the empty mimetype at all, but using hard-coded 0 instead. Does that make sense to you?

  7. bantu commented on Oct 24, 2013

    @bantu

    -1 is returned in case an empty mimetype is tried to insert on Oracle. I am not sure what that signals. It probably should be turned into a constant.

                try{
                    $result = \OC_DB::executeAudited('INSERT INTO `*PREFIX*mimetypes`(`mimetype`) VALUES(?)', array($mime));
                    self::$mimetypeIds[$mime] = \OC_DB::insertid('*PREFIX*mimetypes');
                    self::$mimetypes[self::$mimetypeIds[$mime]] = $mime;
                }
                catch (\Doctrine\DBAL\DBALException $e){
                    \OC_Log::write('core', 'Exception during mimetype insertion: ' . $e->getmessage(), \OC_Log::DEBUG);
                    return -1;
                }
    
  8. VicDeo commented on Oct 24, 2013

    @VicDeo
    Contributor

    For me an empty mimetype ins inserted on mounting an SMB drive

    hmm. Technically mount point is a directory, so it's related to mimetype detection rather than to Oracle DB engine :).
    I'd suggest to prohibit empty mimetype at all.

    As a dirty hack - replace it with space 🔬

  9. bantu commented on Oct 24, 2013

    @bantu

    @VicDeo So you would prefer to not download a remote HTTP file if the webserver does not specify a mimetype? Or what would be the expected behaviour in this case?

  10. VicDeo commented on Oct 24, 2013

    @VicDeo
    Contributor

    I think it is not detected properly on oC side.
    It's true that remote server is not obliged to provide a mimetype but we can detect it if needed once transfer is complete.

  11. bantu commented on Oct 24, 2013

    @bantu

    @VicDeo Maybe mimetype detection should fall back to octet-stream. At least that seems to be what the file command does.

    afischer@leonard:/tmp$ dd if=/dev/urandom of=Testfile_128_MB bs=1M count=128
    128+0 records in
    128+0 records out
    134217728 bytes (134 MB) copied, 9.56035 s, 14.0 MB/s
    
    afischer@leonard:/tmp$ file -b --mime-type Testfile_128_MB
    application/octet-stream
    
  12. locked as resolved and limited conversation to collaborators on Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions