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

SQLSessionContext not correctly initialized in some non-method call nested contexts

    XMLWordPrintableJSON

    Details

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

      Description

      In some contexts, beside calling stored routines containing SQL, Derby
      uses nested execution contexts, wehere we have two nested activations,
      but no nested connections.

      In such cases, currently a new SQLSessionContext is constructed, but
      not initialized correctly. This leads to the session variables
      CURRENT_ROLE/CURRENT_SCHEMA not being set correctly in these contexts
      (they should inherited from the parent context, cf DERBY-3327).

      For method calls, this is being handled by generating a call to
      lcc.setupNestedSessionContext (see
      StaticMethodCallNode#generateSetupNestedSessionContext)

      In some of these nested contexts, one or both of the session variables
      CURRENT_ROLE/CURRENT_SCHEMA can be referenced, in others
      not. Obviously, if they can, this will lead to errors. The following
      contexts will have this problem:

      • ALTER TABLE ADD COLUMN <colname> <coltype> DEFAULT CURRENT_ROLE
        In the AlterTableConstantAction, a nested UPDATE statement is used
        to give existing rows the new column its default value. This
        execution context is nested, cf. AlterTableConstantAction#executeUpdate
      • TRIGGER body execution may reference CURRENT_ROLE/CURRENT_SCHEMA.
        The body executes in a nested context,
        cf. GenericTriggerExecutor#executeSPS.

      In other cases, the session variables can not be referenced, so this
      not a problem:

      • CHECK constraint execution when executed as part of an ALTER TABLE
      • EmbedResultSet.insertRow, .deleteRow, .updateRow

      The session context should not be changed (pushed) for these nested
      executions, since there is no nested connection (SQL 2003, 4.37.1: "An
      SQL-session is associated with an SQL-connection.")

        Attachments

        1. derby-3897-1.diff
          37 kB
          Dag H. Wanvik
        2. derby-3897-1.stat
          1 kB
          Dag H. Wanvik
        3. derby-3897-2.diff
          39 kB
          Dag H. Wanvik
        4. derby-3897-2.stat
          1 kB
          Dag H. Wanvik
        5. derby-3897-3.diff
          41 kB
          Dag H. Wanvik
        6. derby-3897-3.stat
          1 kB
          Dag H. Wanvik
        7. derby-3897-repro.diff
          4 kB
          Dag H. Wanvik

          Issue Links

            Activity

              People

              • Assignee:
                dagw Dag H. Wanvik
                Reporter:
                dagw Dag H. Wanvik
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: