Skip to content

Commit 59be98a

Browse files
committed
Merge remote-tracking branch 'xerial' into sync3.50.2
# Conflicts: # .github/workflows/ci.yml # Makefile.common # README.adoc # VERSION # pom.xml # src/main/resources/org/sqlite/native/FreeBSD/aarch64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/FreeBSD/x86/libsqlitejdbc.so # src/main/resources/org/sqlite/native/FreeBSD/x86_64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux-Android/aarch64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux-Android/arm/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux-Android/x86/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux-Android/x86_64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux-Musl/aarch64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux-Musl/x86/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux-Musl/x86_64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux/aarch64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux/arm/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux/armv6/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux/armv7/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux/ppc64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux/riscv64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux/x86/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Linux/x86_64/libsqlitejdbc.so # src/main/resources/org/sqlite/native/Mac/aarch64/libsqlitejdbc.dylib # src/main/resources/org/sqlite/native/Mac/x86_64/libsqlitejdbc.dylib # src/main/resources/org/sqlite/native/Windows/aarch64/sqlitejdbc.dll # src/main/resources/org/sqlite/native/Windows/armv7/sqlitejdbc.dll # src/main/resources/org/sqlite/native/Windows/x86/sqlitejdbc.dll # src/main/resources/org/sqlite/native/Windows/x86_64/sqlitejdbc.dll
2 parents 7af4d22 + 0450723 commit 59be98a

File tree

11 files changed

+116
-64
lines changed

11 files changed

+116
-64
lines changed

Makefile.common

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,28 +142,28 @@ Linux-Musl-aarch64_SQLITE_FLAGS :=
142142
Linux-Android-arm_CC := $(CROSS_PREFIX)clang
143143
Linux-Android-arm_STRIP := $(CROSS_ROOT)/bin/llvm-strip
144144
Linux-Android-arm_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -I$(CROSS_ROOT)/sysroot/usr/include -Os -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog
145-
Linux-Android-arm_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-soname,libsqlitejdbc.so
145+
Linux-Android-arm_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-z,max-page-size=16384,-soname,libsqlitejdbc.so
146146
Linux-Android-arm_LIBNAME := libsqlitejdbc.so
147147
Linux-Android-arm_SQLITE_FLAGS :=
148148

149149
Linux-Android-aarch64_CC := $(CROSS_PREFIX)clang
150150
Linux-Android-aarch64_STRIP := $(CROSS_ROOT)/bin/llvm-strip
151151
Linux-Android-aarch64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -I$(CROSS_ROOT)/sysroot/usr/include -Os -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog
152-
Linux-Android-aarch64_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-soname,libsqlitejdbc.so
152+
Linux-Android-aarch64_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-z,max-page-size=16384,-soname,libsqlitejdbc.so
153153
Linux-Android-aarch64_LIBNAME := libsqlitejdbc.so
154154
Linux-Android-aarch64_SQLITE_FLAGS :=
155155

156156
Linux-Android-x86_CC := $(CROSS_PREFIX)clang
157157
Linux-Android-x86_STRIP := $(CROSS_ROOT)/bin/llvm-strip
158158
Linux-Android-x86_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -I$(CROSS_ROOT)/sysroot/usr/include -Os -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog -msse4.2 -maes
159-
Linux-Android-x86_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-soname,libsqlitejdbc.so
159+
Linux-Android-x86_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-z,max-page-size=16384,-soname,libsqlitejdbc.so
160160
Linux-Android-x86_LIBNAME := libsqlitejdbc.so
161161
Linux-Android-x86_SQLITE_FLAGS :=
162162

163163
Linux-Android-x86_64_CC := $(CROSS_PREFIX)clang
164164
Linux-Android-x86_64_STRIP := $(CROSS_ROOT)/bin/llvm-strip
165165
Linux-Android-x86_64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -I$(CROSS_ROOT)/sysroot/usr/include -Os -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog -msse4.2 -maes
166-
Linux-Android-x86_64_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-soname,libsqlitejdbc.so
166+
Linux-Android-x86_64_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-z,max-page-size=16384,-soname,libsqlitejdbc.so
167167
Linux-Android-x86_64_LIBNAME := libsqlitejdbc.so
168168
Linux-Android-x86_64_SQLITE_FLAGS :=
169169

README.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
= SQLite JDBC Driver
2-
:project-version: 3.49.1.0
2+
:project-version: 3.50.2.0
33

44
image:https://img.shields.io/github/actions/workflow/status/willena/sqlite-jdbc-crypt/ci.yml?branch=master[GitHub Workflow Status (branch),link=https://github.com/willena/sqlite-jdbc/actions/workflows/ci.yml?query=branch%3Amaster]
5-
image:https://maven-badges.herokuapp.com/maven-central/io.github.willena/sqlite-jdbc/badge.svg[Maven Central,link=https://maven-badges.herokuapp.com/maven-central/io.github.willena/sqlite-jdbc/]
5+
image:https://img.shields.io/maven-central/v/io.github.willena/sqlite-jdbc?label=maven%20central&color=dark-green[Maven Central,link=https://central.sonatype.com/artifact/io.github.willena/sqlite-jdbc]
66
image:https://javadoc.io/badge2/io.github.willena/sqlite-jdbc/javadoc.svg[javadoc,link=https://javadoc.io/doc/io.github.willena/sqlite-jdbc]
77
image:https://img.shields.io/nexus/s/io.github.willena/sqlite-jdbc?color=blue&label=maven%20snapshot&server=https%3A%2F%2Foss.sonatype.org%2F[Sonatype Nexus (Snapshots),link=https://oss.sonatype.org/content/repositories/snapshots/io/github/willena/sqlite-jdbc/]
88

@@ -167,7 +167,7 @@ When packaging the resulting app, simply include the library in the distribution
167167

168168
== Download
169169

170-
Download from https://search.maven.org/artifact/io.github.willena/sqlite-jdbc[Maven Central] or from the https://github.com/willena/sqlite-jdbc-crypt/releases[releases] page.
170+
Download from https://central.sonatype.com/artifact/io.github.willena/sqlite-jdbc[Maven Central] or from the https://github.com/willena/sqlite-jdbc-crypt/releases[releases] page.
171171

172172
[source,xml,subs="attributes+"]
173173
----

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=3.50.1
2-
artifactVersion=3.50.1.0
3-
sqliteMCVersion=2.1.3
1+
version=3.50.2
2+
artifactVersion=3.50.2.0-SNAPSHOT
3+
sqliteMCVersion=2.2.0

pom.xml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>io.github.willena</groupId>
66
<artifactId>sqlite-jdbc</artifactId>
7-
<version>3.50.1.0</version>
7+
<version>3.50.2.0-SNAPSHOT</version>
88
<name>SQLite JDBC</name>
99
<description>SQLite JDBC library with encryption and authentication support</description>
1010
<url>https://github.com/Willena/sqlite-jdbc-crypt</url>
@@ -183,14 +183,14 @@
183183
</plugin>
184184

185185
<plugin>
186-
<groupId>org.sonatype.plugins</groupId>
187-
<artifactId>nexus-staging-maven-plugin</artifactId>
188-
<version>1.7.0</version>
186+
<groupId>org.sonatype.central</groupId>
187+
<artifactId>central-publishing-maven-plugin</artifactId>
188+
<version>0.8.0</version>
189189
<extensions>true</extensions>
190190
<configuration>
191-
<serverId>ossrh</serverId>
192-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
193-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
191+
<publishingServerId>central</publishingServerId>
192+
<autoPublish>true</autoPublish>
193+
<waitUntil>published</waitUntil>
194194
</configuration>
195195
</plugin>
196196

@@ -203,7 +203,7 @@
203203
<plugin>
204204
<groupId>org.apache.maven.plugins</groupId>
205205
<artifactId>maven-enforcer-plugin</artifactId>
206-
<version>3.5.0</version>
206+
<version>3.6.0</version>
207207
<executions>
208208
<execution>
209209
<id>enforce-maven</id>
@@ -253,19 +253,6 @@
253253
<url>https://github.com/xerial/sqlite-jdbc</url>
254254
</scm>
255255

256-
<distributionManagement>
257-
<snapshotRepository>
258-
<id>ossrh</id>
259-
<name>Sonatype Nexus Snapshots</name>
260-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
261-
</snapshotRepository>
262-
<repository>
263-
<id>ossrh</id>
264-
<name>Sonatype Release Repository</name>
265-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
266-
</repository>
267-
</distributionManagement>
268-
269256
<profiles>
270257
<profile>
271258
<id>release</id>
@@ -280,7 +267,7 @@
280267
<plugin>
281268
<groupId>org.apache.maven.plugins</groupId>
282269
<artifactId>maven-gpg-plugin</artifactId>
283-
<version>3.2.7</version>
270+
<version>3.2.8</version>
284271
<configuration>
285272
<!-- Prevent gpg from using pinentry programs -->
286273
<gpgArguments>

src/main/java/org/sqlite/jdbc3/JDBC3DatabaseMetaData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,12 @@ public boolean storesUpperCaseQuotedIdentifiers() {
438438

439439
/** @see java.sql.DatabaseMetaData#supportsAlterTableWithAddColumn() */
440440
public boolean supportsAlterTableWithAddColumn() {
441-
return false;
441+
return true;
442442
}
443443

444444
/** @see java.sql.DatabaseMetaData#supportsAlterTableWithDropColumn() */
445445
public boolean supportsAlterTableWithDropColumn() {
446-
return false;
446+
return true;
447447
}
448448

449449
/** @see java.sql.DatabaseMetaData#supportsANSI92EntryLevelSQL() */

src/main/java/org/sqlite/jdbc3/JDBC3PreparedStatement.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,14 @@ public void setString(int pos, String value) throws SQLException {
390390
/** @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int) */
391391
public void setCharacterStream(int pos, Reader reader, int length) throws SQLException {
392392
try {
393-
// copy chars from reader to StringBuffer
394-
StringBuffer sb = new StringBuffer();
393+
// copy chars from reader to StringBuilder
394+
StringBuilder sb = new StringBuilder();
395395
char[] cbuf = new char[8192];
396396
int cnt;
397397

398-
while ((cnt = reader.read(cbuf)) > 0) {
398+
while ((cnt = reader.read(cbuf, 0, Math.min(length, cbuf.length))) > 0) {
399399
sb.append(cbuf, 0, cnt);
400+
length -= cnt;
400401
}
401402

402403
// set as string

src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ public ResultSetMetaData getMetaData() {
573573

574574
/** @see java.sql.ResultSetMetaData#getCatalogName(int) */
575575
public String getCatalogName(int col) throws SQLException {
576-
return safeGetColumnTableName(col);
576+
return "";
577577
}
578578

579579
/** @see java.sql.ResultSetMetaData#getColumnClassName(int) */

src/main/java/org/sqlite/jdbc4/JDBC4PreparedStatement.java

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.sqlite.jdbc4;
22

3+
import java.io.ByteArrayInputStream;
4+
import java.io.ByteArrayOutputStream;
5+
import java.io.IOException;
36
import java.io.InputStream;
47
import java.io.Reader;
58
import java.sql.NClob;
@@ -48,14 +51,21 @@ public void setNClob(int parameterIndex, NClob value) throws SQLException {
4851
}
4952

5053
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
51-
// TODO Support this
52-
throw new SQLFeatureNotSupportedException();
54+
requireLengthIsPositiveInt(length);
55+
setCharacterStream(parameterIndex, reader, (int) length);
56+
}
57+
58+
private void requireLengthIsPositiveInt(long length) throws SQLFeatureNotSupportedException {
59+
if (length > Integer.MAX_VALUE || length < 0) {
60+
throw new SQLFeatureNotSupportedException(
61+
"Data must have a length between 0 and Integer.MAX_VALUE");
62+
}
5363
}
5464

5565
public void setBlob(int parameterIndex, InputStream inputStream, long length)
5666
throws SQLException {
57-
// TODO Support this
58-
throw new SQLFeatureNotSupportedException();
67+
requireLengthIsPositiveInt(length);
68+
setBinaryStream(parameterIndex, inputStream, (int) length);
5969
}
6070

6171
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
@@ -69,35 +79,59 @@ public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
6979
}
7080

7181
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
72-
// TODO Support this
73-
throw new SQLFeatureNotSupportedException();
82+
requireLengthIsPositiveInt(length);
83+
setAsciiStream(parameterIndex, x, (int) length);
7484
}
7585

7686
public void setBinaryStream(int parameterIndex, InputStream x, long length)
7787
throws SQLException {
78-
// TODO Support this
79-
throw new SQLFeatureNotSupportedException();
88+
requireLengthIsPositiveInt(length);
89+
setBinaryStream(parameterIndex, x, (int) length);
8090
}
8191

8292
public void setCharacterStream(int parameterIndex, Reader reader, long length)
8393
throws SQLException {
84-
// TODO Support this
85-
throw new SQLFeatureNotSupportedException();
94+
requireLengthIsPositiveInt(length);
95+
setCharacterStream(parameterIndex, reader, (int) length);
8696
}
8797

8898
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
89-
// TODO Support this
90-
throw new SQLFeatureNotSupportedException();
99+
byte[] bytes = readBytes(x);
100+
setAsciiStream(parameterIndex, new ByteArrayInputStream(bytes), bytes.length);
101+
}
102+
103+
/**
104+
* Reads given number of bytes from an input stream.
105+
*
106+
* @param istream The input stream.
107+
* @param length The number of bytes to read.
108+
* @return byte array.
109+
* @throws SQLException
110+
*/
111+
private byte[] readBytes(InputStream istream) throws SQLException {
112+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
113+
byte[] bytes = new byte[8192];
114+
115+
try {
116+
int bytesRead;
117+
while ((bytesRead = istream.read(bytes)) > 0) {
118+
baos.write(bytes, 0, bytesRead);
119+
}
120+
return baos.toByteArray();
121+
} catch (IOException cause) {
122+
SQLException exception = new SQLException("Error reading stream");
123+
124+
exception.initCause(cause);
125+
throw exception;
126+
}
91127
}
92128

93129
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
94-
// TODO Support this
95-
throw new SQLFeatureNotSupportedException();
130+
setBytes(parameterIndex, readBytes(x));
96131
}
97132

98133
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
99-
// TODO Support this
100-
throw new SQLFeatureNotSupportedException();
134+
setCharacterStream(parameterIndex, reader, Integer.MAX_VALUE);
101135
}
102136

103137
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
@@ -106,13 +140,11 @@ public void setNCharacterStream(int parameterIndex, Reader value) throws SQLExce
106140
}
107141

108142
public void setClob(int parameterIndex, Reader reader) throws SQLException {
109-
// TODO Support this
110-
throw new SQLFeatureNotSupportedException();
143+
setCharacterStream(parameterIndex, reader, Integer.MAX_VALUE);
111144
}
112145

113146
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
114-
// TODO Support this
115-
throw new SQLFeatureNotSupportedException();
147+
setBytes(parameterIndex, readBytes(inputStream));
116148
}
117149

118150
public void setNClob(int parameterIndex, Reader reader) throws SQLException {

src/main/java/org/sqlite/util/OSInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ private static boolean isRunningAndroid() {
124124
// We don't use libc/libm/libdl because that has changed what directory its pointing to and
125125
// OEMs implement the symlink that allows backwards compatibility
126126
// for apps that use the old path differently, which may cause this check to fail because
127-
// common undocumented behaviour. See
127+
// of common undocumented behaviour. See
128128
// https://developer.android.com/about/versions/10/behavior-changes-all#bionic
129-
File androidGLES = new File("/system/lib/libGLESv1_CM");
130-
File android64GLES = new File("/system/lib64/libGLESv1_CM");
129+
File androidGLES = new File("/system/lib/libGLESv1_CM.so");
130+
File android64GLES = new File("/system/lib64/libGLESv1_CM.so");
131131

132132
return android64GLES.exists() || androidGLES.exists();
133133
}

src/test/java/org/sqlite/PrepStmtTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import static org.assertj.core.data.Offset.offset;
88

99
import java.io.ByteArrayInputStream;
10+
import java.io.StringReader;
1011
import java.math.BigDecimal;
1112
import java.nio.charset.StandardCharsets;
1213
import java.sql.Connection;
@@ -177,6 +178,32 @@ public void stringRS() throws SQLException {
177178
rs.close();
178179
}
179180

181+
@Test
182+
public void clobRS() throws SQLException {
183+
String name = "Gandhi";
184+
PreparedStatement prep = conn.prepareStatement("select ?;");
185+
prep.setClob(1, new StringReader(name));
186+
ResultSet rs = prep.executeQuery();
187+
assertThat(prep.getUpdateCount()).isEqualTo(-1);
188+
assertThat(rs.next()).isTrue();
189+
assertThat(rs.getString(1)).isEqualTo(name);
190+
assertThat(rs.next()).isFalse();
191+
rs.close();
192+
}
193+
194+
@Test
195+
public void blobRS() throws SQLException {
196+
String name = "Gandhi";
197+
PreparedStatement prep = conn.prepareStatement("select ?;");
198+
prep.setBlob(1, new ByteArrayInputStream(name.getBytes()));
199+
ResultSet rs = prep.executeQuery();
200+
assertThat(prep.getUpdateCount()).isEqualTo(-1);
201+
assertThat(rs.next()).isTrue();
202+
assertThat(rs.getBytes(1)).isEqualTo(name.getBytes());
203+
assertThat(rs.next()).isFalse();
204+
rs.close();
205+
}
206+
180207
@Test
181208
public void finalizePrep() throws SQLException {
182209
conn.prepareStatement("select null;");

0 commit comments

Comments
 (0)