View Issue Details

IDProjectCategoryView StatusLast Update
0011265mantisbtdb oraclepublic2015-03-16 19:19
ReporterbobAssigned Todregad 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOSXPOS VersionSP3
Product Version1.2.0rc2 
Target Version1.3.0-beta.1Fixed in Version1.3.0-beta.1 
Summary0011265: Array results from Oracle have uppercase keys
Description

After fixing db_fetch_array for oci8 driver, requires:
Around Line 449 in database_api.php

# mysql obeys FETCH_MODE_BOTH, hence ->fields works, other drivers do not support this
if( $g_db_type == 'mysql' || $g_db_type == 'odbc_mssql' ) {
    $t_array = $p_result->fields;
    $p_result->MoveNext();
    return $t_array;
} if ( $g_db_type == 'oci8' ) {
    $t_array = $p_result->FetchRow() ;
    $p_result->MoveNext() ;
    # print_r($t_array) ;
    # echo "<br />" ;
    return $t_array ;
}
else {
    # $t_row = $p_result->GetRowAssoc( false );

Found that Array returned from db_fetch_array (ie: for the config call) is
Array ( [CONFIG_ID] => database_version [USER_ID] => 0 [PROJECT_ID] => 0 [TYPE] => 1 [VALUE] => 179 [ACCESS_REQD] => 90 )
so
around line 121 in config_api.php

            $query = "SELECT config_id, user_id, project_id, type, value, access_reqd FROM $t_config_table";
            $result = db_query_bound( $query );
            while( false <> ( $row = db_fetch_array( $result ) ) ) {
                $t_config = $row['config_id'];

will fail as:
$row['config_id'] doesn't exist, however $row['CONFIG_ID'] exists with the wanted value

Problem is all of the array key fetches in the code are in lowercase.

Steps To Reproduce

Example was done using Oracle XE
configured database information with null hostname,
commented out check for null hostname in install.php
created schema manually based on display option in install.php
commented out
/ access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); /
in index.php within admin directory
Added additional checks within the database information section:

<tr>
<?php
$t_config_table = db_get_table( 'mantis_config_table' );
$query = "SELECT config_id, user_id, project_id, type, value, access_reqd FROM $t_config_table";
$result = db_query_bound( $query );
$row = db_fetch_array( $result ) ;

print_info_row( lang_get( 'schema_version' ), config_get( 'database_version' ) );
print_info_row( 'config table ', $t_config_table ) ;
print_info_row( 'result', $result ) ;
print_info_row( 'config_id', $row['config_id'] ) ;
print_info_row( 'CONFIG_ID', $row['CONFIG_ID'] ) ;
print_info_row( 'adodb_version', $g_db->Version() );

?>
</tr>

TagsNo tags attached.

Relationships

child of 0013227 closeddregad Oracle DB support multiple issues 

Activities

bob

bob

2009-12-06 17:24

reporter  

mantis_oracle_bug.JPG (112,228 bytes)
mantis_oracle_bug.JPG (112,228 bytes)
bob

bob

2009-12-07 09:43

reporter   ~0023872

Possible fix involves modifing db_fetch_array within database_api

function db_fetch_array( &$p_result ) {
global $g_db, $g_db_type;

if( $p_result->EOF ) {
    return false;
}
# mysql obeys FETCH_MODE_BOTH, hence ->fields works, other drivers do not support this
if( $g_db_type == 'mysql' || $g_db_type == 'odbc_mssql' ) {
    $t_array = $p_result->fields;
    $p_result->MoveNext();
    return $t_array;
} if ( $g_db_type == 'oci8' ) {
    $t_array = $p_result->FetchRow() ;
    $p_result->MoveNext() ;
    return array_change_key_case($t_array,CASE_LOWER) ;
}
bob

bob

2009-12-22 12:02

reporter   ~0023964

For 1.2.0rc2 comment out the $p_result->MoveNext() ;
For 1.1.8 you will need it.
Fetchrow automatically advances the cursor, ie:

if ( $g_db_type == 'oci8' ) {
$t_array = $p_result->FetchRow() ;
return array_change_key_case($t_array,CASE_LOWER) ;
}

sveyret

sveyret

2010-10-25 08:09

reporter   ~0027151

In version 1.2.3 which I am using, the case is managed by AdoDB (through GetRowAssoc, which is not working, but this is another issue — 0009314).
To my opinion, this issue could be closed. Unless I missed something else in the source code?

Related Changesets

MantisBT: master 2ce60e47

2011-08-10 12:34:07

dregad

Details Diff
Fix 0013227: Oracle database support (oci8)

Mantis 1.2.6 currently does not work with Oracle DB:
1. Installation:
1.1. Oracle DB autocreates PK, so index creation for same field forbidden
1.2. Oracle DB uses datetime literal format timestamp'YYYY-MM-DD HH-MI:SS'
1.3. Oracle DB don't allows altering field property NOT NULL into NOT NULL
1.4. Oracle DB max object length is 30 chars, so some index names must be reduced
1.5. Oracle DB means empty string as NULLs, so NOT NULL restriction must be disabled for some field
1.6. Oracle DB can resolve database server name through TNS, so database name cannot be required
2. General:
2.2. Direct DB query execution result accessing instead of db_fetch_array() 1.3. usage didn't works with Oracle DB
2.4. Oracle DB binds variable by name, so bind names in statement must be sorted to address them.
2.5. Oracle DB handles NULL/DEFAULT values with specific way.
2.6. Oracle DB returns NULL value as true PHP null
2.7. Oracle DB handles sequence access with specific syntax
2.8. Nothing returned by db_prepare_string() in case of oci8
2.9. Oracle DB max object length is 30 chars, so table names must be reduced
2.10. Oracle DB uses LOB literal format similar to mssql
2.11. GetRowAssoc returns empty field values with oci8, it's need to enable returning both associative and indexed arrays.

The original patch was provided by DKuranov. He reckons that this also resolves
issues 0006853, 0007644, 0010437, 0010996, 0011265, 0011270, 0011276, 0012152, 0012478

Porting to 1.3 - Conflicts:
admin/install.php
admin/schema.php
core/database_api.php
manage_tags_page.php
mod - admin/install.php Diff File
mod - admin/schema.php Diff File
mod - core/database_api.php Diff File

Issue History

Date Modified Username Field Change
2009-12-06 17:18 bob New Issue
2009-12-06 17:24 bob File Added: mantis_oracle_bug.JPG
2009-12-07 09:43 bob Note Added: 0023872
2009-12-22 12:02 bob Note Added: 0023964
2010-10-25 08:09 sveyret Note Added: 0027151
2011-08-09 11:55 dregad Relationship added parent of 0013227
2013-10-17 12:08 dregad Changeset attached => MantisBT master 2ce60e47
2013-10-17 12:51 dregad Target Version => 1.3.0-beta.1
2013-10-17 12:52 dregad Status new => resolved
2013-10-17 12:52 dregad Fixed in Version => 1.3.0-beta.1
2013-10-17 12:52 dregad Resolution open => fixed
2013-10-17 12:52 dregad Assigned To => dregad
2014-04-12 19:39 grangeway Issue cloned: 0017200
2014-12-08 00:34 vboctor Status resolved => closed
2015-03-16 19:19 dregad Relationship replaced child of 0013227