Index: api/omdatabase.cc
===================================================================
RCS file: /usr/data/cvs/xapian/xapian-core/api/omdatabase.cc,v
retrieving revision 1.55
diff -p -u -u -r1.55 omdatabase.cc
--- api/omdatabase.cc	8 Oct 2002 19:27:05 -0000	1.55
+++ api/omdatabase.cc	14 Nov 2002 02:46:04 -0000
@@ -115,8 +115,6 @@ OmPostListIterator
 OmDatabase::postlist_begin(const om_termname &tname) const
 {
     DEBUGAPICALL(OmPostListIterator, "OmDatabase::postlist_begin", tname);
-    if (tname.empty())
-       	throw OmInvalidArgumentError("Zero length terms are invalid");
     RETURN(OmPostListIterator(new OmPostListIterator::Internal(internal->open_post_list(tname, *this))));
 }
 
@@ -124,8 +122,6 @@ OmPostListIterator
 OmDatabase::postlist_end(const om_termname &tname) const
 {
     DEBUGAPICALL(OmPostListIterator, "OmDatabase::postlist_end", tname);
-    if (tname.empty())
-       	throw OmInvalidArgumentError("Zero length terms are invalid");
     RETURN(OmPostListIterator(NULL));
 }
 
Index: backends/inmemory/inmemory_database.cc
===================================================================
RCS file: /usr/data/cvs/xapian/xapian-core/backends/inmemory/inmemory_database.cc,v
retrieving revision 1.105
diff -p -u -u -r1.105 inmemory_database.cc
--- backends/inmemory/inmemory_database.cc	8 Oct 2002 19:27:05 -0000	1.105
+++ backends/inmemory/inmemory_database.cc	14 Nov 2002 17:46:21 -0000
@@ -70,6 +70,32 @@ InMemoryPostList::get_wdf() const
     return (*pos).wdf;
 }
 
+// InMemoryAllDocsPostList
+
+om_doclength
+InMemoryAllDocsPostList::get_doclength() const
+{
+    return this_db->get_doclength(did);
+}
+
+PositionList *
+InMemoryAllDocsPostList::read_position_list()
+{
+    throw OmUnimplementedError("Can't open position list for all docs iterator"); 
+}
+
+AutoPtr<PositionList>
+InMemoryAllDocsPostList::open_position_list() const
+{
+    throw OmUnimplementedError("Can't open position list for all docs iterator"); 
+}
+
+om_termcount
+InMemoryAllDocsPostList::get_wdf() const
+{
+    return 1;
+}
+
 ///////////////////////////
 // Actual database class //
 ///////////////////////////
@@ -99,12 +121,12 @@ InMemoryDatabase::~InMemoryDatabase()
 LeafPostList *
 InMemoryDatabase::do_open_post_list(const om_termname & tname) const
 {
-    if (!term_exists(tname)) {
-	return new EmptyPostList();
-    };
-
+    if (tname.empty()) {
+	if (termlists.empty()) return new EmptyPostList();
+	return new InMemoryAllDocsPostList(RefCntPtr<const InMemoryDatabase>(RefCntPtrToThis(), this));
+    }
     map<om_termname, InMemoryTerm>::const_iterator i = postlists.find(tname);
-    Assert(i != postlists.end());
+    if (i == postlists.end()) return new EmptyPostList();
 
     return new InMemoryPostList(RefCntPtr<const InMemoryDatabase>(RefCntPtrToThis(), this),
 				i->second);
Index: backends/inmemory/inmemory_database.h
===================================================================
RCS file: /usr/data/cvs/xapian/xapian-core/backends/inmemory/inmemory_database.h,v
retrieving revision 1.116
diff -p -u -u -r1.116 inmemory_database.h
--- backends/inmemory/inmemory_database.h	12 Nov 2002 00:03:23 -0000	1.116
+++ backends/inmemory/inmemory_database.h	16 Nov 2002 01:22:36 -0000
@@ -164,6 +164,33 @@ class InMemoryPostList : public LeafPost
 	string get_description() const;
 };
 
+/** A PostList over all docs in an inmemory database.
+ */
+class InMemoryAllDocsPostList : public LeafPostList {
+    friend class InMemoryDatabase;
+    private:
+	om_docid did;
+
+	RefCntPtr<const InMemoryDatabase> this_db;
+
+	InMemoryAllDocsPostList(RefCntPtr<const InMemoryDatabase> db);
+    public:
+	om_doccount get_termfreq() const;
+
+	om_docid       get_docid() const;     // Gets current docid
+	om_doclength   get_doclength() const; // Length of current document
+        om_termcount   get_wdf() const;	      // Within Document Frequency
+	PositionList *read_position_list();
+	AutoPtr<PositionList> open_position_list() const;
+
+	PostList *next(om_weight w_min); // Moves to next docid
+
+	PostList *skip_to(om_docid did, om_weight w_min); // Moves to next docid >= specified docid
+
+	bool   at_end() const;        // True if we're off the end of the list
+
+	string get_description() const;
+};
 
 // Term List
 class InMemoryTermList : public LeafTermList {
@@ -198,6 +225,7 @@ class InMemoryTermList : public LeafTerm
  */
 class InMemoryDatabase : public Database {
     friend class DatabaseBuilder;
+    friend class InMemoryAllDocsPostList;
     private:
 	map<om_termname, InMemoryTerm> postlists;
 	vector<InMemoryDoc> termlists;
@@ -378,6 +405,64 @@ InMemoryPostList::get_description() cons
     return tname + ":" + om_tostring(termfreq);
 }
 
+//////////////////////////////////////////////
+// Inline function definitions for postlist over all docs //
+//////////////////////////////////////////////
+
+inline
+InMemoryAllDocsPostList::InMemoryAllDocsPostList(RefCntPtr<const InMemoryDatabase> db)
+	: did(0), this_db(db)
+{
+}
+
+inline om_doccount
+InMemoryAllDocsPostList::get_termfreq() const
+{
+    return this_db->totdocs;
+}
+
+inline om_docid
+InMemoryAllDocsPostList::get_docid() const
+{
+    Assert(did > 0 && did <= this_db->termlists.size());
+    Assert(this_db->termlists[did - 1].is_valid);
+    return did;
+}
+
+inline PostList *
+InMemoryAllDocsPostList::next(om_weight /*w_min*/)
+{
+    Assert(!at_end());
+    do {
+	++did;
+    } while (did <= this_db->termlists.size() && !this_db->termlists[did - 1].is_valid);
+    return NULL;
+}
+
+inline PostList *
+InMemoryAllDocsPostList::skip_to(om_docid did_, om_weight /*w_min*/)
+{
+    Assert(!at_end());
+    Assert(did <= did_);
+    did = did_;
+    while (did <= this_db->termlists.size() && !this_db->termlists[did - 1].is_valid) {
+	++did;
+    }
+    return NULL;
+}
+
+inline bool
+InMemoryAllDocsPostList::at_end() const
+{
+    return (did > this_db->termlists.size());
+}
+
+
+inline string
+InMemoryAllDocsPostList::get_description() const
+{
+    return om_tostring(did);
+}
 
 //////////////////////////////////////////////
 // Inline function definitions for termlist //
Index: backends/quartz/quartz_database.cc
===================================================================
RCS file: /usr/data/cvs/xapian/xapian-core/backends/quartz/quartz_database.cc,v
retrieving revision 1.102
diff -p -u -u -r1.102 quartz_database.cc
--- backends/quartz/quartz_database.cc	12 Nov 2002 00:03:23 -0000	1.102
+++ backends/quartz/quartz_database.cc	14 Nov 2002 20:39:33 -0000
@@ -274,8 +274,10 @@ QuartzDatabase::open_post_list_internal(
 				RefCntPtr<const Database> ptrtothis) const
 {
     DEBUGCALL(DB, LeafPostList *, "QuartzDatabase::open_post_list_internal", tname << ", [ptrtothis]");
-    Assert(!tname.empty());
-    return(new QuartzPostList(ptrtothis,
+    if (!tname.empty()) {
+	// FIXME: RETURN(new QuartzAllPostList(ptrtothis, tables->get_record_table()));
+    }
+    RETURN(new QuartzPostList(ptrtothis,
 			      tables->get_postlist_table(),
 			      tables->get_positionlist_table(),
 			      tname));
Index: backends/quartz/quartz_table.cc
===================================================================
RCS file: /usr/data/cvs/xapian/xapian-core/backends/quartz/quartz_table.cc,v
retrieving revision 1.69
diff -p -u -u -r1.69 quartz_table.cc
--- backends/quartz/quartz_table.cc	6 Nov 2002 17:53:01 -0000	1.69
+++ backends/quartz/quartz_table.cc	15 Nov 2002 02:35:18 -0000
@@ -612,15 +609,12 @@ QuartzBufferedTable::get_or_make_tag(con
 	    AutoPtr<string> tag(new string);
 	    tagptr = tag.get();
 	    changed_entries.set_tag(key, tag);
-	    entry_count += 1;
+	    if (!key.empty()) ++entry_count;
 
 	    AssertEq(changed_entries.get_tag(key), tagptr);
 	    Assert(tag.get() == 0);
-
-	    RETURN(tagptr);
-	} else {
-	    RETURN(tagptr);
 	}
+	RETURN(tagptr);
     }
 
     AutoPtr<string> tag(new string);
@@ -629,9 +623,9 @@ QuartzBufferedTable::get_or_make_tag(con
     bool found = disktable->get_exact_entry(key, *tag);
 
     changed_entries.set_tag(key, tag);
-    if (!found) {
-	DEBUGLINE(DB, "QuartzBufferedTable::get_or_make_tag - increasing entry_count - '" << key << "' added");
-	entry_count += 1;
+    if (!found && !key.empty()) {
+	DEBUGLINE(DB, "incrementing entry_count - '" << key << "' added");
+	++entry_count;
     }
     Assert(changed_entries.have_entry(key));
     AssertEq(changed_entries.get_tag(key), tagptr);
