694
695
assertNotNull("Found sys routine after user create", ais().getRoutine(sysName));
698
@Test(expected=UnsupportedOperationException.class)
699
public void alterSequenceName() {
700
transactionallyUnchecked(new Runnable()
704
AkibanInformationSchema ais = new AkibanInformationSchema();
705
Sequence s1 = Sequence.create(ais, SCHEMA, "s1", 1, 1, 1, 10, false);
706
schemaManager.createSequence(session(), s1);
709
transactionallyUnchecked(new Runnable()
713
AkibanInformationSchema ais = new AkibanInformationSchema();
714
Sequence s2 = Sequence.create(ais, SCHEMA, "s2", 1, 1, 1, 10, false);
715
schemaManager.alterSequence(session(), new TableName(SCHEMA, "s1"), s2);
721
public void alterSequenceParameters() {
722
final TableName name = new TableName(SCHEMA, "s");
723
transactionallyUnchecked(new Runnable()
727
AkibanInformationSchema ais = new AkibanInformationSchema();
728
Sequence s = Sequence.create(ais, name.getSchemaName(), name.getTableName(), 3, 4, 1, 10, false);
729
schemaManager.createSequence(session(), s);
732
final String origTreeName = ais().getSequence(name).getTreeName();
733
transactionallyUnchecked(new Runnable()
737
AkibanInformationSchema ais = new AkibanInformationSchema();
738
Sequence s = Sequence.create(ais, name.getSchemaName(), name.getTableName(), 5, 6, 2, 20, true);
739
schemaManager.alterSequence(session(), s.getSequenceName(), s);
742
Sequence s = ais().getSequence(name);
743
assertEquals("startsWith", 5, s.getStartsWith());
744
assertEquals("increment", 6, s.getIncrement());
745
assertEquals("minValue", 2, s.getMinValue());
746
assertEquals("maxValue", 20, s.getMaxValue());
747
assertEquals("cycle", true, s.isCycle());
748
assertEquals("Tree names different", true, !origTreeName.equals(s.getTreeName()));
752
public void alterIdentitySequence() {
753
createTable(SCHEMA, T1_NAME, "id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY");
754
final UserTable origTable = getUserTable(SCHEMA, T1_NAME);
755
final Sequence origSequence = origTable.getColumn("id").getIdentityGenerator();
756
final TableName name = origSequence.getSequenceName();
757
assertNotNull("identity sequence", origSequence);
758
transactionallyUnchecked(new Runnable()
762
AkibanInformationSchema ais = new AkibanInformationSchema();
763
Sequence s = Sequence.create(ais, name.getSchemaName(), name.getTableName(), 5, 6, 2, 20, true);
764
schemaManager.alterSequence(session(), s.getSequenceName(), s);
768
final UserTable newTable = getUserTable(SCHEMA, T1_NAME);
769
final Sequence newSequence = newTable.getColumn("id").getIdentityGenerator();
770
assertNotNull("has identity sequence after alter", newSequence);
771
assertEquals("startsWith", 5, newSequence.getStartsWith());
772
assertEquals("increment", 6, newSequence.getIncrement());
773
assertEquals("minValue", 2, newSequence.getMinValue());
774
assertEquals("maxValue", 20, newSequence.getMaxValue());
775
assertEquals("cycle", true, newSequence.isCycle());
698
780
* Assert that the given tables in the given schema has the, and only the, given tables. Also
699
781
* confirm each table exists in the AIS and has a definition.