This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch hsqldb2 in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 5f818de9958953d4242cd907076f10f58884fdba Author: Jim Jagielski <[email protected]> AuthorDate: Mon Oct 26 07:11:45 2026 -0400 hsqldb: fix the 2.5.0 build and restore the storage hooks Stock 2.5.0 dropped the fileaccess_class_name/storage_class_name hooks; storage_access.patch adds them back for the embedded database. --- .../star/sdbcx/comp/hsqldb/StorageFileAccess.java | 9 + .../source/drivers/hsqldb/HStorageMap.cxx | 5 +- .../source/inc/resource/hsqldb_res.hrc | 3 +- main/hsqldb/makefile.mk | 12 +- main/hsqldb/patches/storage_access.patch | 254 +++++++++++++++++++++ 5 files changed, 271 insertions(+), 12 deletions(-) diff --git a/main/connectivity/java/sdbc_hsqldb/src/main/java/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java b/main/connectivity/java/sdbc_hsqldb/src/main/java/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java index 472ad30065..e71d12ccb0 100644 --- a/main/connectivity/java/sdbc_hsqldb/src/main/java/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java +++ b/main/connectivity/java/sdbc_hsqldb/src/main/java/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java @@ -59,6 +59,11 @@ public class StorageFileAccess implements org.hsqldb.lib.FileAccess{ return new NativeOutputStreamHelper(key,streamName); } + // the native stream has no append mode, so 'append' is not honoured + public java.io.OutputStream openOutputStreamElement(java.lang.String streamName, boolean append) throws java.io.IOException { + return openOutputStreamElement(streamName); + } + public void removeElement(java.lang.String filename) throws java.util.NoSuchElementException { try { if ( isStreamElement(key,filename) ) @@ -79,6 +84,10 @@ public class StorageFileAccess implements org.hsqldb.lib.FileAccess{ } } + public void renameElement(java.lang.String oldName, java.lang.String newName, boolean copyIfFailed) { + renameElement(oldName, newName); + } + public class FileSync implements FileAccess.FileSync { NativeOutputStreamHelper os; diff --git a/main/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/main/connectivity/source/drivers/hsqldb/HStorageMap.cxx index e8ebc4dfc2..5ba95f78b7 100644 --- a/main/connectivity/source/drivers/hsqldb/HStorageMap.cxx +++ b/main/connectivity/source/drivers/hsqldb/HStorageMap.cxx @@ -57,9 +57,8 @@ namespace connectivity { try { - m_xStream.clear(); - m_xSeek.clear(); - if ( m_xOutputStream.is() ) + m_xStream.clear(); + m_xSeek.clear(); if ( m_xInputStream.is() ) { m_xInputStream->closeInput(); diff --git a/main/connectivity/source/inc/resource/hsqldb_res.hrc b/main/connectivity/source/inc/resource/hsqldb_res.hrc index c76ab33519..412b2ad156 100644 --- a/main/connectivity/source/inc/resource/hsqldb_res.hrc +++ b/main/connectivity/source/inc/resource/hsqldb_res.hrc @@ -37,6 +37,7 @@ #define STR_NO_TABLE_EDITOR_DIALOG ( STR_HSQLDB_BASE + 3 ) #define STR_NO_TABLENAME ( STR_HSQLDB_BASE + 4 ) #define STR_NO_DOCUMENTUI ( STR_HSQLDB_BASE + 5 ) -#define STR_ERROR_NEW_VERSION ( STR_HSQLDB_BASE + 6 ) +#define STR_CONVERT_TO_NEW_VERSION ( STR_HSQLDB_BASE + 6 ) +#define STR_SHUTDOWN_REQUIRED ( STR_HSQLDB_BASE + 7 ) #endif // CONNECTIVITY_RESOURCE_HSQLDB_HRC diff --git a/main/hsqldb/makefile.mk b/main/hsqldb/makefile.mk index 7290f83c9e..5df0bfca33 100644 --- a/main/hsqldb/makefile.mk +++ b/main/hsqldb/makefile.mk @@ -45,23 +45,19 @@ TARFILE_MD5=8140e899c4cdf04e31a06743230f8523 TARFILE_ROOTDIR=hsqldb-$(HSQLDB_VERSION)$/hsqldb -CONVERTFILES=build$/build.xml \ - src$/org$/hsqldb$/persist$/HsqlDatabaseProperties.java \ - src$/org$/hsqldb$/Library.java - -PATCH_FILES= +PATCH_FILES=patches$/storage_access.patch JAVAC_SRCTGT=-Dant.build.javac.source=1.8 -Dant.build.javac.target=1.8 .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) jar +BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) hsqldb .ELSE .IF "$(debug)"!="" -BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.debug="on" $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) jar +BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.debug="on" $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) hsqldb .ELSE -BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) jar +BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) hsqldb .ENDIF .ENDIF diff --git a/main/hsqldb/patches/storage_access.patch b/main/hsqldb/patches/storage_access.patch new file mode 100644 index 0000000000..ac5c97a29f --- /dev/null +++ b/main/hsqldb/patches/storage_access.patch @@ -0,0 +1,254 @@ +--- misc/hsqldb/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/Logger.java ++++ misc/build/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/Logger.java +@@ -34,6 +34,7 @@ + import java.io.File; + import java.io.FileInputStream; + import java.io.IOException; ++import java.lang.reflect.Constructor; + import java.text.SimpleDateFormat; + import java.util.Locale; + import java.util.concurrent.atomic.AtomicInteger; +@@ -137,6 +138,7 @@ + private Crypto crypto; + boolean cryptLobs; + public FileAccess fileAccess; ++ private boolean isStoredFileAccess; + String tempDirectoryPath; + + // +@@ -198,7 +200,12 @@ + boolean hasFileProps = false; + boolean hasScript = false; + +- fileAccess = FileUtil.getFileAccess(database.isFilesInJar()); ++ fileAccess = newStoredFileAccess(); ++ ++ if (fileAccess == null) { ++ fileAccess = FileUtil.getFileAccess(database.isFilesInJar()); ++ } ++ + propIsFileDatabase = database.getType().isFileBased(); + database.databaseProperties = new HsqlDatabaseProperties(database); + propTextAllowFullPath = database.databaseProperties.isPropertyTrue( +@@ -285,6 +292,12 @@ + } + } + ++ // the shadow file used for incremental backup is not reachable through FileAccess ++ if (isStoredFileAccess) { ++ database.databaseProperties.setProperty( ++ HsqlDatabaseProperties.hsqldb_inc_backup, false); ++ } ++ + setVariables(); + + String appLogPath = null; +@@ -1102,7 +1115,7 @@ + + public synchronized void setIncrementBackup(boolean val) { + +- if (val == propIncrementBackup) { ++ if (val == propIncrementBackup || isStoredFileAccess) { + return; + } + +@@ -1313,8 +1326,67 @@ + + public FileAccess getFileAccess() { + return fileAccess; ++ } ++ ++ /** ++ * True if the database files are kept in a storage supplied by the host ++ * application instead of the file system. ++ */ ++ public boolean isStoredFileAccess() { ++ return isStoredFileAccess; ++ } ++ ++ // [email protected] - the database files are accessed through a class ++ // named in the connection properties, with a key identifying the storage ++ static final String url_fileaccess_class_name = "fileaccess_class_name"; ++ static final String url_storage_class_name = "storage_class_name"; ++ static final String url_storage_key = "storage_key"; ++ ++ static Class<?> loadStorageClass(String name) throws ClassNotFoundException { ++ ++ ClassLoader loader = Thread.currentThread().getContextClassLoader(); ++ ++ if (loader != null) { ++ try { ++ return loader.loadClass(name); ++ } catch (ClassNotFoundException e) {} ++ } ++ ++ return Class.forName(name); + } + ++ private FileAccess newStoredFileAccess() { ++ ++ String className = ++ database.urlProperties.getProperty(url_fileaccess_class_name); ++ ++ if (className == null) { ++ return null; ++ } ++ ++ try { ++ Class<?> fileAccessClass = loadStorageClass(className); ++ ++ if (!FileAccess.class.isAssignableFrom(fileAccessClass)) { ++ throw new ClassCastException(className); ++ } ++ ++ Constructor<?> constructor = ++ fileAccessClass.getConstructor(Object.class); ++ FileAccess access = (FileAccess) constructor.newInstance( ++ database.urlProperties.getProperty(url_storage_key)); ++ ++ isStoredFileAccess = true; ++ ++ return access; ++ } catch (Throwable t) { ++ throw Error.error(t, ErrorCode.FILE_IO_ERROR, ++ ErrorCode.M_Message_Pair, new Object[] { ++ t.toString(), className ++ }); ++ } ++ } ++ + public boolean isFileDatabase() { + return propIsFileDatabase; + } +--- misc/hsqldb/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/RAStorageWrapper.java ++++ misc/build/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/RAStorageWrapper.java +@@ -32,7 +32,9 @@ + package org.hsqldb.persist; + + import java.io.IOException; ++import java.lang.reflect.Constructor; + ++import org.hsqldb.Database; + import org.hsqldb.lib.Storage; + + /** +@@ -52,6 +54,36 @@ + this.file = virtualFile; + } + ++ /** ++ * Opens a file in the storage supplied by the host application, using the ++ * class and key given in the connection properties. ++ */ ++ static RAStorageWrapper newInstance(Database database, String name, ++ boolean readonly) throws IOException { ++ ++ String className = ++ database.urlProperties.getProperty(Logger.url_storage_class_name); ++ ++ try { ++ Class<?> storageClass = Logger.loadStorageClass(className); ++ ++ if (!Storage.class.isAssignableFrom(storageClass)) { ++ throw new ClassCastException(className); ++ } ++ ++ Constructor<?> constructor = ++ storageClass.getConstructor(String.class, Boolean.class, ++ Object.class); ++ Storage storage = (Storage) constructor.newInstance(name, ++ Boolean.valueOf(readonly), ++ database.urlProperties.getProperty(Logger.url_storage_key)); ++ ++ return new RAStorageWrapper(storage); ++ } catch (Exception e) { ++ throw new IOException("invalid storage class: " + e, e); ++ } ++ } ++ + public long length() throws IOException { + return file.length(); + } +--- misc/hsqldb/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/RAFile.java ++++ misc/build/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/RAFile.java +@@ -92,6 +92,10 @@ + static RandomAccessInterface newScaledRAFile(Database database, + String name, boolean readonly, + int type) throws FileNotFoundException, IOException { ++ ++ if (type == DATA_FILE_STORED) { ++ return RAStorageWrapper.newInstance(database, name, readonly); ++ } + + if (type == DATA_FILE_JAR) { + return new RAFileInJar(name); +--- misc/hsqldb/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/DataFileCache.java ++++ misc/build/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/DataFileCache.java +@@ -156,7 +156,7 @@ + cache = new Cache(this); + + try { +- dataFile = new RAFileSimple(database.logger, dataFileName, "rw"); ++ dataFile = newSimpleFile(false); + } catch (Throwable t) { + throw Error.error(ErrorCode.FILE_IO_ERROR, t); + } +@@ -224,6 +224,8 @@ + + if (database.isFilesInJar()) { + fileType = RAFile.DATA_FILE_JAR; ++ } else if (database.logger.isStoredFileAccess()) { ++ fileType = RAFile.DATA_FILE_STORED; + } else if (isNio) { + fileType = RAFile.DATA_FILE_NIO; + } else { +@@ -263,8 +265,7 @@ + boolean isSaved = false; + + if (preexists) { +- dataFile = new RAFileSimple(database.logger, dataFileName, +- "r"); ++ dataFile = newSimpleFile(true); + + long length = dataFile.length(); + boolean wrongVersion = false; +@@ -389,7 +390,20 @@ + ErrorCode.M_DataFileCache_open, new Object[] { + t.toString(), dataFileName + }); ++ } ++ } ++ ++ private RandomAccessInterface newSimpleFile(boolean readonly) ++ throws IOException { ++ ++ if (database.logger.isStoredFileAccess()) { ++ return RAStorageWrapper.newInstance(database, dataFileName, ++ readonly); + } ++ ++ return new RAFileSimple(database.logger, dataFileName, ++ readonly ? "r" ++ : "rw"); + } + + boolean setDataSpaceManager() { +--- misc/hsqldb/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/LobStoreRAFile.java ++++ misc/build/hsqldb-2.5.0/hsqldb/src/org/hsqldb/persist/LobStoreRAFile.java +@@ -70,8 +70,14 @@ + try { + boolean readonly = database.isFilesReadOnly(); + +- file = new RAFileSimple(database.logger, fileName, readonly ? "r" +- : "rws"); ++ if (database.logger.isStoredFileAccess()) { ++ file = RAStorageWrapper.newInstance(database, fileName, ++ readonly); ++ } else { ++ file = new RAFileSimple(database.logger, fileName, ++ readonly ? "r" ++ : "rws"); ++ } + } catch (Throwable t) { + throw Error.error(ErrorCode.DATA_FILE_ERROR, t); + }
