Skip to content

Commit ca7e6f5

Browse files
committed
Merge origin/master
2 parents 9c5f52f + 1314cd0 commit ca7e6f5

File tree

11 files changed

+175
-66
lines changed

11 files changed

+175
-66
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: https://paypal.me/wumpz

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: java
22
jdk:
3-
- openjdk7
4-
- oraclejdk8
3+
- openjdk8
4+
- openjdk11
55

66
after_success:
77
- mvn clean cobertura:cobertura coveralls:report

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.jsqlparser/jsqlparser/badge.svg)](http://maven-badges.herokuapp.com/maven-central/com.github.jsqlparser/jsqlparser)
66
[![Javadocs](https://www.javadoc.io/badge/com.github.jsqlparser/jsqlparser.svg)](https://www.javadoc.io/doc/com.github.jsqlparser/jsqlparser)
77

8-
[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=blue)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=64CCN9JJANZXA "Help this JSqlParser version using Paypal")
9-
108
[![Gitter](https://badges.gitter.im/JSQLParser/JSqlParser.svg)](https://gitter.im/JSQLParser/JSqlParser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
119
[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/JSQLParser/JSqlParser.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/JSQLParser/JSqlParser/context:java)
1210
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/JSQLParser/JSqlParser.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/JSQLParser/JSqlParser/alerts)
@@ -25,6 +23,7 @@ Please provide feedback on:
2523
* Is there any need for a Java 7 JSqlParser build, or can we move on to at least Java 8? (https://github.com/JSQLParser/JSqlParser/issues/814)
2624

2725
## News
26+
* JSqlParser uses now Java 8 at the minimum
2827
* Released version **2.1** of JSqlParser
2928
* Released version **2.0** of JSqlParser
3029
* breaking **API** change: to support chained functions attribute type was changed to **Expression**
@@ -55,15 +54,21 @@ To help JSqlParser's development you are encouraged to provide
5554
* bugreports
5655
* pull requests for new features
5756
* improvement requests
58-
* fund new features
59-
* a little donation
57+
* fund new features or sponsor JSqlParser ([**Sponsor**](https://www.paypal.me/wumpz))
6058

6159
**Please write in English, since it's the language most of the dev team knows.**
6260

6361
Also I would like to know about needed examples or documentation stuff.
6462

6563
## Extensions in the latest SNAPSHOT version 2.2
6664

65+
* allow empty double quotes
66+
* allow **year**, **month** ... as column data type for **create table**
67+
* allow **duplicate** as object name
68+
* make it JDK 11 buildable
69+
* switched to minimum JDK 8
70+
* avoid buffer copy of input data if a normal String input is used
71+
* allow **limit** and **offset** as keywords in specific places
6772
* DIV operator
6873
* improved performance for SQLCondition production
6974
* support for full text search (MATCH..AGAINST)

pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>commons-io</groupId>
3030
<artifactId>commons-io</artifactId>
31-
<version>2.4</version>
31+
<version>2.6</version>
3232
<scope>test</scope>
3333
</dependency>
3434
<dependency>
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>org.mockito</groupId>
4848
<artifactId>mockito-core</artifactId>
49-
<version>2.16.0</version>
49+
<version>2.28.2</version>
5050
<scope>test</scope>
5151
</dependency>
5252
</dependencies>
@@ -87,8 +87,8 @@
8787
<artifactId>maven-compiler-plugin</artifactId>
8888
<version>3.7.0</version>
8989
<configuration>
90-
<source>1.7</source>
91-
<target>1.7</target>
90+
<source>1.8</source>
91+
<target>1.8</target>
9292
<showWarnings>true</showWarnings>
9393
<encoding>${project.build.sourceEncoding}</encoding>
9494
</configuration>
@@ -110,7 +110,7 @@
110110
<dependency>
111111
<groupId>net.java.dev.javacc</groupId>
112112
<artifactId>javacc</artifactId>
113-
<version>7.0.3</version>
113+
<version>7.0.4</version>
114114
</dependency>
115115
</dependencies>
116116
</plugin>
@@ -353,7 +353,7 @@
353353
<plugin>
354354
<groupId>org.apache.maven.plugins</groupId>
355355
<artifactId>maven-checkstyle-plugin</artifactId>
356-
<version>2.17</version>
356+
<version>3.1.0</version>
357357
<executions>
358358
<execution>
359359
<id>verify-style</id>
@@ -366,7 +366,7 @@
366366
<configuration>
367367
<logViolationsToConsole>true</logViolationsToConsole>
368368
<includeTestSourceDirectory>true</includeTestSourceDirectory>
369-
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
369+
<sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
370370
<checkstyleRules>
371371
<module name="Checker">
372372
<module name="SuppressWarningsFilter" />
@@ -405,7 +405,7 @@
405405
<dependency>
406406
<groupId>com.puppycrawl.tools</groupId>
407407
<artifactId>checkstyle</artifactId>
408-
<version>6.19</version>
408+
<version>8.22</version>
409409
</dependency>
410410
</dependencies>
411411
</plugin>

src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class SimpleCharStream {
3333
protected boolean prevCharIsLF = false;
3434

3535
protected Provider inputStream;
36+
private boolean isStringProvider;
3637

3738
protected char[] buffer;
3839
protected int maxNextCharInd = 0;
@@ -88,7 +89,7 @@ protected void ExpandBuff(boolean wrapAround) {
8889
maxNextCharInd = bufpos -= tokenBegin;
8990
}
9091
} catch (Throwable t) {
91-
throw new Error(t.getMessage());
92+
throw new RuntimeException(t.getMessage());
9293
}
9394

9495
bufsize += 2048;
@@ -97,7 +98,7 @@ protected void ExpandBuff(boolean wrapAround) {
9798
}
9899

99100
protected void FillBuff() throws java.io.IOException {
100-
if (maxNextCharInd == available) {
101+
if (!isStringProvider && maxNextCharInd == available) {
101102
if (available == bufsize) {
102103
if (tokenBegin > 2048) {
103104
bufpos = maxNextCharInd = 0;
@@ -118,11 +119,19 @@ protected void FillBuff() throws java.io.IOException {
118119

119120
int i;
120121
try {
121-
if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) {
122-
inputStream.close();
123-
throw new java.io.IOException();
122+
if (inputStream instanceof StringProvider) {
123+
i = ((StringProvider) inputStream)._string.length();
124+
if (maxNextCharInd == i) {
125+
throw new java.io.IOException();
126+
}
127+
maxNextCharInd = i;
124128
} else {
125-
maxNextCharInd += i;
129+
if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) {
130+
inputStream.close();
131+
throw new java.io.IOException();
132+
} else {
133+
maxNextCharInd += i;
134+
}
126135
}
127136
return;
128137
} catch (java.io.IOException e) {
@@ -180,6 +189,14 @@ protected void UpdateLineColumn(char c) {
180189
bufcolumn[bufpos] = column;
181190
}
182191

192+
private char readChar(int pos) {
193+
if (this.inputStream instanceof StringProvider) {
194+
return ((StringProvider) inputStream)._string.charAt(pos);
195+
} else {
196+
return buffer[pos];
197+
}
198+
}
199+
183200
/**
184201
* Read a character.
185202
*/
@@ -192,7 +209,7 @@ public char readChar() throws java.io.IOException {
192209
}
193210

194211
totalCharsRead++;
195-
return buffer[bufpos];
212+
return readChar(bufpos);
196213
}
197214

198215
if (++bufpos >= maxNextCharInd) {
@@ -201,7 +218,7 @@ public char readChar() throws java.io.IOException {
201218

202219
totalCharsRead++;
203220

204-
char c = buffer[bufpos];
221+
char c = readChar(bufpos);
205222

206223
UpdateLineColumn(c);
207224
return c;
@@ -271,13 +288,21 @@ public void backup(int amount) {
271288
public SimpleCharStream(Provider dstream, int startline,
272289
int startcolumn, int buffersize) {
273290
inputStream = dstream;
291+
isStringProvider = dstream instanceof StringProvider;
274292
line = startline;
275293
column = startcolumn - 1;
276294

277-
available = bufsize = buffersize;
278-
buffer = new char[buffersize];
279-
bufline = new int[buffersize];
280-
bufcolumn = new int[buffersize];
295+
if (isStringProvider) {
296+
int bs = ((StringProvider) inputStream)._string.length();
297+
available = bufsize = bs;
298+
bufline = new int[bs];
299+
bufcolumn = new int[bs];
300+
} else {
301+
available = bufsize = buffersize;
302+
buffer = new char[buffersize];
303+
bufline = new int[buffersize];
304+
bufcolumn = new int[buffersize];
305+
}
281306
}
282307

283308
/**
@@ -301,14 +326,21 @@ public SimpleCharStream(Provider dstream) {
301326
public void ReInit(Provider dstream, int startline,
302327
int startcolumn, int buffersize) {
303328
inputStream = dstream;
329+
isStringProvider = dstream instanceof StringProvider;
304330
line = startline;
305331
column = startcolumn - 1;
306-
307-
if (buffer == null || buffersize != buffer.length) {
308-
available = bufsize = buffersize;
309-
buffer = new char[buffersize];
310-
bufline = new int[buffersize];
311-
bufcolumn = new int[buffersize];
332+
if (isStringProvider) {
333+
int bs = ((StringProvider) inputStream)._string.length();
334+
available = bufsize = bs;
335+
bufline = new int[bs];
336+
bufcolumn = new int[bs];
337+
} else {
338+
if (buffer == null || buffersize != buffer.length) {
339+
available = bufsize = buffersize;
340+
buffer = new char[buffersize];
341+
bufline = new int[buffersize];
342+
bufcolumn = new int[buffersize];
343+
}
312344
}
313345
prevCharIsLF = prevCharIsCR = false;
314346
tokenBegin = inBuf = maxNextCharInd = 0;
@@ -334,18 +366,29 @@ public void ReInit(Provider dstream) {
334366
* Get token literal value.
335367
*/
336368
public String GetImage() {
337-
if (bufpos >= tokenBegin) {
338-
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
369+
if (isStringProvider) {
370+
String data = ((StringProvider) inputStream)._string;
371+
if (bufpos >= tokenBegin) {
372+
return data.substring(tokenBegin, bufpos + 1);
373+
} else {
374+
return data.substring(tokenBegin, bufsize)
375+
+ data.substring(0, bufpos + 1);
376+
}
339377
} else {
340-
return new String(buffer, tokenBegin, bufsize - tokenBegin)
341-
+ new String(buffer, 0, bufpos + 1);
378+
if (bufpos >= tokenBegin) {
379+
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
380+
} else {
381+
return new String(buffer, tokenBegin, bufsize - tokenBegin)
382+
+ new String(buffer, 0, bufpos + 1);
383+
}
342384
}
343385
}
344386

345387
/**
346388
* Get the suffix.
347389
*/
348390
public char[] GetSuffix(int len) {
391+
349392
char[] ret = new char[len];
350393

351394
if ((bufpos + 1) >= len) {
@@ -385,7 +428,7 @@ public void adjustBeginLineColumn(int newLine, int newCol) {
385428
int i = 0;
386429
int j = 0;
387430
int k = 0;
388-
int nextColDiff = 0;
431+
int nextColDiff = 0;
389432
int columnDiff = 0;
390433

391434
while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) {

src/main/java/net/sf/jsqlparser/parser/StatementListener.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@
77
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
88
* #L%
99
*/
10-
/*
11-
* Copyright (C) 2019 JSQLParser.
12-
*
13-
* This library is free software; you can redistribute it and/or
14-
* modify it under the terms of the GNU Lesser General Public
15-
* License as published by the Free Software Foundation; either
16-
* version 2.1 of the License, or (at your option) any later version.
17-
*
18-
* This library is distributed in the hope that it will be useful,
19-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21-
* Lesser General Public License for more details.
22-
*
23-
* You should have received a copy of the GNU Lesser General Public
24-
* License along with this library; if not, write to the Free Software
25-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26-
* MA 02110-1301 USA
27-
*/
2810
package net.sf.jsqlparser.parser;
2911

3012
import net.sf.jsqlparser.statement.Statement;

0 commit comments

Comments
 (0)