Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-5290

NOW() function returns the same value for each call in BEGIN...END block

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 10.1
    • Fix Version/s: 10.2, 10.1.3, 10.0.5
    • Component/s: Query Engine
    • Labels:
      None
    • Environment:

      teiid-10.1.0 on WildFly Full 11.0.0.Final (WildFly Core 3.0.8.Final)

    • Steps to Reproduce:
      Hide

      Try to run the following anonymous procedures and check if the return different values for NOW() function:

      -- FAILURE(values are the same)
      BEGIN
      	declare timestamp ts1 = select now();
      	DECLARE integer c = 20000;
      	WHILE (c > 0) 
      		BEGIN
      			c= c-1; 
      		END
      	declare timestamp ts2 = select now();
      	select ts1, ts2;
      END ;;
      

      and

      --FAILURE(values are the same)
      BEGIN
      	DECLARE integer c = 20000;
      	create local temporary table #tem(ts timestamp);
      	WHILE (c > 0) 
      		BEGIN
      			INSERT INTO #tem VALUES((select NOW()));
      			c= c-1; 
      		END 
      	select * from #tem;
      END ;;
      

      Show
      Try to run the following anonymous procedures and check if the return different values for NOW() function: -- FAILURE(values are the same) BEGIN declare timestamp ts1 = select now(); DECLARE integer c = 20000; WHILE (c > 0) BEGIN c= c-1; END declare timestamp ts2 = select now(); select ts1, ts2; END ;; and --FAILURE(values are the same) BEGIN DECLARE integer c = 20000; create local temporary table #tem(ts timestamp ); WHILE (c > 0) BEGIN INSERT INTO #tem VALUES (( select NOW())); c= c-1; END select * from #tem; END ;;

      Description

      Run the following queries:

      BEGIN
      	declare timestamp ts1 = select now();
      	DECLARE integer c = 20000;
      	WHILE (c > 0) 
      		BEGIN
      			c= c-1; 
      		END
      	declare timestamp ts2 = select now();
      	select ts1, ts2;
      END ;;
      

      and

      BEGIN
      	DECLARE integer c = 20000;
      	create local temporary table #tem(ts timestamp);
      	WHILE (c > 0) 
      		BEGIN
      			INSERT INTO #tem VALUES((select NOW()));
      			c= c-1; 
      		END 
      	select * from #tem;
      END ;;
      

      NOW() function returns the same value for each call in BEGIN...END block and it doesn't matter if it is atomic or not.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                shawkins Steven Hawkins
                Reporter:
                dalex005 dalex dalex
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: