Derby
  1. Derby
  2. DERBY-4334

Invoking certain methods on PreparedStatements after the underlying connection changed forces repreparing

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 10.6.1.0
    • Fix Version/s: None
    • Component/s: JDBC
    • Urgency:
      Normal
    • Issue & fix info:
      Repro attached

      Description

      Whenever we invoke methods like isClosed() or getMetaData() on prepared or callable statements after the underlying connection changed, these methods will try to reprepare the statement. This becomes an issue if in the meanwhile, the query became obsolete (e.g. querying a table that was dropped in the meanwhile).

      For example, if we start a transaction and prepare a statement with "SELECT * FROM FOO;" then drop FOO with a parallel regular connection and try to invoke the said methods on the statement, a repreparement will be attempted. Since FOO no longer exists, it will throw an exception.

      I fixed this issue on DERBY-4310 for the .close() calls on Prepared and Callable statements, but this will require more extensive work to convert the remaining methods that try to do a getRealStatement() on the XAStatementControl. I will be attaching a repro that pops this issue with the isClosed() call.

      The approach I used in DERBY-4310 was to add a couple of methods to XAStatementControl that act directly on the real statement object and close them right away, without attempting to reprepare.

      1. ReproEmbeddedDerby4334.java
        3 kB
        Tiago R. Espinha
      2. utilXid.java
        2 kB
        Tiago R. Espinha

        Issue Links

          Activity

          Hide
          Tiago R. Espinha added a comment -

          Attaching the repro.

          Show
          Tiago R. Espinha added a comment - Attaching the repro.
          Hide
          Kathey Marsden added a comment -

          A full assessment of methods which need the reprepare needs to be done and then a general solution found and perhaps the DERBY-4310 fix reworked to fit into the new scheme. Maybe an argument to getStatment() indicating whether the reprepare on changed connection is necessary. We also need to make sure that any state changes that are made to statements that are not reprepared get copied over when the reprepare does occur. I think this is handled already with the existing code, but some testing is needed to verify.

          Show
          Kathey Marsden added a comment - A full assessment of methods which need the reprepare needs to be done and then a general solution found and perhaps the DERBY-4310 fix reworked to fit into the new scheme. Maybe an argument to getStatment() indicating whether the reprepare on changed connection is necessary. We also need to make sure that any state changes that are made to statements that are not reprepared get copied over when the reprepare does occur. I think this is handled already with the existing code, but some testing is needed to verify.

            People

            • Assignee:
              Unassigned
              Reporter:
              Tiago R. Espinha
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Development