Skip to content

Commit 544ef10

Browse files
committed
mk-oracle: drop query variants for databases below 12.1.0.2
12.1.0.2 is the minimum supported release, so a query variant written for an older database can never be selected. Every section now ships a single variant. The one exception is jobs, which keeps its split into a CDB and a non-CDB variant, because the two differ in their number of fields. - Ten variants written for releases below 12.1.0.2 are gone. Two of them were broken anyway. tablespaces.10020000.all.sql read cdb_data_files, cdb_tablespaces and v$containers, none of which exist before 12.1, so it raised ORA-00942 on exactly the databases it was written for. asm_diskgroup.10020000.all.sql selected one field too many, so the check matched its columns against the wrong layout. - instance.0.all.sql and sessions.0.all.sql now hold what instance.12010002.all.sql and sessions.12010000.all.sql held. Deleting the below-floor variants freed those two file names. - Every surviving query is tagged min_version 0. A gate at 12.1 can no longer fail to match, so it carries no information. - jobs becomes jobs.0.cdb.sql and jobs.0.nocdb.sql. Tenant::NoCdb is now the only thing that selects the ten-field shape. - The tests that asserted the version tiering are removed along with the tiering itself. The tests on query content stay, and the sweep over all sections still resolves every id for both tenants at 12.1.0.2, 19, 21 and 23. TESTS: Manual and automated. Confirmed against a real Oracle database in Docker (23.26), where the section output is unchanged. Unit and component suites are green. CMK-37731 Change-Id: I8248a170f247eb5e92fbcf8fc47cab8281d70fc3
1 parent 7834f14 commit 544ef10

26 files changed

Lines changed: 197 additions & 1246 deletions

packages/mk-oracle/BUILD

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,27 @@ rust_library(
5656
],
5757
aliases = aliases(),
5858
compile_data = [
59-
"sqls/asm_diskgroup.10020000.all.sql",
60-
"sqls/asm_diskgroup.12010000.all.sql",
59+
"sqls/asm_diskgroup.0.all.sql",
6160
"sqls/asm_instance.0.all.sql",
62-
"sqls/dataguard_stats.10020000.all.sql",
61+
"sqls/dataguard_stats.0.all.sql",
6362
"sqls/instance.0.all.sql",
64-
"sqls/instance.12010002.all.sql",
6563
"sqls/io_stats.0.all.sql",
66-
"sqls/jobs.10020000.all.sql",
67-
"sqls/jobs.12010000.cdb.sql",
68-
"sqls/locks.10020000.all.sql",
69-
"sqls/locks.12010000.all.sql",
64+
"sqls/jobs.0.cdb.sql",
65+
"sqls/jobs.0.nocdb.sql",
66+
"sqls/locks.0.all.sql",
7067
"sqls/logswitches.0.all.sql",
71-
"sqls/longactivesessions.10010000.all.sql",
72-
"sqls/longactivesessions.12010000.all.sql",
73-
"sqls/performance.10010000.all.sql",
74-
"sqls/performance.12010000.all.sql",
68+
"sqls/longactivesessions.0.all.sql",
69+
"sqls/performance.0.all.sql",
7570
"sqls/processes.0.all.sql",
7671
"sqls/recovery_area.0.all.sql",
77-
"sqls/recovery_status.10010000.all.sql",
78-
"sqls/recovery_status.12010000.all.sql",
72+
"sqls/recovery_status.0.all.sql",
7973
"sqls/resumable.0.all.sql",
80-
"sqls/rman.10020000.all.sql",
81-
"sqls/rman.12010000.all.sql",
74+
"sqls/rman.0.all.sql",
8275
"sqls/sessions.0.all.sql",
83-
"sqls/sessions.12010000.all.sql",
8476
"sqls/systemparameter.0.all.sql",
85-
"sqls/tablespaces.10020000.all.sql",
86-
"sqls/tablespaces.12010000.all.sql",
77+
"sqls/tablespaces.0.all.sql",
8778
"sqls/ts_quotas.0.all.sql",
88-
"sqls/undostat.10020000.all.sql",
89-
"sqls/undostat.12010000.all.sql",
79+
"sqls/undostat.0.all.sql",
9080
],
9181
crate_name = "mk_oracle",
9282
edition = "2021",
File renamed without changes.

packages/mk-oracle/sqls/asm_diskgroup.10020000.all.sql

Lines changed: 0 additions & 33 deletions
This file was deleted.
File renamed without changes.

packages/mk-oracle/sqls/instance.0.all.sql

Lines changed: 88 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,92 @@
1313
-- limitations under the License.
1414
--
1515
-- SPDX-License-Identifier: Apache-2.0
16+
-- Section instance
17+
-- ATTENTION: must be patched with the version column ${version_column} -> version_full for >= 18.0.0.0 otherwise version
18+
SELECT UPPER(instance_name), -- Oracle instance name (uppercase)
19+
VERSION, -- Oracle version (e.g., 19.12.0.0.0)
20+
STATUS, -- Instance status (STARTED, MOUNTED, OPEN)
21+
LOGINS, -- Whether logins are allowed
22+
ARCHIVER, -- Archive log status (STARTED, STOPPED, FAILED)
23+
ROUND((SYSDATE - STARTUP_TIME) * 24 * 60 * 60), -- Uptime in seconds
24+
DBID, -- Unique identifier for the database
25+
LOG_MODE, -- Archive log mode (ARCHIVELOG/NOARCHIVELOG)
26+
DATABASE_ROLE, -- Role: PRIMARY or STANDBY
27+
FORCE_LOGGING, -- Whether FORCE LOGGING is enabled
28+
NAME, -- Database name
29+
TO_CHAR(CREATED, 'ddmmyyyyhh24mi'), -- Database creation timestamp
30+
UPPER(VALUE), -- Value of 'enable_pluggable_database' parameter (usually TRUE)
31+
CON_ID, -- Container ID (0 for CDB root, >0 for PDBs)
32+
PNAME, -- Pluggable database name
33+
PDBID, -- PDB ID
34+
POPEN_MODE, -- PDB open mode: READ WRITE, MOUNTED, etc.
35+
PRESTRICTED, -- Whether PDB is in RESTRICTED mode
36+
TOTAL_SIZE, -- Size of the PDB
37+
PRECOVERY_STATUS, -- Recovery status of the PDB (e.g., NOT RECOVERED)
38+
ROUND(NVL(POPEN_TIME, -1)), -- Seconds since the PDB was opened (-1 if null)
39+
PBLOCK_SIZE, -- PDB block size
40+
HOST_NAME -- Host where the instance is running
41+
FROM (
42+
-- === First part: Info for PDBs in a multitenant container ===
43+
SELECT i.instance_name,
44+
i.host_name,
45+
i.${version_column} VERSION, -- Bind variable: version or version_full
46+
i.STATUS,
47+
i.LOGINS,
48+
i.ARCHIVER,
49+
i.STARTUP_TIME,
50+
d.DBID,
51+
d.LOG_MODE,
52+
d.DATABASE_ROLE,
53+
d.FORCE_LOGGING,
54+
d.NAME,
55+
d.CREATED,
56+
p.VALUE, -- Value of 'enable_pluggable_database' param
57+
vp.CON_ID,
58+
vp.NAME PNAME, -- PDB name
59+
vp.DBID PDBID, -- PDB ID
60+
vp.OPEN_MODE POPEN_MODE,
61+
vp.RESTRICTED PRESTRICTED,
62+
vp.TOTAL_SIZE TOTAL_SIZE,
63+
vp.BLOCK_SIZE PBLOCK_SIZE,
64+
vp.RECOVERY_STATUS PRECOVERY_STATUS,
65+
(CAST(SYSTIMESTAMP AS DATE) - CAST(OPEN_TIME AS DATE)) * 86400 POPEN_TIME
66+
FROM v$instance i
67+
JOIN v$database d ON 1 = 1
68+
JOIN v$parameter p ON 1 = 1
69+
JOIN v$pdbs vp ON 1 = 1
70+
WHERE p.NAME = 'enable_pluggable_database'
1671

17-
-- Section instance: summary of the current Oracle database's runtime status, configuration, and role
18-
SELECT UPPER(i.instance_name), -- Instance name in uppercase (e.g., ORCL1)
19-
i.VERSION, -- Oracle database version (e.g., 19.0.0.0.0)
20-
i.STATUS, -- Instance status: STARTED, MOUNTED, OPEN
21-
i.LOGINS, -- Login status: ALLOWED, RESTRICTED, DISABLED
22-
i.ARCHIVER, -- Archive log status: STARTED, STOPPED, FAILED
23-
ROUND((SYSDATE - i.startup_time) * 24 * 60 * 60), -- Uptime in seconds since instance started
24-
DBID, -- Database Identifier (unique per DB)
25-
LOG_MODE, -- Archive log mode: ARCHIVELOG or NOARCHIVELOG
26-
DATABASE_ROLE, -- Database role: PRIMARY, PHYSICAL STANDBY, etc.
27-
FORCE_LOGGING, -- Indicates if FORCE LOGGING is enabled (YES/NO)
28-
d.name, -- Database name
29-
TO_CHAR(d.created, 'ddmmyyyyhh24mi'), -- Database creation date/time in custom format
30-
i.host_name -- Hostname of the server running the instance
31-
FROM v$instance i,
32-
v$database d -- Cross join used for combining instance and DB metadata
72+
UNION ALL
73+
74+
-- === Second part: fallback for non-multitenant (CDB only) ===
75+
SELECT i.instance_name,
76+
i.host_name,
77+
i.${version_column} VERSION,
78+
i.STATUS,
79+
i.LOGINS,
80+
i.ARCHIVER,
81+
i.STARTUP_TIME,
82+
d.DBID,
83+
d.LOG_MODE,
84+
d.DATABASE_ROLE,
85+
d.FORCE_LOGGING,
86+
d.NAME,
87+
d.CREATED,
88+
p.VALUE,
89+
0 CON_ID, -- Defaults for non-PDB environments
90+
NULL PNAME,
91+
0 PDBID,
92+
NULL POPEN_MODE,
93+
NULL PRESTRICTED,
94+
NULL PTOTAL_TIME,
95+
0 PBLOCK_SIZE,
96+
NULL PRECOVERY_STATUS,
97+
NULL POPEN_TIME
98+
FROM v$instance i
99+
JOIN v$database d ON 1 = 1
100+
JOIN v$parameter p ON 1 = 1
101+
WHERE p.NAME = 'enable_pluggable_database'
102+
103+
ORDER BY CON_ID
104+
)

packages/mk-oracle/sqls/instance.12010002.all.sql

Lines changed: 0 additions & 104 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/mk-oracle/sqls/locks.10020000.all.sql

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)