You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Rick Hillegas <Ri...@Sun.COM> on 2010/01/12 22:20:20 UTC
Re: svn commit: r898123 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/
engine/org/apache/derby/impl/sql/execute/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/functionTests/tests/tool
Thanks, Mamta. I will scrub this and, while I'm in there, I'll clean up
the javadoc errors in RuntimeStatisticsParser.
Cheers,
-Rick
Mamta Satoor wrote:
> Rick, not a biggie, but I saw a javadoc error because Parameter
> "sequenceName" is documented twice for a method in CreateSequenceNode,
>
> [javadoc] C:\nightlies\main\src\opensource\java\engine\org\apache\derby\impl\sql\compile\CreateSequenceNode.java:65:
> warning - Parameter "sequenceName" is documented more than once.
> [javadoc] 1 warning
>
>
> Mamta
>
>
> On Mon, Jan 11, 2010 at 4:02 PM, <rh...@apache.org> wrote:
>
>> Author: rhillegas
>> Date: Tue Jan 12 00:02:33 2010
>> New Revision: 898123
>>
>> URL: http://svn.apache.org/viewvc?rev=898123&view=rev
>> Log:
>> DERBY-712: Add dblook support for sequences.
>>
>> Added:
>> db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Sequence.java (with props)
>> Modified:
>> db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java
>> db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
>> db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateSequenceConstantAction.java
>> db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
>> db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out
>> db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
>> db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java
>> db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java
>> db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties
>> db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java
>>
>> Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java (original)
>> +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSequenceNode.java Tue Jan 12 00:02:33 2010
>> @@ -26,14 +26,25 @@
>> import org.apache.derby.iapi.sql.compile.CompilerContext;
>> import org.apache.derby.iapi.sql.execute.ConstantAction;
>> import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
>> +import org.apache.derby.iapi.types.DataTypeDescriptor;
>> +import org.apache.derby.iapi.reference.SQLState;
>> +import org.apache.derby.iapi.types.TypeId;
>> +
>>
>> /**
>> * A CreateSequenceNode is the root of a QueryTree that
>> * represents a CREATE SEQUENCE statement.
>> */
>>
>> -public class CreateSequenceNode extends DDLStatementNode {
>> - private TableName sequenceName;
>> +public class CreateSequenceNode extends DDLStatementNode
>> +{
>> + private TableName _sequenceName;
>> + private DataTypeDescriptor _dataType;
>> + private Long _initialValue;
>> + private Long _stepValue;
>> + private Long _maxValue;
>> + private Long _minValue;
>> + private Boolean _cycle;
>>
>> public static final int SEQUENCE_ELEMENT_COUNT = 1;
>>
>> @@ -41,12 +52,35 @@
>> * Initializer for a CreateSequenceNode
>> *
>> * @param sequenceName The name of the new sequence
>> - * @throws org.apache.derby.iapi.error.StandardException
>> - * Thrown on error
>> + * @param dataType Exact numeric type of the new sequence
>> + * @param initialValue Starting value
>> + * @param stepValue Increment amount
>> + * @param maxValue Largest value returned by the sequence generator
>> + * @param minValue Smallest value returned by the sequence generator
>> + * @param cycle True if the generator should wrap around, false otherwise
>> + * @param sequenceName The name of the new sequence
>> + *
>> + * @throws org.apache.derby.iapi.error.StandardException on error
>> */
>> - public void init(Object sequenceName) throws StandardException {
>> - this.sequenceName = (TableName) sequenceName;
>> - initAndCheck(sequenceName);
>> + public void init
>> + (
>> + Object sequenceName,
>> + Object dataType,
>> + Object initialValue,
>> + Object stepValue,
>> + Object maxValue,
>> + Object minValue,
>> + Object cycle
>> + ) throws StandardException {
>> + _sequenceName = (TableName) sequenceName;
>> + initAndCheck(_sequenceName);
>> +
>> + _dataType = (DataTypeDescriptor) dataType;
>> + _initialValue = (Long) initialValue;
>> + _stepValue = (Long) stepValue;
>> + _maxValue = (Long) maxValue;
>> + _minValue = (Long) minValue;
>> + _cycle = (Boolean) cycle;
>>
>> // automcatically create the schema if it doesn't exist
>> implicitCreateSchema = true;
>> @@ -62,7 +96,7 @@
>> public String toString() {
>> if (SanityManager.DEBUG) {
>> return super.toString() +
>> - "sequenceName: " + "\n" + sequenceName + "\n";
>> + "sequenceName: " + "\n" + _sequenceName + "\n";
>> } else {
>> return "";
>> }
>> @@ -80,11 +114,19 @@
>> // this method also compiles permissions checks
>> SchemaDescriptor sd = getSchemaDescriptor();
>>
>> -// sequenceName.bind( getDataDictionary() );
>> - // set the default schema name if the user did not explicitly specify a schema
>> - if (sequenceName.getSchemaName() == null) {
>> - sequenceName.setSchemaName(sd.getSchemaName());
>> + // set the default schema name if the user did not explicitly specify a schema
>> + if (_sequenceName.getSchemaName() == null) {
>> + _sequenceName.setSchemaName(sd.getSchemaName());
>> }
>> +
>> + // Right now we only support vanilla sequences
>> + if ( (_dataType != null) && ( !_dataType.getTypeId().equals( TypeId.INTEGER_ID ) ) ) { throw unimplementedFeature(); }
>> + if ( (_initialValue != null) && ( _initialValue.longValue() != -2147483648L ) ) { throw unimplementedFeature(); }
>> + if ( (_stepValue != null) && ( _stepValue.longValue() != 1L ) ) { throw unimplementedFeature(); }
>> + if ( (_maxValue != null) && ( _maxValue.longValue() != 2147483647L ) ) { throw unimplementedFeature(); }
>> + if ( (_minValue != null) && ( _minValue.longValue() != -2147483648L ) ) { throw unimplementedFeature(); }
>> + if ( (_cycle != null) && ( _cycle != Boolean.FALSE ) ) { throw unimplementedFeature(); }
>> +
>> }
>>
>> public String statementToString() {
>> @@ -101,6 +143,13 @@
>> */
>> public ConstantAction makeConstantAction() {
>> return getGenericConstantActionFactory().
>> - getCreateSequenceConstantAction(sequenceName);
>> + getCreateSequenceConstantAction(_sequenceName);
>> + }
>> +
>> + /** Report an unimplemented feature */
>> + private StandardException unimplementedFeature()
>> + {
>> + return StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE );
>> }
>> +
>> }
>>
>> Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
>> +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Tue Jan 12 00:02:33 2010
>> @@ -2320,6 +2320,7 @@
>> | <COMMITTED: "committed">
>> | <CONCAT: "concat">
>> | <CONTAINS: "contains">
>> +| <CYCLE: "cycle">
>> | <DATA: "data">
>> | <DATE: "date">
>> | <DAY: "day">
>> @@ -2341,6 +2342,8 @@
>> | <LOCKS: "locks">
>> | <LOCKSIZE: "locksize">
>> | <LOGGED: "logged">
>> +| <MAXVALUE: "maxvalue">
>> +| <MINVALUE: "minvalue">
>> | <MOD: "mod">
>> | <MODIFIES: "modifies">
>> | <MODIFY: "modify">
>> @@ -10049,19 +10052,97 @@
>> sequenceDefinition() throws StandardException :
>> {
>> TableName qualifiedSequenceName = null;
>> + DataTypeDescriptor dtd = null;
>> + Long initialValue = null;
>> + Long stepValue = null;
>> + Long maxValue = null;
>> + Long minValue = null;
>> + Boolean cycle = Boolean.FALSE;
>> }
>> {
>> <SEQUENCE> qualifiedSequenceName = qualifiedName(Limits.MAX_IDENTIFIER_LENGTH)
>> + [ <AS> dtd = exactIntegerType() ]
>> + [ <START> <WITH> initialValue = exactIntegerObject() ]
>> + [ <INCREMENT> <BY> stepValue = exactIntegerObject() ]
>> + [
>> + ( <MAXVALUE> maxValue = exactIntegerObject() )
>> + |
>> + LOOKAHEAD( { getToken( 2 ).kind == MAXVALUE } )
>> + ( <NO> <MAXVALUE> )
>> + ]
>> + [
>> + ( <MINVALUE> minValue = exactIntegerObject() )
>> + |
>> + LOOKAHEAD( { getToken( 2 ).kind == MINVALUE } )
>> + ( <NO> <MINVALUE> )
>> + ]
>> + [ cycle = cycleClause() ]
>> {
>> checkVersion( DataDictionary.DD_VERSION_DERBY_10_6, "SEQUENCES");
>> return (StatementNode) nodeFactory.getNode(
>> C_NodeTypes.CREATE_SEQUENCE_NODE,
>> qualifiedSequenceName,
>> + dtd,
>> + initialValue,
>> + stepValue,
>> + maxValue,
>> + minValue,
>> + cycle,
>> getContextManager());
>> }
>> }
>>
>> /*
>> + * <A NAME="cycleClause">cycleClause</A>
>> + */
>> +Boolean
>> +cycleClause() throws StandardException :
>> +{
>> +}
>> +{
>> + <CYCLE>
>> + {
>> + return Boolean.TRUE;
>> + }
>> +|
>> + <NO> <CYCLE>
>> + {
>> + return Boolean.FALSE;
>> + }
>> +}
>> +
>> +/*
>> + * <A NAME="exactIntegerObject">exactNumberObject</A>
>> + */
>> +Long
>> +exactIntegerObject() throws StandardException :
>> +{
>> + long exactNumeric;
>> +}
>> +{
>> + exactNumeric = exactNumber()
>> + {
>> + return new Long( exactNumeric );
>> + }
>> +}
>> +
>> +/*
>> + * <A NAME="stepValue">stepValue</A>
>> + */
>> +Long
>> +stepValue() throws StandardException :
>> +{
>> + long stepValue;
>> +}
>> +{
>> + <INCREMENT> <BY> stepValue = exactNumber()
>> + {
>> + return new Long( stepValue );
>> + }
>> +}
>> +
>> +
>> +/*
>> * <A NAME="dropSequenceStatement">dropSequenceStatement</A>
>> */
>> StatementNode
>>
>> Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateSequenceConstantAction.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateSequenceConstantAction.java?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateSequenceConstantAction.java (original)
>> +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateSequenceConstantAction.java Tue Jan 12 00:02:33 2010
>> @@ -89,7 +89,7 @@
>>
>> seqDef = ddg.newSequenceDescriptor(schemaDescriptor,
>> dd.getUUIDFactory().createUUID(),
>> - sequenceName, DataTypeDescriptor.INTEGER_NOT_NULL, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 1, false); // is definition
>> + sequenceName, DataTypeDescriptor.INTEGER_NOT_NULL, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, 1, false); // is definition
>>
>> dd.addDescriptor(seqDef,
>> null, // parent
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out Tue Jan 12 00:02:33 2010
>> @@ -5786,6 +5786,16 @@
>> -- ----------------------------------------------
>> CREATE SCHEMA "BAR"
>> -- ----------------------------------------------
>> +-- DDL Statements for sequences
>> +-- ----------------------------------------------
>> +CREATE SEQUENCE "APP"."SEQUENCE_1"
>> + AS INTEGER
>> + START WITH -2147483648
>> + INCREMENT BY 1
>> + MAXVALUE 2147483647
>> + MINVALUE -2147483648
>> + NO CYCLE
>> +-- ----------------------------------------------
>> -- DDL Statements for jars
>> -- **** NOTE **** In order for jar files to be loaded correctly,
>> -- you must either 1) ensure that the DBJARS directory (created
>> @@ -5864,6 +5874,17 @@
>> -- ----------------------------------------------
>> CREATE SCHEMA "BAR";
>> -- ----------------------------------------------
>> +-- DDL Statements for sequences
>> +-- ----------------------------------------------
>> +CREATE SEQUENCE "APP"."SEQUENCE_1"
>> + AS INTEGER
>> + START WITH -2147483648
>> + INCREMENT BY 1
>> + MAXVALUE 2147483647
>> + MINVALUE -2147483648
>> + NO CYCLE
>> +;
>> +-- ----------------------------------------------
>> -- DDL Statements for tables
>> -- ----------------------------------------------
>> CREATE TABLE "BAR"."T1" ("C" CHAR(5) NOT NULL, "I" INTEGER, "VC" VARCHAR(10), "FKCHAR" CHAR(5));
>> @@ -5921,6 +5942,17 @@
>> -- ----------------------------------------------
>> CREATE SCHEMA "BAR" #
>> -- ----------------------------------------------
>> +-- DDL Statements for sequences
>> +-- ----------------------------------------------
>> +CREATE SEQUENCE "APP"."SEQUENCE_1"
>> + AS INTEGER
>> + START WITH -2147483648
>> + INCREMENT BY 1
>> + MAXVALUE 2147483647
>> + MINVALUE -2147483648
>> + NO CYCLE
>> + #
>> +-- ----------------------------------------------
>> -- DDL Statements for jars
>> -- **** NOTE **** In order for jar files to be loaded correctly,
>> -- you must either 1) ensure that the DBJARS directory (created
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out Tue Jan 12 00:02:33 2010
>> @@ -5786,6 +5786,16 @@
>> -- ----------------------------------------------
>> CREATE SCHEMA "BAR"
>> -- ----------------------------------------------
>> +-- DDL Statements for sequences
>> +-- ----------------------------------------------
>> +CREATE SEQUENCE "APP"."SEQUENCE_1"
>> + AS INTEGER
>> + START WITH -2147483648
>> + INCREMENT BY 1
>> + MAXVALUE 2147483647
>> + MINVALUE -2147483648
>> + NO CYCLE
>> +-- ----------------------------------------------
>> -- DDL Statements for jars
>> -- **** NOTE **** In order for jar files to be loaded correctly,
>> -- you must either 1) ensure that the DBJARS directory (created
>> @@ -5864,6 +5874,17 @@
>> -- ----------------------------------------------
>> CREATE SCHEMA "BAR";
>> -- ----------------------------------------------
>> +-- DDL Statements for sequences
>> +-- ----------------------------------------------
>> +CREATE SEQUENCE "APP"."SEQUENCE_1"
>> + AS INTEGER
>> + START WITH -2147483648
>> + INCREMENT BY 1
>> + MAXVALUE 2147483647
>> + MINVALUE -2147483648
>> + NO CYCLE
>> +;
>> +-- ----------------------------------------------
>> -- DDL Statements for tables
>> -- ----------------------------------------------
>> CREATE TABLE "BAR"."T1" ("C" CHAR(5) NOT NULL, "I" INTEGER, "VC" VARCHAR(10), "FKCHAR" CHAR(5));
>> @@ -5921,6 +5942,17 @@
>> -- ----------------------------------------------
>> CREATE SCHEMA "BAR" #
>> -- ----------------------------------------------
>> +-- DDL Statements for sequences
>> +-- ----------------------------------------------
>> +CREATE SEQUENCE "APP"."SEQUENCE_1"
>> + AS INTEGER
>> + START WITH -2147483648
>> + INCREMENT BY 1
>> + MAXVALUE 2147483647
>> + MINVALUE -2147483648
>> + NO CYCLE
>> + #
>> +-- ----------------------------------------------
>> -- DDL Statements for jars
>> -- **** NOTE **** In order for jar files to be loaded correctly,
>> -- you must either 1) ensure that the DBJARS directory (created
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql Tue Jan 12 00:02:33 2010
>> @@ -94,3 +94,9 @@
>>
>> create type price external name 'org.apache.derbyTesting.functionTests.tests.lang.Price' language java;
>>
>> +-- ----------------------------------------------
>> +-- Sequences
>> +-- ----------------------------------------------
>> +
>> +create sequence sequence_1;
>> +
>>
>> Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java (original)
>> +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java Tue Jan 12 00:02:33 2010
>> @@ -45,9 +45,10 @@
>> * functions, and UDTs in a given database and write it to
>> * output via Logs.java.
>> * @param conn Connection to the source database.
>> + * @param at10_6 True if the database is at 10.6 or higher
>> ****/
>>
>> - public static void doProceduresFunctionsAndUDTs(Connection conn)
>> + public static void doProceduresFunctionsAndUDTs(Connection conn, boolean at10_6 )
>> throws SQLException {
>>
>> // First do stored procedures.
>> @@ -65,7 +66,10 @@
>> // to interleave routine and UDT ddl.
>> //
>>
>> - generateDDL( ps, UDT_TYPE ); // UDT_TYPE => for UDTs
>> + if ( at10_6 )
>> + {
>> + generateDDL( ps, UDT_TYPE ); // UDT_TYPE => for UDTs
>> + }
>> generateDDL( ps, PROCEDURE_TYPE ); // PROCEDURE_TYPE => for PROCEDURES
>> generateDDL( ps, FUNCTION_TYPE ); // FUNCTION_TYPE => for FUNCTIONS
>>
>>
>> Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java (original)
>> +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java Tue Jan 12 00:02:33 2010
>> @@ -36,13 +36,31 @@
>> * Generate Grant & Revoke statements if sqlAuthorization is on
>> *
>> * @param conn Connection to use
>> + * @param at10_6 True if the databse level is 10.6 or higher
>> */
>> - public static void doAuthorizations(Connection conn)
>> + public static void doAuthorizations(Connection conn, boolean at10_6)
>> throws SQLException {
>>
>> // First generate table privilege statements
>> Statement stmt = conn.createStatement();
>> - ResultSet rs = stmt.executeQuery("SELECT GRANTEE, SCHEMANAME, TABLENAME, SELECTPRIV, " +
>> + ResultSet rs;
>> +
>> + if ( at10_6 )
>> + {
>> + // Generate udt privilege statements
>> + rs = stmt.executeQuery("SELECT P.GRANTEE, S.SCHEMANAME, A.ALIAS, P.PERMISSION, P.OBJECTTYPE FROM " +
>> + "SYS.SYSPERMS P, SYS.SYSALIASES A, SYS.SYSSCHEMAS S WHERE A.SCHEMAID = " +
>> + "S.SCHEMAID AND P.OBJECTID = A.ALIASID AND A.ALIASTYPE='A'");
>> + generateUDTPrivs(rs);
>> +
>> + // Generate sequence privilege statements
>> + rs = stmt.executeQuery("SELECT P.GRANTEE, S.SCHEMANAME, SEQ.SEQUENCENAME, P.PERMISSION, P.OBJECTTYPE FROM " +
>> + "SYS.SYSPERMS P, SYS.SYSSEQUENCES SEQ, SYS.SYSSCHEMAS S WHERE SEQ.SCHEMAID = " +
>> + "S.SCHEMAID AND P.OBJECTID = SEQ.SEQUENCEID");
>> + generateSequencePrivs(rs);
>> + }
>> +
>> + rs = stmt.executeQuery("SELECT GRANTEE, SCHEMANAME, TABLENAME, SELECTPRIV, " +
>> "DELETEPRIV, INSERTPRIV, UPDATEPRIV, REFERENCESPRIV, TRIGGERPRIV FROM " +
>> "SYS.SYSTABLEPERMS P, SYS.SYSTABLES T, SYS.SYSSCHEMAS S WHERE T.SCHEMAID = " +
>> "S.SCHEMAID AND T.TABLEID = P.TABLEID");
>> @@ -54,12 +72,6 @@
>> "S.SCHEMAID AND T.TABLEID = P.TABLEID");
>> generateColumnPrivs(rs, conn);
>>
>> - // Generate udt privilege statements
>> - rs = stmt.executeQuery("SELECT P.GRANTEE, S.SCHEMANAME, A.ALIAS, P.PERMISSION, P.OBJECTTYPE FROM " +
>> - "SYS.SYSPERMS P, SYS.SYSALIASES A, SYS.SYSSCHEMAS S WHERE A.SCHEMAID = " +
>> - "S.SCHEMAID AND P.OBJECTID = A.ALIASID AND A.ALIASTYPE='A'");
>> - generateUDTPrivs(rs);
>> -
>> // Generate routine privilege statements
>> rs = stmt.executeQuery("SELECT GRANTEE, SCHEMANAME, ALIAS, ALIASTYPE FROM " +
>> "SYS.SYSROUTINEPERMS P, SYS.SYSALIASES A, SYS.SYSSCHEMAS S WHERE A.SCHEMAID = " +
>> @@ -315,6 +327,40 @@
>> firstTime = false;
>> }
>> }
>> + /** ************************************************
>> + * Generate sequence privilege statements
>> + *
>> + * @param rs ResultSet holding required information
>> + ****/
>> + public static void generateSequencePrivs(ResultSet rs) throws SQLException
>> + {
>> + boolean firstTime = true;
>> + while (rs.next()) {
>> + String authName = dblook.addQuotes
>> + (dblook.expandDoubleQuotes(rs.getString(1)));
>> + String schemaName = dblook.addQuotes
>> + (dblook.expandDoubleQuotes(rs.getString(2)));
>> + String sequenceName = dblook.addQuotes
>> + (dblook.expandDoubleQuotes(rs.getString(3)));
>> + String fullName = schemaName + "." + sequenceName;
>> + String permission = rs.getString(4);
>> + String objectType = rs.getString(5);
>> +
>> + if (dblook.isIgnorableSchema(schemaName))
>> + continue;
>> +
>> + if (firstTime) {
>> + Logs.reportString("----------------------------------------------");
>> + Logs.reportMessage("DBLOOK_SequencePrivHeader");
>> + Logs.reportString("----------------------------------------------\n");
>> + }
>> +
>> + Logs.writeToNewDDL(genericPrivStatement(fullName, authName, permission, objectType ));
>> + Logs.writeStmtEndToNewDDL();
>> + Logs.writeNewlineToNewDDL();
>> + firstTime = false;
>> + }
>> + }
>> private static String genericPrivStatement(String fullName, String authName, String permission, String objectType )
>> throws SQLException
>> {
>>
>> Added: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Sequence.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Sequence.java?rev=898123&view=auto
>> ==============================================================================
>> --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Sequence.java (added)
>> +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Sequence.java Tue Jan 12 00:02:33 2010
>> @@ -0,0 +1,159 @@
>> +/*
>> +
>> + Derby - Class org.apache.derby.impl.tools.dblook.DB_Sequence
>> +
>> + Licensed to the Apache Software Foundation (ASF) under one or more
>> + contributor license agreements. See the NOTICE file distributed with
>> + this work for additional information regarding copyright ownership.
>> + The ASF licenses this file to you under the Apache License, Version 2.0
>> + (the "License"); you may not use this file except in compliance with
>> + the License. You may obtain a copy of the License at
>> +
>> + http://www.apache.org/licenses/LICENSE-2.0
>> +
>> + Unless required by applicable law or agreed to in writing, software
>> + distributed under the License is distributed on an "AS IS" BASIS,
>> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>> + See the License for the specific language governing permissions and
>> + limitations under the License.
>> +
>> + */
>> +
>> +package org.apache.derby.impl.tools.dblook;
>> +
>> +import java.sql.Connection;
>> +import java.sql.Statement;
>> +import java.sql.PreparedStatement;
>> +import java.sql.ResultSet;
>> +import java.sql.SQLException;
>> +import java.sql.DatabaseMetaData;
>> +
>> +import java.util.HashMap;
>> +import org.apache.derby.tools.dblook;
>> +
>> +/**
>> + * Dblook implementation for SEQUENCEs.
>> + */
>> +public class DB_Sequence
>> +{
>> + ///////////////////////////////////////////////////////////////////////////////////
>> + //
>> + // CONSTANTS
>> + //
>> + ///////////////////////////////////////////////////////////////////////////////////
>> +
>> +
>> + ///////////////////////////////////////////////////////////////////////////////////
>> + //
>> + // BEHAVIOR
>> + //
>> + ///////////////////////////////////////////////////////////////////////////////////
>> +
>> +
>> + /**
>> + * <p>
>> + * Generate the DDL for all sequences and output it via Logs.java.
>> + * </p>
>> + *
>> + * @param conn Connection to the source database.
>> + */
>> +
>> + public static void doSequences( Connection conn )
>> + throws SQLException
>> + {
>> + PreparedStatement ps = conn.prepareStatement
>> + (
>> + "SELECT SCHEMAID, SEQUENCENAME, SEQUENCEDATATYPE, STARTVALUE, MINIMUMVALUE, MAXIMUMVALUE, INCREMENT, CYCLEOPTION\n" +
>> + "FROM SYS.SYSSEQUENCES"
>> + );
>> + ResultSet rs = ps.executeQuery();
>> +
>> + boolean firstTime = true;
>> + while (rs.next())
>> + {
>> + int col = 1;
>> + String schemaName = dblook.lookupSchemaId( rs.getString( col++ ) );
>> + String sequenceName = rs.getString( col++ );
>> + String typeName = stripNotNull( rs.getString( col++ ) );
>> + long startValue = rs.getLong( col++ );
>> + long minimumValue = rs.getLong( col++ );
>> + long maximumValue = rs.getLong( col++ );
>> + long increment = rs.getLong( col++ );
>> + String cycleOption = "Y".equals( rs.getString( col++ ) ) ? "CYCLE" : "NO CYCLE";
>> +
>> + if (firstTime)
>> + {
>> + Logs.reportString("----------------------------------------------");
>> + Logs.reportMessage( "DBLOOK_SequenceHeader" );
>> + Logs.reportString("----------------------------------------------\n");
>> + }
>> +
>> + String fullName = dblook.addQuotes( dblook.expandDoubleQuotes( sequenceName ) );
>> + fullName = schemaName + "." + fullName;
>> +
>> + String creationString = createSequenceString
>> + ( fullName, typeName, startValue, minimumValue, maximumValue, increment, cycleOption );
>> + Logs.writeToNewDDL(creationString);
>> + Logs.writeStmtEndToNewDDL();
>> + Logs.writeNewlineToNewDDL();
>> + firstTime = false;
>> + }
>> +
>> + rs.close();
>> + ps.close();
>> + }
>> + /** Strip the trailing NOT NULL off of the string representation of a datatype */
>> + private static String stripNotNull( String datatypeName )
>> + {
>> + int idx = datatypeName.indexOf( "NOT" );
>> + if ( idx > 0 ) { return datatypeName.substring( 0, idx ); }
>> + else { return datatypeName; }
>> + }
>> +
>> + /**
>> + * <p>
>> + * Generate DDL for a specific sequence.
>> + * </p>
>> + *
>> + * @param fullName Fully qualified name of the sequence
>> + * @param dataTypeName Name of the datatype of the sequence
>> + * @param startValue First value to use in the range of the sequence
>> + * @param minimumValue Smallest value in the range
>> + * @param maximumValue Largest value in the range
>> + * @param increment Step size of the sequence
>> + * @param cycleOption CYCLE or NO CYCLE
>> + *
>> + * @return DDL for the current stored sequence
>> + */
>> + private static String createSequenceString
>> + (
>> + String fullName,
>> + String dataTypeName,
>> + long startValue,
>> + long minimumValue,
>> + long maximumValue,
>> + long increment,
>> + String cycleOption
>> + )
>> + throws SQLException
>> + {
>> + StringBuffer buffer = new StringBuffer();
>> +
>> + buffer.append( "CREATE SEQUENCE " + fullName + '\n' );
>> +
>> + buffer.append( " AS " + dataTypeName + '\n' );
>> +
>> + buffer.append( " START WITH " + Long.toString( startValue ) + '\n' );
>> +
>> + buffer.append( " INCREMENT BY " + Long.toString( increment ) + '\n' );
>> +
>> + buffer.append( " MAXVALUE " + Long.toString( maximumValue ) + '\n' );
>> +
>> + buffer.append( " MINVALUE " + Long.toString( minimumValue ) + '\n' );
>> +
>> + buffer.append( " " + cycleOption + '\n' );
>> +
>> + return buffer.toString();
>> + }
>> +
>> +}
>>
>> Propchange: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Sequence.java
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>>
>> Modified: db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties (original)
>> +++ db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties Tue Jan 12 00:02:33 2010
>> @@ -242,6 +242,7 @@
>> DBLOOK_ForeignHeader=foreign
>> DBLOOK_FunctionHeader=DDL Statements for functions
>> DBLOOK_SchemasHeader=DDL Statements for schemas
>> +DBLOOK_SequenceHeader=DDL Statements for sequences
>> DBLOOK_StoredProcHeader=DDL Statements for stored procedures
>> DBLOOK_SynonymHeader=DDL Statements for Synonyms
>> DBLOOK_TriggersHeader=DDL Statements for triggers
>> @@ -250,6 +251,7 @@
>> DBLOOK_TablePrivHeader=GRANT statements for tables
>> DBLOOK_ColumnPrivHeader=GRANT statements for columns
>> DBLOOK_RoutinePrivHeader=GRANT statements for routines
>> +DBLOOK_SequencePrivHeader=GRANT statements for sequences
>> DBLOOK_UDTPrivHeader=GRANT statements for user defined types
>> DBLOOK_Role_definitions_header=CREATE statements for roles
>> DBLOOK_Role_grants_header=GRANT statements for roles
>>
>> Modified: db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java?rev=898123&r1=898122&r2=898123&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java (original)
>> +++ db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java Tue Jan 12 00:02:33 2010
>> @@ -45,6 +45,7 @@
>> import org.apache.derby.impl.tools.dblook.DB_Key;
>> import org.apache.derby.impl.tools.dblook.DB_Table;
>> import org.apache.derby.impl.tools.dblook.DB_Schema;
>> +import org.apache.derby.impl.tools.dblook.DB_Sequence;
>> import org.apache.derby.impl.tools.dblook.DB_Alias;
>> import org.apache.derby.impl.tools.dblook.DB_Trigger;
>> import org.apache.derby.impl.tools.dblook.DB_View;
>> @@ -516,6 +517,8 @@
>> this.conn = DriverManager.getConnection(sourceDBUrl);
>> prepForDump();
>>
>> + boolean at10_6 = atVersion( conn, 10, 6 );
>> +
>> // Generate DDL.
>>
>> // Start with schemas, since we might need them to
>> @@ -523,10 +526,12 @@
>> DB_Schema.doSchemas(this.conn,
>> (tableList != null) && (targetSchema == null));
>>
>> + DB_Sequence.doSequences( conn );
>> +
>> if (tableList == null) {
>> // Don't do these if user just wants table-related objects.
>> DB_Jar.doJars(sourceDBName, this.conn);
>> - DB_Alias.doProceduresFunctionsAndUDTs(this.conn);
>> + DB_Alias.doProceduresFunctionsAndUDTs(this.conn, at10_6 );
>> }
>>
>> DB_Table.doTables(this.conn, tableIdToNameMap);
>> @@ -541,7 +546,7 @@
>> DB_Trigger.doTriggers(this.conn);
>>
>> DB_Roles.doRoles(this.conn);
>> - DB_GrantRevoke.doAuthorizations(this.conn);
>> + DB_GrantRevoke.doAuthorizations(this.conn, at10_6);
>>
>> // That's it; we're done.
>> if (getColNameFromNumberQuery != null)
>> @@ -1155,5 +1160,37 @@
>>
>> }
>>
>> + /**
>> + * Return true if we are at 10.6 or later.
>> + */
>> + private static boolean atVersion( Connection conn, int major, int minor ) throws SQLException
>> + {
>> + PreparedStatement ps = null;
>> + ResultSet rs = null;
>> + try {
>> + ps = conn.prepareStatement( "values syscs_util.syscs_get_database_property('DataDictionaryVersion')" );
>> + rs = ps.executeQuery();
>> +
>> + rs.next();
>> +
>> + String versionString = rs.getString( 1 );
>> + int dotIdx = versionString.indexOf( '.' );
>> + int actualMajor = Integer.parseInt( versionString.substring( 0, dotIdx ) );
>> + int actualMinor = Integer.parseInt( versionString.substring( dotIdx + 1, versionString.length() ) );
>> +
>> + if ( actualMajor > major ) { return true; }
>> + if ( actualMajor < major ) { return false; }
>> +
>> + boolean result = ( actualMinor >= minor );
>> +
>> + return result;
>> + }
>> + finally
>> + {
>> + if ( rs != null ) { rs.close(); }
>> + if ( ps != null ) { ps.close(); }
>> + }
>> + }
>> +
>> }
>>
>>
>>
>>
>>
Re: svn commit: r898123 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/impl/sql/execute/
testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/tool
Posted by Myrna van Lunteren <m....@gmail.com>.
On Tue, Jan 12, 2010 at 1:35 PM, Myrna van Lunteren
<m....@gmail.com> wrote:
> On Tue, Jan 12, 2010 at 1:20 PM, Rick Hillegas <Ri...@sun.com> wrote:
>> Thanks, Mamta. I will scrub this and, while I'm in there, I'll clean up the
>> javadoc errors in RuntimeStatisticsParser.
>>
>> Cheers,
>> -Rick
>>
>> Mamta Satoor wrote:
>>>
>>> Rick, not a biggie, but I saw a javadoc error because Parameter
>>> "sequenceName" is documented twice for a method in CreateSequenceNode,
>
> Hi Rick,
>
> Don't worry about the RuntimeStatisticsParser - I need to fix it up
> anyway because my changes caused a regression with j2ME.
>
> Myrna
>
Oh well, you already took care of it. thx.
Myrna
Re: svn commit: r898123 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/impl/sql/execute/
testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/tool
Posted by Myrna van Lunteren <m....@gmail.com>.
On Tue, Jan 12, 2010 at 1:20 PM, Rick Hillegas <Ri...@sun.com> wrote:
> Thanks, Mamta. I will scrub this and, while I'm in there, I'll clean up the
> javadoc errors in RuntimeStatisticsParser.
>
> Cheers,
> -Rick
>
> Mamta Satoor wrote:
>>
>> Rick, not a biggie, but I saw a javadoc error because Parameter
>> "sequenceName" is documented twice for a method in CreateSequenceNode,
Hi Rick,
Don't worry about the RuntimeStatisticsParser - I need to fix it up
anyway because my changes caused a regression with j2ME.
Myrna