Subversion Repositories oidplus

Rev

Rev 865 | Rev 1100 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 865 Rev 1050
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * OIDplus 2.0
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
6
 *
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
9
 * You may obtain a copy of the License at
10
 *
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
17
 * limitations under the License.
18
 */
18
 */
19
 
19
 
-
 
20
use ViaThinkSoft\OIDplus\OIDplusDatabaseConnection;
-
 
21
 
20
/**
22
/**
21
 * This function will be called by OIDplusDatabaseConnection.class.php at method afterConnect().
23
 * This function will be called by OIDplusDatabaseConnection.class.php at method afterConnect().
22
 * @param OIDplusDatabaseConnection $db is the OIDplusDatabaseConnection class
24
 * @param OIDplusDatabaseConnection $db is the OIDplusDatabaseConnection class
23
 * @return int new version set
25
 * @return int new version set
24
 * @throws OIDplusException
26
 * @throws \ViaThinkSoft\OIDplus\OIDplusException
25
 */
27
 */
26
function oidplus_dbupdate_1001(OIDplusDatabaseConnection $db) {
28
function oidplus_dbupdate_1001(OIDplusDatabaseConnection $db) {
27
 
29
 
28
        // Change collation so that objects like FourCC can be case-sensitive
30
        // Change collation so that objects like FourCC can be case-sensitive
29
        if ($db->getSlang()->id() == 'mysql') {
31
        if ($db->getSlang()->id() == 'mysql') {
30
                $db->query("ALTER TABLE ###asn1id     CHANGE `oid`    `oid`    varchar(255) NOT NULL     COLLATE utf8_bin;");
32
                $db->query("ALTER TABLE ###asn1id     CHANGE `oid`    `oid`    varchar(255) NOT NULL     COLLATE utf8_bin;");
31
                $db->query("ALTER TABLE ###iri        CHANGE `oid`    `oid`    varchar(255) NOT NULL     COLLATE utf8_bin;");
33
                $db->query("ALTER TABLE ###iri        CHANGE `oid`    `oid`    varchar(255) NOT NULL     COLLATE utf8_bin;");
32
                $db->query("ALTER TABLE ###objects    CHANGE `id`     `id`     varchar(255) NOT NULL     COLLATE utf8_bin;");
34
                $db->query("ALTER TABLE ###objects    CHANGE `id`     `id`     varchar(255) NOT NULL     COLLATE utf8_bin;");
33
                $db->query("ALTER TABLE ###objects    CHANGE `parent` `parent` varchar(255) DEFAULT NULL COLLATE utf8_bin;");
35
                $db->query("ALTER TABLE ###objects    CHANGE `parent` `parent` varchar(255) DEFAULT NULL COLLATE utf8_bin;");
34
                $db->query("ALTER TABLE ###log_object CHANGE `object` `object` varchar(255) NOT NULL     COLLATE utf8_bin;");
36
                $db->query("ALTER TABLE ###log_object CHANGE `object` `object` varchar(255) NOT NULL     COLLATE utf8_bin;");
35
        } else if ($db->getSlang()->id() == 'mssql') {
37
        } else if ($db->getSlang()->id() == 'mssql') {
36
                $db->query("ALTER TABLE ###asn1id     ALTER COLUMN [oid]    varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
38
                $db->query("ALTER TABLE ###asn1id     ALTER COLUMN [oid]    varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
37
                $db->query("ALTER TABLE ###iri        ALTER COLUMN [oid]    varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
39
                $db->query("ALTER TABLE ###iri        ALTER COLUMN [oid]    varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
38
                $db->query("ALTER TABLE ###objects    ALTER COLUMN [id]     varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
40
                $db->query("ALTER TABLE ###objects    ALTER COLUMN [id]     varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
39
                $db->query("ALTER TABLE ###objects    ALTER COLUMN [parent] varchar(255) COLLATE German_PhoneBook_CS_AS NULL    ;");
41
                $db->query("ALTER TABLE ###objects    ALTER COLUMN [parent] varchar(255) COLLATE German_PhoneBook_CS_AS NULL    ;");
40
                $db->query("ALTER TABLE ###log_object ALTER COLUMN [object] varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
42
                $db->query("ALTER TABLE ###log_object ALTER COLUMN [object] varchar(255) COLLATE German_PhoneBook_CS_AS NOT NULL;");
41
        } else if ($db->getSlang()->id() == 'oracle') {
43
        } else if ($db->getSlang()->id() == 'oracle') {
42
                // On the Oracle DeveloperDays 2019 VM, the default behavior is case-sensitive.
44
                // On the Oracle DeveloperDays 2019 VM, the default behavior is case-sensitive.
43
                // Let's hope that this is true for all OIDplus environments
45
                // Let's hope that this is true for all OIDplus environments
44
                // DM 31.05.2022 : Reproduction on Ubuntu+PostgreSQL also successful. The default is case-sensitive, like we want.
46
                // DM 31.05.2022 : Reproduction on Ubuntu+PostgreSQL also successful. The default is case-sensitive, like we want.
45
        } else if ($db->getSlang()->id() == 'pgsql') {
47
        } else if ($db->getSlang()->id() == 'pgsql') {
46
                // It looks like PgSQL is case-sensitive by default
48
                // It looks like PgSQL is case-sensitive by default
47
                // see https://stackoverflow.com/questions/18807276/how-to-make-my-postgresql-database-use-a-case-insensitive-collation
49
                // see https://stackoverflow.com/questions/18807276/how-to-make-my-postgresql-database-use-a-case-insensitive-collation
48
                // DM 31.05.2022 : Reproduction on Ubuntu+PostgreSQL successful. The default is case-sensitive, like we want.
50
                // DM 31.05.2022 : Reproduction on Ubuntu+PostgreSQL successful. The default is case-sensitive, like we want.
49
        } else if ($db->getSlang()->id() == 'access') {
51
        } else if ($db->getSlang()->id() == 'access') {
50
                // TODO: Implement
52
                // TODO: Implement
51
                // However, this is not important, because Access is not yet correctly implemented anyway
53
                // However, this is not important, because Access is not yet correctly implemented anyway
52
        } else if ($db->getSlang()->id() == 'sqlite') {
54
        } else if ($db->getSlang()->id() == 'sqlite') {
53
                // It looks like SQLite is case-sensitive by default
55
                // It looks like SQLite is case-sensitive by default
54
                // https://stackoverflow.com/questions/973541/how-to-set-sqlite3-to-be-case-insensitive-when-string-comparing
56
                // https://stackoverflow.com/questions/973541/how-to-set-sqlite3-to-be-case-insensitive-when-string-comparing
55
                // DM 05.06.2022 : Reproduction on Ubuntu successful. The default is case-sensitive, like we want.
57
                // DM 05.06.2022 : Reproduction on Ubuntu successful. The default is case-sensitive, like we want.
56
        } else {
58
        } else {
57
                // This should not happen
59
                // This should not happen
58
        }
60
        }
59
 
61
 
60
        $version = 1001;
62
        $version = 1001;
61
        $db->query("UPDATE ###config SET value = ? WHERE name = 'database_version'", array($version));
63
        $db->query("UPDATE ###config SET value = ? WHERE name = 'database_version'", array($version));
62
 
64
 
63
        return $version;
65
        return $version;
64
}
66
}
65
 
67