Commit 7c32b51c authored by Ivan Donchevskiy's avatar Ivan Donchevskiy

don't delete rows when changing size of CycleStorage to less (bug 4172)

parent 0cd82222
...@@ -257,6 +257,7 @@ bool testJournal1(void) ...@@ -257,6 +257,7 @@ bool testJournal1(void)
return false; return false;
} }
k = 0; k = 0;
printf("size changed to 33000 rows (increased)\n");
j.setSize(33000); j.setSize(33000);
TableBlockStorage t("big_file.test", 4, 40, 100, 5,28,0); TableBlockStorage t("big_file.test", 4, 40, 100, 5,28,0);
printf("test of 2 classes working in 1 file together\n"); printf("test of 2 classes working in 1 file together\n");
...@@ -319,8 +320,9 @@ bool testJournal1(void) ...@@ -319,8 +320,9 @@ bool testJournal1(void)
if(!reOpen()) return false; if(!reOpen()) return false;
printf("size changed back to 32000 rows\n");
j.setSize(32000); j.setSize(32000);
for(i=0;i<32000;i++) for(i=0;i<20;i++)
{ {
if(j.readRow(i,str)) if(j.readRow(i,str))
{ {
...@@ -328,11 +330,13 @@ bool testJournal1(void) ...@@ -328,11 +330,13 @@ bool testJournal1(void)
k++; k++;
} }
} }
if( k>0 ) if(k != 10)
{ {
delete str; delete str;
return false; return false;
} }
k = 0;
delete str; delete str;
return true; return true;
} }
......
...@@ -408,8 +408,15 @@ bool CycleStorage::setSize(int count) ...@@ -408,8 +408,15 @@ bool CycleStorage::setSize(int count)
if(count<size) if(count<size)
{ {
if( head>count-1 )
{
head = 0;
tail = count - 1;
}
if( tail>count-1 )
tail = count - 1;
size=count; size=count;
return delAllRows(); return true;
} }
int num = count - size; int num = count - size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment