2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * OCI specific temptables store. Needed because temporary tables
19 * in Oracle are global (to all sessions), so we need to rename them
20 * on the fly in order to get local (different for each session) table names.
21 * Also used to be able to retrieve temp table names included in the get_tables()
25 * @copyright 2009 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29 defined('MOODLE_INTERNAL') ||
die();
31 require_once(__DIR__
.'/moodle_temptables.php');
33 class oci_native_moodle_temptables
extends moodle_temptables
{
35 /** @var int To store unique_session_id. Needed for temp tables unique naming (upto 24cc) */
36 protected $unique_session_id; //
37 /** @var int To get incrementally different temptable names on each add_temptable() request */
41 * Creates new moodle_temptables instance
42 * @param object moodle_database instance
44 public function __construct($mdb, $unique_session_id) {
45 $this->unique_session_id
= $unique_session_id;
47 parent
::__construct($mdb);
51 * Add one temptable to the store.
53 * Overridden because OCI only support global temptables, so we need to change completely the name, based
54 * in unique session identifier, to get local-like temp tables support
55 * tables before the prefix.
57 * Given one moodle temptable name (without prefix), add it to the store, with the
58 * key being the original moodle name and the value being the real db temptable name
61 * Override and use this *only* if the database requires modification in the table name.
63 * @param string $tablename name without prefix of the table created as temptable
65 public function add_temptable($tablename) {
66 // TODO: throw exception if exists: if ($this->is_temptable...
67 $this->temptables
[$tablename] = $this->prefix
. $this->unique_session_id
. $this->counter
;