Skip to content

Commit

Permalink
Oracle: BLOB columns defaulted to empty_blob()
Browse files Browse the repository at this point in the history
Fixes an issue preventing insertion of file attachments with
$g_file_upload_method = DISK causing error 'ORA-01400: cannot insert
NULL into ("MANTIS"."M_BUG_FILE_T"."CONTENT")'.

Since I can't do this "properly" without increasing the schema number
(which is not possible in 1.2.x branch), any users encountering this
issue should manually update their schema:

ALTER TABLE M_BUG_FILE_T MODIFY CONTENT DEFAULT empty_blob();
ALTER TABLE M_PROJECT_FILE_T MODIFY CONTENT DEFAULT empty_blob();

Fixes #16331
  • Loading branch information
dregad committed Oct 16, 2013
1 parent 02bbb99 commit 86da037
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions admin/schema.php
Expand Up @@ -46,12 +46,15 @@ function installer_db_now() {
# Special handling for Oracle (oci8):
# - Field cannot be null with oci because empty string equals NULL
# - Oci uses a different date literal syntax
# - Default BLOBs to empty_blob() function
if( db_is_oracle() ) {
$t_notnull = "";
$t_timestamp = "timestamp" . installer_db_now();
$t_blob_default = 'DEFAULT " empty_blob() "';
} else {
$t_notnull = 'NOTNULL';
$t_timestamp = "'" . installer_db_now() . "'";
$t_blob_default = '';
}

$upgrade[] = array('CreateTableSQL',array(db_get_table( 'config' ),"
Expand All @@ -74,7 +77,7 @@ function installer_db_now() {
filesize I NOTNULL DEFAULT '0',
file_type C(250) NOTNULL DEFAULT \" '' \",
date_added T NOTNULL DEFAULT '" . db_null_date() . "',
content B NOTNULL
content B NOTNULL $t_blob_default
",array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateIndexSQL',array('idx_bug_file_bug_id',db_get_table('bug_file'),'bug_id'));
$upgrade[] = array('CreateTableSQL',array(db_get_table('bug_history'),"
Expand Down Expand Up @@ -227,7 +230,7 @@ function installer_db_now() {
filesize I NOTNULL DEFAULT '0',
file_type C(250) NOTNULL DEFAULT \" '' \",
date_added T NOTNULL DEFAULT '" . db_null_date() . "',
content B NOTNULL
content B NOTNULL $t_blob_default
",array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
/* 30 */
$upgrade[] = array('CreateTableSQL',array(db_get_table('project_hierarchy'),"
Expand Down

0 comments on commit 86da037

Please sign in to comment.