MINI MINI MANI MO
<?xml version="1.0"?>
<!--
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
NAME
kualter.xsl
DESCRIPTION
XSLT stylesheet for XML => DDL conversion of ku$_constraint_t ADTs
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
jjanosik 10/11/17 - Bug 26952839: emit memoptimize for read directly
jjanosik 09/14/17 - Bug 26721864: Add Alter for memoptimize
rapayne 12/22/16 - Bug 10367670: fix base_object_type parse item
reference in call to doparse.
bwright 08/15/13 - Bug 17312600: Remove hard tabs from DP src code
dvekaria 10/05/12 - Bug 14488816 NULL returned for get_[dependent]_ddl
sdavidso 03/21/12 - lrg6829209 - change default for INDEX_BY_NAME
sdavidso 03/05/12 - bug13714302: transform param for PK constraint
index by name
sdavidso 05/06/11 - more full/transportable work
sdavidso 03/31/11 - support TRANSPORTABLE xml element
dgagne 09/24/10 - add terminator after begin null; end; if required
sdavidso 03/12/07 - bug 5900676: partitioning ref contstraint exists
sdavidso 01/30/07 - fix constraint name parse item
lbarton 11/02/05 - Bug 4715313: reformat files for use with XMLSpy
lbarton 05/11/04 - Bug 3617842: SAMPLE and PCTSPACE
lbarton 04/14/04 - Bug 3561663: fetch NOT NULL and check constr
emagrath 06/06/03 - Correct index info for constraints
htseng 01/07/03 - fix bug 2736436
lbarton 10/11/02 - new parse item: SYSTEM_GENERATED
htseng 08/02/02 - add grantee parse param
htseng 07/26/02 - add more parse params
lbarton 08/02/02 - transportable export
lbarton 06/21/02 - implement sqlterminator
lbarton 06/13/02 - define EXPORT param
dgagne 08/22/01 - Merged dgagne_add_xsl_stylesheets
dgagne 07/17/01 - creation for alter table/view add constraint
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Import required scripts -->
<xsl:import href="kucommon.xsl"/>
<xsl:import href="kucolumn.xsl"/>
<xsl:import href="kustorag.xsl"/>
<xsl:import href="kuprtobj.xsl"/>
<xsl:import href="kuidxwrk.xsl"/>
<!-- Top-level parameters -->
<xsl:param name="PRETTY">1</xsl:param>
<xsl:param name="SQLTERMINATOR">0</xsl:param>
<xsl:param name="SIZE_BYTE_KEYWORD">0</xsl:param>
<xsl:param name="SEGMENT_ATTRIBUTES">1</xsl:param>
<xsl:param name="STORAGE">1</xsl:param>
<xsl:param name="TABLESPACE">1</xsl:param>
<xsl:param name="EXPORT">0</xsl:param>
<xsl:param name="INDEX_BY_NAME" select="$EXPORT"/>
<!--TRANSPORTABLE is valid for TABLE and TABLESPACE export, not DATABASE export.-->
<xsl:param name="TRANSPORTABLE">0</xsl:param>
<xsl:param name="PCTSPACE">100</xsl:param>
<!-- params for parse -->
<xsl:param name="PRS_DDL">0</xsl:param>
<xsl:param name="PRS_DELIM">\{]`</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_NAME">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_TYPE">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_SYSTEM_GENERATED">0</xsl:param>
<xsl:param name="PRS_TABLESPACE">0</xsl:param>
<xsl:template match="CONSTRAINT_T |
REF_CONSTRAINT_T">
<xsl:if test="$PRS_SYSTEM_GENERATED=1">
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>ASYSTEM_GENERATED</xsl:text>
<xsl:value-of select="$PRS_DELIM"/>
<xsl:text>E</xsl:text>
<xsl:if test="(FLAGS mod 16)>=8">Y</xsl:if>
<xsl:value-of select="$PRS_DELIM"/>
</xsl:if>
<xsl:call-template name="DoParse">
<xsl:with-param name="Verb">ALTER</xsl:with-param>
<xsl:with-param name="ObjectType">CONSTRAINT</xsl:with-param>
<xsl:with-param name="NameNode" select="NAME"/>
<xsl:with-param name="SchemaNode" select="OWNER_NAME"/>
<xsl:with-param name="BaseSchemaNode" select="BASE_OBJ/OWNER_NAME"/>
<xsl:with-param name="BaseNameNode" select="BASE_OBJ/NAME"/>
<xsl:with-param name="BaseObjectType" select="BASE_OBJ/TYPE_NAME"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="not(FLAGS) or ((FLAGS mod 2048) < 512) or $EXPORT=0">
<xsl:text>ALTER </xsl:text>
<xsl:value-of select="BASE_OBJ/TYPE_NAME"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="BASE_OBJ"/>
<xsl:for-each select="CON0">
<xsl:text>MODIFY (</xsl:text>
<xsl:call-template name="ColNameOrAttr">
<xsl:with-param name="ColItem" select="../COL"/>
</xsl:call-template>
<xsl:call-template name="DoConstraint">
<xsl:with-param name="TAB_CONSTRAINT">1</xsl:with-param>
</xsl:call-template>
<xsl:text>)</xsl:text>
</xsl:for-each>
<xsl:for-each select="CON1 | CON2">
<xsl:text>ADD</xsl:text>
<xsl:call-template name="DoConstraint">
<xsl:with-param name="TAB_CONSTRAINT">1</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<xsl:if test="$SQLTERMINATOR=1">
<xsl:text>;</xsl:text>
<!-- Terminate the SQL statement -->
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:text>begin NULL; end;</xsl:text>
<xsl:call-template name="DoTerminator">
<xsl:with-param name="Text"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<!-- if memoptimize read is set on the base table of this constraint,
add another alter to emit it. The attribute was withheld from
the table creation because it requires the primary key
constraint which is separated in datapump to the above alter.
memoptimize cannot be added to the above alter for the same
reason, the constraint has to exist, so a second alter to add
memoptimize is below. -->
<xsl:if test="CON1/PROPERTY3 and CON1/PROPERTY3!=0 and TYPE_NUM=2">
<xsl:variable name="MemoptRead">134217728</xsl:variable>
<xsl:variable name="IsMemoptRead" select="(CON1/PROPERTY3 mod ($MemoptRead*2)>=$MemoptRead)"/>
<xsl:if test="$IsMemoptRead">
<xsl:call-template name="DoParse">
<xsl:with-param name="Verb">ALTER</xsl:with-param>
<xsl:with-param name="ObjectType">CONSTRAINT</xsl:with-param>
<xsl:with-param name="NameNode" select="NAME"/>
<xsl:with-param name="SchemaNode" select="OWNER_NAME"/>
<xsl:with-param name="BaseSchemaNode" select="BASE_OBJ/OWNER_NAME"/>
<xsl:with-param name="BaseNameNode" select="BASE_OBJ/NAME"/>
<xsl:with-param name="BaseObjectType" select="BASE_OBJ/TYPE_NAME"/>
</xsl:call-template>
<xsl:text>
 ALTER </xsl:text>
<xsl:value-of select="BASE_OBJ/TYPE_NAME"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="BASE_OBJ"/>
<xsl:text>MEMOPTIMIZE FOR READ</xsl:text>
<xsl:if test="$SQLTERMINATOR=1">
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
OHA YOOOO