Merged asterix_statement_model_fix into asterix_stabilization
1) Asterix now has a revised statement model. 
  a) Each statement (definition includes a query) is executed as an independent transaction.
  b) Statements are executed in the order of submission with no implicit re-orderings.
  c) Asterix does not differentiate between DDL and DML statements. This is unlike the previous model which executed DDL statements prior to DML statements.
  d) Asterix bails out at the failure in execution of a statement. As stated in (a), the failing statement is rolled back and has no impact on previously executed statements.
  e) Forward references during type creation are not supported. This is not a regression, as these did not work in the previous model either.
  f) Amongst the submitted statements, you could have multiple queries.

2) Asterix has support for AQL bodied functions. You can create AQL bodied fucntions and may use them in subsequent sessions. 

3) Asterix has support for cross dataverse statements. You can invoke statements/queries that refer to entities belonging to different dataverses. 

4) Other Issues resolved: 25, 62, 100, 124, 148, 165, 202  


git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@860 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/metadata/queries/meta01.aql b/asterix-app/src/test/resources/metadata/queries/meta01.aql
new file mode 100644
index 0000000..15b7de8
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta01.aql
@@ -0,0 +1,13 @@
+/*
+ * Description  : Create dataverse & query Metadata dataset Dataverse to verify.
+ * Expected Res : Success
+ * Date         : 15 Sep 2012
+ */
+
+drop dataverse testdv if exists;
+create dataverse testdv;
+
+write output to nc1:"rttest/meta01.adm";
+
+for $l in dataset('Metadata.Dataverse')
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta02.aql b/asterix-app/src/test/resources/metadata/queries/meta02.aql
new file mode 100644
index 0000000..f6686b1
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta02.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : Create dataset & query Metadata dataset Dataset to verify.
+ * Expected Res : Success
+ * Date         : 15 Sep 2012
+ */
+
+drop dataverse testdv if exists;
+create dataverse testdv;
+
+write output to nc1:"rttest/meta02.adm";
+
+create type test.testtype as open {
+id : int32
+}
+
+create dataset testdv.dst01(testtype) partitioned by key id;
+
+for $l in dataset('Metadata.Dataset')
+where $l.DataverseName = 'testdv' and $l.DatasetName = 'dst01'
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta03.aql b/asterix-app/src/test/resources/metadata/queries/meta03.aql
new file mode 100644
index 0000000..88c658c
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta03.aql
@@ -0,0 +1,18 @@
+/*
+ * Description  : Create closed type &  query Metadata dataset Datatype to verify.
+ * Expected Res : Success
+ * Date         : 15 Sep 2012
+ */
+
+drop dataverse testdv if exists;
+create dataverse testdv;
+
+write output to nc1:"rttest/meta03.adm";
+
+create type testdv.testtype as closed {
+id : int32
+}
+
+for $l in dataset('Metadata.Datatype')
+where $l.DataverseName='testdv' and $l.DatatypeName='testtype'
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta04.aql b/asterix-app/src/test/resources/metadata/queries/meta04.aql
new file mode 100644
index 0000000..fac73da
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta04.aql
@@ -0,0 +1,18 @@
+/*
+ * Description  : Create open type & query Metadata dataset Datatype to verify.
+ * Expected Res : Success
+ * Date         : 15 Sep 2012
+ */
+
+drop dataverse testdv if exists;
+create dataverse testdv;
+
+write output to nc1:"rttest/meta04.adm";
+
+create type testdv.testtype as open {
+id : int32
+}
+
+for $l in dataset('Metadata.Datatype')
+where $l.DataverseName='testdv' and $l.DatatypeName='testtype'
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta05.aql b/asterix-app/src/test/resources/metadata/queries/meta05.aql
new file mode 100644
index 0000000..6a99187
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta05.aql
@@ -0,0 +1,23 @@
+/*
+ * Description  : Create primary & secondary indexes & query Metadata dataset to verify.
+ * Expected Res : Success
+ * Date         : 15 Sep 2012
+ */
+
+drop dataverse testdv if exists;
+create dataverse testdv;
+
+write output to nc1:"rttest/meta05.adm";
+
+create type testdv.testtype as open {
+id : int32,
+name : string
+}
+
+create dataset testdv.t1(testtype) partitioned by key id;
+
+create index idx1 on testdv.t1(name);
+
+for $l in dataset('Metadata.Index')
+where $l.DataverseName='testdv' 
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta06.aql b/asterix-app/src/test/resources/metadata/queries/meta06.aql
new file mode 100644
index 0000000..c0b9a9b
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta06.aql
@@ -0,0 +1,18 @@
+/*
+ * Description  : Create AQL bodied UDFs and verify that there are related entries in metadata Function dataset
+ * Expected Res : Success
+ * Date         : Sep 17 2012
+ */
+
+drop dataverse testdv if exists;
+create dataverse testdv;
+
+write output to nc1:"rttest/meta06.adm";
+
+create function testdv.fun01(){
+"This is an AQL Bodied UDF"
+}
+
+for $l in dataset('Metadata.Function')
+return $l
+
diff --git a/asterix-app/src/test/resources/metadata/queries/meta07.aql b/asterix-app/src/test/resources/metadata/queries/meta07.aql
new file mode 100644
index 0000000..2455eeb
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta07.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : Verify default entries for Node dataset in Metadata dataverse
+ * Expected Res : Success
+ * Date         : Sep 17 2012
+ */
+
+// Please note this query was run on two nodes, i.e; two NCs
+
+write output to nc1:"rttest/meta07.adm";
+
+for $l in dataset('Metadata.Node')
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta08.aql b/asterix-app/src/test/resources/metadata/queries/meta08.aql
new file mode 100644
index 0000000..e382c47
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta08.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : Verify default entries for Nodegroup dataset in Metadata dataverse
+ * Expected Res : Success
+ * Date         : Sep 17 2012
+ */
+
+// Please note this query was run on two nodes, i.e; two NCs
+
+write output to nc1:"rttest/meta08.adm";
+
+for $l in dataset('Metadata.Nodegroup')
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta09.aql b/asterix-app/src/test/resources/metadata/queries/meta09.aql
new file mode 100644
index 0000000..4404707
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta09.aql
@@ -0,0 +1,31 @@
+/*
+ * Description  : Create internal dataset, insert data and query metadata Dataset to verify entries for that dataset.
+ * Expected Res : Success
+ * Date         : Sep 17 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/meta09.adm";
+
+create type test.testtype as open {
+id:int32
+}
+
+create dataset test.t1(testtype) partitioned by key id;
+
+insert into dataset test.t1({"id":123});
+insert into dataset test.t1({"id":133});
+insert into dataset test.t1({"id":223});
+insert into dataset test.t1({"id":127});
+insert into dataset test.t1({"id":423});
+insert into dataset test.t1({"id":183});
+insert into dataset test.t1({"id":193});
+insert into dataset test.t1({"id":129});
+insert into dataset test.t1({"id":373});
+insert into dataset test.t1({"id":282});
+
+for $l in dataset('Metadata.Dataset')
+where $l.DataverseName='test' and $l.DatasetName='t1'
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta10.aql b/asterix-app/src/test/resources/metadata/queries/meta10.aql
new file mode 100644
index 0000000..6aae87b
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta10.aql
@@ -0,0 +1,14 @@
+/*
+ * Description  : Create dataverse and drop that dataverse and verify dataverse entries in metadata
+ * Expected Res : Success
+ * Date         : Sep 17 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+drop dataverse test if exists;
+
+write output to nc1:"rttest/meta10.adm";
+
+for $l in dataset('Metadata.Dataverse')
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta11.aql b/asterix-app/src/test/resources/metadata/queries/meta11.aql
new file mode 100644
index 0000000..a5ae81e
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta11.aql
@@ -0,0 +1,21 @@
+/*
+ * Description  : Create dataset and drop that dataset and query Metadata Dataset to verify the drop.
+ * Expected Res : Success
+ * Date         : Sep 17 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/meta11.adm";
+
+create type test.testtype as open {
+id : int32
+}
+
+create dataset test.dst01(testtype) partitioned by key id;
+
+drop dataset test.dst01;
+
+for $l in dataset('Metadata.Dataset')
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta12.aql b/asterix-app/src/test/resources/metadata/queries/meta12.aql
new file mode 100644
index 0000000..481cc3a
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta12.aql
@@ -0,0 +1,27 @@
+/*
+ * Description  : Create secondary index and drop the secondary index and query metadata to verify drop index.
+ * Expected Res : Success 
+ * Date         : Sep 17 2012
+ */
+
+// This drop index test is broken for now.
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/meta12.adm";
+
+create type test.testtype as open {
+id : int32,
+name : string
+}
+
+create dataset test.dst01(testtype) partitioned by key id;
+
+create index idx1 on test.dst01(name);
+
+drop index test.dst01.idx1;
+
+for $l in dataset('Metadata.Index')
+where $l.DatasetName = 'dst01'
+return $l
diff --git a/asterix-app/src/test/resources/metadata/queries/meta13.aql b/asterix-app/src/test/resources/metadata/queries/meta13.aql
new file mode 100644
index 0000000..62d0964
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/meta13.aql
@@ -0,0 +1,23 @@
+/*
+ * Description  : Create functions and drop that function and query metadata 
+ *              : to verify entries in Function dataset for the dropped UDF.
+ * Expected Res : Success
+ * Date         : Sep 17 2012
+ */
+
+// this test returns NPE today
+
+drop dataverse test if exists;
+create dataverse test;
+
+write output to nc1:"rttest/meta13.adm";
+
+create function test.foo(){
+"drop this function"
+}
+
+drop function test.foo@0;
+
+for $l in dataset('Metadata.Function')
+return $l;
+
diff --git a/asterix-app/src/test/resources/metadata/queries/metadata_index.aql b/asterix-app/src/test/resources/metadata/queries/metadata_index.aql
index 6ff3185..cbe0109 100644
--- a/asterix-app/src/test/resources/metadata/queries/metadata_index.aql
+++ b/asterix-app/src/test/resources/metadata/queries/metadata_index.aql
@@ -3,4 +3,5 @@
 write output to nc1:"rttest/metadata_index.adm";
 
 for $c in dataset('Index')
-return $c
\ No newline at end of file
+where $c.DataverseName='Metadata'
+return $c