[Libreoffice-commits] .: Branch 'features/base-preview' - 3 commits - dbaccess/source hsqldb/patches wizards/com
Lionel Elie Mamane
lmamane at kemper.freedesktop.org
Thu Jul 12 14:23:11 PDT 2012
dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 1
hsqldb/patches/jdbc-4.1.patch | 87 +++++++++++++----
wizards/com/sun/star/wizards/db/SQLQueryComposer.java | 33 ++++--
3 files changed, 92 insertions(+), 29 deletions(-)
New commits:
commit 2252caa7381a584a5328727753000bc52e575ce1
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jul 12 23:23:03 2012 +0200
fdo#50800 populate composedCommandNames ASAP, not at call of getFromClause
In particular com/sun/star/wizards/ui/FilterComponent calls getSelectClause before calling getFromClause, and then all hell breaks loose: composedCommandNames is empty, thus cannot find the proper Alias column name, thus the column names in the select list were not properly escaped, ...
We have just made getFromClause quadratic instead of linear, but:
1) I do not think this would be a problem (small datastructures)
2) If it is, rather use a hashmap or something like that, wich will also make getSelectClause faster
Also make the fallback case of "unknown table" more robust: escape the table name (if any) and column name!
Change-Id: I474adc51fc6378d836bd5865d9eb9505983dcbc5
diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index 2b24ac3..f87baee 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -68,7 +68,7 @@ public class SQLQueryComposer
{
try
{
- this.CurDBMetaData = _CurDBMetaData;
+ setDBMetaData(_CurDBMetaData);
xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, CurDBMetaData.DBConnection);
final Object oQueryComposer = xMSF.createInstance("com.sun.star.sdb.SingleSelectQueryComposer");
m_xQueryAnalyzer = UnoRuntime.queryInterface(XSingleSelectQueryAnalyzer.class, oQueryComposer);
@@ -236,6 +236,7 @@ public class SQLQueryComposer
public void setDBMetaData(QueryMetaData _oDBMetaData)
{
this.CurDBMetaData = _oDBMetaData;
+ updateComposedCommandNames();
}
private PropertyValue[][] replaceConditionsByAlias(PropertyValue _filterconditions[][])
@@ -259,22 +260,30 @@ public class SQLQueryComposer
return m_xQueryAnalyzer.getQuery();
}
- public StringBuilder getFromClause()
+ private void updateComposedCommandNames()
{
- StringBuilder sFromClause = new StringBuilder("FROM");
composedCommandNames.clear();
String[] sCommandNames = CurDBMetaData.getIncludedCommandNames();
for (int i = 0; i < sCommandNames.length; i++)
{
- CommandName curCommandName = new CommandName(CurDBMetaData, sCommandNames[i]); //(setComposedCommandName)
+ CommandName curCommandName = new CommandName(CurDBMetaData, sCommandNames[i]);
curCommandName.setAliasName(getuniqueAliasName(curCommandName.getTableName()));
+ composedCommandNames.add(curCommandName);
+ }
+ }
+
+ public StringBuilder getFromClause()
+ {
+ StringBuilder sFromClause = new StringBuilder("FROM");
+ String[] sCommandNames = CurDBMetaData.getIncludedCommandNames();
+ for (int i = 0; i < sCommandNames.length; i++)
+ {
+ CommandName curCommandName = getComposedCommandByDisplayName(sCommandNames[i]);
sFromClause.append(" ").append(curCommandName.getComposedName()).append(" ").append(quoteName(curCommandName.getAliasName()));
if (i < sCommandNames.length - 1)
{
sFromClause.append(", ");
}
- // fill composedCommandNames
- composedCommandNames.add(curCommandName);
}
return sFromClause;
}
@@ -336,13 +345,19 @@ public class SQLQueryComposer
private String getComposedAliasFieldName(String _fieldname)
{
FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByDisplayName(_fieldname);
- CommandName curComposedCommandName = getComposedCommandByDisplayName(CurFieldColumn.getCommandName());
+ final String curCommandName = CurFieldColumn.getCommandName();
+ final String curFieldName = CurFieldColumn.getFieldName();
+ CommandName curComposedCommandName = getComposedCommandByDisplayName(curCommandName);
if (curComposedCommandName == null)
{
- return _fieldname;
+ //return _fieldname;
+ if ( curCommandName.length > 0 )
+ return quoteName(curCommandName) + "." + quoteName(curFieldName);
+ else
+ return quoteName(CurFieldColumn.getFieldName());
}
String curAliasName = curComposedCommandName.getAliasName();
- return quoteName(curAliasName) + "." + quoteName(CurFieldColumn.getFieldName());
+ return quoteName(curAliasName) + "." + quoteName(curFieldName);
}
private CommandName getComposedCommandByAliasName(String _AliasName)
commit ba979e5aab0987d5ce17d4e6f141c8ff08b93d19
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jul 12 18:10:14 2012 +0200
debug unexpected exception
Change-Id: I404072caf6ddab0ed833586066507c7d332fcea4
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 04f7a5a..6bc4c5d 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -626,6 +626,7 @@ void SAL_CALL OSingleSelectQueryComposer::setElementaryQuery( const ::rtl::OUStr
{
(void)e;
OSL_FAIL( "OSingleSelectQueryComposer::setElementaryQuery: there should be no error anymore for the additive statement!" );
+ DBG_UNHANDLED_EXCEPTION();
// every part of the additive statement should have passed other tests already, and should not
// be able to cause any errors ... me thinks
}
commit 9c51265fe0f748b5e228cdc16ba3944e74698bb0
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jul 12 13:07:03 2012 +0200
fix hsqldb java version detection
1) The values were not properly exclusive.
E.g. when compiling under OpenJDK 1.6, iscjava12 was set (!)
2) On Java 1.6, should not enable the parts that are (only) for Java7!
3) When non-JAVA7, need to preprocess the files that have JAVA7-only code, so that it gets removed
Change-Id: I99b6bd9e781fee1007a04a4dc3d3f952c1b2eb00
diff --git a/hsqldb/patches/jdbc-4.1.patch b/hsqldb/patches/jdbc-4.1.patch
index 89149c4..4c4eb85 100644
--- a/hsqldb/patches/jdbc-4.1.patch
+++ b/hsqldb/patches/jdbc-4.1.patch
@@ -1,19 +1,50 @@
---- misc/hsqldb/build/build.xml 2012-02-08 15:14:42.827123541 +0000
-+++ misc/build/hsqldb/build/build.xml 2012-02-08 15:21:43.827722388 +0000
-@@ -98,7 +98,11 @@
+--- misc/hsqldb/build/build.xml 2012-07-12 10:58:11.000000000 +0200
++++ misc/build/hsqldb/build/build.xml 2012-07-12 10:49:28.000000000 +0200
+@@ -98,16 +98,24 @@
<echo message="ant.java.hasjsse=${ant.java.hasjsse}" />
</target>
- <target name="javaversion6">
-+ <target name="javaversion7">
++ <target name="javaversion7" unless="ant.java.iscjavaset">
+ <available classname="java.util.Objects" property="ant.java.iscjava17"/>
++ <available classname="java.util.Objects" property="ant.java.iscjavaset"/>
+ </target>
+
-+ <target name="javaversion6" depends="javaversion7" unless="ant.java.iscjava17">
++ <target name="javaversion6" depends="javaversion7" unless="ant.java.iscjavaset">
<available classname="java.net.IDN" property="ant.java.iscjava16"/>
++ <available classname="java.net.IDN" property="ant.java.iscjavaset"/>
</target>
-@@ -210,6 +214,7 @@
+- <target name="javaversion4" depends="javaversion6" unless="ant.java.iscjava16">
++ <target name="javaversion4" depends="javaversion6" unless="ant.java.iscjavaset">
+ <available classname="java.nio.Buffer" property="ant.java.iscjava14"/>
++ <available classname="java.nio.Buffer" property="ant.java.iscjavaset"/>
+ </target>
+
+- <target name="javaversion2" depends="javaversion4" unless="ant.java.iscjava14">
++ <target name="javaversion2" depends="javaversion4" unless="ant.java.iscjavaset">
+ <available classname="java.lang.ref.Reference" property="ant.java.iscjava12"/>
++ <available classname="java.lang.ref.Reference" property="ant.java.iscjavaset"/>
+ </target>
+
+ <target name="-prepare" depends="init,javaversion2">
+@@ -166,6 +177,7 @@
+ <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
+ <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
+ <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
++ <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcStatement.java"/>
+ <arg file="${src}/org/hsqldb/persist/LockFile.java"/>
+ <arg file="${src}/org/hsqldb/persist/Logger.java"/>
+@@ -183,6 +195,7 @@
+ <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
+ <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
+ <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
++ <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcBlob.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcDataSource.java"/>
+@@ -210,6 +223,7 @@
<arg value="+JAVA2FULL"/>
<arg value="-JAVA4"/>
<arg value="-JAVA6"/>
@@ -21,7 +52,15 @@
</java>
</target>
-@@ -244,6 +249,7 @@
+@@ -218,6 +232,7 @@
+ <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
+ <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
+ <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
++ <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcBlob.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcDataSource.java"/>
+@@ -244,6 +259,7 @@
<arg value="+JAVA2FULL"/>
<arg value="+JAVA4"/>
<arg value="-JAVA6"/>
@@ -29,19 +68,10 @@
</java>
</target>
-@@ -279,10 +285,47 @@
- <arg value="+JAVA2FULL"/>
- <arg value="+JAVA4"/>
- <arg value="+JAVA6"/>
-+ <arg value="+JAVA7"/>
-+ </java>
-+ </target>
-+
-+ <target name="switchtojdk17" depends="switchtojdk16"
-+ description="self explanatory" if="ant.java.iscjava17">
-+ <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
-+ <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
-+ <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
+@@ -253,6 +269,43 @@
+ <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
+ <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
+ <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
+ <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcBlob.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java"/>
@@ -69,6 +99,23 @@
+ <arg value="+JAVA2FULL"/>
+ <arg value="+JAVA4"/>
+ <arg value="+JAVA6"/>
++ <arg value="-JAVA7"/>
++ </java>
++ </target>
++
++ <target name="switchtojdk17" depends="switchtojdk16"
++ description="self explanatory" if="ant.java.iscjava17">
++ <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
++ <arg file="${src}/org/hsqldb/lib/java/JavaSystem.java"/>
++ <arg file="${src}/org/hsqldb/lib/HsqlTimer.java"/>
++ <arg file="${src}/org/hsqldb/jdbcDriver.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcBlob.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java"/>
+ <arg file="${src}/org/hsqldb/jdbc/jdbcDataSource.java"/>
+@@ -279,10 +332,11 @@
+ <arg value="+JAVA2FULL"/>
+ <arg value="+JAVA4"/>
+ <arg value="+JAVA6"/>
+ <arg value="+JAVA7"/>
</java>
</target>
More information about the Libreoffice-commits
mailing list