Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 20 of 22 total
Thread Corrupt a database table?
Tue, Apr 21 2015 3:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Aaron

>Exception: ElevateDB Error #601 The table <table name> is corrupt (The index __PrimaryKey contains duplicate keys).

From a post back in 2007

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<< Occasionally I'm getting the following error. There is no contraint or
primary key on this table, what is causing this and how can I avoid this
problem. >>

Repair the table - most likely it is corrupted.  There is an internal
primary key on the RowID when you don't explicitly define one, and you
should never run into duplicate RowID values unless the table/indexes have
been corrupted.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Best way to handle this type of corruption is to verify the table at start up and if errors are found initiate a repair. I would also recommend adding a primary key (say an autoinc or a guid). If it happens frequently see if you can create a test case and send it to Tim.

If its a rare event then you could handle it in the same way I do. My apps have a screen for verifying / repairing / optimising the tables. It needs to be run without anyone else on the system. It reads in the tables associated with the app and allows the users to select which are to be operated on.

Roy Lambert
Tue, Apr 21 2015 4:18 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

> Best way to handle this type of corruption is to verify the table at
> start up and if errors are found initiate a repair.

This is what my services do automatically. One of the tables is really
big, so takes ages (I think I automatically repair anyway), so it is
only done if the GoodShutdown.txt is not present. If someone killed the
service, then that isn't created so it gets a full check.

--

Matthew Jones
Tue, Apr 21 2015 6:08 AMPermanent Link

Aaron Christiansen

To clarify, because I haven't made myself clear. I am not looking for how to fix this problem, I worked that out months ago.

I want a test database or table that has this error so I can prove to myself it works and because implementing an untested fix is not confidence inspiring..

Thanks.
Tue, Apr 21 2015 6:42 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Aaron


've never had the error you have but here's how I treat table repairs


   DeleteFile(TableList_Table.AsString + dm.TfrSession.LocalTableIndexExtension);
   Actioneer.Close;
   Actioneer.SQL.Text := 'REPAIR TABLE ' + TableList_Table.AsString;
   Progress.Initialise(0, 100, TableList_Table.AsString);
   Actioneer.ExecSQL;

It works. I will stake Matthew's life on it. This is an even more extreme case than yours - no indices at all Smiley

Roy Lambert
Tue, Apr 21 2015 6:49 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

> I will stake Matthew's life on it.

Phew, I'm glad you did rather than me. 8-)

I just checked, and my ElevateDB version of my database checker is
basically:

{$IFDEF EDB_LATER}

{$ENDIF}

I must grab your code and get that working...

--

Matthew Jones
Tue, Apr 21 2015 7:40 AMPermanent Link

Aaron Christiansen

Wow.
Tue, Apr 21 2015 7:52 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew


Do you want the form - it allows for verify, repair & optimise?

If so the best approach would be to use the .pas as a basis cos I'd have to ship you my homebrew components as well. I don't mind doing it but I seem to recall you've spent a lot of money on DevEx.

Roy Lambert
Tue, Apr 21 2015 8:49 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Aaron

>Wow.

Why wow?

DBISAM had a force index rebuild flag, in the early days (and possibly still now) ElevateDB didn't. What it did do well was recreate missing files up to and including the full table. Zapping the index file at the OS level simply guaranteed all indices being rebuilt.

Roy Lambert
Tue, Apr 21 2015 8:50 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

> Do you want the form - it allows for verify, repair & optimise?
>
> If so the best approach would be to use the .pas as a basis cos I'd
> have to ship you my homebrew components as well. I don't mind doing
> it but I seem to recall you've spent a lot of money on DevEx.

I'm happy with any leg up that you want to give me. If you have
components, I'll work out how to replace or whatever. My code is all
run at service startup anyway, so there is no UI, just logging.

But I do think it would be a good thing to be shared generally, so
thanks for anything you can put up.

--

Matthew Jones
Tue, Apr 21 2015 11:30 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew


Of to the binaries it went

Roy Lambert
« Previous PagePage 2 of 3Next Page »
Jump to Page:  1 2 3
Image