http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/catalog/gp_fastsequence.c
----------------------------------------------------------------------
diff --git a/src/backend/catalog/gp_fastsequence.c 
b/src/backend/catalog/gp_fastsequence.c
deleted file mode 100644
index 2284aa7..0000000
--- a/src/backend/catalog/gp_fastsequence.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/*-------------------------------------------------------------------------
- *
- * gp_fastsequence.c
- *    routines to maintain a light-weight sequence table.
- *
- *-------------------------------------------------------------------------
- */
-#include "postgres.h"
-
-#include "catalog/catquery.h"
-#include "catalog/gp_fastsequence.h"
-#include "catalog/indexing.h"
-#include "utils/relcache.h"
-#include "utils/fmgroids.h"
-#include "access/genam.h"
-#include "access/htup.h"
-#include "access/heapam.h"
-#include "cdb/cdbvars.h"
-
-static void update_fastsequence(
-       Relation gp_fastsequence_rel,
-       HeapTuple oldTuple,
-       TupleDesc tupleDesc,
-       Oid objid,
-       int64 objmod,
-       int64 newLastSequence,
-       ItemPointer tid);
-
-/*
- * InsertFastSequenceEntry
- *
- * Insert a new fast sequence entry for a given object. If the given
- * object already exists in the table, this function replaces the old
- * entry with a fresh initial value.
- *
- * The tid for the new entry is returned.
- */
-void
-InsertFastSequenceEntry(Oid objid, int64 objmod, int64 lastSequence,
-               ItemPointer tid)
-{
-       Relation gp_fastsequence_rel;
-       TupleDesc tupleDesc;
-       int natts = 0;
-       Datum *values;
-       bool *nulls;
-       HeapTuple tuple = NULL;
-       cqContext        cqc;
-       
-       /*
-        * Open and lock the gp_fastsequence catalog table.
-        */
-       gp_fastsequence_rel = heap_open(FastSequenceRelationId, 
RowExclusiveLock);
-       tupleDesc = RelationGetDescr(gp_fastsequence_rel);
-       
-       tuple = caql_getfirst(
-                       caql_addrel(cqclr(&cqc), gp_fastsequence_rel),
-                       cql("SELECT * FROM gp_fastsequence "
-                               " WHERE objid = :1 "
-                               " AND objmod = :2 "
-                               " AND contentid = :3 "
-                               " FOR UPDATE ",
-                               ObjectIdGetDatum(objid),
-                               Int64GetDatum(objmod),
-                               Int32GetDatum(-1)));
-
-       if (tuple == NULL)
-       {
-               natts = tupleDesc->natts;
-               values = palloc0(sizeof(Datum) * natts);
-               nulls = palloc0(sizeof(bool) * natts);
-       
-               values[Anum_gp_fastsequence_objid - 1] = 
ObjectIdGetDatum(objid);
-               values[Anum_gp_fastsequence_objmod - 1] = Int64GetDatum(objmod);
-               values[Anum_gp_fastsequence_last_sequence - 1] = 
Int64GetDatum(lastSequence);
-               values[Anum_gp_fastsequence_contentid - 1] = Int32GetDatum(-1);
-
-               tuple = heaptuple_form_to(tupleDesc, values, nulls, NULL, NULL);
-               frozen_heap_insert(gp_fastsequence_rel, tuple);
-               /*
-                * in hawq, index only exists on master
-                */
-               if (Gp_role != GP_ROLE_EXECUTE)
-                       CatalogUpdateIndexes(gp_fastsequence_rel, tuple);
-       
-               ItemPointerCopy(&tuple->t_self, tid);
-
-               heap_freetuple(tuple);
-               pfree(values);
-               pfree(nulls);
-       }
-       else
-       {
-               update_fastsequence(gp_fastsequence_rel,
-                                                       tuple,
-                                                       tupleDesc,
-                                                       objid,
-                                                       objmod,
-                                                       lastSequence,
-                                                       tid);
-       }
-
-       /*
-        * Since the tid for this row may be used later in this transaction, 
-        * we keep the lock until the end of the transaction.
-        */
-       heap_close(gp_fastsequence_rel, NoLock);
-}
-
-/*
- * update_fastsequnece -- update the fast sequence number for (objid, objmod).
- *
- * If such an entry exists in the table, it is provided in oldTuple. This tuple
- * is updated with the new value. Otherwise, a new tuple is inserted into the
- * table.
- *
- * The tuple id value for the entry is copied out to 'tid'.
- *
- * NOTE: in hawq, we do not add new tuple in QE, it should be dispatched
- * from master, and only update is allowed on QE.
- */
-static void
-update_fastsequence(Relation gp_fastsequence_rel,
-                                       HeapTuple oldTuple,
-                                       TupleDesc tupleDesc,
-                                       Oid objid,
-                                       int64 objmod,
-                                       int64 newLastSequence,
-                                       ItemPointer tid)
-{
-       Datum *values;
-       bool *nulls;
-       HeapTuple newTuple;
-
-       values = palloc0(sizeof(Datum) * tupleDesc->natts);
-       nulls = palloc0(sizeof(bool) * tupleDesc->natts);
-
-       /*
-        * If such a tuple does not exist, insert a new one.
-        */
-       if (oldTuple == NULL)
-       {
-               Assert(Gp_role != GP_ROLE_EXECUTE);
-
-               values[Anum_gp_fastsequence_objid - 1] = 
ObjectIdGetDatum(objid);
-               values[Anum_gp_fastsequence_objmod - 1] = Int64GetDatum(objmod);
-               values[Anum_gp_fastsequence_last_sequence - 1] = 
Int64GetDatum(newLastSequence);
-               values[Anum_gp_fastsequence_contentid - 1] = Int32GetDatum(-1);
-
-               newTuple = heaptuple_form_to(tupleDesc, values, nulls, NULL, 
NULL);
-               frozen_heap_insert(gp_fastsequence_rel, newTuple);
-
-               CatalogUpdateIndexes(gp_fastsequence_rel, newTuple);
-
-               ItemPointerCopy(&newTuple->t_self, tid);
-
-               heap_freetuple(newTuple);
-       }
-
-       else
-       {
-#ifdef USE_ASSERT_CHECKING
-               Oid oldObjid;
-               int64 oldObjmod;
-               bool isNull;
-               
-               oldObjid = heap_getattr(oldTuple, Anum_gp_fastsequence_objid, 
tupleDesc, &isNull);
-               Assert(!isNull);
-               oldObjmod = heap_getattr(oldTuple, Anum_gp_fastsequence_objmod, 
tupleDesc, &isNull);
-               Assert(!isNull);
-               Assert(oldObjid == objid && oldObjmod == objmod);
-#endif
-
-               values[Anum_gp_fastsequence_objid - 1] = 
ObjectIdGetDatum(objid);
-               values[Anum_gp_fastsequence_objmod - 1] = Int64GetDatum(objmod);
-               values[Anum_gp_fastsequence_last_sequence - 1] = 
Int64GetDatum(newLastSequence);
-               values[Anum_gp_fastsequence_contentid - 1] = Int32GetDatum(-1);
-
-               newTuple = heap_form_tuple(tupleDesc, values, nulls);
-               newTuple->t_data->t_ctid = oldTuple->t_data->t_ctid;
-               newTuple->t_self = oldTuple->t_self;
-               if (tupleDesc->tdhasoid)
-                       HeapTupleSetOid(newTuple, HeapTupleGetOid(oldTuple));
-               
-               if (Gp_role != GP_ROLE_EXECUTE)
-               {
-                       heap_inplace_update(gp_fastsequence_rel, newTuple);
-               }
-               else
-               {
-                       InMemHeapRelation inmemrel = OidGetInMemHeapRelation(
-                                       gp_fastsequence_rel->rd_id, 
INMEM_HEAP_MAPPING);
-                       if (NULL == inmemrel)
-                       {
-                               elog(ERROR, "cannot find in-memory table: %s",
-                                               
RelationGetRelationName(gp_fastsequence_rel));
-                       }
-
-                       InMemHeap_Update(inmemrel, &oldTuple->t_self, newTuple);
-               }
-
-               ItemPointerCopy(&newTuple->t_self, tid);
-
-               heap_freetuple(newTuple);
-       }
-       
-       pfree(values);
-       pfree(nulls);
-}
-
-/*
- * GetFastSequences
- *
- * Get a list of consecutive sequence numbers. The starting sequence
- * number is the maximal value between 'lastsequence' + 1 and minSequence.
- * The length of the list is given.
- *
- * If there is not such an entry for objid in the table, create
- * one here.
- *
- * The existing entry for objid in the table is updated with a new
- * lastsequence value.
- *
- * The tuple id value for this entry is copied out to 'tid'.
- */
-int64 GetFastSequences(Oid objid, int64 objmod,
-                                          int64 minSequence, int64 
numSequences,
-                                          ItemPointer tid)
-{
-       Relation gp_fastsequence_rel;
-       TupleDesc tupleDesc;
-       HeapTuple tuple;
-       int64 firstSequence = minSequence;
-       Datum lastSequenceDatum;
-       int64 newLastSequence;
-
-       Assert(tid != NULL);
-       Assert(Gp_role != GP_ROLE_DISPATCH);
-       
-       gp_fastsequence_rel = heap_open(FastSequenceRelationId, 
RowExclusiveLock);
-       tupleDesc = RelationGetDescr(gp_fastsequence_rel);
-       
-       cqContext *pcqCtx = caql_beginscan(
-                                       NULL,
-                                       cql("SELECT * FROM gp_fastsequence "
-                                               " WHERE objid = :1 "
-                                               " AND objmod = :2 "
-                                               " FOR UPDATE ",
-                                               ObjectIdGetDatum(objid),
-                                               Int64GetDatum(objmod)));
-
-       tuple = caql_getnext(pcqCtx);
-
-       if (tuple == NULL)
-       {
-               elog(ERROR, "gp_fastsequence should be dispatched to QE, "
-                               "objid = %u, objmod = "INT64_FORMAT", minseq = 
"INT64_FORMAT", numseq = "INT64_FORMAT".",
-                               objid, objmod, minSequence, numSequences);
-
-               newLastSequence = firstSequence + numSequences - 1;
-       }
-       else
-       {
-               bool isNull;
-
-               lastSequenceDatum = heap_getattr(tuple, 
Anum_gp_fastsequence_last_sequence,
-                                                                               
tupleDesc, &isNull);
-               
-               if (isNull)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_UNDEFINED_OBJECT),
-                                        errmsg("got an invalid lastsequence 
number: NULL")));
-               
-               if (DatumGetInt64(lastSequenceDatum) + 1 > firstSequence)
-                       firstSequence = DatumGetInt64(lastSequenceDatum) + 1;
-               newLastSequence = firstSequence + numSequences - 1;
-       }
-       
-       update_fastsequence(gp_fastsequence_rel, tuple, tupleDesc,
-                                               objid, objmod, newLastSequence, 
tid);
-               
-
-       caql_endscan(pcqCtx);
-
-       /*
-        * Since the tid for this row may be used later in this transaction, 
-        * we keep the lock until the end of the transaction.
-        */
-       heap_close(gp_fastsequence_rel, NoLock);
-
-       return firstSequence;
-}
-
-/*
- * GetFastSequencesByTid
- *
- * Same as GetFastSequences, except that the tuple tid is given, and the tuple 
id
- * is not valid.
- */
-int64
-GetFastSequencesByTid(ItemPointer tid,
-                                         int64 minSequence,
-                                         int64 numSequences)
-{
-       Relation gp_fastsequence_rel;
-       TupleDesc tupleDesc;
-       HeapTupleData tuple;
-       Buffer userbuf;
-       bool found = false;
-       Datum lastSequenceDatum;
-       int64 newLastSequence;
-       int64 firstSequence = minSequence;
-       bool isNull;
-       Oid objidDatum;
-       int64 objmodDatum;
-
-       gp_fastsequence_rel = heap_open(FastSequenceRelationId, 
RowExclusiveLock);
-       tupleDesc = RelationGetDescr(gp_fastsequence_rel);
-
-       Assert(ItemPointerIsValid(tid));
-
-       ItemPointerCopy(tid, &tuple.t_self);
-
-       found = heap_fetch(gp_fastsequence_rel, SnapshotNow, &tuple,
-                                          &userbuf, false, NULL);
-       Assert(found);
-       
-       lastSequenceDatum = heap_getattr(&tuple, 
Anum_gp_fastsequence_last_sequence,
-                                                                        
gp_fastsequence_rel->rd_att, &isNull);
-       if (isNull)
-               ereport(ERROR,
-                               (errcode(ERRCODE_UNDEFINED_OBJECT),
-                                errmsg("got an invalid lastsequence number: 
NULL")));
-       
-       objidDatum = heap_getattr(&tuple, Anum_gp_fastsequence_objid,
-                                                         
gp_fastsequence_rel->rd_att, &isNull);
-       if (isNull)
-               ereport(ERROR,
-                               (errcode(ERRCODE_UNDEFINED_OBJECT),
-                                errmsg("got an invalid objid: NULL")));
-       
-       objmodDatum = heap_getattr(&tuple, Anum_gp_fastsequence_objmod,
-                                                          
gp_fastsequence_rel->rd_att, &isNull);
-       if (isNull)
-               ereport(ERROR,
-                               (errcode(ERRCODE_UNDEFINED_OBJECT),
-                                errmsg("got an invalid objmod: NULL")));
-       
-       if (DatumGetInt64(lastSequenceDatum) + 1 > minSequence)
-               firstSequence = DatumGetInt64(lastSequenceDatum) + 1;
-       newLastSequence = firstSequence + numSequences - 1;
-       
-       update_fastsequence(gp_fastsequence_rel,
-                                               &tuple,
-                                               tupleDesc,
-                                               DatumGetObjectId(objidDatum),
-                                               DatumGetInt64(objmodDatum),
-                                               newLastSequence,
-                                               tid);
-       
-       ReleaseBuffer(userbuf);
-       
-       /*
-        * Since the tid for this row may be used later in this transaction, 
-        * we keep the lock until the end of the transaction.
-        */
-       heap_close(gp_fastsequence_rel, NoLock);
-
-       return firstSequence;
-}
-
-/*
- * RemoveFastSequenceEntry
- *
- * Remove all entries associated with the given object id.
- *
- * If the given objid is an invalid OID, this function simply
- * returns.
- *
- * It is okay for the given valid objid to have no entries in
- * gp_fastsequence.
- */
-void
-RemoveFastSequenceEntry(Oid objid)
-{
-       int numDel;
-       
-       if (!OidIsValid(objid))
-               return;
-
-       numDel = caql_getcount(
-                       NULL,
-                       cql("DELETE FROM gp_fastsequence "
-                               " WHERE objid = :1 ",
-                               ObjectIdGetDatum(objid)));
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/catalog/heap.c
----------------------------------------------------------------------
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 477eb67..c61a2e1 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -78,7 +78,6 @@
 #include "catalog/pg_statistic.h"
 #include "catalog/pg_tablespace.h"
 #include "catalog/pg_type.h"
-#include "catalog/gp_fastsequence.h"
 #include "cdb/cdbappendonlyam.h"
 #include "cdb/cdbpartition.h"
 #include "cdb/cdbanalyze.h"

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/catalog/index.c
----------------------------------------------------------------------
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 29dc07a..9d55a87 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -62,7 +62,6 @@
 #include "catalog/pg_opclass.h"
 #include "catalog/pg_tablespace.h"
 #include "catalog/pg_type.h"
-#include "catalog/aoblkdir.h"
 #include "commands/tablecmds.h"
 #include "executor/executor.h"
 #include "miscadmin.h"
@@ -1822,7 +1821,6 @@ IndexBuildAppendOnlyRowScan(Relation parentRelation,
        double reltuples = 0;
        Datum           values[INDEX_MAX_KEYS];
        bool            isnull[INDEX_MAX_KEYS];
-       AppendOnlyBlockDirectory *blockDirectory = NULL;
        
        Assert(estate->es_per_tuple_exprcontext != NULL);
        econtext = estate->es_per_tuple_exprcontext;
@@ -1836,39 +1834,6 @@ IndexBuildAppendOnlyRowScan(Relation parentRelation,
                                                                  snapshot,
                                                                  0,
                                                                  NULL);
-
-       if (!OidIsValid(aoscan->aoEntry->blkdirrelid) ||
-               !OidIsValid(aoscan->aoEntry->blkdiridxid))
-       {
-               IndexInfoOpaque *opaque;
-
-               if (indexInfo->ii_Concurrent)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_GP_COMMAND_ERROR),
-                                        errmsg("Cannot create index 
concurrently. Create an index non-concurrently "
-                                               "before creating an index 
concurrently in an appendonly table.")));
-               
-               /* Obtain the oids from IndexInfo. */
-               Assert(indexInfo->opaque != NULL);
-
-               opaque = (IndexInfoOpaque *)indexInfo->opaque;
-               
-               Assert(OidIsValid(opaque->blkdirRelOid) && 
OidIsValid(opaque->blkdirIdxOid));
-               
AlterTableCreateAoBlkdirTableWithOid(RelationGetRelid(parentRelation),
-                                                                               
         opaque->blkdirRelOid,
-                                                                               
         opaque->blkdirIdxOid,
-                                                                               
         &opaque->blkdirComptypeOid,
-                                                                               
         false);
-
-               /* Update blkdirrelid, blkdiridxid in aoEntry with new values */
-               aoscan->aoEntry->blkdirrelid = opaque->blkdirRelOid;
-               aoscan->aoEntry->blkdiridxid = opaque->blkdirIdxOid;
-               
-               aoscan->buildBlockDirectory = true;
-               aoscan->blockDirectory =
-                       (AppendOnlyBlockDirectory 
*)palloc0(sizeof(AppendOnlyBlockDirectory));
-               blockDirectory = aoscan->blockDirectory;
-       }
        
        while (appendonly_getnext(aoscan, ForwardScanDirection, slot) != NULL)
        {
@@ -1908,10 +1873,7 @@ IndexBuildAppendOnlyRowScan(Relation parentRelation,
        }
        
        appendonly_endscan(aoscan);
-       
-       if (blockDirectory != NULL)
-               pfree(blockDirectory);
-       
+
        return reltuples;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/catalog/pg_appendonly.c
----------------------------------------------------------------------
diff --git a/src/backend/catalog/pg_appendonly.c 
b/src/backend/catalog/pg_appendonly.c
index 02280e8..d7638b4 100644
--- a/src/backend/catalog/pg_appendonly.c
+++ b/src/backend/catalog/pg_appendonly.c
@@ -33,7 +33,6 @@
 #include "catalog/pg_appendonly.h"
 #include "catalog/pg_type.h"
 #include "catalog/pg_proc.h"
-#include "catalog/gp_fastsequence.h"
 #include "access/genam.h"
 #include "access/heapam.h"
 #include "catalog/catquery.h"
@@ -705,9 +704,6 @@ RemoveAppendonlyEntry(Oid relid)
                Assert(OidIsValid(aosegrelid));
        }
 
-       /* Piggyback here to remove gp_fastsequence entries */
-       RemoveFastSequenceEntry(aosegrelid);
-
        /*
         * Delete the appendonly table entry from the catalog (pg_appendonly).
         */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/cdb/cdbappendonlystoragewrite.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbappendonlystoragewrite.c 
b/src/backend/cdb/cdbappendonlystoragewrite.c
index c740115..18288b5 100644
--- a/src/backend/cdb/cdbappendonlystoragewrite.c
+++ b/src/backend/cdb/cdbappendonlystoragewrite.c
@@ -696,9 +696,6 @@ int32 AppendOnlyStorageWrite_CompleteHeaderLen(
                completeHeaderLen += (AoHeader_LongSize - AoHeader_RegularSize);
        }
 
-       if (storageWrite->isFirstRowNumSet)
-               completeHeaderLen += sizeof(int64);
-
        return completeHeaderLen;
 }
 
@@ -718,9 +715,6 @@ static int32 AppendOnlyStorageWrite_LargeContentHeaderLen(
 
        completeHeaderLen = storageWrite->regularHeaderLen;
 
-       if (storageWrite->isFirstRowNumSet)
-               completeHeaderLen += sizeof(int64);
-
        // UNDONE: Right alignment?
 
        return completeHeaderLen;
@@ -1300,9 +1294,9 @@ AppendOnlyStorageWrite_CompressAppend(
                        AppendOnlyStorageFormat_MakeSmallContentHeader(
                                                                                
header,
                                                                                
storageWrite->storageAttributes.checksum,
-                                                                               
storageWrite->isFirstRowNumSet,
+                                                                               
false,
                                                                                
storageWrite->storageAttributes.version,
-                                                                               
storageWrite->firstRowNum,
+                                                                               
1,
                                                                                
executorBlockKind,
                                                                                
itemCount,
                                                                                
sourceLen,
@@ -1316,9 +1310,9 @@ AppendOnlyStorageWrite_CompressAppend(
                        AppendOnlyStorageFormat_MakeBulkDenseContentHeader(
                                                                                
header,
                                                                                
storageWrite->storageAttributes.checksum,
-                                                                               
storageWrite->isFirstRowNumSet,
+                                                                               
false,
                                                                                
storageWrite->storageAttributes.version,
-                                                                               
storageWrite->firstRowNum,
+                                                                               
1,
                                                                                
executorBlockKind,
                                                                                
itemCount,
                                                                                
sourceLen,
@@ -1382,9 +1376,9 @@ AppendOnlyStorageWrite_CompressAppend(
                AppendOnlyStorageFormat_MakeSmallContentHeader(
                                                                header,
                                                                
storageWrite->storageAttributes.checksum,
-                                                               
storageWrite->isFirstRowNumSet,
+                                                               false,
                                                                
storageWrite->storageAttributes.version,
-                                                               
storageWrite->firstRowNum,
+                                                               1,
                                                                
executorBlockKind,
                                                                itemCount,
                                                                sourceLen,
@@ -1457,7 +1451,7 @@ void AppendOnlyStorageWrite_FinishBuffer(
                         contentLen,
                         storageWrite->maxBufferLen,
                         storageWrite->currentCompleteHeaderLen,
-                        (storageWrite->isFirstRowNumSet ? "true" : "false"));
+                        (false ? "true" : "false"));
 
 
        headerOffsetInFile = 
BufferedAppendCurrentBufferPosition(&storageWrite->bufferedAppend);
@@ -1489,9 +1483,9 @@ void AppendOnlyStorageWrite_FinishBuffer(
                        AppendOnlyStorageFormat_MakeSmallContentHeader(
                                                                        
nonCompressedHeader,
                                                                        
storageWrite->storageAttributes.checksum,
-                                                                       
storageWrite->isFirstRowNumSet,
+                                                                       false,
                                                                        
storageWrite->storageAttributes.version,
-                                                                       
storageWrite->firstRowNum,
+                                                                       1,
                                                                        
executorBlockKind,
                                                                        
rowCount,
                                                                        
contentLen,
@@ -1505,9 +1499,9 @@ void AppendOnlyStorageWrite_FinishBuffer(
                        AppendOnlyStorageFormat_MakeNonBulkDenseContentHeader(
                                                                                
nonCompressedHeader,
                                                                                
storageWrite->storageAttributes.checksum,
-                                                                               
storageWrite->isFirstRowNumSet,
+                                                                               
false,
                                                                                
storageWrite->storageAttributes.version,
-                                                                               
storageWrite->firstRowNum,
+                                                                               
1,
                                                                                
executorBlockKind,
                                                                                
rowCount,
                                                                                
contentLen);
@@ -1621,7 +1615,6 @@ void AppendOnlyStorageWrite_FinishBuffer(
 
        Assert(storageWrite->currentCompleteHeaderLen == 0);
        storageWrite->currentBuffer = NULL;
-       storageWrite->isFirstRowNumSet = false;
 }
 
 /*
@@ -1644,12 +1637,6 @@ void AppendOnlyStorageWrite_CancelLastBuffer(
        }
 
        storageWrite->currentCompleteHeaderLen = 0;
-
-       /*
-        * Since we don't know if AppendOnlyStorageWrite_Content will be called 
next or
-        * the writer is doing something else, let's turn off the firstRowNum 
flag.
-        */
-       storageWrite->isFirstRowNumSet = false;
 }
 
 // 
-----------------------------------------------------------------------------
@@ -1818,9 +1805,9 @@ void AppendOnlyStorageWrite_Content(
                AppendOnlyStorageFormat_MakeLargeContentHeader(
                                                                
largeContentHeader,
                                                                
storageWrite->storageAttributes.checksum,
-                                                               
storageWrite->isFirstRowNumSet,
+                                                               false,
                                                                
storageWrite->storageAttributes.version,
-                                                               
storageWrite->firstRowNum,
+                                                               1,
                                                                
executorBlockKind,
                                                                rowCount,
                                                                contentLen);
@@ -1833,11 +1820,6 @@ void AppendOnlyStorageWrite_Content(
                // Declare it finished.
                storageWrite->currentCompleteHeaderLen = 0;
 
-               /*
-                * Now write the fragments as type Block.
-                */
-               storageWrite->isFirstRowNumSet = false; // Not written with 
fragments.
-
                smallContentHeaderLen = 
                                AppendOnlyStorageWrite_CompleteHeaderLen(
                                                                                
                        storageWrite,
@@ -1927,30 +1909,6 @@ void AppendOnlyStorageWrite_Content(
                }
        }
 
-       storageWrite->isFirstRowNumSet = false;
-
        // Verify we have no buffer allocated.
        Assert(storageWrite->currentCompleteHeaderLen == 0);
 }
-
-// 
-----------------------------------------------------------------------------
-// Optional: Set First Row Number
-// 
-----------------------------------------------------------------------------
-
-/*
- * Set the first row value for the next Append-Only Storage
- * Block to be written.  Only applies to the next block.
- */
-void AppendOnlyStorageWrite_SetFirstRowNum(
-       AppendOnlyStorageWrite          *storageWrite,
-       int64                                           firstRowNum)
-{
-
-       Assert(storageWrite != NULL);
-       Assert(storageWrite->isActive);
-
-       // UNDONE: Range check firstRowNum
-
-       storageWrite->isFirstRowNumSet = true;
-       storageWrite->firstRowNum = firstRowNum;
-}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/cdb/cdbllize.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbllize.c b/src/backend/cdb/cdbllize.c
index 393e6bb..4aa8795 100644
--- a/src/backend/cdb/cdbllize.c
+++ b/src/backend/cdb/cdbllize.c
@@ -1328,7 +1328,6 @@ motion_sanity_walker(Node *node, sanity_result_t *result)
                case T_IndexScan:
                case T_BitmapIndexScan:
                case T_BitmapHeapScan:
-               case T_BitmapAppendOnlyScan:
                case T_BitmapTableScan:
                case T_TidScan:
                case T_SubqueryScan:

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/cdb/cdbpath.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbpath.c b/src/backend/cdb/cdbpath.c
index fc25f4c..8c38ee7 100644
--- a/src/backend/cdb/cdbpath.c
+++ b/src/backend/cdb/cdbpath.c
@@ -1392,7 +1392,6 @@ cdbpath_dedup_fixup_walker(Path *path, void *context)
                case T_ParquetScan:
                case T_IndexScan:
                case T_BitmapHeapScan:
-               case T_BitmapAppendOnlyScan:
                case T_BitmapTableScan:
                case T_TidScan:
                case T_SubqueryScan:

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/cdb/cdbpersistentrelfile.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbpersistentrelfile.c 
b/src/backend/cdb/cdbpersistentrelfile.c
index e7c2d63..2b8e3e8 100644
--- a/src/backend/cdb/cdbpersistentrelfile.c
+++ b/src/backend/cdb/cdbpersistentrelfile.c
@@ -36,7 +36,6 @@
 #include "catalog/pg_tablespace.h"
 #include "catalog/pg_database.h"
 #include "catalog/gp_persistent.h"
-#include "catalog/gp_fastsequence.h"
 #include "cdb/cdbsharedoidsearch.h"
 #include "access/persistentfilesysobjname.h"
 #include "cdb/cdbdirectopen.h"
@@ -713,52 +712,6 @@ PersistentFileSysObjStateChangeResult 
PersistentRelfile_MarkAbortingCreate(
                return false;   // The initdb process will load the persistent 
table once we out of bootstrap mode.
        }
 
-       /* MPP-16543: When inserting tuples into AO table, row numbers will be
-        * generated from gp_fastsequence catalog table, as part of the design,
-        * these sequence numbers are not reusable, even if the AO insert 
-        * transaction is aborted. The entry in gp_fastsequence was inserted
-        * using frozen_heap_insert, which means it's always visible. 
-
-        * Aborted AO insert transaction will cause inconsistency between 
-        * gp_fastsequence and pg_class, the solution is to introduce "frozen 
-        * delete" - inplace update tuple's MVCC header to make it invisible.
-        */
-
-       Relation gp_fastsequence_rel = heap_open(FastSequenceRelationId, 
RowExclusiveLock);
-       HeapTuple   tup;
-       SysScanDesc scan;
-       ScanKeyData skey; 
-       ScanKeyInit(&skey,
-                               Anum_gp_fastsequence_objid,
-                               BTEqualStrategyNumber,
-                               F_OIDEQ,
-                               relFileNode->relNode);
-
-       scan = systable_beginscan(gp_fastsequence_rel,
-                                                         InvalidOid,
-                                                         false,
-                                                         SnapshotNow,
-                                                         1,
-                                                         &skey);
-       while (HeapTupleIsValid(tup = systable_getnext(scan)))
-       {
-               Form_gp_fastsequence found = (Form_gp_fastsequence) 
GETSTRUCT(tup);
-               if (found->objid == relFileNode->relNode) 
-               {       
-                       if (Debug_persistent_print)
-                       {
-                       elog(LOG, "frozen deleting gp_fastsequence entry for 
aborted AO insert transaction on relation %s", relpath(*relFileNode));
-                       }
-
-                       frozen_heap_inplace_delete(gp_fastsequence_rel, tup);
-               }
-       }                                               
-       systable_endscan(scan);
-       heap_close(gp_fastsequence_rel, RowExclusiveLock);
-       
-
-       
-
        PersistentRelfile_VerifyInitScan();
 
        // Do this check after skipping out if in bootstrap mode.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/cdb/cdbplan.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbplan.c b/src/backend/cdb/cdbplan.c
index 68d65f0..31152c8 100644
--- a/src/backend/cdb/cdbplan.c
+++ b/src/backend/cdb/cdbplan.c
@@ -415,22 +415,7 @@ plan_tree_mutator(Node *node,
                                return (Node *) newbmheapscan;
                        }
                        break;
-               
-
-               case T_BitmapAppendOnlyScan:
-                       {
-                               BitmapAppendOnlyScan  *bmappendonlyscan = 
(BitmapAppendOnlyScan *) node;
-                               BitmapAppendOnlyScan  *newbmappendonlyscan;
-
-                               FLATCOPY(newbmappendonlyscan, bmappendonlyscan, 
BitmapAppendOnlyScan);
-                               SCANMUTATE(newbmappendonlyscan, 
bmappendonlyscan);
                                
-                               MUTATE(newbmappendonlyscan->bitmapqualorig, 
bmappendonlyscan->bitmapqualorig, List *);
-       
-                               return (Node *) newbmappendonlyscan;
-                       }
-                       break;
-               
                case T_BitmapTableScan:
                        {
                                BitmapTableScan  *bmtablescan = 
(BitmapTableScan *) node;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/cdb/cdbquerycontextdispatching.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbquerycontextdispatching.c 
b/src/backend/cdb/cdbquerycontextdispatching.c
index b8607bd..ca4d6b2 100644
--- a/src/backend/cdb/cdbquerycontextdispatching.c
+++ b/src/backend/cdb/cdbquerycontextdispatching.c
@@ -36,8 +36,6 @@
 #include "catalog/aoseg.h"
 #include "catalog/catalog.h"
 #include "catalog/catquery.h"
-#include "catalog/gp_fastsequence.h"
-#include "catalog/gp_fastsequence.h"
 #include "catalog/pg_amop.h"
 #include "catalog/pg_amproc.h"
 #include "catalog/pg_aggregate.h"
@@ -55,7 +53,6 @@
 #include "catalog/pg_operator.h"
 #include "catalog/pg_proc.h"
 #include "catalog/pg_tablespace.h"
-#include "catalog/gp_fastsequence.h"
 #include "catalog/toasting.h"
 #include "cdb/cdbdispatchedtablespaceinfo.h"
 #include "cdb/cdbfilesystemcredential.h"
@@ -1385,49 +1382,6 @@ static void
 prepareDispatchedCatalogFastSequence(QueryContextInfo *cxt, Oid relid,
                                                                         List 
*segnos)
 {
-    QueryContextDispatchingHashKey hkey;
-    QueryContextDispatchingHashEntry *hentry = NULL;
-    bool found;
-
-    SysScanDesc scanDesc;
-    HeapTuple tuple;
-    Datum contentid;
-    ScanKeyData scanKeys[1];
-    Relation fast_seq_rel;
-
-    hkey.objid = relid;
-    hkey.type = RelationType;
-    hentry = hash_search(cxt->htab, &hkey, HASH_FIND, &found);
-    Assert(found);
-    Assert(hentry);
-
-    fast_seq_rel = heap_open(FastSequenceRelationId, AccessShareLock);
-
-    ScanKeyInit(&scanKeys[0], Anum_gp_fastsequence_objid, 
BTEqualStrategyNumber,
-            F_OIDEQ, ObjectIdGetDatum(hentry->aoseg_relid));
-
-    scanDesc = systable_beginscan(fast_seq_rel, InvalidOid, FALSE,
-            SnapshotNow, 1, scanKeys);
-
-    while (HeapTupleIsValid(tuple = systable_getnext(scanDesc)))
-    {
-               int i;
-               Datum segno;
-        contentid = heap_getattr(tuple, Anum_gp_fastsequence_contentid,
-                RelationGetDescr(fast_seq_rel), NULL);
-        segno = heap_getattr(tuple, Anum_gp_fastsequence_objmod,
-                               RelationGetDescr(fast_seq_rel), NULL);
-        i = list_find_int(segnos, DatumGetInt32(segno));
-        if (i != -1)
-        {
-                       AddTupleToContextInfo(cxt, FastSequenceRelationId, 
"gp_fastsequence",
-                                       tuple, DatumGetInt32(contentid));
-        }
-    }
-
-    systable_endscan(scanDesc);
-
-    heap_close(fast_seq_rel, AccessShareLock);
 }
 
 /*
@@ -2815,9 +2769,6 @@ 
UpdateCatalogModifiedOnSegments(QueryContextDispatchingSendBack sendback)
                                sendback->eof[0], 
sendback->uncompressed_eof[0], sendback->insertCount);
        }
 
-       ItemPointerData tid;
-       InsertFastSequenceEntry(aoEntry->segrelid, sendback->segno,
-                       sendback->nextFastSequence, &tid);
        heap_close(rel, AccessShareLock);
 
        /*
@@ -2882,10 +2833,6 @@ AddSendbackChangedCatalogContent(StringInfo buf,
                pq_sendint64(buf, sendback->uncompressed_eof[i]);
        }
 
-       /*
-        * 10, send next fast sequence.
-        */
-       pq_sendint64(buf, sendback->nextFastSequence);
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/cdb/cdbtargeteddispatch.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbtargeteddispatch.c 
b/src/backend/cdb/cdbtargeteddispatch.c
index 720008d..4dfa6a7 100644
--- a/src/backend/cdb/cdbtargeteddispatch.c
+++ b/src/backend/cdb/cdbtargeteddispatch.c
@@ -166,7 +166,6 @@ GetContentIdsFromPlanForSingleRelation(List *rtable, Plan 
*plan, int rangeTableI
        InitDirectDispatchCalculationInfo(&result);
 
        if ( nodeTag((Node*)plan) == T_BitmapHeapScan ||
-                nodeTag((Node*)plan) == T_BitmapAppendOnlyScan ||
                 nodeTag((Node*)plan) == T_BitmapTableScan)
        {
                /* do not assert for bitmap heap scan --> it can have a child 
which is an index scan */
@@ -471,7 +470,6 @@ AssignContentIdsToPlanData_Walker(Node *node, void *context)
                                /* no change to dispatchInfo --> just iterate 
children */
                                break;
                        case T_BitmapHeapScan:
-                       case T_BitmapAppendOnlyScan:
                        case T_BitmapTableScan:
                                /* no change to dispatchInfo --> just iterate 
children */
                                break;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/commands/analyze.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 1d25cb0..d0e2523 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -918,7 +918,6 @@ static void analyzeRelation(Relation relation, List 
*lAttributeNames, bool rooto
        List    *indexOidList = NIL;
        ListCell        *lc = NULL;
        StringInfoData location;
-       StringInfoData err_msg;
        
        initStringInfo(&location);
        relationOid             = RelationGetRelid(relation);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/commands/cluster.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index ab6b87e..9372efe 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -50,7 +50,6 @@
 #include "catalog/pg_type.h"
 #include "catalog/toasting.h"
 #include "catalog/aoseg.h"
-#include "catalog/aoblkdir.h"
 #include "catalog/pg_tablespace.h"
 #include "commands/cluster.h"
 #include "commands/tablecmds.h"
@@ -857,12 +856,6 @@ make_new_heap(Oid OIDOldHeap, const char *NewName, Oid 
NewTableSpace,
        AlterTableCreateAoSegTableWithOid(OIDNewHeap, aOid, aiOid,
                                                                          
aosegComptypeOid, is_part);
 
-    if ( createAoBlockDirectory )
-    {
-           AlterTableCreateAoBlkdirTableWithOid(OIDNewHeap, blkdirOid, 
blkdirIdxOid,
-                                                                               
 aoblkdirComptypeOid, is_part);
-    }
-
        cloneAttributeEncoding(OIDOldHeap,
                                                   OIDNewHeap,
                                                   
RelationGetNumberOfAttributes(OldHeap));

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/commands/explain.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 876b7ad..51afde2 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -1167,12 +1167,6 @@ explain_outNode(StringInfo str,
                case T_BitmapHeapScan:
                        pname = "Bitmap Heap Scan";
                        break;
-               case T_BitmapAppendOnlyScan:
-                       if (((BitmapAppendOnlyScan *)plan)->isAORow)
-                               pname = "Bitmap Append-Only Row-Oriented Scan";
-                       else
-                               pname = "Bitmap Append-Only Column-Oriented 
Scan";
-                       break;
                case T_BitmapTableScan:
                        pname = "Bitmap Table Scan";
                        break;
@@ -1355,7 +1349,6 @@ explain_outNode(StringInfo str,
                case T_DynamicTableScan:
                case T_DynamicIndexScan:
                case T_BitmapHeapScan:
-               case T_BitmapAppendOnlyScan:
                case T_BitmapTableScan:
                case T_TidScan:
                        if (((Scan *) plan)->scanrelid > 0)
@@ -1538,7 +1531,6 @@ explain_outNode(StringInfo str,
                                                   str, indent, es);
                        break;
                case T_BitmapHeapScan:
-               case T_BitmapAppendOnlyScan:
                case T_BitmapTableScan:
                        /* XXX do we want to show this in production? */
                        if (nodeTag(plan) == T_BitmapHeapScan)
@@ -1549,14 +1541,6 @@ explain_outNode(StringInfo str,
                                                           plan, outer_plan,
                                                           str, indent, es);
                        }
-                       else if (nodeTag(plan) == T_BitmapAppendOnlyScan)
-                       {
-                               show_scan_qual(((BitmapAppendOnlyScan *) 
plan)->bitmapqualorig,
-                                                          "Recheck Cond",
-                                                          ((Scan *) 
plan)->scanrelid,
-                                                          plan, outer_plan,
-                                                          str, indent, es);
-                       }
                        else if (nodeTag(plan) == T_BitmapTableScan)
                        {
                                show_scan_qual(((BitmapTableScan *) 
plan)->bitmapqualorig,
@@ -1901,7 +1885,6 @@ explain_outNode(StringInfo str,
                explain_outNode(str, outerPlan(plan),
                                                outerPlanState(planstate),
                                                (IsA(plan, BitmapHeapScan) |
-                                                IsA(plan, 
BitmapAppendOnlyScan) |
                                                 IsA(plan, BitmapTableScan)) ? 
outer_plan : NULL,
                                                indent + 3, es,isSequential);
        }

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/Makefile
----------------------------------------------------------------------
diff --git a/src/backend/executor/Makefile b/src/backend/executor/Makefile
index d2bf879..2589e6a 100644
--- a/src/backend/executor/Makefile
+++ b/src/backend/executor/Makefile
@@ -17,13 +17,13 @@ override CPPFLAGS := 
-I$(top_srcdir)/src/backend/gp_libpq_fe $(CPPFLAGS)
 OBJS = execAmi.o execGrouping.o execHHashagg.o execJunk.o execMain.o \
        execProcnode.o execQual.o execScan.o execTuples.o execGpmon.o \
        execUtils.o execWorkfile.o execHeapScan.o execAOScan.o 
execParquetScan.o\
-       execBitmapTableScan.o execBitmapHeapScan.o execBitmapAOScan.o 
execBitmapParquetScan.o execDynamicScan.o \
+       execBitmapTableScan.o execBitmapHeapScan.o execDynamicScan.o \
        execIndexscan.o \
        functions.o \
        instrument.o \
        nodeAppend.o nodeAgg.o \
        nodeBitmapAnd.o nodeBitmapOr.o \
-       nodeBitmapAppendOnlyscan.o nodeBitmapHeapscan.o nodeBitmapIndexscan.o 
nodeBitmapTableScan.o \
+       nodeBitmapHeapscan.o nodeBitmapIndexscan.o nodeBitmapTableScan.o \
        nodeExternalscan.o \
        nodeFunctionscan.o \
        nodeHash.o nodeHashjoin.o \

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/execAmi.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index 541ca8c..e51991a 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -46,7 +46,6 @@
 #include "executor/nodeTidscan.h"
 #include "executor/nodeUnique.h"
 #include "executor/nodeValuesscan.h"
-#include "executor/nodeBitmapAppendOnlyscan.h"
 #include "executor/nodeWindow.h"
 #include "executor/nodeShareInputScan.h"
 
@@ -188,10 +187,6 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
                        ExecValuesReScan((ValuesScanState *) node, exprCtxt);
                        break;
 
-               case T_BitmapAppendOnlyScanState:
-                       ExecBitmapAppendOnlyReScan((BitmapAppendOnlyScanState 
*) node, exprCtxt);
-                       break;
-
                case T_NestLoopState:
                        ExecReScanNestLoop((NestLoopState *) node, exprCtxt);
                        break;
@@ -640,11 +635,7 @@ ExecEagerFree(PlanState *node)
                case T_BitmapHeapScanState:
                        ExecEagerFreeBitmapHeapScan((BitmapHeapScanState 
*)node);
                        break;
-                       
-               case T_BitmapAppendOnlyScanState:
-                       
ExecEagerFreeBitmapAppendOnlyScan((BitmapAppendOnlyScanState *)node);
-                       break;
-                       
+
                case T_BitmapTableScanState:
                        ExecEagerFreeBitmapTableScan((BitmapTableScanState 
*)node);
                        break;
@@ -788,7 +779,6 @@ ExecEagerFreeChildNodes(PlanState *node, bool subplanDone)
                case T_ExternalScanState:
                case T_IndexScanState:
                case T_BitmapHeapScanState:
-               case T_BitmapAppendOnlyScanState:
                case T_FunctionScanState:
                case T_MaterialState:
                case T_SortState:

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/execBitmapAOScan.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execBitmapAOScan.c 
b/src/backend/executor/execBitmapAOScan.c
deleted file mode 100644
index 94ef8f4..0000000
--- a/src/backend/executor/execBitmapAOScan.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * execBitmapAOScan.c
- *   Support routines for scanning AO and AOCO tables using bitmaps.
- *
- * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- */
-#include "postgres.h"
-
-#include "access/heapam.h"
-#include "executor/execdebug.h"
-#include "executor/nodeBitmapAppendOnlyscan.h"
-#include "cdb/cdbappendonlyam.h"
-#include "pgstat.h"
-#include "utils/memutils.h"
-#include "miscadmin.h"
-#include "parser/parsetree.h"
-#include "cdb/cdbvars.h" /* gp_select_invisible */
-#include "nodes/tidbitmap.h"
-
-typedef struct
-{
-       int                     tupleIndex;
-       int                     nTuples;
-} AOIteratorState;
-
-/*
- * Prepares for a new AO scan.
- */
-void
-BitmapAOScanBegin(ScanState *scanState)
-{
-       BitmapTableScanState *node = (BitmapTableScanState *)(scanState);
-       Relation currentRelation = node->ss.ss_currentRelation;
-       EState *estate = node->ss.ps.state;
-
-       if (scanState->tableType == TableTypeAppendOnly)
-       {
-               node->scanDesc =
-                       appendonly_fetch_init(currentRelation,
-                                                                 
estate->es_snapshot);
-       }
-       else if (scanState->tableType == TableTypeParquet)
-       {
-         Assert(!"BitmapScan for Parquet is not supported yet");
-      /*
-       * Obtain the projection.
-       */
-      Assert(currentRelation->rd_att != NULL);
-
-      bool *proj = (bool *)palloc0(sizeof(bool) * 
currentRelation->rd_att->natts);
-
-      GetNeededColumnsForScan((Node *) node->ss.ps.plan->targetlist, proj, 
currentRelation->rd_att->natts);
-      GetNeededColumnsForScan((Node *) node->ss.ps.plan->qual, proj, 
currentRelation->rd_att->natts);
-
-      int colno = 0;
-
-      /* Check if any column is projected */
-      for(colno = 0; colno < currentRelation->rd_att->natts; colno++)
-      {
-        if(proj[colno])
-        {
-          break;
-        }
-      }
-
-      /*
-       * At least project one column. Since the tids stored in the index may 
not have
-       * a corresponding tuple any more (because of previous crashes, for 
example), we
-       * need to read the tuple to make sure.
-       */
-      if(colno == currentRelation->rd_att->natts)
-      {
-        proj[0] = true;
-      }
-
-      /*
-        node->scanDesc =
-            parquet_fetch_init(currentRelation, estate->es_snapshot, proj);
-       */
-       }
-       else
-       {
-               Assert(!"Invalid table type");
-       }
-
-
-       /*
-        * AO doesn't need rechecking every tuple once it resolves
-        * from the bitmap page, except when it deals with lossy
-        * bitmap, which is handled via scanState->isLossyBitmapPage.
-        */
-       node->recheckTuples = false;
-}
-
-/*
- * Cleans up after the scanning is done.
- */
-void
-BitmapAOScanEnd(ScanState *scanState)
-{
-       BitmapTableScanState *node = (BitmapTableScanState *)scanState;
-       Assert(node->ss.scan_state == SCAN_SCAN);
-
-       if (scanState->tableType == TableTypeAppendOnly)
-       {
-               appendonly_fetch_finish((AppendOnlyFetchDesc)node->scanDesc);
-       }
-       else if (scanState->tableType == TableTypeParquet)
-       {
-         Assert(!"BitmapScan for Parquet is not supported yet");
-         /*
-               pfree(((AOCSFetchDesc)node->scanDesc)->proj);
-               aocs_fetch_finish(node->scanDesc);
-               */
-       }
-       else
-       {
-               Assert(!"Invalid table type");
-       }
-       pfree(node->scanDesc);
-       node->scanDesc = NULL;
-
-       if (node->iterator)
-       {
-               pfree(node->iterator);
-               node->iterator = NULL;
-       }
-}
-
-/*
- * Returns the next matching tuple.
- */
-TupleTableSlot *
-BitmapAOScanNext(ScanState *scanState)
-{
-       BitmapTableScanState *node = (BitmapTableScanState *)scanState;
-
-       TupleTableSlot *slot = node->ss.ss_ScanTupleSlot;
-
-       TBMIterateResult *tbmres = (TBMIterateResult *)node->tbmres;
-
-       /* Make sure we never cross 15-bit offset number [MPP-24326] */
-       Assert(tbmres->ntuples <= INT16_MAX + 1);
-
-       OffsetNumber psuedoHeapOffset;
-       ItemPointerData psudeoHeapTid;
-       AOTupleId aoTid;
-
-       Assert(tbmres != NULL && tbmres->ntuples != 0);
-       Assert(node->needNewBitmapPage == false);
-
-       AOIteratorState *iterator = (AOIteratorState *)node->iterator;
-       for (;;)
-       {
-               CHECK_FOR_INTERRUPTS();
-
-               if (iterator == NULL)
-               {
-                       iterator = palloc0(sizeof(AOIteratorState));
-
-                       if (node->isLossyBitmapPage)
-                       {
-                               /* Iterate over the first 2^15 tuples 
[MPP-24326] */
-                               iterator->nTuples = INT16_MAX + 1;
-                       }
-                       else
-                       {
-                               iterator->nTuples = tbmres->ntuples;
-                       }
-                       /* Start from the beginning of the page */
-                       iterator->tupleIndex = 0;
-
-                       node->iterator = iterator;
-               }
-               else
-               {
-                       /*
-                        * Continuing in previously obtained page; advance 
tupleIndex
-                        */
-                       iterator->tupleIndex++;
-               }
-
-               /*
-                * Out of range?  If so, nothing more to look at on this page
-                */
-               if (iterator->tupleIndex < 0 || iterator->tupleIndex >= 
iterator->nTuples)
-               {
-                       pfree(iterator);
-
-                       node->iterator = NULL;
-
-                       node->needNewBitmapPage = true;
-
-                       return ExecClearTuple(slot);
-               }
-
-               /*
-                * Must account for lossy page info...
-                */
-               if (node->isLossyBitmapPage)
-               {
-                       /* We are iterating through all items. */
-                       psuedoHeapOffset = iterator->tupleIndex;
-               }
-               else
-               {
-                       Assert(iterator->tupleIndex <= tbmres->ntuples);
-                       psuedoHeapOffset = 
tbmres->offsets[iterator->tupleIndex];
-
-                       /*
-                        * Ensure that the reserved 16-th bit is always ON for 
offsets from
-                        * lossless bitmap pages [MPP-24326].
-                        */
-                       Assert(((uint16)(psuedoHeapOffset & 0x8000)) > 0);
-               }
-
-               /*
-                * Okay to fetch the tuple
-                */
-               ItemPointerSet(
-                               &psudeoHeapTid,
-                               tbmres->blockno,
-                               psuedoHeapOffset);
-
-               tbm_convert_appendonly_tid_out(&psudeoHeapTid, &aoTid);
-
-               if (scanState->tableType == TableTypeAppendOnly)
-               {
-                       appendonly_fetch((AppendOnlyFetchDesc)node->scanDesc, 
&aoTid, slot);
-               }
-               else if (scanState->tableType == TableTypeParquet)
-               {
-                 Assert(!"BitmapScan for Parquet is not supported yet");
-                 /*
-                       Assert(scanState->tableType == TableTypeAOCS);
-                       aocs_fetch((AOCSFetchDesc)node->scanDesc, &aoTid, slot);
-                       */
-               }
-
-       if (TupIsNull(slot))
-       {
-                       continue;
-       }
-
-               Assert(ItemPointerIsValid(slot_get_ctid(slot)));
-
-               pgstat_count_heap_fetch(node->ss.ss_currentRelation);
-
-               if (!BitmapTableScanRecheckTuple(node, slot))
-               {
-                       ExecClearTuple(slot);
-                       continue;
-               }
-
-               return slot;
-       }
-
-       /*
-        * We should never reach here as the termination is handled
-        * from nodeBitmapTableScan.
-        */
-       Assert(false);
-       return NULL;
-}
-
-/*
- * Prepares for a re-scan.
- */
-void
-BitmapAOScanReScan(ScanState *scanState)
-{
-       /*
-        * As per the existing implementation from nodeBitmapAppendOnlyScan.c
-        * for rescanning of AO, we don't have anything specific
-        * to do here (the refactored BitmapTableScan takes care of everything).
-        */
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/execBitmapParquetScan.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execBitmapParquetScan.c 
b/src/backend/executor/execBitmapParquetScan.c
deleted file mode 100644
index ec960b6..0000000
--- a/src/backend/executor/execBitmapParquetScan.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/*
- * execBitmapParquetScan.c
- *   Support routines for scanning parquet tables using bitmaps.
- *
- */
-
-#include "postgres.h"
-#include "nodes/execnodes.h"
-#include "executor/tuptable.h"
-
-void BitmapParquetScanBegin(ScanState *scanState);
-void BitmapParquetScanEnd(ScanState *scanState);
-TupleTableSlot* BitmapParquetScanNext(ScanState *scanState);
-void BitmapParquetScanReScan(ScanState *scanState);
-
-/*
- * Prepares for a new parquet scan.
- */
-void
-BitmapParquetScanBegin(ScanState *scanState)
-{
-       Insist(!"Bitmap index scan on parquet table is not supported");
-}
-
-/*
- * Cleans up after the scanning is done.
- */
-void
-BitmapParquetScanEnd(ScanState *scanState)
-{
-       Insist(!"Bitmap index scan on parquet table is not supported");
-}
-
-/*
- * Returns the next matching tuple.
- */
-TupleTableSlot *
-BitmapParquetScanNext(ScanState *scanState)
-{
-       Insist(!"Bitmap index scan on parquet table is not supported");
-}
-
-/*
- * Prepares for a re-scan.
- */
-void
-BitmapParquetScanReScan(ScanState *scanState)
-{
-       Insist(!"Bitmap index scan on parquet table is not supported");
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/execBitmapTableScan.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execBitmapTableScan.c 
b/src/backend/executor/execBitmapTableScan.c
index aa4a491..066624e 100644
--- a/src/backend/executor/execBitmapTableScan.c
+++ b/src/backend/executor/execBitmapTableScan.c
@@ -62,20 +62,6 @@ getBitmapTableScanMethod(TableType tableType)
                {
                        &BitmapHeapScanNext, &BitmapHeapScanBegin, 
&BitmapHeapScanEnd,
                        &BitmapHeapScanReScan, &MarkRestrNotAllowed, 
&MarkRestrNotAllowed
-               },
-               {
-                       &BitmapAOScanNext, &BitmapAOScanBegin, &BitmapAOScanEnd,
-                       &BitmapAOScanReScan, &MarkRestrNotAllowed, 
&MarkRestrNotAllowed
-               },
-               {
-                       /* The same set of methods serve both AO and AOCO scans 
*/
-                       &BitmapAOScanNext, &BitmapAOScanBegin, &BitmapAOScanEnd,
-                       &BitmapAOScanReScan, &MarkRestrNotAllowed, 
&MarkRestrNotAllowed
-               },
-               {
-                       /* The same set of methods serve both AO and AOCO scans 
*/
-                       &BitmapParquetScanNext, &BitmapParquetScanBegin, 
&BitmapParquetScanEnd,
-                       &BitmapParquetScanReScan, &MarkRestrNotAllowed, 
&MarkRestrNotAllowed
                }
        };
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/execMain.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 444d9a4..1c215b0 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -65,7 +65,6 @@
 #include "catalog/namespace.h"
 #include "catalog/toasting.h"
 #include "catalog/aoseg.h"
-#include "catalog/aoblkdir.h"
 #include "catalog/catalog.h"
 #include "catalog/pg_attribute_encoding.h"
 #include "catalog/pg_type.h"

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/execProcnode.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execProcnode.c 
b/src/backend/executor/execProcnode.c
index d3ad168..0cc8716 100644
--- a/src/backend/executor/execProcnode.c
+++ b/src/backend/executor/execProcnode.c
@@ -109,7 +109,6 @@
 #include "executor/nodeBitmapIndexscan.h"
 #include "executor/nodeBitmapTableScan.h"
 #include "executor/nodeBitmapOr.h"
-#include "executor/nodeBitmapAppendOnlyscan.h"
 #include "executor/nodeExternalscan.h"
 #include "executor/nodeTableScan.h"
 #include "executor/nodeDML.h"
@@ -265,8 +264,7 @@ ExecInitNode(Plan *node, EState *estate, int eflags)
         */
        if (force_bitmap_table_scan)
        {
-               if (IsA(node, BitmapHeapScan) ||
-                               IsA(node, BitmapAppendOnlyScan))
+               if (IsA(node, BitmapHeapScan))
                {
                        node->type = T_BitmapTableScan;
                }
@@ -417,17 +415,6 @@ ExecInitNode(Plan *node, EState *estate, int eflags)
                        END_MEMORY_ACCOUNT();
                        break;
 
-               case T_BitmapAppendOnlyScan:
-                       curMemoryAccount = 
CREATE_EXECUTOR_MEMORY_ACCOUNT(isAlienPlanNode, node, BitmapAppendOnlyScan);
-
-                       START_MEMORY_ACCOUNT(curMemoryAccount);
-                       {
-                       result = (PlanState *) 
ExecInitBitmapAppendOnlyScan((BitmapAppendOnlyScan*) node,
-                                                                               
                                        estate, eflags);
-                       }
-                       END_MEMORY_ACCOUNT();
-                       break;
-
                case T_BitmapTableScan:
                        curMemoryAccount = 
CREATE_EXECUTOR_MEMORY_ACCOUNT(isAlienPlanNode, node, BitmapTableScan);
 
@@ -842,7 +829,6 @@ ExecProcNode(PlanState *node)
                &&Exec_Jmp_DynamicIndexScan,
                &&Exec_Jmp_BitmapIndexScan,
                &&Exec_Jmp_BitmapHeapScan,
-               &&Exec_Jmp_BitmapAppendOnlyScan,
                &&Exec_Jmp_BitmapTableScan,
                &&Exec_Jmp_TidScan,
                &&Exec_Jmp_SubqueryScan,
@@ -945,10 +931,6 @@ Exec_Jmp_BitmapHeapScan:
        result = ExecBitmapHeapScan((BitmapHeapScanState *) node);
        goto Exec_Jmp_Done;
 
-Exec_Jmp_BitmapAppendOnlyScan:
-       result = ExecBitmapAppendOnlyScan((BitmapAppendOnlyScanState *) node);
-       goto Exec_Jmp_Done;
-
 Exec_Jmp_BitmapTableScan:
        result = ExecBitmapTableScan((BitmapTableScanState *) node);
        goto Exec_Jmp_Done;
@@ -1369,9 +1351,6 @@ ExecCountSlotsNode(Plan *node)
 
                case T_BitmapHeapScan:
                        return ExecCountSlotsBitmapHeapScan((BitmapHeapScan *) 
node);
-
-               case T_BitmapAppendOnlyScan:
-                       return 
ExecCountSlotsBitmapAppendOnlyScan((BitmapAppendOnlyScan*) node);
                        
                case T_BitmapTableScan:
                        return ExecCountSlotsBitmapTableScan((BitmapTableScan 
*) node);
@@ -1649,10 +1628,6 @@ ExecEndNode(PlanState *node)
                        ExecEndBitmapHeapScan((BitmapHeapScanState *) node);
                        break;
 
-               case T_BitmapAppendOnlyScanState:
-                       ExecEndBitmapAppendOnlyScan((BitmapAppendOnlyScanState 
*) node);
-                       break;
-
                case T_BitmapTableScanState:
                        ExecEndBitmapTableScan((BitmapTableScanState *) node);
                        break;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/execUtils.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 399584f..ffd756d 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -2341,7 +2341,6 @@ void (*initGpmonPktFuncs[])(Plan *planNode, 
gpmon_packet_t *gpmon_pkt, EState *e
        &initGpmonPktForDynamicIndexScan, /* T_DynamicIndexScan */
        &initGpmonPktForBitmapIndexScan, /* T_BitmapIndexScan */
        &initGpmonPktForBitmapHeapScan, /* T_BitmapHeapScan */
-       &initGpmonPktForBitmapAppendOnlyScan, /* T_BitmapAppendOnlyScan */
        &initGpmonPktForBitmapTableScan, /* T_BitmapTableScan */
        &initGpmonPktForTidScan, /* T_TidScan */
        &initGpmonPktForSubqueryScan, /* T_SubqueryScan */
@@ -2480,7 +2479,6 @@ sendInitGpmonPkts(Plan *node, EState *estate)
 
                case T_Result:
                case T_BitmapHeapScan:
-               case T_BitmapAppendOnlyScan:
                case T_BitmapTableScan:
                case T_ShareInputScan:
                case T_Material:

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/executor/nodeBitmapAppendOnlyscan.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/nodeBitmapAppendOnlyscan.c 
b/src/backend/executor/nodeBitmapAppendOnlyscan.c
deleted file mode 100755
index 77316cf..0000000
--- a/src/backend/executor/nodeBitmapAppendOnlyscan.c
+++ /dev/null
@@ -1,612 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*-------------------------------------------------------------------------
- *
- * nodeBitmapAppendOnlyscan.c
- *       Routines to support bitmapped scan from Append-Only relations
- *
- * This is a modified copy of nodeBitmapHeapscan.c converted to Append-Only.
- *
- *
- * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- * Portions Copyright (c) 2008-2009, Greenplum Inc.
- *
- *-------------------------------------------------------------------------
- */
-/*
- * INTERFACE ROUTINES
- *             ExecBitmapAppendOnlyScan                scan from an AO 
relation using bitmap info
- *             ExecBitmapAppendOnlyNext                workhorse for above
- *             ExecInitBitmapAppendOnlyScan    creates and initializes state 
info.
- *             ExecBitmapAppendOnlyReScan      prepares to rescan the plan.
- *             ExecEndBitmapAppendOnlyScan     releases all storage.
- */
-#include "postgres.h"
-
-#include "access/heapam.h"
-#include "executor/execdebug.h"
-#include "executor/nodeBitmapAppendOnlyscan.h"
-#include "cdb/cdbappendonlyam.h"
-#include "pgstat.h"
-#include "utils/memutils.h"
-#include "miscadmin.h"
-#include "parser/parsetree.h"
-#include "cdb/cdbvars.h" /* gp_select_invisible */
-#include "nodes/tidbitmap.h"
-
-static TupleTableSlot *BitmapAppendOnlyScanNext(BitmapAppendOnlyScanState 
*node);
-
-/*
- * Initialize the fetch descriptor for the BitmapAppendOnlyScanState if
- * it is not initialized.
- */
-static void
-initFetchDesc(BitmapAppendOnlyScanState *scanstate)
-{
-       BitmapAppendOnlyScan *node = (BitmapAppendOnlyScan 
*)(scanstate->ss.ps.plan);
-       Relation currentRelation = scanstate->ss.ss_currentRelation;
-       EState *estate = scanstate->ss.ps.state;
-
-       if (node->isAORow)
-       {
-               if (scanstate->baos_currentAOFetchDesc == NULL)
-               {
-                       scanstate->baos_currentAOFetchDesc = 
-                               appendonly_fetch_init(currentRelation,
-                                                                         
estate->es_snapshot);
-               }
-       }
-       
-}
-
-/*
- * Free fetch descriptor.
- */
-static inline void
-freeFetchDesc(BitmapAppendOnlyScanState *scanstate)
-{
-       if (scanstate->baos_currentAOFetchDesc != NULL)
-       {
-               Assert(((BitmapAppendOnlyScan 
*)(scanstate->ss.ps.plan))->isAORow);
-               appendonly_fetch_finish(scanstate->baos_currentAOFetchDesc);
-               pfree(scanstate->baos_currentAOFetchDesc);
-               scanstate->baos_currentAOFetchDesc = NULL;
-       }
-
-}
-
-/*
- * Initialize the state relevant to bitmaps.
- */
-static inline void
-initBitmapState(BitmapAppendOnlyScanState *scanstate)
-{
-       if (scanstate->baos_tbmres == NULL)
-       {
-               scanstate->baos_tbmres =
-                       palloc(sizeof(TBMIterateResult) +
-                                       MAX_TUPLES_PER_PAGE * 
sizeof(OffsetNumber));
-
-               /* initialize result header */
-               MemSetAligned(scanstate->baos_tbmres, 0, 
sizeof(TBMIterateResult));
-       }
-}
-
-/*
- * Free the state relevant to bitmaps
- */
-static inline void
-freeBitmapState(BitmapAppendOnlyScanState *scanstate)
-{
-       if (scanstate->baos_tbm != NULL)
-       {
-               if(IsA(scanstate->baos_tbm, HashBitmap))
-                       tbm_free((HashBitmap *)scanstate->baos_tbm);
-               else
-            tbm_bitmap_free(scanstate->baos_tbm);
-
-               scanstate->baos_tbm = NULL;
-       }
-       if (scanstate->baos_tbmres != NULL)
-       {
-               pfree(scanstate->baos_tbmres);
-               scanstate->baos_tbmres = NULL;
-       }
-}
-
-/* ----------------------------------------------------------------
- *             BitmapAppendOnlyNext
- *
- *             Retrieve next tuple from the BitmapAppendOnlyScan node's 
currentRelation
- * ----------------------------------------------------------------
- */
-static TupleTableSlot *
-BitmapAppendOnlyScanNext(BitmapAppendOnlyScanState *node)
-{
-       EState     *estate;
-       ExprContext *econtext;
-       AppendOnlyFetchDesc aoFetchDesc;
-       Index           scanrelid;
-       Node            *tbm;
-       TBMIterateResult *tbmres;
-       OffsetNumber psuedoHeapOffset;
-       ItemPointerData psudeoHeapTid;
-       AOTupleId aoTid;
-       TupleTableSlot *slot;
-
-       /*
-        * extract necessary information from index scan node
-        */
-       estate = node->ss.ps.state;
-       econtext = node->ss.ps.ps_ExprContext;
-       slot = node->ss.ss_ScanTupleSlot;
-
-       initBitmapState(node);
-       initFetchDesc(node);
-
-       aoFetchDesc = node->baos_currentAOFetchDesc;
-       scanrelid = ((BitmapAppendOnlyScan *) node->ss.ps.plan)->scan.scanrelid;
-       tbm = node->baos_tbm;
-       tbmres = (TBMIterateResult *) node->baos_tbmres;
-       Assert(tbmres != NULL);
-
-       /*
-        * Check if we are evaluating PlanQual for tuple of this relation.
-        * Additional checking is not good, but no other way for now. We could
-        * introduce new nodes for this case and handle IndexScan --> NewNode
-        * switching in Init/ReScan plan...
-        */
-       if (estate->es_evTuple != NULL &&
-               estate->es_evTuple[scanrelid - 1] != NULL)
-       {
-               if (estate->es_evTupleNull[scanrelid - 1])
-               {
-                       freeFetchDesc(node);
-                       freeBitmapState(node);
-                       
-                       return ExecClearTuple(slot);
-               }
-
-               ExecStoreGenericTuple(estate->es_evTuple[scanrelid - 1],
-                                          slot, false);
-
-               /* Does the tuple meet the original qual conditions? */
-               econtext->ecxt_scantuple = slot;
-
-               ResetExprContext(econtext);
-
-               if (!ExecQual(node->baos_bitmapqualorig, econtext, false))
-               {
-                       ExecEagerFreeBitmapAppendOnlyScan(node);
-
-                       ExecClearTuple(slot);           /* would not be 
returned by scan */
-               }
-
-               /* Flag for the next call that no more tuples */
-               estate->es_evTupleNull[scanrelid - 1] = true;
-
-               if (!TupIsNull(slot))
-               {
-                       
Gpmon_M_Incr_Rows_Out(GpmonPktFromBitmapAppendOnlyScanState(node));
-                       CheckSendPlanStateGpmonPkt(&node->ss.ps);
-               }
-               return slot;
-       }
-
-       /*
-        * If we haven't yet performed the underlying index scan, or
-        * we have used up the bitmaps from the previous scan, do the next scan,
-        * and prepare the bitmap to be iterated over.
-        */
-       if (tbm == NULL)
-       {
-               tbm = (Node *) MultiExecProcNode(outerPlanState(node));
-
-               if (tbm != NULL && (!(IsA(tbm, HashBitmap) ||
-                                                         IsA(tbm, 
StreamBitmap))))
-                       elog(ERROR, "unrecognized result from subplan");
-
-               /* When a HashBitmap is returned, set the returning bitmaps
-                * in the subplan to NULL, so that the subplan nodes do not
-                * mistakenly try to release the space during the rescan.
-                */
-               if (tbm != NULL && IsA(tbm, HashBitmap))
-                       tbm_reset_bitmaps(outerPlanState(node));
-
-               node->baos_tbm = tbm;
-       }
-
-       if (tbm == NULL)
-       {
-               ExecEagerFreeBitmapAppendOnlyScan(node);
-
-               return ExecClearTuple(slot);
-       }
-
-       Assert(tbm != NULL);
-       Assert(tbmres != NULL);
-
-       for (;;)
-       {
-               CHECK_FOR_INTERRUPTS();
-
-               if (!node->baos_gotpage)
-               {
-                       /*
-                        * Obtain the next psuedo-heap-page-info with item 
bit-map.  Later, we'll
-                        * convert the (psuedo) heap block number and item 
number to an
-                        * Append-Only TID.
-                        */
-                       if (!tbm_iterate(tbm, tbmres))
-                       {
-                               /* no more entries in the bitmap */
-                               break;
-                       }
-
-                       /* If tbmres contains no tuples, continue. */
-                       if (tbmres->ntuples == 0)
-                               continue;
-
-                       
Gpmon_M_Incr(GpmonPktFromBitmapAppendOnlyScanState(node), 
GPMON_BITMAPAPPENDONLYSCAN_PAGE);
-                       CheckSendPlanStateGpmonPkt(&node->ss.ps);
-
-                       node->baos_gotpage = true;
-
-                       /*
-                       * Set cindex to first slot to examine
-                       */
-                       node->baos_cindex = 0;
-
-                       node->baos_lossy = (tbmres->ntuples < 0);
-                       if (!node->baos_lossy)
-                               node->baos_ntuples = tbmres->ntuples;
-                       else
-                               node->baos_ntuples = MAX_TUPLES_PER_PAGE;
-                               
-               }
-               else
-               {
-                       /*
-                        * Continuing in previously obtained page; advance 
cindex
-                        */
-                       node->baos_cindex++;
-               }
-
-               /*
-                * Out of range?  If so, nothing more to look at on this page
-                */
-               if (node->baos_cindex < 0 || node->baos_cindex >= 
node->baos_ntuples)
-               {
-                       node->baos_gotpage = false;
-                       continue;
-               }
-
-               /*
-                * Must account for lossy page info...
-                */
-               if (node->baos_lossy)
-                       psuedoHeapOffset = node->baos_cindex;   // We are 
iterating through all items.
-               else
-               {
-                       Assert(node->baos_cindex <= tbmres->ntuples);
-                       psuedoHeapOffset = tbmres->offsets[node->baos_cindex];
-               }
-
-               /*
-                * Okay to fetch the tuple
-                */
-               ItemPointerSet(
-                               &psudeoHeapTid, 
-                               tbmres->blockno, 
-                               psuedoHeapOffset);
-
-               tbm_convert_appendonly_tid_out(&psudeoHeapTid, &aoTid);
-
-               if (aoFetchDesc != NULL)
-               {
-                       appendonly_fetch(aoFetchDesc, &aoTid, slot);
-               }
-               
-       if (TupIsNull(slot))
-                       continue;
-
-               pgstat_count_heap_fetch(node->ss.ss_currentRelation);
-
-               /*
-                * If we are using lossy info, we have to recheck the qual
-                * conditions at every tuple.
-                */
-               if (node->baos_lossy)
-               {
-                       econtext->ecxt_scantuple = slot;
-                       ResetExprContext(econtext);
-
-                       if (!ExecQual(node->baos_bitmapqualorig, econtext, 
false))
-                       {
-                               /* Fails recheck, so drop it and loop back for 
another */
-                               ExecClearTuple(slot);
-                               continue;
-                       }
-               }
-
-               /* OK to return this tuple */
-       if (!TupIsNull(slot))
-               {
-                       
Gpmon_M_Incr_Rows_Out(GpmonPktFromBitmapAppendOnlyScanState(node));
-                       CheckSendPlanStateGpmonPkt(&node->ss.ps);
-               }
-
-               return slot;
-       }
-
-       /*
-        * if we get here it means we are at the end of the scan..
-        */
-       ExecEagerFreeBitmapAppendOnlyScan(node);
-
-       return ExecClearTuple(slot);
-}
-
-/* ----------------------------------------------------------------
- *             ExecBitmapAppendOnlyScan(node)
- * ----------------------------------------------------------------
- */
-TupleTableSlot *
-ExecBitmapAppendOnlyScan(BitmapAppendOnlyScanState *node)
-{
-       /*
-        * use BitmapAppendOnlyNext as access method
-        */
-       return ExecScan(&node->ss, (ExecScanAccessMtd) 
BitmapAppendOnlyScanNext);
-}
-
-/* ----------------------------------------------------------------
- *             ExecBitmapAppendOnlyReScan(node)
- * ----------------------------------------------------------------
- */
-void
-ExecBitmapAppendOnlyReScan(BitmapAppendOnlyScanState *node, ExprContext 
*exprCtxt)
-{
-       EState     *estate;
-       Index           scanrelid;
-
-       estate = node->ss.ps.state;
-       scanrelid = ((BitmapAppendOnlyScan *) node->ss.ps.plan)->scan.scanrelid;
-
-       /* node->aofs.ps.ps_TupFromTlist = false; */
-
-       /*
-        * If we are being passed an outer tuple, link it into the "regular"
-        * per-tuple econtext for possible qual eval.
-        */
-       if (exprCtxt != NULL)
-       {
-               ExprContext *stdecontext;
-
-               stdecontext = node->ss.ps.ps_ExprContext;
-               stdecontext->ecxt_outertuple = exprCtxt->ecxt_outertuple;
-       }
-
-       /* If this is re-scanning of PlanQual ... */
-       if (estate->es_evTuple != NULL &&
-               estate->es_evTuple[scanrelid - 1] != NULL)
-       {
-               estate->es_evTupleNull[scanrelid - 1] = false;
-       }
-
-       /*
-        * NOTE: The appendonly_fetch routine can fetch randomly, so no need to 
reset it.
-        */
-
-       freeBitmapState(node);
-       tbm_reset_bitmaps(outerPlanState(node));
-
-       /*
-        * Always rescan the input immediately, to ensure we can pass down any
-        * outer tuple that might be used in index quals.
-        */
-       Gpmon_M_Incr(GpmonPktFromBitmapAppendOnlyScanState(node), 
GPMON_BITMAPAPPENDONLYSCAN_RESCAN);
-       CheckSendPlanStateGpmonPkt(&node->ss.ps);
-
-       ExecReScan(outerPlanState(node), exprCtxt);
-}
-
-/* ----------------------------------------------------------------
- *             ExecEndBitmapAppendOnlyScan
- * ----------------------------------------------------------------
- */
-void
-ExecEndBitmapAppendOnlyScan(BitmapAppendOnlyScanState *node)
-{
-       Relation        relation;
-
-       /*
-        * extract information from the node
-        */
-       relation = node->ss.ss_currentRelation;
-
-       /*
-        * Free the exprcontext
-        */
-       ExecFreeExprContext(&node->ss.ps);
-
-       /*
-        * clear out tuple table slots
-        */
-       ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
-       ExecClearTuple(node->ss.ss_ScanTupleSlot);
-
-       /*
-        * close down subplans
-        */
-       ExecEndNode(outerPlanState(node));
-
-       ExecEagerFreeBitmapAppendOnlyScan(node);
-       
-       /*
-        * close the heap relation.
-        */
-       ExecCloseScanRelation(relation);
-
-       node->baos_gotpage = false;
-       node->baos_lossy = false;
-       node->baos_cindex = 0;
-       node->baos_ntuples = 0;
-
-       EndPlanStateGpmonPkt(&node->ss.ps);
-}
-
-/* ----------------------------------------------------------------
- *             ExecInitBitmapAppendOnlyScan
- *
- *             Initializes the scan's state information.
- * ----------------------------------------------------------------
- */
-BitmapAppendOnlyScanState *
-ExecInitBitmapAppendOnlyScan(BitmapAppendOnlyScan *node, EState *estate, int 
eflags)
-{
-       BitmapAppendOnlyScanState *scanstate;
-       Relation        currentRelation;
-
-       /* check for unsupported flags */
-       Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
-
-       Assert(IsA(node, BitmapAppendOnlyScan));
-
-       /*
-        * Assert caller didn't ask for an unsafe snapshot --- see comments at
-        * head of file.
-        *
-        * MPP-4703: the MVCC-snapshot restriction is required for correct 
results.
-        * our test-mode may deliberately return incorrect results, but that's 
OK.
-        */
-       Assert(IsMVCCSnapshot(estate->es_snapshot) || gp_select_invisible);
-
-       /*
-        * create state structure
-        */
-       scanstate = makeNode(BitmapAppendOnlyScanState);
-       scanstate->ss.ps.plan = (Plan *) node;
-       scanstate->ss.ps.state = estate;
-
-       scanstate->baos_tbm = NULL;
-       scanstate->baos_tbmres = NULL;
-       scanstate->baos_gotpage = false;
-       scanstate->baos_lossy = false;
-       scanstate->baos_cindex = 0;
-       scanstate->baos_ntuples = 0;
-
-       /*
-        * Miscellaneous initialization
-        *
-        * create expression context for node
-        */
-       ExecAssignExprContext(estate, &scanstate->ss.ps);
-
-       /* scanstate->aofs.ps.ps_TupFromTlist = false;*/
-
-       /*
-        * initialize child expressions
-        */
-       scanstate->ss.ps.targetlist = (List *)
-               ExecInitExpr((Expr *) node->scan.plan.targetlist,
-                                        (PlanState *) scanstate);
-       scanstate->ss.ps.qual = (List *)
-               ExecInitExpr((Expr *) node->scan.plan.qual,
-                                        (PlanState *) scanstate);
-       scanstate->baos_bitmapqualorig = (List *)
-               ExecInitExpr((Expr *) node->bitmapqualorig,
-                                        (PlanState *) scanstate);
-
-#define BITMAPAPPENDONLYSCAN_NSLOTS 2
-
-       /*
-        * tuple table initialization
-        */
-       ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
-       ExecInitScanTupleSlot(estate, &scanstate->ss);
-
-       /*
-        * open the base relation and acquire appropriate lock on it.
-        */
-       currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid);
-
-       scanstate->ss.ss_currentRelation = currentRelation;
-
-       /*
-        * get the scan type from the relation descriptor.
-        */
-       ExecAssignScanType(&scanstate->ss, RelationGetDescr(currentRelation));
-
-       /*
-        * Initialize result tuple type and projection info.
-        */
-       ExecAssignResultTypeFromTL(&scanstate->ss.ps);
-       ExecAssignScanProjectionInfo(&scanstate->ss);
-
-       scanstate->baos_currentAOFetchDesc = NULL;
-       
-       /*
-        * initialize child nodes
-        *
-        * We do this last because the child nodes will open indexscans on our
-        * relation's indexes, and we want to be sure we have acquired a lock on
-        * the relation first.
-        */
-       outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate, 
eflags);
-
-       initGpmonPktForBitmapAppendOnlyScan((Plan *)node, 
&scanstate->ss.ps.gpmon_pkt, estate);
-
-       /*
-        * all done.
-        */
-       return scanstate;
-}
-
-int
-ExecCountSlotsBitmapAppendOnlyScan(BitmapAppendOnlyScan *node)
-{
-       return ExecCountSlotsNode(outerPlan((Plan *) node)) +
-               ExecCountSlotsNode(innerPlan((Plan *) node)) + 
BITMAPAPPENDONLYSCAN_NSLOTS;
-}
-
-void
-initGpmonPktForBitmapAppendOnlyScan(Plan *planNode, gpmon_packet_t *gpmon_pkt, 
EState *estate)
-{
-       Assert(planNode != NULL && gpmon_pkt != NULL && IsA(planNode, 
BitmapAppendOnlyScan));
-
-       {
-               RangeTblEntry *rte = rt_fetch(((BitmapAppendOnlyScan 
*)planNode)->scan.scanrelid,
-                                                                         
estate->es_range_table);
-               char schema_rel_name[SCAN_REL_NAME_BUF_SIZE] = {0};
-               
-               Assert(GPMON_BITMAPAPPENDONLYSCAN_TOTAL <= 
(int)GPMON_QEXEC_M_COUNT);
-               InitPlanNodeGpmonPkt(planNode, gpmon_pkt, estate, 
PMNT_BitmapAppendOnlyScan,
-                                                        
(int64)planNode->plan_rows,
-                                                        
GetScanRelNameGpmon(rte->relid, schema_rel_name));
-       }
-}
-
-void
-ExecEagerFreeBitmapAppendOnlyScan(BitmapAppendOnlyScanState *node)
-{
-       freeFetchDesc(node);
-       freeBitmapState(node);
-}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/gp_libpq_fe/fe-protocol3.c
----------------------------------------------------------------------
diff --git a/src/backend/gp_libpq_fe/fe-protocol3.c 
b/src/backend/gp_libpq_fe/fe-protocol3.c
index ac4eeb9..4143d49 100644
--- a/src/backend/gp_libpq_fe/fe-protocol3.c
+++ b/src/backend/gp_libpq_fe/fe-protocol3.c
@@ -610,12 +610,6 @@ pqParseInput3(PGconn *conn)
                                                        if 
(pqGetInt64(&(sendback[i].uncompressed_eof[j]), conn))
                                                                                
return;
                                                }
-
-                                               /*
-                                                * 10, get fast sequence.
-                                                */
-                                               if 
(pqGetInt64(&(sendback[i].nextFastSequence), conn))
-                                                               return;
                                        }
                                }
                                        break;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/nodes/copyfuncs.c
----------------------------------------------------------------------
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 94527b4..8f48008 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -587,28 +587,6 @@ _copyBitmapHeapScan(BitmapHeapScan *from)
 }
 
 /*
- * _copyBitmapAppendOnlyScan
- */
-static BitmapAppendOnlyScan *
-_copyBitmapAppendOnlyScan(BitmapAppendOnlyScan *from)
-{
-       BitmapAppendOnlyScan *newnode = makeNode(BitmapAppendOnlyScan);
-
-       /*
-        * copy node superclass fields
-        */
-       CopyScanFields((Scan *) from, (Scan *) newnode);
-
-       /*
-        * copy remainder of node
-        */
-       COPY_NODE_FIELD(bitmapqualorig);
-       COPY_SCALAR_FIELD(isAORow);
-
-       return newnode;
-}
-
-/*
  * _copyBitmapTableScan
  */
 static BitmapTableScan *
@@ -4449,9 +4427,6 @@ copyObject(void *from)
                case T_BitmapHeapScan:
                        retval = _copyBitmapHeapScan(from);
                        break;
-               case T_BitmapAppendOnlyScan:
-                       retval = _copyBitmapAppendOnlyScan(from);
-                       break;
                case T_BitmapTableScan:
                        retval = _copyBitmapTableScan(from);
                        break;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/nodes/outfast.c
----------------------------------------------------------------------
diff --git a/src/backend/nodes/outfast.c b/src/backend/nodes/outfast.c
index 4600c88..ac943c9 100644
--- a/src/backend/nodes/outfast.c
+++ b/src/backend/nodes/outfast.c
@@ -689,17 +689,6 @@ _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
 }
 
 static void
-_outBitmapAppendOnlyScan(StringInfo str, BitmapAppendOnlyScan *node)
-{
-       WRITE_NODE_TYPE("BITMAPAPPENDONLYSCAN");
-
-       _outScanInfo(str, (Scan *) node);
-
-       WRITE_LIST_FIELD(bitmapqualorig);
-       WRITE_BOOL_FIELD(isAORow);
-}
-
-static void
 _outBitmapTableScan(StringInfo str, BitmapTableScan *node)
 {
        WRITE_NODE_TYPE("BITMAPTABLESCAN");
@@ -3997,9 +3986,6 @@ _outNode(StringInfo str, void *obj)
                        case T_BitmapHeapScan:
                                _outBitmapHeapScan(str, obj);
                                break;
-                       case T_BitmapAppendOnlyScan:
-                               _outBitmapAppendOnlyScan(str, obj);
-                               break;
                        case T_BitmapTableScan:
                                _outBitmapTableScan(str, obj);
                                break;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/nodes/outfuncs.c
----------------------------------------------------------------------
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 2b6aad2..0f35610 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -4176,9 +4176,6 @@ _outNode(StringInfo str, void *obj)
                        case T_BitmapHeapScan:
                                _outBitmapHeapScan(str, obj);
                                break;
-                       case T_BitmapAppendOnlyScan:
-                               _outBitmapAppendOnlyScan(str, obj);
-                               break;
                        case T_BitmapTableScan:
                                _outBitmapTableScan(str, obj);
                                break;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/nodes/print.c
----------------------------------------------------------------------
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c
index 75e015f..03367b0 100644
--- a/src/backend/nodes/print.c
+++ b/src/backend/nodes/print.c
@@ -529,8 +529,6 @@ char * plannode_type(Plan *p)
                        return "FUNCTIONSCAN";
                case T_ValuesScan:
                        return "VALUESSCAN";
-               case T_BitmapAppendOnlyScan:
-                       return "BITMAPAPPENDONLYSCAN";
                case T_BitmapTableScan:
                        return "BITMAPTABLESCAN";
                case T_Join:
@@ -588,8 +586,7 @@ print_plan_recursive(struct Plan *p, struct Query 
*parsetree, int indentLevel, c
                   p->plan_rows, p->plan_width);
        if (IsA(p, Scan) ||
                IsA(p, SeqScan) ||
-               IsA(p, BitmapHeapScan) ||
-               IsA(p, BitmapAppendOnlyScan))
+               IsA(p, BitmapHeapScan))
        {
                RangeTblEntry *rte;
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/nodes/readfast.c
----------------------------------------------------------------------
diff --git a/src/backend/nodes/readfast.c b/src/backend/nodes/readfast.c
index 38caa38..cfdcc06 100644
--- a/src/backend/nodes/readfast.c
+++ b/src/backend/nodes/readfast.c
@@ -3195,19 +3195,6 @@ _readBitmapHeapScan(const char ** str)
        READ_DONE();
 }
 
-static BitmapAppendOnlyScan *
-_readBitmapAppendOnlyScan(const char ** str)
-{
-       READ_LOCALS(BitmapAppendOnlyScan);
-
-       readScanInfo(str, (Scan *)local_node);
-
-       READ_NODE_FIELD(bitmapqualorig);
-       READ_BOOL_FIELD(isAORow);
-
-       READ_DONE();
-}
-
 static BitmapTableScan *
 _readBitmapTableScan(const char ** str)
 {
@@ -4268,9 +4255,6 @@ readNodeBinary(const char ** str)
                        case T_BitmapHeapScan:
                                return_value = _readBitmapHeapScan(str);
                                break;
-                       case T_BitmapAppendOnlyScan:
-                               return_value = _readBitmapAppendOnlyScan(str);
-                               break;
                        case T_BitmapTableScan:
                                return_value = _readBitmapTableScan(str);
                                break;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/optimizer/path/indxpath.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/path/indxpath.c 
b/src/backend/optimizer/path/indxpath.c
index 25d2114..e8baea8 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -157,9 +157,6 @@ create_bitmap_scan_path(char relstorage,
                case RELSTORAGE_HEAP:
                        path = (Path *)create_bitmap_heap_path(root, rel, 
bitmapqual, outer_rel);
                        break;
-               case RELSTORAGE_AOROWS:
-                       path = (Path *)create_bitmap_appendonly_path(root, rel, 
bitmapqual, outer_rel, true);
-                       break;
                default:
                        elog(ERROR, "unrecognized relstorage type %d for using 
bitmap scan path",
                                 relstorage);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/optimizer/plan/createplan.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/plan/createplan.c 
b/src/backend/optimizer/plan/createplan.c
index 09da978..ba6069d 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -119,9 +119,6 @@ static TableFunctionScan 
*create_tablefunction_plan(CreatePlanContext *ctx,
                                                                                
                        List *scan_clauses);
 static ValuesScan *create_valuesscan_plan(CreatePlanContext *ctx, Path 
*best_path,
                                           List *tlist, List *scan_clauses);
-static BitmapAppendOnlyScan 
*create_bitmap_appendonly_scan_plan(CreatePlanContext *ctx,
-                                               BitmapAppendOnlyPath *best_path,
-                                               List *tlist, List 
*scan_clauses);
 static Plan *create_nestloop_plan(CreatePlanContext *ctx, NestPath *best_path,
                                         Plan *outer_plan, Plan *inner_plan);
 static MergeJoin *create_mergejoin_plan(CreatePlanContext *ctx, MergePath 
*best_path,
@@ -167,12 +164,6 @@ static BitmapHeapScan *make_bitmap_heapscan(List *qptlist,
                                         Plan *lefttree,
                                         List *bitmapqualorig,
                                         Index scanrelid);
-static BitmapAppendOnlyScan *make_bitmap_appendonlyscan(List *qptlist,
-                                                                               
                                List *qpqual,
-                                                                               
                                Plan *lefttree,
-                                                                               
                                List *bitmapqualorig,
-                                                                               
                                Index scanrelid,
-                                                                               
                                bool isAORow);
 static TableFunctionScan* make_tablefunction(List *tlist,
                                                                                
         List *scan_quals,
                                                                                
         Plan *subplan,
@@ -250,7 +241,6 @@ create_subplan(CreatePlanContext *ctx, Path *best_path)
                case T_AppendOnlyScan:
                case T_ParquetScan:
                case T_BitmapHeapScan:
-               case T_BitmapAppendOnlyScan:
                case T_BitmapTableScan:
                case T_TidScan:
                case T_SubqueryScan:
@@ -383,13 +373,6 @@ create_scan_plan(CreatePlanContext *ctx, Path *best_path)
                                                                                
                        scan_clauses);
                        break;
 
-               case T_BitmapAppendOnlyScan:
-                       plan = (Plan *) create_bitmap_appendonly_scan_plan(ctx,
-                                                                               
                    (BitmapAppendOnlyPath *) best_path,
-                                                                               
                        tlist,
-                                                                               
                        scan_clauses);
-                       break;
-
                case T_TidScan:
                        plan = (Plan *) create_tidscan_plan(ctx,
                                                                                
                (TidPath *) best_path,
@@ -565,7 +548,6 @@ disuse_physical_tlist(Plan *plan, Path *path)
                case T_ExternalScan:
                case T_IndexScan:
                case T_BitmapHeapScan:
-               case T_BitmapAppendOnlyScan:
                case T_BitmapTableScan:
                case T_TidScan:
                case T_SubqueryScan:
@@ -2196,118 +2178,6 @@ create_bitmap_scan_plan(CreatePlanContext *ctx,
 }
 
 /*
- * create_bitmap_appendonly_scan_plan
- *
- * NOTE: Copy of create_bitmap_scan_plan routine.
- */
-static BitmapAppendOnlyScan *
-create_bitmap_appendonly_scan_plan(CreatePlanContext *ctx,
-                                               BitmapAppendOnlyPath *best_path,
-                                               List *tlist,
-                                               List *scan_clauses)
-{
-       Index           baserelid = best_path->path.parent->relid;
-       Plan       *bitmapqualplan;
-       List       *bitmapqualorig = NULL;
-       List       *indexquals = NULL;
-       List       *qpqual;
-       ListCell   *l;
-       BitmapAppendOnlyScan *scan_plan;
-
-       /* it should be a base rel... */
-       Assert(baserelid > 0);
-       Assert(best_path->path.parent->rtekind == RTE_RELATION);
-
-       /* Process the bitmapqual tree into a Plan tree and qual lists */
-       bitmapqualplan = create_bitmap_subplan(ctx, best_path->bitmapqual,
-                                                                               
   &bitmapqualorig, &indexquals);
-
-       /* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants 
*/
-       scan_clauses = extract_actual_clauses(scan_clauses, false);
-
-       /*
-        * If this is a innerjoin scan, the indexclauses will contain join 
clauses
-        * that are not present in scan_clauses (since the passed-in value is 
just
-        * the rel's baserestrictinfo list).  We must add these clauses to
-        * scan_clauses to ensure they get checked.  In most cases we will 
remove
-        * the join clauses again below, but if a join clause contains a special
-        * operator, we need to make sure it gets into the scan_clauses.
-        */
-       if (best_path->isjoininner)
-       {
-               scan_clauses = list_concat_unique(scan_clauses, bitmapqualorig);
-       }
-
-       /*
-        * The qpqual list must contain all restrictions not automatically 
handled
-        * by the index.  All the predicates in the indexquals will be checked
-        * (either by the index itself, or by nodeBitmapHeapscan.c), but if 
there
-        * are any "special" or lossy operators involved then they must be added
-        * to qpqual.  The upshot is that qpqual must contain scan_clauses minus
-        * whatever appears in indexquals.
-        *
-        * In normal cases simple equal() checks will be enough to spot 
duplicate
-        * clauses, so we try that first.  In some situations (particularly with
-        * OR'd index conditions) we may have scan_clauses that are not equal 
to,
-        * but are logically implied by, the index quals; so we also try a
-        * predicate_implied_by() check to see if we can discard quals that way.
-        * (predicate_implied_by assumes its first input contains only immutable
-        * functions, so we have to check that.)
-        *
-        * Unlike create_indexscan_plan(), we need take no special thought here
-        * for partial index predicates; this is because the predicate 
conditions
-        * are already listed in bitmapqualorig and indexquals.  Bitmap scans 
have
-        * to do it that way because predicate conditions need to be rechecked 
if
-        * the scan becomes lossy.
-        */
-       qpqual = NIL;
-       foreach(l, scan_clauses)
-       {
-               Node       *clause = (Node *) lfirst(l);
-
-               if (list_member(indexquals, clause))
-                       continue;
-               if (!contain_mutable_functions(clause))
-               {
-                       List       *clausel = list_make1(clause);
-
-                       if (predicate_implied_by(clausel, indexquals))
-                               continue;
-               }
-               qpqual = lappend(qpqual, clause);
-       }
-
-       /* Sort clauses into best execution order */
-       qpqual = order_qual_clauses(ctx->root, qpqual);
-
-       /*
-        * When dealing with special or lossy operators, we will at this point
-        * have duplicate clauses in qpqual and bitmapqualorig.  We may as well
-        * drop 'em from bitmapqualorig, since there's no point in making the
-        * tests twice.
-        */
-       bitmapqualorig = list_difference_ptr(bitmapqualorig, qpqual);
-
-       /*
-        * Copy the finished bitmapqualorig to make sure we have an independent
-        * copy --- needed in case there are subplans in the index quals
-        */
-       bitmapqualorig = copyObject(bitmapqualorig);
-
-       /* Finally ready to build the plan node */
-       scan_plan = make_bitmap_appendonlyscan(tlist,
-                                                                               
   qpqual,
-                                                                               
   bitmapqualplan,
-                                                                               
   bitmapqualorig,
-                                                                               
   baserelid,
-                                                                               
   best_path->isAORow);
-
-       copy_path_costsize(ctx->root, &scan_plan->scan.plan, &best_path->path);
-
-       return scan_plan;
-}
-
-/*
  * Given a bitmapqual tree, generate the Plan tree that implements it
  *
  * As byproducts, we also return in *qual and *indexqual the qual lists
@@ -3750,30 +3620,6 @@ make_bitmap_heapscan(List *qptlist,
        return node;
 }
 
-static BitmapAppendOnlyScan *
-make_bitmap_appendonlyscan(List *qptlist,
-                                                  List *qpqual,
-                                                  Plan *lefttree,
-                                                  List *bitmapqualorig,
-                                                  Index scanrelid,
-                                                  bool isAORow)
-{
-       BitmapAppendOnlyScan *node = makeNode(BitmapAppendOnlyScan);
-       Plan       *plan = &node->scan.plan;
-
-       /* cost should be inserted by caller */
-       plan->targetlist = qptlist;
-       plan->qual = qpqual;
-       plan->lefttree = lefttree;
-       plan->righttree = NULL;
-       node->scan.scanrelid = scanrelid;
-
-       node->bitmapqualorig = bitmapqualorig;
-       node->isAORow = isAORow;
-
-       return node;
-}
-
 static TidScan *
 make_tidscan(List *qptlist,
                         List *qpqual,

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/optimizer/plan/planpartition.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/plan/planpartition.c 
b/src/backend/optimizer/plan/planpartition.c
index 9940de6..bf92b28 100644
--- a/src/backend/optimizer/plan/planpartition.c
+++ b/src/backend/optimizer/plan/planpartition.c
@@ -781,7 +781,6 @@ AdjustVarnoWalker(Node *node, AdjustVarnoContext *ctx)
                case T_IndexScan:
                case T_BitmapIndexScan:
                case T_BitmapHeapScan:
-               case T_BitmapAppendOnlyScan:
                case T_BitmapTableScan:
                case T_TidScan:
                case T_FunctionScan:

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/optimizer/plan/setrefs.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/plan/setrefs.c 
b/src/backend/optimizer/plan/setrefs.c
index 461e39e..afce5a5 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -568,30 +568,6 @@ set_plan_refs(PlannerGlobal *glob, Plan *plan, const int 
rtoffset)
                        fix_scan_list(glob, splan->bitmapqualorig, rtoffset);
                }
                        break;
-               case T_BitmapAppendOnlyScan:
-               {
-                       BitmapAppendOnlyScan *splan = (BitmapAppendOnlyScan *) 
plan;
-                       
-                       if (cdb_expr_requires_full_eval((Node 
*)plan->targetlist))
-                               return  cdb_insert_result_node(glob, plan, 
rtoffset);
-                       
-                       splan->scan.scanrelid += rtoffset;
-
-#ifdef USE_ASSERT_CHECKING
-                       RangeTblEntry *rte = rt_fetch(splan->scan.scanrelid, 
glob->finalrtable);
-                       char relstorage = get_rel_relstorage(rte->relid);
-                       Assert(relstorage == RELSTORAGE_AOROWS ||
-                                  relstorage == RELSTORAGE_PARQUET);
-#endif
-
-                       splan->scan.plan.targetlist =
-                       fix_scan_list(glob, splan->scan.plan.targetlist, 
rtoffset);
-                       splan->scan.plan.qual =
-                       fix_scan_list(glob, splan->scan.plan.qual, rtoffset);
-                       splan->bitmapqualorig =
-                       fix_scan_list(glob, splan->bitmapqualorig, rtoffset);
-               }
-                       break;
                case T_BitmapTableScan:
                {
                        BitmapTableScan *splan = (BitmapTableScan *) plan;
@@ -1473,8 +1449,7 @@ set_inner_join_references(PlannerGlobal *glob, Plan 
*inner_plan,
                        Assert(inner_plan->qual == NIL);
                }
        }
-       else if (IsA(inner_plan, BitmapHeapScan) ||
-                        IsA(inner_plan, BitmapAppendOnlyScan))
+       else if (IsA(inner_plan, BitmapHeapScan))
        {
                /*
                 * The inner side is a bitmap scan plan.  Fix the top node, and
@@ -1491,14 +1466,6 @@ set_inner_join_references(PlannerGlobal *glob, Plan 
*inner_plan,
                        innerrel = innerscan->scan.scanrelid;
                        bitmapqualorig_p = &(innerscan->bitmapqualorig);
                }
-               else
-               {
-                       Assert(IsA(inner_plan, BitmapAppendOnlyScan));
-                       
-                       BitmapAppendOnlyScan *innerscan = (BitmapAppendOnlyScan 
*) inner_plan;
-                       innerrel = innerscan->scan.scanrelid;
-                       bitmapqualorig_p = &(innerscan->bitmapqualorig);
-               }
                
                /* only refs to outer vars get changed in the inner qual */
                if (NumRelids((Node *) (*bitmapqualorig_p)) > 1)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ae38cfbd/src/backend/optimizer/plan/subselect.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/plan/subselect.c 
b/src/backend/optimizer/plan/subselect.c
index 9e3da25..0289c59 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -1193,11 +1193,6 @@ finalize_plan(PlannerInfo *root, Plan *plan, List 
*rtable,
                                                          &context);
                        break;
 
-               case T_BitmapAppendOnlyScan:
-                       finalize_primnode((Node *) ((BitmapAppendOnlyScan *) 
plan)->bitmapqualorig,
-                                                         &context);
-                       break;
-
                case T_BitmapTableScan:
                        finalize_primnode((Node *) ((BitmapTableScan *) 
plan)->bitmapqualorig,
                                                          &context);

Reply via email to