Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4524

Incorrect DROP FUNCTION logic in AccessTest's tearDown() method

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.6.1.0
    • Fix Version/s: 10.6.1.0
    • Component/s: Test
    • Labels:
      None

      Description

      public void tearDown() throws Exception {
      Statement st = createStatement();
      super.tearDown();
      try

      { st.executeUpdate("DROP FUNCTION PADSTRING"); }

      catch (SQLException e)

      { // never mind. }

      }

      The DROP FUNCTION statement always fails with "No current connection" because super.tearDown(), which is called between createStatement() and executeUpdate(), closes the connection.

      1. removeTearDown.diff
        0.8 kB
        Knut Anders Hatlen

        Activity

        Hide
        knutanders Knut Anders Hatlen added a comment -

        The PADSTRING function is created in the decorateSQL() method of a CleanDatabaseTestSetup decorator, so it's probably wrong to attempt to drop the function after each separate test case in the first place. Since CleanDatabaseTestSetup.tearDown() will drop all functions in all user schemas, including the PADSTRING function, it's probably OK to remove this tearDown() method altogether.

        Show
        knutanders Knut Anders Hatlen added a comment - The PADSTRING function is created in the decorateSQL() method of a CleanDatabaseTestSetup decorator, so it's probably wrong to attempt to drop the function after each separate test case in the first place. Since CleanDatabaseTestSetup.tearDown() will drop all functions in all user schemas, including the PADSTRING function, it's probably OK to remove this tearDown() method altogether.
        Hide
        knutanders Knut Anders Hatlen added a comment -

        Attaching patch that removes tearDown().

        Show
        knutanders Knut Anders Hatlen added a comment - Attaching patch that removes tearDown().
        Hide
        knutanders Knut Anders Hatlen added a comment -

        Committed revision 902288.

        Show
        knutanders Knut Anders Hatlen added a comment - Committed revision 902288.
        Hide
        bryanpendleton Bryan Pendleton added a comment -

        +1 to removing the tearDown and letting CleanDatabaseTestSetup handle the cleanup. Thanks for cleaning this up!

        Show
        bryanpendleton Bryan Pendleton added a comment - +1 to removing the tearDown and letting CleanDatabaseTestSetup handle the cleanup. Thanks for cleaning this up!

          People

          • Assignee:
            knutanders Knut Anders Hatlen
            Reporter:
            knutanders Knut Anders Hatlen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development