FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour hb_cdxPageSeekKey how to intercept this error
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
hb_cdxPageSeekKey how to intercept this error
Posted: Wed Oct 18, 2023 04:04 PM

Hi to all!

I'd like to intercept this error (see subject) in fact it is different

from other kinds of error that I find in error.log.

I have a question: How can I create a little prg that during execution go into

this error in order to study the way to intercept it and for instance perform

a reindex or simply try write a personlized error.log?

it's painful when it happens

marco

Marco Boschi
info@marcoboschi.it
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Wed Oct 18, 2023 04:11 PM

Would it be possible for you to attach the error obtained in this topic?

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Wed Oct 18, 2023 04:20 PM

no the error is a dialog

When I close the dialog

the program stops to run

ad no trace remains

Marco Boschi
info@marcoboschi.it
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Wed Oct 18, 2023 04:36 PM

Dear Marco,

try to reindex

You can always use a modified error handler:

SetErrorhandler( { | oError | ... } )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Wed Oct 18, 2023 05:02 PM

Show how you INDEX and OPENING the.CDX FILES, please.

Muestre cómo está INDEXANDO y ABRIENDO los ARCHIVOS.CDX, por favor.

Gracias, thanks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Thu Oct 19, 2023 06:59 AM

Dear all,

I open as usual dbf and cdx

SELECT 0

USE customer

SET INDEX TO customer

it rarely happens but when it happens a visual dialog opens even if the program is a console type

and there is no way for me to understand procname() procline and table

For this reason, how can I simulate with an ad hoc program a corruption of an index that sends the program into that error?

When one of my programs goes into error I usually read customized error files and I can often manage the error automatically.

But this error is blocking and when I open the dialog I don't know anything about what happened

Have a nice day

Marco

Marco Boschi
info@marcoboschi.it
Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Thu Oct 19, 2023 07:34 AM
Hi,

1st. Please show your hb_out.log last trace error


2st. My index corrupted test, used at init critical processes
To use: lCompruebaIndice("Customer")
Code (fw): Select all Collapse
//-------------------------------------------------------------------------//
// Poner este control antes de empezar los procesos.
FUNCTION lCompruebaIndiceTabla(cAlias)
Local a:= SEntorno({cAlias})
Local nI
Local lOk:= .t.
Local cOrdKey, cIndexKey, lClave, bIndexKey
Local nJ, nFCount
Local oRet        
*
IF Empty(cAlias)
   MERROR_("Necesario el alias !!", cAlias)
   RETURN .F.
ENDIF
*
*

   SELECT (cAlias)
   nFCount:= FCount()
   bIndexKey:= bCOMPILA( IndexKey(0) )
   *
   // Comprueba 2 registros: uno nuevo y uno existente.
   Add_Rec(0)
   FOR nI:= 1 TO 2

      *
      *
      *
      *
      *
      *
      // PRIMERO. Comprueba que las operaciones de a¤adir y replace funcionen
      Rec_Lock(0)
         FOR nJ:= 1 TO Min(6, nFCount) 
            FieldPut(nJ, FieldGet(nJ))
         NEXT
         COMMIT
         IF nI == 1
            DELETE
         ENDIF
      UNLOCK
      *
      *
      *
      // SEGUNDO. Comprueba que la clave se corresponda
      cOrdKey:= OrdKeyVal()
      cIndexKey:= ""
      lClave:= cOrdKey != NIL
      IF lClave
         cIndexKey:= Eval(bIndexKey)
         *
         // El left para por las claves
         // super grandes y el maximo es 250.
         IF ValType(cOrdKey) == "C"
            IF Len(cIndexKey) >= 250
               lClave:= Left(cIndexKey, Len(cOrdKey)) == cOrdKey
            ELSE
               lClave:= cIndexKey == cOrdKey
            ENDIF
         ELSE
            lClave:= cIndexKey == cOrdKey
         ENDIF
      ENDIF
      IF !lClave
         lOk:= .f.
         EXIT
      ENDIF
      *
      *
      *
      *
      *
      *
      // Compruebo un registro con datos de los ultimos
      SKIP -5
      IF Bof()
         EXIT
      ENDIF
   NEXT
   *
   // Comprueba con SEEK todos los indices del alias actual
   oRet:= oCompruebaIndicesYClaves()
   IF !oRet:lOk
      lOk:= .f.
   ENDIF
   *

*
*
REntorno(a)
RETURN lOk
*
*
//-------------------------------------------------------------------------//
// Esto puede dar positivo (error) en un entorno compartido donde
// otros usuarios estan añadiendo registros en el momento de comprobar,
// especialmente si otro usuario esta añadiendo registros masivamente
STATIC FUNCTION oCompruebaIndicesYClaves()
Local cAlias:= Alias()
Local a:= SEntorno({cAlias})
Local nItem, nJ
Local xClave
Local lOk:= .t.
Local nSitio
Local oRet
*
SELECT (cAlias)
*
FOR nItem:= 1 TO 40        // H-V
   SET ORDER TO (nItem)
   IF IndexOrd() != nItem
      EXIT                 // No hay mas indices
   ENDIF
   *
   GO BOTTOM
   SKIP -20     // Comprueba los ultimos 20 registros
   DO WHILE !Eof()
      nSitio:= Recno()
      xClave:= & ( IndexKey(0) )
      SEEK xClave  // Debe encontrar la clave actual o una anterior igual
      IF Eof()
         lOk:= .f.
         EXIT
      ENDIF
      GO nSitio
      SKIP
   ENDDO
   *
   IF !lOk
      FLOGMSG_("Error !! Indice incorrecto !!", Alias(), dbInfo(10), IndexKey(0), IndexOrd(), OrdBagName(nItem), OrdName(), xClave)
      EXIT
   ENDIF
NEXT
*
oRet:= ClassVarRapida({"lOk", "cAlias", "cFullFile", "cIndexKey", "xClave"})
oRet:lOk:= lOk
oRet:cAlias:= Alias()
oRet:cFullFile:= dbInfo(10)
IF !lOk
   oRet:cIndexKey:= IndexKey(0)
   oRet:xClave:= xClave
ENDIF
*
REntorno(a)
RETURN oRet
*
*
Regards
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Thu Oct 19, 2023 09:19 AM

I don't have hb_out.log Im' sorry

will there be a way to simulate and fail with that type of error? and then because a dialog appears even if the program is console program

Marco Boschi
info@marcoboschi.it
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Thu Oct 19, 2023 10:39 AM
Dear Marco,

In Harbour source code we have this:
Code (fw): Select all Collapse
   if( ! fLeaf )
   {
      hb_cdxPageGetChild( pPage );
#ifdef HB_CDX_DBGCODE
      if( memcmp( hb_cdxPageGetKeyVal( pPage, pPage->iCurKey ),
                  hb_cdxPageGetKeyVal( pPage->Child, pPage->Child->iKeys - 1 ),
                  pPage->TagParent->uiLen ) != 0 ||
          hb_cdxPageGetKeyRec( pPage, pPage->iCurKey ) !=
          hb_cdxPageGetKeyRec( pPage->Child, pPage->Child->iKeys - 1 ) )
      {
         fprintf( stderr, "\r\nkeyLen=%u", pPage->TagParent->uiLen );
         fprintf( stderr, "\r\nparent=%lx, iKey=%d, rec=%lu", pPage->Page, pPage->iCurKey, hb_cdxPageGetKeyRec( pPage, pPage->iCurKey ) );
         fprintf( stderr, "\r\n child=%lx, iKey=%d, rec=%lu", pPage->Child->Page, pPage->Child->iKeys - 1, hb_cdxPageGetKeyRec( pPage->Child, pPage->Child->iKeys - 1 ) );
         fprintf( stderr, "\r\nparent val=[%s]", hb_cdxPageGetKeyVal( pPage, pPage->iCurKey ) );
         fprintf( stderr, "\r\n child val=[%s]", hb_cdxPageGetKeyVal( pPage->Child, pPage->Child->iKeys - 1 ) );
         fflush( stderr );
         hb_cdxErrInternal( "hb_cdxPageSeekKey: wrong parent key." );
      }
#endif
      k = hb_cdxPageSeekKey( pPage->Child, pKey, ulKeyRec );
   }
and hb_cdxErrInternal() has this code:
Code (fw): Select all Collapse
static void hb_cdxErrInternal( const char * szMsg )
{
   hb_errInternal( 9201, szMsg ? szMsg : "hb_cdxErrInternal: data integrity error.", NULL, NULL );
}
You can modify it to force the error. What exactly is what you want to avoid ? Please provide a screenshot
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Thu Oct 19, 2023 01:03 PM

Antonio,

next time it happens I provide screenshot.

1) I create a screenshot

1) I save dbf+fpt+cdx

2) reindex

4) restart app

5) post in this forum the screenshot

Many thanks to all

Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Tue Mar 12, 2024 12:04 PM
Antonio,
It happens another time

http://www.marcoboschi.it/public/cattura.jpg

This dialog appears if I use emagdbu or if I use a console program
Have a nice day
Marco Boschi
info@marcoboschi.it
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Tue Mar 12, 2024 01:13 PM
MarcoBoschi wrote:Antonio,
It happens another time

http://www.marcoboschi.it/public/cattura.jpg

This dialog appears if I use emagdbu or if I use a console program
Have a nice day
Good morning Marcos, did you download EMAGDBU.exe from this link? AVG anti virus is reporting problems with the executable.

Buenos días Marcos, ¿descargaste EMAGDBU.exe desde este enlace? El antivirus AVG informa problemas con el ejecutable.

https://www.emagsoftware.it/Download.asp

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Tue Mar 12, 2024 01:35 PM

I don't remember I'm sorry

Marco Boschi
info@marcoboschi.it
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Tue Mar 12, 2024 01:52 PM
MarcoBoschi wrote:I don't remember I'm sorry
Marcos, I downloaded this link from this link, and this version of EMAGDBU.exe is working fine. Please test it as DBU2.exe.

Marcos, descargué desde este Link y desde este link esta versión de EMAGDBU.exe está funcionando bien. Pruébelo como DBU2.exe.

https://linguagemclipper.com.br/content/dbu-para-windows#google_vignette

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: hb_cdxPageSeekKey how to intercept this error
Posted: Tue Mar 12, 2024 02:48 PM
karinha wrote:Good morning Marcos, did you download EMAGDBU.exe from this link? AVG anti virus is reporting problems with the executable.

Buenos días Marcos, ¿descargaste EMAGDBU.exe desde este enlace? El antivirus AVG informa problemas con el ejecutable.

https://www.emagsoftware.it/Download.asp
It is a false positive. Anyway, I just update the release to 2.75 (with a little fix to the messagebar tooltips). Please check, although I think that it will receive the same false alert. :-(