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

Triggers should not allow MERGE statements that reference temporary tables

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.11.1.1
    • 10.11.1.3, 10.12.1.1
    • SQL
    • None
    • Repro attached

    Description

      The reference manual topic on the DECLARE GLOBAL TEMPORARY TABLE statement says: "Temporary tables cannot be referenced in a triggeredSQLStatement or in a WHEN clause"

      Still, a CREATE TRIGGER statement succeeds if the triggered SQL statement is a MERGE statement that references a temporary table:

      ij> connect 'jdbc:derby:memory:db;create=true';
      ij> declare global temporary table temp (x int) not logged;
      0 rows inserted/updated/deleted
      ij> create table t1(x int);
      0 rows inserted/updated/deleted
      ij> create trigger tr after insert on t1 insert into session.temp values 1;
      ERROR XCL51: The requested function can not reference tables in SESSION schema.
      ij> create trigger tr after insert on t1 merge into session.temp using t1 on session.temp.x=t1.x when matched then delete;
      0 rows inserted/updated/deleted
      ij> insert into t1 values 1,2,3;
      3 rows inserted/updated/deleted
      

      The second CREATE TRIGGER statement above should have failed the same way as the first.

      Attachments

        1. d6705-1b.diff
          7 kB
          Knut Anders Hatlen
        2. d6705-1a.diff
          7 kB
          Knut Anders Hatlen

        Issue Links

          Activity

            People

              knutanders Knut Anders Hatlen
              knutanders Knut Anders Hatlen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: