MINI MINI MANI MO
<?xml version="1.0"?>
<!--
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
NAME
kucommon.xsl
DESCRIPTION
Templates for common and utility functions
NOTES
Do NOT modify this file under any circumstance. If you wish to use this
stylesheet with an external XML/XSL parser, first make a copy then reverse
the comments on any xsl:import statements appearing below.
MODIFIED MM/DD/YY
apfwkr 04/13/18 - Backport rmacnico_bug-25882883 from main
rapayne 03/18/18 - allow suppression of inmemory duplicate attributes.
jjanosik 10/11/17 - Bug 26952839: No memoptimize for read if constraints
are turned off
sdavidso 10/07/17 - bug26385367 move chunk fails with ILM POLICY
sdavidso 08/29/17 - allow enquote to enclose the string
rapayne 08/12/17 - Bug DWCS: add new dwcs transform param.
jjanosik 08/11/17 - Bug 26595466: Get original column name for index
partition columns
tbhukya 08/08/17 - Bug 26582168: Inmemory clause is not valid for PET
rapayne 07/28/17 - bug 26033751: correctly handle objects with
special chars (eg. spaces, apos, etc).
tbhukya 07/26/17 - Bug 26515193: Handle location files of different
directories with departition option
tbhukya 07/12/17 - Bug 26421152: Handle location files of different
directories with merge partition option
tbhukya 06/12/17 - Bug 26237351: Add support of merge partition option
to external partition table
tbhukya 05/16/17 - Bug 26036341: Add GenExtTableLoc
jjanosik 05/11/17 - Bug 25321187: change DoSegInMemory
rapayne 05/09/17 - Bug 25732728: define INDEX_COMPRESSION_CLAUSE param.
tbhukya 04/10/17 - Bug 25556006: Partitioned Databound Collation support
sdavidso 03/23/17 - bug25440009 handle user name with apostrophe
rapayne 03/20/17 - Bug 25723235: handle INMEMORY_CLAUSE values which
have embedded quotes.
tbhukya 01/30/17 - Bug 25095866: Generate MEMOPTIMIZE clause
jjanosik 12/07/16 - bug 24482120: generate cellmemory when segment
creation is deferred
rapayne 10/22/16 - Bug 24732029: generate IM selective col clauses
when table is marke NO INMEMORY.
jjanosik 09/02/16 - Bug 24313182: consolidate collation clauses
tbhukya 08/25/16 - Bug 24285300: Add EncryptAlgo template
tbhukya 06/09/16 - Bug 22171888: CellMemory support
sdavidso 04/15/16 - bug23098311 add sharing=none
sdavidso 03/23/16 - bug22535196 update "sharing=" clause
rapayne 01/30/16 - bug 22611512: fix variable Transportable
rapayne 12/15/15 - bug 22165030: fix imc SERVICE name after txn aditigu_sv2.
rapayne 11/16/15 - bug 22165030 (and 21238674): imc distribute for
subpartition templates.
rapayne 10/20/15 - Bug 22014893: inmemory SERVICE names need to be
quoted.
bwright 10/19/15 - Use common QuoteObject in ColNameOrAttr
tbhukya 10/07/15 - Bug 14696962: Use name for unused attribute cols
rapayne 07/07/15 - Bug 2114761: New IMC DISTRIBUTE syntax.
rapayne 04/09/15 - APP_ROOT support. Add common SHARING clause
function as well as sharing_clause transform
parameter.
aditigu 03/03/15 - Bug 20433683: Unspecified IMC attrs should be null
sdavidso 08/28/14 - proj 56220-2 - partition transportable
tbhukya 01/05/15 - Bug 20319428: Declare referred params
tbhukya 06/04/14 - Bug 18777954 : Do not generate inmemory properties
for system generated nested table column
sdavidso 03/15/14 - bug18405747: fix externally identified user
lbarton 02/27/14 - bug 18322658: OMIT_COL_DATATYPE
sdavidso 12/02/13 - lrg10314000: unused column inmemory
bwright 11/25/13 - Bug 17801303: Diff default action for
PRESERVE_TYPE_EVOLUTION for GET_DDL (no)
than for DP import (yes)
sdavidso 11/14/13 - bug17718297 - IMC selective column
sdavidso 08/02/13 - bug16915643: extended inmemory options
dgagne 09/06/13 - remove reclaimtempsegment from being converted
bwright 08/15/13 - Bug 17312600: Remove hard tabs from DP src code
sdavidso 04/05/13 - proj42352: DP In-memory columnar
sdavidso 10/26/12 - bug14783517 - SOURCE_VERSION trans param
bwright 10/08/12 - Add PRESERVE_TYPE_EVOLUTION transform param
traney 08/08/12 - 14407652: [non]editionable template
rapayne 12/17/11 - Triton PRIVS are no longer schema based.
rapayne 10/24/11 - XS_OBJ/OWNER changed to XS_OBJ/OWNER_NAME
sdavidso 10/21/11 - add AUDIT_OBJ
lbarton 07/13/11 - 32948_lob_storage
lbarton 07/12/11 - 32135_table_compression_clause
rapayne 07/04/11 - proj: schema based XDS objects
rapayne 03/20/11 - proj 30924: support disabling of archive logging
for indexes.
rapayne 08/01/10 - add SingleQuotedName and XSNameList
tbhukya 05/30/10 - bug 9675800: Add logging clause for index in
partition clause
lbarton 04/29/10 - bug 9650606: more dsc details
lbarton 02/12/10 - lrg 4478962: logging in partitions
sdavidso 01/15/10 - bug 8929002: bad column name for mView
lbarton 11/23/09 - TABLE_COMPRESSION param
rapayne 04/26/09 - bug 8355496: define common VERSION parameter.
sdavidso 01/20/09 - bug 5672035: fix quote handling for
remap_column_name
lbarton 12/30/08 - Bug 7354560: procedure terminator
lbarton 11/02/07 - bug 6605086: escape single quote
lbarton 10/31/07 - bug 6051635: map SYS_NC_ROWINFO$ to pseudocolumn
OBJECT_VALUE
rapayne 10/02/07 - bug 6088114: add supertype_obj to schema obj template
sdavidso 11/08/05 - Fix error importing tables w/multi XMLtype cols
lbarton 11/02/05 - Bug 4715313: reformat files for use with XMLSpy
lbarton 07/18/03 - Bug 3045926: move common PLSQL processing here
lbarton 05/16/03 - bug 2949397: support INDEXTYPE options
lbarton 04/11/03 - new param to SCHEMA_OBJ template
lbarton 10/09/02 - add row parsing
bmccarth 08/22/02 - Add EMIT_SCHEMA
htseng 08/02/02 - add grantee params
htseng 07/25/02 - add BaseSchemaNode, BaseNameNode and BaseObjectType
htseng 09/24/01 - fix missing kujob.xsl.
htseng 09/04/01 - add STATS_OBJ.
gclaborn 11/03/00 - change name
lbarton 09/28/00 - add ColNameOrAttr
gclaborn 06/27/00 - Remove <dummy/> element
lbarton 06/23/00 - Multinested collections
lbarton 06/02/00 - support parsing
lbarton 03/17/00 - Add module header
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Top-level parameters -->
<xsl:param name="EMIT_SCHEMA">1</xsl:param>
<xsl:param name="LOB_STORAGE">NO_CHANGE</xsl:param>
<xsl:param name="TABLE_COMPRESSION">1</xsl:param>
<xsl:param name="TABLE_COMPRESSION_CLAUSE" select="''"/>
<xsl:param name="INDEX_COMPRESSION_CLAUSE" select="''"/>
<xsl:param name="CONSTRAINTS">1</xsl:param>
<xsl:param name="INMEMORY">1</xsl:param>
<xsl:param name="INMEMORY_CLAUSE" select="''"/>
<xsl:param name="PRS_ROW">0</xsl:param>
<xsl:param name="PRS_DELIM">\{]`</xsl:param>
<xsl:param name="VERSION">9999999999</xsl:param>
<xsl:param name="SOURCE_VERSION">1000000000</xsl:param>
<xsl:param name="DISABLE_ARCHIVE_LOGGING">0</xsl:param>
<xsl:param name="RESTORE_ARCHIVE_LOGGING">0</xsl:param>
<xsl:param name="OMIT_COL_DATATYPE">0</xsl:param>
<xsl:param name="PRETTY">1</xsl:param>
<xsl:param name="SQLTERMINATOR">0</xsl:param>
<xsl:param name="EXPORT">0</xsl:param>
<xsl:param name="SHARING_CLAUSE">0</xsl:param>
<xsl:param name="COLLATION_CLAUSE">NEVER</xsl:param>
<xsl:param name="PARTITIONING">1</xsl:param>
<xsl:param name="TRANSPORTABLE">0</xsl:param>
<xsl:param name="DWCS_CVT_IOTS">0</xsl:param>
<xsl:param name="DWCS_CVT_CONSTRAINTS">0</xsl:param>
<!-- Determine whether this is a transportable mode convert.
See kutable.xsl for more details.
-->
<xsl:variable name="Transportable">
<xsl:choose>
<xsl:when test="$TRANSPORTABLE = 0">0</xsl:when>
<xsl:when test="$TRANSPORTABLE = 1">1</xsl:when>
<xsl:when test='$TRANSPORTABLE = 2 and
not(/ROWSET/ROW/TABLE_T/VIEW_AS_TABLE) and
.//TRANSPORTABLE="1"'>1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- [TABLE | INDEX]_COMPRESSION_CLAUSE are not used/valid during
transportable related transforms. The associated variable accounts for
this and will only mirror the actual transform param value when this
is not a transportable job.
-->
<xsl:variable name="Table_Compression_Clause">
<xsl:if test="$TRANSPORTABLE = 0">
<xsl:value-of select="$TABLE_COMPRESSION_CLAUSE"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="Index_Compression_Clause">
<xsl:if test="$TRANSPORTABLE = 0">
<xsl:value-of select="$INDEX_COMPRESSION_CLAUSE"/>
</xsl:if>
</xsl:variable>
<xsl:param name="UNIQUE_NAME" select="''"/>
<!-- Params for parse -->
<xsl:param name="PRS_DDL">0</xsl:param>
<xsl:param name="PRS_VERB">0</xsl:param>
<xsl:param name="PRS_OBJECT_TYPE">0</xsl:param>
<xsl:param name="PRS_SCHEMA">0</xsl:param>
<xsl:param name="PRS_GRANTEE">0</xsl:param>
<xsl:param name="PRS_GRANTOR">0</xsl:param>
<xsl:param name="PRS_BASE_OBJECT_SCHEMA">0</xsl:param>
<xsl:param name="PRS_BASE_OBJECT_NAME">0</xsl:param>
<xsl:param name="PRS_BASE_OBJECT_TYPE">0</xsl:param>
<xsl:param name="PRS_NAME">0</xsl:param>
<!-- Keep in-sync with catmetinsert's default. The expected values
for this parameter are 0 (FALSE) or 1 (TRUE). We set the
default to something different, 3, so we know if the parameter
was passed in or not. See usage in kusource.xsl -->
<xsl:param name="PRESERVE_TYPE_EVOLUTION">3</xsl:param>
<!-- All DDL is text, and this is the only way to correctly render '<' -->
<xsl:output method="text"/>
<!-- Top level template for all objects -->
<xsl:template match="/">
<xsl:for-each select="RESULTSET/ROW | ROWSET/ROW">
<xsl:if test="$PRS_ROW=1">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>D</xsl:text>
<xsl:value-of select="position()"/>
<xsl:value-of select="$PRS_DELIM"/>
</xsl:if>
<xsl:apply-templates/>
</xsl:for-each>
</xsl:template>
<!-- Formats a schema object name -->
<xsl:template match="SCHEMA_OBJ | BASE_OBJ | IMPL_OBJ | OPER_OBJ | STATS_OBJ
| BASETYPE_OBJ | ARRAYTYPE_OBJ | SUPERTYPE_OBJ | AUDIT_OBJ">
<xsl:param name="TrailingBlank">1</xsl:param>
<xsl:param name="DoP2T">0</xsl:param>
<xsl:variable name="LocalName">
<xsl:choose>
<xsl:when test="string-length($UNIQUE_NAME) > 0 and TYPE_NAME = 'TABLE' and $DoP2T = 1">
<xsl:variable name="FName">
<xsl:text>KU$_</xsl:text>
<xsl:value-of select="$UNIQUE_NAME"/>
<xsl:text>_</xsl:text>
<xsl:value-of select="OBJ_NUM"/>
<xsl:text>_</xsl:text>
<xsl:value-of select="../TABPART/PHYPART_NUM"/>
<!-- phypart_num is not unique for subpartitions - use subpart obj# -->
<xsl:value-of select="../SUBPART/OBJ_NUM"/>
<xsl:text>_</xsl:text>
<xsl:value-of select="NAME"/>
</xsl:variable>
<xsl:value-of select="substring($FName,1,128)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="NAME"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Schema" select="OWNER_NAME"/>
<xsl:with-param name="Object" select="$LocalName"/>
<xsl:with-param name="TrailingBlank" select="$TrailingBlank"/>
</xsl:call-template>
</xsl:template>
<!-- Utility routine to form a qualified schema object name; e.g, "a"."b" -->
<xsl:template name="QuoteObject">
<xsl:param name="EnQuo" select="'0'"/>
<xsl:param name="Schema" select="''"/>
<xsl:param name="Object"/>
<xsl:param name="TrailingBlank">0</xsl:param>
<xsl:if test="$EMIT_SCHEMA=1">
<xsl:if test="string-length($Schema)!=0">
<xsl:text>"</xsl:text>
<xsl:choose>
<xsl:when test="$EnQuo!=0">
<xsl:call-template name="EnQuote">
<xsl:with-param name="String" select="$Schema"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Schema"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"</xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="string-length($Object)!=0">
<xsl:if test="$EMIT_SCHEMA=1">
<xsl:if test="string-length($Schema)!=0">
<xsl:text>.</xsl:text>
</xsl:if>
</xsl:if>
<xsl:text>"</xsl:text>
<xsl:choose>
<xsl:when test="$EnQuo!=0">
<xsl:call-template name="EnQuote">
<xsl:with-param name="String" select="$Object"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Object"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"</xsl:text>
</xsl:if>
<xsl:if test="$TrailingBlank!=0">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<!-- Utility routine to form a qualified schema object name.
Typically used to generate API parameter values:
e.g, '"a"."b"'
Essentially a wrapper for the common template QuoteObject
-->
<xsl:template name="TSQuoteObject">
<xsl:param name="Schema"/>
<xsl:param name="Object"/>
<xsl:text>'</xsl:text>
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Schema" select="$Schema"/>
<xsl:with-param name="Object" select="$Object"/>
<xsl:with-param name="EnQuo" select='"1"'/>
</xsl:call-template>
<xsl:text>'</xsl:text>
</xsl:template>
<!--output string, converting QUOTE_SYMBOL-->
<xsl:template name="SubstQuot">
<xsl:param name="String" select="''"/>
<xsl:variable name="Remain" select='substring-after($String,"&")'/>
<!-- *******************************************************************
Template: SubstQuot
Parameters:
String - string to output, which may have replaced quotes (to pass the string as a transform parameter).
Substitutions:
& -> &
" -> "
******************************************************************** -->
<xsl:choose>
<xsl:when test='contains($String,"&")'>
<xsl:value-of select='substring-before($String,"&")'/>
<xsl:choose>
<xsl:when test='substring($Remain,1,4)="amp;"'>
<xsl:text>&</xsl:text>
<xsl:call-template name="SubstQuot">
<xsl:with-param name="String" select="substring($Remain,5)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test='substring($Remain,1,5)="quot;"'>
<xsl:text>"</xsl:text>
<xsl:call-template name="SubstQuot">
<xsl:with-param name="String" select="substring($Remain,6)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!--We really shouldn't get here. If we do, it means we are doing SubstQuot on a string which had not undergone quote substitution - so we'll just produce the '$' and copy out the remaining string-->
<xsl:text>&</xsl:text>
<xsl:value-of select="$Remain"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$String"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--EnQuote - double single quotes (apostrophies)-->
<xsl:template name="EnQuote">
<xsl:param name="String" select="''"/>
<xsl:param name="Enclose" select="'0'"/>
<!-- *******************************************************************
Template: EnQuote
Parameters:
String - string to output, which may have replaced quotes (to pass the string as a transform parameter).
Substitutions:
' -> ''
******************************************************************** -->
<xsl:if test="$Enclose!=0">
<xsl:text>'</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test='contains($String,"'")'>
<xsl:value-of select='substring-before($String,"'")'/>
<xsl:text>''</xsl:text>
<xsl:call-template name="EnQuote">
<xsl:with-param name="String" select='substring-after($String,"'")'/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$String"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$Enclose!=0">
<xsl:text>'</xsl:text>
</xsl:if>
</xsl:template>
<!-- emit a column name or attrname depending on property bit
InColDef - 1 = we are in the context of defining a column - avoid
use of the pseudo column name OBJECT_VALUE -->
<xsl:template name="ColNameOrAttr">
<xsl:param name="ColItem">0</xsl:param>
<xsl:param name="InColDef">0</xsl:param>
<!-- use FULLATTRNAME if it exists (should already be double quoted),
otherwise use ATTRNAME (should already be double quoted) if it exists,
otherwise use NAME (needs to be double quoted here). The old test
was "1>($ColItem/PROPERTY mod 2)". Bug 14696962: Use NAME for unused
attribute column in tts mode instead of FULLATTRNAME or ATTRNAME -->
<xsl:choose>
<xsl:when test="$ColItem/FULLATTRNAME and
not((($ColItem/PROPERTY mod 65536)>=32768 and ($ColItem/PROPERTY mod 2)>=1) and
$Transportable=1)">
<xsl:value-of select="$ColItem/FULLATTRNAME"/>
</xsl:when>
<xsl:when test="$ColItem/ATTRNAME and
not((($ColItem/PROPERTY mod 65536)>=32768 and ($ColItem/PROPERTY mod 2)>=1) and
$Transportable=1)">
<xsl:value-of select="$ColItem/ATTRNAME"/>
<!-- already in quotes -->
</xsl:when>
<!-- Use original column name for partition column when virtual column
for partitioned collation exists
PROPERTY2 :
16384 - Virtual column created for collation
536870912 - Virtual column created for partitioning -->
<xsl:when test="$ColItem/DEFAULT_VAL and
($ColItem/PROPERTY2 mod 32768)>=16384 and ($ColItem/PROPERTY2 mod 1073741824)>=536870912">
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="$ColItem/ORG_COLNAME"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$ColItem/NAME='SYS_NC_ROWINFO$'and $InColDef=0">
<!-- SQL Ref Manual says to use pseudocolumn OBJECT_VALUE instead of
SYS_NC_ROWINFO$ -->
<xsl:text>OBJECT_VALUE</xsl:text>
</xsl:when>
<xsl:when test="$ColItem/ORG_COLNAME">
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="$ColItem/ORG_COLNAME"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- must supply quotes -->
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="$ColItem/NAME"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="DoAllLogging">
<xsl:param name="FlagsNode" select="''"/>
<xsl:param name="ADT_type">TABLE</xsl:param>
<xsl:param name="Partition">0</xsl:param>
<!-- *******************************************************************
Template: DoAllLogging - General purpose template for processing logging
Parameters
FlagsNode - FLAGS
ADT_type - TABLE = tables
INDEX = PIOTs and indexes
LOB = lobs
Partition - non-0 = processing a partition
******************************************************************** -->
<!-- logging not supported for lob storage -->
<xsl:choose>
<xsl:when test="$ADT_type = 'LOB'"/>
<xsl:when test="$ADT_type = 'INDEX'">
<xsl:choose>
<xsl:when test="$Partition='1'">
<xsl:call-template name="DoPartLogging">
<xsl:with-param name="FlagsNode" select="FLAGS"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="DoIndLogging">
<xsl:with-param name="FlagsNode" select="FLAGS"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$Partition='0'">
<xsl:call-template name="DoLogging">
<xsl:with-param name="FlagsNode" select="FLAGS"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="DoPartLogging">
<xsl:with-param name="FlagsNode" select="FLAGS"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="DoLogging">
<xsl:param name="FlagsNode" select="''"/>
<!-- *******************************************************************
Template: DoLogging - Process the logging bit in tab$.flags
where 0x20 = table has no logging
Parameters
FlagsNode - FLAGS
******************************************************************** -->
<xsl:choose>
<xsl:when test="($FlagsNode mod 64)>=32">NOLOGGING</xsl:when>
<xsl:otherwise>LOGGING</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="DoPartLogging">
<xsl:param name="FlagsNode" select="''"/>
<!-- *******************************************************************
Template: DoPartLogging - Process the logging bit in tabpart$.flags
and other tables (tabsubpart$, etc.) where 0x04 = NO LOGGING for partition
Parameters
FlagsNode - FLAGS
******************************************************************** -->
<xsl:choose>
<xsl:when test="($FlagsNode mod 8)>=4">NOLOGGING </xsl:when>
<xsl:otherwise>LOGGING </xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="DoIndLogging">
<xsl:param name="FlagsNode" select="''"/>
<!-- *******************************************************************
Template: DoIndLogging - Process the logging bit in ind$.flags
and other tables (indpart$, indsubpart$) where 0x04 = NO LOGGING
Parameters
FlagsNode - FLAGS
Implicit Parameters (i.e., transform parameters).
DISABLE_ ARCHIVE_LOGGING - transform parameter to designate whether to disable
archive logging for indexes.
For indexes the create ddl is alter to disable logging. There will be
an additional alter index generated to restore logging attribute
after the index is create/built.
******************************************************************** -->
<xsl:if test="($FlagsNode mod 8)>=4 or
$DISABLE_ARCHIVE_LOGGING='1'">NOLOGGING </xsl:if>
<!-- if the bit is not set, do not emit anything -->
</xsl:template>
<!-- Emits terminating / with or without preceding lf -->
<xsl:template name="DoTerminator">
<xsl:param name="Text"/>
<xsl:param name="TrailingNL"/>
<xsl:if test="$SQLTERMINATOR=1">
<!-- test whether Text ends in lf; if not, insert lf before / -->
<!-- Bug 7354560: Use TRAILING_NL from XML doc if available -->
<xsl:choose>
<xsl:when test="$TrailingNL='Y'">/</xsl:when>
<xsl:when test="$TrailingNL='N'">
/</xsl:when>
<xsl:when test="substring($Text,string-length($Text),1)!=
substring(normalize-space($Text),
string-length(normalize-space($Text)),1)">/</xsl:when>
<xsl:otherwise>
/</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<!-- Processes the parse items -->
<xsl:template name="DoParse">
<xsl:param name="Verb"/>
<xsl:param name="ObjectType"/>
<xsl:param name="SchemaNode" select="''"/>
<xsl:param name="NameNode" select="''"/>
<xsl:param name="Grantee" select="''"/>
<xsl:param name="Grantor" select="''"/>
<xsl:param name="BaseObjectType" select="''"/>
<xsl:param name="BaseSchemaNode" select="''"/>
<xsl:param name="BaseNameNode" select="''"/>
<xsl:if test="$PRS_VERB=1">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>AVERB</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$Verb"/>
</xsl:if>
<xsl:if test="$PRS_OBJECT_TYPE=1">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>AOBJECT_TYPE</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$ObjectType"/>
</xsl:if>
<xsl:if test="$PRS_SCHEMA=1 and $SchemaNode != ''">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>ASCHEMA</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$SchemaNode"/>
</xsl:if>
<xsl:if test="$PRS_NAME=1 and $NameNode != ''">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>ANAME</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$NameNode"/>
</xsl:if>
<xsl:if test="$PRS_GRANTEE=1 and $Grantee != ''">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>AGRANTEE</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$Grantee"/>
</xsl:if>
<xsl:if test="$PRS_GRANTOR=1 and $Grantor != ''">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>AGRANTOR</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$Grantor"/>
</xsl:if>
<xsl:if test="$PRS_BASE_OBJECT_TYPE=1 and $BaseObjectType != ''">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>ABASE_OBJECT_TYPE</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$BaseObjectType"/>
</xsl:if>
<xsl:if test="$PRS_BASE_OBJECT_SCHEMA=1 and $BaseSchemaNode != ''">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>ABASE_OBJECT_SCHEMA</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$BaseSchemaNode"/>
</xsl:if>
<xsl:if test="$PRS_BASE_OBJECT_NAME=1 and $BaseNameNode != ''">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>ABASE_OBJECT_NAME</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>B</xsl:text>
<xsl:value-of select="$BaseNameNode"/>
</xsl:if>
<xsl:if test="$PRS_DDL=1">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>C</xsl:text>
</xsl:if>
</xsl:template>
<!-- common code for ku$_procobj_lines
(used by kuprocoj.xsl and kuidxwrk.xsl
-->
<xsl:template match="PLSQL">
<xsl:param name="Objecttype">""</xsl:param>
<xsl:param name="Schemanode">""</xsl:param>
<xsl:param name="Namenode">""</xsl:param>
<xsl:param name="Baseschemanode">""</xsl:param>
<xsl:param name="Basenamenode">""</xsl:param>
<xsl:param name="Baseobjecttype">""</xsl:param>
<!-- Each PLSQL_ITEM is an anonymous PLSQL block -->
<xsl:for-each select="PLSQL_ITEM">
<!-- Need to remove this call. This is hard coded in here because there is
no other way to determine if the call is for the reclaim temp segment.
The casing has been this way since day 1. This is for dump files
older than . Newer dumpfile will not have this call
-->
<xsl:if test="substring(LOCS/LOCS_ITEM/LINE_OF_CODE, 2, 34) !=
'sys.dbms_plugts.reclaimTempSegment'">
<xsl:call-template name="DoParse">
<xsl:with-param name="ObjectType" select="$Objecttype"/>
<xsl:with-param name="SchemaNode" select="$Schemanode"/>
<xsl:with-param name="NameNode" select="$Namenode"/>
<xsl:with-param name="BaseSchemaNode" select="$Baseschemanode"/>
<xsl:with-param name="BaseNameNode" select="$Basenamenode"/>
<xsl:with-param name="BaseObjectType" select="$Baseobjecttype"/>
<xsl:with-param name="Grantor" select="GRANTOR"/>
</xsl:call-template>
<!-- start with BEGIN -->
<xsl:if test="$PRETTY=1">
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:text>BEGIN </xsl:text>
<!-- Each LOCS_ITEM is a line of code -->
<xsl:for-each select="LOCS/LOCS_ITEM">
<!-- NEWBLOCK = -2 means append this line to the previous one -->
<xsl:if test="NEWBLOCK!=-2">
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:value-of select="LINE_OF_CODE"/>
</xsl:for-each>
<!-- finish with COMMIT; END; -->
<xsl:if test="$PRETTY=1">
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:text>COMMIT; </xsl:text>
<xsl:if test="$PRETTY=1">
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:text>END; </xsl:text>
<xsl:text>
</xsl:text>
<xsl:if test="$SQLTERMINATOR=1">
<xsl:text>/ </xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="EscapeString">
<xsl:param name="OrigStr"/>
<xsl:param name="Leading"/>
<xsl:param name="Trailing"/>
<xsl:param name="NullVal"/>
<!-- *******************************************************************
Template: EscapeString
If a string has an apos in it, it needs 2 because of sql.
So emit the string escaping the apos characters
Parameters:
OrigString - string containing apos chars
Leading - string to precede
Trailing - string to trail
NullVal - what to put out if OrigString is null
******************************************************************** -->
<xsl:choose>
<xsl:when test="string-length($OrigStr)=0">
<xsl:value-of select="$NullVal"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="APOS">'</xsl:variable>
<xsl:value-of select="$Leading"/>
<xsl:choose>
<xsl:when test="contains($OrigStr, $APOS)">
<xsl:value-of select="substring-before($OrigStr, $APOS)"/>
<xsl:text>''</xsl:text>
<xsl:call-template name="EscapeString">
<xsl:with-param name="OrigStr" select="substring-after($OrigStr,$APOS)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$OrigStr"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$Trailing"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="SingleQuotedName">
<xsl:param name="NameNode" select="''"/>
<xsl:param name="Force" select="''"/>
<!-- *******************************************************************
Template: SingleQuotedName
Description: always enclose node value in single quotes. Used extensively
in the Triton Security support (i.e., kuts*.xsl)
Parameters:
NameNode - NAME node
Force - Always add single quotes.
******************************************************************** -->
<xsl:call-template name="EscapeString">
<xsl:with-param name="OrigStr" select="$NameNode"/>
<xsl:with-param name="Leading" select='"'"'/>
<xsl:with-param name="Trailing" select='"'"'/>
</xsl:call-template>
</xsl:template>
<xsl:template name="XSNameList">
<xsl:param name="nameList" select="''"/>
<!-- *******************************************************************
Template: XSNameList
Parameters:
nameList - list of name nodes.
******************************************************************** -->
<xsl:text>XS$NAME_LIST(</xsl:text>
<!-- loop through and collect all of the NAMEs to build in the XS$NAME_LIST.
Note: we order these to allow for consistent test logfiles.
-->
<xsl:for-each select="$nameList">
<xsl:sort order="ascending" select="NAME | XS_OBJ/NAME"/>
<xsl:variable name="Name">
<xsl:choose>
<xsl:when test="XS_OBJ/NAME">
<xsl:value-of select="XS_OBJ/NAME"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="NAME"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="Owner">
<xsl:choose>
<!-- Triton PRIVILEGES do not have owners (i.e., unlike ACLs, SECURITY_CLASSes, etc-->
<xsl:when test="XS_OBJ/OWNER_NAME and name() != 'PRIV_LIST_ITEM'">
<xsl:value-of select="XS_OBJ/OWNER_NAME"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="TSQuoteObject">
<xsl:with-param name="Schema" select="$Owner"/>
<xsl:with-param name="Object" select="$Name"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="position()=last()">
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:otherwise>, </xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="XSDateArgs">
<xsl:param name="startDate" select="''"/>
<xsl:param name="endDate" select="''"/>
<!-- *******************************************************************
Template: XSDateArgs
Description: The common Triton Security function process START/END_DATE
args. If neither are present then nothing is generated.
PL/SQL block.
Parameters:
startDate - <START_DATE>
endDate - <END_DATE>
******************************************************************** -->
<xsl:if test="$startDate">
<xsl:text>,
 </xsl:text>
<xsl:text>start_date => to_timestamp_tz(</xsl:text>
<xsl:call-template name="SingleQuotedName">
<xsl:with-param name="NameNode" select="$startDate"/>
</xsl:call-template>
<xsl:text>,
 'DD-MON-YY HH.MI.SS.FF PM TZH:TZM')</xsl:text>
</xsl:if>
<xsl:if test="$endDate">
<xsl:text>,
 </xsl:text>
<xsl:text>end_date => to_timestamp_tz(</xsl:text>
<xsl:call-template name="SingleQuotedName">
<xsl:with-param name="NameNode" select="$endDate"/>
</xsl:call-template>
<xsl:text>,
 'DD-MON-YY HH.MI.SS.FF PM TZH:TZM')</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="Editionable">
<xsl:param name="SchemaObjNode" select="''"/>
<!-- *******************************************************************
Template: Editionable - common processing for [NON]EDITIONABLE
Description: Generates the [NON]EDITIONABLE keyword if version > 12.
Parameters:
SchemaObjNode: SCHEMA_OBJ
******************************************************************** -->
<xsl:if test="$VERSION>=1200000000 and ($EXPORT=0 or $SOURCE_VERSION>=1200000000)">
<xsl:choose>
<xsl:when test="$SchemaObjNode/FLAGS mod 2097152 >= 1048576">
<xsl:text>NONEDITIONABLE </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>EDITIONABLE </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template name="DoSegInMemory">
<!-- *******************************************************************
Template: DoSegInMemory
Generate an INMEMORY clause for in memory columnar
support from DEFERRED_STG/IMCFLAG_STG or STORAGE/FLAGS
Parameters:
Root location of the DEFERRED_STG or STORAGE tree
******************************************************************** -->
<xsl:param name="Root" select="''"/>
<xsl:choose>
<xsl:when test="$Root/DEFERRED_STG">
<!-- if deferred segment creation, storage params are in DEFERRED_STG$ -->
<!-- *******************************************************************
Defined in rdbms/src/server/space/if/stgdef.h:
found in deferred_stg$.stgflags
#define STGF_IMC_ENABLED (ub4) 0x200000 /* IMC is enabled */
#define STGF_IMC_NOTENABLED (ub4) 0x400000 /* IMC not enabled */
#define STGF_IMC_FORCED (ub4) 0x800000 /* IMC has been forced */
found in deferred_stg$.stgimcflag
#define STGF_IMC_MIRRORMAP (ub2) 0x01
#define STGF_IMC_LEVEL1 (ub2) 0x02
#define STGF_IMC_PRELOAD (ub2) 0x04
#define STGF_IMC_LEVEL2 (ub2) 0x08
#define STGF_IMC_MAPBY1 (ub2) 0x10
#define STGF_IMC_MAPBY2 (ub2) 0x20
#define STGF_IMC_LEVEL3 (ub2) 0x40
#define STGF_IMC_LEVEL4 (ub2) 0x80
#define STGF_IMC_PRIORITY_NONE (ub2) 0x100 /* Priority - NONE */
#define STGF_IMC_PRIORITY_LOW (ub2) 0x200 /* Priority - LOW */
#define STGF_IMC_PRIORITY_MEDIUM (ub2) 0x400 /* Priority - MEDIUM */
#define STGF_IMC_PRIORITY_HIGH (ub2) 0x800 /* Priority - HIGH */
#define STGF_IMC_PRIORITY_CRITICAL (ub2) 0x1000 /* Priority - CRITICAL */
#define STGF_IMC_DUPLICATE1 (ub2) 0x2000 /* 1 copy */
#define STGF_IMC_DUPLICATE2 (ub2) 0x4000 /* 2 copies */
******************************************************************** -->
<xsl:variable name="IMCsegflag" select="$Root/DEFERRED_STG/IMCFLAG_STG"/>
<xsl:variable name="MirrorMap" select="$IMCsegflag mod 2"/>
<xsl:variable name="Level1" select="floor($IMCsegflag div 2) mod 2"/>
<xsl:variable name="Preload" select="floor($IMCsegflag div 4) mod 2"/>
<xsl:variable name="Level2" select="floor($IMCsegflag div 8) mod 2"/>
<xsl:variable name="MapBy1" select="floor($IMCsegflag div 16) mod 2"/>
<xsl:variable name="MapBy2" select="floor($IMCsegflag div 32) mod 2"/>
<xsl:variable name="Level34" select="floor($IMCsegflag div 64) mod 4"/>
<xsl:variable name="Priority" select="floor($Root/DEFERRED_STG/IMCFLAG_STG div 256) mod 32"/>
<!-- storage is allocated, params are in SEG$ - aka the STORAGE element. -->
<xsl:call-template name="DoInMemory">
<xsl:with-param name="InMemory">
<xsl:choose>
<xsl:when test="($Root/DEFERRED_STG/FLAGS_STG mod (2097152*2)) >=2097152">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="($Root/DEFERRED_STG/FLAGS_STG mod (4194304*2)) >= 4194304">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="Priority">
<xsl:choose>
<xsl:when test="($Root/DEFERRED_STG/IMCFLAG_STG mod (4*2)) >= 4">
<!-- above test 'PRELOAD'=1, then we decode the 5 bits of priority-->
<xsl:choose>
<xsl:when test="$Priority=1">
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:when test="$Priority=2">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="$Priority=4">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:when test="$Priority=8">
<xsl:text>4</xsl:text>
</xsl:when>
<xsl:when test="$Priority=16">
<xsl:text>6</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>5</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="Compression" select="($Level34*4)+($Level2*2)+$Level1"/>
<xsl:with-param name="Distribute" select="($MapBy2*4)+($MapBy1*2)+$MirrorMap"/>
<xsl:with-param name="Duplicate" select="floor($IMCsegflag div 8192) mod 4"/>
<xsl:with-param name="ServiceName">
<xsl:if test="$VERSION>=1202000000 and $Root/SVCFLAGS">
<xsl:choose>
<xsl:when test="$Root/SVCFLAGS=1">
<xsl:text>DEFAULT</xsl:text>
</xsl:when>
<xsl:when test="$Root/SVCFLAGS=2">
<xsl:text>NONE</xsl:text>
</xsl:when>
<xsl:when test="$Root/SVCFLAGS=3">
<xsl:text>ALL</xsl:text>
</xsl:when>
<xsl:when test="$Root/SVCFLAGS=4">
<xsl:value-of select="$Root/SVCNAME"/>
</xsl:when>
<xsl:otherwise>DEFAULT</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- *******************************************************************
defined in rdbms/src/server/space/if/ktscts.h
found in stg$.flags
#define KTSSEGM_FLAG_IMC_ENABLED ((ub8)0x1 00000000) /* Set if IMC enabled */
#define KTSSEGM_FLAG_IMC_MIRRORMAP ((ub8)0x2 00000000) /* Set for IMC MAP mode */
#define KTSSEGM_FLAG_IMC_LEVEL1 ((ub8)0x4 00000000) /* Set for IMC level bit 1 */
#define KTSSEGM_FLAG_IMC_PRELOAD ((ub8)0x8 00000000) /* Set for IMC PRELOAD */
#define KTSSEGM_FLAG_IMC_MAPBY1 ((ub8)0x10 00000000) /* IMC mapby bit 1 */
#define KTSSEGM_FLAG_IMC_MAPBY2 ((ub8)0x20 00000000) /* IMC mapby bit 2 */
#define KTSSEGM_FLAG_IMC_LEVEL2 ((ub8)0x40 00000000) /* IMC level bit 2 */
#define KTSSEGM_FLAG_IMC_LEVEL3 ((ub8)0x80 00000000) /* IMC level bit 3 */
#define KTSSEGM_FLAG_IMC_LEVEL4 ((ub8)0x100 00000000) /* IMC level bit 4 */
#define KTSSEGM_FLAG_IMC_DUPLICATE1 ((ub8)0x200 00000000) /* IMC duplicate */
#define KTSSEGM_FLAG_IMC_DUPLICATE2 ((ub8)0x400 00000000) /* IMC duplicate */
#define KTSSEGM_FLAG_IMC_PL_LOW ((ub8)0x0800 00000000) /* PriLevel:LOW */
#define KTSSEGM_FLAG_IMC_PL_MEDIUM ((ub8)0x1000 00000000) /* PriLevel:MED */
#define KTSSEGM_FLAG_IMC_PL_HIGH ((ub8)0x2000 00000000) /* PriLevel:HIGH */
#define KTSSEGM_FLAG_IMC_PL_CRITICAL ((ub8)0x3000 00000000) /* PriLevel:CRITICAL */
#define KTSSEGM_FLAG_IMC_NOTENABLED ((ub8)0x4000 00000000) /* IMC explicitly disabled */
#define KTT_IMC_FORSVC ((ub8)0x10000000 00000000) /* IMC FOR SERVICE */
Note: in version 12.2 we now fetch the upper FLAGS word separately (i.e.,into
FLAGS2 which includes all of the IMC bits). For compatibility with existing
older dumpfiles we only use FLAGS2 when present.
******************************************************************** -->
<xsl:variable name="IMCsegflag">
<xsl:choose>
<xsl:when test="$VERSION>=1202000000 and $Root/STORAGE/FLAGS2">
<xsl:value-of select="$Root/STORAGE/FLAGS2"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="floor($Root/STORAGE/FLAGS div 4294967296)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="Enabled" select="($IMCsegflag) mod 2"/>
<xsl:variable name="MirrorMap" select="floor($IMCsegflag div 2) mod 2"/>
<xsl:variable name="Level1" select="floor($IMCsegflag div 4) mod 2"/>
<xsl:variable name="Preload" select="floor($IMCsegflag div 8) mod 2"/>
<xsl:variable name="MapBy12" select="floor($IMCsegflag div 16) mod 4"/>
<xsl:variable name="Level234" select="floor($IMCsegflag div 64) mod 8"/>
<xsl:variable name="Disabled" select="floor($IMCsegflag div 16384) mod 2"/>
<!-- storage is allocated, params are in SEG$ - aka the STORAGE element. -->
<xsl:variable name="Priority" select="floor($Root/STORAGE/FLAGS div 8796093022208) mod 8"/>
<xsl:call-template name="DoInMemory">
<xsl:with-param name="InMemory">
<xsl:choose>
<xsl:when test="$Enabled = 1">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="$Disabled = 1">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="Priority">
<xsl:choose>
<xsl:when test="$Preload=1">
<xsl:value-of select="$Priority"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="Compression" select="($Level234*2)+$Level1"/>
<xsl:with-param name="Distribute" select="($MapBy12*2)+$MirrorMap"/>
<xsl:with-param name="Duplicate" select="floor($IMCsegflag div 512) mod 4"/>
<xsl:with-param name="ServiceName">
<xsl:if test="$IMCsegflag and ($IMCsegflag mod (2097152*2))>=2097152">
<xsl:choose>
<xsl:when test="$Root/SVCFLAGS=1">
<xsl:text>DEFAULT</xsl:text>
</xsl:when>
<xsl:when test="$Root/SVCFLAGS=2">
<xsl:text>NONE</xsl:text>
</xsl:when>
<xsl:when test="$Root/SVCFLAGS=3">
<xsl:text>ALL</xsl:text>
</xsl:when>
<xsl:when test="$Root/SVCFLAGS=4">
<xsl:value-of select="$Root/SVCNAME"/>
</xsl:when>
<xsl:otherwise>DEFAULT</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="EncryptAlgo">
<!-- *************************************************************************
Template:EncryptAlgo
Generates encryption and internal algorithm numbers
Parameters:
EncAlg : Encryption algorithm number
IntAlg : Internal algorithm number
*************************************************************************** -->
<xsl:param name="EncAlg">0</xsl:param>
<xsl:param name="IntAlg">0</xsl:param>
<xsl:text> ENCRYPT USING </xsl:text>
<xsl:choose>
<xsl:when test="$EncAlg='1'">'3DES168'</xsl:when>
<xsl:when test="$EncAlg='2'">'AES128'</xsl:when>
<xsl:when test="$EncAlg='3'">'AES192'</xsl:when>
<xsl:when test="$EncAlg='4'">'AES256'</xsl:when>
<xsl:when test="$EncAlg='5'">'ARIA128'</xsl:when>
<xsl:when test="$EncAlg='6'">'ARIA192'</xsl:when>
<xsl:when test="$EncAlg='7'">'ARIA256'</xsl:when>
<xsl:when test="$EncAlg='8'">'SEED128'</xsl:when>
<xsl:when test="$EncAlg='9'">'GOST256'</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="$IntAlg='1'"> 'SHA-1'</xsl:when>
<xsl:when test="$IntAlg='2'"> 'NOMAC'</xsl:when>
</xsl:choose>
</xsl:template>
<!-- **************************************************************************
Template: DoMemoptimizeSyntax -
Generates memoptimize clause
Parameters:
isMemoptRead : memoptimize for read
isMemoptWrite : memoptimize for write
**************************************************************************** -->
<xsl:template name="DoMemoptimizeSyntax">
<xsl:param name="isMemoptRead" select="false()"/>
<xsl:param name="isMemoptWrite" select="false()"/>
<xsl:if test="$VERSION>=1202000000">
<xsl:if test="$PRETTY=1 and (($CONSTRAINTS=1 and $isMemoptRead) or $isMemoptWrite)">
<xsl:text>
</xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:if test="$CONSTRAINTS=1 and $isMemoptRead">
<xsl:text>MEMOPTIMIZE FOR READ </xsl:text>
</xsl:if>
<xsl:if test="$isMemoptWrite">
<xsl:text>MEMOPTIMIZE FOR WRITE </xsl:text>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="DoCMemoryCompressSyntax">
<!-- *************************************************************************
Template:DoCMemoryCompressSyntax
Generates Syntax [NO] CELLMEMORY [MEMCOMPRESS FOR QUERY | CAPACITY]
Parameters:
isNoCMemory : NO CELLMEMORY
isCMemory : CELLMEMORY
isCMCompressQuery : CELLMEMORY MEMCOMPRESS FOR QUERY
isCMCompressCapacity : CELLMEMORY MEMCOMPRESS FOR CAPACITY
doPretty : Add the newline to the beginning?
*************************************************************************** -->
<xsl:param name="isNoCMemory" select="false()"/>
<xsl:param name="isCMemory" select="false()"/>
<xsl:param name="isCMCompressQuery" select="false()"/>
<xsl:param name="isCMCompressCapacity" select="false()"/>
<xsl:param name="doPretty" select="true()"/>
<!-- version and content check -->
<xsl:if test="$VERSION>=1202000000 and ($isNoCMemory or $isCMemory or
$isCMCompressQuery or $isCMCompressCapacity)">
<xsl:if test="$doPretty and $PRETTY=1">
<xsl:text>
</xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:if test="$isNoCMemory">
<xsl:text>NO CELLMEMORY </xsl:text>
</xsl:if>
<xsl:if test="$isCMemory or $isCMCompressQuery or $isCMCompressCapacity">
<xsl:text>CELLMEMORY</xsl:text>
<xsl:choose>
<xsl:when test="$isCMCompressQuery">
<xsl:text> MEMCOMPRESS FOR QUERY </xsl:text>
</xsl:when>
<xsl:when test="$isCMCompressCapacity">
<xsl:text> MEMCOMPRESS FOR CAPACITY </xsl:text>
</xsl:when>
</xsl:choose>
</xsl:if>
<!-- if we didn't add the newline at the top and pretty is set, add it now -->
<xsl:if test="$doPretty=false() and $PRETTY=1">
<xsl:text>
</xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="DoInMemory">
<!--*******************************************************************
Template: DoInMemory
Generate an INMEMORY clause for in memory columnar support InMemory
Parameters:
InMemory: 1 if object had 'in memory' set; 2 if NO INMEMORY
Priority: 0 = NONE, 1 = LOW, 2 = MEDIUM, 4 = HIGH, 6 = CRITICAL,
7 = no priority clause, otherwise "(unknown)"
Compression: 0 = no compression clause, 1 = NO MEMCOMPRESS, 2 = FOR DML
3 = FOR QUERY LOW, 4 = FOR QUERY HIGH,
5 = FOR CAPACITY LOW, 6 = FOR CAPACITY HIGH
Distribute: 0 = <none>, 1 = DISTRIBUTE AUTO, 3 = BY ROWID RANGE
5 = BY PARTITION, 7 = BY SUBPARTITION
Duplicate: 0 = <none>, 1 = NO DUPLICATE, 2 = DUPLICATE, 3 = DUPLICATE ALL
ServiceName: service name attribute for DISTRIBUTE clause.
********************************************************************
The DDL syntax is common, but actual metadata is stored differently for
allocted segmetns, unallocated segments, partition default,
composite partition default, template subapartitions, and tablespaces-->
<xsl:param name="InMemory" select="''"/>
<xsl:param name="Priority" select="''"/>
<xsl:param name="Compression" select="''"/>
<xsl:param name="Distribute" select="''"/>
<xsl:param name="Duplicate" select="''"/>
<xsl:param name="ServiceName" select="''"/>
<xsl:if test="$INMEMORY=1 and $VERSION>=1200000000">
<xsl:choose>
<!-- Inmemory clause is not valid for PET. Don't generate it -->
<xsl:when test=" string-length($INMEMORY_CLAUSE)>0 and
not((../../../PROPERTY mod 4294967296)>=2147483648 and ../../../PART_OBJ)">
<!--we add a <space> before and after the user supplied clause to assure identifiers are not run together-->
<xsl:text> </xsl:text>
<xsl:call-template name="SubstQuot">
<xsl:with-param name="String" select="$INMEMORY_CLAUSE"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="$InMemory=2">
<xsl:text> NO INMEMORY </xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- -->
<xsl:if test="$InMemory=1">
<xsl:if test="$PRETTY=1">
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:text> INMEMORY </xsl:text>
<xsl:choose>
<xsl:when test="$Priority=0">
<xsl:text>PRIORITY NONE </xsl:text>
</xsl:when>
<xsl:when test="$Priority=1">
<xsl:text>PRIORITY LOW </xsl:text>
</xsl:when>
<xsl:when test="$Priority=2">
<xsl:text>PRIORITY MEDIUM </xsl:text>
</xsl:when>
<xsl:when test="$Priority=4">
<xsl:text>PRIORITY HIGH </xsl:text>
</xsl:when>
<xsl:when test="$Priority=6">
<xsl:text>PRIORITY CRITICAL </xsl:text>
</xsl:when>
<xsl:when test="$Priority=7"/>
<xsl:otherwise>
<xsl:text>PRIORITY (unknown) </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$Compression=0"/>
<xsl:when test="$Compression=1">
<xsl:text>NO MEMCOMPRESS </xsl:text>
</xsl:when>
<xsl:when test="$Compression=2">
<xsl:text>MEMCOMPRESS FOR DML </xsl:text>
</xsl:when>
<xsl:when test="$Compression=3">
<xsl:text>MEMCOMPRESS FOR QUERY LOW </xsl:text>
</xsl:when>
<xsl:when test="$Compression=4">
<xsl:text>MEMCOMPRESS FOR QUERY HIGH </xsl:text>
</xsl:when>
<xsl:when test="$Compression=5">
<xsl:text>MEMCOMPRESS FOR CAPACITY LOW </xsl:text>
</xsl:when>
<xsl:when test="$Compression=6">
<xsl:text>MEMCOMPRESS FOR CAPACITY HIGH </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>(unknown) </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$PRETTY=1">
<xsl:if test="($Distribute > 0) or ($Duplicate > 0)">
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:if>
<xsl:choose>
<xsl:when test="$Distribute=0"/>
<xsl:when test="$Distribute=1">
<xsl:text> DISTRIBUTE AUTO </xsl:text>
</xsl:when>
<xsl:when test="$Distribute=3">
<xsl:text> DISTRIBUTE BY ROWID RANGE </xsl:text>
</xsl:when>
<xsl:when test="$Distribute=5">
<xsl:text> DISTRIBUTE BY PARTITION </xsl:text>
</xsl:when>
<xsl:when test="$Distribute=7">
<xsl:text> DISTRIBUTE BY SUBPARTITION </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> DISTRIBUTE (unknown) </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$VERSION>=1202000000 and (string-length($ServiceName)!=0)">
<xsl:if test="$Distribute=0"> DISTRIBUTE </xsl:if>
<xsl:text>FOR SERVICE </xsl:text>
<xsl:choose>
<xsl:when test="$ServiceName = 'NONE' or
$ServiceName = 'DEFAULT' or
$ServiceName = 'ALL'">
<xsl:value-of select="$ServiceName"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="$ServiceName"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="$Duplicate=1">
<xsl:text>NO DUPLICATE </xsl:text>
</xsl:when>
<xsl:when test="$Duplicate=2">
<xsl:text>DUPLICATE </xsl:text>
</xsl:when>
<xsl:when test="$Duplicate=3">
<xsl:text>DUPLICATE ALL </xsl:text>
</xsl:when>
<xsl:when test="$Duplicate=0"/>
</xsl:choose>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<!-- Also, generate any selective column inmemory clauses if version >12.
This is generated whether there are table level inmemory attribs or whether
the table level attribute are NO INMEMORY.
-->
<xsl:if test="$VERSION>=1200000000">
<xsl:call-template name="doIMcolset"/>
</xsl:if>
</xsl:template>
<xsl:template name="doIMcolset">
<!-- Template: doIMcolset
Description: generate selective column InMemory attributes.
Args: none
Note: expected location: parent of IM_COLSEL node.
-->
<xsl:for-each select="IM_COLSEL/IM_COLSEL_ITEM">
<xsl:sort order="ascending" select="COLUMN_NAME"/>
<xsl:variable name="Col" select="COLUMN_NAME"/>
<!-- Don't generate clauses for unused columns and
system generated nested table column -->
<xsl:if test="../../COL_LIST/COL_LIST_ITEM[NAME=$Col and (PROPERTY mod (32768*2))<32768 and
((PROPERTY mod (1024*2))<1024 and
(PROPERTY mod (32*2))<32)]">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="COMPRESSION = 'NO MEMCOMPRESS'">
<xsl:text>INMEMORY </xsl:text>
</xsl:when>
<xsl:when test="COMPRESSION != 'NO INMEMORY'">
<xsl:text>INMEMORY MEMCOMPRESS </xsl:text>
</xsl:when>
</xsl:choose>
<xsl:value-of select="COMPRESSION"/>
<xsl:text> ("</xsl:text>
<xsl:value-of select="COLUMN_NAME"/>
<xsl:text>") </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="DoSharing">
<xsl:param name="Flags" select="''"/>
<!-- Template DoSharing
Description: Utility routine to generate SHARING clause for shared objects.
This SHARING clause is applicable to APPLICATION objects or
Oracle supplied common objects can be defined to be metadata,
data, extended data linked, or none.
For datapump (EXPORT set), we don't want the sharing clause
for oracle objects - which may be exported using impcalloutreg$.
Args: flags: value of object level FLAGS field (e.g., obj$.flags)
-->
<xsl:choose>
<xsl:when test="$SHARING_CLAUSE">
<xsl:choose>
<xsl:when test="$SHARING_CLAUSE='NONE'"/>
<xsl:when test="$SHARING_CLAUSE='NO_SHARING' ">
<xsl:text>SHARING=NONE </xsl:text>
</xsl:when>
<xsl:when test="$SHARING_CLAUSE='EXTENDED_DATA' ">
<xsl:text>SHARING=EXTENDED DATA </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>SHARING=</xsl:text>
<xsl:value-of select="$SHARING_CLAUSE"/>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="($EXPORT=0) or ($Flags mod (134217728*2)) >= 134217728">
<xsl:choose>
<xsl:when test="((($Flags mod (65536*2)) >= 65536) and (($Flags mod (4294967296*2)) >= 4294967296))">
<xsl:text>SHARING=EXTENDED DATA </xsl:text>
</xsl:when>
<xsl:when test="($Flags mod (65536*2)) >= 65536">
<xsl:text>SHARING=METADATA </xsl:text>
</xsl:when>
<xsl:when test="($Flags mod (131072*2)) >= 131072">
<xsl:text>SHARING=DATA </xsl:text>
</xsl:when>
<xsl:when test="($Flags mod (134217728*2)) >= 134217728">
<xsl:text>SHARING=NONE </xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="DoCollation">
<xsl:param name="IsDefault" select="''"/>
<xsl:param name="Name" select="''"/>
<!-- Template DoCollation
Description: Utility routine to generate collation clause for objects.
Parameters:
IsDefault: Is this a default collation or collate clause
Name: The collation name from the XML
Note: changes here should probably also be made in kuscommd.xsl
-->
<!-- NOTE: BypassCollation is here to support pre 12.2.0.2 behavior in the
test system only. The value NO_NLS should only be used for testing. -->
<!-- the clause is set to the value for the column or
whatever the user specified (collation_clause != always) -->
<xsl:variable name="BypassCollation">
<xsl:choose>
<xsl:when test="$COLLATION_CLAUSE = 'NEVER'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="$COLLATION_CLAUSE = 'NO_NLS' and
$Name = 'USING_NLS_COMP'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$BypassCollation = '0'">
<xsl:variable name="CollationClause">
<xsl:choose>
<xsl:when test="$COLLATION_CLAUSE = ''">
<xsl:value-of select="$Name"/>
</xsl:when>
<xsl:when test="$COLLATION_CLAUSE != 'ALWAYS' and
$COLLATION_CLAUSE != 'NO_NLS'">
<xsl:value-of select="$COLLATION_CLAUSE"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$IsDefault = '1'">
<xsl:text> DEFAULT COLLATION </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> COLLATE </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="$CollationClause"/>
<xsl:with-param name="TrailingBlank" select="$IsDefault"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="GenExtTableLoc">
<xsl:param name="Loc" select="''"/>
<xsl:param name="FPos" select="false()"/>
<xsl:param name="LPos" select="false()"/>
<xsl:param name="IsExtPartConv" select="false()"/>
<!-- *******************************************************************
Template: GenExtTableLoc : Generates location clause
Parameters:
Loc - LOCATION node
FPos - First partition in composite partition
LPos - Last partition in composite partition
******************************************************************** -->
<xsl:choose>
<!-- Handles location clause when partition_options is merge -->
<!-- Bug 26429369: Merge location files only when external table
is partitioned -->
<xsl:when test="$PARTITIONING=0 and (PART_OBJ or SUBPARTS)">
<xsl:if test="$FPos">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:text> LOCATION</xsl:text>
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:text> ( </xsl:text>
</xsl:if>
<xsl:for-each select="$Loc">
<xsl:for-each select="EXT_LOCATION/LOCATION/LOCATION_ITEM">
<xsl:choose>
<xsl:when test="DIR">
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="DIR"/>
<xsl:with-param name="TrailingBlank">0</xsl:with-param>
</xsl:call-template>
<xsl:text>:</xsl:text>
</xsl:when>
<!-- Bug 26421152: Use partition level default directory when directory
is not available in location -->
<xsl:when test="../../DEFAULT_DIR">
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="../../DEFAULT_DIR"/>
<xsl:with-param name="TrailingBlank">0</xsl:with-param>
</xsl:call-template>
<xsl:text>:</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:call-template name="SingleQuotedName">
<xsl:with-param name="NameNode" select="NAME"/>
</xsl:call-template>
<xsl:if test="not(position()=last())">
<xsl:text>, </xsl:text>
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
<xsl:if test="not(position()=last()) or $LPos=0">
<xsl:text>, </xsl:text>
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="position()=last() and $LPos=1">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:text> )</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$Loc/LOCATION_ITEM">
<xsl:if test="position()=1">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:text> LOCATION</xsl:text>
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:text> ( </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="DIR">
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="DIR"/>
<xsl:with-param name="TrailingBlank">0</xsl:with-param>
</xsl:call-template>
<xsl:text>:</xsl:text>
</xsl:when>
<!-- Use default directory in case of departition if location directory
doesn't exists -->
<xsl:when test="$IsExtPartConv and ../../DEFAULT_DIR">
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Object" select="../../DEFAULT_DIR"/>
<xsl:with-param name="TrailingBlank">0</xsl:with-param>
</xsl:call-template>
<xsl:text>:</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:call-template name="SingleQuotedName">
<xsl:with-param name="NameNode" select="NAME"/>
</xsl:call-template>
<xsl:if test="not(position()=last())">
<xsl:text>, </xsl:text>
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="position()=last()">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:text> )</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
OHA YOOOO