Fix #13227: 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 #6853, #7644, #10437, #10996, #11265, #11270, #11276, #12152, #12478

Porting to 1.3 - Conflicts:
	admin/install.php
	admin/schema.php
	core/database_api.php
	manage_tags_page.php
Oracle support: revised schema.php to avoid schema version increase

Commit 9098615ccc028bee92c84e169353051b90aa1f20 introduced some schema changes
to fix Issues #13227, which is not acceptable in a maintenance release. The
code was amended to avoid that.

Porting to 1.3 - Conflicts:
	admin/schema.php
Add new global config for plugin table prefix

This allows users on Oracle to shorten the table identifier, to avoid hitting
the 30-char size limit.

Also modified comments for the existing db prefix/suffix to explain that they
should be blank or shortened for Oracle.

Affects #13227

Porting to 1.3 - Conflicts:
	config_defaults_inc.php
	core/plugin_api.php
Add new database function to check identifier size

The code fixing #13227 was modified, to remove the str_replace that deletes the
the hardcoded "_table" suffix from the table name. We rely instead on the user
modifying the db prefix and suffix in their config_inc.php to keep them short
enough (or even blank) so that we don't go over the 30 characters limit in
Oracle. This is cleaner than arbitrarily changing the table in the code.

Porting to 1.3 - Conflicts:
	core/database_api.php
	lang/strings_english.txt
Add new database function db_is_oracle()

Follows the same logic as for other RDBMS. The new function is used instead of
hardcoded tests like $GLOBALS['g_db_type'] == 'oci8'

Affects #13227

Porting to 1.3 - Conflicts:
	core/database_api.php
Align with coding standards

Renamed the new oracle-specific functions introduced to fix #13227; implement
various minor changes to comply with coding standards (spaces/tabs, braces,
variable names...)
Fixed datetime literal format and bug with removing 'AS' from string literals

Tests passed with MySQL and Oracle.
Oracle installation reqires only changing:
1. $g_db_table_suffix: Just as planned, to reduce object name length
2. $g_db_type: because of config_get_global( 'db_type' ) returns 'mysql' on installation stage
Improve Oracle DB connection check in install.php

Oracle supports DB bindings in two ways:
1. Use hostname, username/password and database name
2. Use tns name (insert into hostname field) and username/password, database name is still empty

Original patch provided by Carsten Grohmann in issue #13227

Porting to 1.3 - Conflicts:
	admin/install.php
Modified generated SQL for triggers in install.php to work with Oracle sqlplus

"CREATE OR REPLACE TRIGGER" statements must end with
	END;
	/
to work for Oracle sqlplus

Original patch provided by Carsten Grohmann in issue #13227

Porting to 1.3 - Conflicts:
	admin/install.php
Initialize table prefix and suffix to short values within install.php for Oracle

This allows the installer to automatically setup a config_inc.php file with
appropriately short values, avoiding multiple steps and errors during the
install process for oci8.

Porting to 1.3 - Conflicts:
	admin/install.php
DB ADOdb MetaIndex fails when no constraints exist

Working with Oracle database (oci8), when MetaIndex() method is called
to retrieve the list of indexes for a table that has no constraints
set, an error is triggered:
Fatal error: Call to a member function FetchRow() on a non-object

This commit adds a check to cleanly exit the function, returning false.

Similar error handling has also been added to the calling database_api
function db_index_exists()

This allows the DB installation (schema.php) to proceed without errors.

Fixes #13438

Porting to 1.3 - Conflicts:
	library/adodb/drivers/adodb-oci8.inc.php

Note: the fix to ADOdb driver does not need to be ported as it was
included in a later release of the library.
Add "no-op" upgrade action to install.php

This is necessary to ensure schema version number consistency when an
upgrade step needs to be skipped.

This is the case with support for Oracle DB (oci8) where some indexes
are created automatically.

Affects #13227

Porting to 1.3 - Conflicts:
	admin/schema.php
Fix ADOdb errors when creating database with Oracle

ADOdb was triggering errors in 2 distinct cases:

 - calling config_get() to retrieve the db_type was returning 'mysql'
   instead of 'oci8' due to caching of the value in a prior call to the
   function. Setting the global variable using config_set_global()
   rather than directly assigning it with $GLOBALS clears the cache and
   allows normal processing.

 - when calling NewDataDictionary(), for an unknown reason an error
   occurs in adodb.inc.php line 4350 trying to include_once the oci8
   data dictionary class. This was resolved by using @ operator to
   ignore the error

Affects #13227
Added separator comments in schema.php

Every 10 instructions, a comment block with an horizontal line and the
schema version has been inserted to improve readability.
Fix 'Call to undefined function' error
Simplify db_is_oracle() function
Change ADOdb fetch mode to ADODB_FETCH_NUM for Oracle

We were previously using ADODB_FETCH_BOTH, which is less efficient as
each field is returned twice in the recordset. Using ADODB_FETCH_NUM
reduces the memory footprint.

This is a workaround for issue #15426, allowing MantisBT to function
until ADOdb library is patched to fix the problem's root cause.
Oracle: error handling in install when db already exists

Oracle returns error ORA-01920 if attempting to create a user (schema)
which already exists.
Oracle: close and unset ADOdb object after admin connection

This frees up memory, and ensures that the next connection attempts is
done from a clean slate, because some object properties are not reset to
their original values when closing the connection.
Oracle: DB version information split on 2 lines

The version info contains a newline char, so we use nl2br() to split the
line to improve readability