Merge branch 'yingyi/asterix_fix'
diff --git a/asterix-app/src/test/resources/runtimets/queries/types/record01/record01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/types/record01/record01.1.ddl.aql
new file mode 100644
index 0000000..faae040
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/types/record01/record01.1.ddl.aql
@@ -0,0 +1,5 @@
+drop dataverse local if exists;
+create dataverse local;
+use dataverse local;
+create type ttype as { "id" : int32 } ;
+create dataset dset (ttype) primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/types/record01/record01.1.adm b/asterix-app/src/test/resources/runtimets/results/types/record01/record01.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/types/record01/record01.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index eadf7fb..1e65071 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4442,4 +4442,11 @@
       </compilation-unit>
     </test-case>
   </test-group>
+  <test-group name="types">
+    <test-case FilePath="types">
+      <compilation-unit name="record01">
+        <output-dir compare="Text">record01</output-dir>
+      </compilation-unit>
+    </test-case>
+  </test-group>
 </test-suite>
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index 84d46f5..fdcd86e 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -96,6 +96,49 @@
         }  
         return s.substring(1).trim();
     }
+    
+    private static IRecordFieldDataGen parseFieldDataGen(String hint) throws ParseException {
+      IRecordFieldDataGen rfdg = null;
+      String splits[] = hint.split(" +");
+      if (splits[0].equals(VAL_FILE_HINT)) { 
+        File[] valFiles = new File[splits.length - 1];
+        for (int k=1; k<splits.length; k++) {
+          valFiles[k-1] = new File(splits[k]);
+        } 
+        rfdg = new FieldValFileDataGen(valFiles);
+      } else if (splits[0].equals(VAL_FILE_SAME_INDEX_HINT)) {
+        rfdg = new FieldValFileSameIndexDataGen(new File(splits[1]), splits[2]);
+      } else if (splits[0].equals(LIST_VAL_FILE_HINT)) {
+        rfdg = new ListValFileDataGen(new File(splits[1]), Integer.parseInt(splits[2]), Integer.parseInt(splits[3]));
+      } else if (splits[0].equals(LIST_HINT)) {
+        rfdg = new ListDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
+      } else if (splits[0].equals(INTERVAL_HINT)) {
+        FieldIntervalDataGen.ValueType vt;
+        if (splits[1].equals("int")) {
+          vt = FieldIntervalDataGen.ValueType.INT;
+        } else if (splits[1].equals("long")) {
+          vt = FieldIntervalDataGen.ValueType.LONG;
+        } else if (splits[1].equals("float")) {
+          vt = FieldIntervalDataGen.ValueType.FLOAT;
+        } else if (splits[1].equals("double")) {
+          vt = FieldIntervalDataGen.ValueType.DOUBLE;
+        } else {
+          throw new ParseException("Unknown type for interval data gen: " + splits[1]);
+        }
+        rfdg = new FieldIntervalDataGen(vt, splits[2], splits[3]); 
+      } else if (splits[0].equals(INSERT_RAND_INT_HINT)) {
+        rfdg = new InsertRandIntDataGen(splits[1], splits[2]);
+      } else if (splits[0].equals(DATE_BETWEEN_YEARS_HINT)) {
+        rfdg = new DateBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
+      } else if (splits[0].equals(DATETIME_BETWEEN_YEARS_HINT)) {
+        rfdg = new DatetimeBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
+      } else if (splits[0].equals(DATETIME_ADD_RAND_HOURS_HINT)) {
+        rfdg = new DatetimeAddRandHoursDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]), splits[3]);
+      } else if (splits[0].equals(AUTO_HINT)) {
+        rfdg = new AutoDataGen(splits[1]);
+      }
+      return rfdg;
+    }
 
     public AQLParser(String s){
         this(new StringReader(s));
@@ -893,63 +936,20 @@
 
 void RecordField(RecordTypeDefinition recType) throws ParseException:
 {
-        String fieldName;
-        TypeExpression type = null; 
-        boolean nullable = false;
+  String fieldName;
+  TypeExpression type = null; 
+  boolean nullable = false;
 }
 {
-      fieldName = Identifier()
-      	{
-	     fieldName = token.image;	     	     
-         String hint = getHint(token);
-         IRecordFieldDataGen rfdg = null;
-         if (hint != null) { 
-           String splits[] = hint.split(" +");
-           if (splits[0].equals(VAL_FILE_HINT)) { 
-             File[] valFiles = new File[splits.length - 1];
-             for (int k=1; k<splits.length; k++) {
-               valFiles[k-1] = new File(splits[k]);
-             } 
-             rfdg = new FieldValFileDataGen(valFiles);
-           } else if (splits[0].equals(VAL_FILE_SAME_INDEX_HINT)) {
-             rfdg = new FieldValFileSameIndexDataGen(new File(splits[1]), splits[2]);
-           } else if (splits[0].equals(LIST_VAL_FILE_HINT)) {
-             rfdg = new ListValFileDataGen(new File(splits[1]), Integer.parseInt(splits[2]), Integer.parseInt(splits[3]));
-           } else if (splits[0].equals(LIST_HINT)) {
-             rfdg = new ListDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
-           } else if (splits[0].equals(INTERVAL_HINT)) {
-             FieldIntervalDataGen.ValueType vt;
-             if (splits[1].equals("int")) {
-               vt = FieldIntervalDataGen.ValueType.INT;
-             } else if (splits[1].equals("long")) {
-               vt = FieldIntervalDataGen.ValueType.LONG;
-             } else if (splits[1].equals("float")) {
-               vt = FieldIntervalDataGen.ValueType.FLOAT;
-             } else if (splits[1].equals("double")) {
-               vt = FieldIntervalDataGen.ValueType.DOUBLE;
-             } else {
-               throw new ParseException("Unknown type for interval data gen: " + splits[1]);
-             }
-             rfdg = new FieldIntervalDataGen(vt, splits[2], splits[3]); 
-           } else if (splits[0].equals(INSERT_RAND_INT_HINT)) {
-             rfdg = new InsertRandIntDataGen(splits[1], splits[2]);
-           } else if (splits[0].equals(DATE_BETWEEN_YEARS_HINT)) {
-             rfdg = new DateBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
-           } else if (splits[0].equals(DATETIME_BETWEEN_YEARS_HINT)) {
-             rfdg = new DatetimeBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
-           } else if (splits[0].equals(DATETIME_ADD_RAND_HOURS_HINT)) {
-             rfdg = new DatetimeAddRandHoursDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]), splits[3]);
-           } else if (splits[0].equals(AUTO_HINT)) {
-              rfdg = new AutoDataGen(splits[1]);
-           }
-         }
-	    }
-	  ":"
-	  ( type =  TypeExpr() )
-	  ("?" { nullable = true; } )?
-	  {
-	     recType.addField(fieldName, type, nullable, rfdg);
-	  }   
+  fieldName = Identifier()
+    {
+      String hint = getHint(token);
+      IRecordFieldDataGen rfdg = hint != null ? parseFieldDataGen(hint) : null;
+    }
+  ":" type =  TypeExpr() ("?" { nullable = true; } )?
+    {
+      recType.addField(fieldName, type, nullable, rfdg);
+    }   
 }
 
 TypeReferenceExpression TypeReference() throws ParseException:
diff --git a/asterix-installer/ittest/asterix-lifecycle_backupRestore.adm b/asterix-installer/ittest/asterix-lifecycle_backupRestore.adm
deleted file mode 100644
index 4c4f073..0000000
--- a/asterix-installer/ittest/asterix-lifecycle_backupRestore.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "DataverseName": "backupDataverse", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Mon Jul 08 17:23:56 PDT 2013", "PendingOp": 0 }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
index 645b613..803a2a9 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
@@ -120,7 +120,7 @@
                 // indicates an absence of logs any further.
             }
 
-            if (logicalLogLocator.getLsn() > logManager.getLastFlushedLsn().get()) {
+            if (logManager.isMemoryRead(logicalLogLocator.getLsn())) {
                 return next(currentLogLocator); //should read from memory if there is any further log
             }
         }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
index d4eb8a4..07f89cb 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
@@ -591,14 +591,14 @@
         readDiskLog(lsnValue, logicalLogLocator);
     }
 
-    public boolean isMemoryRead(long currentLSN) {
+    public boolean isMemoryRead(long readLSN) {
         long flushLSN = lastFlushedLSN.get();
-        if ((flushLSN + 1) % logPageSize == 0) {
+        if ((flushLSN + 1) == readLSN) {
             return false;
         }
         long logPageBeginOffset = flushLSN - (flushLSN % logPageSize);
         long logPageEndOffset = logPageBeginOffset + logPageSize;
-        if (currentLSN > flushLSN || (currentLSN >= logPageBeginOffset && currentLSN < logPageEndOffset)) {
+        if (readLSN > flushLSN || (readLSN >= logPageBeginOffset && readLSN < logPageEndOffset)) {
             return true;
         } else {
             return false;