*** misc/hsqldb/build/build.xml	Sun Oct 23 18:54:00 2005
--- misc/build/hsqldb/build/build.xml	Tue May 30 16:22:33 2006
***************
*** 16,28 ****
     <property file='build/build.properties'/>
     <property name="hsqldb.version" value="1.8.0"/>
  
!    <tstamp>
!        <format property="_tmpstamp" pattern="yyyy/MM/dd-hh:mm:ss"
!                locale="en"/>
!    </tstamp>
! 
!    <property name="build.label" value="private-${_tmpstamp}"/>
!    <property name="build.vendor" value="${user.name}"/>
     <property name="hsqldb.title" value="HSQLDB"/>
     <property name="hsqldb.vendor" value="The HSQLDB Development Group"/>
     <property name="src" value="${basedir}/src"/>
--- 16,23 ----
     <property file='build/build.properties'/>
     <property name="hsqldb.version" value="1.8.0"/>
  
!    <property name="build.label" value="replace-me"/>
!    <property name="build.vendor" value="OpenOffice.org"/>
     <property name="hsqldb.title" value="HSQLDB"/>
     <property name="hsqldb.vendor" value="The HSQLDB Development Group"/>
     <property name="src" value="${basedir}/src"/>
***************
*** 55,82 ****
  jars built with JDK 1.2 OR 1.3 can now be used with JRE 1.1.</echo>
     </target>
  
!    <!-- Blaine's new jar target naming strategy.
          Target name is always the same as the desired jar file name, less
          the ".jar" extension. -->
-    <!-- Commented out descriptions can be enabled if we want to assist
-         people using old-style target names.  If so, remember to remove
-         the trailing "/>" on every first target line. -->
     <target name='jar' depends='hsqldb'/>
-        <!-- description="Same as target 'hsqldb'"/> -->
     <target name='jarclient' depends='hsqljdbc'/>
-        <!-- description="Same as target 'hsqljdbc'"/> -->
     <target name='jarmain' depends='hsqldbmain'/>
-        <!-- description="Same as target 'hsqldbmain'"/> -->
     <target name='jarmin' depends='hsqldbmin'/>
-        <!-- description="Same as target 'hsqldbmin'"/> -->
     <target name='jarsqltool' depends='hsqltool'/>
-        <!-- description="Same as target 'hsqltool'"/> -->
     <target name='jartest' depends='hsqldbtest'/>
-        <!-- description="Same as target 'hsqldbtest'"/> -->
     <target name='jarutil' depends='hsqldbutil'/>
-        <!-- description="Same as target 'hsqldbutil'"/> -->
     <target name='jarzaurus' depends='hsqldbz'/>
-        <!-- description="Same as target 'hsqldbz'"/> -->
  
     <target name="help" description="Top-level help message">
        <echo>usage:
--- 50,66 ----
  jars built with JDK 1.2 OR 1.3 can now be used with JRE 1.1.</echo>
     </target>
  
!    <!-- Deprecated targets.  New naming convention is:
          Target name is always the same as the desired jar file name, less
          the ".jar" extension. -->
     <target name='jar' depends='hsqldb'/>
     <target name='jarclient' depends='hsqljdbc'/>
     <target name='jarmain' depends='hsqldbmain'/>
     <target name='jarmin' depends='hsqldbmin'/>
     <target name='jarsqltool' depends='hsqltool'/>
     <target name='jartest' depends='hsqldbtest'/>
     <target name='jarutil' depends='hsqldbutil'/>
     <target name='jarzaurus' depends='hsqldbz'/>
  
     <target name="help" description="Top-level help message">
        <echo>usage:
***************
*** 97,115 ****
        <echo message="ant.java.hasjsse=${ant.java.hasjsse}" />
     </target>
  
     <target name="-javaversion4">
        <available classname="java.nio.Buffer" property="ant.java.iscjava14"/>
        <available classname="java.nio.Buffer" property="ant.java.iscjavamodern"/>
-       <available classname="com.jamonapi.MonitorFactory" property="jamon"/>
     </target>
  
!    <target name="javaversion2" depends="-javaversion4"
             unless="ant.java.iscjava14">
        <available classname="java.lang.ref.Reference" property="ant.java.iscjava12"/>
        <available classname="java.lang.ref.Reference" property="ant.java.iscjavamodern"/>
     </target>
  
!    <target name="-prepare" depends="init,javaversion2">
         <mkdir dir="classes" />
     </target>
  
--- 81,114 ----
        <echo message="ant.java.hasjsse=${ant.java.hasjsse}" />
     </target>
  
+    <!-- If there really are no inter-dependencies between these availability
+         properties (i.e., we always want to set all of these properties 
+         during setup), then we should clean things up and make one 
+         -checkAvailability, or similar, target instead of 3. -->
     <target name="-javaversion4">
        <available classname="java.nio.Buffer" property="ant.java.iscjava14"/>
        <available classname="java.nio.Buffer" property="ant.java.iscjavamodern"/>
     </target>
  
!    <target name="-checkJamonPresence">
!       <available classname="com.jamonapi.MonitorFactory"
!                  classpath='lib/JAMon.jar' property="use-jamon"/>
!    </target>
! 
!    <!-- I can't think of any reason for the 'unless' att.
!         If this is to prevent repeat runs, then why depend on a property 
!         which may or may not be called by a sub-target.
!         This property is not set elsewhere, and doesn't look at all like
!         a property which would be set externally (by -D or a properties file).
!                                                       - blaine
!    -->
!    <target name="-javaversion2" depends="-javaversion4"
             unless="ant.java.iscjava14">
        <available classname="java.lang.ref.Reference" property="ant.java.iscjava12"/>
        <available classname="java.lang.ref.Reference" property="ant.java.iscjavamodern"/>
     </target>
  
!    <target name="-prepare" depends="init,-javaversion2, -checkJamonPresence">
         <mkdir dir="classes" />
     </target>
  
***************
*** 139,145 ****
  
      <target name="switchtojava1target" depends="codeswitcher"
              description="self explanatory">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes" >
           <arg line="${src}/org/hsqldb/Column.java
                      ${src}/org/hsqldb/Tokenizer.java
                      ${src}/org/hsqldb/lib/java/JavaSystem.java
--- 138,144 ----
  
      <target name="switchtojava1target" depends="codeswitcher"
              description="self explanatory">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
           <arg line="${src}/org/hsqldb/Column.java
                      ${src}/org/hsqldb/Tokenizer.java
                      ${src}/org/hsqldb/lib/java/JavaSystem.java
***************
*** 155,161 ****
  
      <target name="switchoffjava1target" depends="codeswitcher"
              description="self explanatory">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes" >
           <arg line="${src}/org/hsqldb/Column.java
                      ${src}/org/hsqldb/Tokenizer.java
                      ${src}/org/hsqldb/lib/java/JavaSystem.java
--- 154,160 ----
  
      <target name="switchoffjava1target" depends="codeswitcher"
              description="self explanatory">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
           <arg line="${src}/org/hsqldb/Column.java
                      ${src}/org/hsqldb/Tokenizer.java
                      ${src}/org/hsqldb/lib/java/JavaSystem.java
***************
*** 170,176 ****
  
      <target name="switchtodeprecatedjdbc" depends="codeswitcher"
              description="self explanatory">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcCallableStatement.java
                      ${src}/org/hsqldb/jdbc/jdbcPreparedStatement.java
                      ${src}/org/hsqldb/jdbc/jdbcResultSet.java +DEPRECATEDJDBC"/>
--- 169,175 ----
  
      <target name="switchtodeprecatedjdbc" depends="codeswitcher"
              description="self explanatory">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcCallableStatement.java
                      ${src}/org/hsqldb/jdbc/jdbcPreparedStatement.java
                      ${src}/org/hsqldb/jdbc/jdbcResultSet.java +DEPRECATEDJDBC"/>
***************
*** 179,212 ****
  
      <target name="switchoffdeprecatedjdbc" depends="codeswitcher"
              description="self explanatory">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcCallableStatement.java
                      ${src}/org/hsqldb/jdbc/jdbcPreparedStatement.java
                      ${src}/org/hsqldb/jdbc/jdbcResultSet.java -DEPRECATEDJDBC"/>
         </java>
      </target>
  
!     <target name="switch1" depends="codeswitcher"
!             description="self explanatory" if="jamon">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes">
           <arg line="${src}/org/hsqldb/monitor/DBMonFactory.java +JAMON"/>
         </java>
      </target>
  
!     <target name="switch2" depends="switch1"
!             description="self explanatory" unless="jamon">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes">
           <arg line="${src}/org/hsqldb/monitor/DBMonFactory.java -JAMON"/>
         </java>
      </target>
  
!     <target name="switches" depends="switch2"
!             description="self explanatory">
      </target>
  
      <target name="switchtojdk11" depends="switches"
              description="self explanatory" unless="ant.java.iscjavamodern">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcStubs.java
                      ${src}/org/hsqldb/jdbc/jdbcConnection.java
                      ${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java
--- 178,216 ----
  
      <target name="switchoffdeprecatedjdbc" depends="codeswitcher"
              description="self explanatory">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcCallableStatement.java
                      ${src}/org/hsqldb/jdbc/jdbcPreparedStatement.java
                      ${src}/org/hsqldb/jdbc/jdbcResultSet.java -DEPRECATEDJDBC"/>
         </java>
      </target>
  
!     <!-- If this should not be called externally, rename to -jamonSwitcher
!          and remove the description attribute -->
!     <target name='jamonswitcher' depends='-jamonSwitchOn, -jamonSwitchOff'
!             description='Run code switcher for JAMon'/>
! 
!     <target name="-jamonSwitchOn" depends="codeswitcher" if="use-jamon">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes">
           <arg line="${src}/org/hsqldb/monitor/DBMonFactory.java +JAMON"/>
         </java>
      </target>
  
!     <target name="-jamonSwitchOff" depends="codeswitcher" unless="use-jamon">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes">
           <arg line="${src}/org/hsqldb/monitor/DBMonFactory.java -JAMON"/>
         </java>
      </target>
  
!     <!-- If this should not be called externally, rename to -switches
!          and remove the description attribute -->
!     <target name="switches" depends="jamonswitcher"
!             description="Execute code switchers, other than for JVM version">
      </target>
  
      <target name="switchtojdk11" depends="switches"
              description="self explanatory" unless="ant.java.iscjavamodern">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcStubs.java
                      ${src}/org/hsqldb/jdbc/jdbcConnection.java
                      ${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java
***************
*** 223,229 ****
  
      <target name="switchtojdk12" depends="switches"
              description="self explanatory" if="ant.java.iscjava12">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcStubs.java
                      ${src}/org/hsqldb/jdbc/jdbcConnection.java
                      ${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java
--- 227,233 ----
  
      <target name="switchtojdk12" depends="switches"
              description="self explanatory" if="ant.java.iscjava12">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcStubs.java
                      ${src}/org/hsqldb/jdbc/jdbcConnection.java
                      ${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java
***************
*** 239,245 ****
  
      <target name="switchtojdk14" depends="switches"
              description="self explanatory" if="ant.java.iscjava14">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath= "classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcStubs.java
                      ${src}/org/hsqldb/jdbc/jdbcConnection.java
                      ${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java
--- 243,249 ----
  
      <target name="switchtojdk14" depends="switches"
              description="self explanatory" if="ant.java.iscjava14">
!       <java classname="org.hsqldb.util.CodeSwitcher" classpath="classes" >
           <arg line="${src}/org/hsqldb/jdbc/jdbcStubs.java
                      ${src}/org/hsqldb/jdbc/jdbcConnection.java
                      ${src}/org/hsqldb/jdbc/jdbcDatabaseMetaData.java
***************
*** 285,290 ****
--- 289,295 ----
         >
           <classpath>
              <pathelement location="lib/servlet.jar"/>
+             <pathelement location="lib/JAMon.jar"/>
           </classpath>
           <include name="*.java"/>
           <include name="org/hsqldb/*.java"/>
***************
*** 295,300 ****
--- 300,306 ----
           <include name="org/hsqldb/rowio/*.java"/>
           <include name="org/hsqldb/scriptio/*.java"/>
           <include name="org/hsqldb/types/*.java"/>
+          <include name="org/hsqldb/monitor/*.java"/>
           <exclude name="org/hsqldb/HsqlSocketFactorySecure.java" unless="ant.java.hasjsse"/>
           <exclude name="org/hsqldb/jdbc/jdbcBlob.java"/>
           <exclude name="org/hsqldb/jdbc/jdbcClob.java"/>
***************
*** 336,343 ****
        </javac>
     </target>
  
!    <target name="-test14" if="ant.java.iscjava14"
!            description="compiles 1.4-specific test classes">
        <javac srcdir="${src}"
               destdir="classes"
               debug="${build.debug}"
--- 342,355 ----
        </javac>
     </target>
  
!    <!-- Don't both use name beginning with - AND supply a 'description'.
!         If this should be externally callable, then remove the leading -
!         and change the following description to a description attribute:
!                                                - blaine
! 
!         compiles 1.4-specific test classes
!    -->
!     <target name="-test14" if="ant.java.iscjava14">
        <javac srcdir="${src}"
               destdir="classes"
               debug="${build.debug}"
***************
*** 471,478 ****
        </jar>
      </target>
  
      <target name="hsqldbmain" depends="classes14"
!             description="Build the hsqldbmain.jar (no utilities) (use '-Dnoswing=true jarmain' to exclude swing classes)">
          <jar jarfile="lib/hsqldbmain.jar"
               basedir="classes"
           >
--- 483,497 ----
        </jar>
      </target>
  
+     <!-- 
+             Sat Nov 19 17:52:33 EST 2005  Blaine changing this description,
+             because I see no Swing classes in hsqldbmain.jar when I build
+             it... why would anybody ever want them in a no-util jar anyways?
+      
+             description="Build the hsqldbmain.jar (no utilities) (use ant switch '-Dnoswing=true' to exclude swing classes)">
+     -->
      <target name="hsqldbmain" depends="classes14"
!             description="Build the hsqldbmain.jar (no utilities)">
          <jar jarfile="lib/hsqldbmain.jar"
               basedir="classes"
           >
*** misc/hsqldb/doc/changelist_1_8_0.txt	Wed Nov  2 14:19:26 2005
--- misc/build/hsqldb/doc/changelist_1_8_0.txt	Tue May 30 16:22:33 2006
***************
*** 6,11 ****
--- 6,19 ----
  Fred Toussi (fredt@users.sourceforge.net)
  Maintainer, HSQLDB Project
  
+ 2005.12.22
+ 
+ Fixed bug where ON DELETE SET DEFAULT was accepted without a matching DEFAULT value
+ Fixed bug where column renaming was allowed in tables accessed in views
+ Fixed bug where TRUE or FALSE is used as search condition as WHERE .. AND FALSE
+ Fixed bug where dropping TEMPORARY tables was not logged
+ Fixed bug where negative values for IDENTITY columns were treated as positive
+ 
  
  2005.11.02 1.8.0.3
  
*** misc/hsqldb/docsrc/guide/sqltool.xml	Sat Jun  4 20:07:12 2005
--- misc/build/hsqldb/docsrc/guide/sqltool.xml	Tue May 30 16:22:32 2006
***************
*** 33,122 ****
              control and error handling).
          </simpara><simpara>
              Some of the examples below use quoting which works exactly
!             as-is for any normal UNIX shell.
              I have not yet tested these commands on Windows, and I doubt
              whether the quoting will work just like this (though it is
              possible).
              SqlTool is still a very useful tool even if you have no quoting
              capability at all.
          </simpara><simpara>
!             This document is now updated for version 1.46 of SqlTool and
!             1.114 of SqlFile (the latter is the class which does most of the
              work for SqlTool).
              The startup banner will report both versions when you run SqlTool
              interactively.
-             I expect this version of this document to accurately describe 
-             SqlTool for some unknown number of versions into the future.
          </simpara>
          <section><title>Recent changes</title>
              <simpara>This section lists changes to SqlTool since the last
                  major release of HSQLDB.
!                 For this version of this document, that means, changes since
!                 HSQLDB versions 1.7.x.
              </simpara>
              <itemizedlist>
                  <listitem><simpara>
!                     Slight adjustments to command-line switch behavior to make
!                     them more convenient for the most common forms of usage.
                  </simpara></listitem><listitem><simpara>
!                     Changed PL alias prefix from * to / (in order to allow for
!                     the following improvement).
                  </simpara></listitem><listitem><simpara>
!                     Removed the funny whitespace requirements for PL commands.
                  </simpara></listitem><listitem><simpara>
!                     Uppercase/lowercase requirements for special commands are
!                     relegated to the database.
!                     Therefore, in special commands only, you are safest to key 
!                     in object names in the case exactly as the real object name
!                     in your database.
!                     This is the only way for me to remove ambiguity from 
!                     case-specific object names without having to code different
!                     rules for every database.
!                     (Because, for example, Postgresql defaults object names to
!                     lowercase and Oracle defaults them to uppercase).
!                 </simpara></listitem><listitem><simpara>
!                     Added special command \dn.
!                 </simpara></listitem><listitem><simpara>
!                     Added special command \ds (old \ds command is now \dS).
!                 </simpara></listitem><listitem><simpara>
!                     Added special command \di.
!                 </simpara></listitem><listitem><simpara>
!                     Renamed special command \* to \c.  (\* still supported
!                     for backward compatibility).
!                 </simpara></listitem><listitem><simpara>
!                     Not so stingy about saving commands in history.
!                 </simpara></listitem><listitem><simpara>
!                     Allow optional filter substring for many more \d commands,
!                     including for "\d TABLENAME".
!                 </simpara></listitem><listitem><simpara>
!                     Implemented special use of substrings ending with dot.
!                     These do not just filter on the string, but mean to
!                     filter to only objects with this exact schema.
!                 </simpara></listitem><listitem><simpara>
!                     \da and \ds commands now work for HSQLDB servers, even 
!                     though HSQLDB Aliases and Sequences are not listed in the
!                     JDBC Metadata.
!                 </simpara></listitem><listitem><simpara>
!                     Improved exception handling.
!                 </simpara></listitem><listitem><simpara>
!                     Implemented Raw SQL mode, and ability for users to enter
!                     PL/SQL.
!                 </simpara></listitem><listitem><simpara>
!                     Fixed open Statement bug (HSQLDB bug #1191524).
!                 </simpara></listitem><listitem><simpara>
!                     Improved Oracle idiosyncracy work-arounds.
!                 </simpara></listitem><listitem><simpara>
!                     Added support for all non-text type fields, including BLOBs.
!                 </simpara></listitem><listitem><simpara>
!                     Can download and upload both ASCII and binary column
!                     values to/from local files.
!                 </simpara></listitem><listitem><simpara>
!                     Better display of null values occurring in result sets.
!                 </simpara></listitem><listitem><simpara>
!                     RC file functionality isolated into separate class, RCData.
!                     Other programs can now use RC files by using this class.
                  </simpara></listitem>
              </itemizedlist>
          </section>
      </section>
  
--- 33,96 ----
              control and error handling).
          </simpara><simpara>
              Some of the examples below use quoting which works exactly
!             as-is for any Bourne-compatible UNIX shell.
!             (Only line-continuation would need to be changed for C-compatible
!             UNIX shells).
              I have not yet tested these commands on Windows, and I doubt
              whether the quoting will work just like this (though it is
              possible).
              SqlTool is still a very useful tool even if you have no quoting
              capability at all.
          </simpara><simpara>
!             If you are using SqlTool from a HSQDLB distribution before
!             version 1.8.0.0 final, you should use the documentation with that
!             distribution
!             (because, for brevity, I do not here indicate changes made to
!             behavior before 1.8.0.0 final).
!             This document is now updated for the current versions of SqlTool
!             and SqlFile at the time I am writing this (versions 1.50 and
!             1.130 correspondingly, SqlFile is the class which does most of the
              work for SqlTool).
+             Therefore, if you are using a version of SqlTool or SqlFile that
+             is more than a couple revisions greater, you should find a newer
+             version of this document.
+             (The imprecision is due to content-independent revision increments
+             at build time, and the likelihood of one or two 
+             behavior-independent bug fixes after public releases).
              The startup banner will report both versions when you run SqlTool
              interactively.
          </simpara>
          <section><title>Recent changes</title>
              <simpara>This section lists changes to SqlTool since the last
                  major release of HSQLDB.
!                 For this revision of this document, this list consists of
!                 significant changes made to SqlTool AFTER the final 1.8.0.0
!                 HSQLDB release.
              </simpara>
              <itemizedlist>
                  <listitem><simpara>
!                     Fixed bug where PL "end" command was still requiring old 
!                     syntax (wrt white space).
!                     Fixed for HSQLDB v. 1.8.0.2.
                  </simpara></listitem><listitem><simpara>
!                     Fixed NPE sometimes encountered when fetching null 
!                     Timestamp values.
!                     Fixed for HSQLDB v. 1.8.0.2.
                  </simpara></listitem><listitem><simpara>
!                     Implemented new \dr command for HSQLDB and Sybase servers.
!                     Implemented \du for Sybase.
!                     Added for HSQLDB v. 1.8.0.3.
                  </simpara></listitem><listitem><simpara>
!                     Implemented CSV eXport and iMport commands \x and \m.
!                     Added for HSQLDB v. 1.8.0.3.
                  </simpara></listitem>
              </itemizedlist>
+             <simpara>
+                 When recently changed or added features (i.e, those items
+                 in the preceding list) are described in the main document 
+                 below, there is a <emphasis>Note</emphasis> at that point
+                 indicating when the feature was added or changed.
+             </simpara>
          </section>
      </section>
  
***************
*** 523,529 ****
              with their older HSQLDB database, as well as with Postgresql
              and a local application.
              <informalexample><screen>
! CLASSPATH=/path/to/hsqldbutil.jar:/home/bob/myapp/classes:/usr/local/lib/pg.jdbc3.jar
  export CLASSPATH
  java org.hsqldb.util.SqlTool urlid</screen>
              </informalexample>
--- 497,503 ----
              with their older HSQLDB database, as well as with Postgresql
              and a local application.
              <informalexample><screen>
! CLASSPATH=/path/to/hsqldbutil.jar:/home/bob/classes:/usr/local/lib/pg.jdbc3.jar
  export CLASSPATH
  java org.hsqldb.util.SqlTool urlid</screen>
              </informalexample>
***************
*** 670,680 ****
                  More detailed explanation of PL variables and the other 
                  PL features, with examples, are covered in the
                  <link linkend='pl-section' endterm='pl-title'/> section.
-                 <note>
-                     The requirement for a space after the asterisk has been
-                     removed with this version of SqlFile.
-                     It is up to you whether to put a space after the *.
-                 </note>
              </para></listitem></varlistentry>
              <varlistentry><term>Raw Mode</term><listitem><simpara>
                  The descriptions of command-types above do not apply to
--- 644,649 ----
***************
*** 757,771 ****
                      SqlTool.
                      You can use spaces and other special characters in
                      the string.
-                 </simpara>
-                     Note that this is a change in behavior from SqlFile
-                     before about version 1.100, where substring tests
-                     were case-insensitive.
-                 <simpara>
                  </simpara></important>
                  <tip><simpara>
!                     Beginning with the current version of SqlFile, filter
!                     substrings ending with "." are special.
                      If a substring ends with ".", then this means to narrow
                      the search by the exact, case-sensitive schema name
                      given.
--- 726,734 ----
                      SqlTool.
                      You can use spaces and other special characters in
                      the string.
                  </simpara></important>
                  <tip><simpara>
!                     Filter substrings ending with "." are special.
                      If a substring ends with ".", then this means to narrow
                      the search by the exact, case-sensitive schema name
                      given.
***************
*** 783,805 ****
                      functionality which cannot (portably) be reproduced by 
                      SqlTool.
                  </simpara></tip>
-                 <note><simpara>
-                 Several new \dX commands have been added with the current
-                 of SqlFile.
-                 Be aware that the meaning of the \s command has changed!
-                 </simpara></note>
                  <important><simpara>
!                 Indexes may not be searched for by 
!                 <emphasis>substring</emphasis>, only by
!                 exact target table name.
!                 So if <literal>I1</literal> is an index on table
!                 <literal>T1</literal>, then you list this index by running
!                 "\di T1".
!                 In addition, many database vendors will report on indexes 
!                 only if a target table is identified.
!                 Therefore, "\di" with no argument will fail if your database
!                 vendor does not support it.
!             </simpara></important>
              </listitem></varlistentry>
              <varlistentry><term>\d objectname [filter]</term><listitem><simpara>
                  Lists names of columns in the specified table or view.
--- 746,763 ----
                      functionality which cannot (portably) be reproduced by 
                      SqlTool.
                  </simpara></tip>
                  <important><simpara>
!                     Indexes may not be searched for by 
!                     <emphasis>substring</emphasis>, only by
!                     exact target table name.
!                     So if <literal>I1</literal> is an index on table
!                     <literal>T1</literal>, then you list this index by running
!                     "\di T1".
!                     In addition, many database vendors will report on indexes 
!                     only if a target table is identified.
!                     Therefore, "\di" with no argument will fail if your database
!                     vendor does not support it.
!                 </simpara></important>
              </listitem></varlistentry>
              <varlistentry><term>\d objectname [filter]</term><listitem><simpara>
                  Lists names of columns in the specified table or view.
***************
*** 1190,1214 ****
      java -jar $HSQLDB_HOME/lib/hsqldb.jar --sql 'SQL statement' urlid</screen>
              </informalexample>
              <note><simpara>
-                 With the current version of SqlTool, we have changed the default
-                 behavior of the <literal>--sql</literal> switch.
                  The <literal>--sql</literal> automatically implies
                  <literal>--noinput</literal>, so if you want to execute the
                  specified SQL before <emphasis>and in addition to</emphasis> an
                  interactive session (or stdin piping), then you must also give
!                 the (new) <emphasis>--stdinput</emphasis> switch.
!                 This was changed because it turns out that this is the desired
!                 behavior well over 90% of the time that you would want to use
!                 the <literal>--sql</literal> switch.
              </simpara></note> <note><simpara>
!                 Beginning with the current version of SqlTool, SqlTool will
!                 automatically add a trailing semicolon to your
                  <literal>--sql</literal> SQL.  You may still give the trailing
                  semicolon if you wish to, and you must still delimit multiple
                  SQL commands with a simicolon, of course.
-                 This was changed because in the very few sitations where you
-                 do not want to execute your SQL by a terminating semicolon, you
-                 would be better off using an SQL file.
              </simpara></note>
              </para><para>
                  Since SqlTool transmits SQL statements to the database engine
--- 1148,1163 ----
      java -jar $HSQLDB_HOME/lib/hsqldb.jar --sql 'SQL statement' urlid</screen>
              </informalexample>
              <note><simpara>
                  The <literal>--sql</literal> automatically implies
                  <literal>--noinput</literal>, so if you want to execute the
                  specified SQL before <emphasis>and in addition to</emphasis> an
                  interactive session (or stdin piping), then you must also give
!                 the <emphasis>--stdinput</emphasis> switch.
              </simpara></note> <note><simpara>
!                 SqlTool will automatically add a trailing semicolon to your
                  <literal>--sql</literal> SQL.  You may still give the trailing
                  semicolon if you wish to, and you must still delimit multiple
                  SQL commands with a simicolon, of course.
              </simpara></note>
              </para><para>
                  Since SqlTool transmits SQL statements to the database engine
***************
*** 1235,1241 ****
                  this.
              <informalexample><programlisting>
      # A shell script
!     USERCOUNT=`java -jar $HSQLDB_HOME/lib/hsqldb.jar --sql 'select count(*) from usertbl' urlid` || {
          # Handle the SqlTool error
      }
      echo "There are $USERCOUNT users registered in the database."
--- 1184,1192 ----
                  this.
              <informalexample><programlisting>
      # A shell script
!     USERCOUNT=`java -jar $HSQLDB_HOME/lib/hsqldb.jar --sql '
!         select count(*) from usertbl
!     ' urlid` || {
          # Handle the SqlTool error
      }
      echo "There are $USERCOUNT users registered in the database."
***************
*** 1295,1301 ****
                  You can execute this SQL file with a Memory Only database with 
                  a command like
              <informalexample><programlisting>
!     java -jar $HSQLDB_HOME/lib/hsqldb.jar  --sql "create user 'tomcat' password 'x'" mem path/to/hsqldb/src/org/hsqldb/sample/sample.sql</programlisting>
              </informalexample>
              </para><simpara>
                  (The <literal>--sql "create..."</literal> arguments create an
--- 1246,1254 ----
                  You can execute this SQL file with a Memory Only database with 
                  a command like
              <informalexample><programlisting>
!     java -jar $HSQLDB_HOME/lib/hsqldb.jar  --sql '
!         create user tomcat password "x"
!     ' mem path/to/hsqldb/src/org/hsqldb/sample/sample.sql</programlisting>
              </informalexample>
              </para><simpara>
                  (The <literal>--sql "create..."</literal> arguments create an
***************
*** 1531,1546 ****
                          Only you know whether errors in your SQL files can
                          safely be ignored.
                      </simpara></important>
-                     <note><simpara>
-                         In previous versions of SqlTool, this special command
-                         was "\*".  This usage is still supported, but is
-                         deprecated.  It was changed because "\*" is a very
-                         poor mnemonic.
-                         Even the author of the program had to constantly 
-                         look up whether "\* true" meant to Continue on
-                         error or to Abort upon error.
-                         Now, the "c" signifies <emphasis>Continue</emphasis>.
-                     </simpara></note>
                  </listitem></varlistentry>
              </variablelist>
          </section>
--- 1484,1489 ----
***************
*** 1589,1595 ****
                  You can use another character set by setting the system 
                  property <property>sqlfile.charset</property>, like
              <informalexample><screen>
! java -Dsqlfile.charset=UTF-8 -jar $HSQLDB_HOME/lib/hsqldb.jar urlid filepath1.sql...</screen>
              </informalexample></para><simpara>
                  You can also set this per urlid in the SqlTool configuration 
                  file.
--- 1532,1538 ----
                  You can use another character set by setting the system 
                  property <property>sqlfile.charset</property>, like
              <informalexample><screen>
! java -Dsqlfile.charset=UTF-8 -jar $HSQLDB_HOME/lib/hsqldb.jar urlid file.sql...</screen>
              </informalexample></para><simpara>
                  You can also set this per urlid in the SqlTool configuration 
                  file.
***************
*** 1695,1705 ****
              variable expansion.
              People who don't use PL don't have to worry about strings getting
              accidentally expanded.
!         </simpara> <para> <note>
!                 Users of previous versions of SqlFile should notice that
!                 whitespace is no longer required after the *
!                 (though you may use whitespace there if you wish).
!         </note> </para> <simpara>
              All other PL commands imply the "*" command, so you only need to 
              use the "*" statement if your script uses PL variables
              and it is possible that no variables may be set before-hand (and
--- 1638,1644 ----
              variable expansion.
              People who don't use PL don't have to worry about strings getting
              accidentally expanded.
!         </simpara> <simpara>
              All other PL commands imply the "*" command, so you only need to 
              use the "*" statement if your script uses PL variables
              and it is possible that no variables may be set before-hand (and
***************
*** 2205,2210 ****
--- 2144,2327 ----
      </section>
  
      <section>
+         <title>Character-Separated-Value Imports and Exports</title>
+         <note><simpara>
+             These features were added for version 1.8.0.3 of HSQLDB.
+         </simpara></note>
+         <note><simpara>
+             This feature is independent of HSQLDB 
+             <link linkend='texttables-chapter' endterm='texttables-title'/>,
+             a server-side feature of HSQLDB.
+             It makes no difference to SqlTool whether the source or target
+             table of your export/import is a memory, cache, or text table.
+             Indeed, like all features of SqlTool, it works fine with other
+             JDBC databases.
+             It works great, for example to migrate data from a table
+             of one type to a table of another type, or to another schema,
+             or to another database instance, or to another database system.
+         </simpara></note>
+         <simpara>
+             Because of common usage of the term, I call this feature
+             <emphasis>CSV</emphasis> imports and exports, even though the
+             delimiters are not constrained to single characters, but
+             may be any String.
+             Use the <literal>\x</literal> command to eXport a table to a
+             CSV file, and the <literal>\m</literal> command to iMport a
+             CSV file into a pre-existing table.
+         </simpara><simpara>
+             Just as the delimiter capability is more general than traditional
+             CSV delimiters, the export function is also more general than
+             just a table data exporter.
+             Besides the trivial generalization that you may specify a
+             view or other virtual table name in place of a table name,
+             you can alternatively export the output of any query which 
+             produces normal text output.
+             A benefit to this approach is that it allows you to export only
+             some columns of a table, and to specify a WHERE clause to narrow 
+             down the rows to be exported (or perform any other SQL 
+             transformation, mapping, join, etc.).
+             One specific use for this would be to exclude columns of
+             binary data (which can be exported by other means, such as
+             a PL loop to store binary values to files with the \bd command).
+         </simpara><simpara>
+             Note that the import command will not create a new table.
+             This is because of the impossibility of guessing appropriate
+             types and constraints based only on column names and a data
+             sampling (which is all that a CSV-importer has access to).
+             Therefore, if you wish to populate a new table, create the
+             table before running the import.
+             The import file does not need to have data for all columns of a
+             table.
+             The only required columns are those required by non-null and
+             FK constraints.
+             One specific reason to omit columns is if you want values of
+             some columns to be created automatically by column DEFAULT
+             settings, triggers, HSQLDB identity sequences, etc.
+             Another reason would be to skip binary columns.
+         </simpara>
+         <section>
+             <title>Simple CSV exports and imports using default settings</title>
+             <simpara>
+                 Even if you need to change delimiters, table names, or file
+                 names from the defaults, I suggest that you run one export
+                 and import with default settings as a practice run.
+                 A memory-only HSQLDB instance is ideal for test runs like this.
+             </simpara> <para>
+                 This command exports the table <literal>icf.projects</literal>
+                 to the file <filename>projects.csv</filename> in the current
+                 directory (where you invoked SqlTool from).
+                 By default, the output file name will be the specified source
+                 table name plus the extension <literal>.csv</literal>.
+                 <example><title>CSV Export Example</title>
+                     <screen>    SET SCHEMA icf;
+     \x projects
+ </screen>
+                 </example>
+                 We could also have run <literal>\x icf.projects</literal>
+                 (which would have created a file named 
+                 <filename>icf.projects.csv</filename>)
+                 instead of changing the session schema.
+                 In this example we have chosen to make the export file name
+                 independent of the schema to facilitate importing it into
+                 a different schema.
+             </para> <simpara>
+                 Take a look at the output file.
+                 Notice that the first line consists of column names, not
+                 data.
+                 This line is present because it will be needed if the file is
+                 to used for a CSV import.
+                 Notice the following characterstics about the export data.
+                 The column delimiter is the pipe character "|".
+                 The record delimiter is the default line delimiter character(s)
+                 for your operating system.
+                 The string used to represent database <literal>NULL</literal>s
+                 is <literal>[null]</literal>.
+                 See the next section for how to change these from their default
+                 values.
+             </simpara> <para>
+                 This command imports the data from the file
+                 <filename>projects.csv</filename> in the current
+                 directory (where you invoked SqlTool from) into the table
+                 <literal>newschema.projects</literal>.
+                 By default, the output table name will be the input filename
+                 after removing optional leading directory and trailing final
+                 extension.
+                 <example><title>CSV Import Example</title>
+                     <screen>    SET SCHEMA newschema;
+     \m projects.csv
+ </screen>
+                 </example>
+                 If the CSV file was named with the target schema, you would
+                 have skipped the <literal>SET SCHEMA</literal> command, like
+                 <literal>\m newschema.projects.csv</literal>.
+             </para>
+         </section>
+         <section>
+             <title>Specifying queries, delimiters, file names, table names,
+                 columns</title>
+             <simpara>
+                 The header line in the CSV file is required at this time.
+                 (If there is user demand, it can be made optional for
+                 exporting, but it will remain required for importing).
+             </simpara><simpara>
+                 Your export will fail if the column or record delimiter, or
+                 the null representation value occurs in the data being
+                 exported.
+                 You change these values by setting the PL variables
+                 <literal>*CSV_COL_DELIM</literal>,
+                 <literal>*CSV_ROW_DELIM</literal>,
+                 <literal>*CSV_NULL_REP</literal>.
+                 Notice that the asterisk is part of the variable names, to
+                 indicate that these variables are used by SqlTool internally.
+                 You can use the escape sequences \n, \r, and \t in the
+                 usual manner.
+                 For example, to change the column delimiter to the tab character,
+                 you would give the command
+                 <informalexample><screen>
+     * *CSV_COL_DELIM = \t</screen>
+                 </informalexample>
+             </simpara><simpara>
+                 For imports, you must always specify the source CSV file path.
+                 If you want to <emphasis>export</emphasis> to a different file 
+                 than one in the current directory named according to the source
+                 table, set the PL variable <literal>*CSV_FILEPATH</literal>,
+                 like
+                 <informalexample><screen>
+     * *CSV_FILEPATH = /tmp/dtbl.csv</screen>
+                 </informalexample>
+             </simpara><simpara>
+                 For exports, you must always specify the source table name
+                 or query.
+                 If you want to <emphasis>import</emphasis> to a table other 
+                 than that derived from
+                 the input CSV file name, set the PL variable
+                 <literal>*CSV_TABLENAME</literal>.
+                 The table name may contain a schema name prefix.
+             </simpara><simpara>
+                 At this time, you must import all columns that have data in
+                 the CSV file.
+                 If there is demand to specify an optional list of columns to
+                 import, I'll gladly add that feature.
+             </simpara><para>
+                 You can specify a query instead of a tablename with the
+                 \x command in order to filter or transform data from a table
+                 or view, or to export the output of a join, etc.
+                 You must set the PL variable <literal>*CSV_FILEPATH</literal>,
+                 as explained above (since there is no table name from which to
+                 automatically map a file name).
+                 <example>
+                     <title>CSV Export of an Arbitrary SELECT Statement</title>
+                     <screen>    * *CSV_FILEPATH = outfile.txt
+     \x SELECT entrydate, 2 * aval "Double aval", modtime from bs.dtbl</screen>
+                 </example>
+                 Note that I specified the column label alias "Double aval"
+                 so that the label for that column in the CSV file header will 
+                 not be blank.
+             </para>
+         </section>
+     </section>
+     <!--  The unit tests need to be updated!
+     <section>
          <title>Unit Testing SqlTool</title>
          <simpara>
              A unit testing framework is in place.
***************
*** 2228,2231 ****
--- 2345,2349 ----
              (The SqlTool unit tests require java 1.4).
          </simpara>
      </section>
+     -->
  </chapter>
Files misc/hsqldb/lib/hsqldb.jar and misc/build/hsqldb/lib/hsqldb.jar differ
*** misc/hsqldb/src/org/hsqldb/Column.java	Sun Oct 23 18:26:18 2005
--- misc/build/hsqldb/src/org/hsqldb/Column.java	Tue May 30 16:22:32 2006
***************
*** 932,937 ****
--- 932,941 ----
                          return ValuePool.getInt(((Number) o).intValue());
                      }
  
+                     if (o instanceof Byte || o instanceof Short) {
+                         return ValuePool.getInt(((Number) o).intValue());
+                     }
+ 
                      if (o instanceof java.lang.Number) {
                          return convertToInt(o);
                      }
***************
*** 960,965 ****
--- 964,973 ----
                          return ValuePool.getLong(((Integer) o).longValue());
                      }
  
+                     if (o instanceof Byte || o instanceof Short) {
+                         return ValuePool.getLong(((Number) o).intValue());
+                     }
+ 
                      if (o instanceof java.lang.Number) {
                          return convertToLong(o);
                      }
*** misc/hsqldb/src/org/hsqldb/CompiledStatement.java	Fri Nov  4 20:36:42 2005
--- misc/build/hsqldb/src/org/hsqldb/CompiledStatement.java	Tue May 30 16:22:32 2006
***************
*** 647,656 ****
          for (int i = 0; i < subqueries.length; i++) {
              sb.append("\n[level=").append(subqueries[i].level).append(
                  '\n').append("hasParams=").append(
!                 subqueries[i].hasParams).append('\n').append(
!                 "org.hsqldb.Select@").append(
!                 Integer.toHexString(subqueries[i].select.hashCode())).append(
!                 "]");
          }
  
          sb.append(']');
--- 647,660 ----
          for (int i = 0; i < subqueries.length; i++) {
              sb.append("\n[level=").append(subqueries[i].level).append(
                  '\n').append("hasParams=").append(
!                 subqueries[i].hasParams).append('\n');
! 
!             if (subqueries[i].select != null) {
!                 sb.append("org.hsqldb.Select@").append(
!                     Integer.toHexString(subqueries[i].select.hashCode()));
!             }
! 
!             sb.append("]");
          }
  
          sb.append(']');
*** misc/hsqldb/src/org/hsqldb/DITableInfo.java	Sun Oct 23 17:40:10 2005
--- misc/build/hsqldb/src/org/hsqldb/DITableInfo.java	Tue May 30 16:22:32 2006
***************
*** 552,568 ****
       * @return null (not implemented)
       */
      Integer getIndexCardinality(int i) {
- 
-         // TODO:     - implement cardinality for all table and index types
-         // REQUIRES: - checkpoint of cardinality for CACHED tables
-         //           - maybe extend SET TABLE <table-name> INDEX ... DDL to
-         //           include index cardinality as well as index roots?
-         // REQUIRES: completion of TODOs in Index for non-unique indices
-         // REQUIRES: setIndexInfoDirty() for DatabaseInformation and related
-         //           support  code.  That is global setDirty on every update
-         //           DML ruins DatabaseInforamation system table caching
-         //           effect
- //      return ValuePool.getInt(index.getCardinality());
          return null;
      }
  
--- 552,557 ----
***************
*** 611,619 ****
       * @param i zero-based index specifier
       * @return null (not implemented)
       */
!     Integer getIndexPages(int i) {
! 
!         // not supported yet: hsqldb does not even know what a "page" is
          return null;
      }
  
--- 600,606 ----
       * @param i zero-based index specifier
       * @return null (not implemented)
       */
!     Integer getIndexRowCardinality(int i) {
          return null;
      }
  
*** misc/hsqldb/src/org/hsqldb/Database.java	Sat Nov  5 19:15:56 2005
--- misc/build/hsqldb/src/org/hsqldb/Database.java	Tue May 30 16:22:32 2006
***************
*** 118,126 ****
   */
  public class Database {
  
!     int            databaseID;
!     private String sType;
!     private String sName;
  
  // loosecannon1@users 1.7.2 patch properties on the JDBC URL
      private HsqlProperties urlProperties;
--- 118,126 ----
   */
  public class Database {
  
!     int    databaseID;
!     String sType;
!     String sName;
  
  // loosecannon1@users 1.7.2 patch properties on the JDBC URL
      private HsqlProperties urlProperties;
*** misc/hsqldb/src/org/hsqldb/DatabaseCommandInterpreter.java	Sun Nov  6 23:01:34 2005
--- misc/build/hsqldb/src/org/hsqldb/DatabaseCommandInterpreter.java	Tue May 30 16:22:32 2006
***************
*** 1451,1477 ****
          // in certain cases; the workaround here discards such scripted column
          // lists when used in OOo
          if (tokenizer.isGetThis(Token.T_OPENBRACKET)) {
!             try {    // added line
                  HsqlArrayList list = Parser.getColumnNames(database, null,
                      tokenizer, true);
  
                  colList = new HsqlName[list.size()];
                  colList = (HsqlName[]) list.toArray(colList);
  
!                 //added lines to make sure all columns are quoted
                  if (database.isStoredFileAccess()) {
                      for (int i = 0; i < colList.length; i++) {
                          if (!colList[i].isNameQuoted) {
!                             throw (Trace.error(Trace.INVALID_IDENTIFIER));
                          }
                      }
                  }
              } catch (HsqlException e) {
  
!                 //added lines to catch unquoted column names with spaces
                  if (database.isStoredFileAccess()) {
-                     colList = null;
- 
                      while (!tokenizer.getString().equals(
                              Token.T_CLOSEBRACKET)) {}
                  } else {
--- 1451,1477 ----
          // in certain cases; the workaround here discards such scripted column
          // lists when used in OOo
          if (tokenizer.isGetThis(Token.T_OPENBRACKET)) {
!             try {
                  HsqlArrayList list = Parser.getColumnNames(database, null,
                      tokenizer, true);
  
                  colList = new HsqlName[list.size()];
                  colList = (HsqlName[]) list.toArray(colList);
  
!                 //added lines to make sure all valid columns are quoted
                  if (database.isStoredFileAccess()) {
                      for (int i = 0; i < colList.length; i++) {
                          if (!colList[i].isNameQuoted) {
!                             colList = null;
! 
!                             break;
                          }
                      }
                  }
              } catch (HsqlException e) {
  
!                 //added lines to catch unquoted names with spaces
                  if (database.isStoredFileAccess()) {
                      while (!tokenizer.getString().equals(
                              Token.T_CLOSEBRACKET)) {}
                  } else {
***************
*** 1864,1869 ****
--- 1864,1871 ----
              throw Trace.error(Trace.COLUMN_ALREADY_EXISTS, newName);
          }
  
+         t.database.schemaManager.checkColumnIsInView(t,
+                 column.columnName.name);
          session.commit();
          session.setScripting(true);
          t.renameColumn(column, newName, isquoted);
***************
*** 2466,2472 ****
      private Table newTable(int type, String name, boolean quoted,
                             HsqlName schema) throws HsqlException {
  
-         int sid = session.getId();
          HsqlName tableHsqlName = database.nameManager.newHsqlName(name,
              quoted);
  
--- 2468,2473 ----
***************
*** 2536,2543 ****
                  if (defExpr == null) {
                      String columnName = column.columnName.name;
  
!                     throw Trace.error(Trace.COLUMN_TYPE_MISMATCH,
!                                       Trace.NO_DEFAULT_VALUE_FOR_COLUMN,
                                        new Object[]{ columnName });
                  }
              }
--- 2537,2543 ----
                  if (defExpr == null) {
                      String columnName = column.columnName.name;
  
!                     throw Trace.error(Trace.NO_DEFAULT_VALUE_FOR_COLUMN,
                                        new Object[]{ columnName });
                  }
              }
***************
*** 2710,2727 ****
          return;
      }
  
      private void processCreateAlias() throws HsqlException {
  
          String alias;
          String methodFQN;
  
!         alias = tokenizer.getSimpleName();
  
          tokenizer.getThis(Token.T_FOR);
  
          methodFQN = upgradeMethodFQN(tokenizer.getSimpleName());
  
!         database.getAliasMap().put(alias, methodFQN);
      }
  
      private void processCreateIndex(boolean unique) throws HsqlException {
--- 2710,2741 ----
          return;
      }
  
+     /**
+      * If an invalid alias is encountered while processing an old script,
+      * simply discard it.
+      */
      private void processCreateAlias() throws HsqlException {
  
          String alias;
          String methodFQN;
  
!         try {
!             alias = tokenizer.getSimpleName();
!         } catch (HsqlException e) {
!             if (session.isProcessingScript()) {
!                 alias = null;
!             } else {
!                 throw e;
!             }
!         }
  
          tokenizer.getThis(Token.T_FOR);
  
          methodFQN = upgradeMethodFQN(tokenizer.getSimpleName());
  
!         if (alias != null) {
!             database.getAliasMap().put(alias, methodFQN);
!         }
      }
  
      private void processCreateIndex(boolean unique) throws HsqlException {
***************
*** 3200,3205 ****
--- 3214,3220 ----
  
          tc = processCreateFK(t, n);
  
+         checkFKColumnDefaults(t, tc);
          t.checkColumnsMatch(tc.core.mainColArray, tc.core.refTable,
                              tc.core.refColArray);
          session.commit();
*** misc/hsqldb/src/org/hsqldb/DatabaseInformationFull.java	Sat Oct 29 18:30:22 2005
--- misc/build/hsqldb/src/org/hsqldb/DatabaseInformationFull.java	Tue May 30 16:22:32 2006
***************
*** 449,457 ****
  
          // Do it.
          while (caches.hasNext()) {
!             cache      = (DataFileCache) caches.next();
!             row        = t.getEmptyRowData();
!             iFreeBytes = 0;
              row[icache_file] =
                  FileUtil.canonicalOrAbsolutePath(cache.getFileName());
              row[imax_cache_sz]    = ValuePool.getInt(cache.capacity());
--- 449,456 ----
  
          // Do it.
          while (caches.hasNext()) {
!             cache = (DataFileCache) caches.next();
!             row   = t.getEmptyRowData();
              row[icache_file] =
                  FileUtil.canonicalOrAbsolutePath(cache.getFileName());
              row[imax_cache_sz]    = ValuePool.getInt(cache.capacity());
*** misc/hsqldb/src/org/hsqldb/DatabaseInformationMain.java	Sat Oct 29 18:30:22 2005
--- misc/build/hsqldb/src/org/hsqldb/DatabaseInformationMain.java	Tue May 30 16:22:32 2006
***************
*** 1351,1357 ****
       * COLUMN_NAME      VARCHAR   simple column name
       * ASC_OR_DESC      VARCHAR   col. sort sequence: {"A" (Asc) | "D" (Desc)}
       * CARDINALITY      INTEGER   # of unique values in index (not implemented)
!      * PAGES            INTEGER   index page use (not implemented)
       * FILTER_CONDITION VARCHAR   filter condition, if any (not implemented)
       * </pre> <p>
       *
--- 1351,1357 ----
       * COLUMN_NAME      VARCHAR   simple column name
       * ASC_OR_DESC      VARCHAR   col. sort sequence: {"A" (Asc) | "D" (Desc)}
       * CARDINALITY      INTEGER   # of unique values in index (not implemented)
!      * ROW_CARDINALITY  INTEGER   # of rows in index (not implemented)
       * FILTER_CONDITION VARCHAR   filter condition, if any (not implemented)
       * </pre> <p>
       *
***************
*** 1378,1384 ****
              addColumn(t, "COLUMN_NAME", Types.VARCHAR);
              addColumn(t, "ASC_OR_DESC", Types.VARCHAR, 1, true);
              addColumn(t, "CARDINALITY", Types.INTEGER);
!             addColumn(t, "PAGES", Types.INTEGER);
              addColumn(t, "FILTER_CONDITION", Types.VARCHAR);
  
              // order: NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
--- 1378,1384 ----
              addColumn(t, "COLUMN_NAME", Types.VARCHAR);
              addColumn(t, "ASC_OR_DESC", Types.VARCHAR, 1, true);
              addColumn(t, "CARDINALITY", Types.INTEGER);
!             addColumn(t, "ROW_CARDINALITY", Types.INTEGER);
              addColumn(t, "FILTER_CONDITION", Types.VARCHAR);
  
              // order: NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
***************
*** 1404,1410 ****
          //String  columnName;
          //String  ascOrDesc;
          Integer cardinality;
!         Integer pages;
          String  filterCondition;
  
          // Intermediate holders
--- 1404,1410 ----
          //String  columnName;
          //String  ascOrDesc;
          Integer cardinality;
!         Integer rowCardinality;
          String  filterCondition;
  
          // Intermediate holders
***************
*** 1430,1436 ****
          final int icolumn_name      = 8;
          final int iasc_or_desc      = 9;
          final int icardinality      = 10;
!         final int ipages            = 11;
          final int ifilter_condition = 12;
  
          // Initialization
--- 1430,1436 ----
          final int icolumn_name      = 8;
          final int iasc_or_desc      = 9;
          final int icardinality      = 10;
!         final int irowcardinality   = 11;
          final int ifilter_condition = 12;
  
          // Initialization
***************
*** 1469,1480 ****
                      continue;
                  }
  
!                 indexName   = ti.getIndexName(i);
!                 nonUnique   = ti.isIndexNonUnique(i);
!                 cardinality = ti.getIndexCardinality(i);
!                 pages       = ti.getIndexPages(i);
!                 cols        = ti.getIndexColumns(i);
!                 indexType   = ti.getIndexType(i);
  
                  for (int k = 0; k < colCount; k++) {
                      col                    = cols[k];
--- 1469,1480 ----
                      continue;
                  }
  
!                 indexName      = ti.getIndexName(i);
!                 nonUnique      = ti.isIndexNonUnique(i);
!                 cardinality    = ti.getIndexCardinality(i);
!                 rowCardinality = ti.getIndexRowCardinality(i);
!                 cols           = ti.getIndexColumns(i);
!                 indexType      = ti.getIndexType(i);
  
                  for (int k = 0; k < colCount; k++) {
                      col                    = cols[k];
***************
*** 1490,1496 ****
                      row[icolumn_name]      = ti.getColName(col);
                      row[iasc_or_desc]      = ti.getIndexColDirection(i, col);
                      row[icardinality]      = cardinality;
!                     row[ipages]            = pages;
                      row[ifilter_condition] = filterCondition;
  
                      t.insertSys(row);
--- 1490,1496 ----
                      row[icolumn_name]      = ti.getColName(col);
                      row[iasc_or_desc]      = ti.getIndexColDirection(i, col);
                      row[icardinality]      = cardinality;
!                     row[irowcardinality]   = rowCardinality;
                      row[ifilter_condition] = filterCondition;
  
                      t.insertSys(row);
*** misc/hsqldb/src/org/hsqldb/DatabaseManager.java	Sun Nov  6 23:26:52 2005
--- misc/build/hsqldb/src/org/hsqldb/DatabaseManager.java	Tue May 30 16:22:32 2006
***************
*** 241,247 ****
              String path, HsqlProperties props) throws HsqlException {
  
          Database db;
!         Object   key = path;
          HashMap  databaseMap;
  
          if (type == DatabaseURL.S_FILE) {
--- 241,247 ----
              String path, HsqlProperties props) throws HsqlException {
  
          Database db;
!         String   key = path;
          HashMap  databaseMap;
  
          if (type == DatabaseURL.S_FILE) {
***************
*** 375,382 ****
              }
          } else if (type == DatabaseURL.S_RES) {
              databaseMap = resDatabaseMap;
!         } else {
              databaseMap = memDatabaseMap;
          }
  
          databaseIDMap.remove(dbID);
--- 375,386 ----
              }
          } else if (type == DatabaseURL.S_RES) {
              databaseMap = resDatabaseMap;
!         } else if (type == DatabaseURL.S_MEM) {
              databaseMap = memDatabaseMap;
+         } else {
+             throw (Trace.runtimeError(
+                 Trace.INTERNAL_UNSUPPORTED_OPERATION,
+                 "DatabaseManager.lookupDatabaseObject()"));
          }
  
          databaseIDMap.remove(dbID);
***************
*** 479,488 ****
  
      // converts file path to database lookup key, converting any
      // thrown exception to an HsqlException in the process
!     private static Object filePathToKey(String path) throws HsqlException {
  
          try {
!             return FileUtil.canonicalFile(path);
          } catch (Exception e) {
              throw Trace.error(Trace.FILE_IO_ERROR, e.toString());
          }
--- 483,492 ----
  
      // converts file path to database lookup key, converting any
      // thrown exception to an HsqlException in the process
!     private static String filePathToKey(String path) throws HsqlException {
  
          try {
!             return FileUtil.canonicalPath(path);
          } catch (Exception e) {
              throw Trace.error(Trace.FILE_IO_ERROR, e.toString());
          }
*** misc/hsqldb/src/org/hsqldb/Expression.java	Fri Nov  4 20:55:42 2005
--- misc/build/hsqldb/src/org/hsqldb/Expression.java	Tue May 30 16:22:32 2006
***************
*** 234,247 ****
      private int aggregateSpec = AGGREGATE_NONE;
  
      // nodes
!     private Expression eArg, eArg2;
  
!     // VALUE, VALUELIST
!     Object          valueData;
!     private HashSet hList;
!     private int     dataType;
  
      // VALUE LIST NEW
      Expression[]    valueList;
      private boolean isFixedConstantValueList;
  
--- 234,247 ----
      private int aggregateSpec = AGGREGATE_NONE;
  
      // nodes
!     Expression eArg, eArg2;
  
!     // VALUE
!     Object      valueData;
!     private int dataType;
  
      // VALUE LIST NEW
+     HashSet         hList;
      Expression[]    valueList;
      private boolean isFixedConstantValueList;
  
***************
*** 263,269 ****
      private TableFilter tableFilter;                // null if not yet resolved
      TableFilter         outerFilter;                // defined if this is part of an OUTER JOIN condition tree
  
!     //
      private int     columnIndex;
      private boolean columnQuoted;
      private int     precision;
--- 263,269 ----
      private TableFilter tableFilter;                // null if not yet resolved
      TableFilter         outerFilter;                // defined if this is part of an OUTER JOIN condition tree
  
!     // COLUMN
      private int     columnIndex;
      private boolean columnQuoted;
      private int     precision;
***************
*** 413,420 ****
       */
      Expression(String schema, String table, String column) {
  
!         schema    = schema;
!         tableName = table;
  
          if (column == null) {
              exprType = ASTERISK;
--- 413,420 ----
       */
      Expression(String schema, String table, String column) {
  
!         this.schema = schema;
!         tableName   = table;
  
          if (column == null) {
              exprType = ASTERISK;
***************
*** 1572,1578 ****
              result = result && eArg2.checkResolved(check);
          }
  
!         if (subQuery != null) {
              result = result && subQuery.select.checkResolved(check);
          }
  
--- 1572,1578 ----
              result = result && eArg2.checkResolved(check);
          }
  
!         if (subQuery != null && subQuery.select != null) {
              result = result && subQuery.select.checkResolved(check);
          }
  
*** misc/hsqldb/src/org/hsqldb/Index.java	Sun Oct 23 17:40:10 2005
--- misc/build/hsqldb/src/org/hsqldb/Index.java	Tue May 30 16:22:32 2006
***************
*** 259,265 ****
  
      Node getRoot(Session session) {
  
!         if (isTemp) {
              return session.getIndexRoot(indexName, onCommitPreserve);
          } else {
              return root;
--- 259,265 ----
  
      Node getRoot(Session session) {
  
!         if (isTemp && session != null) {
              return session.getIndexRoot(indexName, onCommitPreserve);
          } else {
              return root;
***************
*** 562,568 ****
          }
      }
  
!     public Row findRow(Session session, Row row) throws HsqlException {
  
          Node node = search(session, row);
  
--- 562,571 ----
          }
      }
  
!     /**
!      * Finds an existing row
!      */
!     Row findRow(Session session, Row row) throws HsqlException {
  
          Node node = search(session, row);
  
***************
*** 1034,1040 ****
       *
       * @throws HsqlException
       */
!     Node search(Session session, Row row) throws HsqlException {
  
          Object[] d = row.getData();
          Node     x = getRoot(session);
--- 1037,1043 ----
       *
       * @throws HsqlException
       */
!     private Node search(Session session, Row row) throws HsqlException {
  
          Object[] d = row.getData();
          Node     x = getRoot(session);
***************
*** 1211,1216 ****
--- 1214,1230 ----
          }
      }
  
+     private RowIterator getIterator(Session session, Node x) {
+ 
+         if (x == null) {
+             return emptyIterator;
+         } else {
+             IndexRowIterator it = new IndexRowIterator(session, this, x);
+ 
+             return it;
+         }
+     }
+ 
      static class IndexRowIterator implements RowIterator {
  
          Session                    session;
*** misc/hsqldb/src/org/hsqldb/Parser.java	Wed Nov  2 14:05:00 2005
--- misc/build/hsqldb/src/org/hsqldb/Parser.java	Tue May 30 16:24:12 2006
***************
*** 232,238 ****
                          &&!t.getLongNameFirst().equals(
                              table.getName().name)) {
                      throw (Trace.error(Trace.TABLE_NOT_FOUND,
!                                        t.getLongNameFirst()));
                  }
              }
  
--- 232,238 ----
                          &&!t.getLongNameFirst().equals(
                              table.getName().name)) {
                      throw (Trace.error(Trace.TABLE_NOT_FOUND,
!                                        new Object[] { t.getLongNameFirst() }));
                  }
              }
  
***************
*** 889,895 ****
                      TableFilter f = e.findTableFilter(filters);
  
                      if (f == null) {
!                         throw Trace.error(Trace.TABLE_NOT_FOUND, tablename);
                      }
  
                      pos      = addFilterColumns(f, vcolumn, pos);
--- 889,895 ----
                      TableFilter f = e.findTableFilter(filters);
  
                      if (f == null) {
!                         throw Trace.error(Trace.TABLE_NOT_FOUND, new Object[]{ tablename });
                      }
  
                      pos      = addFilterColumns(f, vcolumn, pos);
***************
*** 2330,2335 ****
--- 2330,2337 ----
              } else {
                  iToken = Expression.COLUMN;
              }
+         } else if (tokenizer.wasParameter()) {
+             iToken = Expression.PARAM;
          } else if (sToken.length() == 0) {
              iToken = Expression.END;
          } else {
***************
*** 2789,2795 ****
  
              if (tablename != null
                      &&!tableFilter.getName().equals(tablename)) {
!                 throw Trace.error(Trace.TABLE_NOT_FOUND);
              }
  
              tokenizer.getThis(Token.T_EQUALS);
--- 2791,2797 ----
  
              if (tablename != null
                      &&!tableFilter.getName().equals(tablename)) {
!                 throw Trace.error(Trace.TABLE_NOT_FOUND, new Object[]{ tablename });
              }
  
              tokenizer.getThis(Token.T_EQUALS);
*** misc/hsqldb/src/org/hsqldb/Row.java	Sun Oct 23 17:40:16 2005
--- misc/build/hsqldb/src/org/hsqldb/Row.java	Tue May 30 16:22:32 2006
***************
*** 95,101 ****
      /**
       *  Default constructor used only in subclasses.
       */
!     Row() {}
  
      /**
       *  Constructor for MEMORY table Row. The result is a Row with Nodes that
--- 95,101 ----
      /**
       *  Default constructor used only in subclasses.
       */
!     protected Row() {}
  
      /**
       *  Constructor for MEMORY table Row. The result is a Row with Nodes that
*** misc/hsqldb/src/org/hsqldb/SchemaManager.java	Sun Oct 23 17:40:16 2005
--- misc/build/hsqldb/src/org/hsqldb/SchemaManager.java	Tue May 30 16:24:12 2006
***************
*** 350,356 ****
  
          if (t == null) {
              if (!"INFORMATION_SCHEMA".equals(schema)) {
!                 throw Trace.error(Trace.TABLE_NOT_FOUND);
              }
  
              if (database.dbInfo != null) {
--- 350,356 ----
  
          if (t == null) {
              if (!"INFORMATION_SCHEMA".equals(schema)) {
!                 throw Trace.error(Trace.TABLE_NOT_FOUND, new Object[]{ name });
              }
  
              if (database.dbInfo != null) {
***************
*** 359,365 ****
          }
  
          if (t == null) {
!             throw Trace.error(Trace.TABLE_NOT_FOUND, name);
          }
  
          return t;
--- 359,365 ----
          }
  
          if (t == null) {
!             throw Trace.error(Trace.TABLE_NOT_FOUND, new Object[]{ name });
          }
  
          return t;
***************
*** 377,383 ****
          Table t = findUserTable(session, name, schema);
  
          if (t == null) {
!             throw Trace.error(Trace.TABLE_NOT_FOUND, name);
          }
  
          return t;
--- 377,383 ----
          Table t = findUserTable(session, name, schema);
  
          if (t == null) {
!             throw Trace.error(Trace.TABLE_NOT_FOUND, new Object[]{ name });
          }
  
          return t;
***************
*** 718,724 ****
                  return;
              } else {
                  throw Trace.error(isView ? Trace.VIEW_NOT_FOUND
!                                          : Trace.TABLE_NOT_FOUND, name);
              }
          }
  
--- 718,724 ----
                  return;
              } else {
                  throw Trace.error(isView ? Trace.VIEW_NOT_FOUND
!                                          : Trace.TABLE_NOT_FOUND, new Object[]{ name });
              }
          }
  
***************
*** 728,734 ****
  // ft - concurrent
          session.commit();
          dropTable(table, cascade);
!         session.setScripting(!table.isTemp());
      }
  
      void dropTable(Table table, boolean cascade) throws HsqlException {
--- 728,734 ----
  // ft - concurrent
          session.commit();
          dropTable(table, cascade);
!         session.setScripting(true);
      }
  
      void dropTable(Table table, boolean cascade) throws HsqlException {
*** misc/hsqldb/src/org/hsqldb/Session.java	Fri Nov  4 20:36:52 2005
--- misc/build/hsqldb/src/org/hsqldb/Session.java	Tue May 30 16:22:33 2006
***************
*** 119,125 ****
      //
      Database          database;
      private User      user;
!     HsqlArrayList     transactionList;
      private boolean   isNestedTransaction;
      private int       nestedOldTransIndex;
      int               isolationMode = SessionInterface.TX_READ_COMMITTED;
--- 119,125 ----
      //
      Database          database;
      private User      user;
!     HsqlArrayList     rowActionList;
      private boolean   isNestedTransaction;
      private int       nestedOldTransIndex;
      int               isolationMode = SessionInterface.TX_READ_COMMITTED;
***************
*** 172,178 ****
          sessionId                 = id;
          database                  = db;
          this.user                 = user;
!         transactionList           = new HsqlArrayList(true);
          savepoints                = new HashMappedList(4);
          isAutoCommit              = autocommit;
          isReadOnly                = readonly;
--- 172,178 ----
          sessionId                 = id;
          database                  = db;
          this.user                 = user;
!         rowActionList             = new HsqlArrayList(true);
          savepoints                = new HashMappedList(4);
          isAutoCommit              = autocommit;
          isReadOnly                = readonly;
***************
*** 228,234 ****
  
              database                  = null;
              user                      = null;
!             transactionList           = null;
              savepoints                = null;
              intConnection             = null;
              compiledStatementExecutor = null;
--- 228,234 ----
  
              database                  = null;
              user                      = null;
!             rowActionList             = null;
              savepoints                = null;
              intConnection             = null;
              compiledStatementExecutor = null;
***************
*** 386,398 ****
       * @param  row the deleted row
       * @throws  HsqlException
       */
!     boolean addTransactionDelete(Table table, Row row) throws HsqlException {
  
          if (!isAutoCommit || isNestedTransaction) {
              Transaction t = new Transaction(true, table, row,
                                              actionTimestamp);
  
!             transactionList.add(t);
              database.txManager.addTransaction(this, t);
  
              return true;
--- 386,398 ----
       * @param  row the deleted row
       * @throws  HsqlException
       */
!     boolean addDeleteAction(Table table, Row row) throws HsqlException {
  
          if (!isAutoCommit || isNestedTransaction) {
              Transaction t = new Transaction(true, table, row,
                                              actionTimestamp);
  
!             rowActionList.add(t);
              database.txManager.addTransaction(this, t);
  
              return true;
***************
*** 410,422 ****
       * @param  row the inserted row
       * @throws  HsqlException
       */
!     boolean addTransactionInsert(Table table, Row row) throws HsqlException {
  
          if (!isAutoCommit || isNestedTransaction) {
              Transaction t = new Transaction(false, table, row,
                                              actionTimestamp);
  
!             transactionList.add(t);
              database.txManager.addTransaction(this, t);
  
              return true;
--- 410,422 ----
       * @param  row the inserted row
       * @throws  HsqlException
       */
!     boolean addInsertAction(Table table, Row row) throws HsqlException {
  
          if (!isAutoCommit || isNestedTransaction) {
              Transaction t = new Transaction(false, table, row,
                                              actionTimestamp);
  
!             rowActionList.add(t);
              database.txManager.addTransaction(this, t);
  
              return true;
***************
*** 469,475 ****
          }
  
          synchronized (database) {
!             if (!transactionList.isEmpty()) {
                  try {
                      database.logger.writeCommitStatement(this);
                  } catch (HsqlException e) {}
--- 469,475 ----
          }
  
          synchronized (database) {
!             if (!rowActionList.isEmpty()) {
                  try {
                      database.logger.writeCommitStatement(this);
                  } catch (HsqlException e) {}
***************
*** 492,498 ****
          }
  
          synchronized (database) {
!             if (transactionList.size() != 0) {
                  try {
                      database.logger.writeToLog(this, Token.T_ROLLBACK);
                  } catch (HsqlException e) {}
--- 492,498 ----
          }
  
          synchronized (database) {
!             if (rowActionList.size() != 0) {
                  try {
                      database.logger.writeToLog(this, Token.T_ROLLBACK);
                  } catch (HsqlException e) {}
***************
*** 520,526 ****
      void savepoint(String name) throws HsqlException {
  
          savepoints.remove(name);
!         savepoints.add(name, ValuePool.getInt(transactionList.size()));
  
          try {
              database.logger.writeToLog(this, Token.T_SAVEPOINT + " " + name);
--- 520,526 ----
      void savepoint(String name) throws HsqlException {
  
          savepoints.remove(name);
!         savepoints.add(name, ValuePool.getInt(rowActionList.size()));
  
          try {
              database.logger.writeToLog(this, Token.T_SAVEPOINT + " " + name);
***************
*** 580,586 ****
              Trace.doAssert(false, "beginNestedTransaction");
          }
  
!         nestedOldTransIndex = transactionList.size();
          isNestedTransaction = true;
      }
  
--- 580,586 ----
              Trace.doAssert(false, "beginNestedTransaction");
          }
  
!         nestedOldTransIndex = rowActionList.size();
          isNestedTransaction = true;
      }
  
***************
*** 731,737 ****
       * @return the current value
       */
      int getTransactionSize() {
!         return transactionList.size();
      }
  
      /**
--- 731,737 ----
       * @return the current value
       */
      int getTransactionSize() {
!         return rowActionList.size();
      }
  
      /**
*** misc/hsqldb/src/org/hsqldb/Table.java	Sat Nov  5 19:09:56 2005
--- misc/build/hsqldb/src/org/hsqldb/Table.java	Tue May 30 16:24:12 2006
***************
*** 355,361 ****
       */
      protected void setDataSource(Session s, String source, boolean isDesc,
                                   boolean newFile) throws HsqlException {
!         throw (Trace.error(Trace.TABLE_NOT_FOUND));
      }
  
      /**
--- 355,361 ----
       */
      protected void setDataSource(Session s, String source, boolean isDesc,
                                   boolean newFile) throws HsqlException {
!         throw (Trace.error(Trace.TABLE_NOT_FOUND, new Object[]{ tableName.name }));
      }
  
      /**
***************
*** 1097,1103 ****
       * the first non-unique index. NULL if there is no user-defined index.
       *
       */
!     private void setBestRowIdentifiers() {
  
          int[]   briCols      = null;
          int     briColsCount = 0;
--- 1097,1103 ----
       * the first non-unique index. NULL if there is no user-defined index.
       *
       */
!     void setBestRowIdentifiers() {
  
          int[]   briCols      = null;
          int     briColsCount = 0;
***************
*** 1333,1339 ****
       */
      public void setIndexRoots(int[] roots) throws HsqlException {
  
!         Trace.check(isCached, Trace.TABLE_NOT_FOUND);
  
          for (int i = 0; i < getIndexCount(); i++) {
              int p = roots[i];
--- 1333,1339 ----
       */
      public void setIndexRoots(int[] roots) throws HsqlException {
  
!         Trace.check(isCached, Trace.TABLE_NOT_FOUND, new Object[]{ tableName.name });
  
          for (int i = 0; i < getIndexCount(); i++) {
              int p = roots[i];
***************
*** 1359,1365 ****
      void setIndexRoots(String s) throws HsqlException {
  
          // the user may try to set this; this is not only internal problem
!         Trace.check(isCached, Trace.TABLE_NOT_FOUND);
  
          Tokenizer t     = new Tokenizer(s);
          int[]     roots = new int[getIndexCount()];
--- 1359,1365 ----
      void setIndexRoots(String s) throws HsqlException {
  
          // the user may try to set this; this is not only internal problem
!         Trace.check(isCached, Trace.TABLE_NOT_FOUND, new Object[]{ tableName.name });
  
          Tokenizer t     = new Tokenizer(s);
          int[]     roots = new int[getIndexCount()];
***************
*** 1709,1715 ****
      /**
       * Returns empty Object array for a new row.
       */
!     Object[] getEmptyRowData() {
          return new Object[columnCount];
      }
  
--- 1709,1715 ----
      /**
       * Returns empty Object array for a new row.
       */
!     public Object[] getEmptyRowData() {
          return new Object[columnCount];
      }
  
***************
*** 1910,1916 ****
          indexRow(session, row);
  
          if (session != null) {
!             session.addTransactionInsert(this, row);
          }
  
          if (isLogged) {
--- 1910,1916 ----
          indexRow(session, row);
  
          if (session != null) {
!             session.addInsertAction(this, row);
          }
  
          if (isLogged) {
***************
*** 1930,1936 ****
          indexRow(session, r);
  
          if (session != null) {
!             session.addTransactionInsert(this, r);
          }
      }
  
--- 1930,1936 ----
          indexRow(session, r);
  
          if (session != null) {
!             session.addInsertAction(this, r);
          }
      }
  
***************
*** 2814,2820 ****
          row.delete();
  
          if (session != null) {
!             boolean tx = session.addTransactionDelete(this, row);
          }
  
          if (log && isLogged) {
--- 2814,2820 ----
          row.delete();
  
          if (session != null) {
!             session.addDeleteAction(this, row);
          }
  
          if (log && isLogged) {
***************
*** 2896,2902 ****
          row.delete();
  
          if (session != null) {
!             session.addTransactionDelete(this, row);
          }
      }
  
--- 2896,2902 ----
          row.delete();
  
          if (session != null) {
!             session.addDeleteAction(this, row);
          }
      }
  
*** misc/hsqldb/src/org/hsqldb/Tokenizer.java	Fri Nov  4 21:20:40 2005
--- misc/build/hsqldb/src/org/hsqldb/Tokenizer.java	Fri Jun  9 14:21:37 2006
***************
*** 98,122 ****
   */
  public class Tokenizer {
  
!     private static final int NO_TYPE   = 0,
!                              NAME      = 1,
!                              LONG_NAME = 2,
!                              SPECIAL   = 3,
!                              NUMBER    = 4,
!                              FLOAT     = 5,
!                              STRING    = 6,
!                              LONG      = 7,
!                              DECIMAL   = 8,
!                              BOOLEAN   = 9,
!                              DATE      = 10,
!                              TIME      = 11,
!                              TIMESTAMP = 12,
!                              NULL      = 13;
  
      // used only internally
!     private static final int QUOTED_IDENTIFIER = 14,
!                              REMARK_LINE       = 15,
!                              REMARK            = 16;
      private String           sCommand;
      private int              iLength;
      private int              iIndex;
--- 98,123 ----
   */
  public class Tokenizer {
  
!     private static final int NO_TYPE     = 0,
!                              NAME        = 1,
!                              LONG_NAME   = 2,
!                              SPECIAL     = 3,
!                              NUMBER      = 4,
!                              FLOAT       = 5,
!                              STRING      = 6,
!                              LONG        = 7,
!                              DECIMAL     = 8,
!                              BOOLEAN     = 9,
!                              DATE        = 10,
!                              TIME        = 11,
!                              TIMESTAMP   = 12,
!                              NULL        = 13,
!                              NAMED_PARAM = 14;
  
      // used only internally
!     private static final int QUOTED_IDENTIFIER = 15,
!                              REMARK_LINE       = 16,
!                              REMARK            = 17;
      private String           sCommand;
      private int              iLength;
      private int              iIndex;
***************
*** 342,347 ****
--- 343,359 ----
          return !Token.isKeyword(sToken);
      }
  
+     /** checks whether the previously obtained token was a (named) parameter
+      *
+      * @return true if the previously obtained token was a (named) parameter
+      */
+     boolean wasParameter() throws HsqlException {
+ 
+         Trace.doAssert(!bWait, "Querying state when in Wait mode");
+ 
+         return ( iType == NAMED_PARAM );
+     }
+ 
      /**
       * Name means all quoted and unquoted identifiers plus any word not in the
       * hKeyword list.
***************
*** 386,400 ****
  
      boolean wasSimpleToken() throws HsqlException {
          return iType != QUOTED_IDENTIFIER && iType != LONG_NAME
!                && iType != STRING;
      }
  
      String getSimpleToken() throws HsqlException {
  
          getToken();
  
!         if (iType == QUOTED_IDENTIFIER || iType == LONG_NAME
!                 || iType == STRING) {
              String token = iType == LONG_NAME ? sLongNameFirst
                                                : sToken;
  
--- 398,411 ----
  
      boolean wasSimpleToken() throws HsqlException {
          return iType != QUOTED_IDENTIFIER && iType != LONG_NAME
!                && iType != STRING && iType != NAMED_PARAM;
      }
  
      String getSimpleToken() throws HsqlException {
  
          getToken();
  
!         if (!wasSimpleToken()) {
              String token = iType == LONG_NAME ? sLongNameFirst
                                                : sToken;
  
***************
*** 485,491 ****
  
          getToken();
  
!         if (sToken.equals(Token.T_MINUS)) {
              minus = true;
  
              getToken();
--- 496,502 ----
  
          getToken();
  
!         if (sToken.equals("-")) {
              minus = true;
  
              getToken();
***************
*** 835,840 ****
--- 846,861 ----
  
                      return;
  
+                 case ':' :
+                     Trace.check(++iIndex < iLength, Trace.UNEXPECTED_END_OF_COMMAND);
+ 
+                     c = sCommand.charAt(iIndex);
+                     Trace.check(Character.isJavaIdentifierStart(c), Trace.INVALID_IDENTIFIER, ":" + c);
+ 
+                     iType = NAMED_PARAM;
+ 
+                     break;
+ 
                  case '\"' :
                      lastTokenQuotedID = true;
                      iType             = QUOTED_IDENTIFIER;
***************
*** 916,921 ****
--- 937,943 ----
  
              switch (iType) {
  
+                 case NAMED_PARAM :
                  case NAME :
                      if (Character.isJavaIdentifierPart(c)) {
                          break;
***************
*** 925,930 ****
--- 947,956 ----
                      sToken = sCommand.substring(start, iIndex).toUpperCase(
                          Locale.ENGLISH);
  
+                     // the following only for NAME, not for NAMED_PARAM
+                     if ( iType == NAMED_PARAM )
+                         return;
+ 
                      if (c == '.') {
                          typeLongNameFirst = iType;
                          sLongNameFirst    = sToken;
*** misc/hsqldb/src/org/hsqldb/Trace.java	Fri Nov  4 20:36:56 2005
--- misc/build/hsqldb/src/org/hsqldb/Trace.java	Fri Jun  9 14:20:23 2006
***************
*** 111,371 ****
          null);
  
      //
!     public static final int DATABASE_ALREADY_IN_USE                 = 1,
!                             CONNECTION_IS_CLOSED                    = 2,
!                             CONNECTION_IS_BROKEN                    = 3,
!                             DATABASE_IS_SHUTDOWN                    = 4,
!                             COLUMN_COUNT_DOES_NOT_MATCH             = 5,
!                             DIVISION_BY_ZERO                        = 6,
!                             INVALID_ESCAPE                          = 7,
!                             INTEGRITY_CONSTRAINT_VIOLATION          = 8,
!                             VIOLATION_OF_UNIQUE_INDEX               = 9,
!                             TRY_TO_INSERT_NULL                      = 10,
!                             UNEXPECTED_TOKEN                        = 11,
!                             UNEXPECTED_END_OF_COMMAND               = 12,
!                             UNKNOWN_FUNCTION                        = 13,
!                             NEED_AGGREGATE                          = 14,
!                             SUM_OF_NON_NUMERIC                      = 15,
!                             WRONG_DATA_TYPE                         = 16,
!                             CARDINALITY_VIOLATION_NO_SUBCLASS       = 17,
!                             SERIALIZATION_FAILURE                   = 18,
!                             TRANSFER_CORRUPTED                      = 19,
!                             FUNCTION_NOT_SUPPORTED                  = 20,
!                             TABLE_ALREADY_EXISTS                    = 21,
!                             TABLE_NOT_FOUND                         = 22,
!                             INDEX_ALREADY_EXISTS                    = 23,
!                             SECOND_PRIMARY_KEY                      = 24,
!                             DROP_PRIMARY_KEY                        = 25,
!                             INDEX_NOT_FOUND                         = 26,
!                             COLUMN_ALREADY_EXISTS                   = 27,
!                             COLUMN_NOT_FOUND                        = 28,
!                             FILE_IO_ERROR                           = 29,
!                             WRONG_DATABASE_FILE_VERSION             = 30,
!                             DATABASE_IS_READONLY                    = 31,
!                             DATA_IS_READONLY                        = 32,
!                             ACCESS_IS_DENIED                        = 33,
!                             INPUTSTREAM_ERROR                       = 34,
!                             NO_DATA_IS_AVAILABLE                    = 35,
!                             USER_ALREADY_EXISTS                     = 36,
!                             USER_NOT_FOUND                          = 37,
!                             ASSERT_FAILED                           = 38,
!                             EXTERNAL_STOP                           = 39,
!                             GENERAL_ERROR                           = 40,
!                             WRONG_OUT_PARAMETER                     = 41,
!                             FUNCTION_NOT_FOUND                      = 42,
!                             TRIGGER_NOT_FOUND                       = 43,
!                             SAVEPOINT_NOT_FOUND                     = 44,
!                             LABEL_REQUIRED                          = 45,
!                             WRONG_DEFAULT_CLAUSE                    = 46,
!                             FOREIGN_KEY_NOT_ALLOWED                 = 47,
!                             UNKNOWN_DATA_SOURCE                     = 48,
!                             BAD_INDEX_CONSTRAINT_NAME               = 49,
!                             DROP_FK_INDEX                           = 50,
!                             RESULTSET_FORWARD_ONLY                  = 51,
!                             VIEW_ALREADY_EXISTS                     = 52,
!                             VIEW_NOT_FOUND                          = 53,
!                             NOT_USED_54                             = 54,
!                             NOT_A_TABLE                             = 55,
!                             SYSTEM_INDEX                            = 56,
!                             COLUMN_TYPE_MISMATCH                    = 57,
!                             BAD_ADD_COLUMN_DEFINITION               = 58,
!                             DROP_SYSTEM_CONSTRAINT                  = 59,
!                             CONSTRAINT_ALREADY_EXISTS               = 60,
!                             CONSTRAINT_NOT_FOUND                    = 61,
!                             INVALID_JDBC_ARGUMENT                   = 62,
!                             DATABASE_IS_MEMORY_ONLY                 = 63,
!                             OUTER_JOIN_CONDITION                    = 64,
!                             NUMERIC_VALUE_OUT_OF_RANGE              = 65,
!                             MISSING_SOFTWARE_MODULE                 = 66,
!                             NOT_IN_AGGREGATE_OR_GROUP_BY            = 67,
!                             INVALID_GROUP_BY                        = 68,
!                             INVALID_HAVING                          = 69,
!                             INVALID_ORDER_BY                        = 70,
!                             INVALID_ORDER_BY_IN_DISTINCT_SELECT     = 71,
!                             OUT_OF_MEMORY                           = 72,
!                             OPERATION_NOT_SUPPORTED                 = 73,
!                             INVALID_IDENTIFIER                      = 74,
!                             TEXT_TABLE_SOURCE                       = 75,
!                             TEXT_FILE                               = 76,
!                             NOT_USED_77                             = 77,
!                             ERROR_IN_SCRIPT_FILE                    = 78,
!                             NULL_IN_VALUE_LIST                      = 79,
!                             SOCKET_ERROR                            = 80,
!                             INVALID_CHARACTER_ENCODING              = 81,
!                             NOT_USED_82                             = 82,
!                             NOT_USED_83                             = 83,
!                             NOT_USED_84                             = 84,
!                             UNEXPECTED_EXCEPTION                    = 85,
!                             NOT_USED_86                             = 86,
!                             NOT_USED_87                             = 87,
!                             NOT_USED_88                             = 88,
!                             NOT_USED_89                             = 89,
!                             NOT_USED_90                             = 90,
!                             NOT_USED_91                             = 91,
!                             NOT_USED_92                             = 92,
!                             NOT_USED_93                             = 93,
!                             DATABASE_NOT_EXISTS                     = 94,
!                             INVALID_CONVERSION                      = 95,
!                             ERROR_IN_BINARY_SCRIPT_1                = 96,
!                             ERROR_IN_BINARY_SCRIPT_2                = 97,
!                             GENERAL_IO_ERROR                        = 98,
!                             EXPRESSION_NOT_SUPPORTED                = 99,
!                             Constraint_violation                    = 100,
!                             Database_dropTable                      = 101,
!                             ERROR_IN_CONSTRAINT_COLUMN_LIST         = 102,
!                             TABLE_HAS_NO_PRIMARY_KEY                = 103,
!                             VIOLATION_OF_UNIQUE_CONSTRAINT          = 104,
!                             NO_DEFAULT_VALUE_FOR_COLUMN             = 105,
!                             NULL_VALUE_AS_BOOLEAN                   = 106,
!                             DatabaseManager_getDatabase             = 107,
!                             NOT_USED_108                            = 108,
!                             NOT_USED_109                            = 109,
!                             NOT_USED_110                            = 110,
!                             NOT_USED_111                            = 111,
!                             NOT_USED_112                            = 112,
!                             DatabaseScriptReader_readDDL            = 113,
!                             DatabaseScriptReader_readExistingData   = 114,
!                             Message_Pair                            = 115,
!                             LOAD_SAVE_PROPERTIES                    = 116,
!                             INVALID_TRANSACTION_STATE_NO_SUBCLASS   = 117,
!                             JDBC_INVALID_BRI_SCOPE                  = 118,
!                             JDBC_NO_RESULT_SET_METADATA             = 119,
!                             JDBC_NO_RESULT_SET                      = 120,
!                             MISSING_CLOSEBRACKET                    = 121,
!                             ITSNS_OVERWRITE                         = 122,
!                             COLUMN_IS_IN_INDEX                      = 123,
!                             STRING_DATA_TRUNCATION                  = 124,
!                             QUOTED_IDENTIFIER_REQUIRED              = 125,
!                             STATEMENT_IS_CLOSED                     = 126,
!                             DatabaseRowInput_skipBytes              = 127,
!                             DatabaseRowInput_readLine               = 128,
!                             DATA_FILE_ERROR                         = 129,
!                             NOT_USED_130                            = 130,
!                             HsqlDateTime_null_string                = 131,
!                             NOT_USED_132                            = 132,
!                             HsqlDateTime_null_date                  = 133,
!                             NOT_USED_134                            = 134,
!                             HsqlProperties_load                     = 135,
!                             HsqlSocketFactorySecure_verify          = 136,
!                             HsqlSocketFactorySecure_verify2         = 137,
!                             jdbcConnection_nativeSQL                = 138,
!                             HsqlSocketFactorySecure_verify3         = 139,
!                             NOT_USED_140                            = 140,
!                             NOT_USED_141                            = 141,
!                             jdbcStatement_executeUpdate             = 142,
!                             LockFile_checkHeartbeat                 = 143,
!                             LockFile_checkHeartbeat2                = 144,
!                             TEXT_STRING_HAS_NEWLINE                 = 145,
!                             Result_Result                           = 146,
!                             SERVER_NO_DATABASE                      = 147,
!                             Server_openServerSocket                 = 148,
!                             Server_openServerSocket2                = 149,
!                             TEXT_TABLE_HEADER                       = 150,
!                             NOT_USED_151                            = 151,
!                             TextDatabaseRowOutput_writeIntData      = 152,
!                             INVALID_LIMIT                           = 153,
!                             JDBC_STATEMENT_NOT_ROW_COUNT            = 154,
!                             JDBC_STATEMENT_NOT_RESULTSET            = 155,
!                             AMBIGUOUS_COLUMN_REFERENCE              = 156,
!                             CHECK_CONSTRAINT_VIOLATION              = 157,
!                             JDBC_RESULTSET_IS_CLOSED                = 158,
!                             SINGLE_COLUMN_EXPECTED                  = 159,
!                             TOKEN_REQUIRED                          = 160,
!                             NOT_USED_161                            = 161,
!                             NOT_USED_162                            = 162,
!                             ORDER_LIMIT_REQUIRED                    = 163,
!                             TRIGGER_ALREADY_EXISTS                  = 164,
!                             ASSERT_DIRECT_EXEC_WITH_PARAM           = 165,
!                             NOT_USED_166                            = 166,
!                             Expression_compareValues                = 167,
!                             INVALID_LIMIT_EXPRESSION                = 168,
!                             INVALID_TOP_EXPRESSION                  = 169,
!                             SQL_CONSTRAINT_REQUIRED                 = 170,
!                             TableWorks_dropConstraint               = 171,
!                             TEXT_TABLE_SOURCE_FILENAME              = 172,
!                             TEXT_TABLE_SOURCE_VALUE_MISSING         = 173,
!                             TEXT_TABLE_SOURCE_SEPARATOR             = 174,
!                             UNSUPPORTED_PARAM_CLASS                 = 175,
!                             JDBC_NULL_STREAM                        = 176,
!                             INTEGRITY_CONSTRAINT_VIOLATION_NOPARENT = 177,
!                             NOT_USED_178                            = 178,
!                             NOT_USED_179                            = 179,
!                             QuotedTextDatabaseRowInput_getField     = 180,
!                             QuotedTextDatabaseRowInput_getField2    = 181,
!                             TextDatabaseRowInput_getField           = 182,
!                             TextDatabaseRowInput_getField2          = 183,
!                             TextDatabaseRowInput_getField3          = 184,
!                             Parser_ambiguous_between1               = 185,
!                             SEQUENCE_REFERENCED_BY_VIEW             = 186,
!                             NOT_USED_187                            = 187,
!                             TextCache_openning_file_error           = 188,
!                             TextCache_closing_file_error            = 189,
!                             TextCache_purging_file_error            = 190,
!                             SEQUENCE_NOT_FOUND                      = 191,
!                             SEQUENCE_ALREADY_EXISTS                 = 192,
!                             TABLE_REFERENCED_CONSTRAINT             = 193,
!                             TABLE_REFERENCED_VIEW                   = 194,
!                             NOT_USED_195                            = 195,
!                             TEXT_SOURCE_EXISTS                      = 196,
!                             COLUMN_IS_REFERENCED                    = 197,
!                             FUNCTION_CALL_ERROR                     = 198,
!                             TRIGGERED_DATA_CHANGE                   = 199,
!                             INVALID_FUNCTION_ARGUMENT               = 200,
!                             INTERNAL_UNSUPPORTED_OPERATION          = 201,
!                             NOT_USED_202                            = 202,
!                             INVALID_PREPARED_STATEMENT              = 203,
!                             CREATE_TRIGGER_COMMAND_1                = 204,
!                             TRIGGER_FUNCTION_CLASS_NOT_FOUND        = 205,
!                             NOT_USED_206                            = 206,
!                             NOT_USED_207                            = 207,
!                             INVALID_COLLATION_NAME_NO_SUBCLASS      = 208,
!                             DataFileCache_makeRow                   = 209,
!                             DataFileCache_open                      = 210,
!                             DataFileCache_close                     = 211,
!                             Expression_resolveTypes1                = 212,
!                             Expression_resolveTypes2                = 213,
!                             Expression_resolveTypes3                = 214,
!                             Expression_resolveTypes4                = 215,
!                             UNRESOLVED_PARAMETER_TYPE               = 216,
!                             Expression_resolveTypes6                = 217,
!                             Expression_resolveTypes7                = 218,
!                             Expression_resolveTypeForLike           = 219,
!                             NOT_USED_220                            = 220,
!                             Expression_resolveTypeForIn2            = 221,
!                             Session_execute                         = 222,
!                             NOT_USED_223                            = 223,
!                             NOT_USED_224                            = 224,
!                             DATA_FILE_IS_FULL                       = 225,
!                             THREE_PART_IDENTIFIER                   = 226,
!                             INVALID_SCHEMA_NAME_NO_SUBCLASS         = 227,
!                             DEPENDENT_DATABASE_OBJECT_EXISTS        = 228,
!                             NO_SUCH_ROLE_GRANT                      = 229,
!                             NO_SUCH_ROLE_REVOKE                     = 230,
!                             NONMOD_ACCOUNT                          = 231,
!                             NO_SUCH_GRANTEE                         = 232,
!                             MISSING_SYSAUTH                         = 233,
!                             MISSING_GRANTEE                         = 234,
!                             CHANGE_GRANTEE                          = 235,
!                             NULL_NAME                               = 236,
!                             ILLEGAL_ROLE_NAME                       = 237,
!                             ROLE_ALREADY_EXISTS                     = 238,
!                             NO_SUCH_ROLE                            = 239,
!                             MISSING_ROLEMANAGER                     = 240,
!                             GRANTEE_ALREADY_EXISTS                  = 241,
!                             MISSING_PUBLIC_GRANTEE                  = 242,
!                             NONMOD_GRANTEE                          = 243,
!                             CIRCULAR_GRANT                          = 244,
!                             ALREADY_HAVE_ROLE                       = 245,
!                             DONT_HAVE_ROLE                          = 246,
!                             NOT_USED_247                            = 247,
!                             RETRIEVE_NEST_ROLE_FAIL                 = 248,
!                             NO_SUCH_RIGHT                           = 249,
!                             IN_SCHEMA_DEFINITION                    = 250,
!                             PRIMARY_KEY_NOT_ALLOWED                 = 251,
!                             COLUMN_IS_IN_CONSTRAINT                 = 252,
!                             COLUMN_SIZE_REQUIRED                    = 253,
!                             INVALID_SIZE_PRECISION                  = 254,
!                             LAST_ERROR_HANDLE                       = 255;
  
      //
      static String MESSAGE_TAG = "$$";
--- 111,374 ----
          null);
  
      //
!     public static final int
! 
!     //
!     DATABASE_ALREADY_IN_USE                 = 1,
!     CONNECTION_IS_CLOSED                    = 2,
!     CONNECTION_IS_BROKEN                    = 3,
!     DATABASE_IS_SHUTDOWN                    = 4,
!     COLUMN_COUNT_DOES_NOT_MATCH             = 5,
!     DIVISION_BY_ZERO                        = 6,
!     INVALID_ESCAPE                          = 7,
!     INTEGRITY_CONSTRAINT_VIOLATION          = 8,
!     VIOLATION_OF_UNIQUE_INDEX               = 9,
!     TRY_TO_INSERT_NULL                      = 10,
!     UNEXPECTED_TOKEN                        = 11,
!     UNEXPECTED_END_OF_COMMAND               = 12,
!     UNKNOWN_FUNCTION                        = 13,
!     NEED_AGGREGATE                          = 14,
!     SUM_OF_NON_NUMERIC                      = 15,
!     WRONG_DATA_TYPE                         = 16,
!     CARDINALITY_VIOLATION_NO_SUBCLASS       = 17,
!     SERIALIZATION_FAILURE                   = 18,
!     TRANSFER_CORRUPTED                      = 19,
!     FUNCTION_NOT_SUPPORTED                  = 20,
!     TABLE_ALREADY_EXISTS                    = 21,
!     TABLE_NOT_FOUND                         = 22,
!     INDEX_ALREADY_EXISTS                    = 23,
!     SECOND_PRIMARY_KEY                      = 24,
!     DROP_PRIMARY_KEY                        = 25,
!     INDEX_NOT_FOUND                         = 26,
!     COLUMN_ALREADY_EXISTS                   = 27,
!     COLUMN_NOT_FOUND                        = 28,
!     FILE_IO_ERROR                           = 29,
!     WRONG_DATABASE_FILE_VERSION             = 30,
!     DATABASE_IS_READONLY                    = 31,
!     DATA_IS_READONLY                        = 32,
!     ACCESS_IS_DENIED                        = 33,
!     INPUTSTREAM_ERROR                       = 34,
!     NO_DATA_IS_AVAILABLE                    = 35,
!     USER_ALREADY_EXISTS                     = 36,
!     USER_NOT_FOUND                          = 37,
!     ASSERT_FAILED                           = 38,
!     EXTERNAL_STOP                           = 39,
!     GENERAL_ERROR                           = 40,
!     WRONG_OUT_PARAMETER                     = 41,
!     FUNCTION_NOT_FOUND                      = 42,
!     TRIGGER_NOT_FOUND                       = 43,
!     SAVEPOINT_NOT_FOUND                     = 44,
!     LABEL_REQUIRED                          = 45,
!     WRONG_DEFAULT_CLAUSE                    = 46,
!     FOREIGN_KEY_NOT_ALLOWED                 = 47,
!     UNKNOWN_DATA_SOURCE                     = 48,
!     BAD_INDEX_CONSTRAINT_NAME               = 49,
!     DROP_FK_INDEX                           = 50,
!     RESULTSET_FORWARD_ONLY                  = 51,
!     VIEW_ALREADY_EXISTS                     = 52,
!     VIEW_NOT_FOUND                          = 53,
!     NOT_USED_54                             = 54,
!     NOT_A_TABLE                             = 55,
!     SYSTEM_INDEX                            = 56,
!     COLUMN_TYPE_MISMATCH                    = 57,
!     BAD_ADD_COLUMN_DEFINITION               = 58,
!     DROP_SYSTEM_CONSTRAINT                  = 59,
!     CONSTRAINT_ALREADY_EXISTS               = 60,
!     CONSTRAINT_NOT_FOUND                    = 61,
!     INVALID_JDBC_ARGUMENT                   = 62,
!     DATABASE_IS_MEMORY_ONLY                 = 63,
!     OUTER_JOIN_CONDITION                    = 64,
!     NUMERIC_VALUE_OUT_OF_RANGE              = 65,
!     MISSING_SOFTWARE_MODULE                 = 66,
!     NOT_IN_AGGREGATE_OR_GROUP_BY            = 67,
!     INVALID_GROUP_BY                        = 68,
!     INVALID_HAVING                          = 69,
!     INVALID_ORDER_BY                        = 70,
!     INVALID_ORDER_BY_IN_DISTINCT_SELECT     = 71,
!     OUT_OF_MEMORY                           = 72,
!     OPERATION_NOT_SUPPORTED                 = 73,
!     INVALID_IDENTIFIER                      = 74,
!     TEXT_TABLE_SOURCE                       = 75,
!     TEXT_FILE                               = 76,
!     NOT_USED_77                             = 77,
!     ERROR_IN_SCRIPT_FILE                    = 78,
!     NULL_IN_VALUE_LIST                      = 79,
!     SOCKET_ERROR                            = 80,
!     INVALID_CHARACTER_ENCODING              = 81,
!     NOT_USED_82                             = 82,
!     NOT_USED_83                             = 83,
!     NOT_USED_84                             = 84,
!     UNEXPECTED_EXCEPTION                    = 85,
!     NOT_USED_86                             = 86,
!     NOT_USED_87                             = 87,
!     NOT_USED_88                             = 88,
!     NOT_USED_89                             = 89,
!     NOT_USED_90                             = 90,
!     NOT_USED_91                             = 91,
!     NOT_USED_92                             = 92,
!     NOT_USED_93                             = 93,
!     DATABASE_NOT_EXISTS                     = 94,
!     INVALID_CONVERSION                      = 95,
!     ERROR_IN_BINARY_SCRIPT_1                = 96,
!     ERROR_IN_BINARY_SCRIPT_2                = 97,
!     GENERAL_IO_ERROR                        = 98,
!     EXPRESSION_NOT_SUPPORTED                = 99,
!     Constraint_violation                    = 100,
!     Database_dropTable                      = 101,
!     ERROR_IN_CONSTRAINT_COLUMN_LIST         = 102,
!     TABLE_HAS_NO_PRIMARY_KEY                = 103,
!     VIOLATION_OF_UNIQUE_CONSTRAINT          = 104,
!     NO_DEFAULT_VALUE_FOR_COLUMN             = 105,
!     NULL_VALUE_AS_BOOLEAN                   = 106,
!     DatabaseManager_getDatabase             = 107,
!     NOT_USED_108                            = 108,
!     NOT_USED_109                            = 109,
!     NOT_USED_110                            = 110,
!     NOT_USED_111                            = 111,
!     NOT_USED_112                            = 112,
!     DatabaseScriptReader_readDDL            = 113,
!     DatabaseScriptReader_readExistingData   = 114,
!     Message_Pair                            = 115,
!     LOAD_SAVE_PROPERTIES                    = 116,
!     INVALID_TRANSACTION_STATE_NO_SUBCLASS   = 117,
!     JDBC_INVALID_BRI_SCOPE                  = 118,
!     JDBC_NO_RESULT_SET_METADATA             = 119,
!     JDBC_NO_RESULT_SET                      = 120,
!     MISSING_CLOSEBRACKET                    = 121,
!     ITSNS_OVERWRITE                         = 122,
!     COLUMN_IS_IN_INDEX                      = 123,
!     STRING_DATA_TRUNCATION                  = 124,
!     QUOTED_IDENTIFIER_REQUIRED              = 125,
!     STATEMENT_IS_CLOSED                     = 126,
!     DatabaseRowInput_skipBytes              = 127,
!     DatabaseRowInput_readLine               = 128,
!     DATA_FILE_ERROR                         = 129,
!     NOT_USED_130                            = 130,
!     HsqlDateTime_null_string                = 131,
!     NOT_USED_132                            = 132,
!     HsqlDateTime_null_date                  = 133,
!     NOT_USED_134                            = 134,
!     HsqlProperties_load                     = 135,
!     HsqlSocketFactorySecure_verify          = 136,
!     HsqlSocketFactorySecure_verify2         = 137,
!     jdbcConnection_nativeSQL                = 138,
!     HsqlSocketFactorySecure_verify3         = 139,
!     NOT_USED_140                            = 140,
!     NOT_USED_141                            = 141,
!     jdbcStatement_executeUpdate             = 142,
!     LockFile_checkHeartbeat                 = 143,
!     LockFile_checkHeartbeat2                = 144,
!     TEXT_STRING_HAS_NEWLINE                 = 145,
!     Result_Result                           = 146,
!     SERVER_NO_DATABASE                      = 147,
!     Server_openServerSocket                 = 148,
!     Server_openServerSocket2                = 149,
!     TEXT_TABLE_HEADER                       = 150,
!     NOT_USED_151                            = 151,
!     TextDatabaseRowOutput_writeIntData      = 152,
!     INVALID_LIMIT                           = 153,
!     JDBC_STATEMENT_NOT_ROW_COUNT            = 154,
!     JDBC_STATEMENT_NOT_RESULTSET            = 155,
!     AMBIGUOUS_COLUMN_REFERENCE              = 156,
!     CHECK_CONSTRAINT_VIOLATION              = 157,
!     JDBC_RESULTSET_IS_CLOSED                = 158,
!     SINGLE_COLUMN_EXPECTED                  = 159,
!     TOKEN_REQUIRED                          = 160,
!     NOT_USED_161                            = 161,
!     NOT_USED_162                            = 162,
!     ORDER_LIMIT_REQUIRED                    = 163,
!     TRIGGER_ALREADY_EXISTS                  = 164,
!     ASSERT_DIRECT_EXEC_WITH_PARAM           = 165,
!     NOT_USED_166                            = 166,
!     Expression_compareValues                = 167,
!     INVALID_LIMIT_EXPRESSION                = 168,
!     INVALID_TOP_EXPRESSION                  = 169,
!     SQL_CONSTRAINT_REQUIRED                 = 170,
!     TableWorks_dropConstraint               = 171,
!     TEXT_TABLE_SOURCE_FILENAME              = 172,
!     TEXT_TABLE_SOURCE_VALUE_MISSING         = 173,
!     TEXT_TABLE_SOURCE_SEPARATOR             = 174,
!     UNSUPPORTED_PARAM_CLASS                 = 175,
!     JDBC_NULL_STREAM                        = 176,
!     INTEGRITY_CONSTRAINT_VIOLATION_NOPARENT = 177,
!     NOT_USED_178                            = 178,
!     NOT_USED_179                            = 179,
!     QuotedTextDatabaseRowInput_getField     = 180,
!     QuotedTextDatabaseRowInput_getField2    = 181,
!     TextDatabaseRowInput_getField           = 182,
!     TextDatabaseRowInput_getField2          = 183,
!     TextDatabaseRowInput_getField3          = 184,
!     Parser_ambiguous_between1               = 185,
!     SEQUENCE_REFERENCED_BY_VIEW             = 186,
!     NOT_USED_187                            = 187,
!     TextCache_openning_file_error           = 188,
!     TextCache_closing_file_error            = 189,
!     TextCache_purging_file_error            = 190,
!     SEQUENCE_NOT_FOUND                      = 191,
!     SEQUENCE_ALREADY_EXISTS                 = 192,
!     TABLE_REFERENCED_CONSTRAINT             = 193,
!     TABLE_REFERENCED_VIEW                   = 194,
!     NOT_USED_195                            = 195,
!     TEXT_SOURCE_EXISTS                      = 196,
!     COLUMN_IS_REFERENCED                    = 197,
!     FUNCTION_CALL_ERROR                     = 198,
!     TRIGGERED_DATA_CHANGE                   = 199,
!     INVALID_FUNCTION_ARGUMENT               = 200,
!     INTERNAL_UNSUPPORTED_OPERATION          = 201,
!     NOT_USED_202                            = 202,
!     INVALID_PREPARED_STATEMENT              = 203,
!     CREATE_TRIGGER_COMMAND_1                = 204,
!     TRIGGER_FUNCTION_CLASS_NOT_FOUND        = 205,
!     NOT_USED_206                            = 206,
!     NOT_USED_207                            = 207,
!     INVALID_COLLATION_NAME_NO_SUBCLASS      = 208,
!     DataFileCache_makeRow                   = 209,
!     DataFileCache_open                      = 210,
!     DataFileCache_close                     = 211,
!     Expression_resolveTypes1                = 212,
!     Expression_resolveTypes2                = 213,
!     Expression_resolveTypes3                = 214,
!     Expression_resolveTypes4                = 215,
!     UNRESOLVED_PARAMETER_TYPE               = 216,
!     Expression_resolveTypes6                = 217,
!     Expression_resolveTypes7                = 218,
!     Expression_resolveTypeForLike           = 219,
!     NOT_USED_220                            = 220,
!     Expression_resolveTypeForIn2            = 221,
!     Session_execute                         = 222,
!     NOT_USED_223                            = 223,
!     NOT_USED_224                            = 224,
!     DATA_FILE_IS_FULL                       = 225,
!     THREE_PART_IDENTIFIER                   = 226,
!     INVALID_SCHEMA_NAME_NO_SUBCLASS         = 227,
!     DEPENDENT_DATABASE_OBJECT_EXISTS        = 228,
!     NO_SUCH_ROLE_GRANT                      = 229,
!     NO_SUCH_ROLE_REVOKE                     = 230,
!     NONMOD_ACCOUNT                          = 231,
!     NO_SUCH_GRANTEE                         = 232,
!     MISSING_SYSAUTH                         = 233,
!     MISSING_GRANTEE                         = 234,
!     CHANGE_GRANTEE                          = 235,
!     NULL_NAME                               = 236,
!     ILLEGAL_ROLE_NAME                       = 237,
!     ROLE_ALREADY_EXISTS                     = 238,
!     NO_SUCH_ROLE                            = 239,
!     MISSING_ROLEMANAGER                     = 240,
!     GRANTEE_ALREADY_EXISTS                  = 241,
!     MISSING_PUBLIC_GRANTEE                  = 242,
!     NONMOD_GRANTEE                          = 243,
!     CIRCULAR_GRANT                          = 244,
!     ALREADY_HAVE_ROLE                       = 245,
!     DONT_HAVE_ROLE                          = 246,
!     NOT_USED_247                            = 247,
!     RETRIEVE_NEST_ROLE_FAIL                 = 248,
!     NO_SUCH_RIGHT                           = 249,
!     IN_SCHEMA_DEFINITION                    = 250,
!     PRIMARY_KEY_NOT_ALLOWED                 = 251,
!     COLUMN_IS_IN_CONSTRAINT                 = 252,
!     COLUMN_SIZE_REQUIRED                    = 253,
!     INVALID_SIZE_PRECISION                  = 254,
!     LAST_ERROR_HANDLE                       = 255;
  
      //
      static String MESSAGE_TAG = "$$";
***************
*** 660,665 ****
--- 663,685 ----
      }
  
      /**
+      *     Throws exception if condition is false
+      *
+      *     @param condition
+      *     @param code
+      *     @param add
+      *
+      * @throws HsqlException
+      */
+     public static void check(boolean condition, int code,
+                              final Object[] add) throws HsqlException {
+ 
+         if (!condition) {
+             throw error(code, add);
+         }
+     }
+ 
+     /**
       * Method declaration
       *
       *
*** misc/hsqldb/src/org/hsqldb/TransactionManager.java	Thu Oct 27 21:40:18 2005
--- misc/build/hsqldb/src/org/hsqldb/TransactionManager.java	Tue May 30 16:22:33 2006
***************
*** 102,109 ****
  
      void commit(Session session) {
  
!         Object[] list = session.transactionList.getArray();
!         int      size = session.transactionList.size();
  
          for (int i = 0; i < size; i++) {
              Transaction tx    = (Transaction) list[i];
--- 102,109 ----
  
      void commit(Session session) {
  
!         Object[] list = session.rowActionList.getArray();
!         int      size = session.rowActionList.size();
  
          for (int i = 0; i < size; i++) {
              Transaction tx    = (Transaction) list[i];
***************
*** 113,119 ****
              rowSessionMap.remove(rowid);
          }
  
!         session.transactionList.clear();
          session.savepoints.clear();
      }
  
--- 113,119 ----
              rowSessionMap.remove(rowid);
          }
  
!         session.rowActionList.clear();
          session.savepoints.clear();
      }
  
***************
*** 143,155 ****
  
      void rollbackTransactions(Session session, int limit, boolean log) {
  
!         Object[] list = session.transactionList.getArray();
!         int      size = session.transactionList.size();
  
          for (int i = size - 1; i >= limit; i--) {
              Transaction tx = (Transaction) list[i];
  
!             tx.rollback(session, false);
          }
  
          for (int i = limit; i < size; i++) {
--- 143,155 ----
  
      void rollbackTransactions(Session session, int limit, boolean log) {
  
!         Object[] list = session.rowActionList.getArray();
!         int      size = session.rowActionList.size();
  
          for (int i = size - 1; i >= limit; i--) {
              Transaction tx = (Transaction) list[i];
  
!             tx.rollback(session, log);
          }
  
          for (int i = limit; i < size; i++) {
***************
*** 159,165 ****
              rowSessionMap.remove(rowid);
          }
  
!         session.transactionList.setSize(limit);
      }
  
      void addTransaction(Session session, Transaction transaction) {
--- 159,165 ----
              rowSessionMap.remove(rowid);
          }
  
!         session.rowActionList.setSize(limit);
      }
  
      void addTransaction(Session session, Transaction transaction) {
***************
*** 212,218 ****
  
                  if (tIndex[i] < tSize) {
                      Transaction current =
!                         (Transaction) sessions[i].transactionList.get(
                              tIndex[i]);
  
                      if (current.SCN < minChangeNo) {
--- 212,218 ----
  
                  if (tIndex[i] < tSize) {
                      Transaction current =
!                         (Transaction) sessions[i].rowActionList.get(
                              tIndex[i]);
  
                      if (current.SCN < minChangeNo) {
***************
*** 228,235 ****
                  break;
              }
  
!             HsqlArrayList currentList =
!                 sessions[sessionIndex].transactionList;
  
              for (; tIndex[sessionIndex] < currentList.size(); ) {
                  Transaction current =
--- 228,234 ----
                  break;
              }
  
!             HsqlArrayList currentList = sessions[sessionIndex].rowActionList;
  
              for (; tIndex[sessionIndex] < currentList.size(); ) {
                  Transaction current =
***************
*** 264,270 ****
          lookup.setKeysSearchTarget();
  
          for (int i = 0; i < sessions.length; i++) {
!             HsqlArrayList tlist = sessions[i].transactionList;
  
              for (int j = 0, size = tlist.size(); j < size; j++) {
                  Transaction tx = (Transaction) tlist.get(j);
--- 263,269 ----
          lookup.setKeysSearchTarget();
  
          for (int i = 0; i < sessions.length; i++) {
!             HsqlArrayList tlist = sessions[i].rowActionList;
  
              for (int j = 0, size = tlist.size(); j < size; j++) {
                  Transaction tx = (Transaction) tlist.get(j);
***************
*** 286,292 ****
          Session[] sessions = database.sessionManager.getAllSessions();
  
          for (int i = 0; i < sessions.length; i++) {
!             HsqlArrayList tlist = sessions[i].transactionList;
  
              for (int j = 0, size = tlist.size(); j < size; j++) {
                  Transaction tx = (Transaction) tlist.get(j);
--- 285,291 ----
          Session[] sessions = database.sessionManager.getAllSessions();
  
          for (int i = 0; i < sessions.length; i++) {
!             HsqlArrayList tlist = sessions[i].rowActionList;
  
              for (int j = 0, size = tlist.size(); j < size; j++) {
                  Transaction tx = (Transaction) tlist.get(j);
*** misc/hsqldb/src/org/hsqldb/jdbc/jdbcConnection.java	Sun Nov  6 23:05:18 2005
--- misc/build/hsqldb/src/org/hsqldb/jdbc/jdbcConnection.java	Fri Jun  9 16:26:49 2006
***************
*** 755,794 ****
                      } else if (c == '"') {
                          state = outside_escape_inside_double_quotes;
                      } else if (c == '{') {
-                         sb.setCharAt(i++, ' ');
  
!                         i = StringUtil.skipSpaces(sql, i);
! 
!                         if (sql.regionMatches(true, i, "fn ", 0, 3)
!                                 || sql.regionMatches(true, i, "oj ", 0, 3)
!                                 || sql.regionMatches(true, i, "ts ", 0, 3)) {
!                             sb.setCharAt(i++, ' ');
!                             sb.setCharAt(i++, ' ');
!                         } else if (sql.regionMatches(true, i, "d ", 0, 2)
!                                    || sql.regionMatches(true, i, "t ", 0,
!                                                         2)) {
!                             sb.setCharAt(i++, ' ');
!                         } else if (sql.regionMatches(true, i, "call ", 0,
!                                                      5)) {
!                             i += 4;
!                         } else if (sql.regionMatches(true, i, "?= call ", 0,
!                                                      8)) {
!                             sb.setCharAt(i++, ' ');
!                             sb.setCharAt(i++, ' ');
! 
!                             i += 5;
!                         } else if (sql.regionMatches(true, i, "escape ", 0,
!                                                      7)) {
!                             i += 6;
!                         } else {
!                             i--;
! 
!                             throw new SQLException(Trace
!                                 .getMessage(Trace
!                                     .jdbcConnection_nativeSQL, true, new Object[]{ sql
!                                         .substring(i) }), "S0010", Trace
!                                             .INVALID_JDBC_ARGUMENT);
!                         }
  
                          // changed = true;
                          nest++;
--- 755,762 ----
                      } else if (c == '"') {
                          state = outside_escape_inside_double_quotes;
                      } else if (c == '{') {
  
!                         i = onStartEscapeSequence(sql, sb, i);
  
                          // changed = true;
                          nest++;
***************
*** 825,862 ****
                          state = (nest == 0) ? outside_all
                                              : inside_escape;
                      } else if (c == '{') {
-                         sb.setCharAt(i++, ' ');
  
!                         if (sql.regionMatches(true, i, "fn ", 0, 3)
!                                 || sql.regionMatches(true, i, "oj ", 0, 3)
!                                 || sql.regionMatches(true, i, "ts ", 0, 3)) {
!                             sb.setCharAt(i++, ' ');
!                             sb.setCharAt(i++, ' ');
!                         } else if (sql.regionMatches(true, i, "d ", 0, 2)
!                                    || sql.regionMatches(true, i, "t ", 0,
!                                                         2)) {
!                             sb.setCharAt(i++, ' ');
!                         } else if (sql.regionMatches(true, i, "call ", 0,
!                                                      5)) {
!                             i += 4;
!                         } else if (sql.regionMatches(true, i, "?= call ", 0,
!                                                      8)) {
!                             sb.setCharAt(i++, ' ');
!                             sb.setCharAt(i++, ' ');
! 
!                             i += 5;
!                         } else if (sql.regionMatches(true, i, "escape ", 0,
!                                                      7)) {
!                             i += 6;
!                         } else {
!                             i--;
! 
!                             throw new SQLException(Trace
!                                 .getMessage(Trace
!                                     .jdbcConnection_nativeSQL, true, new Object[]{ sql
!                                         .substring(i) }), "S0010", Trace
!                                             .INVALID_JDBC_ARGUMENT);
!                         }
  
                          // changed = true;
                          nest++;
--- 793,800 ----
                          state = (nest == 0) ? outside_all
                                              : inside_escape;
                      } else if (c == '{') {
  
!                         i = onStartEscapeSequence(sql, sb, i);
  
                          // changed = true;
                          nest++;
***************
*** 2702,2705 ****
--- 2640,2685 ----
                                     + e.getMessage());
          }
      }
+ 
+     /** is called from within nativeSQL when the start of an JDBC escape sequence is encountered
+      */
+     private int onStartEscapeSequence( String sql, StringBuffer sb, int i ) throws SQLException {
+ 
+         sb.setCharAt(i++, ' ');
+ 
+         i = StringUtil.skipSpaces(sql, i);
+ 
+         if (sql.regionMatches(true, i, "fn ", 0, 3)
+                 || sql.regionMatches(true, i, "oj ", 0, 3)
+                 || sql.regionMatches(true, i, "ts ", 0, 3)) {
+             sb.setCharAt(i++, ' ');
+             sb.setCharAt(i++, ' ');
+         } else if (sql.regionMatches(true, i, "d ", 0, 2)
+                    || sql.regionMatches(true, i, "t ", 0,
+                                         2)) {
+             sb.setCharAt(i++, ' ');
+         } else if (sql.regionMatches(true, i, "call ", 0,
+                                      5)) {
+             i += 4;
+         } else if (sql.regionMatches(true, i, "?= call ", 0,
+                                      8)) {
+             sb.setCharAt(i++, ' ');
+             sb.setCharAt(i++, ' ');
+ 
+             i += 5;
+         } else if (sql.regionMatches(true, i, "escape ", 0,
+                                      7)) {
+             i += 6;
+         } else {
+             i--;
+ 
+             throw new SQLException(Trace
+                 .getMessage(Trace
+                     .jdbcConnection_nativeSQL, true, new Object[]{ sql
+                         .substring(i) }), "S0010", Trace
+                             .INVALID_JDBC_ARGUMENT);
+         }
+ 
+         return i;
+     }
  }
*** misc/hsqldb/src/org/hsqldb/jdbc/jdbcResultSet.java	Sun Oct 23 17:40:14 2005
--- misc/build/hsqldb/src/org/hsqldb/jdbc/jdbcResultSet.java	Fri Jun  9 16:25:34 2006
***************
*** 4950,4956 ****
          }
  
          if (t != type) {
!             if (o instanceof Binary) {
                  throw Util.sqlException(Trace.WRONG_DATA_TYPE);
              }
  
--- 4950,4956 ----
          }
  
          if (t != type) {
!             if (o instanceof Binary && type != Types.CHAR) {
                  throw Util.sqlException(Trace.WRONG_DATA_TYPE);
              }
  
*** misc/hsqldb/src/org/hsqldb/lib/SimpleLog.java	Sun Oct 23 18:26:26 2005
--- misc/build/hsqldb/src/org/hsqldb/lib/SimpleLog.java	Tue May 30 16:22:33 2006
***************
*** 35,43 ****
  import java.io.FileWriter;
  import java.io.PrintWriter;
  
  /**
   * Simple log for recording abnormal events in persistence<p>
!  * Log levels, 0 and 1 are currently supported.
   *
   * @author fredt@users
   * @version 1.8.0
--- 35,49 ----
  import java.io.FileWriter;
  import java.io.PrintWriter;
  
+ import org.hsqldb.HsqlDateTime;
+ 
  /**
   * Simple log for recording abnormal events in persistence<p>
!  * Log levels, LOG_NONE, LOG_ERROR, and LOG_NORMAL are currently supported.<p>
!  * LOG_ERROR corresponds to property value 1 and logs main database events plus
!  * any major errors encountered in operation.
!  * LOG_NORMAL corresponds to property value 2 and logs additional normal events
!  * and minor errors.
   *
   * @author fredt@users
   * @version 1.8.0
***************
*** 45,50 ****
--- 51,59 ----
   */
  public class SimpleLog {
  
+     public static int   LOG_NONE   = 0;
+     public static int   LOG_ERROR  = 1;
+     public static int   LOG_NORMAL = 2;
      private PrintWriter writer;
      private int         level;
  
***************
*** 52,58 ****
  
          this.level = level;
  
!         if (level != 0) {
              if (useFile) {
                  File file = new File(path);
  
--- 61,67 ----
  
          this.level = level;
  
!         if (level != LOG_NONE) {
              if (useFile) {
                  File file = new File(path);
  
***************
*** 88,115 ****
          return writer;
      }
  
!     public synchronized void sendLine(String message) {
  
!         if (level != 0) {
!             writer.println(message);
          }
      }
  
!     public synchronized void logContext(String message) {
  
!         if (level == 0) {
              return;
          }
  
!         String info = "";
  
  //#ifdef JDBC3
          Throwable           t        = new Throwable();
          StackTraceElement[] elements = t.getStackTrace();
  
          if (elements.length > 1) {
!             info = elements[1].getClassName() + "."
!                    + elements[1].getMethodName();
          }
  
  //#endif
--- 97,124 ----
          return writer;
      }
  
!     public synchronized void sendLine(int atLevel, String message) {
  
!         if (level >= atLevel) {
!             writer.println(HsqlDateTime.getSytemTimeString() + " " + message);
          }
      }
  
!     public synchronized void logContext(int atLevel, String message) {
  
!         if (level < atLevel) {
              return;
          }
  
!         String info = HsqlDateTime.getSytemTimeString();
  
  //#ifdef JDBC3
          Throwable           t        = new Throwable();
          StackTraceElement[] elements = t.getStackTrace();
  
          if (elements.length > 1) {
!             info += " " + elements[1].getClassName() + "."
!                     + elements[1].getMethodName();
          }
  
  //#endif
***************
*** 118,135 ****
  
      public synchronized void logContext(Throwable t) {
  
!         if (level == 0) {
              return;
          }
  
!         String info = t.getClass().getName();
  
  //#ifdef JDBC3
          StackTraceElement[] elements = t.getStackTrace();
  
          if (elements.length > 0) {
!             info = elements[0].getClassName() + "."
!                    + elements[0].getMethodName();
          }
  
  //#endif
--- 127,144 ----
  
      public synchronized void logContext(Throwable t) {
  
!         if (level == LOG_NONE) {
              return;
          }
  
!         String info = HsqlDateTime.getSytemTimeString();
  
  //#ifdef JDBC3
          StackTraceElement[] elements = t.getStackTrace();
  
          if (elements.length > 0) {
!             info += " " + elements[0].getClassName() + "."
!                     + elements[0].getMethodName();
          }
  
  //#endif
*** misc/hsqldb/src/org/hsqldb/persist/DataFileBlockManager.java	Sun Oct 23 17:40:16 2005
--- misc/build/hsqldb/src/org/hsqldb/persist/DataFileBlockManager.java	Tue May 30 16:22:33 2006
***************
*** 51,57 ****
      private long           requestSize;
  
      // reporting vars
!     long lostFreeBlockSize;
  
      /**
       *
--- 51,58 ----
      private long           requestSize;
  
      // reporting vars
!     long    lostFreeBlockSize;
!     boolean isModified;
  
      /**
       *
***************
*** 72,77 ****
--- 73,80 ----
       */
      void add(int pos, int rowSize) {
  
+         isModified = true;
+ 
          if (capacity == 0) {
              lostFreeBlockSize += rowSize;
  
***************
*** 133,138 ****
--- 136,145 ----
          return lostFreeBlockSize;
      }
  
+     boolean isModified() {
+         return isModified;
+     }
+ 
      private void resetList() {
  
          if (requestCount != 0) {
*** misc/hsqldb/src/org/hsqldb/persist/DataFileCache.java	Sun Oct 23 18:26:26 2005
--- misc/build/hsqldb/src/org/hsqldb/persist/DataFileCache.java	Tue May 30 16:22:33 2006
***************
*** 39,44 ****
--- 39,45 ----
  import org.hsqldb.Trace;
  import org.hsqldb.lib.FileAccess;
  import org.hsqldb.lib.FileUtil;
+ import org.hsqldb.lib.SimpleLog;
  import org.hsqldb.lib.StopWatch;
  import org.hsqldb.lib.Storage;
  import org.hsqldb.lib.ZipUnzipFile;
***************
*** 275,302 ****
                  cache.saveAll();
                  Trace.printSystemOut("saveAll: " + sw.elapsedTime());
  
!                 // set empty
!                 dataFile.seek(LONG_EMPTY_SIZE);
!                 dataFile.writeLong(freeBlocks.getLostBlocksSize());
  
!                 // set end
!                 dataFile.seek(LONG_FREE_POS_POS);
!                 dataFile.writeLong(fileFreePosition);
  
!                 // set saved flag;
!                 dataFile.seek(FLAGS_POS);
  
!                 int flag = BitMap.set(0, FLAG_ISSAVED);
  
!                 if (hasRowInfo) {
!                     flag = BitMap.set(flag, FLAG_ROWINFO);
!                 }
  
!                 dataFile.writeInt(flag);
  
!                 //
!                 dataFile.seek(fileFreePosition);
!                 Trace.printSystemOut("pos and flags: " + sw.elapsedTime());
              }
  
              if (dataFile != null) {
--- 276,310 ----
                  cache.saveAll();
                  Trace.printSystemOut("saveAll: " + sw.elapsedTime());
  
!                 if (fileModified || freeBlocks.isModified()) {
  
!                     // set empty
!                     dataFile.seek(LONG_EMPTY_SIZE);
!                     dataFile.writeLong(freeBlocks.getLostBlocksSize());
  
!                     // set end
!                     dataFile.seek(LONG_FREE_POS_POS);
!                     dataFile.writeLong(fileFreePosition);
  
!                     // set saved flag;
!                     dataFile.seek(FLAGS_POS);
  
!                     int flag = BitMap.set(0, FLAG_ISSAVED);
  
!                     if (hasRowInfo) {
!                         flag = BitMap.set(flag, FLAG_ROWINFO);
!                     }
  
!                     dataFile.writeInt(flag);
! 
!                     //
!                     if (dataFile.length() != fileFreePosition) {
!                         dataFile.seek(fileFreePosition);
!                     }
! 
!                     Trace.printSystemOut("pos and flags: "
!                                          + sw.elapsedTime());
!                 }
              }
  
              if (dataFile != null) {
***************
*** 557,563 ****
  
              return object;
          } catch (IOException e) {
!             database.logger.appLog.logContext("" + cache + " pos: " + i);
              database.logger.appLog.logContext(e);
  
              throw Trace.error(Trace.DATA_FILE_ERROR,
--- 565,572 ----
  
              return object;
          } catch (IOException e) {
!             database.logger.appLog.logContext(SimpleLog.LOG_ERROR,
!                                               "" + cache + " pos: " + i);
              database.logger.appLog.logContext(e);
  
              throw Trace.error(Trace.DATA_FILE_ERROR,
*** misc/hsqldb/src/org/hsqldb/persist/DataFileDefrag.java	Sun Oct 23 18:26:26 2005
--- misc/build/hsqldb/src/org/hsqldb/persist/DataFileDefrag.java	Tue May 30 16:22:33 2006
***************
*** 37,42 ****
--- 37,43 ----
  
  import org.hsqldb.Database;
  import org.hsqldb.HsqlException;
+ import org.hsqldb.Session;
  import org.hsqldb.Table;
  import org.hsqldb.Trace;
  import org.hsqldb.index.RowIterator;
***************
*** 202,207 ****
--- 203,209 ----
      int[] writeTableToDataFile(Table table)
      throws IOException, HsqlException {
  
+         Session session        = database.getSessionManager().getSysSession();
          RowOutputBinary rowOut = new RowOutputBinary();
          DoubleIntIndex pointerLookup =
              new DoubleIntIndex(table.getPrimaryIndex().sizeEstimate(), false);
***************
*** 212,218 ****
          pointerLookup.setKeysSearchTarget();
          Trace.printSystemOut("lookup begins: " + stopw.elapsedTime());
  
!         RowIterator it = table.rowIterator(null);
  
          for (; it.hasNext(); count++) {
              CachedObject row = (CachedObject) it.next();
--- 214,220 ----
          pointerLookup.setKeysSearchTarget();
          Trace.printSystemOut("lookup begins: " + stopw.elapsedTime());
  
!         RowIterator it = table.rowIterator(session);
  
          for (; it.hasNext(); count++) {
              CachedObject row = (CachedObject) it.next();
***************
*** 231,237 ****
                               stopw.elapsedTime());
  
          count = 0;
!         it    = table.rowIterator(null);
  
          for (; it.hasNext(); count++) {
              CachedObject row = it.next();
--- 233,239 ----
                               stopw.elapsedTime());
  
          count = 0;
!         it    = table.rowIterator(session);
  
          for (; it.hasNext(); count++) {
              CachedObject row = it.next();
*** misc/hsqldb/src/org/hsqldb/persist/HsqlDatabaseProperties.java	Sun Oct 23 18:26:26 2005
--- misc/build/hsqldb/src/org/hsqldb/persist/HsqlDatabaseProperties.java	Tue May 30 16:22:33 2006
***************
*** 300,306 ****
  
          boolean exists;
  
!         if (database.getType().equals(DatabaseURL.S_MEM)) {
              return true;
          }
  
--- 300,306 ----
  
          boolean exists;
  
!         if (!DatabaseURL.isFileBasedDatabaseType(database.getType())) {
              return true;
          }
  
***************
*** 366,372 ****
  
      public void save() throws HsqlException {
  
!         if (database.getType().equals(DatabaseURL.S_MEM)
                  || database.isFilesReadOnly() || database.isFilesInJar()) {
              return;
          }
--- 366,372 ----
  
      public void save() throws HsqlException {
  
!         if (!DatabaseURL.isFileBasedDatabaseType(database.getType())
                  || database.isFilesReadOnly() || database.isFilesInJar()) {
              return;
          }
*** misc/hsqldb/src/org/hsqldb/persist/Logger.java	Sun Oct 23 18:26:28 2005
--- misc/build/hsqldb/src/org/hsqldb/persist/Logger.java	Tue May 30 16:22:33 2006
***************
*** 98,106 ****
          appLog = new SimpleLog(path + ".app.log", loglevel,
                                 !db.isFilesReadOnly());
  
!         appLog.sendLine("Database (re)opened: "
!                         + db.getFileAccess().getClass().getName() + " "
!                         + HsqlDateTime.getSytemTimeString());
  
          logStatements = false;
  
--- 98,104 ----
          appLog = new SimpleLog(path + ".app.log", loglevel,
                                 !db.isFilesReadOnly());
  
!         appLog.sendLine(SimpleLog.LOG_ERROR, "Database (re)opened");
  
          logStatements = false;
  
***************
*** 142,149 ****
  
          if (log == null) {
              if (appLog != null) {
!                 appLog.sendLine("Database closed: "
!                                 + HsqlDateTime.getSytemTimeString());
                  appLog.close();
              }
  
--- 140,146 ----
  
          if (log == null) {
              if (appLog != null) {
!                 appLog.sendLine(SimpleLog.LOG_ERROR, "Database closed");
                  appLog.close();
              }
  
***************
*** 168,175 ****
              }
          } catch (Throwable e) {
              if (appLog != null) {
!                 appLog.sendLine("Database closed: "
!                                 + HsqlDateTime.getSytemTimeString());
                  appLog.close();
              }
  
--- 165,171 ----
              }
          } catch (Throwable e) {
              if (appLog != null) {
!                 appLog.sendLine(SimpleLog.LOG_NORMAL, "Database closed");
                  appLog.close();
              }
  
***************
*** 179,186 ****
          }
  
          if (appLog != null) {
!             appLog.sendLine("Database closed: "
!                             + HsqlDateTime.getSytemTimeString());
              appLog.close();
          }
  
--- 175,181 ----
          }
  
          if (appLog != null) {
!             appLog.sendLine(SimpleLog.LOG_ERROR, "Database closed");
              appLog.close();
          }
  
*** misc/hsqldb/src/org/hsqldb/persist/NIOScaledRAFile.java	Sun Oct 23 18:26:28 2005
--- misc/build/hsqldb/src/org/hsqldb/persist/NIOScaledRAFile.java	Tue May 30 16:22:33 2006
***************
*** 53,64 ****
   */
  class NIOScaledRAFile extends ScaledRAFile {
  
!     MappedByteBuffer  buffer;
!     FileChannel       channel;
!     long              bufferLength;
!     private boolean   wasNio;
!     private boolean   bufferModified;
!     static final long MAX_NIO_LENGTH = (1L << 28);
  
      /**
       * Public constructor for access by reflection
--- 53,63 ----
   */
  class NIOScaledRAFile extends ScaledRAFile {
  
!     MappedByteBuffer buffer;
!     FileChannel      channel;
!     long             bufferLength;
!     private boolean  wasNio;
!     private boolean  bufferModified;
  
      /**
       * Public constructor for access by reflection
*** misc/hsqldb/src/org/hsqldb/persist/ScaledRAFile.java	Sun Oct 23 18:26:28 2005
--- misc/build/hsqldb/src/org/hsqldb/persist/ScaledRAFile.java	Tue May 30 16:22:33 2006
***************
*** 53,61 ****
   */
  class ScaledRAFile implements Storage {
  
!     static final int         DATA_FILE_RAF = 0;
!     static final int         DATA_FILE_NIO = 1;
!     static final int         DATA_FILE_JAR = 2;
      final RandomAccessFile   file;
      private final boolean    readOnly;
      final String             fileName;
--- 53,62 ----
   */
  class ScaledRAFile implements Storage {
  
!     static final int         DATA_FILE_RAF  = 0;
!     static final int         DATA_FILE_NIO  = 1;
!     static final int         DATA_FILE_JAR  = 2;
!     static final long        MAX_NIO_LENGTH = (1L << 28);
      final RandomAccessFile   file;
      private final boolean    readOnly;
      final String             fileName;
***************
*** 107,112 ****
--- 108,122 ----
          } else if (type == DATA_FILE_RAF) {
              return new ScaledRAFile(name, readonly);
          } else {
+             RandomAccessFile file = new RandomAccessFile(name, readonly ? "r"
+                                                                         : "rw");
+ 
+             if (file.length() > MAX_NIO_LENGTH) {
+                 return new ScaledRAFile(name, file, readonly);
+             } else {
+                 file.close();
+             }
+ 
              try {
                  Class.forName("java.nio.MappedByteBuffer");
  
***************
*** 124,129 ****
--- 134,147 ----
          }
      }
  
+     ScaledRAFile(String name, RandomAccessFile file,
+                  boolean readonly) throws FileNotFoundException, IOException {
+ 
+         this.readOnly = readonly;
+         fileName      = name;
+         this.file     = file;
+     }
+ 
      ScaledRAFile(String name,
                   boolean readonly) throws FileNotFoundException, IOException {
  
*** misc/hsqldb/src/org/hsqldb/persist/ScriptRunner.java	Sun Oct 23 18:26:28 2005
--- misc/build/hsqldb/src/org/hsqldb/persist/ScriptRunner.java	Tue May 30 16:22:33 2006
***************
*** 38,43 ****
--- 38,44 ----
  import org.hsqldb.Session;
  import org.hsqldb.Trace;
  import org.hsqldb.lib.IntKeyHashMap;
+ import org.hsqldb.lib.SimpleLog;
  import org.hsqldb.lib.StopWatch;
  import org.hsqldb.scriptio.ScriptReaderBase;
  import org.hsqldb.scriptio.ScriptWriterBase;
***************
*** 103,109 ****
                      continue;
                  }
  
-                 String schema = current.currentSchema.name;
                  Result result = null;
  
                  switch (scr.getStatementType()) {
--- 104,109 ----
***************
*** 164,170 ****
                  message = "out of memory processing " + logFilename
                            + " line: " + scr.getLineNumber();
  
!                 database.logger.appLog.logContext(message);
  
                  throw Trace.error(Trace.OUT_OF_MEMORY);
              }
--- 164,171 ----
                  message = "out of memory processing " + logFilename
                            + " line: " + scr.getLineNumber();
  
!                 database.logger.appLog.logContext(SimpleLog.LOG_ERROR,
!                                                   message);
  
                  throw Trace.error(Trace.OUT_OF_MEMORY);
              }
***************
*** 173,179 ****
              message = logFilename + " line: " + scr.getLineNumber() + " "
                        + e.getMessage();
  
!             database.logger.appLog.logContext(message);
              Trace.printSystemOut(message);
          } finally {
              if (scr != null) {
--- 174,180 ----
              message = logFilename + " line: " + scr.getLineNumber() + " "
                        + e.getMessage();
  
!             database.logger.appLog.logContext(SimpleLog.LOG_ERROR, message);
              Trace.printSystemOut(message);
          } finally {
              if (scr != null) {
*** misc/hsqldb/src/org/hsqldb/resources/sql-error-messages.properties	Sun Nov  6 23:07:20 2005
--- misc/build/hsqldb/src/org/hsqldb/resources/sql-error-messages.properties	Tue May 30 16:24:12 2006
***************
*** 23,29 ****
  019=40001 Transfer corrupted
  020=IM001 This function is not supported
  021=S0001 Table already exists
! 022=S0002 Table not found
  023=S0011 Index already exists
  024=S0011 Attempt to define a second primary key
  025=S0011 Attempt to drop the primary key
--- 23,29 ----
  019=40001 Transfer corrupted
  020=IM001 This function is not supported
  021=S0001 Table already exists
! 022=S0002 Table '$$' not found
  023=S0011 Index already exists
  024=S0011 Attempt to define a second primary key
  025=S0011 Attempt to drop the primary key
***************
*** 54,60 ****
  050=S0011 Attempt to drop a foreign key index
  051=S1000 ResultSet was set to forward only
  052=S0003 View already exists
! 053=S0004 View not found
  054=S0005 NA
  055=S0005 Not a Table
  056=S0011 Attempt to drop or rename a system index
--- 54,60 ----
  050=S0011 Attempt to drop a foreign key index
  051=S1000 ResultSet was set to forward only
  052=S0003 View already exists
! 053=S0004 View '$$' not found
  054=S0005 NA
  055=S0005 Not a Table
  056=S0011 Attempt to drop or rename a system index
***************
*** 106,112 ****
  102=duplicate column in list
  103=table has no primary key
  104=23000 Unique constraint violation
! 105=missing DEFAULT value on column $$
  106=S1000 NULL value as BOOLEAN
  107=attempt to connect while db opening /closing
  108=NA
--- 106,112 ----
  102=duplicate column in list
  103=table has no primary key
  104=23000 Unique constraint violation
! 105=S0021 missing DEFAULT value on column $$
  106=S1000 NULL value as BOOLEAN
  107=attempt to connect while db opening /closing
  108=NA
***************
*** 139,145 ****
  135=properties name is null or empty
  136=Server certificate has no Common Name
  137=Server certificate has empty Common Name
! 138=Unknown JDBC escape sequence: {
  139=Certificate Common Name[$$] does not match host name[$$]
  140=NA
  141=NA
--- 139,145 ----
  135=properties name is null or empty
  136=Server certificate has no Common Name
  137=Server certificate has empty Common Name
! 138=Unknown JDBC escape sequence: $$
  139=Certificate Common Name[$$] does not match host name[$$]
  140=NA
  141=NA
***************
*** 198,204 ****
  194=23000 Table is referenced by view
  195=NA
  196=S1000 Text source file already exists
! 197=23000 Column is referenced in constraint
  198=S1000 Error calling function
  199=27000 Triggered data change violation
  200=37000 Invalid argument
--- 198,204 ----
  194=23000 Table is referenced by view
  195=NA
  196=S1000 Text source file already exists
! 197=23000 Column is referenced in constraint or view
  198=S1000 Error calling function
  199=27000 Triggered data change violation
  200=37000 Invalid argument
*** misc/hsqldb/src/org/hsqldb/resources/sql-error-messages_it.properties	Sun Nov  6 23:07:32 2005
--- misc/build/hsqldb/src/org/hsqldb/resources/sql-error-messages_it.properties	Tue May 30 16:22:33 2006
***************
*** 1,6 ****
  # Copyright 2005 HSQL Developers Group
  # can be distributed and used according to HSQLDB License
! # see http://hsqldb.sourceforge.net
  # Italian translation by Nicola Pedot (http://www.jugtrento.org/)
  # JRC-Editor by http://zavel.org
  000=NOT USED
--- 1,6 ----
  # Copyright 2005 HSQL Developers Group
  # can be distributed and used according to HSQLDB License
! # see http://hsqldb.org
  # Italian translation by Nicola Pedot (http://www.jugtrento.org/)
  # JRC-Editor by http://zavel.org
  000=NOT USED
***************
*** 108,114 ****
  102=colonna duplicata nella lista
  103=tabella senza chiave primaria
  104=23000 Violazione del vincolo di unicit\u00e0
! 105=manca il valore DEFAULT sulla colonna $$
  106=S1000 valore NULL come BOOLEAN
  107=tentativo di connessione mentre l'archivio si stava aprendo/chiudendo
  108=NA
--- 108,114 ----
  102=colonna duplicata nella lista
  103=tabella senza chiave primaria
  104=23000 Violazione del vincolo di unicit\u00e0
! 105=S2001 manca il valore DEFAULT sulla colonna $$
  106=S1000 valore NULL come BOOLEAN
  107=tentativo di connessione mentre l'archivio si stava aprendo/chiudendo
  108=NA
***************
*** 200,206 ****
  194=23000 Tabella referenziata dalla vista
  195=NA
  196=S1000 Testo sorgente gi\u00e0 esistente
! 197=23000 Colonna referenziata nel vincolo
  198=S1000 Errore nella chiamata alla funzione
  199=27000 Violazione nel cambio di dati da trigger
  200=37000 Argomento non valido
--- 200,206 ----
  194=23000 Tabella referenziata dalla vista
  195=NA
  196=S1000 Testo sorgente gi\u00e0 esistente
! 197=23000 Colonna referenziata nel vincolo o vista
  198=S1000 Errore nella chiamata alla funzione
  199=27000 Violazione nel cambio di dati da trigger
  200=37000 Argomento non valido
*** misc/hsqldb/src/org/hsqldb/rowio/RowInputTextQuoted.java	Sun Oct 23 18:26:28 2005
--- misc/build/hsqldb/src/org/hsqldb/rowio/RowInputTextQuoted.java	Tue May 30 16:22:33 2006
***************
*** 120,125 ****
--- 120,126 ----
                          } else {
  
                              //-- End of field.
+                             // todo - bug here as it throws when there are line terminators after the last field
                              if (((next + 1) != qtext.length)
                                      && (text.indexOf(sep, next) != next)) {
                                  throw Trace
*** misc/hsqldb/src/org/hsqldb/scriptio/ScriptWriterBase.java	Sun Oct 23 18:26:28 2005
--- misc/build/hsqldb/src/org/hsqldb/scriptio/ScriptWriterBase.java	Tue May 30 16:22:33 2006
***************
*** 305,311 ****
  
                          writeTableInit(t);
  
!                         RowIterator it = t.rowIterator(null);
  
                          while (it.hasNext()) {
                              writeRow(currentSession, t, it.next().getData());
--- 305,311 ----
  
                          writeTableInit(t);
  
!                         RowIterator it = t.rowIterator(currentSession);
  
                          while (it.hasNext()) {
                              writeRow(currentSession, t, it.next().getData());
