Skip to content

Commit f76f0db

Browse files
committed
Use gv$Parameter if gv$Systemparameter has empty value column (e.g. autonomous DB)
1 parent 601f2a0 commit f76f0db

File tree

8 files changed

+38
-26
lines changed

8 files changed

+38
-26
lines changed

app/controllers/dba_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def oracle_parameter
633633
Display_Value,
634634
IsDefault,
635635
ISSES_MODIFIABLE, IsSys_Modifiable, IsInstance_Modifiable, IsModified, IsAdjusted, IsDeprecated, Update_Comment#{", IsBasic" if get_db_version >= '11.1'}#{", Con_ID" if get_db_version >= '12.1'}
636-
FROM gv$System_Parameter
636+
FROM #{PanoramaConnection.system_parameter_table}
637637
) v ON v.Instance = i.Instance AND v.ID = i.ID+1
638638
)
639639
WHERE 1=1 #{where_string}
@@ -643,7 +643,7 @@ def oracle_parameter
643643
rescue Exception
644644
if @option.nil?
645645
@hint = "Access rights on tables X$KSPPI and X$KSPPSV are possibly missing!</br>
646-
Therefore only documented parameters from GV$System_Parameter are shown.</br></br>
646+
Therefore only documented parameters from #{PanoramaConnection.system_parameter_table} are shown.</br></br>
647647
648648
Possible solution to show underscore parameters also: Execute the following as user 'SYS':</br>
649649
&nbsp;&nbsp; create view X_$KSPPI as select * from X$KSPPI;</br>
@@ -667,7 +667,7 @@ def oracle_parameter
667667
Display_Value,
668668
IsDefault,
669669
ISSES_MODIFIABLE, IsSys_Modifiable, IsInstance_Modifiable, IsModified, IsAdjusted, IsDeprecated, Update_Comment#{", IsBasic" if get_db_version >= '11.1'}#{", Con_ID" if get_db_version >= '12.1'}
670-
FROM gv$System_Parameter
670+
FROM #{PanoramaConnection.system_parameter_table}
671671
)
672672
WHERE 1=1 #{where_string}
673673
ORDER BY Name, Instance"].concat(where_values)

app/controllers/dba_sga_controller.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -839,12 +839,12 @@ def list_sga_components
839839
@sums.each do |s|
840840
s['parameter'] =
841841
case s.pool
842-
when 'buffer_cache' then "db_block_buffers = #{ fn(sql_select_one(["SELECT Value FROM gv$System_Parameter WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'db_block_buffers']))}, db_cache_size = #{fn(sql_select_one(["SELECT Value FROM gv$System_Parameter WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'db_cache_size']))}"
843-
when 'java pool' then "java_pool_size = #{ fn(sql_select_one(["SELECT Value FROM gv$System_Parameter WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'java_pool_size']))}"
844-
when 'large pool' then "large_pool_size = #{ fn(sql_select_one(["SELECT Value FROM gv$System_Parameter WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'large_pool_size']))}"
845-
when 'log_buffer' then "log_buffer = #{ fn(sql_select_one(["SELECT Value FROM gv$System_Parameter WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'log_buffer']))}"
846-
when 'shared pool' then "shared_pool_size = #{ fn(sql_select_one(["SELECT Value FROM gv$System_Parameter WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'shared_pool_size']))}"
847-
when 'streams pool' then "streams_pool_size = #{fn(sql_select_one(["SELECT Value FROM gv$System_Parameter WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'streams_pool_size']))}"
842+
when 'buffer_cache' then "db_block_buffers = #{ fn(sql_select_one(["SELECT Value FROM #{PanoramaConnection.system_parameter_table} WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'db_block_buffers']))}, db_cache_size = #{fn(sql_select_one(["SELECT Value FROM #{PanoramaConnection.system_parameter_table} WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'db_cache_size']))}"
843+
when 'java pool' then "java_pool_size = #{ fn(sql_select_one(["SELECT Value FROM #{PanoramaConnection.system_parameter_table} WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'java_pool_size']))}"
844+
when 'large pool' then "large_pool_size = #{ fn(sql_select_one(["SELECT Value FROM #{PanoramaConnection.system_parameter_table} WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'large_pool_size']))}"
845+
when 'log_buffer' then "log_buffer = #{ fn(sql_select_one(["SELECT Value FROM #{PanoramaConnection.system_parameter_table} WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'log_buffer']))}"
846+
when 'shared pool' then "shared_pool_size = #{ fn(sql_select_one(["SELECT Value FROM #{PanoramaConnection.system_parameter_table} WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'shared_pool_size']))}"
847+
when 'streams pool' then "streams_pool_size = #{fn(sql_select_one(["SELECT Value FROM #{PanoramaConnection.system_parameter_table} WHERE Inst_ID = ? AND Name = ?", s.inst_id, 'streams_pool_size']))}"
848848
end
849849

850850
end
@@ -1192,7 +1192,7 @@ def list_result_cache_content
11921192
#{@instance ? " AND Inst_ID = ?" : ""}
11931193
GROUP BY Inst_ID
11941194
) s
1195-
JOIN gv$System_Parameter ms ON ms.Inst_ID = s.Inst_ID AND ms.Name = 'result_cache_max_size'
1195+
JOIN #{PanoramaConnection.system_parameter_table} ms ON ms.Inst_ID = s.Inst_ID AND ms.Name = 'result_cache_max_size'
11961196
", @instance]
11971197

11981198
@usage = sql_select_all ["\

app/controllers/env_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ def start_page
172172

173173

174174
system_parameter_sql = if get_db_version >= '12.1'
175-
# Ensure uniqueness of parameter names, because GV$System_Parameter may contain parameter names for each container
175+
# Ensure uniqueness of parameter names, because #{PanoramaConnection.system_parameter_table} may contain parameter names for each container
176176
# Use the parameter of the current container if exists, otherwise use the parameter of the CDB (0)
177-
"SELECT Inst_ID, Name, Value FROM GV$System_Parameter p0
177+
"SELECT Inst_ID, Name, Value FROM #{PanoramaConnection.system_parameter_table} p0
178178
WHERE Con_ID = 0
179-
AND NOT EXISTS (SELECT 1 FROM GV$System_Parameter pi WHERE pi.Inst_ID = p0.Inst_ID AND pi.Name = p0.Name AND pi.Con_ID = SYS_CONTEXT('USERENV', 'CON_ID'))
179+
AND NOT EXISTS (SELECT 1 FROM #{PanoramaConnection.system_parameter_table} pi WHERE pi.Inst_ID = p0.Inst_ID AND pi.Name = p0.Name AND pi.Con_ID = SYS_CONTEXT('USERENV', 'CON_ID'))
180180
UNION ALL
181-
SELECT Inst_ID, Name, Value FROM GV$System_Parameter WHERE Con_ID = SYS_CONTEXT('USERENV', 'CON_ID')"
181+
SELECT Inst_ID, Name, Value FROM #{PanoramaConnection.system_parameter_table} WHERE Con_ID = SYS_CONTEXT('USERENV', 'CON_ID')"
182182
else
183-
"SELECT Inst_ID, Name, Value FROM GV$System_Parameter"
183+
"SELECT Inst_ID, Name, Value FROM #{PanoramaConnection.system_parameter_table}"
184184
end
185185
nls_parameters_sql = if get_db_version >= '12.1'
186186
"SELECT Inst_ID, Parameter, Value FROM gv$NLS_Parameters p0
@@ -735,7 +735,7 @@ def init_management_pack_license
735735

736736
# @return [String] NONE | DIAGNOSTIC | DIAGNOSTIC+TUNING
737737
def read_control_management_pack_access
738-
pack = sql_select_one "SELECT Value FROM V$System_Parameter WHERE name='control_management_pack_access'"
738+
pack = sql_select_one "SELECT Value FROM #{PanoramaConnection.system_parameter_table[1..-1]} WHERE name='control_management_pack_access'"
739739
if pack.nil?
740740
if PanoramaConnection.autonomous_database?
741741
pack = 'DIAGNOSTIC+TUNING' # 'control_management_pack_access' is not set in autonomous databases, but license is included

app/controllers/storage_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def storage_usage_totals
6464
AND lf.Is_Recovery_Dest_File = 'NO' /* Count only redo logs outside FRA separate */
6565
"
6666

67-
@fra_size_bytes = sql_select_one("SELECT Value FROM v$System_Parameter WHERE Name='db_recovery_file_dest_size'").to_i
67+
@fra_size_bytes = sql_select_one("SELECT Value FROM #{PanoramaConnection.system_parameter_table[1..-1]} WHERE Name='db_recovery_file_dest_size'").to_i
6868
#@flashback_log = sql_select_first_row "SELECT * FROM v$Flashback_Database_Log"
6969
@fra_usage = sql_select_all "SELECT * FROM v$Flash_Recovery_Area_Usage WHERE Percent_Space_Used > 0 ORDER BY Percent_Space_Used DESC"
7070

@@ -668,14 +668,14 @@ def undo_usage
668668
SUM(DECODE(Status, 'UNEXPIRED', Bytes, 0))/(1024*1024) Size_MB_UnExpired,
669669
SUM(DECODE(Status, 'EXPIRED', Bytes, 0))/(1024*1024) Size_MB_Expired,
670670
SUM(DECODE(Status, 'ACTIVE', Bytes, 0))/(1024*1024) Size_MB_Active,
671-
(SELECT Inst_ID FROM gv$System_Parameter p WHERE Name='undo_tablespace' AND p.Value = e.Tablespace_Name) Inst_ID
671+
(SELECT Inst_ID FROM #{PanoramaConnection.system_parameter_table} p WHERE Name='undo_tablespace' AND p.Value = e.Tablespace_Name) Inst_ID
672672
FROM DBA_UNDO_Extents e
673673
GROUP BY Owner, Tablespace_Name
674674
ORDER BY SUM(Bytes) DESC")
675675

676676
@undo_segments = sql_select_iterator("\
677677
SELECT /* Panorama-Tool Ramm */ r.*, i.Owner Extent_Owner, i.Size_MB, i.Size_MB_UnExpired, i.Size_MB_Expired, i.Size_MB_Active, t.Transactions
678-
--,(SELECT Inst_ID FROM gv$System_Parameter p WHERE Name='undo_tablespace' AND p.Value = i.Tablespace_Name) Inst_ID
678+
--,(SELECT Inst_ID FROM #{PanoramaConnection.system_parameter_table} p WHERE Name='undo_tablespace' AND p.Value = i.Tablespace_Name) Inst_ID
679679
FROM DBA_Rollback_Segs r
680680
LEFT OUTER JOIN (SELECT Owner, Segment_Name, Tablespace_Name,
681681
SUM(Bytes)/(1024*1024) Size_MB,

app/helpers/dragnet/dragnet_sqls_tuning_sga_pga_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ def dragnet_sqls_tuning_sga_pga
211211
:desc => t(:dragnet_helper_3_12_desc, :default=> 'Detection of non-optimal or incompatible database parameters'),
212212
:sql=> "SELECT /* DB-Tools Ramm DB-Parameter */
213213
Inst_ID, Name, Value, 'Value should be 0 if cursor_sharing is used because lookup to session cached cursors is done before converting literals to bind variables' Description
214-
FROM gv$System_Parameter p
214+
FROM #{PanoramaConnection.system_parameter_table} p
215215
WHERE Name = 'session_cached_cursors'
216216
AND Value != '0'
217-
AND EXISTS (SELECT 1 FROM gv$System_Parameter pi WHERE pi.Inst_ID=p.Inst_ID AND pi.Name='cursor_sharing' AND pi.value!='EXACT' )
217+
AND EXISTS (SELECT 1 FROM #{PanoramaConnection.system_parameter_table} pi WHERE pi.Inst_ID=p.Inst_ID AND pi.Name='cursor_sharing' AND pi.value!='EXACT' )
218218
",
219219
},
220220
]

app/helpers/panorama_sampler/package_panorama_sampler_snapshot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def panorama_sampler_snapshot_code
266266
INSERT INTO panorama_owner.Panorama_Parameter (SNAP_ID, DBID, INSTANCE_NUMBER, PARAMETER_HASH, PARAMETER_NAME, VALUE, ISDEFAULT, ISMODIFIED, CON_DBID, CON_ID
267267
) SELECT p_Snap_ID, p_DBID, p_Instance, Hash, Name, Value, ISDEFAULT, ISMODIFIED,
268268
#{PanoramaConnection.db_version >= '12.1' ? "panorama_owner.Con_DBID_From_Con_ID.Get(Con_ID), Con_ID" : "p_DBID, 0"}
269-
FROM v$System_Parameter
269+
FROM #{PanoramaConnection.system_parameter_table[1..-1]}
270270
;
271271
COMMIT;
272272
END Snap_Parameter;

app/models/panorama_connection.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ def read_initial_attributes
181181
db_config = PanoramaConnection.direct_select_one(@jdbc_connection,
182182
"SELECT i.Instance_Number, i.Version, d.DBID, d.Name Database_Name, SYS_CONTEXT('USERENV', 'SID') SID, v.Edition,
183183
CASE WHEN d.Platform_Name LIKE '%64%' THEN 8 ELSE 4 END db_wordsize,
184-
NVL((SELECT /*+ NO_MERGE */ TO_NUMBER(Value) FROM v$System_Parameter WHERE Name = 'db_block_size'), 8192) db_blocksize,
185-
NVL((SELECT /*+ NO_MERGE */ Value FROM v$System_Parameter WHERE Name = 'cluster_database'), 'FALSE') cluster_database,
184+
NVL((SELECT /*+ NO_MERGE */ TO_NUMBER(Value) FROM #{system_parameter_table[1..-1]} WHERE Name = 'db_block_size'), 8192) db_blocksize,
185+
NVL((SELECT /*+ NO_MERGE */ Value FROM #{system_parameter_table[1..-1]} WHERE Name = 'cluster_database'), 'FALSE') cluster_database,
186186
(SELECT Type_Size FROM v$Type_Size WHERE Type = 'KCBH') Block_Common_Header_Size,
187187
(SELECT Type_Size FROM v$Type_Size WHERE Type = 'UB4') Unsigned_Byte_4_Size,
188188
(SELECT Type_Size FROM v$Type_Size WHERE Type = 'KTBBH') Transaction_Fixed_Header_Size,
@@ -286,6 +286,17 @@ def autonomous_database?
286286
@autonomous_database
287287
end
288288

289+
# @return [String] the name of the system parameter table to use
290+
def system_parameter_table
291+
if !defined?(@system_parameter_table) || @system_parameter_table.nil?
292+
@system_parameter_table = 'GV$System_Parameter' # Default if no other need
293+
if PanoramaConnection.direct_select_one(@jdbc_connection, "SELECT Value FROM v$System_Parameter WHERE Name = 'cpu_count'")['value'].nil?
294+
@system_parameter_table = 'GV$Parameter' # Use gv$Parameter if v$System_Parameter has empty values (e.g. for autonomous DB)
295+
end
296+
end
297+
@system_parameter_table
298+
end
299+
289300
# Select PDBs each time they are requested because number of PDBs may change during lifetime of PanoramaConnection
290301
def pdbs
291302
if !defined?(@pdbs) || @pdbs.nil?
@@ -444,6 +455,7 @@ def self.rowid_size; check_for_open_connection; Thre
444455
def self.saddr; check_for_open_connection; Thread.current[:panorama_connection_connection_object].saddr; end
445456
def self.serial_no; check_for_open_connection; Thread.current[:panorama_connection_connection_object].serial_no; end
446457
def self.sid; check_for_open_connection; Thread.current[:panorama_connection_connection_object].sid; end
458+
def self.system_parameter_table; check_for_open_connection; Thread.current[:panorama_connection_connection_object].system_parameter_table; end
447459
# @return [Time] Time on DB-Server in his default timezone, but flagged with the time zone of the Panorama server
448460
def self.db_systime; check_for_open_connection; Time.now + Thread.current[:panorama_connection_connection_object].time_delay_secs; end
449461
def self.stat_id_consistent_gets; check_for_open_connection; Thread.current[:panorama_connection_connection_object].stat_id_consistent_gets; end

app/views/env/_start_page.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@
131131
{:caption=>"Startup", :data=>proc{|rec| localeDateTime(rec.startup_time) }, :title=>"Startup der DB" },
132132
{:caption=>"Archiver", :data=>proc{|rec| rec.archiver }, :title=>"Archiver mode of instance"},
133133
{:caption=>"Character-set", :data=>proc{|rec| rec.nls_characterset }, :title=>"Character set of database", :data_title=>proc{|rec| "%t: NChar_Character_Set=#{rec.nls_nchar_characterset}"}},
134-
{:caption=>"Cp.", :data=>show_compatible, :title=>"Optimizer compatible mode of instance (from v$System_Parameter)", data_title: data_title_compatible},
134+
{:caption=>"Cp.", :data=>show_compatible, :title=>"Optimizer compatible mode of instance (from #{PanoramaConnection.system_parameter_table[1..-1]})", data_title: data_title_compatible},
135135
{:caption=>"Instance role", :data=>proc{|rec| rec["instance_role"] }, :title=>"Instance role for data guard"},
136-
{:caption=>"CPU cnt.", :data=>proc{|rec| rec.cpu_count }, :title=>"Number of CPUs counted for instance (from gv$System_Parameter)", data_title: cpu_count_data_title, align: :right},
136+
{:caption=>"CPU cnt.", :data=>proc{|rec| rec.cpu_count }, :title=>"Number of CPUs counted for instance (from #{PanoramaConnection.system_parameter_table})", data_title: cpu_count_data_title, align: :right},
137137
{:caption=>"Phys. memory (GB)", :data=>proc{|rec| fn(rec.phys_mem_gb, 3) }, :title=>"Physical server memory in Gigabyte (from gv$OSStat)", data_title: phys_mem_data_title, align: :right},
138138
{:caption=>"Resource manager plan", :data=>proc{|rec| rec.resource_manager_plan }, :title=>"Resource manager plan that is currently active.\nEmpty if resource manager is deactivated."},
139139
{:caption=>"Srv.", :data=>link_services, :title=>"Number of TNS services for this instance\n(from gv$Services)", :align=>:right},

0 commit comments

Comments
 (0)