MINI MINI MANI MO
<?xml version="1.0"?>
<!--
Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
NAME
kuscomm.xsl
DESCRIPTION
Templates for common and utility functions (XML-SXML conversion)
MODIFIED MM/DD/YY
jjanosik 09/18/17 - Bug 26634972: Do not emit encryption for type 58,
121,122 and 123 columns
tbhukya 04/10/17 - Bug 25556006: Partitioned Databound Collation support
tbhukya 02/24/17 - Bug 25571994: Use memoptimize read, write
tbhukya 01/30/17 - Bug 25095866: Generate MEMOPTIMIZE clause
tbhukya 01/13/16 - Bug 25336873: encryption not valid at column level
for varray columns
rapayne 12/22/16 - Bug 22069676: fix VECTOR ENCODE col attribute
tbhukya 09/29/16 - Bug 23035574: Add EncryptAlgo template
jjanosik 09/12/16 - Bug 24387072: unconditionally add collation to SXML
tbhukya 06/09/16 - Bug 22171888: CellMemory support
rapayne 11/16/15 - bug 22165030: imc distribute for subpartition
templates.
rapayne 09/15/15 - bug 21147617: fix inMemory DISTRIBUTE FOR SERVICE
tbhukya 09/03/15 - Bug 21760912: Support new encryption algorithms
rapayne 06/06/15 - bug 21205467: fix virtual and hidden col attributes
rapayne 06/02/15 - Bug 21147617: extended inMemory DISTRIBUTE support
to include FOR SERVICE attribute.
tbhukya 06/02/15 - Bug 21184350: Generate collate after datatype
tbhukya 05/20/15 - Bug 21118229: Add collate for virtual column
bwright 04/09/15 - Bug 20755241: fix size of exttbl null bit image col
aditigu 03/03/15 - Bug 20433683: Unspecified IMC attrs should be null
tbhukya 02/25/15 - Proj 47173: Data bound collation
tbhukya 01/05/15 - Bug 20319428: Declare referred param
lbarton 06/10/14 - bug 18750140: default on null
abodge 06/10/14 - CM MODIFIED: Generate COL_NUM
rapayne 02/20/14 - bug 18155007: add INMEMORY support. Also incorporate
fix for bug 18777954 (Do not generate inmemory
properties for system generated nested table cols).
bwright 10/18/13 - Bug 17627666: Add COL_SORTKEY for consistent
column ordering with stream and exttbl metadata
lbarton 04/24/13 - bug 16716831: functional index expression as varchar
or clob
rapayne 01/17/13 - add Editionable template.
rapayne 11/21/11 - project 36780: Invisible Column support.
rapayne 11/08/11 - support ON NULL identity column qualifier
ebatbout 10/24/11 - 12781157: Unpacked opaque column support
rapayne 08/21/11 - project 36780: Identity Column support.
rapayne 06/15/10 - modify SCHEMA_OBJ template to return SUBNAME for
partition requests.
ebatbout 03/28/10 - Refine prior edit to take into account stream meta-
data version when add suffix, '.NESTED_TABLE_SETID$'
rapayne 03/20/10 - bug 9439234: Generated COL_FLAGS when a column
is referenced in a virtual column or functional
index expression.
ebatbout 09/30/09 - bug 8465341: Add support for NESTED_TABLE_SETID
element and add the suffix, '.NESTED_TABLE_SETID$'
in template, ColumnDefinition
abodge 09/21/09 - CONSOLIDATE STYLESHEETS: MAKE_DIFF_READY -> CM_MODE
ebatbout 09/15/08 - bug 6075698: add input parameter, ExternalTable, to
ColumnDefinition template. Additional info will be
written to sxml doc. for the external table case.
add support to TYPE_NUM template for STRMTABLE_T
xml document
rapayne 01/05/08 - bug 7605276: in 11.2 (i.e., with edition support)
the original owner# is now stored in obj$.spare3 -
while obj$.owner# now contains the internal adjunct
schema when editions have been enabled.
rapayne 10/12/08 - bug 7413914 - fix char_semantics for varrays and
nested tables.
rapayne 10/07/08 - bug 7438241 - fix udt generation for pls_types.
rapayne 02/12/08 - Support CHAR_SEMANTICS
- Add ParentNode to TypeName and TYPE_NUM
templates to make them more general purpose.
rapayne 02/10/08 - add SUPERTYPE_OBJ to schema_obj template
lbarton 01/24/08 - Bug 6724820: add VERSION param
lbarton 12/12/07 - bug 6682373: char semantics
abodge 01/22/07 - add ADD_TBLCOL_NUM parameter
rapayne 12/04/06 - Integrate EM specific changes
lbarton 11/20/06 - remove ENABLE VALIDATE
lbarton 09/28/06 - bugfix: named not null constraint
htseng 05/23/06 - add virtual support
lbarton 03/27/06 - move EnableDisable from kuxcnstr to here
lbarton 11/09/05 - bug 4724986: fix handling of xmlns
rapayne 11/02/05 - Bug 4715313: Reformat with XMLSpy
lbarton 08/10/05 - lbarton_mddiff
lbarton 11/01/04 - Initial version
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://xmlns.oracle.com/ku">
<!-- Top-level parameters -->
<xsl:param name="CM_MODE">0</xsl:param>
<xsl:param name="IGNORE_TBLCOL_NUM">0</xsl:param>
<xsl:param name="VERSION">9999999999</xsl:param>
<xsl:param name="LRG">0</xsl:param>
<xsl:param name="STREAMD_VERSION">2</xsl:param>
<!-- Templates -->
<xsl:template match="/">
<!-- *******************************************************************
Top level template for all objects
******************************************************************** -->
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="RESULTSET | ROWSET">
<xsl:for-each select="ROW">
<xsl:apply-templates/>
</xsl:for-each>
</xsl:template>
<xsl:template match="SCHEMA_OBJ | BASE_OBJ | SUPERTYPE_OBJ">
<xsl:param name="PartitionFlag">0</xsl:param>
<!-- *******************************************************************
Template: SCHEMA_OBJ | BASE_OBJ
This template puts out SCHEMA and NAME elements
******************************************************************** -->
<xsl:element name="SCHEMA">
<xsl:variable name="Owner">
<xsl:choose>
<xsl:when test="not(string(OWNER_NAME2))">
<xsl:value-of select="OWNER_NAME"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="OWNER_NAME2"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="$Owner"/>
</xsl:element>
<xsl:element name="NAME">
<xsl:choose>
<xsl:when test="$PartitionFlag ='1'">
<xsl:value-of select="SUBNAME"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="NAME"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<xsl:template name="SimpleColumnList">
<xsl:param name="ColListNode" select="''"/>
<!-- *******************************************************************
Template: SimpleColumnList
Parameters:
ColListNode - COL_LIST node
This template puts out a simple column_list (names only).
Assumes that NAME is a child of COL_LIST_ITEM
******************************************************************** -->
<xsl:element name="COL_LIST">
<xsl:for-each select="$ColListNode/COL_LIST_ITEM">
<xsl:element name="COL_LIST_ITEM">
<xsl:element name="NAME">
<xsl:value-of select="NAME"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template name="ColNameType">
<xsl:param name="ColListItem" select="''"/>
<!-- *******************************************************************
Template: ColNameType - put out NAME and DATATYPE
Parameters:
ColListItem - COL_LIST_ITEM
******************************************************************** -->
<xsl:call-template name="ColName">
<xsl:with-param name="ColNode" select="$ColListItem"/>
</xsl:call-template>
<xsl:call-template name="TypeName">
<xsl:with-param name="TypeNumNode" select="$ColListItem/TYPE_NUM"/>
<xsl:with-param name="ParentNode" select="$ColListItem"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="ColName">
<xsl:param name="ColNode" select="''"/>
<!-- *******************************************************************
Template: ColName - put out NAME
Parameters:
ColNode - Parent of NAME and ATTRNAME
******************************************************************** -->
<xsl:element name="NAME">
<xsl:call-template name="ColOrAttrName">
<xsl:with-param name="ColNode" select="$ColNode"/>
</xsl:call-template>
</xsl:element>
</xsl:template>
<xsl:template name="ColOrAttrName">
<xsl:param name="ColNode" select="''"/>
<!-- *******************************************************************
Template: ColOrAttrName - put out content of NAME
Parameters:
ColNode - Parent of NAME and ATTRNAME
******************************************************************** -->
<xsl:choose>
<xsl:when test="$ColNode/ATTRNAME">
<xsl:value-of select="$ColNode/ATTRNAME"/>
</xsl:when>
<xsl:when test="$ColNode/NAME='SYS_NC_ROWINFO$'">
<!-- SQL Ref Manual says to use pseudocolumn OBJECT_VALUE instead of
SYS_NC_ROWINFO$ -->
<xsl:text>OBJECT_VALUE</xsl:text>
</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="$ColNode/DEFAULT_VAL and
($ColNode/PROPERTY2 mod 32768)>=16384 and ($ColNode/PROPERTY2 mod 1073741824)>=536870912">
<xsl:value-of select="$ColNode/ORG_COLNAME"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$ColNode/NAME"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="TypeName">
<xsl:param name="TypeNumNode" select="''"/>
<xsl:param name="ParentNode" select="''"/>
<!-- *******************************************************************
Template: TypeName
This template puts out DATATYPE and type name
Parameters:
TypeNumNode - TYPE_NUM node
ParentNode - Node containing TYPEMD, PRECISION_NUM, SCALE, CHARSETFORM
******************************************************************** -->
<DATATYPE>
<xsl:choose>
<xsl:when test="$TypeNumNode='1' or $TypeNumNode='9'">
<xsl:choose>
<xsl:when test="$ParentNode/CHARSETFORM='2'">
<xsl:text>NVARCHAR2</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>VARCHAR2</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$TypeNumNode='96'">
<xsl:choose>
<xsl:when test="$ParentNode/CHARSETFORM='2'">
<xsl:text>NCHAR</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>CHAR</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$TypeNumNode='3' or
$TypeNumNode='246'">INTEGER</xsl:when>
<xsl:when test="$TypeNumNode='4' or
$TypeNumNode='21' or
$TypeNumNode='22'">FLOAT</xsl:when>
<xsl:when test="$TypeNumNode='7'">DECIMAL</xsl:when>
<xsl:when test="$TypeNumNode='2'">
<xsl:choose>
<xsl:when test="($ParentNode/PRECISION_NUM)
and not($ParentNode/SCALE)">FLOAT</xsl:when>
<xsl:otherwise>NUMBER</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$TypeNumNode='100'">BINARY_FLOAT</xsl:when>
<xsl:when test="$TypeNumNode='101'">BINARY_DOUBLE</xsl:when>
<xsl:when test="$TypeNumNode='8'">LONG</xsl:when>
<xsl:when test="$TypeNumNode='24'">LONG_RAW</xsl:when>
<xsl:when test="$TypeNumNode='23' or
$TypeNumNode='95'">RAW</xsl:when>
<xsl:when test="$TypeNumNode='12'">DATE</xsl:when>
<xsl:when test="$TypeNumNode='180'">TIMESTAMP</xsl:when>
<xsl:when test="$TypeNumNode='181'">TIMESTAMP_WITH_TIMEZONE</xsl:when>
<xsl:when test="$TypeNumNode='231'">TIMESTAMP_WITH_LOCAL_TIMEZONE</xsl:when>
<xsl:when test="$TypeNumNode='182'">INTERVAL_YEAR_TO_MONTH</xsl:when>
<xsl:when test="$TypeNumNode='183'">INTERVAL_DAY_TO_SECOND</xsl:when>
<xsl:when test="$TypeNumNode='178'">TIME</xsl:when>
<xsl:when test="$TypeNumNode='179'">TIME_WITH_TIMEZONE</xsl:when>
<xsl:when test="$TypeNumNode='113'">BLOB</xsl:when>
<xsl:when test="$TypeNumNode='112'">
<xsl:choose>
<xsl:when test="$ParentNode/CHARSETFORM='2'">
<xsl:text>NCLOB</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>CLOB</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$TypeNumNode='114'">BFILE</xsl:when>
<xsl:when test="$TypeNumNode='69'">ROWID</xsl:when>
<xsl:when test="$TypeNumNode='208'">UROWID</xsl:when>
<xsl:when test="$TypeNumNode='105'">MLSLABEL</xsl:when>
<xsl:when test="$TypeNumNode='121'">UDT</xsl:when>
<xsl:when test="$TypeNumNode='108' ">
<xsl:choose>
<xsl:when test="($ParentNode/PROPERTIES mod 65536)>=32768">
<xsl:text>REF</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>UDT</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$TypeNumNode='122'">NESTED_TABLE</xsl:when>
<xsl:when test="$TypeNumNode='123'">VARRAY</xsl:when>
<xsl:when test="$TypeNumNode='111'">REF</xsl:when>
<xsl:when test="$TypeNumNode='58'">
<xsl:choose>
<xsl:when test="$TypeNumNode/../TYPEMD/SCHEMA_OBJ/OWNER_NAME='SYS' and
$ParentNode/TYPEMD/SCHEMA_OBJ/NAME='XMLTYPE'">XMLTYPE</xsl:when>
<!-- First test is valid for table metadata and the second test is valid
for stream metadata -->
<xsl:when test="($TypeNumNode/../TYPEMD/SCHEMA_OBJ/OWNER_NAME='SYS' and
$ParentNode/TYPEMD/SCHEMA_OBJ/NAME='XMLTYPE') or
($ParentNode/TYPEMD/OWNER_NAME='SYS' and
$ParentNode/TYPEMD/NAME='XMLTYPE')">XMLTYPE</xsl:when>
<xsl:otherwise>OPAQUE</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</DATATYPE>
</xsl:template>
<xsl:template name="doColFlags">
<xsl:param name="ColList">0</xsl:param>
<xsl:param name="ColNode">0</xsl:param>
<!-- *******************************************************************
Template: doColFlags
ColList - COL_LIST
ColNode - specific COL_LIST_ITEM we are adding flags to.
******************************************************************** -->
<!-- Loop thru all of the columns and see if the current column name is
used in any virtual column expression
-->
<xsl:variable name="ColName">
<xsl:value-of select="$ColNode/NAME"/>
</xsl:variable>
<xsl:variable name="inFuncIdx" select="$ColList/COL_LIST_ITEM/PARSED_DEF/*/COLUMN_REF[COLUMN=$ColName and
(../../../PROPERTY mod 64) >= 32 and (../../../PROPERTY mod 64) >= 32]"/>
<xsl:variable name="inVirtExpr" select="$ColList/COL_LIST_ITEM/PARSED_DEF/*/COLUMN_REF[COLUMN=$ColName and
not((../../../PROPERTY mod 64) >= 32 and (../../../PROPERTY mod 64) >= 32)]"/>
<xsl:if test="count($inFuncIdx) > 0 or count($inVirtExpr) > 0">
<xsl:element name="FLAGS">
<xsl:if test="count($inFuncIdx) > 0">
<xsl:element name="FLAGS_ITEM">IN_FUNCTIONAL_INDEX</xsl:element>
</xsl:if>
<xsl:if test="count($inVirtExpr) > 0">
<xsl:element name="FLAGS_ITEM">IN_VIRTUAL_COL_EXPRESSION</xsl:element>
</xsl:if>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template name="ColumnDefinition">
<xsl:param name="ExternalTable">0</xsl:param>
<xsl:param name="Prefix">"''"</xsl:param>
<!-- *******************************************************************
Template: ColumnDefinition - Emit the column_definition
Current Node: {TABLE_T | CLUSTER_T}/COL_LIST/COL_LIST_ITEM
******************************************************************** -->
<!-- Column NAME -->
<xsl:variable name="ColName">
<xsl:value-of select="NAME"/>
</xsl:variable>
<xsl:choose>
<!-- The input parameter, ExternalTable, will be set to 1 when the transform
parameter, HIDDEN_COLUMNS, is TRUE -->
<xsl:when test="$ExternalTable=0">
<xsl:call-template name="ColName">
<xsl:with-param name="ColNode" select="."/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:element name="NAME">
<xsl:choose>
<!-- Append the suffix, '.NESTED_TABLE_SETID$'. The purpose is to create
a unique name for this column in case the document will be diff'ed
-->
<xsl:when test="((PROPERTY mod 2048)>=1024) and BASE_COL_NAME and
($STREAMD_VERSION >= 2)">
<xsl:value-of select="concat(BASE_COL_NAME,'.NESTED_TABLE_SETID$')"/>
</xsl:when>
<xsl:when test="((PROPERTY mod 2048)>=1024) and ATTRNAME and
($STREAMD_VERSION >= 2)">
<xsl:value-of select="concat(ATTRNAME,'.NESTED_TABLE_SETID$')"/>
</xsl:when>
<!-- Create unique name for unpacked opaque types -->
<xsl:when test="BASE_COL_TYPE=5">
<xsl:choose>
<xsl:when test="ATTRNAME2">
<xsl:value-of select="ATTRNAME2"/>
</xsl:when>
<xsl:when test="ATTRNAME">
<!-- Attribute name contains system generated name -->
<xsl:value-of select="ATTRNAME"/>
</xsl:when>
<xsl:otherwise>
<!-- Column must be type id col or image col -->
<xsl:choose>
<xsl:when test="TYPE_NUM=58 and SEGCOL_NUM!=0">
<xsl:value-of select="$Prefix"/>
<xsl:text>.ANYDATA_IMAGE$</xsl:text>
</xsl:when>
<xsl:when test="TYPEMD">
<xsl:value-of select="$Prefix"/>
<xsl:value-of select="TYPEMD/OWNER_NAME"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="TYPEMD/NAME"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Prefix"/>
<xsl:text>.ANYDATA_TOID$</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Attrname2 -->
<xsl:when test="ATTRNAME">
<xsl:value-of select="ATTRNAME"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="NAME"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="not($CM_MODE=0)">
<!-- Add COL_NUM needed to perform SXML Diff -->
<xsl:element name="COL_NUM">
<xsl:if test="not($IGNORE_TBLCOL_NUM=0)">
<xsl:attribute name="no_diff">1</xsl:attribute>
</xsl:if>
<xsl:value-of select="COL_NUM"/>
</xsl:element>
</xsl:if>
<!-- DATATYPE and related elements (LENGTH, PRECISION, SCALE,
TYPE_PROPERTIES -->
<xsl:apply-templates select="TYPE_NUM">
<xsl:with-param name="ParentNode" select="."/>
</xsl:apply-templates>
<!-- Generate Collate name for char, varchar2, nchar, nvarchar2
when version 12.2, higher and collname exists -->
<xsl:if test="$VERSION>=1202000000 and COLLNAME and
(TYPE_NUM=1 or TYPE_NUM=96 or
TYPE_NUM=8 or TYPE_NUM=112)">
<xsl:element name="COLLATE_NAME">
<xsl:value-of select="COLLNAME"/>
</xsl:element>
</xsl:if>
<!-- SORT -->
<xsl:if test="(PROPERTY mod 268435456)>= 134217728">
<xsl:element name="SORT"/>
</xsl:if>
<!-- INVISIBLE Column-->
<xsl:if test="(PROPERTY2 mod 8) =4">
<xsl:element name="INVISIBLE"/>
</xsl:if>
<!-- DEFAULT/VIRTUAL COLUMN -->
<xsl:if test="DEFLENGTH !=0">
<xsl:choose>
<xsl:when test="(PROPERTY mod 131072)>= 65536 and (PROPERTY mod 512)<256">
<xsl:element name="VIRTUAL">
<!--either DEFAULT_VAL or DEFAULT_VALC will be present but not both-->
<xsl:apply-templates select="DEFAULT_VAL"/>
<xsl:apply-templates select="DEFAULT_VALC"/>
</xsl:element>
<!-- Only generate HIDDEN if property flag is set and not the VIRTUAL flag as
they are mutually exclusive (read: HIDDEN+VIRTUAL=invalid ddl)
-->
<xsl:if test="(PROPERTY mod 64)>= 32 and
not((PROPERTY mod 131072)>= 65536 and (PROPERTY mod 512)<256)">
<xsl:element name="HIDDEN"/>
</xsl:if>
<xsl:if test="$VERSION>=1200000000 and EVALEDITION_NUM
and EVALEDITION_NUM > 0">
<xsl:element name="EVALUATE">
<xsl:text>CURRENT EDITION</xsl:text>
</xsl:element>
</xsl:if>
</xsl:when>
<xsl:when test="(PROPERTY2 mod 64)>=32 or
(PROPERTY2 mod 128)>=64">
<xsl:element name="IDENTITY_COLUMN">
<xsl:call-template name="doSequence">
<xsl:with-param name="seqNode" select="./IDENTITY_COL/SEQUENCE"/>
<xsl:with-param name="identityColumn" select="./IDENTITY_COL"/>
</xsl:call-template>
</xsl:element>
</xsl:when>
<xsl:when test="(PROPERTY2 mod 32)>=16 and $VERSION >= 1200000000">
<xsl:element name="DEFAULT_ON_NULL">
<!--either DEFAULT_VAL or DEFAULT_VALC will be present but not both-->
<xsl:apply-templates select="DEFAULT_VAL"/>
<xsl:apply-templates select="DEFAULT_VALC"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="DEFAULT">
<!--either DEFAULT_VAL or DEFAULT_VALC will be present but not both-->
<xsl:apply-templates select="DEFAULT_VAL"/>
<xsl:apply-templates select="DEFAULT_VALC"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<!-- NOT_NULL
CONTYPE 7: NOT NULL
11: NOT NULL on ADT type column
-->
<xsl:if test="CON/CONTYPE='7' or CON/CONTYPE='11'">
<xsl:element name="NOT_NULL">
<xsl:choose>
<xsl:when test="(CON/FLAGS mod 16) >= 8"/>
<xsl:when test="CON/NAME">
<NAME>
<xsl:value-of select="CON/NAME"/>
</NAME>
</xsl:when>
</xsl:choose>
<xsl:call-template name="EnableDisable">
<xsl:with-param name="ConNode" select="CON"/>
</xsl:call-template>
</xsl:element>
</xsl:if>
<!-- ENCRYPT, don't check for: (see kucolumn.xsl)
Type num Datatype
======== ========
58 Opaque
121 UDT
122 Nested table
123 Varray
-->
<xsl:variable name="CanEncrypt"
select="TYPE_NUM!=58 and TYPE_NUM!=121 and
TYPE_NUM!=122 and TYPE_NUM!=123"/>
<xsl:if test="(PROPERTY mod 134217728)>=67108864 and $CanEncrypt">
<xsl:element name="ENCRYPT">
<xsl:element name="USING">
<xsl:call-template name="EncryptAlgo">
<xsl:with-param name="Encalg" select="../../ENCALG"/>
<xsl:with-param name="Intalg" select="../../INTALG"/>
</xsl:call-template>
</xsl:element>
<xsl:if test="(PROPERTY mod 1073741824)>=536870912">
<xsl:element name="NOSALT"/>
</xsl:if>
</xsl:element>
</xsl:if>
<xsl:if test="$ExternalTable!=0">
<xsl:element name="SEGCOL_NUM">
<xsl:value-of select="SEGCOL_NUM"/>
</xsl:element>
<xsl:element name="INTCOL_NUM">
<xsl:value-of select="INTCOL_NUM"/>
</xsl:element>
<xsl:element name="COL_SORTKEY">
<xsl:choose>
<xsl:when test="COL_SORTKEY">
<xsl:value-of select="COL_SORTKEY"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="SEGCOL_NUM"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<!-- generate VIRTUAL element if it wasn't done previously -->
<xsl:if test="(PROPERTY mod 131072)>=65536 and not((PROPERTY mod 512)<256)">
<xsl:element name="VIRTUAL"/>
</xsl:if>
<xsl:if test="ATTRNAME or (PROPERTY mod 2048)>=1024 or BASE_COL_TYPE=5">
<xsl:element name="INTERNAL_NAME">
<xsl:value-of select="NAME"/>
</xsl:element>
<xsl:if test="((PROPERTY mod 2048)>=1024)">
<xsl:element name="NESTED_TABLE_SETID"/>
</xsl:if>
</xsl:if>
<xsl:if test="BASE_COL_TYPE=5">
<xsl:element name="UNPACKED_ANYDATA_ATTR"/>
</xsl:if>
</xsl:if>
<!-- Determine if there are any columns which are referenced in
a virtual column expression.
-->
<xsl:call-template name="doColFlags">
<xsl:with-param name="ColList" select=".."/>
<xsl:with-param name="ColNode" select="."/>
</xsl:call-template>
<!-- Determine if column is VECTOR ENCODED -->
<xsl:if test="(PROPERTY2 mod 65536)>=32768 and $VERSION>=1202000000">
<xsl:element name="VECTOR_ENCODE"/>
</xsl:if>
</xsl:template>
<xsl:template name="EncryptAlgo">
<xsl:param name="Encalg">0</xsl:param>
<xsl:param name="Intalg">0</xsl:param>
<!--
Template: ENCRYPTALGO - Encryption internal algorithm
Parameters :
Encalg - Encryption algorithm
Intalg - Internal encryption algorithm
-->
<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>
<xsl:template match="DEFAULT_VAL | DEFAULT_VALC">
<!-- *******************************************************************
Template: DEFAULT_VAL[C] - column default
******************************************************************** -->
<xsl:call-template name="Trim_string">
<xsl:with-param name="String" select="."/>
<xsl:with-param name="TrimAllWS">1</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="TYPE_NUM">
<xsl:param name="ParentNode">0</xsl:param>
<!-- *******************************************************************
Template: TYPE_NUM - Emit column datatype and related elements
Current Node: TABLE_T/COL_LIST/COL_LIST_ITEM/TYPE_NUM or
STRMTABLE_T/COL_LIST/COL_LIST_ITEM/TYPE_NUM
ParentNode = Node containing TYPEMD, LENGTH, CHARSETFORM,etc
(i.e., use to assume current node was correct)
******************************************************************** -->
<!-- first the datatype -->
<xsl:call-template name="TypeName">
<xsl:with-param name="TypeNumNode" select="."/>
<xsl:with-param name="ParentNode" select="$ParentNode"/>
</xsl:call-template>
<!-- optional LENGTH -->
<!-- CHAR, NCHAR, VARCHAR2, NVARCHAR2, null-bit image of UDT-->
<xsl:if test=".='1' or .='96' or .='9' or .='121'">
<xsl:choose>
<xsl:when test="($ParentNode/CHARSETFORM='2' or (../PROPERTY mod 16777216)>=8388608)
and $ParentNode/SPARE3">
<xsl:element name="LENGTH">
<xsl:value-of select="$ParentNode/SPARE3"/>
</xsl:element>
</xsl:when>
<xsl:when test="($ParentNode/CHARSETFORM='2' or (../PROPERTY mod 16777216)>=8388608)
and $ParentNode/CHARLENGTH">
<xsl:element name="LENGTH">
<xsl:value-of select="$ParentNode/CHARLENGTH"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$ParentNode/LENGTH">
<xsl:element name="LENGTH">
<xsl:value-of select="$ParentNode/LENGTH"/>
</xsl:element>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<!-- char semantics (CHAR and VARCHAR2 only)
Note: PROPERTIES must be checked for TYPE objects -->
<xsl:if test="($ParentNode/CHARSETFORM!='2') and
(($ParentNode/PROPERTY mod 16777216)>=8388608 or
($ParentNode/PROPERTIES mod 8192)>=4096)">
<xsl:element name="CHAR_SEMANTICS"/>
</xsl:if>
</xsl:if>
<!-- LENGTH: RAW, UROWID -->
<xsl:if test=".='23' or .='95' or .='208'">
<xsl:element name="LENGTH">
<xsl:value-of select="$ParentNode/LENGTH"/>
</xsl:element>
</xsl:if>
<!-- optional PRECISION, SCALE -->
<!-- 2: NUMBER
178: TIME
179: TIME_WITH_TIMEZONE
180: TIMESTAMP
181: TIMESTAMP_WITH_TIMEZONE
182: INTERVAL_YEAR_TO_MONTH
183: INTERVAL_DAY_TO_SECOND
231: TIMESTAMP_WITH_LOCAL_TIMEZONE
-->
<xsl:if test=".='2'
or .= '4'
or .= '7'
or .='178'
or .='179'
or .='180'
or .='181'
or .='182'
or .='183'
or .='231'">
<xsl:if test="$ParentNode/PRECISION_NUM">
<xsl:element name="PRECISION">
<xsl:value-of select="$ParentNode/PRECISION_NUM"/>
</xsl:element>
</xsl:if>
<xsl:if test="$ParentNode/SCALE">
<xsl:element name="SCALE">
<xsl:value-of select="$ParentNode/SCALE"/>
</xsl:element>
</xsl:if>
</xsl:if>
<!-- TYPE_PROPERTIES for UDTs
58: OPAQUE
121: UDT
122: NESTED_TABLE
123: VARRAY
111: REF
-->
<xsl:if test="(.='58'
or .='108'
or .='121'
or .='122'
or .='123'
or .='111')">
<xsl:element name="TYPE_PROPERTIES">
<xsl:choose>
<xsl:when test="$ParentNode/TYPEMD/SYN_NAME">
<xsl:if test="$ParentNode/TYPEMD/SYN_OWNER">
<xsl:element name="SCHEMA">
<xsl:value-of select="$ParentNode/TYPEMD/SYN_OWNER"/>
</xsl:element>
</xsl:if>
<xsl:element name="NAME">
<xsl:value-of select="$ParentNode/TYPEMD/SYN_NAME"/>
</xsl:element>
</xsl:when>
<!-- If this is a stream table document,then the type name and owner
is found under TYPEMD, and not TYPEMD/SCHEMA_OBJ
-->
<xsl:when test="$ParentNode/TYPEMD and (../../../../STRMTABLE_T)">
<xsl:element name="SCHEMA">
<xsl:value-of select="$ParentNode/TYPEMD/OWNER_NAME"/>
</xsl:element>
<xsl:element name="NAME">
<xsl:value-of select="$ParentNode/TYPEMD/NAME"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$ParentNode/TYPEMD/SCHEMA_OBJ"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template name="Trim_string">
<xsl:param name="String"/>
<xsl:param name="TrimAllWS">0</xsl:param>
<!-- *******************************************************************
Template: Trim_string - trim trailing white space, then output string
(copied from kucolumn.xsl)
Parameters: String = the string to trim
TrimAllWS = 0: only trim trailing space (default)
1: trim all trailing whitespace
TrimAllWS is designed to handle default values that are stored
in the dictionary with a trailing new-line, e.g.,
create table foo( a number default 1
);
The default value is stored as "1<NL>".
Since pretty-printing introduces a new-line before the trailing right
paren, failure to trim the new-line in the default value can cause
a blank line in the generated DDL:
CREATE TABLE "FOO" (
"A" NUMBER DEFAULT 1
);
Trimming the new-line fixes the problem in this case, but it doesn't
if the column default value includes a comment and the column is not the
last item before the right paren: in that case the comma separator
appears right after the comment, i.e., it becomes part of the comment.
(Since XSL does not allow the string "dash-dash" inside xsl comments,
in this and subsequent examples the comment string is represented "- -").
create table foo(a number default 1 - - this is a comment
, constraint bar foreign key ...
);
We would generate
CREATE TABLE "FOO" (
"A" NUMBER DEFAULT 1 - - this is a comment,
CONSTRAINT "BAR" FOREIGN KEY ...
);
The code below causes the least harm but is still not perfect, e.g.,
create table foo(a number default 1 - - this is a comment
);
still results in a blank line
CREATE TABLE "FOO" (
"A" NUMBER DEFAULT 1 - - this is a comment
);
(All this would be much easier if xsl allowed us to keep state.)
******************************************************************** -->
<xsl:choose>
<xsl:when test="$TrimAllWS=1 and contains($String,'--')=0 and
string-length(normalize-space(substring($String,string-length($String),1)))=0">
<xsl:call-template name="Trim_string">
<xsl:with-param name="String" select="substring($String,1,string-length($String)-1)"/>
<xsl:with-param name="TrimAllWS">1</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="substring($String,string-length($String),1)=' '">
<xsl:value-of select="substring($String,1,string-length($String)-1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$String"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="EnableDisable">
<xsl:param name="ConNode" select="''"/>
<!-- *******************************************************************
Template: EnableDisable - common processing for ENABLE [NOVALIDATE]
DISABLE [VALIDATE]
11/20/06: We only generate DISABLE and NOVALIDATE. ENABLE and VALIDATE
are the defaults.
Parameters:
ConNode: CON_LIST_ITEM
******************************************************************** -->
<!-- DISABLE -->
<!-- ENABLED is NULL or 0 if disabled -->
<xsl:choose>
<xsl:when test="$ConNode/ENABLED">
<xsl:if test="$ConNode/ENABLED='0'">
<xsl:element name="DISABLE"/>
</xsl:if>
</xsl:when>
<!-- ENABLED is NULL, i.e., disabled -->
<xsl:otherwise>
<xsl:element name="DISABLE"/>
</xsl:otherwise>
</xsl:choose>
<!-- NOVALIDATE -->
<xsl:choose>
<xsl:when test="$ConNode/FLAGS">
<xsl:if test="($ConNode/FLAGS mod 8) < 4">
<xsl:element name="NOVALIDATE"/>
</xsl:if>
</xsl:when>
<!-- FLAGS is NULL, i.e., novalidate -->
<xsl:otherwise>
<xsl:element name="NOVALIDATE"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="doSequence">
<xsl:param name="seqNode" select="''"/>
<xsl:param name="identityColumn" select="''"/>
<!-- *******************************************************************
Template: doSequence- generate sequence data for
sequence objects as well as identity columns
Parameters:
seqNode: <SEQUENCE>
identiyColumn - flag to indicate we are processing an identity column.
******************************************************************** -->
<xsl:element name="SCHEMA">
<xsl:value-of select="$seqNode/SCHEMA_OBJ/OWNER_NAME"/>
</xsl:element>
<xsl:if test="$identityColumn = ''">
<xsl:element name="NAME">
<xsl:value-of select="$seqNode/SCHEMA_OBJ/NAME"/>
</xsl:element>
</xsl:if>
<xsl:if test="$identityColumn != ''">
<xsl:element name="GENERATION">
<xsl:choose>
<xsl:when test="($identityColumn/PROPERTY2 mod 128) >= 64">
<xsl:text>DEFAULT</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>ALWAYS</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:if test="($identityColumn/PROPERTY2 mod 128) >= 64 and
($identityColumn/PROPERTY2 mod 32) >= 16">
<xsl:element name="ON_NULL"/>
</xsl:if>
</xsl:if>
<xsl:element name="START_WITH">
<xsl:value-of select="$seqNode/HIGHWATER"/>
</xsl:element>
<xsl:element name="INCREMENT">
<xsl:value-of select="$seqNode/INCRE"/>
</xsl:element>
<xsl:element name="MINVALUE">
<xsl:value-of select="$seqNode/MINVALUE"/>
</xsl:element>
<xsl:element name="MAXVALUE">
<xsl:value-of select="$seqNode/MAXVALUE"/>
</xsl:element>
<xsl:if test="$seqNode/CYCLE=1">
<xsl:element name="CYCLE"/>
</xsl:if>
<xsl:element name="CACHE">
<xsl:value-of select="$seqNode/CACHE"/>
</xsl:element>
<xsl:if test="$seqNode/SEQ_ORDER=1">
<xsl:element name="ORDER"/>
</xsl:if>
</xsl:template>
<xsl:template name="Editionable">
<xsl:param name="SchemaObjNode" select="''"/>
<!-- *******************************************************************
Template: Editionable - add NONEDITIONABLE node if appropriate.
Parameters:
SchemaObjNode: SCHEMA_OBJ
Note: EDITIONABLE is the sql default.
******************************************************************** -->
<xsl:if test="$VERSION>=1200000000 and
$SchemaObjNode/FLAGS mod 2097152 >= 1048576">
<xsl:element name="NONEDITIONABLE"/>
</xsl:if>
</xsl:template>
<xsl:template name="xDoSegInMemory">
<!-- *******************************************************************
Template: xDoSegInMemory
Generate an INMEMORY clause for in memory columnar
support from DEFERRED_STG/IMCFLAG_STG or STORAGE/FLAGS
Parameters:
Deferred non-zero if deferred segment creation
******************************************************************** -->
<xsl:param name="Deferred" select="''"/>
<xsl:param name="ParentNode" select="'.'"/>
<xsl:choose>
<xsl:when test="$Deferred != 0">
<!-- 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="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(DEFERRED_STG/IMCFLAG_STG div 256) mod 32"/>
<!-- storage is allocated, params are in SEG$ - aka the STORAGE element. -->
<xsl:call-template name="xDoInMemory">
<xsl:with-param name="InMemory">
<xsl:choose>
<xsl:when test="(DEFERRED_STG/FLAGS_STG mod (2097152*2)) >=2097152">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="(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="(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="SVCFLAGS">
<xsl:choose>
<xsl:when test="SVCFLAGS=1">
<xsl:text>DEFAULT</xsl:text>
</xsl:when>
<xsl:when test="SVCFLAGS=2">
<xsl:text>NONE</xsl:text>
</xsl:when>
<xsl:when test="SVCFLAGS=3">
<xsl:text>ALL</xsl:text>
</xsl:when>
<xsl:when test="SVCFLAGS=4">
<xsl:value-of select="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 $ParentNode/STORAGE/FLAGS2">
<xsl:value-of select="$ParentNode/STORAGE/FLAGS2"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="floor($ParentNode/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($ParentNode/STORAGE/FLAGS div 8796093022208) mod 8"/>
<xsl:variable name="DS_pri" select="floor($ParentNode/STORAGE/FLAGS div 549755813888) mod 8"/>
<xsl:call-template name="xDoInMemory">
<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="$ParentNode/SVCFLAGS=1">
<xsl:text>DEFAULT</xsl:text>
</xsl:when>
<xsl:when test="$ParentNode/SVCFLAGS=2">
<xsl:text>NONE</xsl:text>
</xsl:when>
<xsl:when test="$ParentNode/SVCFLAGS=3">
<xsl:text>ALL</xsl:text>
</xsl:when>
<xsl:when test="$ParentNode/SVCFLAGS=4">
<xsl:value-of select="$ParentNode/SVCNAME"/>
</xsl:when>
<xsl:otherwise>DEFAULT</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- **************************************************************************
Template: DoMemoptimizeSyntax -
Generates syntax MEMOPTIMIZE FOR READ/WRITE
Parameters:
isMemoptWrite - Memoptimize for write
isMemoptRead - Memoptimize for read
**************************************************************************** -->
<xsl:template name="DoMemoptimizeSyntax">
<xsl:param name="isMemoptRead" select="false()"/>
<xsl:param name="isMemoptWrite" select="false()"/>
<xsl:if test="$VERSION>=1202000000 and ($isMemoptRead or $isMemoptWrite)">
<xsl:if test="$isMemoptRead">
<xsl:element name="MEMOPTIMIZE_READ"/>
</xsl:if>
<xsl:if test="$isMemoptWrite">
<xsl:element name="MEMOPTIMIZE_WRITE"/>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="DoCMemoryCompressSyntax">
<!-- *************************************************************************
Template:DoCMemoryCompressSyntax
Generates Syntax CELLMEMORY [MEMCOMPRESS FOR QUERY | CAPACITY]
Parameters:
isCMemory : NO CELLMEMORY
isCMemory : CELLMEMORY
isCMCompressQuery : CELLMEMORY MEMCOMPRESS FOR QUERY
isCMCompressCapacity : CELLMEMORY MEMCOMPRESS FOR CAPACITY
*************************************************************************** -->
<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:if test="$VERSION>=1202000000">
<xsl:if test="$isNoCMemory">
<xsl:element name="NO_CELLMEMORY"/>
</xsl:if>
<xsl:if test="$isCMemory or $isCMCompressQuery or $isCMCompressCapacity">
<xsl:element name="CELLMEMORY">
<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:element>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="xDoInMemory">
<!--****x***************************************************************
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: 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 segments, 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 !=0 and $VERSION>=1200000000">
<xsl:element name="INMEMORY">
<xsl:choose>
<xsl:when test="$InMemory=2">
<xsl:element name="STATE">DISABLE</xsl:element>
</xsl:when>
<xsl:otherwise>
<!-- -->
<xsl:if test="$InMemory=1">
<xsl:element name="STATE">ENABLE</xsl:element>
<xsl:if test="$Priority!=7">
<xsl:element name="PRIORITY">
<xsl:choose>
<xsl:when test="$Priority=0">NONE</xsl:when>
<xsl:when test="$Priority=1">LOW</xsl:when>
<xsl:when test="$Priority=2">MEDIUM</xsl:when>
<xsl:when test="$Priority=4">HIGH</xsl:when>
<xsl:when test="$Priority=6">CRITICAL</xsl:when>
<xsl:otherwise>UNKNOWN</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
<xsl:if test="$Compression!=0">
<xsl:element name="COMPRESSION">
<xsl:choose>
<xsl:when test="$Compression=0"/>
<xsl:when test="$Compression=1">NONE</xsl:when>
<xsl:when test="$Compression=2">FOR DML</xsl:when>
<xsl:when test="$Compression=3">FOR QUERY LOW</xsl:when>
<xsl:when test="$Compression=4">FOR QUERY HIGH</xsl:when>
<xsl:when test="$Compression=5">FOR CAPACITY LOW</xsl:when>
<xsl:when test="$Compression=6">FOR CAPACITY HIGH</xsl:when>
<xsl:otherwise>BASIC</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
<xsl:if test="$Distribute!=0">
<xsl:element name="DISTRIBUTE">
<xsl:choose>
<xsl:when test="$Distribute=0"/>
<xsl:when test="$Distribute=1">AUTO</xsl:when>
<xsl:when test="$Distribute=3">BY ROWID RANGE</xsl:when>
<xsl:when test="$Distribute=5">BY PARTITION</xsl:when>
<xsl:when test="$Distribute=7">BY SUBPARTITION</xsl:when>
<xsl:otherwise>DISTRIBUTE (unknown)</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
<xsl:if test="$VERSION>=1202000000 and (string-length($ServiceName)!=0)">
<xsl:element name="FOR_SERVICE">
<xsl:value-of select="$ServiceName"/>
</xsl:element>
</xsl:if>
<xsl:if test="$Duplicate!=0">
<xsl:element name="DUPLICATE">
<xsl:choose>
<xsl:when test="$Duplicate=0"/>
<xsl:when test="$Duplicate=1">NO DUPLICATE</xsl:when>
<xsl:when test="$Duplicate=2">DUPLICATE</xsl:when>
<xsl:when test="$Duplicate=3">DUPLICATE ALL</xsl:when>
</xsl:choose>
</xsl:element>
</xsl:if>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<!-- Also, generate any selective column inmemory clauses-->
<xsl:if test="IM_COLSEL/IM_COLSEL_ITEM">
<xsl:element name="IM_COL_LIST">
<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:element name="IM_COL_LIST_ITEM">
<xsl:element name="COLUMN_NAME">
<xsl:value-of select="COLUMN_NAME"/>
</xsl:element>
<xsl:element name="COMPRESSION">
<xsl:value-of select="COMPRESSION"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
OHA YOOOO