Menu

View problem with user-defined function

Help
2002-08-30
2014-01-19
  • David Miller

    David Miller - 2002-08-30

    I am using hsqldb 1.7.0 in hsql server mode.  I am able to define a function and use it in a view.  However when I shutdown and restart, I get an error message (see below). 

    If I modify the .script file and move the CREATE ALIAS statement BEFORE the CREATE VIEW statement that references it, things work...until the next time I shutdown. 

    Is this a known bug?  This seems to render user-defined functions useless.  I have looked recent bugs in  the bug list (not exhaustive), but did not find this.

    I am otherwise very happy with functionality/performance.

    Steps to re-create:

    Note: the table dual is defined as one column DUMMY VARCHAR(1) with one row 'X'....kind of Oracleish I know.

    1. Create a function
    Function source:
    public class Lib
    {
        public static String foo () {
            return "bar";
        }
    }

    2. start or re-start server with function in classpath

    3. Create alias for the function
    create alias foo for "ecas.db.Lib.foo";

    4. Create a view that references the function
    create view foo_view as select foo() foo from dual;

    5. Test selecting from the view.
    select * from foo_view;

    6. Shutdown server
    shutdown

    7. Re-start server
    The following error message is displayed.

    Server.run/init: java.sql.SQLException: Unexpected token: 37000 Unexpected token
    : FOO in statement [CREATE VIEW FOO_VIEW AS  select foo() foo from dual]
    java.sql.SQLException: Unexpected token: 37000 Unexpected token: FOO in statemen
    t [CREATE VIEW FOO_VIEW AS  select foo() foo from dual]
            at org.hsqldb.Trace.getError(Trace.java:226)
            at org.hsqldb.Log.runScript(Log.java:863)
            at org.hsqldb.Log.open(Log.java:306)
            at org.hsqldb.Database$Logger.openLog(Database.java:2596)
            at org.hsqldb.Database.<init>(Database.java:203)
            at org.hsqldb.Server.openDB(Server.java:178)
            at org.hsqldb.Server.run(Server.java:197)
            at org.hsqldb.Server.main(Server.java:147)

     
    • Fred Toussi

      Fred Toussi - 2002-08-30

      Until now, this issue was not known. We will try to fix it before the release of 1.7.1.

      Please use version 1.7.1 release candidate for your testing as it fixes a number of issues that were reported since the release of 1.7.0.

       
      • Fred Toussi

        Fred Toussi - 2002-09-05

        This has been fixed for the forthcoming 1.7.1 RC2. The package will be released very soon.

         

Log in to post a comment.