Hi Thomas, Will this be fixed in 1.3 in the near future? I am avoiding the beta builds because I am under the impression they are less stable than 1.3.
Thanks, Gili On Saturday, August 30, 2014 7:57:14 AM UTC-4, Thomas Mueller wrote: > > Hi, > > I know what the problem is. readLong will first try to convert > 9223372036854775808 > to a long (that doesn't work), and then negate it (that would work, but > it's too late). One solution is to first negate it, and then convert to a > long. See below for a possible patch (not tested). > > > It seems any negative number causes the same problem. .. CREATE TABLE > connection (id BIGINT AUTO_INCREMENT(-1, 1) PRIMARY KEY) > > I think that's not the problem. Your statement (with -1) works for me. > > Patch (it also renames getInt to readInt): > > ### Eclipse Workspace Patch 1.0 > #P h2 > Index: src/main/org/h2/command/Parser.java > =================================================================== > --- src/main/org/h2/command/Parser.java (revision 5847) > +++ src/main/org/h2/command/Parser.java (working copy) > @@ -536,7 +536,7 @@ > private Prepared parseAnalyze() { > Analyze command = new Analyze(session); > if (readIf("SAMPLE_SIZE")) { > - command.setTop(getPositiveInt()); > + command.setTop(readPositiveInt()); > } > return command; > } > @@ -2966,15 +2966,15 @@ > return function; > } > > - private int getPositiveInt() { > - int v = getInt(); > + private int readPositiveInt() { > + int v = readInt(); > if (v < 0) { > throw DbException.getInvalidValueException("positive > integer", v); > } > return v; > } > > - private int getInt() { > + private int readInt() { > boolean minus = false; > if (currentTokenType == MINUS) { > minus = true; > @@ -2982,12 +2982,16 @@ > } else if (currentTokenType == PLUS) { > read(); > } > - if (currentTokenType != VALUE || currentValue.getType() != > Value.INT) { > + if (currentTokenType != VALUE) { > throw DbException.getSyntaxError(sqlCommand, parseIndex, > "integer"); > } > + if (minus) { > + // must do that now, otherwise Integer.MIN_VALUE wouldn't work > + currentValue = currentValue.negate(); > + } > int i = currentValue.getInt(); > read(); > - return minus ? -i : i; > + return i; > } > > private long readLong() { > @@ -2995,14 +2999,19 @@ > if (currentTokenType == MINUS) { > minus = true; > read(); > + } else if (currentTokenType == PLUS) { > + read(); > } > - if (currentTokenType != VALUE || > - (currentValue.getType() != Value.INT && > currentValue.getType() != Value.LONG)) { > + if (currentTokenType != VALUE) { > throw DbException.getSyntaxError(sqlCommand, parseIndex, > "long"); > } > + if (minus) { > + // must do that now, otherwise Long.MIN_VALUE wouldn't work > + currentValue = currentValue.negate(); > + } > long i = currentValue.getLong(); > read(); > - return minus ? -i : i; > + return i; > } > > private boolean readBooleanSetting() { > @@ -3901,7 +3910,7 @@ > column.setSequence(sequence); > } > if (readIf("SELECTIVITY")) { > - int value = getPositiveInt(); > + int value = readPositiveInt(); > column.setSelectivity(value); > } > String comment = readCommentIf(); > @@ -4005,7 +4014,7 @@ > readIf("CHAR"); > if (dataType.supportsScale) { > if (readIf(",")) { > - scale = getInt(); > + scale = readInt(); > original += ", " + scale; > } else { > // special case: TIMESTAMP(5) actually means > @@ -4027,7 +4036,7 @@ > } else if (readIf("(")) { > // Support for MySQL: INT(11), MEDIUMINT(8) and so on. > // Just ignore the precision. > - getPositiveInt(); > + readPositiveInt(); > read(")"); > } > if (readIf("FOR")) { > @@ -4532,7 +4541,7 @@ > command.setRowBased(false); > } > if (readIf("QUEUE")) { > - command.setQueueSize(getPositiveInt()); > + command.setQueueSize(readPositiveInt()); > } > command.setNoWait(readIf("NOWAIT")); > read("CALL"); > @@ -4940,7 +4949,7 @@ > } else if (readIf("NUMBERS")) { > command.setInt(Constants.ALLOW_LITERALS_NUMBERS); > } else { > - command.setInt(getPositiveInt()); > + command.setInt(readPositiveInt()); > } > return command; > } else if (readIf("DEFAULT_TABLE_TYPE")) { > @@ -4951,7 +4960,7 @@ > } else if (readIf("CACHED")) { > command.setInt(Table.TYPE_CACHED); > } else { > - command.setInt(getPositiveInt()); > + command.setInt(readPositiveInt()); > } > return command; > } else if (readIf("CREATE")) { > > > Regards, > Thomas > > > > > On Sat, Aug 30, 2014 at 1:31 PM, Steve McLeod <steve....@gmail.com > <javascript:>> wrote: > >> It is not your use of Long.MIN_VALUE that is a problem. It seems any >> negative number causes the same problem. For instance, this fails with a >> syntax exception: >> >> CREATE TABLE connection (id BIGINT AUTO_INCREMENT(-1, 1) PRIMARY KEY); >> >> >> On Saturday, 30 August 2014 08:21:54 UTC+2, Gili wrote: >>> >>> Noel, >>> >>> Both the H2 documentation and java.lang.Long.MIN_VALUE indicate that >>> -9223372036854775808 is a legal value, yet H2 rejects it. Isn't this a bug? >>> >>> Gili >>> >>> On Saturday, August 30, 2014 1:36:15 AM UTC-4, Noel Grandin wrote: >>>> >>>> Our internal implementation of sequences uses longs for everything, so >>>> you will need to use values for start/stop/cycle/increment that fit >>>> into a long value. >>>> >>>> On Fri, Aug 29, 2014 at 11:04 PM, Gili <cow...@bbs.darktech.org> >>>> wrote: >>>> > Two clarifications: >>>> > >>>> > I am using version 1.3.176. >>>> > This behavior contradicts the documentation: >>>> > http://www.h2database.com/html/datatypes.html#bigint_type >>>> > >>>> > Please also take this opportunity to clarify the difference between >>>> IDENTITY >>>> > and BIGINT in the documentation. As far as I understand it, IDENTITY >>>> is >>>> > equivalent to "BIGINT AUTO_INCREMENT PRIMARY KEY" but it's not clear >>>> if >>>> > there are any other differences. For example, the documentation reads >>>> "Used >>>> > values are never re-used, even when the transaction is rolled back" >>>> for >>>> > IDENTITY but not for BIGINT AUTO_INCREMENT so it's not clear if there >>>> is >>>> > some magic under the hood. >>>> > >>>> > Gili >>>> > >>>> > On Friday, August 29, 2014 4:53:16 PM UTC-4, Gili wrote: >>>> >> >>>> >> Hi, >>>> >> >>>> >> If I run: >>>> >> >>>> >> CREATE TABLE connection (id BIGINT >>>> >> AUTO_INCREMENT(-9223372036854775808, >>>> >>>> >> 1) PRIMARY KEY); >>>> >> >>>> >> I get: >>>> >> >>>> >> Syntax error in SQL statement "CREATE TABLE CONNECTION (ID BIGINT >>>> >> AUTO_INCREMENT(-9223372036854775808[*], 1) PRIMARY KEY)"; expected >>>> "long" >>>> >> >>>> >> I've successfully initialized all other types at their minimum >>>> values. >>>> >> BIGINT seems to be the only type that has a problem with this. >>>> >> >>>> >> Gili >>>> > >>>> > -- >>>> > You received this message because you are subscribed to the Google >>>> Groups >>>> > "H2 Database" group. >>>> > To unsubscribe from this group and stop receiving emails from it, >>>> send an >>>> > email to h2-database...@googlegroups.com. >>>> > To post to this group, send email to h2-da...@googlegroups.com. >>>> > Visit this group at http://groups.google.com/group/h2-database. >>>> > For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "H2 Database" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to h2-database...@googlegroups.com <javascript:>. >> To post to this group, send email to h2-da...@googlegroups.com >> <javascript:>. >> Visit this group at http://groups.google.com/group/h2-database. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscr...@googlegroups.com. To post to this group, send email to h2-database@googlegroups.com. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.