MINI MINI MANI MO
Rem
Rem $Header: sdo/admin/seme112.sql /main/24 2017/05/26 16:34:20 rjanders Exp $
Rem
Rem seme112.sql
Rem
Rem Copyright (c) 2010, 2017, Oracle and/or its affiliates.
Rem All rights reserved.
Rem
Rem NAME
Rem seme112.sql - <one-line expansion of the name>
Rem
Rem DESCRIPTION
Rem <short description of component this file declares/defines>
Rem
Rem NOTES
Rem <other useful comments, qualifications, etc.>
Rem
Rem BEGIN SQL_FILE_METADATA
Rem SQL_SOURCE_FILE: sdo/admin/seme112.sql
Rem SQL_SHIPPED_FILE: md/admin/seme112.sql
Rem SQL_PHASE: DOWNGRADE
Rem SQL_STARTUP_MODE: NORMAL
Rem SQL_IGNORABLE_ERRORS: NONE
Rem SQL_CALLING_FILE: NONE
Rem END SQL_FILE_METADATA
Rem
Rem MODIFIED (MM/DD/YY)
Rem rjanders 05/10/17 - #26037683: Raise 'when other' exceptions
Rem rjanders 04/13/17 - #25814260: Allow quoted bumpy-case usernames
Rem rjanders 03/23/17 - #25437999: Remove 'when others then NULL'
Rem handlers
Rem sravada 01/11/17 - bug 25370681
Rem matperry 01/25/16 - #22578872: remove calls to number_to_char
Rem matperry 12/22/15 - drop a few more synonyms
Rem matperry 06/16/15 - update for 128 byte identifiers
Rem rjanders 01/02/15 - long identifier project phase 1
Rem rjanders 01/29/14 - #18146131: Use NUMBER_TO_CHAR() for TO_CHAR()
Rem matperry 11/19/13 - refactor to call seme121.sql
Rem matperry 11/18/13 - remove set echo off
Rem matperry 10/17/13 - drop varchar versions of sparql aggregates
Rem rjanders 09/16/13 - OCCS: Remove hardtabs
Rem rjanders 03/16/13 - #16473696: Start/End _ORACLE_SCRIPT
Rem initialization
Rem matperry 09/25/12 - drop tables used for imp/exp
Rem matperry 07/30/12 - fix case when semantics and spatial are both not
Rem installed
Rem matperry 06/20/12 - update for 12.1 downgrade
Rem sdas 01/24/12 - drop sdo_rdf_rel2rdf_internal package body
Rem sdas 05/03/11 - add RDFCTX Upgrade
Rem matperry 03/31/11 - add initial contents
Rem sravada 05/03/10 - Created
Rem
Rem ********************************************************************
Rem #16473696: Indicate Oracle-Supplied object
@@?/rdbms/admin/sqlsessstart.sql
Rem ********************************************************************
-----------------------------------------------------------------------------------------------
-- The "e" script reverts the component's data dictionary back from release NNN+1 to release --
-- NNN. Since the cmpdbdwg.sql script calls the script for the downgrade release, these --
-- scripts are stacked in the reverse order. They are called in the context of the NEW --
-- server, before the RDBMS itself is downgraded. Set the version to the release version --
-- (3 digits), not a patch version, in the dbms_registry.downgraded procedure invocation. --
-----------------------------------------------------------------------------------------------
COLUMN :script_name1 NEW_VALUE comp_file1 NOPRINT
VARIABLE script_name1 VARCHAR2(130)
alter session set current_schema=MDSYS;
set define on;
-- make sure we do the downgrade without errors --
whenever sqlerror continue;
-- downgrade to 12.1 first --
@@seme121.sql
alter session set current_schema=MDSYS;
-- now downgrade to 11.2 --
-- First mark that we are downgrading --
begin
EXECUTE IMMEDIATE '
UPDATE MDSYS.RDF_PARAMETER
SET description = :1
WHERE namespace = :2 and
attribute = :3'
USING 'DOWNGRADING','MDSYS','SEM_VERSION';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: set downgrade in rdf_parameter: '||SQLERRM);
end;
/
declare
sem_exists number := 0;
begin
-- if semantics doesn't exist we need a dummy sdo_sem_downgrade package
select count(*) into sem_exists
from SYS.all_objects
where owner = 'MDSYS' and object_name = 'SDO_RDF_TRIPLE_S';
if (sem_exists = 0) then
begin
execute immediate '
create or replace package mdsys.sdo_sem_downgrade_utl as
function data_112NG_exists(notify_level in integer)
return boolean;
end sdo_sem_downgrade_utl;';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: sdo_sem_downgrade_utl: '||SQLERRM);
end;
end if;
end;
/
show errors;
-- Check data compatibility with 11.2.0.1.0 --
declare
sem_exists number := 0;
begin
select count(*) into sem_exists
from SYS.all_objects
where owner = 'MDSYS' and object_name = 'SDO_RDF_TRIPLE_S';
if (sem_exists > 0) then
if (mdsys.sdo_sem_downgrade_utl.data_112NG_exists(0)) then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Semantics data is not compatible with version 11.2.0.1.0. Not downgrading to Release 11.2.0.1.0.');
raise_application_error(-20000,
'Semantics data is not compatible with version 11.2.0.1.0');
end if;
end if;
end;
/
show errors;
declare
rdfctx_exists number;
sem_installed number;
remove_rdfctx boolean := false;
table_not_found exception;
pragma exception_init(table_not_found, -00942);
begin
-- we need to uninstall RDFCTX if it is installed
begin
-- see if semantics is installed
SELECT count(*) INTO sem_installed FROM SYS.ALL_TABLES
WHERE table_name='RDF_PARAMETER' AND owner='MDSYS';
if (sem_installed > 0) then
if (not(mdsys.sdo_sem_downgrade_utl.data_112NG_exists(0))) then
begin
rdfctx_exists := 0;
execute immediate '
select count(*)
from mdsys.rdf_parameter
where namespace = :1 and
attribute = :2'
into rdfctx_exists
using 'COMPONENT', 'RDFCTX';
exception
when table_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: query rdf_parameter for rdfctx: '||SQLERRM);
end;
if (rdfctx_exists is not null and rdfctx_exists > 0) then
remove_rdfctx := true;
end if;
end if;
end if;
if (remove_rdfctx) then
:script_name1 := '@sdordfctx_rm.sql';
else
:script_name1 := dbms_registry.nothing_script;
end if;
end;
end;
/
SELECT :script_name1 FROM SYS.DUAL;
@&comp_file1
alter session set current_schema=MDSYS;
set define on;
-- DROP packages, views, and classes that were added in the new release
prompt dropping new views ...
declare
network_exists number;
type cursor_type is ref cursor;
query_crs cursor_type;
mName varchar2(128);
clnMName varchar2(128);
sem_exists number := 0;
object_not_found exception;
pragma exception_init(object_not_found, -04043);
view_errors exception;
pragma exception_init(view_errors, -04063);
compile_errors exception;
pragma exception_init(compile_errors, -22324);
begin
select count(*) into sem_exists
from SYS.all_objects
where owner = 'MDSYS' and object_name = 'SDO_RDF_TRIPLE_S';
if (sem_exists > 0) then
if (not(mdsys.sdo_sem_downgrade_utl.data_112NG_exists(0))) then
--//////////////// packages \\\\\\\\\\\\\\\\--
-- drop package sdo_rdf_rel2rdf_internal
begin
execute immediate 'drop package mdsys.sdo_rdf_rel2rdf_internal';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: sdo_rdf_rel2rdf_internal: '||SQLERRM);
end;
-- EXP/IMP related stuff --
-- delete RDF exp/imp related rows and drop SDO_RDF_EXO_IMP package --
begin
execute immediate
'delete from SYS.EXPPKGACT$
where package=''SDO_RDF_EXP_IMP'' and schema=''SYS''';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: delete from sys.exppkgact$: '||SQLERRM);
end;
begin
execute immediate
'delete from SYS.impcalloutreg$
where package=''SDO_RDF_EXP_IMP'' and schema=''SYS''
and tag=''SEMANTIC''';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: delete from sys.impcalloutreg$: '||SQLERRM);
end;
begin
execute immediate 'drop package SYS.SDO_RDF_EXP_IMP';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop package sys.sdo_rdf_exp_imp: '||SQLERRM);
end;
-- drop package sdo_rdf_rel2rdf_internal
begin
execute immediate 'drop package mdsys.sdo_rdf_rel2rdf_internal';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: sdo_rdf_rel2rdf_internal: '||SQLERRM);
end;
--////////// views that are network independent \\\\\\\--
---------- RDF_PARAM$ ----------
begin
execute immediate 'drop view mdsys.rdf_param$';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop view mdsys.rdf_param$: '||SQLERRM);
end;
--/////////// network dependent views \\\\\\\\\--
-- see if RDF Network is present in DB
SELECT count(*) INTO network_exists FROM SYS.ALL_TABLES
WHERE table_name='RDF_VALUE$' AND owner='MDSYS';
if (network_exists > 0) then
---------- RDF_PRIV$ ----------
begin
EXECUTE IMMEDIATE '
DROP VIEW MDSYS.RDF_PRIV$
';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: rdf_priv$: '||SQLERRM);
end;
------- DTYPE_INDEX_INFO -------
begin
EXECUTE IMMEDIATE '
DROP VIEW MDSYS.SEM_DTYPE_INDEX_INFO
';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: sem_dtype_index_info: '||SQLERRM);
end;
begin
EXECUTE IMMEDIATE '
DROP VIEW MDSYS.RDF_DTYPE_INDEX_INFO
';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: rdf_dtype_index_info: '||SQLERRM);
end;
--------- Drop new stats views ------
begin
open query_crs for 'select model_name
from mdsys.rdf_model$';
loop
begin
fetch query_crs into mName;
exit when query_crs%NOTFOUND;
-- get the model name
clnMName := sys.dbms_assert.simple_sql_name(mName);
begin
EXECUTE IMMEDIATE '
DROP VIEW MDSYS.SEMT_' || clnMName || '
';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: semt stats view: '||SQLERRM);
end;
begin
EXECUTE IMMEDIATE '
DROP VIEW MDSYS.SEMP_' || clnMName || '
';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: semp stats view: '||SQLERRM);
end;
EXCEPTION
WHEN view_errors THEN NULL;
WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop stats views: '||SQLERRM);
end;
end loop;
close query_crs;
EXCEPTION
WHEN view_errors THEN NULL;
WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop stats views: '||SQLERRM);
close query_crs;
end;
end if;
end if;
end if;
end;
/
prompt ... finished dropping views
-- DROP force any new types, operators, and indextypes;
prompt dropping new types ...
declare
sem_exists number := 0;
object_not_found exception;
pragma exception_init(object_not_found, -04043);
synonym_not_found exception;
pragma exception_init(synonym_not_found, -01432);
begin
select count(*) into sem_exists
from SYS.all_objects
where owner = 'MDSYS' and object_name = 'SDO_RDF_TRIPLE_S';
if (sem_exists > 0) then
if (not(mdsys.sdo_sem_downgrade_utl.data_112NG_exists(0))) then
/* -- Keep these types to avoid too many invalid objects during RDBMS
-- downgrade testing
-------------- RDF_Graphs ------------
begin
EXECUTE IMMEDIATE '
DROP PUBLIC SYNONYM SDO_RDF_Graphs
';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop SDO_RDF_Graphs synonym: '||SQLERRM);
end;
begin
EXECUTE IMMEDIATE '
DROP TYPE MDSYS.RDF_Graphs FORCE
';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop RDF_Graphs: '||SQLERRM);
end;
----------- SDO_RDF_TERM_LIST ---------
begin
execute immediate 'drop public synonym SDO_RDF_TERM_LIST';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sdo_rdf_term_list synonym: '||SQLERRM);
end;
begin
execute immediate 'drop type mdsys.SDO_RDF_TERM_LIST force';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sdo_rdf_term_list: '||SQLERRM);
end;
------------- SDO_RDF_TERM ------------
begin
execute immediate 'drop public synonym SDO_RDF_TERM';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sdo_rdf_term synonym: '||SQLERRM);
end;
begin
execute immediate 'drop type mdsys.SDO_RDF_TERM force';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sdo_rdf_term type: '||SQLERRM);
end;
--------------- RDF_CLOBS -------------
begin
execute immediate 'drop public synonym SEM_CLOBS';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sem_clobs synonym: '||SQLERRM);
end;
begin
execute immediate 'drop public synonym SDO_RDF_CLOBS';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sdo_rdf_clobs synonym: '||SQLERRM);
end;
begin
execute immediate 'drop type mdsys.RDF_CLOBS force';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop rdf_clobs type: '||SQLERRM);
end;
------------- RDF_ENTAILMENTS ----------
begin
execute immediate 'drop public synonym SDO_RDF_Entailments';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop SDO_RDF_Entailments synonym: '||SQLERRM);
end;
begin
execute immediate 'drop public synonym SEM_Entailments';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sem_entailments synonym: '||SQLERRM);
end;
begin
execute immediate 'drop type mdsys.RDF_Entailments force';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop rdf_entailments type: '||SQLERRM);
end;
*/
----------- SPARQL 1.1 Aggregates --------
begin
execute immediate 'drop type MDSYS.SPARQL_Group_Concat force';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sparql_group_concat type: '||SQLERRM);
end;
begin
execute immediate 'drop type MDSYS.SPARQL_Sample force';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sparql_sample type: '||SQLERRM);
end;
begin
execute immediate 'drop type MDSYS.SPARQL_min force';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sparql_min type: '||SQLERRM);
end;
begin
execute immediate 'drop type MDSYS.SPARQL_max force';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sparql_max type: '||SQLERRM);
end;
begin
execute immediate 'drop function mdsys.sparql_groupconcat';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sparql_groupconcat function: '||SQLERRM);
end;
begin
execute immediate 'drop function mdsys.sparql_sampleagg';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sparql_sampleagg function: '||SQLERRM);
end;
begin
execute immediate 'drop function mdsys.sparql_minagg';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sparql_minagg function: '||SQLERRM);
end;
begin
execute immediate 'drop function mdsys.sparql_maxagg';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sparql_maxagg function: '||SQLERRM);
end;
begin
execute immediate 'drop public synonym SEM_APIS_GROUPCONCAT';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sem_apis_groupconcat synonynm: '||SQLERRM);
end;
begin
execute immediate 'drop public synonym SEM_APIS_SAMPLE';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sem_apis_sample synonym: '||SQLERRM);
end;
begin
execute immediate 'drop public synonym SEM_APIS_MIN';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sem_apis_min synonym: '||SQLERRM);
end;
begin
execute immediate 'drop public synonym SEM_APIS_MAX';
exception
when synonym_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop sem_apis_max synonym: '||SQLERRM);
end;
end if;
end if;
end;
/
prompt ... finished dropping new types
-- ALTER TYPE for existing types back to their prior release definitions
prompt altering types ...
declare
sem_exists number := 0;
begin
select count(*) into sem_exists
from SYS.all_objects
where owner = 'MDSYS' and object_name = 'SDO_RDF_TRIPLE_S';
if (sem_exists > 0) then
if (not(mdsys.sdo_sem_downgrade_utl.data_112NG_exists(0))) then
-------- SDO_RDF_TRIPLE_S ------
begin
EXECUTE IMMEDIATE '
ALTER TYPE sdo_rdf_triple_s
DROP MEMBER FUNCTION get_model RETURN VARCHAR2
DETERMINISTIC CASCADE
';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: sdo_rdf_triple_s: '||SQLERRM);
end;
end if;
end if;
end;
/
prompt ... finished altering types
-- ALTER OPERATOR and INDEXTYPE back to their prior release bindings and properties
-- UPDATE new columns to values appropriate for the old release and for when the database is re-upgraded
prompt altering network tables and rebuilding indexes...
declare
network_exists number;
numIdxCols pls_integer := 0;
optCol varchar2(128);
optComp varchar2(128);
wm_view boolean;
wm_vc varchar2(4000);
wm_vc_len integer;
wm_cursor integer;
wm_stmt varchar2(4000);
junk integer;
apptabName varchar2(4000);
idx_name varchar2(270);
begin
-- see if RDF Network is present in DB
SELECT count(*) INTO network_exists FROM SYS.ALL_TABLES
WHERE table_name='RDF_VALUE$' AND owner='MDSYS';
if (network_exists > 0) then
if(not(mdsys.sdo_sem_downgrade_utl.data_112NG_exists(0))) then
--------- See which non-gid unique index we need to create -------------
-- See if existing index is 5 or 6 columns.
-- If 6 columns, then it has been modified for optional components
idx_name := 'MDSYS.RDF_LNK_PCSGM_IDX';
begin
execute immediate '
select count(*)
from SYS.all_ind_columns
where index_name = ''RDF_LNK_PCSGM_IDX''
and index_owner = ''MDSYS'''
into numIdxCols;
-- rdfsa uses pcsgml_idx ...
if (numIdxCols = 0) then
execute immediate '
select count(*)
from SYS.all_ind_columns
where index_name = ''RDF_LNK_PCSGML_IDX''
and index_owner = ''MDSYS'''
into numIdxCols;
idx_name := 'RDF_LNK_PCSGML_IDX';
end if;
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: get num idx columns: '||SQLERRM);
end;
-- if we have 6 columns see what optional column is used
if (numIdxCols = 6) then
begin
-- see what modified index we have
execute immediate '
select attribute
from mdsys.rdf_parameter
where value = ''ENABLED''
and attribute in (''RDFCTX'',''RDFOLS'',''RDFOWM'')'
into optComp;
if (optComp = 'RDFOLS') then
optCol := 'CTXT1';
else
optCol := 'SUBSTR(CTXT2,1,600)';
end if;
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: get optional unique index column: '||SQLERRM);
end;
end if;
---------------- drop g_id-based unique index -----------------
begin
execute immediate '
drop index '|| idx_name;
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop graph-based unique index: '||SQLERRM);
end;
---------------- redefine LINK_ID column ----------------------
-- drop link_id --
begin
execute immediate
'alter table mdsys.rdf_link$ drop (link_id) cascade constraints';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop link_id from link$: '||SQLERRM);
end;
-- add new link_id --
begin
execute immediate
'alter table rdf_link$ add
(link_id as (
to_char(model_id, ''FMXXXXXXXXXXXXXXXX'') ||''_''||
to_char(start_node_id, ''FMXXXXXXXXXXXXXXXX'') ||''_''||
to_char(p_value_id, ''FMXXXXXXXXXXXXXXXX'') ||''_''||
to_char(canon_end_node_id,''FMXXXXXXXXXXXXXXXX'')))
';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: add link_id to link$: '||SQLERRM);
end;
------------------ drop G_ID column ---------------------------
begin
execute immediate
'alter table mdsys.rdf_link$ drop (g_id) cascade constraints';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop g_id from link$: '||SQLERRM);
end;
-------------- create non-gid unique index --------------------
-- if only 5 columns then create plain pvidcensnmid unique index
if (numIdxCols = 5) then
begin
execute immediate '
create unique index mdsys.rdf_lnk_pvidcensnmid_idx
on mdsys.rdf_link$ (
p_value_id, canon_end_node_id, start_node_id, model_id)
compress 2 nologging local parallel';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: create 4-column index: '||SQLERRM);
end;
-- if 6 columns then create modified unique index
elsif (numIdxCols = 6) then
begin
-- create new pvidcensnmid index --
execute immediate '
create unique index mdsys.rdf_lnk_pvidcensnmid_idx
on mdsys.rdf_link$ (
p_value_id, canon_end_node_id, start_node_id, model_id, '||optCol||')
compress 2 nologging local parallel';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: create 5-column index: '||SQLERRM);
end;
-- unique index is screwed up
else
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: Unexpected number of columns in RDF_LNK_PCSGM_IDX index');
end if;
---------- Undo RDF_MODEL$ changes from rdb2rdf ----------
begin
execute immediate
'alter table mdsys.rdf_model_internal$ drop(flags) cascade constraints';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: alter mdsys.rdf_model_internal$: '||SQLERRM);
end;
-- check view definition to see if we have a WM-enabled MODEL$ view
wm_view := false;
begin
wm_cursor := dbms_sql.open_cursor();
wm_stmt :=
'select text
from sys.all_views
where view_name=''RDF_MODEL$'' and
owner=''MDSYS''';
dbms_sql.parse(wm_cursor, wm_stmt, dbms_sql.NATIVE);
dbms_sql.define_column_long(wm_cursor, 1);
junk := dbms_sql.execute(wm_cursor);
if (dbms_sql.fetch_rows(wm_cursor) > 0) then
dbms_sql.column_value_long(
wm_cursor, 1, 4000, 0, wm_vc, wm_vc_len);
if (INSTR(NLS_UPPER(wm_vc), 'GET_ORIG_APPTAB_NAME') > 0) then
wm_view := true;
end if;
end if;
dbms_sql.close_cursor(wm_cursor);
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: semu112: check for wm rdf_model$ view: '||SQLERRM);
dbms_sql.close_cursor(wm_cursor);
end;
-- set correct application table name based on WM
apptabName := 'ao.object_name';
if (wm_view) then
apptabName := 'mdsys.sem_rdfwm_dr.get_orig_apptab_name(au.username, ao.object_name)';
end if;
begin
execute immediate
'CREATE OR REPLACE VIEW rdf_model$ (
owner
, model_id
, model_name
, table_name
, column_name
, model_tablespace_name
) AS
SELECT
au.username
, rmi.model_id
, rmi.model_name
, ' || apptabName || '
, rmi.column_name
, rmi.model_tablespace_name
FROM rdf_model_internal$ rmi,sys.all_users au,sys.all_objects ao
WHERE rmi.owner_id=au.user_id AND ao.owner=au.username AND
rmi.table_id=ao.object_id AND rmi.model_id > 0
UNION ALL
SELECT
au.username
, rmi.model_id
, rmi.model_name
, NULL
, NULL
, NULL
FROM rdf_model_internal$ rmi, sys.all_users au
WHERE rmi.owner_id=au.user_id AND
rmi.model_id < 0';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: re-create rdf_model$ view: '||SQLERRM);
end;
end if;
end if;
end;
/
prompt ... finished altering network tables and rebuilding indexes
-- Undo any modifications that were made to user objects during the upgrade.
-- Drop new tables
prompt dropping new tables ...
declare
network_exists number;
sem_exists number := 0;
begin
select count(*) into sem_exists
from SYS.all_objects
where owner = 'MDSYS' and object_name = 'SDO_RDF_TRIPLE_S';
if (sem_exists > 0) then
if (not(mdsys.sdo_sem_downgrade_utl.data_112NG_exists(0))) then
-------- RDF_PARAM$_TBL --------
begin
execute immediate 'drop table mdsys.rdf_param$_tbl';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop mdsys.rdf_param$_tbl: '||SQLERRM);
end;
-- see if RDF Network is present in DB
SELECT count(*) INTO network_exists FROM SYS.ALL_TABLES
WHERE table_name='RDF_VALUE$' AND owner='MDSYS';
if (network_exists > 0) then
-------- STATS_TABLES ------
begin
EXECUTE IMMEDIATE '
DROP TABLE MDSYS.RDF_PRED_STATS$
';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: rdf_pred_stats$: '||SQLERRM);
end;
begin
EXECUTE IMMEDIATE '
DROP TABLE MDSYS.RDF_TERM_STATS$
';
EXCEPTION WHEN OTHERS THEN
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: rdf_term_stats$: '||SQLERRM);
end;
begin
-- this dummy table was needed for export of RDF_MODEL$ view from 11.2.0.3
execute immediate 'DROP TABLE MDSYS.RDF_MODEL$_TBL';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop rdf_model$_tbl: '||SQLERRM);
end;
begin
-- this dummy table was needed for export of SEM_DTYPE_INDEX_INFO view from 11.2.0.3
execute immediate 'DROP TABLE MDSYS.RDF_DTYPE_INDEX_INFO_TBL';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop rdf_dtype_index_info_tbl: '||SQLERRM);
end;
begin
-- was used for export of grant info from 11.2.0.3: populated at export system_callout
execute immediate 'DROP TABLE MDSYS.RDF_GRANT_INFO$';
exception when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'SEM_INSTALL: seme112: drop rdf_grant_info$: '||SQLERRM);
end;
end if;
end if;
end if;
end;
/
prompt ...finished dropping new tables
-- go down to 11.1 as temporary fix to upgrade/downgrade issues
--@@seme111.sql
alter session set current_schema=SYS;
Rem ********************************************************************
Rem #16473696: Indicate Oracle-Supplied object
@@?/rdbms/admin/sqlsessend.sql
Rem ********************************************************************
OHA YOOOO