[ https://issues.apache.org/jira/browse/PHOENIX-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14055744#comment-14055744 ]
Thomas D'Silva commented on PHOENIX-1016: ----------------------------------------- James, I have attached a patch for the master/4.0 and 3.0 branches. My implementation is consistent with how sequences work in http://msdn.microsoft.com/en-us/library/ff878091.aspx . The default for MINVALUE, MAXVALUE and CYCLE are Long.MIN_VALUE, Long.MAX_VALUE and false. The default for START WITH is Long.MIN_VALUE. This is not compatible with existing behavior since the default START WITH value is 1, and the default behavior is to cycle. I had to change the implementation of Sequence to store the CURRENT_VALUE in SYSTEM.SEQUENCE (instead of NEXT_VALUE) in order to get cycle to work correctly. This change is not compatible with existing sequences in SYSTEM.SEQUENCE. I am not sure how to handle these compatibility differences. Please let me know if I need to make changes. Thank you, Thomas > Support MINVALUE, MAXVALUE, and CYCLE options in CREATE SEQUENCE > ---------------------------------------------------------------- > > Key: PHOENIX-1016 > URL: https://issues.apache.org/jira/browse/PHOENIX-1016 > Project: Phoenix > Issue Type: Bug > Reporter: James Taylor > Assignee: Thomas D'Silva > Attachments: PHOENIX-1016.3.0.patch, PHOENIX-1016.patch > > > We currently don't support MINVALUE, MAXVALUE, and CYCLE options in CREATE > SEQUENCE, but we should. See > http://msdn.microsoft.com/en-us/library/ff878091.aspx for the syntax. > I believe MINVALUE applies if the INCREMENT is negative while MAXVALUE > applies otherwise. If the value of a sequence goes beyond MINVALUE/MAXVALUE, > then: > - if CYCLE is true, then the sequence value should start again at the START > WITH value (or the MINVALUE if specified too? Not sure about this). > - if CYCLE is false, then an exception should be thrown. > To implement this: > - make the grammar changes in PhoenixSQL.g > - add member variables for MINVALUE, MAXVALUE, and CYCLE to > CreateSequenceStatement > - add the appropriate error checking and handle bind variables for these new > options in CreateSequenceCompiler > - modify the MetaDataClient.createSequence() call by passing along these new > parameters. > - same for ConnectionQueryServices.createSequence() call > - same for Sequence.createSequence(). > - pass along these parameters as new KeyValues in the Append that constitutes > the RPC call > - act on these in the SequenceRegionObserver coprocessor as indicated above. -- This message was sent by Atlassian JIRA (v6.2#6252)