Browse Source

Merge pull request #3726 from manticoresoftware/columnar_duplicate_ids

fix: fixed duplicate ids not returning an error when id is columnar
Ilya Kuznetsov 5 months ago
parent
commit
f540fb4dcc
4 changed files with 14 additions and 9 deletions
  1. 6 7
      src/sphinxrt.cpp
  2. 1 1
      src/sphinxrt.h
  3. 1 1
      test/test_439/model.bin
  4. 6 0
      test/test_439/test.xml

+ 6 - 7
src/sphinxrt.cpp

@@ -377,13 +377,11 @@ int RtSegment_t::GetStride () const NO_THREAD_SAFETY_ANALYSIS
 	return int ( m_dRows.GetLength() / m_uRows );
 }
 
-const CSphRowitem * RtSegment_t::FindAliveRow ( DocID_t tDocid ) const
+
+bool RtSegment_t::IsAlive ( DocID_t tDocid ) const
 {
 	RowID_t tRowID = GetRowidByDocid(tDocid);
-	if ( tRowID==INVALID_ROWID || m_tDeadRowMap.IsSet(tRowID) )
-		return nullptr;
-
-	return GetDocinfoByRowID(tRowID);
+	return tRowID!=INVALID_ROWID && !m_tDeadRowMap.IsSet(tRowID);
 }
 
 
@@ -392,6 +390,7 @@ const CSphRowitem * RtSegment_t::GetDocinfoByRowID ( RowID_t tRowID ) const NO_T
 	return m_dRows.GetLength() ? &m_dRows[tRowID*GetStride()] : nullptr;
 }
 
+
 RowID_t RtSegment_t::GetAliveRowidByDocid ( DocID_t tDocID ) const
 {
 	RowID_t* pRowID = m_tDocIDtoRowID.Find ( tDocID );
@@ -2098,14 +2097,14 @@ bool RtIndex_c::AddDocument ( InsertDocData_c & tDoc, bool bReplace, const CSphS
 			do
 				tDocID = UidShort ();
 			while ( tGuard.m_dRamSegs.any_of (
-					[tDocID] ( const ConstRtSegmentRefPtf_t & p ) { return p->FindAliveRow ( tDocID ); } ) );
+					[tDocID] ( const ConstRtSegmentRefPtf_t & p ) { return p->IsAlive ( tDocID ); } ) );
 
 			tDoc.SetID ( tDocID );
 		} else
 		{
 			// docID was provided, but that is new insert and we need to check for duplicates
 			assert ( !bReplace && tDocID!=0 );
-			if ( tGuard.m_dRamSegs.any_of ( [tDocID] ( const ConstRtSegmentRefPtf_t & p ) { return p->FindAliveRow ( tDocID ); })
+			if ( tGuard.m_dRamSegs.any_of ( [tDocID] ( const ConstRtSegmentRefPtf_t & p ) { return p->IsAlive ( tDocID ); })
 				|| tGuard.m_dDiskChunks.any_of ( [tDocID] ( const ConstDiskChunkRefPtr_t & p ) { return p->Cidx().IsAlive(tDocID); }))
 			{
 				sError.SetSprintf ( "duplicate id '" UINT64_FMT "'", tDocID );

+ 1 - 1
src/sphinxrt.h

@@ -294,7 +294,7 @@ public:
 	DWORD					GetMergeFactor() const;
 	int						GetStride() const;
 
-	const CSphRowitem * 	FindAliveRow ( DocID_t tDocid ) const;
+	bool					IsAlive ( DocID_t tDocid ) const;
 	const CSphRowitem *		GetDocinfoByRowID ( RowID_t tRowID ) const;
 	RowID_t					GetAliveRowidByDocid ( DocID_t tDocid ) const;
 	RowID_t					GetRowidByDocid ( DocID_t tDocID ) const;

File diff suppressed because it is too large
+ 1 - 1
test/test_439/model.bin


+ 6 - 0
test/test_439/test.xml

@@ -125,6 +125,12 @@ searchd
 	select * from test;
 	drop table test;
 
+	<!-- regression for duplicate ids -->
+	create table t (columnar_str string engine='columnar' );
+	insert into t values(1,'a');
+	insert into t values(1,'b');
+	select * from t;
+	drop table t;
 </sphinxql>
 </queries>
 

Some files were not shown because too many files changed in this diff