GnuCOBOL  2.0
A free COBOL compiler
isinternal.h File Reference
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include "vbisam.h"
#include "byteswap.h"
Include dependency graph for isinternal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  VBLOCK
 
struct  VBKEY
 
struct  VBTREE
 
struct  DICTNODE
 
struct  DICTINFO
 
struct  VBFILE
 
struct  SLOGHDR
 

Macros

#define _LFS64_LARGEFILE   1
 
#define _LFS64_STDIO   1
 
#define _FILE_OFFSET_BITS   64
 
#define _LARGEFILE64_SOURCE   1
 
#define __USE_LARGEFILE64   1
 
#define __USE_FILE_OFFSET64   1
 
#define QUADSIZE   8
 
#define VB_OFFLEN_7F   0x7fffffffffffffffLL
 
#define VB_OFFLEN_3F   0x3fffffffffffffffLL
 
#define VB_OFFLEN_40   0x4000000000000000LL
 
#define MAXSUBS   32 /* Maximum number of indexes per table */
 
#define VB_MAX_FILES   128 /* Maximum number of open VBISAM files */
 
#define VBISAM_LIB
 
#define VB_HIDDEN
 
#define O_BINARY   0
 
#define likely(x)   (x)
 
#define unlikely(x)   (x)
 
#define MISALIGNED
 
#define MAX_NODE_LENGTH   4096
 
#define VB_NODE_MAX   4096
 
#define MAX_ISREC_LENGTH   32511
 
#define MAX_RESERVED_LENGTH   32768 /* Greater then MAX_ISREC_LENGTH */
 
#define MAX_BUFFER_LENGTH   65536
 
#define VBUNLOCK   0 /* Unlock */
 
#define VBRDLOCK   1 /* A simple read lock, non-blocking */
 
#define VBRDLCKW   2 /* A simple read lock, blocking */
 
#define VBWRLOCK   3 /* An exclusive write lock, non-blocking */
 
#define VBWRLCKW   4 /* An exclusive write lock, blocking */
 
#define RECOV_C   0x00 /* Boring old buggy C-ISAM mode */
 
#define RECOV_VB   0x01 /* New, improved error detection */
 
#define RECOV_LK   0x02 /* Use locks in isrecover (See documentation) */
 
#define VBNOTRANS   0 /* NOT in a transaction at all */
 
#define VBBEGIN   1 /* An isbegin has been issued but no more */
 
#define VBNEEDFLUSH   2 /* Something BEYOND just isbegin has been issued */
 
#define VBCOMMIT   3 /* We're in 'iscommit' mode */
 
#define VBROLLBACK   4 /* We're in 'isrollback' mode */
 
#define VBRECOVER   5 /* We're in 'isrecover' mode */
 
#define VBL_BUILD   ("BU")
 
#define VBL_BEGIN   ("BW")
 
#define VBL_CREINDEX   ("CI")
 
#define VBL_CLUSTER   ("CL")
 
#define VBL_COMMIT   ("CW")
 
#define VBL_DELETE   ("DE")
 
#define VBL_DELINDEX   ("DI")
 
#define VBL_FILEERASE   ("ER")
 
#define VBL_FILECLOSE   ("FC")
 
#define VBL_FILEOPEN   ("FO")
 
#define VBL_INSERT   ("IN")
 
#define VBL_RENAME   ("RE")
 
#define VBL_ROLLBACK   ("RW")
 
#define VBL_SETUNIQUE   ("SU")
 
#define VBL_UNIQUEID   ("UN")
 
#define VBL_UPDATE   ("UP")
 

Typedefs

typedef unsigned char * ucharptr
 

Functions

static int inl_ldint (void *pclocation)
 
static void inl_stint (int ivalue, void *pclocation)
 
static int inl_ldlong (void *pclocation)
 
static void inl_stlong (int lvalue, void *pclocation)
 
static off_t inl_ldquad (void *pclocation)
 
static void inl_stquad (off_t tvalue, void *pclocation)
 
int ivbforceexit (const int ihandle)
 
int ivbclose2 (const int ihandle)
 
void ivbclose3 (const int ihandle)
 
int ivbcheckkey (const int ihandle, struct keydesc *pskey, const int imode, int irowlength, const int iisbuild)
 
int ivbtransbuild (const char *pcfilename, const int iminrowlen, const int imaxrowlen, struct keydesc *pskeydesc, const int imode)
 
int ivbtranscreateindex (const int ihandle, struct keydesc *pskeydesc)
 
int ivbtranscluster (void)
 
int ivbtransdelete (const int ihandle, off_t trownumber, int irowlength)
 
int ivbtransdeleteindex (const int ihandle, struct keydesc *pskeydesc)
 
int ivbtranserase (const char *pcfilename)
 
int ivbtransclose (const int ihandle, const char *pcfilename)
 
int ivbtransopen (const int ihandle, const char *pcfilename)
 
int ivbtransinsert (const int ihandle, const off_t trownumber, int irowlength, char *pcrow)
 
int ivbtransrename (char *pcoldname, char *pcnewname)
 
int ivbtranssetunique (const int ihandle, const off_t tuniqueid)
 
int ivbtransuniqueid (const int ihandle, const off_t tuniqueid)
 
int ivbtransupdate (const int ihandle, const off_t trownumber, const int ioldrowlen, const int inewrowlen, const char *pcrow)
 
int ivbwriterow (const int ihandle, char *pcrow, const off_t trownumber)
 
int ivbdataread (const int ihandle, char *pcbuffer, int *pideletedrow, const off_t trownumber)
 
int ivbdatawrite (const int ihandle, char *pcbuffer, int ideletedrow, const off_t trownumber)
 
off_t tvbnodecountgetnext (const int ihandle)
 
int ivbnodefree (const int ihandle, const off_t tnodenumber)
 
int ivbdatafree (const int ihandle, const off_t trownumber)
 
off_t tvbnodeallocate (const int ihandle)
 
off_t tvbdataallocate (const int ihandle)
 
int ivbforcedataallocate (const int ihandle, const off_t trownumber)
 
void vvbmakekey (const struct keydesc *pskeydesc, char *pcrow_buffer, unsigned char *pckeyvalue)
 
int ivbkeysearch (const int ihandle, const int imode, const int ikeynumber, int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
 
int ivbkeylocaterow (const int ihandle, const int ikeynumber, off_t trownumber)
 
int ivbkeyload (const int ihandle, const int ikeynumber, const int imode, const int isetcurr, struct VBKEY **ppskey)
 
void vvbkeyvalueset (const int ihigh, struct keydesc *pskeydesc, unsigned char *pckeyvalue)
 
int ivbkeyinsert (const int ihandle, struct VBTREE *pstree, const int ikeynumber, unsigned char *pckeyvalue, off_t trownode, off_t tdupnumber, struct VBTREE *pschild)
 
int ivbkeydelete (const int ihandle, const int ikeynumber)
 
int ivbkeycompare (const int ihandle, const int ikeynumber, int ilength, unsigned char *pckey1, unsigned char *pckey2)
 
int ivbenter (const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
 
int ivbexit (const int ihandle)
 
int ivbfileopenlock (const int ihandle, const int imode)
 
int ivbdatalock (const int ihandle, const int imode, const off_t trownumber)
 
int ivbopen (const char *pcfilename, const int iflags, const mode_t tmode)
 
int ivbclose (const int ihandle)
 
off_t tvblseek (const int ihandle, off_t toffset, const int iwhence)
 
ssize_t tvbread (const int ihandle, void *pvbuffer, const size_t tcount)
 
ssize_t tvbwrite (const int ihandle, const void *pvbuffer, const size_t tcount)
 
int ivbblockread (const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
 
int ivbblockwrite (const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
 
int ivblock (const int ihandle, const off_t toffset, const off_t tlength, const int imode)
 
struct VBLOCKpsvblockallocate (const int ihandle)
 
void vvblockfree (struct VBLOCK *pslock)
 
struct VBTREEpsvbtreeallocate (const int ihandle)
 
void vvbtreeallfree (const int ihandle, const int ikeynumber, struct VBTREE *pstree)
 
struct VBKEYpsvbkeyallocate (const int ihandle, const int ikeynumber)
 
void vvbkeyallfree (const int ihandle, const int ikeynumber, struct VBTREE *pstree)
 
void vvbkeyfree (const int ihandle, const int ikeynumber, struct VBKEY *pskey)
 
void vvbkeyunmalloc (const int ihandle, const int ikeynumber)
 
void * pvvbmalloc (const size_t size)
 
void vvbfree (void *mptr)
 
void vvbunmalloc (void)
 
int ivbnodeload (const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int iprevlvl)
 
int ivbnodesave (const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int imode, const int iposn)
 

Variables

int ivbintrans
 
int ivblogfilehandle
 
int ivbmaxusedhandle
 
struct DICTINFOpsvbfile [128+1]
 
struct VBFILE svbfile [128 *3]
 

Macro Definition Documentation

#define __USE_FILE_OFFSET64   1

Definition at line 36 of file isinternal.h.

#define __USE_LARGEFILE64   1

Definition at line 35 of file isinternal.h.

#define _FILE_OFFSET_BITS   64

Definition at line 33 of file isinternal.h.

#define _LARGEFILE64_SOURCE   1

Definition at line 34 of file isinternal.h.

#define _LFS64_LARGEFILE   1

Definition at line 31 of file isinternal.h.

#define _LFS64_STDIO   1

Definition at line 32 of file isinternal.h.

#define likely (   x)    (x)

Definition at line 146 of file isinternal.h.

#define MAX_BUFFER_LENGTH   65536

Definition at line 291 of file isinternal.h.

Referenced by ircvchecktrans(), and isrecover().

#define MAX_ISREC_LENGTH   32511

Definition at line 289 of file isinternal.h.

#define MAX_NODE_LENGTH   4096

Definition at line 283 of file isinternal.h.

Referenced by isbuild(), isopen(), and ttailnode().

#define MAX_RESERVED_LENGTH   32768 /* Greater then MAX_ISREC_LENGTH */

Definition at line 290 of file isinternal.h.

Referenced by iprocessdelete(), isbuild(), isopen(), ivbdataread(), and ivbdatawrite().

#define MAXSUBS   32 /* Maximum number of indexes per table */
#define MISALIGNED

Definition at line 157 of file isinternal.h.

Referenced by inl_ldint(), inl_ldlong(), inl_ldquad(), inl_stint(), inl_stlong(), and inl_stquad().

#define O_BINARY   0

Definition at line 133 of file isinternal.h.

#define RECOV_C   0x00 /* Boring old buggy C-ISAM mode */

Definition at line 301 of file isinternal.h.

#define RECOV_LK   0x02 /* Use locks in isrecover (See documentation) */

Definition at line 303 of file isinternal.h.

#define RECOV_VB   0x01 /* New, improved error detection */

Definition at line 302 of file isinternal.h.

Referenced by ircvchecktrans().

#define unlikely (   x)    (x)

Definition at line 147 of file isinternal.h.

#define VB_HIDDEN

Definition at line 129 of file isinternal.h.

#define VB_MAX_FILES   128 /* Maximum number of open VBISAM files */
#define VB_OFFLEN_3F   0x3fffffffffffffffLL

Definition at line 110 of file isinternal.h.

Referenced by ivbdatalock(), ivbenter(), and ivbexit().

#define VB_OFFLEN_40   0x4000000000000000LL

Definition at line 111 of file isinternal.h.

Referenced by ivbdatalock().

#define VB_OFFLEN_7F   0x7fffffffffffffffLL

Definition at line 109 of file isinternal.h.

Referenced by ivbfileopenlock().

#define VBCOMMIT   3 /* We're in 'iscommit' mode */

Definition at line 309 of file isinternal.h.

Referenced by iprocessdelete(), iscommit(), and ivbenter().

#define VBISAM_LIB

Definition at line 122 of file isinternal.h.

#define VBL_BEGIN   ("BW")

Definition at line 469 of file isinternal.h.

Referenced by ircvchecktrans(), isrecover(), ivbrollmeback(), ivbrollmeforward(), and iwritebegin().

#define VBL_BUILD   ("BU")

Definition at line 468 of file isinternal.h.

Referenced by isrecover(), and ivbtransbuild().

#define VBL_CLUSTER   ("CL")

Definition at line 471 of file isinternal.h.

Referenced by isrecover().

#define VBL_COMMIT   ("CW")

Definition at line 472 of file isinternal.h.

Referenced by ircvchecktrans(), iscommit(), and isrecover().

#define VBL_CREINDEX   ("CI")

Definition at line 470 of file isinternal.h.

Referenced by isrecover(), and ivbtranscreateindex().

#define VBL_DELETE   ("DE")

Definition at line 473 of file isinternal.h.

Referenced by isrecover(), ivbrollmeback(), ivbrollmeforward(), and ivbtransdelete().

#define VBL_DELINDEX   ("DI")

Definition at line 474 of file isinternal.h.

Referenced by isrecover(), and ivbtransdeleteindex().

#define VBL_FILECLOSE   ("FC")

Definition at line 476 of file isinternal.h.

Referenced by isrecover(), ivbrollmeback(), ivbrollmeforward(), and ivbtransclose().

#define VBL_FILEERASE   ("ER")

Definition at line 475 of file isinternal.h.

Referenced by isrecover(), and ivbtranserase().

#define VBL_FILEOPEN   ("FO")

Definition at line 477 of file isinternal.h.

Referenced by isrecover(), ivbrollmeback(), ivbrollmeforward(), and ivbtransopen().

#define VBL_INSERT   ("IN")

Definition at line 478 of file isinternal.h.

Referenced by isrecover(), ivbrollmeback(), and ivbtransinsert().

#define VBL_RENAME   ("RE")

Definition at line 479 of file isinternal.h.

Referenced by isrecover(), and ivbtransrename().

#define VBL_ROLLBACK   ("RW")

Definition at line 480 of file isinternal.h.

Referenced by ircvchecktrans(), isrecover(), and isrollback().

#define VBL_SETUNIQUE   ("SU")

Definition at line 481 of file isinternal.h.

Referenced by isrecover(), and ivbtranssetunique().

#define VBL_UNIQUEID   ("UN")

Definition at line 482 of file isinternal.h.

Referenced by isrecover(), and ivbtransuniqueid().

#define VBL_UPDATE   ("UP")

Definition at line 483 of file isinternal.h.

Referenced by isrecover(), ivbrollmeback(), and ivbtransupdate().

#define VBNOTRANS   0 /* NOT in a transaction at all */
#define VBRDLCKW   2 /* A simple read lock, blocking */

Definition at line 296 of file isinternal.h.

Referenced by ivblock().

#define VBRDLOCK   1 /* A simple read lock, non-blocking */

Definition at line 295 of file isinternal.h.

Referenced by ivbenter(), ivbfileopenlock(), and ivblock().

#define VBRECOVER   5 /* We're in 'isrecover' mode */

Definition at line 311 of file isinternal.h.

Referenced by isclose(), and isrecover().

#define VBROLLBACK   4 /* We're in 'isrollback' mode */

Definition at line 310 of file isinternal.h.

Referenced by iprocessdelete(), isrollback(), ivbenter(), and ivbtransclose().

#define VBUNLOCK   0 /* Unlock */
#define VBWRLCKW   4 /* An exclusive write lock, blocking */

Definition at line 298 of file isinternal.h.

Referenced by isread(), istartrownumber(), ivblock(), and iwritetrans().

#define VBWRLOCK   3 /* An exclusive write lock, non-blocking */

Typedef Documentation

typedef unsigned char* ucharptr

Definition at line 150 of file isinternal.h.

Function Documentation

static int inl_ldint ( void *  pclocation)
inlinestatic

Definition at line 170 of file isinternal.h.

References MISALIGNED, and VB_BSWAP_16.

Referenced by iaddkeydescriptor(), idatafreecheck(), idelnodes(), iindexfreecheck(), iquicknodesave(), ircvbegin(), ircvbuild(), ircvchecktrans(), ircvcluster(), ircvcommit(), ircvcreateindex(), ircvdelete(), ircvdeleteindex(), ircvfileclose(), ircvfileerase(), ircvfileopen(), ircvfilerename(), ircvinsert(), ircvrollback(), ircvsetunique(), ircvuniqueid(), ircvupdate(), isopen(), isrecover(), ivbdatafree(), ivbdataread(), ivbdatawrite(), ivbforcedataallocate(), ivbkeycompare(), ivbnodefree(), ivbnodeload(), ivbrollmeback(), ivbrollmeforward(), ivbvarlendelete(), ivbvarlenread(), ivbvarlenwrite(), tdelkeydescriptor(), ttailnode(), tvbdataallocate(), and tvbnodeallocate().

171 {
172 #ifndef WORDS_BIGENDIAN
173  return (int)VB_BSWAP_16(*(unsigned short MISALIGNED *)pclocation);
174 #else
175  short ivalue = 0;
176  unsigned char *pctemp = (unsigned char *) &ivalue;
177  unsigned char *pctemp2 = (unsigned char *) pclocation;
178 
179  *(pctemp + 0) = *(pctemp2 + 0);
180  *(pctemp + 1) = *(pctemp2 + 1);
181  return (int)ivalue;
182 #endif
183 }
#define MISALIGNED
Definition: isinternal.h:157
#define VB_BSWAP_16(val)
Definition: byteswap.h:184

Here is the caller graph for this function:

static int inl_ldlong ( void *  pclocation)
inlinestatic

Definition at line 209 of file isinternal.h.

References MISALIGNED, and VB_BSWAP_32.

Referenced by ivbkeycompare().

210 {
211 #ifndef WORDS_BIGENDIAN
212  return VB_BSWAP_32(*(unsigned int MISALIGNED *)pclocation);
213 #else
214  int lvalue;
215 
216  memcpy((unsigned char *)&lvalue, (unsigned char *)pclocation, 4);
217  return lvalue;
218 #endif
219 }
#define MISALIGNED
Definition: isinternal.h:157
#define VB_BSWAP_32(val)
Definition: byteswap.h:185

Here is the caller graph for this function:

static off_t inl_ldquad ( void *  pclocation)
inlinestatic

Definition at line 238 of file isinternal.h.

References MISALIGNED, VB_BSWAP_32, and VB_BSWAP_64.

Referenced by iaddkeydescriptor(), icheckkeydesc(), idatafreecheck(), idelnodes(), iindexfreecheck(), imakekeysfromdata(), ircvdelete(), ircvinsert(), ircvsetunique(), ircvuniqueid(), ircvupdate(), isopen(), issetunique(), istartrownumber(), isuniqueid(), ivbdatafree(), ivbdataread(), ivbenter(), ivbexit(), ivbforcedataallocate(), ivbkeycompare(), ivbnodefree(), ivbnodeload(), ivbnodesave(), ivbrollmeback(), ivbrollmeforward(), ivbvarlendelete(), ivbvarlenread(), tdelkeydescriptor(), ttailnode(), tvbdataallocate(), tvbdatacountgetnext(), tvbnodeallocate(), tvbnodecountgetnext(), and vrebuildindexfree().

239 {
240 
241 #ifndef WORDS_BIGENDIAN
242 #if ISAMMODE == 1
243  return VB_BSWAP_64(*(unsigned long long MISALIGNED *)pclocation);
244 #else
245  return VB_BSWAP_32(*(unsigned int MISALIGNED *)pclocation);
246 #endif
247 #else
248  off_t tvalue = 0;
249 
250 #if ISAMMODE == 1
251  memcpy((unsigned char *)&tvalue, (unsigned char *)pclocation, 8);
252 #else
253  memcpy((unsigned char *)&tvalue, (unsigned char *)pclocation, 4);
254 #endif
255  return tvalue;
256 #endif
257 }
#define MISALIGNED
Definition: isinternal.h:157
#define VB_BSWAP_64(val)
Definition: byteswap.h:186
#define VB_BSWAP_32(val)
Definition: byteswap.h:185

Here is the caller graph for this function:

static void inl_stint ( int  ivalue,
void *  pclocation 
)
inlinestatic

Definition at line 190 of file isinternal.h.

References MISALIGNED, and VB_BSWAP_16.

Referenced by iaddkeydescriptor(), iindexcheck(), iquicknodesave(), irollbackall(), isaddindex(), isbuild(), isdelindex(), ivbdatafree(), ivbdatawrite(), ivbforcedataallocate(), ivbnodefree(), ivbnodesave(), ivbtransbuild(), ivbtransclose(), ivbtranscreateindex(), ivbtransdelete(), ivbtransdeleteindex(), ivbtransinsert(), ivbtransopen(), ivbtransrename(), ivbtranssetunique(), ivbtransuniqueid(), ivbtransupdate(), ivbvarlendelete(), ivbvarlenwrite(), iwritetrans(), tdelkeydescriptor(), ttailnode(), tvbdataallocate(), tvbnodeallocate(), vtranshdr(), and vvbkeyvalueset().

191 {
192 #ifndef WORDS_BIGENDIAN
193  *(unsigned short MISALIGNED *)pclocation = VB_BSWAP_16((unsigned short)ivalue);
194 #else
195  unsigned char *pctemp = (char *) &ivalue;
196  unsigned char *pctemp2 = (unsigned char *) pclocation;
197 
198  *(pctemp2 + 0) = *(pctemp + 0 + INTSIZE);
199  *(pctemp2 + 1) = *(pctemp + 1 + INTSIZE);
200 #endif
201  return;
202 }
#define MISALIGNED
Definition: isinternal.h:157
#define VB_BSWAP_16(val)
Definition: byteswap.h:184

Here is the caller graph for this function:

static void inl_stlong ( int  lvalue,
void *  pclocation 
)
inlinestatic

Definition at line 226 of file isinternal.h.

References MISALIGNED, and VB_BSWAP_32.

Referenced by vtranshdr(), and vvbkeyvalueset().

227 {
228 #ifndef WORDS_BIGENDIAN
229  *(unsigned int MISALIGNED *)pclocation = VB_BSWAP_32((unsigned int)lvalue);
230 #else
231  memcpy((unsigned char *)pclocation, (unsigned char *)&lvalue, 4);
232 #endif
233  return;
234 }
#define MISALIGNED
Definition: isinternal.h:157
#define VB_BSWAP_32(val)
Definition: byteswap.h:185

Here is the caller graph for this function:

static void inl_stquad ( off_t  tvalue,
void *  pclocation 
)
inlinestatic

Definition at line 260 of file isinternal.h.

References MISALIGNED, VB_BSWAP_32, and VB_BSWAP_64.

Referenced by iaddkeydescriptor(), idatafreecheck(), iindexfreecheck(), ipostamble(), iquicknodesave(), isbuild(), issetunique(), isuniqueid(), ivbdatafree(), ivbdatawrite(), ivbexit(), ivbforcedataallocate(), ivbnodefree(), ivbnodesave(), ivbrollmeforward(), ivbtransdelete(), ivbtransinsert(), ivbtranssetunique(), ivbtransuniqueid(), ivbtransupdate(), ivbvarlendelete(), ivbvarlenwrite(), ttailnode(), tvbdataallocate(), tvbdatacountgetnext(), tvbnodeallocate(), tvbnodecountgetnext(), and vrebuildindexfree().

261 {
262 #ifndef WORDS_BIGENDIAN
263 #if ISAMMODE == 1
264  *(unsigned long long MISALIGNED *)pclocation = VB_BSWAP_64((unsigned long long)tvalue);
265 #else
266  *(unsigned int MISALIGNED *)pclocation = VB_BSWAP_32((unsigned int)tvalue);
267 #endif
268 #else
269 #if ISAMMODE == 1
270  memcpy((unsigned char *)pclocation, (unsigned char *)&tvalue, 8);
271 #else
272  memcpy((unsigned char *)pclocation, (unsigned char *)&tvalue, 4);
273 #endif
274 #endif
275  return;
276 }
#define MISALIGNED
Definition: isinternal.h:157
#define VB_BSWAP_64(val)
Definition: byteswap.h:186
#define VB_BSWAP_32(val)
Definition: byteswap.h:185

Here is the caller graph for this function:

int ivbblockread ( const int  ihandle,
const int  iisindex,
const off_t  tblocknumber,
char *  cbuffer 
)

Definition at line 137 of file vblowlevel.c.

References DICTINFO::idatahandle, DICTINFO::iindexhandle, DICTINFO::inodesize, tvblseek(), and tvbread().

Referenced by iaddkeydescriptor(), icheckkey(), icheckkeydesc(), idatafreecheck(), idelnodes(), iindexfreecheck(), iquicknodesave(), isopen(), ivbdatafree(), ivbdataread(), ivbdatawrite(), ivbenter(), ivbfileopenlock(), ivbforcedataallocate(), ivbnodefree(), ivbnodeload(), ivbvarlendelete(), ivbvarlenread(), tdelkeydescriptor(), ttailnode(), tvbdataallocate(), and tvbnodeallocate().

138 {
139  struct DICTINFO *psvbptr;
140  off_t toffset;
141  ssize_t tresult;
142  int thandle;
143 
144  psvbptr = psvbfile[ihandle];
145  toffset = (off_t) ((tblocknumber - 1) * psvbptr->inodesize);
146  if (iisindex) {
147  thandle = psvbptr->iindexhandle;
148  } else {
149  thandle = psvbptr->idatahandle;
150  }
151  if (tvblseek (thandle, toffset, SEEK_SET) != toffset) {
152  return EIO;
153  }
154 
155  tresult = tvbread (thandle, cbuffer, (size_t) psvbptr->inodesize);
156  if (!iisindex && tresult == 0) {
157  tresult = (ssize_t) psvbptr->inodesize;
158  memset (cbuffer, 0, (size_t)psvbptr->inodesize);
159  }
160  if (tresult != (ssize_t)psvbptr->inodesize) {
161  return EIO;
162  }
163  return 0;
164 }
int iindexhandle
Definition: isinternal.h:406
off_t tvblseek(const int ihandle, off_t toffset, const int iwhence)
Definition: vblowlevel.c:107
ssize_t tvbread(const int ihandle, void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:117
int idatahandle
Definition: isinternal.h:405
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int inodesize
Definition: isinternal.h:402

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbblockwrite ( const int  ihandle,
const int  iisindex,
const off_t  tblocknumber,
const char *  cbuffer 
)

Definition at line 167 of file vblowlevel.c.

References DICTINFO::idatahandle, DICTINFO::iindexhandle, DICTINFO::inodesize, tvblseek(), and tvbwrite().

Referenced by iaddkeydescriptor(), iindexcheck(), iquicknodesave(), isbuild(), ivbdatafree(), ivbdatawrite(), ivbexit(), ivbforcedataallocate(), ivbforceexit(), ivbnodefree(), ivbnodesave(), ivbvarlendelete(), ivbvarlenwrite(), tdelkeydescriptor(), ttailnode(), tvbdataallocate(), and tvbnodeallocate().

168 {
169  struct DICTINFO *psvbptr;
170  off_t toffset;
171  ssize_t tresult;
172  int thandle;
173 
174  psvbptr = psvbfile[ihandle];
175  toffset = (off_t) ((tblocknumber - 1) * psvbptr->inodesize);
176  if (iisindex) {
177  thandle = psvbptr->iindexhandle;
178  } else {
179  thandle = psvbptr->idatahandle;
180  }
181 /* RXW
182  tresult = tvblseek (thandle, toffset, SEEK_SET);
183  if (tresult == (off_t) -1) {
184 */
185  if (tvblseek (thandle, toffset, SEEK_SET) != toffset) {
186  return EIO;
187  }
188 
189  tresult = tvbwrite (thandle, cbuffer, (size_t) psvbptr->inodesize);
190  if (tresult != (ssize_t)psvbptr->inodesize) {
191  return EIO;
192  }
193  return 0;
194 }
ssize_t tvbwrite(const int ihandle, const void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:127
int iindexhandle
Definition: isinternal.h:406
off_t tvblseek(const int ihandle, off_t toffset, const int iwhence)
Definition: vblowlevel.c:107
int idatahandle
Definition: isinternal.h:405
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int inodesize
Definition: isinternal.h:402

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbcheckkey ( const int  ihandle,
struct keydesc *  pskey,
const int  imode,
int  irowlength,
const int  iisbuild 
)

Definition at line 124 of file isread.c.

References DICTINFO::iminrowlength, DICTINFO::inkeys, iserrno, DICTINFO::pskeydesc, psvbfile, and QUADSIZE.

Referenced by isaddindex(), isbuild(), isdelindex(), and isstart().

126 {
127  struct DICTINFO *psvbptr;
128  struct keydesc *pslocalkey;
129  struct keypart *pskptr;
130  struct keypart *psklptr;
131  int iloop, ipart, itype, ilocalkeylength;
132 
133  psvbptr = psvbfile[ihandle];
134  if (imode) {
135  irowlength = psvbptr->iminrowlength;
136  }
137  if (imode < 2) {
138  /* Basic key validity test */
139  pskey->k_len = 0;
140  if (pskey->k_flags < 0 || pskey->k_flags > COMPRESS + ISDUPS) {
141  goto vbcheckkey_exit;
142  }
143  if (pskey->k_nparts >= NPARTS || pskey->k_nparts < 0) {
144  goto vbcheckkey_exit;
145  }
146  if (pskey->k_nparts == 0 && !iisbuild) {
147  goto vbcheckkey_exit;
148  }
149  for (ipart = 0; ipart < pskey->k_nparts; ipart++) {
150  /* Wierdly enough, a single keypart CAN span multiple instances */
151  /* EG: Part number 1 might contain 4 long values */
152  pskptr = &pskey->k_part[ipart];
153  pskey->k_len += pskptr->kp_leng;
154  if (pskey->k_len > VB_MAX_KEYLEN) {
155  goto vbcheckkey_exit;
156  }
157  itype = pskptr->kp_type & ~ISDESC;
158  switch (itype) {
159  case CHARTYPE:
160  break;
161 
162  case INTTYPE:
163  if (pskptr->kp_leng % INTSIZE) {
164  goto vbcheckkey_exit;
165  }
166  break;
167 
168  case LONGTYPE:
169  if (pskptr->kp_leng % LONGSIZE) {
170  goto vbcheckkey_exit;
171  }
172  break;
173 
174  case QUADTYPE:
175  if (pskptr->kp_leng % QUADSIZE) {
176  goto vbcheckkey_exit;
177  }
178  break;
179 
180  case FLOATTYPE:
181  if (pskptr->kp_leng % FLOATSIZE) {
182  goto vbcheckkey_exit;
183  }
184  break;
185 
186  case DOUBLETYPE:
187  if (pskptr->kp_leng % DOUBLESIZE) {
188  goto vbcheckkey_exit;
189  }
190  break;
191 
192  default:
193  goto vbcheckkey_exit;
194  }
195  if (pskptr->kp_start + pskptr->kp_leng > irowlength) {
196  goto vbcheckkey_exit;
197  }
198  if (pskptr->kp_start < 0) {
199  goto vbcheckkey_exit;
200  }
201  }
202  if (!imode) {
203  return 0;
204  }
205  }
206 
207  /* Check whether the key already exists */
208  for (iloop = 0; iloop < psvbptr->inkeys; iloop++) {
209  pslocalkey = psvbptr->pskeydesc[iloop];
210  if (pslocalkey->k_nparts != pskey->k_nparts) {
211  continue;
212  }
213  ilocalkeylength = 0;
214  for (ipart = 0; ipart < pslocalkey->k_nparts; ipart++) {
215  pskptr = &pskey->k_part[ipart];
216  psklptr = &pslocalkey->k_part[ipart];
217  if (psklptr->kp_start != pskptr->kp_start) {
218  break;
219  }
220  if (psklptr->kp_leng != pskptr->kp_leng) {
221  break;
222  }
223  if (psklptr->kp_type != pskptr->kp_type) {
224  break;
225  }
226  ilocalkeylength += pskptr->kp_leng;
227  }
228  if (ipart == pslocalkey->k_nparts) {
229  pskey->k_len = ilocalkeylength;
230  break; /* found */
231  }
232  }
233  if (iloop == psvbptr->inkeys) {
234  if (imode == 2) {
235  goto vbcheckkey_exit;
236  }
237  return iloop;
238  }
239  if (imode == 1) {
240  goto vbcheckkey_exit;
241  }
242  return iloop;
243 
244 vbcheckkey_exit:
245  iserrno = EBADKEY;
246  return -1;
247 }
int inkeys
Definition: isinternal.h:400
int iminrowlength
Definition: isinternal.h:403
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
int iserrno
Definition: vbmemio.c:27

Here is the caller graph for this function:

int ivbclose ( const int  ihandle)

Definition at line 93 of file vblowlevel.c.

References VBFILE::irefcount, and svbfile.

Referenced by isbuild(), islogclose(), isopen(), and ivbclose2().

94 {
95  if (!svbfile[ihandle].irefcount) {
96  errno = ENOENT;
97  return -1;
98  }
99  svbfile[ihandle].irefcount--;
100  if (!svbfile[ihandle].irefcount) {
101  return close (svbfile[ihandle].ihandle);
102  }
103  return 0;
104 }
int irefcount
Definition: isinternal.h:457
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24

Here is the caller graph for this function:

int ivbclose2 ( const int  ihandle)

Definition at line 83 of file isopen.c.

References DICTINFO::cfilename, DICTINFO::idatahandle, DICTINFO::iindexhandle, DICTINFO::iisopen, iserrno, isrelease(), DICTINFO::itransyet, ivbclose(), ivbtransclose(), MAXSUBS, NULL, DICTINFO::pskeycurr, VBFILE::pslockhead, VBFILE::pslocktail, VBLOCK::psnext, psvbfile, svbfile, DICTINFO::tdupnumber, DICTINFO::trownumber, and vvblockfree().

Referenced by iscleanup(), isclose(), iscommit(), and isrollback().

84 {
85  struct VBLOCK *psrowlock;
86  struct DICTINFO *psvbptr;
87  int iloop;
88  int iindexhandle;
89 
90  psvbptr = psvbfile[ihandle];
91  psvbptr->iisopen = 0; /* It's a LIE, but so what! */
92  isrelease (ihandle);
93  iserrno = ivbtransclose (ihandle, psvbptr->cfilename);
94  if (ivbclose (psvbptr->idatahandle)) {
95  iserrno = errno;
96  }
97  psvbptr->idatahandle = -1;
98  if (ivbclose (psvbptr->iindexhandle)) {
99  iserrno = errno;
100  }
101  iindexhandle = psvbptr->iindexhandle;
102  while (svbfile[iindexhandle].pslockhead) {
103  psrowlock = svbfile[iindexhandle].pslockhead->psnext;
104  vvblockfree (svbfile[iindexhandle].pslockhead);
105  svbfile[iindexhandle].pslockhead = psrowlock;
106  }
108  psvbptr->iindexhandle = -1;
109 /* RXW
110  psvbptr->trownumber = -1;
111  psvbptr->tdupnumber = -1;
112 */
113  psvbptr->trownumber = 0;
114  psvbptr->tdupnumber = 0;
115  psvbptr->iisopen = 2; /* Only buffers remain! */
116  psvbptr->itransyet = 0;
117  for (iloop = 0; iloop < MAXSUBS; iloop++) {
118  psvbptr->pskeycurr[iloop] = NULL;
119  }
120 
121  return (iserrno ? -1 : 0);
122 }
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24
int ivbtransclose(const int ihandle, const char *pcfilename)
Definition: istrans.c:806
struct VBLOCK * pslocktail
Definition: isinternal.h:455
struct VBLOCK * psnext
Definition: isinternal.h:318
int iindexhandle
Definition: isinternal.h:406
struct VBLOCK * pslockhead
Definition: isinternal.h:454
char * cfilename
Definition: isinternal.h:422
int iisopen
Definition: isinternal.h:407
void vvblockfree(struct VBLOCK *pslock)
Definition: vbmemio.c:81
off_t tdupnumber
Definition: isinternal.h:417
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbclose(const int ihandle)
Definition: vblowlevel.c:93
int isrelease(const int ihandle)
Definition: ishelper.c:126
off_t trownumber
Definition: isinternal.h:416
unsigned char itransyet
Definition: isinternal.h:438
int idatahandle
Definition: isinternal.h:405
int iserrno
Definition: vbmemio.c:27
#define MAXSUBS
Definition: isinternal.h:119

Here is the call graph for this function:

Here is the caller graph for this function:

void ivbclose3 ( const int  ihandle)

Definition at line 125 of file isopen.c.

References DICTINFO::cfilename, MAXSUBS, NULL, DICTINFO::ppcrowbuffer, DICTINFO::pskeydesc, DICTINFO::pstree, psvbfile, vvbfree(), vvbkeyunmalloc(), and vvbtreeallfree().

Referenced by isbuild(), iscleanup(), iserase(), and isfullclose().

126 {
127  struct DICTINFO *psvbptr;
128  int iloop;
129 
130  psvbptr = psvbfile[ihandle];
131  if (!psvbptr) {
132  return;
133  }
134  for (iloop = 0; iloop < MAXSUBS; iloop++) {
135  vvbtreeallfree (ihandle, iloop, psvbptr->pstree[iloop]);
136  if (psvbptr->pskeydesc[iloop]) {
137  vvbkeyunmalloc (ihandle, iloop);
138  vvbfree (psvbptr->pskeydesc[iloop]);
139  }
140  }
141  if (psvbptr->cfilename) {
142  free (psvbptr->cfilename);
143  }
144  if (psvbptr->ppcrowbuffer) {
145  free (psvbptr->ppcrowbuffer);
146  }
147  vvbfree (psvbptr);
148  psvbfile[ihandle] = NULL;
149 }
void vvbfree(void *mptr)
Definition: vbmemio.c:59
char * cfilename
Definition: isinternal.h:422
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
struct VBTREE * pstree[32]
Definition: isinternal.h:446
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
char * ppcrowbuffer
Definition: isinternal.h:423
void vvbkeyunmalloc(const int ihandle, const int ikeynumber)
Definition: vbmemio.c:196
#define MAXSUBS
Definition: isinternal.h:119

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbdatafree ( const int  ihandle,
const off_t  trownumber 
)

Definition at line 150 of file vbindexio.c.

References DICTNODE::cdatacount, DICTNODE::cdatafree, cvbnodetmp, DICTINFO::iisdictlocked, inl_ldint(), inl_ldquad(), inl_stint(), inl_stquad(), DICTINFO::inodesize, iserrno, ivbblockread(), ivbblockwrite(), psvbfile, QUADSIZE, DICTINFO::sdictnode, tvbnodeallocate(), and VB_NODE_MAX.

Referenced by iprocessdelete(), iswrcurr(), iswrite(), ivbforcedataallocate(), ivbrollmeback(), ivbrollmeforward(), and vrebuilddatafree().

151 {
152  struct DICTINFO *psvbptr;
153  off_t theadnode, tnodenumber;
154  int ilengthused, iresult;
155 
156  /* Sanity check - Is ihandle a currently open table? */
157  iserrno = ENOTOPEN;
158  psvbptr = psvbfile[ihandle];
159  if (!psvbptr) {
160  return -1;
161  }
162  iserrno = EBADARG;
163  if (!psvbptr->iisdictlocked) {
164  return -1;
165  }
166  iserrno = 0;
167 
168  if (inl_ldquad (psvbptr->sdictnode.cdatacount) == trownumber) {
169  inl_stquad (trownumber - 1, psvbptr->sdictnode.cdatacount);
170  psvbptr->iisdictlocked |= 0x02;
171  return 0;
172  }
173 
174  theadnode = inl_ldquad (psvbptr->sdictnode.cdatafree);
175  if (theadnode != 0) {
176  iresult = ivbblockread (ihandle, 1, theadnode, cvbnodetmp);
177  if (iresult) {
178  return iresult;
179  }
180 /* C-ISAM is not 100% C-ISAM compatible */
181 #if ISAMMODE == 1
182  if (cvbnodetmp[psvbptr->inodesize - 2] != 0x7f) {
183  return EBADFILE;
184  }
185 #endif
186  if (cvbnodetmp[psvbptr->inodesize - 3] != -1) {
187  return EBADFILE;
188  }
189  ilengthused = inl_ldint (cvbnodetmp);
190  if (ilengthused < psvbptr->inodesize - (QUADSIZE + 3)) {
191  /* We need to add trownumber to the current node */
192  inl_stquad ((off_t) trownumber, cvbnodetmp + ilengthused);
193  ilengthused += QUADSIZE;
194  inl_stint (ilengthused, cvbnodetmp);
195  iresult = ivbblockwrite (ihandle, 1, theadnode, cvbnodetmp);
196  return iresult;
197  }
198  }
199  /* We need to allocate a new row-free node! */
200  /* We append any existing nodes using the next pointer from the new node */
201  tnodenumber = tvbnodeallocate (ihandle);
202  if (tnodenumber == (off_t)-1) {
203  return iserrno;
204  }
205  memset (cvbnodetmp, 0, VB_NODE_MAX);
206  cvbnodetmp[psvbptr->inodesize - 2] = 0x7f;
207  cvbnodetmp[psvbptr->inodesize - 3] = -1;
208  inl_stint (INTSIZE + (2 * QUADSIZE), cvbnodetmp);
209  inl_stquad (theadnode, &cvbnodetmp[INTSIZE]);
210  inl_stquad (trownumber, &cvbnodetmp[INTSIZE + QUADSIZE]);
211  iresult = ivbblockwrite (ihandle, 1, tnodenumber, cvbnodetmp);
212  if (iresult) {
213  return iresult;
214  }
215  inl_stquad (tnodenumber, psvbptr->sdictnode.cdatafree);
216  psvbptr->iisdictlocked |= 0x02;
217  return 0;
218 }
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
off_t tvbnodeallocate(const int ihandle)
Definition: vbindexio.c:221
char cdatacount[8]
Definition: isinternal.h:375
#define VB_NODE_MAX
Definition: isinternal.h:288
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTNODE sdictnode
Definition: isinternal.h:444
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
static char cvbnodetmp[4096]
Definition: vbindexio.c:22
char cdatafree[8]
Definition: isinternal.h:373
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
off_t trownumber
Definition: isinternal.h:416
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbdatalock ( const int  ihandle,
const int  imode,
const off_t  trownumber 
)

Definition at line 432 of file vblocking.c.

References VBLOCK::ihandle, DICTINFO::iindexhandle, DICTINFO::iisdatalocked, ilockdelete(), ilockinsert(), DICTINFO::iopenmode, ivblock(), ivbmaxusedhandle, VBFILE::pslockhead, VBLOCK::psnext, psvbfile, svbfile, VBLOCK::trownumber, unlikely, VB_OFFLEN_3F, VB_OFFLEN_40, and VBUNLOCK.

Referenced by idemotelocks(), iprocessdelete(), islock(), isread(), isrelcurr(), isrelease(), isrelrec(), isrewcurr(), isrewrec(), isrewrite(), istartrownumber(), isunlock(), and ivbwriterow().

433 {
434  struct DICTINFO *psvbptr;
435  struct VBLOCK *pslock;
436  off_t tlength = 1, toffset;
437  int iresult = 0;
438 
439  /* Sanity check - Is ihandle a currently open table? */
440  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
441  return ENOTOPEN;
442  }
443  psvbptr = psvbfile[ihandle];
444  if (!psvbptr) {
445  return ENOTOPEN;
446  }
447  if (psvbptr->iopenmode & ISEXCLLOCK) {
448  return 0;
449  }
450  /*
451  * If this is a FILE (un)lock (row = 0), then we may as well free ALL
452  * locks. Even if CISAMLOCKS is set, we do this!
453  */
454  if (trownumber == 0) {
455  for (pslock = svbfile[psvbptr->iindexhandle].pslockhead; pslock;
456  pslock = pslock->psnext) {
458  }
459  tlength = VB_OFFLEN_3F;
460  if (imode == VBUNLOCK) {
461  psvbptr->iisdatalocked = 0;
462  } else {
463  psvbptr->iisdatalocked = 1;
464  }
465  } else if (imode == VBUNLOCK) {
466  iresult = ilockdelete (ihandle, trownumber);
467  }
468  if (!iresult) {
469  toffset = VB_OFFLEN_40;
470  iresult = ivblock (psvbptr->iindexhandle, toffset + trownumber,
471  tlength, imode);
472  if (iresult != 0) {
473  return ELOCKED;
474  }
475  }
476  if ((imode != VBUNLOCK) && trownumber) {
477  return ilockinsert (ihandle, trownumber);
478  }
479  return iresult;
480 }
int ivblock(const int ihandle, const off_t toffset, const off_t tlength, const int imode)
Definition: vblowlevel.c:197
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24
struct VBLOCK * psnext
Definition: isinternal.h:318
int ihandle
Definition: isinternal.h:319
int iindexhandle
Definition: isinternal.h:406
struct VBLOCK * pslockhead
Definition: isinternal.h:454
#define unlikely(x)
Definition: common.h:437
#define VB_OFFLEN_40
Definition: isinternal.h:111
off_t trownumber
Definition: isinternal.h:320
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define VB_OFFLEN_3F
Definition: isinternal.h:110
unsigned char iisdatalocked
Definition: isinternal.h:426
int iopenmode
Definition: isinternal.h:412
int ivbmaxusedhandle
Definition: vblocking.c:26
int ivbdatalock(const int ihandle, const int imode, const off_t trownumber)
Definition: vblocking.c:432
static int ilockdelete(const int ihandle, const off_t trownumber)
Definition: vblocking.c:97
static int ilockinsert(const int ihandle, const off_t trownumber)
Definition: vblocking.c:31
#define VBUNLOCK
Definition: isinternal.h:294

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbdataread ( const int  ihandle,
char *  pcbuffer,
int *  pideletedrow,
const off_t  trownumber 
)

Definition at line 493 of file vbdataio.c.

References cvbnodetmp, DICTINFO::idatahandle, DICTINFO::iminrowlength, inl_ldint(), inl_ldquad(), DICTINFO::inodesize, DICTINFO::iopenmode, iserrno, isreclen, DICTINFO::ivarlenlength, DICTINFO::ivarlenslot, ivbblockread(), ivbmaxusedhandle, ivbvarlenread(), MAX_RESERVED_LENGTH, psvbfile, QUADSIZE, DICTINFO::tvarlennode, tvblseek(), tvbread(), unlikely, and VB_NODE_MAX.

Referenced by idatacheck(), imakekeysfromdata(), iprocessdelete(), isread(), isrewcurr(), isrewrec(), isrewrite(), istartrownumber(), and vrebuildkeys().

494 {
495  struct DICTINFO *psvbptr;
496  off_t tblocknumber, toffset, tsofar;
497  int irowlength;
498  int n;
499  char cfooter[VB_NODE_MAX];
500  char cvbnodetmp[VB_NODE_MAX];
501  char pcreadbuffer[MAX_RESERVED_LENGTH];
502 
503  /* Sanity check - Is ihandle a currently open table? */
504  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
505  return ENOTOPEN;
506  }
507  if (!psvbfile[ihandle]) {
508  return ENOTOPEN;
509  }
510  if (trownumber < 1) {
511  return EBADARG;
512  }
513  psvbptr = psvbfile[ihandle];
514 
515  irowlength = psvbptr->iminrowlength;
516  irowlength++;
517  if (psvbptr->iopenmode & ISVARLEN) {
518  irowlength += INTSIZE + QUADSIZE;
519  } else {
520 /* RXW */
521  toffset = irowlength * (trownumber - 1);
522  if (tvblseek (psvbptr->idatahandle, toffset, SEEK_SET) != toffset) {
523  return EBADFILE;
524  }
525  memset (pcreadbuffer, 0, irowlength);
526  if (tvbread (psvbptr->idatahandle, pcreadbuffer, (size_t)irowlength) < 0) {
527  return EBADFILE;
528  }
529  memcpy (pcbuffer, pcreadbuffer, (size_t)psvbptr->iminrowlength);
530  if (pcreadbuffer[psvbptr->iminrowlength] == 0) {
531  *pideletedrow = 1;
532  } else {
533  *pideletedrow = 0;
534  }
535  isreclen = psvbptr->iminrowlength;
536  return 0;
537  }
538  toffset = irowlength * (trownumber - 1);
539  tblocknumber = (toffset / psvbptr->inodesize);
540  toffset -= (tblocknumber * psvbptr->inodesize);
541  if (ivbblockread (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
542  return EBADFILE;
543  }
544  /* Read in the *MINIMUM* rowlength and store it into pcbuffer */
545  tsofar = 0;
546  while (tsofar < psvbptr->iminrowlength) {
547  if ((psvbptr->iminrowlength - tsofar) < (psvbptr->inodesize - toffset)) {
548  memcpy (pcbuffer + tsofar, cvbnodetmp + toffset,
549  (size_t)(psvbptr->iminrowlength - tsofar));
550  toffset += psvbptr->iminrowlength - tsofar;
551  tsofar = psvbptr->iminrowlength;
552  break;
553  }
554  memcpy (pcbuffer + tsofar, cvbnodetmp + toffset, (size_t)(psvbptr->inodesize - toffset));
555  tblocknumber++;
556  tsofar += psvbptr->inodesize - toffset;
557  toffset = 0;
558  if (ivbblockread (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
559  return EBADFILE;
560  }
561  }
562  pcbuffer += tsofar;
563  /* OK, now for the footer. Either 1 byte or 1 + INTSIZE + QUADSIZE. */
564  while (tsofar < irowlength) {
565  if ((irowlength - tsofar) <= (psvbptr->inodesize - toffset)) {
566  memcpy (cfooter + tsofar - psvbptr->iminrowlength, cvbnodetmp + toffset,
567  (size_t)(irowlength - tsofar));
568  break;
569  }
570  memcpy (cfooter + tsofar - psvbptr->iminrowlength, cvbnodetmp + toffset,
571  (size_t)(psvbptr->inodesize - toffset));
572  tblocknumber++;
573  tsofar += psvbptr->inodesize - toffset;
574  toffset = 0;
575  if (ivbblockread (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
576  return EBADFILE;
577  }
578  }
579  isreclen = psvbptr->iminrowlength;
580  *pideletedrow = 0;
581  if (cfooter[0] == 0x00) {
582  *pideletedrow = 1;
583  } else {
584  if (psvbptr->iopenmode & ISVARLEN) {
585  psvbptr->ivarlenlength = inl_ldint (cfooter + 1);
586 /* VBISAM in 64 bit mode (4k Nodes) uses a ten bit slot number */
587 /* VBISAM in 32 bit mode (1k Nodes) uses an eight bit slot number */
588 #if ISAMMODE == 1
589  n = inl_ldint (cfooter + 1 + INTSIZE);
590  psvbptr->ivarlenslot = n >> 6;
591  *(cfooter + 1 + INTSIZE + 1) &= (unsigned char)0x3f;
592 #else
593  psvbptr->ivarlenslot = *(cfooter + 1 + INTSIZE);
594 #endif
595  *(cfooter + 1 + INTSIZE) = 0;
596  psvbptr->tvarlennode = inl_ldquad (cfooter + 1 + INTSIZE);
597  if (psvbptr->ivarlenlength) {
598  if (ivbvarlenread (ihandle, (char *)pcbuffer,
599  psvbptr->tvarlennode,
600  psvbptr->ivarlenslot, psvbptr->ivarlenlength)) {
601  return iserrno;
602  }
603  }
604  isreclen += psvbptr->ivarlenlength;
605  }
606  }
607  return 0;
608 }
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
int isreclen
Definition: vbmemio.c:29
int ivarlenslot
Definition: isinternal.h:414
int iminrowlength
Definition: isinternal.h:403
int ivbmaxusedhandle
Definition: vblocking.c:26
off_t tvarlennode
Definition: isinternal.h:421
static int ivbvarlenread(const int ihandle, char *pcbuffer, off_t tnodenumber, int islotnumber, int ilength)
Definition: vbdataio.c:220
#define VB_NODE_MAX
Definition: isinternal.h:288
#define unlikely(x)
Definition: common.h:437
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
int iopenmode
Definition: isinternal.h:412
#define MAX_RESERVED_LENGTH
Definition: isinternal.h:290
ssize_t tvbread(const int ihandle, void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:117
int ivarlenlength
Definition: isinternal.h:413
static char * cvbnodetmp
Definition: ischeck.c:25
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
off_t trownumber
Definition: isinternal.h:416
int idatahandle
Definition: isinternal.h:405
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402
off_t tvblseek(const int ihandle, off_t toffset, const int iwhence)
Definition: vblowlevel.c:107

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbdatawrite ( const int  ihandle,
char *  pcbuffer,
int  ideletedrow,
const off_t  trownumber 
)

Definition at line 611 of file vbdataio.c.

References cvbnodetmp, DICTINFO::idatahandle, DICTINFO::iminrowlength, inl_ldint(), inl_stint(), inl_stquad(), DICTINFO::inodesize, DICTINFO::iopenmode, iserrno, isreclen, DICTINFO::ivarlenlength, DICTINFO::ivarlenslot, ivbblockread(), ivbblockwrite(), ivbmaxusedhandle, ivbvarlendelete(), ivbvarlenwrite(), MAX_RESERVED_LENGTH, pcwritebuffer, psvbfile, QUADSIZE, DICTINFO::tvarlennode, tvblseek(), tvbwrite(), unlikely, and VB_NODE_MAX.

Referenced by iprocessdelete(), isrewcurr(), isrewrec(), isrewrite(), and ivbwriterow().

612 {
613  struct DICTINFO *psvbptr;
614  char *pctemp;
615  off_t tblocknumber, toffset, tsofar;
616  int irowlength;
617  int n;
618  char cvbnodetmp[VB_NODE_MAX];
620 
621  /* Sanity check - Is ihandle a currently open table? */
622  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
623  return ENOTOPEN;
624  }
625  if (!psvbfile[ihandle]) {
626  return ENOTOPEN;
627  }
628  if (trownumber < 1) {
629  return EBADARG;
630  }
631  psvbptr = psvbfile[ihandle];
632 
633  irowlength = psvbptr->iminrowlength;
634  toffset = irowlength + 1;
635  if (psvbptr->iopenmode & ISVARLEN) {
636  toffset += INTSIZE + QUADSIZE;
637  } else {
638 /* RXW */
639  toffset *= (trownumber - 1);
640  if (tvblseek (psvbptr->idatahandle, toffset, SEEK_SET) != toffset) {
641  return EBADFILE;
642  }
643  memcpy (pcwritebuffer, pcbuffer, (size_t)irowlength);
644  *(pcwritebuffer + irowlength) = ideletedrow ? 0x00 : 0x0a;
645  irowlength++;
646  if (tvbwrite (psvbptr->idatahandle, pcwritebuffer, (size_t)irowlength) != (ssize_t)irowlength) {
647  return EBADFILE;
648  }
649  return 0;
650  }
651  toffset *= (trownumber - 1);
652  if (psvbptr->iopenmode & ISVARLEN) {
653  if (psvbptr->tvarlennode) {
654  if (ivbvarlendelete (ihandle, psvbptr->tvarlennode, psvbptr->ivarlenslot,
655  psvbptr->ivarlenlength)) {
656  return -69;
657  }
658  }
659  if (isreclen == psvbptr->iminrowlength || ideletedrow) {
660  psvbptr->tvarlennode = 0;
661  psvbptr->ivarlenlength = 0;
662  psvbptr->ivarlenslot = 0;
663  } else {
664  if (ivbvarlenwrite (ihandle, pcbuffer + psvbptr->iminrowlength,
665  isreclen - psvbptr->iminrowlength)) {
666  return iserrno;
667  }
668  }
669  }
670  memcpy (pcwritebuffer, pcbuffer, (size_t)irowlength);
671  *(pcwritebuffer + irowlength) = ideletedrow ? 0x00 : 0x0a;
672  irowlength++;
673  if (psvbptr->iopenmode & ISVARLEN) {
674  inl_stint (psvbptr->ivarlenlength, pcwritebuffer + irowlength);
675  pctemp = pcwritebuffer + irowlength + INTSIZE;
676  inl_stquad (psvbptr->tvarlennode, pctemp);
677 #if ISAMMODE == 1
678  n = (psvbptr->ivarlenslot << 6) + inl_ldint (pctemp);
679  inl_stint (n, pctemp);
680 #else
681  *pctemp = psvbptr->ivarlenslot;
682 #endif
683  irowlength += INTSIZE + QUADSIZE;
684  }
685 
686  tblocknumber = (toffset / psvbptr->inodesize);
687  toffset -= (tblocknumber * psvbptr->inodesize);
688  tsofar = 0;
689  while (tsofar < irowlength) {
690  memset (cvbnodetmp, 0, VB_NODE_MAX);
691  ivbblockread (ihandle, 0, tblocknumber + 1, cvbnodetmp); /* Can fail!! */
692  if ((irowlength - tsofar) <= (psvbptr->inodesize - toffset)) {
693  memcpy (cvbnodetmp + toffset, pcwritebuffer + tsofar,
694  (size_t)(irowlength - tsofar));
695  if (ivbblockwrite (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
696  return EBADFILE;
697  }
698  break;
699  }
700  memcpy (cvbnodetmp + toffset, pcbuffer + tsofar, (size_t)(psvbptr->inodesize - toffset));
701  if (ivbblockwrite (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
702  return EBADFILE;
703  }
704  tblocknumber++;
705  tsofar += psvbptr->inodesize - toffset;
706  toffset = 0;
707  }
708  return 0;
709 }
ssize_t tvbwrite(const int ihandle, const void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:127
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
int isreclen
Definition: vbmemio.c:29
int ivarlenslot
Definition: isinternal.h:414
int iminrowlength
Definition: isinternal.h:403
int ivbmaxusedhandle
Definition: vblocking.c:26
off_t tvarlennode
Definition: isinternal.h:421
#define VB_NODE_MAX
Definition: isinternal.h:288
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define unlikely(x)
Definition: common.h:437
static int ivbvarlenwrite(const int ihandle, char *pcbuffer, int ilength)
Definition: vbdataio.c:270
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
int iopenmode
Definition: isinternal.h:412
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
#define MAX_RESERVED_LENGTH
Definition: isinternal.h:290
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static int ivbvarlendelete(const int ihandle, off_t tnodenumber, int islotnumber, int ilength)
Definition: vbdataio.c:376
int ivarlenlength
Definition: isinternal.h:413
static char * cvbnodetmp
Definition: ischeck.c:25
off_t trownumber
Definition: isinternal.h:416
int idatahandle
Definition: isinternal.h:405
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402
static char * pcwritebuffer
Definition: isdelete.c:22
off_t tvblseek(const int ihandle, off_t toffset, const int iwhence)
Definition: vblowlevel.c:107

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbenter ( const int  ihandle,
const unsigned int  imodifying,
const unsigned int  ispecial 
)

Definition at line 178 of file vblocking.c.

References DICTNODE::ctransnumber, cvbnodetmp, DICTINFO::iindexchanged, DICTINFO::iindexhandle, DICTINFO::iisdictlocked, DICTINFO::iisopen, inl_ldquad(), DICTINFO::iopenmode, iserrno, ivbblockread(), ivbexit(), ivbintrans, ivblock(), ivbmaxusedhandle, MAXSUBS, NULL, DICTINFO::pskeycurr, DICTINFO::pstree, psvbfile, DICTINFO::sdictnode, VBKEY::trownode, DICTINFO::ttranslast, unlikely, VB_NODE_MAX, VB_OFFLEN_3F, VBCOMMIT, VBNOTRANS, VBRDLOCK, VBROLLBACK, VBWRLOCK, and vvbtreeallfree().

Referenced by ircvinsert(), isaddindex(), ischeck(), isdelcurr(), isdelete(), isdelindex(), isdelrec(), isindexinfo(), isopen(), isread(), isrewcurr(), isrewrec(), isrewrite(), issetunique(), isstart(), isuniqueid(), iswrcurr(), iswrite(), ivbrollmeback(), and ivbrollmeforward().

180 {
181  struct DICTINFO *psvbptr;
182  off_t tlength;
183  size_t iloop;
184  int ilockmode;
185  char cvbnodetmp[VB_NODE_MAX];
186 
187  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
188  iserrno = EBADARG;
189  return -1;
190  }
191  psvbptr = psvbfile[ihandle];
192  if (unlikely(!psvbptr)) {
193  iserrno = ENOTOPEN;
194  return -1;
195  }
196  for (iloop = 0; iloop < MAXSUBS; iloop++) {
197  if (psvbptr->pskeycurr[iloop]
198  && psvbptr->pskeycurr[iloop]->trownode == -1) {
199  psvbptr->pskeycurr[iloop] = NULL;
200  }
201  }
202  iserrno = 0;
203  if (psvbptr->iisopen && ivbintrans != VBCOMMIT && ivbintrans != VBROLLBACK) {
204  iserrno = ENOTOPEN;
205  return -1;
206  }
207  if ((psvbptr->iopenmode & ISTRANS) && ivbintrans == VBNOTRANS) {
208  iserrno = ENOTRANS;
209  return -1;
210  }
211  psvbptr->iindexchanged = 0;
212  if (psvbptr->iopenmode & ISEXCLLOCK) {
213  psvbptr->iisdictlocked |= 0x01;
214  return 0;
215  }
216  if (psvbptr->iisdictlocked & 0x03) {
217  iserrno = EBADARG;
218  return -1;
219  }
220 /* RXW
221  if (imodifying) {
222  ilockmode = VBWRLCKW;
223  } else {
224  ilockmode = VBRDLCKW;
225  }
226 */
227  if (imodifying) {
228  ilockmode = VBWRLOCK;
229  } else {
230  ilockmode = VBRDLOCK;
231  }
232  tlength = VB_OFFLEN_3F;
233  psvbptr->iindexchanged = 0;
234  if (ivblock (psvbptr->iindexhandle, (off_t)0, tlength, ilockmode)) {
235  iserrno = EFLOCKED;
236  return -1;
237  }
238  psvbptr->iisdictlocked |= 0x01;
239 /* RXW
240  if (unlikely(ispecial)) {
241  if (tvblseek (psvbptr->iindexhandle, (off_t)0, SEEK_SET)) {
242  psvbptr->iisdictlocked = 0;
243  ivbexit (ihandle);
244  iserrno = EBADFILE;
245  return -1;
246  }
247  if (tvbread (psvbptr->iindexhandle, cvbnodetmp, 8) != 8) {
248  psvbptr->iisdictlocked = 0;
249  ivbexit (ihandle);
250  iserrno = EBADFILE;
251  return -1;
252  }
253  psvbptr->inodesize = inl_ldint (&cvbnodetmp[6]) + 1;
254  }
255 */
256  if (ivbblockread (ihandle, 1, (off_t) 1, cvbnodetmp)) {
257  psvbptr->iisdictlocked = 0;
258  ivbexit (ihandle);
259  iserrno = EBADFILE;
260  return -1;
261  }
262  memcpy ((void *)&psvbptr->sdictnode, (void *)cvbnodetmp,
263  sizeof (struct DICTNODE));
264  psvbptr->iisdictlocked |= 0x01;
265 /*
266  * If we're in C-ISAM mode, then there is NO way to determine if a given node
267  * has been updated by some other process. Thus *ANY* change to the index
268  * file needs to invalidate the ENTIRE cache for that table!!!
269  * If we're in VBISAM 64-bit mode, then each node in the index table has a
270  * stamp on it stating the transaction number when it was updated. If this
271  * stamp is BELOW that of the current transaction number, we know that the
272  * associated VBTREE / VBKEY linked lists are still coherent!
273  */
274 #if ISAMMODE == 0
275  if (psvbptr->ttranslast !=
276  inl_ldquad (psvbptr->sdictnode.ctransnumber)) {
277  for (iloop = 0; iloop < MAXSUBS; iloop++) {
278  if (psvbptr->pstree[iloop]) {
279  vvbtreeallfree (ihandle, iloop,
280  psvbptr->pstree[iloop]);
281  }
282  psvbptr->pstree[iloop] = NULL;
283  }
284  }
285 #endif
286  return 0;
287 }
int ivblock(const int ihandle, const off_t toffset, const off_t tlength, const int imode)
Definition: vblowlevel.c:197
unsigned char iindexchanged
Definition: isinternal.h:434
#define VBCOMMIT
Definition: isinternal.h:309
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
#define VBRDLOCK
Definition: isinternal.h:295
int iindexhandle
Definition: isinternal.h:406
#define VBNOTRANS
Definition: isinternal.h:306
#define VB_NODE_MAX
Definition: isinternal.h:288
int iisopen
Definition: isinternal.h:407
#define unlikely(x)
Definition: common.h:437
int ivbexit(const int ihandle)
Definition: vblocking.c:290
unsigned char iisdictlocked
Definition: isinternal.h:427
off_t ttranslast
Definition: isinternal.h:419
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
struct DICTNODE sdictnode
Definition: isinternal.h:444
off_t trownode
Definition: isinternal.h:328
#define VBWRLOCK
Definition: isinternal.h:297
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define VB_OFFLEN_3F
Definition: isinternal.h:110
char ctransnumber[8]
Definition: isinternal.h:377
int iopenmode
Definition: isinternal.h:412
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
int ivbmaxusedhandle
Definition: vblocking.c:26
#define VBROLLBACK
Definition: isinternal.h:310
struct VBTREE * pstree[32]
Definition: isinternal.h:446
static char * cvbnodetmp
Definition: ischeck.c:25
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
int iserrno
Definition: vbmemio.c:27
#define MAXSUBS
Definition: isinternal.h:119
int ivbintrans
Definition: istrans.c:23

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbexit ( const int  ihandle)

Definition at line 290 of file vblocking.c.

References DICTNODE::ctransnumber, cvbnodetmp, DICTINFO::iindexhandle, DICTINFO::iisdictlocked, DICTINFO::inkeys, inl_ldquad(), inl_stquad(), DICTINFO::iopenmode, iserrno, ivbblockwrite(), IVBBUFFERLEVEL, ivblock(), NULL, VBKEY::pschild, VBTREE::pskeycurr, DICTINFO::pskeycurr, VBTREE::pskeyfirst, VBKEY::psnext, VBKEY::psparent, VBTREE::psparent, psvbfile, DICTINFO::sdictnode, DICTINFO::ttranslast, VB_NODE_MAX, VB_OFFLEN_3F, VBUNLOCK, and vvbtreeallfree().

Referenced by ircvinsert(), isaddindex(), ischeck(), isdelcurr(), isdelete(), isdelindex(), isdelrec(), isindexinfo(), isopen(), isread(), isrewcurr(), isrewrec(), isrewrite(), isrollback(), issetunique(), isstart(), isuniqueid(), iswrcurr(), iswrite(), ivbenter(), ivbrollmeback(), and ivbrollmeforward().

291 {
292  struct DICTINFO *psvbptr;
293  struct VBKEY *pskey, *pskeycurr;
294  off_t tlength, ttransnumber;
295  int iresult = 0, iloop, iloop2, isaveerror;
296  char cvbnodetmp[VB_NODE_MAX];
297 
298  isaveerror = iserrno;
299  psvbptr = psvbfile[ihandle];
300  if (!psvbptr || (!psvbptr->iisdictlocked && !(psvbptr->iopenmode & ISEXCLLOCK))) {
301  iserrno = EBADARG;
302  return -1;
303  }
304  ttransnumber = inl_ldquad (psvbptr->sdictnode.ctransnumber);
305  psvbptr->ttranslast = ttransnumber;
306 /* RXW
307  if (psvbptr->iopenmode & ISEXCLLOCK) {
308  return 0;
309  }
310 */
311  if (psvbptr->iisdictlocked & 0x02) {
312  if (!(psvbptr->iisdictlocked & 0x04)) {
313  psvbptr->ttranslast = ttransnumber + 1;
314  inl_stquad (ttransnumber + 1,
315  psvbptr->sdictnode.ctransnumber);
316  }
317  memset (cvbnodetmp, 0, VB_NODE_MAX);
318  memcpy ((void *)cvbnodetmp, (void *)&psvbptr->sdictnode,
319  sizeof (struct DICTNODE));
320  iresult = ivbblockwrite (ihandle, 1, (off_t) 1, cvbnodetmp);
321  if (iresult) {
322  iserrno = EBADFILE;
323  } else {
324  iserrno = 0;
325  }
326  }
327  tlength = VB_OFFLEN_3F;
328  if (ivblock (psvbptr->iindexhandle, (off_t)0, tlength, VBUNLOCK)) {
329  iserrno = errno;
330  return -1;
331  }
332  psvbptr->iisdictlocked = 0;
333  /* Free up any key/tree no longer wanted */
334  for (iloop2 = 0; iloop2 < psvbptr->inkeys; iloop2++) {
335  pskey = psvbptr->pskeycurr[iloop2];
336  /*
337  * This is a REAL fudge factor...
338  * We simply free up all the dynamically allocated memory
339  * associated with non-current nodes above a certain level.
340  * In other words, we wish to keep the CURRENT key and all data
341  * in memory above it for IVBBUFFERLEVEL levels.
342  * Anything *ABOVE* that in the tree is to be purged with
343  * EXTREME prejudice except for the 'current' tree up to the
344  * root.
345  */
346  for (iloop = 0; pskey && iloop < IVBBUFFERLEVEL; iloop++) {
347  if (pskey->psparent->psparent) {
348  pskey = pskey->psparent->psparent->pskeycurr;
349  } else {
350  pskey = NULL;
351  }
352  }
353  if (!pskey) {
354  iserrno = isaveerror;
355  return 0;
356  }
357  while (pskey) {
358  for (pskeycurr = pskey->psparent->pskeyfirst; pskeycurr;
359  pskeycurr = pskeycurr->psnext) {
360  if (pskeycurr != pskey && pskeycurr->pschild) {
361  vvbtreeallfree (ihandle, iloop2, pskeycurr->pschild);
362  pskeycurr->pschild = NULL;
363  }
364  }
365  if (pskey->psparent->psparent) {
366  pskey = pskey->psparent->psparent->pskeycurr;
367  } else {
368  pskey = NULL;
369  }
370  }
371  }
372  if (iresult) {
373  return -1;
374  }
375  iserrno = isaveerror;
376  return 0;
377 }
int ivblock(const int ihandle, const off_t toffset, const off_t tlength, const int imode)
Definition: vblowlevel.c:197
#define IVBBUFFERLEVEL
Definition: vblocking.c:22
int inkeys
Definition: isinternal.h:400
struct VBTREE * pschild
Definition: isinternal.h:327
int iindexhandle
Definition: isinternal.h:406
#define VB_NODE_MAX
Definition: isinternal.h:288
struct VBTREE * psparent
Definition: isinternal.h:326
struct VBKEY * pskeycurr
Definition: isinternal.h:342
unsigned char iisdictlocked
Definition: isinternal.h:427
off_t ttranslast
Definition: isinternal.h:419
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
struct DICTNODE sdictnode
Definition: isinternal.h:444
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define VB_OFFLEN_3F
Definition: isinternal.h:110
char ctransnumber[8]
Definition: isinternal.h:377
int iopenmode
Definition: isinternal.h:412
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
#define VBUNLOCK
Definition: isinternal.h:294
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
struct VBTREE * psparent
Definition: isinternal.h:339
static char * cvbnodetmp
Definition: ischeck.c:25
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
struct VBKEY * psnext
Definition: isinternal.h:324
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbfileopenlock ( const int  ihandle,
const int  imode 
)

Definition at line 380 of file vblocking.c.

References cvbnodetmp, DICTINFO::iindexhandle, ivbblockread(), ivblock(), ivbmaxusedhandle, psvbfile, DICTINFO::sdictnode, unlikely, VB_NODE_MAX, VB_OFFLEN_7F, VBRDLOCK, VBUNLOCK, and VBWRLOCK.

Referenced by ircvcreateindex(), ircvdeleteindex(), isbuild(), and isopen().

381 {
382  struct DICTINFO *psvbptr;
383  off_t toffset;
384  int ilocktype;
385 /* RXW
386  int iresult;
387 */
388  char cvbnodetmp[VB_NODE_MAX];
389 
390  /* Sanity check - Is ihandle a currently open table? */
391  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
392  return ENOTOPEN;
393  }
394  psvbptr = psvbfile[ihandle];
395  if (!psvbptr) {
396  return ENOTOPEN;
397  }
398 
399  toffset = VB_OFFLEN_7F;
400 
401  switch (imode) {
402  case 0:
403  ilocktype = VBUNLOCK;
404  break;
405 
406  case 1:
407  ilocktype = VBRDLOCK;
408  break;
409 
410  case 2:
411  ilocktype = VBWRLOCK;
412  break;
413 
414  default:
415  return EBADARG;
416  }
417  if (ivblock (psvbptr->iindexhandle, toffset, (off_t)1, ilocktype)) {
418  return EFLOCKED;
419  }
420  if (imode == 2) {
421  if (ivbblockread (ihandle, 1, (off_t) 1, cvbnodetmp)) {
422  (void)ivblock (psvbptr->iindexhandle, toffset, (off_t)1, VBUNLOCK);
423  return EBADFILE;
424  }
425  memcpy ((void *)&psvbptr->sdictnode, (void *)cvbnodetmp,
426  sizeof (struct DICTNODE));
427  }
428  return 0;
429 }
int ivblock(const int ihandle, const off_t toffset, const off_t tlength, const int imode)
Definition: vblowlevel.c:197
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
#define VBRDLOCK
Definition: isinternal.h:295
int iindexhandle
Definition: isinternal.h:406
#define VB_NODE_MAX
Definition: isinternal.h:288
#define unlikely(x)
Definition: common.h:437
struct DICTNODE sdictnode
Definition: isinternal.h:444
#define VB_OFFLEN_7F
Definition: isinternal.h:109
#define VBWRLOCK
Definition: isinternal.h:297
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbmaxusedhandle
Definition: vblocking.c:26
#define VBUNLOCK
Definition: isinternal.h:294
static char * cvbnodetmp
Definition: ischeck.c:25

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbforcedataallocate ( const int  ihandle,
const off_t  trownumber 
)

Definition at line 355 of file vbindexio.c.

References DICTNODE::cdatacount, DICTNODE::cdatafree, cvbnodetmp, DICTINFO::iisdictlocked, inl_ldint(), inl_ldquad(), inl_stint(), inl_stquad(), DICTINFO::inodesize, iserrno, ivbblockread(), ivbblockwrite(), ivbdatafree(), ivbnodefree(), psvbfile, QUADSIZE, and DICTINFO::sdictnode.

Referenced by ircvinsert(), and ivbrollmeback().

356 {
357  struct DICTINFO *psvbptr;
358  off_t theadnode, tprevnode, tnextnode;
359  int iloop, ilengthused;
360 
361  /* Sanity check - Is ihandle a currently open table? */
362  iserrno = ENOTOPEN;
363  psvbptr = psvbfile[ihandle];
364  if (!psvbptr) {
365  return -1;
366  }
367  iserrno = EBADARG;
368  if (!psvbptr->iisdictlocked) {
369  return -1;
370  }
371  iserrno = 0;
372 
373  /* Test 1: Is it already beyond EOF (the SIMPLE test) */
374  theadnode = inl_ldquad (psvbptr->sdictnode.cdatacount);
375  if (theadnode < trownumber) {
376  psvbptr->iisdictlocked |= 0x02;
378  theadnode++;
379  while (theadnode < trownumber) {
380  if (theadnode != 0) {
381  ivbdatafree (ihandle, theadnode);
382  }
383  theadnode++;
384  }
385  return 0;
386  }
387  /* <SIGH> It SHOULD be *SOMEWHERE* in the data free list! */
388  tprevnode = 0;
389  theadnode = inl_ldquad (psvbptr->sdictnode.cdatafree);
390  while (theadnode != 0) {
391  iserrno = ivbblockread (ihandle, 1, theadnode, cvbnodetmp);
392  if (iserrno) {
393  return -1;
394  }
395  iserrno = EBADFILE;
396 /* C-ISAM is not 100% C-ISAM compatible */
397 #if ISAMMODE == 1
398  if (cvbnodetmp[psvbptr->inodesize - 2] != 0x7f) {
399  return -1;
400  }
401 #endif
402  if (cvbnodetmp[psvbptr->inodesize - 3] != -1) {
403  return -1;
404  }
405  ilengthused = inl_ldint (cvbnodetmp);
406  for (iloop = INTSIZE + QUADSIZE; iloop < ilengthused; iloop += QUADSIZE) {
407  if (inl_ldquad (&cvbnodetmp[iloop]) == trownumber) { /* Extract it */
408  memcpy (&(cvbnodetmp[iloop]), &(cvbnodetmp[iloop + QUADSIZE]),
409  (size_t)(ilengthused - iloop));
410  ilengthused -= QUADSIZE;
411  if (ilengthused > INTSIZE + QUADSIZE) {
412  inl_stquad ((off_t)0, &cvbnodetmp[ilengthused]);
413  inl_stint (ilengthused, cvbnodetmp);
414  return ivbblockwrite (ihandle, 1, theadnode, cvbnodetmp);
415  } else { /* It was the last one in the node! */
416  tnextnode = inl_ldquad (&cvbnodetmp[INTSIZE]);
417  if (tprevnode) {
418  iserrno =
419  ivbblockread (ihandle, 1, tprevnode,
420  cvbnodetmp);
421  if (iserrno) {
422  return -1;
423  }
424  inl_stquad (tnextnode, &cvbnodetmp[INTSIZE]);
425  return ivbblockwrite
426  (ihandle, 1, tprevnode, cvbnodetmp);
427  } else {
428  psvbptr->iisdictlocked |= 0x02;
429  inl_stquad (tnextnode,
430  psvbptr->sdictnode.cdatafree);
431  }
432  return ivbnodefree (ihandle, theadnode);
433  }
434  }
435  }
436  tprevnode = theadnode;
437  theadnode = inl_ldquad (&cvbnodetmp[INTSIZE]);
438  }
439  /* If we get here, we've got a MAJOR integrity error in that the */
440  /* nominated row number was simply *NOT FREE* */
441  iserrno = EBADFILE;
442  return -1;
443 }
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
char cdatacount[8]
Definition: isinternal.h:375
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTNODE sdictnode
Definition: isinternal.h:444
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
static char cvbnodetmp[4096]
Definition: vbindexio.c:22
char cdatafree[8]
Definition: isinternal.h:373
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
off_t trownumber
Definition: isinternal.h:416
int ivbdatafree(const int ihandle, const off_t trownumber)
Definition: vbindexio.c:150
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402
int ivbnodefree(const int ihandle, const off_t tnodenumber)
Definition: vbindexio.c:67

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbforceexit ( const int  ihandle)

Definition at line 50 of file isopen.c.

References cvbnodetmp, DICTINFO::iisdictlocked, iserrno, ivbblockwrite(), psvbfile, DICTINFO::sdictnode, and VB_NODE_MAX.

Referenced by isclose().

51 {
52  struct DICTINFO *psvbptr;
53  int iresult = 0;
54  char cvbnodetmp[VB_NODE_MAX];
55 
56  psvbptr = psvbfile[ihandle];
57  if (psvbptr->iisdictlocked & 0x02) {
58  memset (cvbnodetmp, 0, VB_NODE_MAX);
59  memcpy ((void *)cvbnodetmp, (void *)&psvbptr->sdictnode,
60  sizeof (struct DICTNODE));
61  iresult = ivbblockwrite (ihandle, 1, (off_t) 1, cvbnodetmp);
62  if (iresult) {
63  iserrno = EBADFILE;
64  } else {
65  iserrno = 0;
66  }
67  }
68  psvbptr->iisdictlocked = 0;
69  if (iresult) {
70  return -1;
71  }
72  return 0;
73 }
#define VB_NODE_MAX
Definition: isinternal.h:288
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTNODE sdictnode
Definition: isinternal.h:444
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
static char * cvbnodetmp
Definition: ischeck.c:25
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbkeycompare ( const int  ihandle,
const int  ikeynumber,
int  ilength,
unsigned char *  pckey1,
unsigned char *  pckey2 
)

Definition at line 230 of file vbkeysio.c.

References inl_ldint(), inl_ldlong(), inl_ldquad(), lddbl(), ldfloat(), DICTINFO::pskeydesc, psvbfile, and QUADSIZE.

Referenced by ichecktree(), itreeload(), and ivbkeylocaterow().

232 {
233  struct keydesc *pskeydesc;
234  struct keypart *pskptr;
235  off_t tvalue1, tvalue2;
236  int idescbias, ipart, ilengthtocompare;
237  int ivalue1, ivalue2;
238  int n;
239  int lvalue1, lvalue2;
240  float fvalue1, fvalue2;
241  double dvalue1, dvalue2;
242 
243  pskeydesc = psvbfile[ihandle]->pskeydesc[ikeynumber];
244  if (ilength == 0) {
245  ilength = pskeydesc->k_len;
246  }
247  for (ipart = 0; ilength > 0 && ipart < pskeydesc->k_nparts; ipart++) {
248  pskptr = &pskeydesc->k_part[ipart];
249  if (ilength >= pskptr->kp_leng) {
250  ilengthtocompare = pskptr->kp_leng;
251  } else {
252  ilengthtocompare = ilength;
253  }
254  ilength -= ilengthtocompare;
255  if (pskptr->kp_type & ISDESC) {
256  idescbias = -1;
257  } else {
258  idescbias = 1;
259  }
260  switch (pskptr->kp_type & ~ISDESC) {
261  case CHARTYPE:
262 
263  n = memcmp (pckey1, pckey2, (size_t)ilengthtocompare);
264  if (n < 0) {
265  return -idescbias;
266  }
267  if (n > 0) {
268  return idescbias;
269  }
270  pckey1 += ilengthtocompare;
271  pckey2 += ilengthtocompare;
272 /*
273  while (ilengthtocompare--) {
274  if (*pckey1 < *pckey2) {
275  return -idescbias;
276  }
277  if (*pckey1++ > *pckey2++) {
278  return idescbias;
279  }
280  }
281 */
282  break;
283 
284  case INTTYPE:
285  while (ilengthtocompare >= INTSIZE) {
286  ivalue1 = inl_ldint (pckey1);
287  ivalue2 = inl_ldint (pckey2);
288  if (ivalue1 < ivalue2) {
289  return -idescbias;
290  }
291  if (ivalue1 > ivalue2) {
292  return idescbias;
293  }
294  pckey1 += INTSIZE;
295  pckey2 += INTSIZE;
296  ilengthtocompare -= INTSIZE;
297  }
298  break;
299 
300  case LONGTYPE:
301  while (ilengthtocompare >= LONGSIZE) {
302  lvalue1 = inl_ldlong (pckey1);
303  lvalue2 = inl_ldlong (pckey2);
304  if (lvalue1 < lvalue2) {
305  return -idescbias;
306  }
307  if (lvalue1 > lvalue2) {
308  return idescbias;
309  }
310  pckey1 += LONGSIZE;
311  pckey2 += LONGSIZE;
312  ilengthtocompare -= LONGSIZE;
313  }
314  break;
315 
316  case QUADTYPE:
317  while (ilengthtocompare >= QUADSIZE) {
318  tvalue1 = inl_ldquad (pckey1);
319  tvalue2 = inl_ldquad (pckey2);
320  if (tvalue1 < tvalue2) {
321  return -idescbias;
322  }
323  if (tvalue1 > tvalue2) {
324  return idescbias;
325  }
326  pckey1 += QUADSIZE;
327  pckey2 += QUADSIZE;
328  ilengthtocompare -= QUADSIZE;
329  }
330  break;
331 
332  case FLOATTYPE:
333  while (ilengthtocompare >= FLOATSIZE) {
334  fvalue1 = ldfloat (pckey1);
335  fvalue2 = ldfloat (pckey2);
336  if (fvalue1 < fvalue2) {
337  return -idescbias;
338  }
339  if (fvalue1 > fvalue2) {
340  return idescbias;
341  }
342  pckey1 += FLOATSIZE;
343  pckey2 += FLOATSIZE;
344  ilengthtocompare -= FLOATSIZE;
345  }
346  break;
347 
348  case DOUBLETYPE:
349  while (ilengthtocompare >= DOUBLESIZE) {
350  dvalue1 = lddbl (pckey1);
351  dvalue2 = lddbl (pckey2);
352  if (dvalue1 < dvalue2) {
353  return -idescbias;
354  }
355  if (dvalue1 > dvalue2) {
356  return idescbias;
357  }
358  pckey1 += DOUBLESIZE;
359  pckey2 += DOUBLESIZE;
360  ilengthtocompare -= DOUBLESIZE;
361  }
362  break;
363 
364  default:
365  break;
366  }
367  }
368  return 0;
369 }
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
double lddbl(void *pclocation)
Definition: ishelper.c:504
double ldfloat(void *pclocation)
Definition: ishelper.c:465
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
static int inl_ldlong(void *pclocation)
Definition: isinternal.h:209
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbkeydelete ( const int  ihandle,
const int  ikeynumber 
)

Definition at line 777 of file vbkeysio.c.

References VBKEY::iisdummy, VBTREE::iiseof, VBKEY::iishigh, VBTREE::iisroot, VBTREE::iistof, VBTREE::ikeysinnode, VBTREE::ilevel, ivbnodefree(), ivbnodeload(), ivbnodesave(), NULL, VBKEY::pschild, VBTREE::pskeycurr, DICTINFO::pskeycurr, DICTINFO::pskeydesc, VBTREE::pskeyfirst, VBTREE::pskeylist, VBKEY::psnext, VBKEY::psparent, VBTREE::psparent, VBKEY::psprev, DICTINFO::pstree, psvbfile, VBKEY::tdupnumber, VBTREE::tnodenumber, VBKEY::trownode, vvbkeyfree(), and vvbtreeallfree().

Referenced by irowdelete(), and irowupdate().

778 {
779  struct DICTINFO *psvbptr;
780  struct VBKEY *pskey, *pskeytemp;
781  struct VBTREE *pstree, *pstreeroot;
782  int iforcerewrite = 0, iposn, iresult;
783 
784  psvbptr = psvbfile[ihandle];
785  pskey = psvbptr->pskeycurr[ikeynumber];
786  /*
787  * We're going to *TRY* to keep the index buffer populated!
788  * However, since it's technically feasible for the current node to be
789  * removed in it's entirety, we can only do this if there is at least 1
790  * other key in the node that's not the dummy entry.
791  * Since the current key is guaranteed to be at the LEAF node level (0),
792  * it's impossible to ever have an iishigh entry in the node.
793  */
794  if (pskey->psnext && pskey->psnext->iisdummy == 0) {
795  psvbptr->pskeycurr[ikeynumber] = pskey->psnext;
796  pskey->psparent->pskeycurr = pskey->psnext;
797  } else {
798  if (pskey->psprev) {
799  psvbptr->pskeycurr[ikeynumber] = pskey->psprev;
800  pskey->psparent->pskeycurr = pskey->psprev;
801  } else {
802  psvbptr->pskeycurr[ikeynumber] = NULL;
803  pskey->psparent->pskeycurr = NULL;
804  }
805  }
806  while (1) {
807  pstree = pskey->psparent;
808  if (pskey->iishigh) {
809  /*
810  * Handle removal of the high key in a node.
811  * Since we're modifying a key OTHER than the one we're
812  * deleting, we need a FULL node rewrite!
813  */
814  if (pskey->psprev) {
815  pskey->pschild = pskey->psprev->pschild;
816  pskey->trownode = pskey->psprev->trownode;
817  pskey->tdupnumber = pskey->psprev->tdupnumber;
818  pskey = pskey->psprev;
819  iforcerewrite = 1;
820  } else {
821  iresult = ivbnodefree (ihandle, pstree->tnodenumber); /* BUG - didn't check iresult */
822  pstree = pstree->psparent;
823  vvbtreeallfree (ihandle, ikeynumber,
824  pstree->pskeycurr->pschild);
825  pskey = pstree->pskeycurr;
826  pskey->pschild = NULL;
827  continue;
828  }
829  }
830  iposn = -1;
831  pskey->psparent->ikeysinnode = 0;
832  for (pskeytemp = pskey->psparent->pskeyfirst; pskeytemp;
833  pskeytemp = pskeytemp->psnext) {
834  if (pskey == pskeytemp) {
835  iposn = pskey->psparent->ikeysinnode;
836  } else {
837  pskey->psparent->pskeylist[pskey->psparent->ikeysinnode] = pskeytemp;
838  pskey->psparent->ikeysinnode++;
839  }
840  }
841  if (pskey->psprev) {
842  pskey->psprev->psnext = pskey->psnext;
843  } else {
844  pstree->pskeyfirst = pskey->psnext;
845  }
846  if (pskey->psnext) {
847  pskey->psnext->psprev = pskey->psprev;
848  }
849  pskey->psparent = NULL;
850  pskey->pschild = NULL;
851  vvbkeyfree (ihandle, ikeynumber, pskey);
852  if (pstree->iisroot
853  && (pstree->pskeyfirst->iishigh
854  || pstree->pskeyfirst->iisdummy)) {
855  pskey = pstree->pskeyfirst;
856  if (!pskey->pschild) {
857  pstreeroot = pstree;
858  } else {
859  pstreeroot = pskey->pschild;
860  pskey->pschild = NULL;
861  }
862  if (pskey->iisdummy) { /* EMPTY FILE! */
863  return ivbnodesave (ihandle, ikeynumber, pstreeroot,
864  pstreeroot->tnodenumber, 0, 0);
865  }
866  iresult = ivbnodeload (ihandle, ikeynumber, pstreeroot, pskey->trownode,
867  (int)pstree->ilevel);
868  if (iresult) {
869  return iresult; /* BUG Corrupt! */
870  }
871  iresult = ivbnodefree (ihandle, pstreeroot->tnodenumber);
872  if (iresult) {
873  return iresult; /* BUG Corrupt! */
874  }
875  pstreeroot->tnodenumber =
876  psvbptr->pskeydesc[ikeynumber]->k_rootnode;
877  pstreeroot->psparent = NULL;
878  pstreeroot->iistof = 1;
879  pstreeroot->iiseof = 1;
880  pstreeroot->iisroot = 1;
881  if (pstree != pstreeroot) {
882  vvbtreeallfree (ihandle, ikeynumber, pstree);
883  }
884  psvbptr->pstree[ikeynumber] = pstreeroot;
885  return ivbnodesave (ihandle, ikeynumber, pstreeroot,
886  pstreeroot->tnodenumber, 0, 0);
887  }
888  if (pstree->pskeyfirst->iisdummy) {
889  /* Handle removal of the last key in a node */
890  iresult = ivbnodefree (ihandle, pstree->tnodenumber);
891  if (iresult) {
892  return iresult; /* BUG Corrupt! */
893  }
894  pstree = pstree->psparent;
895  vvbtreeallfree (ihandle, ikeynumber, pstree->pskeycurr->pschild);
896  pstree->pskeycurr->pschild = NULL;
897  pskey = pstree->pskeycurr;
898  continue;
899  }
900  break;
901  }
902  if (iforcerewrite) {
903  return ivbnodesave (ihandle, ikeynumber, pstree, pstree->tnodenumber, 0, 0);
904  }
905  return ivbnodesave (ihandle, ikeynumber, pstree, pstree->tnodenumber, -1, iposn);
906 }
unsigned char iishigh
Definition: isinternal.h:331
struct VBTREE * pschild
Definition: isinternal.h:327
unsigned char iisroot
Definition: isinternal.h:347
unsigned char iisdummy
Definition: isinternal.h:332
int ivbnodeload(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int iprevlvl)
Definition: vbnodememio.c:285
struct VBTREE * psparent
Definition: isinternal.h:326
struct VBKEY * pskeycurr
Definition: isinternal.h:342
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
off_t tnodenumber
Definition: isinternal.h:343
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
off_t trownode
Definition: isinternal.h:328
unsigned char iiseof
Definition: isinternal.h:349
int ivbnodesave(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int imode, const int iposn)
Definition: vbnodememio.c:416
unsigned int ikeysinnode
Definition: isinternal.h:346
void vvbkeyfree(const int ihandle, const int ikeynumber, struct VBKEY *pskey)
Definition: vbmemio.c:172
struct VBKEY * psprev
Definition: isinternal.h:325
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
off_t tdupnumber
Definition: isinternal.h:329
int ivbnodefree(const int ihandle, const off_t tnodenumber)
Definition: vbindexio.c:67
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
struct VBKEY * pskeylist[512]
Definition: isinternal.h:352
unsigned int ilevel
Definition: isinternal.h:345
struct VBTREE * pstree[32]
Definition: isinternal.h:446
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
struct VBTREE * psparent
Definition: isinternal.h:339
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
unsigned char iistof
Definition: isinternal.h:348
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbkeyinsert ( const int  ihandle,
struct VBTREE pstree,
const int  ikeynumber,
unsigned char *  pckeyvalue,
off_t  trownode,
off_t  tdupnumber,
struct VBTREE pschild 
)

Definition at line 727 of file vbkeysio.c.

References VBKEY::ckey, VBKEY::iisnew, VBTREE::ikeysinnode, ivbnodesave(), VBKEY::pschild, VBTREE::pskeycurr, DICTINFO::pskeycurr, DICTINFO::pskeydesc, VBTREE::pskeyfirst, VBTREE::pskeylist, VBKEY::psnext, VBKEY::psparent, VBKEY::psprev, psvbfile, psvbkeyallocate(), VBKEY::tdupnumber, VBTREE::tnodenumber, and VBKEY::trownode.

Referenced by imakekeysfromdata(), inodesplit(), irowinsert(), irowupdate(), and vaddkeyforrow().

730 {
731  struct DICTINFO *psvbptr;
732  struct VBKEY *pskey, *pstempkey;
733  int iposn = 0, iresult;
734 
735  psvbptr = psvbfile[ihandle];
736  pskey = psvbkeyallocate (ihandle, ikeynumber);
737  if (!pskey) {
738  return errno;
739  }
740  if (!psvbptr->pskeycurr[ikeynumber]) {
741  return EBADFILE;
742  }
743  if (!pstree) {
744  pstree = psvbptr->pskeycurr[ikeynumber]->psparent;
745  }
746  pskey->psparent = pstree;
747  pskey->pschild = pschild;
748  pskey->trownode = trownode;
749  pskey->tdupnumber = tdupnumber;
750  pskey->iisnew = 1;
751  memcpy (pskey->ckey, pckeyvalue, (size_t)psvbptr->pskeydesc[ikeynumber]->k_len);
752  pskey->psnext = pstree->pskeycurr;
753  pskey->psprev = pstree->pskeycurr->psprev;
754  if (pstree->pskeycurr->psprev) {
755  pstree->pskeycurr->psprev->psnext = pskey;
756  } else {
757  pstree->pskeyfirst = pskey;
758  }
759  pstree->pskeycurr->psprev = pskey;
760  pstree->pskeycurr = pskey;
761  psvbptr->pskeycurr[ikeynumber] = pskey;
762  pstree->ikeysinnode = 0;
763  for (pstempkey = pstree->pskeyfirst; pstempkey; pstempkey = pstempkey->psnext) {
764  if (pstempkey == pskey) {
765  iposn = pstree->ikeysinnode;
766  }
767  pstree->pskeylist[pstree->ikeysinnode] = pstempkey;
768  pstree->ikeysinnode++;
769  }
770  iresult = ivbnodesave (ihandle, ikeynumber, pskey->psparent,
771  pskey->psparent->tnodenumber, 1, iposn);
772  pskey->iisnew = 0;
773  return iresult;
774 }
struct VBTREE * pschild
Definition: isinternal.h:327
unsigned char ckey[1]
Definition: isinternal.h:334
struct VBKEY * psvbkeyallocate(const int ihandle, const int ikeynumber)
Definition: vbmemio.c:120
struct VBTREE * psparent
Definition: isinternal.h:326
struct VBKEY * pskeycurr
Definition: isinternal.h:342
off_t tnodenumber
Definition: isinternal.h:343
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
off_t trownode
Definition: isinternal.h:328
int ivbnodesave(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int imode, const int iposn)
Definition: vbnodememio.c:416
unsigned int ikeysinnode
Definition: isinternal.h:346
struct VBKEY * psprev
Definition: isinternal.h:325
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
off_t tdupnumber
Definition: isinternal.h:329
struct VBKEY * pskeylist[512]
Definition: isinternal.h:352
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
unsigned char iisnew
Definition: isinternal.h:330
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbkeyload ( const int  ihandle,
const int  ikeynumber,
const int  imode,
const int  isetcurr,
struct VBKEY **  ppskey 
)

Definition at line 503 of file vbkeysio.c.

References DICTINFO::iindexchanged, VBKEY::iisdummy, VBTREE::iiseof, VBTREE::iistof, VBTREE::ilevel, ivbnodeload(), NULL, VBKEY::pschild, VBTREE::pskeycurr, DICTINFO::pskeycurr, VBTREE::pskeyfirst, VBTREE::pskeylast, VBKEY::psnext, VBKEY::psparent, VBTREE::psparent, VBKEY::psprev, psvbfile, psvbtreeallocate(), VBKEY::trownode, and vvbtreeallfree().

Referenced by imakekeysfromdata(), irowinsert(), irowupdate(), isread(), isstart(), ivbkeylocaterow(), ivbkeysearch(), and vaddkeyforrow().

505 {
506  struct DICTINFO *psvbptr;
507  struct VBKEY *pskey, *pskeyhold;
508  struct VBTREE *pstree;
509  int iresult;
510 
511  psvbptr = psvbfile[ihandle];
512  pskey = psvbptr->pskeycurr[ikeynumber];
513  if (pskey->psparent->ilevel) {
514  return EBADFILE;
515  }
516  switch (imode) {
517  case ISPREV:
518  if (pskey->psprev) {
519  *ppskey = pskey->psprev;
520  if (isetcurr) {
521  psvbptr->pskeycurr[ikeynumber] = pskey->psprev;
522  pskey->psparent->pskeycurr = pskey->psprev;
523  }
524  return 0;
525  }
526  pstree = pskey->psparent;
527  if (pstree->iistof) {
528  return EENDFILE;
529  }
530  /* Back up the tree until we find a node where there is a < */
531  while (pstree->pskeycurr == pstree->pskeyfirst) {
532  if (pstree->psparent) {
533  pstree = pstree->psparent;
534  } else {
535  break;
536  }
537  }
538  /* Back down the tree selecting the LAST valid key of each */
539  pskey = pstree->pskeycurr->psprev;
540  if (isetcurr) {
541  pstree->pskeycurr = pstree->pskeycurr->psprev;
542  }
543  while (pstree->ilevel && pskey) {
544  if (isetcurr) {
545  pstree->pskeycurr = pskey;
546  }
547  if (!pskey->pschild || psvbptr->iindexchanged) {
548  if (!pskey->pschild) {
549  pskey->pschild = psvbtreeallocate (ihandle);
550  if (!pskey->pschild) {
551  return errno;
552  }
553  pskey->pschild->psparent = pskey->psparent;
554  if (pskey->psparent->iistof
555  && pskey == pskey->psparent->pskeyfirst) {
556  pskey->pschild->iistof = 1;
557  }
558  if (pskey->psparent->iiseof
559  && pskey == pskey->psparent->pskeylast->psprev) {
560  pskey->pschild->iiseof = 1;
561  }
562  }
563  pskeyhold = pskey;
564  iresult = ivbnodeload (ihandle, ikeynumber, pskey->pschild,
565  pskey->trownode, (int)pstree->ilevel);
566  if (iresult) {
567  /* Ooops, make sure the tree is not corrupt */
568  vvbtreeallfree (ihandle, ikeynumber,
569  pskeyhold->pschild);
570  pskeyhold->pschild = NULL;
571  return iresult;
572  }
573  }
574  pstree = pskey->pschild;
575  /* Last key is always the dummy, so backup by one */
576  pskey = pstree->pskeylast->psprev;
577  }
578  if (isetcurr) {
579  pstree->pskeycurr = pskey;
580  psvbptr->pskeycurr[ikeynumber] = pskey;
581  }
582  *ppskey = pskey;
583  break;
584 
585  case ISNEXT:
586  if (pskey->psnext && !pskey->psnext->iisdummy) {
587  *ppskey = pskey->psnext;
588  if (isetcurr) {
589  psvbptr->pskeycurr[ikeynumber] = pskey->psnext;
590  pskey->psparent->pskeycurr = pskey->psnext;
591  }
592  return 0;
593  }
594  pstree = pskey->psparent;
595  if (pstree->iiseof) {
596  return EENDFILE;
597  }
598  pstree = pstree->psparent;
599  /* Back up the tree until we find a node where there is a > */
600  while (1) {
601  if (pstree->pskeylast->psprev != pstree->pskeycurr) {
602  break;
603  }
604  pstree = pstree->psparent;
605  }
606  pskey = pstree->pskeycurr->psnext;
607  if (isetcurr) {
608  pstree->pskeycurr = pstree->pskeycurr->psnext;
609  }
610  /* Back down the tree selecting the FIRST valid key of each */
611  while (pstree->ilevel) {
612  if (isetcurr) {
613  pstree->pskeycurr = pskey;
614  }
615  if (!pskey->pschild || psvbptr->iindexchanged) {
616  if (!pskey->pschild) {
617  pskey->pschild = psvbtreeallocate (ihandle);
618  if (!pskey->pschild) {
619  return errno;
620  }
621  pskey->pschild->psparent = pskey->psparent;
622  if (pskey->psparent->iistof
623  && pskey == pskey->psparent->pskeyfirst) {
624  pskey->pschild->iistof = 1;
625  }
626  if (pskey->psparent->iiseof
627  && pskey == pskey->psparent->pskeylast->psprev) {
628  pskey->pschild->iiseof = 1;
629  }
630  }
631  pskeyhold = pskey;
632  iresult = ivbnodeload (ihandle, ikeynumber, pskey->pschild,
633  pskey->trownode, (int)pstree->ilevel);
634  if (iresult) {
635  /* Ooops, make sure the tree is not corrupt */
636  vvbtreeallfree (ihandle, ikeynumber,
637  pskeyhold->pschild);
638  pskeyhold->pschild = NULL;
639  return iresult;
640  }
641  }
642  pstree = pskey->pschild;
643  pskey = pstree->pskeyfirst;
644  }
645  if (isetcurr) {
646  pstree->pskeycurr = pskey;
647  psvbptr->pskeycurr[ikeynumber] = pskey;
648  }
649  *ppskey = pskey;
650  break;
651 
652  default:
653  break;
654  }
655  return 0;
656 }
struct VBTREE * psvbtreeallocate(const int ihandle)
Definition: vbmemio.c:88
unsigned char iindexchanged
Definition: isinternal.h:434
struct VBTREE * pschild
Definition: isinternal.h:327
struct VBKEY * pskeylast
Definition: isinternal.h:341
unsigned char iisdummy
Definition: isinternal.h:332
int ivbnodeload(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int iprevlvl)
Definition: vbnodememio.c:285
struct VBTREE * psparent
Definition: isinternal.h:326
struct VBKEY * pskeycurr
Definition: isinternal.h:342
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
off_t trownode
Definition: isinternal.h:328
unsigned char iiseof
Definition: isinternal.h:349
struct VBKEY * psprev
Definition: isinternal.h:325
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
unsigned int ilevel
Definition: isinternal.h:345
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
struct VBTREE * psparent
Definition: isinternal.h:339
unsigned char iistof
Definition: isinternal.h:348
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbkeylocaterow ( const int  ihandle,
const int  ikeynumber,
off_t  trownumber 
)

Definition at line 435 of file vbkeysio.c.

References VBKEY::ckey, iserrno, ivbkeycompare(), ivbkeyload(), ivbkeysearch(), DICTINFO::ppcrowbuffer, VBKEY::pschild, VBTREE::pskeycurr, DICTINFO::pskeycurr, DICTINFO::pskeydesc, VBTREE::pskeyfirst, VBKEY::psnext, VBKEY::psparent, VBTREE::psparent, psvbfile, VBKEY::trownode, and vvbmakekey().

Referenced by irowdelete(), irowupdate(), and isread().

436 {
437  struct DICTINFO *psvbptr;
438  struct VBKEY *pskey;
439  struct VBTREE *pstree;
440  int iresult;
441  unsigned char ckeyvalue[VB_MAX_KEYLEN];
442 
443  /*
444  * Step 1:
445  * The easy way out...
446  * If it is already the current index pointer *AND*
447  * the index file has remained unchanged since then,
448  * we don't need to do anything
449  */
450  psvbptr = psvbfile[ihandle];
451  iresult = 1;
452  pskey = psvbptr->pskeycurr[ikeynumber];
453  if (pskey && pskey->trownode == trownumber) {
454  pskey->psparent->pskeycurr = pskey;
455  /* Position pskeycurr all the way up to the root to point at us */
456  pstree = pskey->psparent;
457  while (pstree->psparent) {
458  for (pstree->psparent->pskeycurr = pstree->psparent->pskeyfirst;
459  pstree->psparent->pskeycurr
460  && pstree->psparent->pskeycurr->pschild != pstree;
461  pstree->psparent->pskeycurr =
462  pstree->psparent->pskeycurr->psnext) ;
463  if (!pstree->psparent->pskeycurr) {
464  iresult = 0;
465  }
466  pstree = pstree->psparent;
467  }
468  if (iresult) {
469  return 0;
470  }
471  }
472 
473  /*
474  * Step 2:
475  * It's a valid and non-deleted row. Therefore, let's make a
476  * contiguous key from it to search by.
477  * Find the damn key!
478  */
479  vvbmakekey (psvbptr->pskeydesc[ikeynumber], psvbptr->ppcrowbuffer, ckeyvalue);
480  iresult = ivbkeysearch (ihandle, ISGTEQ, ikeynumber, 0, ckeyvalue, (off_t)0);
481  if (iresult < 0 || iresult > 1) {
482  iserrno = ENOREC;
483  return -1;
484  }
485  while (psvbptr->pskeycurr[ikeynumber]->trownode != trownumber) {
486  iserrno = ivbkeyload (ihandle, ikeynumber, ISNEXT, 1, &pskey);
487  if (iserrno) {
488  if (iserrno == EENDFILE) {
489  iserrno = ENOREC;
490  }
491  return -1;
492  }
493  if (ivbkeycompare (ihandle, ikeynumber, 0, ckeyvalue,
494  psvbptr->pskeycurr[ikeynumber]->ckey)) {
495  iserrno = ENOREC;
496  return -1;
497  }
498  }
499  return 0;
500 }
void vvbmakekey(const struct keydesc *pskeydesc, char *pcrow_buffer, unsigned char *pckeyvalue)
Definition: vbkeysio.c:212
int ivbkeyload(const int ihandle, const int ikeynumber, const int imode, const int isetcurr, struct VBKEY **ppskey)
Definition: vbkeysio.c:503
int ivbkeycompare(const int ihandle, const int ikeynumber, int ilength, unsigned char *pckey1, unsigned char *pckey2)
Definition: vbkeysio.c:230
struct VBTREE * pschild
Definition: isinternal.h:327
unsigned char ckey[1]
Definition: isinternal.h:334
int ivbkeysearch(const int ihandle, const int imode, const int ikeynumber, int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
Definition: vbkeysio.c:372
struct VBTREE * psparent
Definition: isinternal.h:326
struct VBKEY * pskeycurr
Definition: isinternal.h:342
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
off_t trownode
Definition: isinternal.h:328
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
struct VBTREE * psparent
Definition: isinternal.h:339
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
struct VBKEY * psnext
Definition: isinternal.h:324
char * ppcrowbuffer
Definition: isinternal.h:423
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbkeysearch ( const int  ihandle,
const int  imode,
const int  ikeynumber,
int  ilength,
unsigned char *  pckeyvalue,
off_t  tdupnumber 
)

Definition at line 372 of file vbkeysio.c.

References iserrno, itreeload(), ivbkeyload(), DICTINFO::pskeydesc, psvbfile, VB_MAX_OFF_T, and vvbkeyvalueset().

Referenced by imakekeysfromdata(), irowinsert(), irowupdate(), isdelete(), isread(), isrewrite(), isstart(), ivbkeylocaterow(), and vaddkeyforrow().

374 {
375  struct VBKEY *pskey;
376  struct keydesc *pskeydesc;
377  int iresult;
378  unsigned char ckeyvalue[VB_MAX_KEYLEN];
379 
380  pskeydesc = psvbfile[ihandle]->pskeydesc[ikeynumber];
381  if (ilength == 0) {
382  ilength = pskeydesc->k_len;
383  }
384  switch (imode) {
385  case ISFIRST:
386  vvbkeyvalueset (0, pskeydesc, ckeyvalue);
387  tdupnumber = -1;
388  return itreeload (ihandle, ikeynumber, ilength, ckeyvalue, tdupnumber);
389 
390  case ISLAST:
391  vvbkeyvalueset (1, pskeydesc, ckeyvalue);
392  tdupnumber = VB_MAX_OFF_T;
393  return itreeload (ihandle, ikeynumber, ilength, ckeyvalue, tdupnumber);
394 
395  case ISNEXT:
396  iresult = ivbkeyload (ihandle, ikeynumber, ISNEXT, 1, &pskey);
397  iserrno = iresult;
398  if (iresult == EENDFILE) {
399  iresult = 0;
400  }
401  if (iresult) {
402  return -1;
403  }
404  return 1; /* "NEXT" can NEVER be an exact match! */
405 
406  case ISPREV:
407  iresult = ivbkeyload (ihandle, ikeynumber, ISPREV, 1, &pskey);
408  iserrno = iresult;
409  if (iresult == EENDFILE) {
410  iresult = 0;
411  }
412  if (iresult) {
413  return -1;
414  }
415  return 1; /* "PREV" can NEVER be an exact match */
416 
417  case ISCURR:
418  return itreeload (ihandle, ikeynumber, ilength, pckeyvalue, tdupnumber);
419 
420  case ISEQUAL: /* Falls thru to ISGTEQ */
421  tdupnumber = 0;
422  case ISGTEQ:
423  return itreeload (ihandle, ikeynumber, ilength, pckeyvalue, tdupnumber);
424 
425  case ISGREAT:
426  tdupnumber = VB_MAX_OFF_T;
427  return itreeload (ihandle, ikeynumber, ilength, pckeyvalue, tdupnumber);
428 
429  }
430  /* From call sites, not possible */
431  return -1;
432 }
#define VB_MAX_OFF_T
Definition: vbkeysio.c:23
int ivbkeyload(const int ihandle, const int ikeynumber, const int imode, const int isetcurr, struct VBKEY **ppskey)
Definition: vbkeysio.c:503
static int itreeload(const int ihandle, const int ikeynumber, const int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
Definition: vbkeysio.c:31
void vvbkeyvalueset(const int ihigh, struct keydesc *pskeydesc, unsigned char *pckeyvalue)
Definition: vbkeysio.c:659
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivblock ( const int  ihandle,
const off_t  toffset,
const off_t  tlength,
const int  imode 
)

Definition at line 197 of file vblowlevel.c.

References svbfile, VBRDLCKW, VBRDLOCK, VBUNLOCK, VBWRLCKW, and VBWRLOCK.

Referenced by ivbdatalock(), ivbenter(), ivbexit(), ivbfileopenlock(), and iwritetrans().

198 {
199 #ifdef _WIN32
200 #ifdef USE_LOCKFILE_EX
201 
202  OVERLAPPED toverlapped;
203  DWORD tflags = 0;
204  DWORD winerrno = 0;
205  int bunlock = 0;
206 
207  if (!svbfile[ihandle].irefcount) {
208  errno = ENOENT;
209  return -1;
210  }
211 
212  switch (imode) {
213  case VBUNLOCK:
214  bunlock = 1;
215  break;
216 
217  case VBRDLOCK:
218  tflags = LOCKFILE_FAIL_IMMEDIATELY;
219  break;
220 
221  case VBRDLCKW:
222  tflags = 0;
223  break;
224 
225  case VBWRLOCK:
226  tflags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY;
227  break;
228 
229  case VBWRLCKW:
230  tflags = LOCKFILE_EXCLUSIVE_LOCK;
231  break;
232 
233  default:
234  errno = EBADARG;
235  return -1;
236  }
237 
238  memset (&toverlapped, 0, sizeof(OVERLAPPED));
239  toverlapped.Offset = (DWORD)(toffset & 0xffffffff);
240  toverlapped.OffsetHigh = (DWORD)(toffset >> 32);
241  errno = 0;
242  if (!bunlock) {
243  if (LockFileEx (svbfile[ihandle].whandle, tflags, 0, (int)(tlength & 0xffffffff),
244  (int)(tlength >> 32), &toverlapped)) {
245  return 0;
246  }
247  } else {
248  if (UnlockFileEx (svbfile[ihandle].whandle, 0, (int)(tlength & 0xffffffff),
249  (int)(tlength >> 32), &toverlapped)) {
250  return 0;
251  }
252  winerrno = GetLastError ();
253  if (winerrno == ERROR_NOT_LOCKED) {
254  //ALREADY UNLOCKED **SAME FCNTL**
255  return 0;
256  }
257  }
258 
259  errno = EBADARG;
260  return -1;
261 #else
262 /* This will probably not work correctly - 64 bit */
263  int itype, iresult = -1;
264  off_t soffset;
265  off_t tempoffset;
266 
267  if (!svbfile[ihandle].irefcount) {
268  errno = ENOENT;
269  return -1;
270  }
271  switch (imode) {
272  case VBUNLOCK:
273  itype = _LK_UNLCK;
274  break;
275 
276  case VBRDLOCK:
277  itype = _LK_NBRLCK;
278  break;
279 
280  case VBRDLCKW:
281  itype = _LK_RLCK;
282  break;
283 
284  case VBWRLOCK:
285  itype = _LK_NBLCK;
286  break;
287 
288  case VBWRLCKW:
289  itype = _LK_LOCK;
290  break;
291 
292  default:
293  errno = EBADARG;
294  return -1;
295  }
296  soffset = lseek (svbfile[ihandle].ihandle, 0, SEEK_CUR);
297  if (soffset == -1) {
298  errno = 172;
299  return -1;
300  }
301  tempoffset = lseek (svbfile[ihandle].ihandle, toffset, SEEK_SET);
302  if (tempoffset == -1) {
303  errno = 172;
304  return -1;
305  }
306  errno = 0;
307  iresult = _locking (svbfile[ihandle].ihandle, itype, (long)tlength);
308  /* Something weird going on here */
309  if (errno == 22) {
310  errno = 0;
311  iresult = 0;
312  }
313  lseek (svbfile[ihandle].ihandle, soffset, SEEK_SET);
314  return iresult;
315 #endif
316 #else
317  int icommand, itype, iresult;
318  struct flock sflock;
319 
320  if (!svbfile[ihandle].irefcount) {
321  errno = ENOENT;
322  return -1;
323  }
324  switch (imode) {
325  case VBUNLOCK:
326  icommand = F_SETLK;
327  itype = F_UNLCK;
328  break;
329 
330  case VBRDLOCK:
331  icommand = F_SETLK;
332  itype = F_RDLCK;
333  break;
334 
335  case VBRDLCKW:
336  icommand = F_SETLKW;
337  itype = F_RDLCK;
338  break;
339 
340  case VBWRLOCK:
341  icommand = F_SETLK;
342  itype = F_WRLCK;
343  break;
344 
345  case VBWRLCKW:
346  icommand = F_SETLKW;
347  itype = F_WRLCK;
348  break;
349 
350  default:
351  errno = EBADARG;
352  return -1;
353  }
354  sflock.l_type = itype;
355  sflock.l_whence = SEEK_SET;
356  sflock.l_start = toffset;
357  sflock.l_len = tlength;
358  sflock.l_pid = 0;
359  do {
360  iresult = fcntl (svbfile[ihandle].ihandle, icommand, &sflock);
361  } while (iresult && errno == EINTR);
362 
363  return iresult;
364 #endif
365 }
#define VBRDLOCK
Definition: isinternal.h:295
#define VBWRLCKW
Definition: isinternal.h:298
#define VBWRLOCK
Definition: isinternal.h:297
#define VBRDLCKW
Definition: isinternal.h:296
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24
#define VBUNLOCK
Definition: isinternal.h:294

Here is the caller graph for this function:

int ivbnodefree ( const int  ihandle,
const off_t  tnodenumber 
)

Definition at line 67 of file vbindexio.c.

References DICTNODE::cnodefree, cvbnodetmp, DICTINFO::iisdictlocked, inl_ldint(), inl_ldquad(), inl_stint(), inl_stquad(), DICTINFO::inodesize, iserrno, ivbblockread(), ivbblockwrite(), psvbfile, QUADSIZE, DICTINFO::sdictnode, and VB_NODE_MAX.

Referenced by idelnodes(), ivbforcedataallocate(), ivbkeydelete(), ivbvarlendelete(), tvbdataallocate(), and vrebuildindexfree().

68 {
69  struct DICTINFO *psvbptr;
70  off_t theadnode;
71  int ilengthused, iresult;
72  char cvbnodetmp2[VB_NODE_MAX];
73 
74  /* Sanity check - Is ihandle a currently open table? */
75  iserrno = ENOTOPEN;
76  psvbptr = psvbfile[ihandle];
77  if (!psvbptr) {
78  return -1;
79  }
80  iserrno = EBADARG;
81  if (!psvbptr->iisdictlocked) {
82  return -1;
83  }
84  iserrno = 0;
85 
86  memset (cvbnodetmp2, 0, (size_t) psvbptr->inodesize);
87  inl_stint (INTSIZE, cvbnodetmp2);
88 
89  theadnode = inl_ldquad (psvbptr->sdictnode.cnodefree);
90  /* If the list is empty, node tnodenumber becomes the whole list */
91  if (theadnode == 0) {
92  inl_stint (INTSIZE + QUADSIZE, cvbnodetmp2);
93  inl_stquad ((off_t)0, cvbnodetmp2 + INTSIZE);
94  cvbnodetmp2[psvbptr->inodesize - 2] = 0x7f;
95  cvbnodetmp2[psvbptr->inodesize - 3] = -2;
96  iresult = ivbblockwrite (ihandle, 1, tnodenumber, cvbnodetmp2);
97  if (iresult) {
98  return iresult;
99  }
100  inl_stquad (tnodenumber, psvbptr->sdictnode.cnodefree);
101  psvbptr->iisdictlocked |= 0x02;
102  return 0;
103  }
104 
105  /* Read in the head of the current free list */
106  iresult = ivbblockread (ihandle, 1, theadnode, cvbnodetmp);
107  if (iresult) {
108  return iresult;
109  }
110 /* C-ISAM is not 100% C-ISAM compatible */
111 #if ISAMMODE == 1
112  if (cvbnodetmp[psvbptr->inodesize - 2] != 0x7f) {
113  return EBADFILE;
114  }
115 #endif
116  if (cvbnodetmp[psvbptr->inodesize - 3] != -2) {
117  return EBADFILE;
118  }
119  ilengthused = inl_ldint (cvbnodetmp);
120  if (ilengthused >= psvbptr->inodesize - (QUADSIZE + 3)) {
121  /* If there was no space left, tnodenumber becomes the head */
122  cvbnodetmp2[psvbptr->inodesize - 2] = 0x7f;
123  cvbnodetmp2[psvbptr->inodesize - 3] = -2;
124  inl_stint (INTSIZE + QUADSIZE, cvbnodetmp2);
125  inl_stquad (theadnode, &cvbnodetmp2[INTSIZE]);
126  iresult = ivbblockwrite (ihandle, 1, tnodenumber, cvbnodetmp2);
127  if (!iresult) {
128  inl_stquad (tnodenumber, psvbptr->sdictnode.cnodefree);
129  psvbptr->iisdictlocked |= 0x02;
130  }
131  return iresult;
132  }
133 
134  /* If we got here, there's space left in the theadnode to store it */
135  cvbnodetmp2[psvbptr->inodesize - 2] = 0x7f;
136  cvbnodetmp2[psvbptr->inodesize - 3] = -2;
137  iresult = ivbblockwrite (ihandle, 1, tnodenumber, cvbnodetmp2);
138  if (iresult) {
139  return iresult;
140  }
141  inl_stquad (tnodenumber, &cvbnodetmp[ilengthused]);
142  ilengthused += QUADSIZE;
143  inl_stint (ilengthused, cvbnodetmp);
144  iresult = ivbblockwrite (ihandle, 1, theadnode, cvbnodetmp);
145 
146  return iresult;
147 }
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
#define VB_NODE_MAX
Definition: isinternal.h:288
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTNODE sdictnode
Definition: isinternal.h:444
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
static char cvbnodetmp[4096]
Definition: vbindexio.c:22
char cnodefree[8]
Definition: isinternal.h:374
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbnodeload ( const int  ihandle,
const int  ikeynumber,
struct VBTREE pstree,
const off_t  tnodenumber,
const int  iprevlvl 
)

Definition at line 285 of file vbnodememio.c.

References VBKEY::ckey, cvbnodetmp, VBKEY::iisdummy, VBKEY::iishigh, VBTREE::ikeysinnode, VBTREE::ilevel, inl_ldint(), inl_ldquad(), DICTINFO::inodesize, ivbblockread(), NULL, VBKEY::pschild, VBTREE::pskeycurr, DICTINFO::pskeydesc, VBTREE::pskeyfirst, VBTREE::pskeylast, VBTREE::pskeylist, VBKEY::psnext, VBKEY::psparent, VBKEY::psprev, psvbfile, psvbkeyallocate(), QUADSIZE, TCC, VBKEY::tdupnumber, VBTREE::tnodenumber, VBKEY::trownode, VBTREE::ttransnumber, vvbkeyfree(), vvbkeyvalueset(), and vvbtreeallfree().

Referenced by ichecktree(), itreeload(), ivbkeydelete(), and ivbkeyload().

287 {
288  struct DICTINFO *psvbptr;
289  struct VBKEY *pskey, *pskeynext;
290  struct keydesc *pskeydesc;
291  char *pcnodeptr;
292 #if ISAMMODE == 1
293  off_t ttransnumber;
294 #endif
295  int icountlc = 0; /* Leading compression */
296  int icounttc = 0; /* Trailing compression */
297  int idups = 0, inodelen, iresult;
298  unsigned char cprevkey[VB_MAX_KEYLEN];
299  unsigned char chighkey[VB_MAX_KEYLEN];
300 
301  psvbptr = psvbfile[ihandle];
302  pskeydesc = psvbptr->pskeydesc[ikeynumber];
303  vvbkeyvalueset (0, pskeydesc, cprevkey);
304  vvbkeyvalueset (1, pskeydesc, chighkey);
305  iresult = ivbblockread (ihandle, 1, tnodenumber, cvbnodetmp);
306  if (iresult) {
307  return iresult;
308  }
309  if (iprevlvl != -1) {
310  if (*(cvbnodetmp + psvbptr->inodesize - 2) != iprevlvl - 1) {
311  return EBADFILE;
312  }
313  }
314  pstree->tnodenumber = tnodenumber;
315  pstree->ilevel = *(cvbnodetmp + psvbptr->inodesize - 2);
316  inodelen = inl_ldint (cvbnodetmp);
317 #if ISAMMODE == 1
318  pcnodeptr = cvbnodetmp + INTSIZE + QUADSIZE;
319  ttransnumber = inl_ldquad (cvbnodetmp + INTSIZE);
320  if (ttransnumber == pstree->ttransnumber) {
321  return 0;
322  }
323 #else
324  pcnodeptr = cvbnodetmp + INTSIZE;
325 #endif
326  for (pskey = pstree->pskeyfirst; pskey; pskey = pskeynext) {
327  if (pskey->pschild) {
328  vvbtreeallfree (ihandle, ikeynumber, pskey->pschild);
329  }
330  pskey->pschild = NULL;
331  pskeynext = pskey->psnext;
332  vvbkeyfree (ihandle, ikeynumber, pskey);
333  }
334  pstree->pskeyfirst = pstree->pskeycurr = pstree->pskeylast = NULL;
335  pstree->ikeysinnode = 0;
336  while (pcnodeptr - cvbnodetmp < inodelen) {
337  pskey = psvbkeyallocate (ihandle, ikeynumber);
338  if (!pskey) {
339  return errno;
340  }
341  if (!idups) {
342  if (pskeydesc->k_flags & LCOMPRESS) {
343 #if ISAMMODE == 1
344  icountlc = inl_ldint (pcnodeptr);
345  pcnodeptr += INTSIZE;
346 #else
347  icountlc = *(pcnodeptr);
348  pcnodeptr++;
349 #endif
350  }
351  if (pskeydesc->k_flags & TCOMPRESS) {
352 #if ISAMMODE == 1
353  icounttc = inl_ldint (pcnodeptr);
354  pcnodeptr += INTSIZE;
355 #else
356  icounttc = *(pcnodeptr);
357  pcnodeptr++;
358 #endif
359  }
360  memcpy (cprevkey + icountlc, pcnodeptr,
361  (size_t)(pskeydesc->k_len - (icountlc + icounttc)));
362  memset (cprevkey + pskeydesc->k_len - icounttc, TCC, (size_t)icounttc);
363  pcnodeptr += pskeydesc->k_len - (icountlc + icounttc);
364  }
365  if (pskeydesc->k_flags & ISDUPS) {
366  pskey->tdupnumber = inl_ldquad (pcnodeptr);
367  pcnodeptr += QUADSIZE;
368  } else {
369  pskey->tdupnumber = 0;
370  }
371  if (pskeydesc->k_flags & DCOMPRESS) {
372  if (*pcnodeptr & 0x80) {
373  idups = 1;
374  } else {
375  idups = 0;
376  }
377  *pcnodeptr &= ~0x80;
378  }
379  pskey->trownode = inl_ldquad (pcnodeptr);
380  pcnodeptr += QUADSIZE;
381  pskey->psparent = pstree;
382  if (pstree->pskeyfirst) {
383  pstree->pskeylast->psnext = pskey;
384  } else {
385  pstree->pskeyfirst = pstree->pskeycurr = pskey;
386  }
387  pstree->pskeylist[pstree->ikeysinnode] = pskey;
388  pstree->ikeysinnode++;
389  pskey->psprev = pstree->pskeylast;
390  pstree->pskeylast = pskey;
391  memcpy (pskey->ckey, cprevkey, (size_t)pskeydesc->k_len);
392  }
393  if (pstree->ilevel) {
394  pstree->pskeylast->iishigh = 1;
395  memcpy (pstree->pskeylast->ckey, chighkey, (size_t)pskeydesc->k_len);
396  }
397  pskey = psvbkeyallocate (ihandle, ikeynumber);
398  if (!pskey) {
399  return errno;
400  }
401  pskey->psparent = pstree;
402  pskey->iisdummy = 1;
403  if (pstree->pskeyfirst) {
404  pstree->pskeylast->psnext = pskey;
405  } else {
406  pstree->pskeyfirst = pstree->pskeycurr = pskey;
407  }
408  pskey->psprev = pstree->pskeylast;
409  pstree->pskeylast = pskey;
410  pstree->pskeylist[pstree->ikeysinnode] = pskey;
411  pstree->ikeysinnode++;
412  return 0;
413 }
unsigned char iishigh
Definition: isinternal.h:331
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
static char cvbnodetmp[4096]
Definition: vbnodememio.c:24
void vvbkeyvalueset(const int ihigh, struct keydesc *pskeydesc, unsigned char *pckeyvalue)
Definition: vbkeysio.c:659
struct VBTREE * pschild
Definition: isinternal.h:327
struct VBKEY * pskeylast
Definition: isinternal.h:341
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
unsigned char ckey[1]
Definition: isinternal.h:334
struct VBKEY * psvbkeyallocate(const int ihandle, const int ikeynumber)
Definition: vbmemio.c:120
unsigned char iisdummy
Definition: isinternal.h:332
struct VBTREE * psparent
Definition: isinternal.h:326
struct VBKEY * pskeycurr
Definition: isinternal.h:342
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
off_t tnodenumber
Definition: isinternal.h:343
off_t ttransnumber
Definition: isinternal.h:344
off_t trownode
Definition: isinternal.h:328
#define TCC
Definition: vbnodememio.c:22
unsigned int ikeysinnode
Definition: isinternal.h:346
void vvbkeyfree(const int ihandle, const int ikeynumber, struct VBKEY *pskey)
Definition: vbmemio.c:172
struct VBKEY * psprev
Definition: isinternal.h:325
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
off_t tdupnumber
Definition: isinternal.h:329
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
struct VBKEY * pskeylist[512]
Definition: isinternal.h:352
unsigned int ilevel
Definition: isinternal.h:345
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
struct VBKEY * psnext
Definition: isinternal.h:324
int inodesize
Definition: isinternal.h:402

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbnodesave ( const int  ihandle,
const int  ikeynumber,
struct VBTREE pstree,
const off_t  tnodenumber,
const int  imode,
const int  iposn 
)

Definition at line 416 of file vbnodememio.c.

References VBKEY::ckey, DICTNODE::ctransnumber, cvbnodetmp, VBKEY::iisdummy, VBKEY::iishigh, VBKEY::iisnew, VBTREE::ikeysinnode, VBTREE::ilevel, inl_ldquad(), inl_stint(), inl_stquad(), DICTINFO::inodesize, inodesplit(), iquicknodesave(), ivbblockwrite(), NULL, DICTINFO::pskeydesc, VBTREE::pskeyfirst, VBTREE::pskeylast, VBTREE::pskeylist, VBKEY::psnext, VBKEY::psprev, psvbfile, QUADSIZE, DICTINFO::sdictnode, TCC, VBKEY::tdupnumber, VBKEY::trownode, and VB_NODE_MAX.

Referenced by inewroot(), inodesplit(), ivbkeydelete(), and ivbkeyinsert().

418 {
419  struct DICTINFO *psvbptr;
420  unsigned char *pckeyendptr, *pcnodeptr, *pcnodehalfway;
421  unsigned char *pcnodeend, *pcprevkey = NULL;
422  struct VBKEY *pskey, *pskeyhalfway = NULL;
423  struct keydesc *pskeydesc;
424  int icountlc = 0, /* Leading compression */
425  icounttc = 0, /* Trailing compression */
426  ilasttc = 0, ikeylen, imaxtc, iresult;
427 
428  psvbptr = psvbfile[ihandle];
429  pskeydesc = psvbptr->pskeydesc[ikeynumber];
430  /*
431  * If it's an INSERT into a node or a DELETE from a node
432  * *AND*
433  * there's no compression
434  * *THEN*
435  * We can *TRY* to do a quick and dirty insertion / deletion instead!
436  * However, it's still possible that we have insufficient free space
437  * so we *MAY* still need to continue.
438  */
439  if (pstree->ilevel) {
440  if (pstree->pskeylast->psprev) {
441  pstree->pskeylast->psprev->iishigh = 1;
442  }
443  }
444  if (imode && !(pskeydesc->k_flags & (DCOMPRESS | TCOMPRESS | LCOMPRESS))) {
445  if (iquicknodesave (ihandle, pstree, tnodenumber, pskeydesc, imode, iposn) == 0) {
446  return 0;
447  }
448  }
449  pcnodehalfway = (ucharptr)cvbnodetmp + (psvbptr->inodesize / 2);
450  pcnodeend = (ucharptr)cvbnodetmp + psvbptr->inodesize - 2;
451  memset (cvbnodetmp, 0, VB_NODE_MAX);
452 #if ISAMMODE == 1
454  cvbnodetmp + INTSIZE);
455  pcnodeptr = (ucharptr)cvbnodetmp + INTSIZE + QUADSIZE;
456 #else
457  pcnodeptr = (ucharptr)cvbnodetmp + INTSIZE;
458 #endif
459  *pcnodeend = pstree->ilevel;
460  pstree->ikeysinnode = 0;
461  for (pskey = pstree->pskeyfirst; pskey && !pskey->iisdummy;
462  pskey = pskey->psnext) {
463  pstree->pskeylist[pstree->ikeysinnode] = pskey;
464  pstree->ikeysinnode++;
465  if (!pskeyhalfway) {
466  if (pcnodeptr >= pcnodehalfway) {
467  pskeyhalfway = pskey->psprev;
468  }
469  }
470  ikeylen = pskeydesc->k_len;
471  if (pskeydesc->k_flags & TCOMPRESS) {
472  ilasttc = icounttc;
473  icounttc = 0;
474  pckeyendptr = pskey->ckey + ikeylen - 1;
475  while (*pckeyendptr-- == TCC && pckeyendptr != pskey->ckey) {
476  icounttc++;
477  }
478 #if ISAMMODE == 1
479  ikeylen += INTSIZE - icounttc;
480 #else
481  ikeylen += 1 - icounttc;
482 #endif
483  }
484  if (pskeydesc->k_flags & LCOMPRESS) {
485  icountlc = 0;
486  if (pskey != pstree->pskeyfirst) {
487  imaxtc = pskeydesc->k_len - (icounttc >
488  ilasttc ? icounttc : ilasttc);
489  for (; pskey->ckey[icountlc] == pcprevkey[icountlc]
490  && icountlc < imaxtc; icountlc++) ;
491  }
492 #if ISAMMODE == 1
493  ikeylen += INTSIZE - icountlc;
494 #else
495  ikeylen += 1 - icountlc;
496 #endif
497  if (pskey->iishigh && pskeydesc->k_flags && LCOMPRESS) {
498  icountlc = pskeydesc->k_len;
499  icounttc = 0;
500 #if ISAMMODE == 1
501  if (pskeydesc->k_flags && TCOMPRESS) {
502  ikeylen = INTSIZE * 2;
503  } else {
504  ikeylen = INTSIZE;
505  }
506 #else
507  if (pskeydesc->k_flags && TCOMPRESS) {
508  ikeylen = 2;
509  } else {
510  ikeylen = 1;
511  }
512 #endif
513  if (pskeydesc->k_flags & DCOMPRESS) {
514  ikeylen = 0;
515  }
516  }
517  }
518  if (pskeydesc->k_flags & ISDUPS) {
519  ikeylen += QUADSIZE;
520  /* If the key is a duplicate and it's not first in node */
521  if (pskey->iishigh || (pskey != pstree->pskeyfirst
522  && !memcmp (pskey->ckey, pcprevkey, (size_t)pskeydesc->k_len))) {
523  if (pskeydesc->k_flags & DCOMPRESS) {
524  ikeylen = QUADSIZE;
525  }
526  }
527  }
528  ikeylen += QUADSIZE;
529  /* Split? */
530  if (pcnodeptr + ikeylen >= pcnodeend - 1) {
531  if (pstree->pskeylast->psprev->iisnew) {
532  pskeyhalfway = pstree->pskeylast->psprev->psprev;
533  }
534  if (pstree->pskeylast->psprev->iishigh
535  && pstree->pskeylast->psprev->psprev->iisnew) {
536  pskeyhalfway = pstree->pskeylast->psprev->psprev->psprev;
537  }
538  iresult = inodesplit (ihandle, ikeynumber, pstree, pskeyhalfway);
539  return iresult;
540  }
541  if (((ikeylen == (QUADSIZE * 2))
542  && ((pskeydesc->k_flags & (DCOMPRESS | ISDUPS)) == (DCOMPRESS | ISDUPS)))
543  || (pskeydesc->k_flags & DCOMPRESS && !(pskeydesc->k_flags & ISDUPS)
544  && ikeylen == QUADSIZE)) {
545  *(pcnodeptr - QUADSIZE) |= 0x80;
546  } else {
547  if (pskeydesc->k_flags & LCOMPRESS) {
548 #if ISAMMODE == 1
549  inl_stint (icountlc, pcnodeptr);
550  pcnodeptr += INTSIZE;
551 #else
552  *pcnodeptr++ = icountlc;
553 #endif
554  }
555  if (pskeydesc->k_flags & TCOMPRESS) {
556 #if ISAMMODE == 1
557  inl_stint (icounttc, pcnodeptr);
558  pcnodeptr += INTSIZE;
559 #else
560  *pcnodeptr++ = icounttc;
561 #endif
562  }
563  if (icountlc != pskeydesc->k_len) {
564  pcprevkey = pskey->ckey + icountlc;
565  imaxtc = pskeydesc->k_len - (icountlc + icounttc);
566  while (imaxtc--) {
567  *pcnodeptr++ = *pcprevkey++;
568  }
569  }
570  pcprevkey = pskey->ckey;
571  }
572  if (pskeydesc->k_flags & ISDUPS) {
573  inl_stquad (pskey->tdupnumber, pcnodeptr);
574  pcnodeptr += QUADSIZE;
575  }
576  inl_stquad (pskey->trownode, pcnodeptr);
577  pcnodeptr += QUADSIZE;
578  }
579  if (pskey && pskey->iisdummy) {
580  pstree->pskeylist[pstree->ikeysinnode] = pskey;
581  pstree->ikeysinnode++;
582  }
583  inl_stint ((int)((ucharptr)pcnodeptr - (ucharptr)cvbnodetmp), cvbnodetmp);
584  return ivbblockwrite (ihandle, 1, tnodenumber, cvbnodetmp);
585 }
unsigned char iishigh
Definition: isinternal.h:331
static char cvbnodetmp[4096]
Definition: vbnodememio.c:24
struct VBKEY * pskeylast
Definition: isinternal.h:341
unsigned char ckey[1]
Definition: isinternal.h:334
unsigned char iisdummy
Definition: isinternal.h:332
unsigned char * ucharptr
Definition: isinternal.h:150
static int inodesplit(const int ihandle, const int ikeynumber, struct VBTREE *pstree, struct VBKEY *pskeyhalfway)
Definition: vbnodememio.c:163
#define VB_NODE_MAX
Definition: isinternal.h:288
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static int iquicknodesave(const int ihandle, struct VBTREE *pstree, const off_t tnodenumber, struct keydesc *pskeydesc, const int imode, const int iposn)
Definition: vbnodememio.c:27
struct DICTNODE sdictnode
Definition: isinternal.h:444
off_t trownode
Definition: isinternal.h:328
#define TCC
Definition: vbnodememio.c:22
unsigned int ikeysinnode
Definition: isinternal.h:346
struct VBKEY * psprev
Definition: isinternal.h:325
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
char ctransnumber[8]
Definition: isinternal.h:377
off_t tdupnumber
Definition: isinternal.h:329
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
struct VBKEY * pskeylist[512]
Definition: isinternal.h:352
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
unsigned int ilevel
Definition: isinternal.h:345
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
unsigned char iisnew
Definition: isinternal.h:330
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
struct VBKEY * psnext
Definition: isinternal.h:324
int inodesize
Definition: isinternal.h:402

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbopen ( const char *  pcfilename,
const int  iflags,
const mode_t  tmode 
)

Definition at line 32 of file vblowlevel.c.

References VBFILE::ihandle, iinitialized, VBFILE::irefcount, O_BINARY, svbfile, VBFILE::tdevice, VBFILE::tinode, and VB_MAX_FILES.

Referenced by isbuild(), islogopen(), and isopen().

33 {
34  int iloop;
35  struct stat sstat;
36 
37  if (!iinitialized) {
38  memset ((void *)&svbfile[0], 0, sizeof (svbfile));
39  iinitialized = 1;
40  }
41  if (stat (pcfilename, &sstat)) {
42  if (!iflags & O_CREAT) {
43  return -1;
44  }
45  } else {
46  for (iloop = 0; iloop < VB_MAX_FILES * 3; iloop++) {
47  if (svbfile[iloop].irefcount
48  && svbfile[iloop].tdevice == sstat.st_dev
49 #ifdef _WIN32
50  && !strcmp(svbfile[iloop].cfilename, pcfilename)) {
51 #else
52  && svbfile[iloop].tinode == sstat.st_ino) {
53 #endif
54  svbfile[iloop].irefcount++;
55  return iloop;
56  }
57  }
58  }
59  for (iloop = 0; iloop < VB_MAX_FILES * 3; iloop++) {
60  if (svbfile[iloop].irefcount == 0) {
61  svbfile[iloop].ihandle = open (pcfilename, iflags | O_BINARY, tmode);
62  if (svbfile[iloop].ihandle == -1) {
63  break;
64  }
65  if ((iflags & O_CREAT) && stat (pcfilename, &sstat)) {
66  close (svbfile[iloop].ihandle);
67  return -1;
68  }
69 #ifdef _WIN32
70  svbfile[iloop].tinode = 0;
71  if (svbfile[iloop].cfilename) {
72  free (svbfile[iloop].cfilename);
73  }
74  svbfile[iloop].whandle = (HANDLE)_get_osfhandle (svbfile[iloop].ihandle);
75  if (svbfile[iloop].whandle == INVALID_HANDLE_VALUE) {
76  close (svbfile[iloop].ihandle);
77  return -1;
78  }
79  svbfile[iloop].cfilename = strdup (pcfilename);
80 #else
81  svbfile[iloop].tinode = sstat.st_ino;
82 #endif
83  svbfile[iloop].tdevice = sstat.st_dev;
84  svbfile[iloop].irefcount++;
85  return iloop;
86  }
87  }
88  errno = ENOENT;
89  return -1;
90 }
int ihandle
Definition: isinternal.h:456
#define O_BINARY
Definition: fileio.c:90
ino_t tinode
Definition: isinternal.h:459
int irefcount
Definition: isinternal.h:457
#define VB_MAX_FILES
Definition: isinternal.h:120
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24
dev_t tdevice
Definition: isinternal.h:458
static int iinitialized
Definition: vblowlevel.c:26

Here is the caller graph for this function:

int ivbtransbuild ( const char *  pcfilename,
const int  iminrowlen,
const int  imaxrowlen,
struct keydesc *  pskeydesc,
const int  imode 
)

Definition at line 599 of file istrans.c.

References cvbtransbuffer, inl_stint(), iserrno, ivbintrans, ivblogfilehandle, iwritebegin(), iwritetrans(), VBBEGIN, VBL_BUILD, VBNEEDFLUSH, and vtranshdr().

Referenced by isbuild().

601 {
602  char *pcbuffer;
603  struct keypart *pskptr;
604  int ilength = 0, ilength2, iloop;
605 
606  if (ivblogfilehandle < 0 || imode & ISNOLOG) {
607  return 0;
608  }
609  /* Don't log transactions if we're in rollback / recover mode */
610  if (ivbintrans > VBNEEDFLUSH) {
611  return 0;
612  }
613  if (ivbintrans == VBBEGIN) {
614  if (iwritebegin ()) {
615  return -1;
616  }
617  }
619  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
620  inl_stint (imode, pcbuffer);
621  inl_stint (iminrowlen, pcbuffer + INTSIZE);
622  inl_stint (imaxrowlen, pcbuffer + (2 * INTSIZE));
623  inl_stint (pskeydesc->k_flags, pcbuffer + (3 * INTSIZE));
624  inl_stint (pskeydesc->k_nparts, pcbuffer + (4 * INTSIZE));
625  pcbuffer += (INTSIZE * 6);
626  for (iloop = 0; iloop < pskeydesc->k_nparts; iloop++) {
627  pskptr = &pskeydesc->k_part[iloop];
628  inl_stint (pskptr->kp_start, pcbuffer + (iloop * 3 * INTSIZE));
629  inl_stint (pskptr->kp_leng,
630  pcbuffer + INTSIZE + (iloop * 3 * INTSIZE));
631  inl_stint (pskptr->kp_type,
632  pcbuffer + (INTSIZE * 2) + (iloop * 3 * INTSIZE));
633  ilength += pskptr->kp_leng;
634  }
635  inl_stint (ilength, pcbuffer - INTSIZE);
636  ilength = (INTSIZE * 6) + (INTSIZE * 3 * (pskeydesc->k_nparts));
637  ilength2 = strlen (pcfilename) + 1;
638  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR) + ilength;
639  memcpy (pcbuffer, pcfilename, (size_t)ilength2);
640  iserrno = iwritetrans (ilength + ilength2, 0);
641  if (iserrno) {
642  return -1;
643  }
644  return 0;
645 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
#define VBL_BUILD
Definition: isinternal.h:468
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
int ivblogfilehandle
Definition: istrans.c:24
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtransclose ( const int  ihandle,
const char *  pcfilename 
)

Definition at line 806 of file istrans.c.

References cvbtransbuffer, inl_stint(), DICTINFO::iopenmode, iserrno, DICTINFO::itransyet, ivbintrans, iwritebegin(), iwritetrans(), psvbfile, VBBEGIN, VBL_FILECLOSE, VBROLLBACK, and vtranshdr().

Referenced by ivbclose2().

807 {
808  struct DICTINFO *psvbptr;
809  char *pcbuffer;
810  int ilength;
811 
812  psvbptr = psvbfile[ihandle];
813  if (ivblogfilehandle < 0 || psvbptr->iopenmode & ISNOLOG) {
814  return 0;
815  }
816  /* Don't log transactions if we're in rollback / recover mode */
817  if (ivbintrans > VBROLLBACK) {
818  return 0;
819  }
820  if (psvbptr->itransyet == 0) {
821  return 0;
822  }
823  if (ivbintrans == VBBEGIN) {
824  if (iwritebegin ()) {
825  return -1;
826  }
827  }
829  ilength = strlen (pcfilename) + 1;
830  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
831  inl_stint (ihandle, pcbuffer);
832  inl_stint (psvbptr->iopenmode & ISVARLEN, pcbuffer + INTSIZE); /* VARLEN flag! */
833  memcpy (pcbuffer + INTSIZE + INTSIZE, pcfilename, (size_t)ilength);
834  ilength += (INTSIZE * 2);
835  iserrno = iwritetrans (ilength, 0);
836  if (iserrno) {
837  return -1;
838  }
839  return 0;
840 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int iopenmode
Definition: isinternal.h:412
#define VBL_FILECLOSE
Definition: isinternal.h:476
#define VBROLLBACK
Definition: isinternal.h:310
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
unsigned char itransyet
Definition: isinternal.h:438
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtranscluster ( void  )

Definition at line 691 of file istrans.c.

692 {
693  /* BUG - Write ivbtranscluster */
694  return 0;
695 }
int ivbtranscreateindex ( const int  ihandle,
struct keydesc *  pskeydesc 
)

Definition at line 648 of file istrans.c.

References cvbtransbuffer, inl_stint(), iserrno, ivbintrans, ivblogfilehandle, iwritebegin(), iwritetrans(), psvbfile, VBBEGIN, VBL_CREINDEX, VBNEEDFLUSH, and vtranshdr().

Referenced by isaddindex().

649 {
650  char *pcbuffer;
651  struct keypart *pskptr;
652  int ilength = 0, iloop;
653 
654  if (ivblogfilehandle < 0 || psvbfile[ihandle]->iopenmode & ISNOLOG) {
655  return 0;
656  }
657  /* Don't log transactions if we're in rollback / recover mode */
658  if (ivbintrans > VBNEEDFLUSH) {
659  return 0;
660  }
661  if (ivbintrans == VBBEGIN) {
662  if (iwritebegin ()) {
663  return -1;
664  }
665  }
667  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
668  inl_stint (ihandle, pcbuffer);
669  inl_stint (pskeydesc->k_flags, pcbuffer + INTSIZE);
670  inl_stint (pskeydesc->k_nparts, pcbuffer + (2 * INTSIZE));
671  pcbuffer += (INTSIZE * 4);
672  for (iloop = 0; iloop < pskeydesc->k_nparts; iloop++) {
673  pskptr = &pskeydesc->k_part[iloop];
674  inl_stint (pskptr->kp_start, pcbuffer + (iloop * 3 * INTSIZE));
675  inl_stint (pskptr->kp_leng,
676  pcbuffer + INTSIZE + (iloop * 3 * INTSIZE));
677  inl_stint (pskptr->kp_type,
678  pcbuffer + (INTSIZE * 2) + (iloop * 3 * INTSIZE));
679  ilength += pskptr->kp_leng;
680  }
681  inl_stint (ilength, pcbuffer - INTSIZE);
682  ilength = (INTSIZE * 4) + (INTSIZE * 3 * (pskeydesc->k_nparts));
683  iserrno = iwritetrans (ilength, 0);
684  if (iserrno) {
685  return -1;
686  }
687  return 0;
688 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
#define VBL_CREINDEX
Definition: isinternal.h:470
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivblogfilehandle
Definition: istrans.c:24
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtransdelete ( const int  ihandle,
off_t  trownumber,
int  irowlength 
)

Definition at line 698 of file istrans.c.

References DICTINFO::cfilename, cvbtransbuffer, inl_stint(), inl_stquad(), DICTINFO::iopenmode, iserrno, DICTINFO::itransyet, ivbintrans, ivbtransopen(), iwritebegin(), iwritetrans(), DICTINFO::ppcrowbuffer, psvbfile, QUADSIZE, VBBEGIN, VBL_DELETE, VBNEEDFLUSH, and vtranshdr().

Referenced by iprocessdelete().

699 {
700  struct DICTINFO *psvbptr;
701  char *pcbuffer;
702 
703  psvbptr = psvbfile[ihandle];
704  if (ivblogfilehandle < 0 || psvbptr->iopenmode & ISNOLOG) {
705  return 0;
706  }
707  /* Don't log transactions if we're in rollback / recover mode */
708  if (ivbintrans > VBNEEDFLUSH) {
709  return 0;
710  }
711  if (ivbintrans == VBBEGIN) {
712  if (iwritebegin ()) {
713  return -1;
714  }
715  }
716  if (psvbptr->itransyet == 0) {
717  ivbtransopen (ihandle, psvbptr->cfilename);
718  }
720  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
721  inl_stint (ihandle, pcbuffer);
722  inl_stquad (trownumber, pcbuffer + INTSIZE);
723  inl_stint (irowlength, pcbuffer + INTSIZE + QUADSIZE);
724  memcpy (pcbuffer + INTSIZE + QUADSIZE + INTSIZE, psvbptr->ppcrowbuffer, (size_t)irowlength);
725  irowlength += (INTSIZE * 2) + QUADSIZE;
726  iserrno = iwritetrans (irowlength, 1);
727  if (iserrno) {
728  return -1;
729  }
730  return 0;
731 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
#define VBL_DELETE
Definition: isinternal.h:473
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
char * cfilename
Definition: isinternal.h:422
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
int ivbtransopen(const int ihandle, const char *pcfilename)
Definition: istrans.c:843
int iopenmode
Definition: isinternal.h:412
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
unsigned char itransyet
Definition: isinternal.h:438
char * ppcrowbuffer
Definition: isinternal.h:423
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtransdeleteindex ( const int  ihandle,
struct keydesc *  pskeydesc 
)

Definition at line 734 of file istrans.c.

References cvbtransbuffer, inl_stint(), iserrno, ivbintrans, ivblogfilehandle, iwritebegin(), iwritetrans(), psvbfile, VBBEGIN, VBL_DELINDEX, VBNEEDFLUSH, and vtranshdr().

Referenced by isdelindex().

735 {
736  char *pcbuffer;
737  struct keypart *pskptr;
738  int ilength = 0, iloop;
739 
740  if (ivblogfilehandle < 0 || psvbfile[ihandle]->iopenmode & ISNOLOG) {
741  return 0;
742  }
743  /* Don't log transactions if we're in rollback / recover mode */
744  if (ivbintrans > VBNEEDFLUSH) {
745  return 0;
746  }
747  if (ivbintrans == VBBEGIN) {
748  if (iwritebegin ()) {
749  return -1;
750  }
751  }
753  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
754  inl_stint (ihandle, pcbuffer);
755  inl_stint (pskeydesc->k_flags, pcbuffer + INTSIZE);
756  inl_stint (pskeydesc->k_nparts, pcbuffer + (2 * INTSIZE));
757  pcbuffer += (INTSIZE * 4);
758  for (iloop = 0; iloop < pskeydesc->k_nparts; iloop++) {
759  pskptr = &pskeydesc->k_part[iloop];
760  inl_stint (pskptr->kp_start, pcbuffer + (iloop * 3 * INTSIZE));
761  inl_stint (pskptr->kp_leng,
762  pcbuffer + INTSIZE + (iloop * 3 * INTSIZE));
763  inl_stint (pskptr->kp_type,
764  pcbuffer + (INTSIZE * 2) + (iloop * 3 * INTSIZE));
765  ilength += pskptr->kp_leng;
766  }
767  inl_stint (ilength, pcbuffer - INTSIZE);
768  ilength = (INTSIZE * 4) + (INTSIZE * 3 * (pskeydesc->k_nparts));
769  iserrno = iwritetrans (ilength, 0);
770  if (iserrno) {
771  return -1;
772  }
773  return 0;
774 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
#define VBL_DELINDEX
Definition: isinternal.h:474
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivblogfilehandle
Definition: istrans.c:24
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtranserase ( const char *  pcfilename)

Definition at line 777 of file istrans.c.

References cvbtransbuffer, iserrno, ivbintrans, ivblogfilehandle, iwritebegin(), iwritetrans(), VBBEGIN, VBL_FILEERASE, VBNEEDFLUSH, and vtranshdr().

Referenced by iserase().

778 {
779  char *pcbuffer;
780  int ilength;
781 
782  if (ivblogfilehandle < 0) {
783  return 0;
784  }
785  /* Don't log transactions if we're in rollback / recover mode */
786  if (ivbintrans > VBNEEDFLUSH) {
787  return 0;
788  }
789  if (ivbintrans == VBBEGIN) {
790  if (iwritebegin ()) {
791  return -1;
792  }
793  }
795  ilength = strlen (pcfilename) + 1;
796  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
797  memcpy (pcbuffer, pcfilename, (size_t)ilength);
798  iserrno = iwritetrans (ilength, 0);
799  if (iserrno) {
800  return -1;
801  }
802  return 0;
803 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
#define VBNEEDFLUSH
Definition: isinternal.h:308
#define VBL_FILEERASE
Definition: isinternal.h:475
int ivblogfilehandle
Definition: istrans.c:24
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtransinsert ( const int  ihandle,
const off_t  trownumber,
int  irowlength,
char *  pcrow 
)

Definition at line 878 of file istrans.c.

References DICTINFO::cfilename, cvbtransbuffer, inl_stint(), inl_stquad(), DICTINFO::iopenmode, iserrno, DICTINFO::itransyet, ivbintrans, ivbtransopen(), iwritebegin(), iwritetrans(), psvbfile, QUADSIZE, VBBEGIN, VBL_INSERT, VBNEEDFLUSH, and vtranshdr().

Referenced by ivbwriterow().

879 {
880  struct DICTINFO *psvbptr;
881  char *pcbuffer;
882 
883  psvbptr = psvbfile[ihandle];
884  if (ivblogfilehandle < 0 || psvbptr->iopenmode & ISNOLOG) {
885  return 0;
886  }
887  /* Don't log transactions if we're in rollback / recover mode */
888  if (ivbintrans > VBNEEDFLUSH) {
889  return 0;
890  }
891  if (ivbintrans == VBBEGIN) {
892  if (iwritebegin ()) {
893  return -1;
894  }
895  }
896  if (psvbptr->itransyet == 0) {
897  ivbtransopen (ihandle, psvbptr->cfilename);
898  }
900  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
901  inl_stint (ihandle, pcbuffer);
902  inl_stquad (trownumber, pcbuffer + INTSIZE);
903  inl_stint (irowlength, pcbuffer + INTSIZE + QUADSIZE);
904  memcpy (pcbuffer + INTSIZE + QUADSIZE + INTSIZE, pcrow, (size_t)irowlength);
905  irowlength += (INTSIZE * 2) + QUADSIZE;
906  iserrno = iwritetrans (irowlength, 1);
907  if (iserrno) {
908  return -1;
909  }
910  return 0;
911 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
char * cfilename
Definition: isinternal.h:422
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
int ivbtransopen(const int ihandle, const char *pcfilename)
Definition: istrans.c:843
#define VBL_INSERT
Definition: isinternal.h:478
int iopenmode
Definition: isinternal.h:412
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
unsigned char itransyet
Definition: isinternal.h:438
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtransopen ( const int  ihandle,
const char *  pcfilename 
)

Definition at line 843 of file istrans.c.

References cvbtransbuffer, inl_stint(), DICTINFO::iopenmode, iserrno, DICTINFO::itransyet, ivbintrans, iwritebegin(), iwritetrans(), psvbfile, VBBEGIN, VBL_FILEOPEN, VBNEEDFLUSH, and vtranshdr().

Referenced by isopen(), ivbtransdelete(), ivbtransinsert(), ivbtranssetunique(), ivbtransuniqueid(), and ivbtransupdate().

844 {
845  struct DICTINFO *psvbptr;
846  char *pcbuffer;
847  int ilength;
848 
849  psvbptr = psvbfile[ihandle];
850  if (ivblogfilehandle < 0 || psvbptr->iopenmode & ISNOLOG) {
851  return 0;
852  }
853  /* Don't log transactions if we're in rollback / recover mode */
854  if (ivbintrans > VBNEEDFLUSH) {
855  return 0;
856  }
857  if (ivbintrans == VBBEGIN) {
858  if (iwritebegin ()) {
859  return -1;
860  }
861  }
862  psvbptr->itransyet = 2;
864  ilength = strlen (pcfilename) + 1;
865  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
866  inl_stint (ihandle, pcbuffer);
867  inl_stint (psvbptr->iopenmode & ISVARLEN, pcbuffer + INTSIZE); /* VARLEN flag! */
868  memcpy (pcbuffer + INTSIZE + INTSIZE, pcfilename, (size_t)ilength);
869  ilength += (INTSIZE * 2);
870  iserrno = iwritetrans (ilength, 0);
871  if (iserrno) {
872  return -1;
873  }
874  return 0;
875 }
#define VBBEGIN
Definition: isinternal.h:307
#define VBL_FILEOPEN
Definition: isinternal.h:477
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int iopenmode
Definition: isinternal.h:412
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
unsigned char itransyet
Definition: isinternal.h:438
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtransrename ( char *  pcoldname,
char *  pcnewname 
)

Definition at line 914 of file istrans.c.

References cvbtransbuffer, inl_stint(), iserrno, ivbintrans, ivblogfilehandle, iwritebegin(), iwritetrans(), VBBEGIN, VBL_RENAME, VBNEEDFLUSH, and vtranshdr().

Referenced by isrename().

915 {
916  char *pcbuffer;
917  int ilength, ilength1, ilength2;
918 
919  if (ivblogfilehandle < 0) {
920  return 0;
921  }
922  /* Don't log transactions if we're in rollback / recover mode */
923  if (ivbintrans > VBNEEDFLUSH) {
924  return 0;
925  }
926  if (ivbintrans == VBBEGIN) {
927  if (iwritebegin ()) {
928  return -1;
929  }
930  }
932  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
933  ilength1 = strlen (pcoldname) + 1;
934  ilength2 = strlen (pcnewname) + 1;
935  inl_stint (ilength1, pcbuffer);
936  inl_stint (ilength2, pcbuffer + INTSIZE);
937  memcpy (pcbuffer + (INTSIZE * 2), pcoldname, (size_t)ilength1);
938  memcpy (pcbuffer + (INTSIZE * 2) + ilength1, pcnewname, (size_t)ilength2);
939  ilength = (INTSIZE * 2) + ilength1 + ilength2;
940  iserrno = iwritetrans (ilength, 0);
941  if (iserrno) {
942  return -1;
943  }
944  return 0;
945 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
int ivblogfilehandle
Definition: istrans.c:24
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
#define VBL_RENAME
Definition: isinternal.h:479
int ivbintrans
Definition: istrans.c:23
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtranssetunique ( const int  ihandle,
const off_t  tuniqueid 
)

Definition at line 948 of file istrans.c.

References DICTINFO::cfilename, cvbtransbuffer, inl_stint(), inl_stquad(), DICTINFO::iopenmode, iserrno, DICTINFO::itransyet, ivbintrans, ivbtransopen(), iwritebegin(), iwritetrans(), psvbfile, QUADSIZE, VBBEGIN, VBL_SETUNIQUE, VBNEEDFLUSH, and vtranshdr().

Referenced by issetunique().

949 {
950  struct DICTINFO *psvbptr;
951  char *pcbuffer;
952 
953  psvbptr = psvbfile[ihandle];
954  if (ivblogfilehandle < 0 || psvbptr->iopenmode & ISNOLOG) {
955  return 0;
956  }
957  /* Don't log transactions if we're in rollback / recover mode */
958  if (ivbintrans > VBNEEDFLUSH) {
959  return 0;
960  }
961  if (ivbintrans == VBBEGIN) {
962  if (iwritebegin ()) {
963  return -1;
964  }
965  }
966  if (psvbptr->itransyet == 0) {
967  ivbtransopen (ihandle, psvbptr->cfilename);
968  }
970  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
971  inl_stint (ihandle, pcbuffer);
972  inl_stquad (tuniqueid, pcbuffer + INTSIZE);
973  iserrno = iwritetrans (INTSIZE + QUADSIZE, 0);
974  if (iserrno) {
975  return -1;
976  }
977  return 0;
978 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
char * cfilename
Definition: isinternal.h:422
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
int ivbtransopen(const int ihandle, const char *pcfilename)
Definition: istrans.c:843
int iopenmode
Definition: isinternal.h:412
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
#define VBL_SETUNIQUE
Definition: isinternal.h:481
unsigned char itransyet
Definition: isinternal.h:438
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtransuniqueid ( const int  ihandle,
const off_t  tuniqueid 
)

Definition at line 981 of file istrans.c.

References DICTINFO::cfilename, cvbtransbuffer, inl_stint(), inl_stquad(), DICTINFO::iopenmode, iserrno, DICTINFO::itransyet, ivbintrans, ivblogfilehandle, ivbtransopen(), iwritebegin(), iwritetrans(), psvbfile, QUADSIZE, VBBEGIN, VBL_UNIQUEID, VBNEEDFLUSH, and vtranshdr().

Referenced by isuniqueid().

982 {
983  struct DICTINFO *psvbptr;
984  char *pcbuffer;
985 
986  psvbptr = psvbfile[ihandle];
987  if (ivblogfilehandle < 0 || (psvbptr->iopenmode & ISNOLOG)) {
988  return 0;
989  }
990  /* Don't log transactions if we're in rollback / recover mode */
991  if (ivbintrans > VBNEEDFLUSH) {
992  return 0;
993  }
994  if (ivbintrans == VBBEGIN) {
995  if (iwritebegin ()) {
996  return -1;
997  }
998  }
999  if (psvbptr->itransyet == 0) {
1000  ivbtransopen (ihandle, psvbptr->cfilename);
1001  }
1003  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
1004  inl_stint (ihandle, pcbuffer);
1005  inl_stquad (tuniqueid, pcbuffer + INTSIZE);
1006  iserrno = iwritetrans (INTSIZE + QUADSIZE, 0);
1007  if (iserrno) {
1008  return -1;
1009  }
1010  return 0;
1011 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
#define VBL_UNIQUEID
Definition: isinternal.h:482
char * cfilename
Definition: isinternal.h:422
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
int ivbtransopen(const int ihandle, const char *pcfilename)
Definition: istrans.c:843
int ivblogfilehandle
Definition: istrans.c:24
int iopenmode
Definition: isinternal.h:412
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
unsigned char itransyet
Definition: isinternal.h:438
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbtransupdate ( const int  ihandle,
const off_t  trownumber,
const int  ioldrowlen,
const int  inewrowlen,
const char *  pcrow 
)

Definition at line 1014 of file istrans.c.

References DICTINFO::cfilename, cvbtransbuffer, inl_stint(), inl_stquad(), DICTINFO::iopenmode, iserrno, DICTINFO::itransyet, ivbintrans, ivblogfilehandle, ivbtransopen(), iwritebegin(), iwritetrans(), DICTINFO::ppcrowbuffer, psvbfile, QUADSIZE, VBBEGIN, VBL_UPDATE, VBNEEDFLUSH, and vtranshdr().

Referenced by isrewcurr(), isrewrec(), and isrewrite().

1015 {
1016  struct DICTINFO *psvbptr;
1017  char *pcbuffer;
1018  int ilength;
1019 
1020  psvbptr = psvbfile[ihandle];
1021  if (ivblogfilehandle < 0 || (psvbptr->iopenmode & ISNOLOG)) {
1022  return 0;
1023  }
1024  /* Don't log transactions if we're in rollback / recover mode */
1025  if (ivbintrans > VBNEEDFLUSH) {
1026  return 0;
1027  }
1028  if (ivbintrans == VBBEGIN) {
1029  if (iwritebegin ()) {
1030  return -1;
1031  }
1032  }
1033  if (psvbptr->itransyet == 0) {
1034  ivbtransopen (ihandle, psvbptr->cfilename);
1035  }
1037  pcbuffer = cvbtransbuffer + sizeof (struct SLOGHDR);
1038  inl_stint (ihandle, pcbuffer);
1039  inl_stquad (trownumber, pcbuffer + INTSIZE);
1040  inl_stint (ioldrowlen, pcbuffer + INTSIZE + QUADSIZE);
1041  inl_stint (inewrowlen, pcbuffer + INTSIZE + QUADSIZE + INTSIZE);
1042  memcpy (pcbuffer + INTSIZE + QUADSIZE + INTSIZE + INTSIZE, psvbptr->ppcrowbuffer,
1043  (size_t)ioldrowlen);
1044  memcpy (pcbuffer + INTSIZE + QUADSIZE + INTSIZE + INTSIZE + ioldrowlen, pcrow,
1045  (size_t)inewrowlen);
1046  ilength = INTSIZE + QUADSIZE + (INTSIZE * 2) + ioldrowlen + inewrowlen;
1047  iserrno = iwritetrans (ilength, 1);
1048  if (iserrno) {
1049  return -1;
1050  }
1051  return 0;
1052 }
#define VBBEGIN
Definition: isinternal.h:307
static int iwritebegin(void)
Definition: istrans.c:136
#define VBL_UPDATE
Definition: isinternal.h:483
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
char * cfilename
Definition: isinternal.h:422
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
int ivbtransopen(const int ihandle, const char *pcfilename)
Definition: istrans.c:843
int ivblogfilehandle
Definition: istrans.c:24
int iopenmode
Definition: isinternal.h:412
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
unsigned char itransyet
Definition: isinternal.h:438
char * ppcrowbuffer
Definition: isinternal.h:423
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbwriterow ( const int  ihandle,
char *  pcrow,
const off_t  trownumber 
)

Definition at line 85 of file iswrite.c.

References DICTINFO::iminrowlength, DICTINFO::iopenmode, irowinsert(), iserrno, isreclen, isrecnum, ivbdatalock(), ivbdatawrite(), ivbtransinsert(), psvbfile, DICTINFO::trownumber, DICTINFO::tvarlennode, VBUNLOCK, and VBWRLOCK.

Referenced by ircvinsert(), iswrcurr(), iswrite(), and ivbrollmeback().

86 {
87  struct DICTINFO *psvbptr;
88  int iresult = 0;
89 
90  psvbptr = psvbfile[ihandle];
92  if (psvbptr->iopenmode & ISTRANS) {
93  iserrno = ivbdatalock (ihandle, VBWRLOCK, trownumber);
94  if (iserrno) {
95  return -1;
96  }
97  }
98  iresult = irowinsert (ihandle, pcrow, trownumber);
99  if (!iresult) {
100  iserrno = 0;
101  psvbptr->tvarlennode = 0; /* Stop it from removing */
102  iresult = ivbdatawrite (ihandle, (void *)pcrow, 0, trownumber);
103  if (iresult) {
104  iserrno = iresult;
105  if (psvbptr->iopenmode & ISTRANS) {
106  ivbdatalock (ihandle, VBUNLOCK, trownumber);
107  }
108  return -1;
109  }
110  if (psvbptr->iopenmode & ISVARLEN) {
111  iresult = ivbtransinsert (ihandle, trownumber,
112  isreclen, pcrow);
113  } else {
114  iresult = ivbtransinsert (ihandle, trownumber,
115  psvbptr->iminrowlength, pcrow);
116  }
117  }
118  return iresult;
119 }
int isreclen
Definition: vbmemio.c:29
int ivbdatawrite(const int ihandle, char *pcbuffer, int ideletedrow, const off_t trownumber)
Definition: vbdataio.c:611
int ivbtransinsert(const int ihandle, const off_t trownumber, int irowlength, char *pcrow)
Definition: istrans.c:878
int iminrowlength
Definition: isinternal.h:403
off_t tvarlennode
Definition: isinternal.h:421
int ivbdatalock(const int ihandle, const int imode, const off_t trownumber)
Definition: vblocking.c:432
#define VBWRLOCK
Definition: isinternal.h:297
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int iopenmode
Definition: isinternal.h:412
static int irowinsert(const int ihandle, char *pcrow_buffer, off_t trownumber)
Definition: iswrite.c:23
#define VBUNLOCK
Definition: isinternal.h:294
off_t trownumber
Definition: isinternal.h:416
int iserrno
Definition: vbmemio.c:27
int isrecnum
Definition: vbmemio.c:30

Here is the call graph for this function:

Here is the caller graph for this function:

struct VBKEY* psvbkeyallocate ( const int  ihandle,
const int  ikeynumber 
)

Definition at line 120 of file vbmemio.c.

References NULL, DICTINFO::pskeydesc, DICTINFO::pskeyfree, VBKEY::psnext, psvbfile, pvvbmalloc(), VBKEY::trownode, and vb_error.

Referenced by inodesplit(), ivbkeyinsert(), and ivbnodeload().

121 {
122  struct VBKEY *pskey;
123  struct DICTINFO *psvbptr;
124  int ilength = 0;
125 
126  psvbptr = psvbfile[ihandle];
127  pskey = psvbptr->pskeyfree[ikeynumber];
128  if (pskey == NULL) {
129  ilength = psvbptr->pskeydesc[ikeynumber]->k_len;
130  pskey = pvvbmalloc (sizeof (struct VBKEY) + ilength);
131  } else {
132  if (pskey->trownode != -1) {
133  vb_error ("Keyallocated not free");
134  }
135  psvbptr->pskeyfree[ikeynumber] =
136  psvbptr->pskeyfree[ikeynumber]->psnext;
137  memset (pskey, 0, (sizeof (struct VBKEY) + ilength));
138  }
139  return pskey;
140 }
#define vb_error(x)
Definition: vbmemio.c:41
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
off_t trownode
Definition: isinternal.h:328
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

struct VBLOCK* psvblockallocate ( const int  ihandle)

Definition at line 67 of file vbmemio.c.

References NULL, pslockfree, VBLOCK::psnext, and pvvbmalloc().

Referenced by ilockinsert().

68 {
69  struct VBLOCK *pslock = pslockfree;
70 
71  if (pslockfree != NULL) {
73  memset (pslock, 0, sizeof (struct VBLOCK));
74  } else {
75  pslock = pvvbmalloc (sizeof (struct VBLOCK));
76  }
77  return pslock;
78 }
struct VBLOCK * psnext
Definition: isinternal.h:318
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static struct VBLOCK * pslockfree
Definition: vbmemio.c:22

Here is the call graph for this function:

Here is the caller graph for this function:

struct VBTREE* psvbtreeallocate ( const int  ihandle)

Definition at line 88 of file vbmemio.c.

References NULL, VBTREE::psnext, pstreefree, pvvbmalloc(), VBTREE::tnodenumber, and vb_error.

Referenced by inodesplit(), itreeload(), and ivbkeyload().

89 {
90  struct VBTREE *pstree = pstreefree;
91 
92  if (pstreefree == NULL) {
93  pstree = pvvbmalloc (sizeof (struct VBTREE));
94  } else {
96  if (pstree->tnodenumber != -1) {
97  vb_error ("Treeallocated not free");
98  }
99  memset (pstree, 0, sizeof (struct VBTREE));
100  }
101  return pstree;
102 }
static struct VBTREE * pstreefree
Definition: vbmemio.c:23
#define vb_error(x)
Definition: vbmemio.c:41
struct VBTREE * psnext
Definition: isinternal.h:338
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
off_t tnodenumber
Definition: isinternal.h:343

Here is the call graph for this function:

Here is the caller graph for this function:

void* pvvbmalloc ( const size_t  size)

Definition at line 45 of file vbmemio.c.

References unlikely.

Referenced by ipreamble(), iprocessdelete(), ircvbegin(), ircvchecktrans(), ircvfileopen(), isaddindex(), isbuild(), isdi_kdsc(), isopen(), isrecover(), psvbkeyallocate(), psvblockallocate(), and psvbtreeallocate().

46 {
47  void *mptr;
48 
49  mptr = calloc (1, size);
50  if (unlikely(!mptr)) {
51  fprintf (stderr, "Cannot allocate %d bytes of memory - Aborting\n", size);
52  fflush (stderr);
53  exit (1);
54  }
55  return mptr;
56 }
#define unlikely(x)
Definition: common.h:437

Here is the caller graph for this function:

off_t tvbdataallocate ( const int  ihandle)

Definition at line 284 of file vbindexio.c.

References DICTNODE::cdatafree, cvbnodetmp, DICTINFO::iisdictlocked, inl_ldint(), inl_ldquad(), inl_stint(), inl_stquad(), DICTINFO::inodesize, iserrno, ivbblockread(), ivbblockwrite(), ivbnodefree(), psvbfile, QUADSIZE, DICTINFO::sdictnode, and tvbdatacountgetnext().

Referenced by iswrcurr(), and iswrite().

285 {
286  struct DICTINFO *psvbptr;
287  off_t theadnode, tnextnode, tvalue;
288  int ilengthused, iresult;
289 
290  psvbptr = psvbfile[ihandle];
291  iserrno = EBADARG;
292  if (!psvbptr->iisdictlocked) {
293  return -1;
294  }
295  iserrno = 0;
296 
297  /* If there's *ANY* rows in the free list, use them first! */
298  theadnode = inl_ldquad (psvbptr->sdictnode.cdatafree);
299  while (theadnode != 0) {
300  iserrno = ivbblockread (ihandle, 1, theadnode, cvbnodetmp);
301  if (iserrno) {
302  return -1;
303  }
304  iserrno = EBADFILE;
305 /* C-ISAM is not 100% C-ISAM compatible */
306 #if ISAMMODE == 1
307  if (cvbnodetmp[psvbptr->inodesize - 2] != 0x7f) {
308  return -1;
309  }
310 #endif
311  if (cvbnodetmp[psvbptr->inodesize - 3] != -1) {
312  return -1;
313  }
314  ilengthused = inl_ldint (cvbnodetmp);
315  if (ilengthused > INTSIZE + QUADSIZE) {
316  psvbptr->iisdictlocked |= 0x02;
317  ilengthused -= QUADSIZE;
318  inl_stint (ilengthused, cvbnodetmp);
319  tvalue = inl_ldquad (&cvbnodetmp[ilengthused]);
320  inl_stquad ((off_t)0, &cvbnodetmp[ilengthused]);
321  if (ilengthused > INTSIZE + QUADSIZE) {
322  iserrno = ivbblockwrite (ihandle, 1, theadnode, cvbnodetmp);
323  if (iserrno) {
324  return -1;
325  }
326  return tvalue;
327  }
328  /* If we're using the last entry in the node, advance */
329  tnextnode = inl_ldquad (&cvbnodetmp[INTSIZE]);
330  iresult = ivbnodefree (ihandle, theadnode);
331  if (iresult) {
332  return -1;
333  }
334  inl_stquad (tnextnode, psvbptr->sdictnode.cdatafree);
335  return tvalue;
336  }
337  /* Ummmm, this is an INTEGRITY ERROR of sorts! */
338  /* However, let's fix it anyway! */
339  tnextnode = inl_ldquad (&cvbnodetmp[INTSIZE]);
340  iresult = ivbnodefree (ihandle, theadnode);
341  if (iresult) {
342  return -1;
343  }
344  inl_stquad (tnextnode, psvbptr->sdictnode.cdatafree);
345  psvbptr->iisdictlocked |= 0x02;
346  theadnode = tnextnode;
347  }
348  /* If we get here, we need to allocate a NEW row number. */
349  /* Since we already hold a dictionary lock, we don't need another */
350  tvalue = tvbdatacountgetnext (ihandle);
351  return tvalue;
352 }
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
static off_t tvbdatacountgetnext(const int ihandle)
Definition: vbindexio.c:27
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTNODE sdictnode
Definition: isinternal.h:444
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
static char cvbnodetmp[4096]
Definition: vbindexio.c:22
char cdatafree[8]
Definition: isinternal.h:373
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402
int ivbnodefree(const int ihandle, const off_t tnodenumber)
Definition: vbindexio.c:67

Here is the call graph for this function:

Here is the caller graph for this function:

off_t tvblseek ( const int  ihandle,
off_t  toffset,
const int  iwhence 
)

Definition at line 107 of file vblowlevel.c.

References svbfile, and unlikely.

Referenced by ircvchecktrans(), iscommit(), isrecover(), isrollback(), ivbblockread(), ivbblockwrite(), ivbdataread(), ivbdatawrite(), ivbrollmeback(), ivbrollmeforward(), and iwritetrans().

108 {
109  if (unlikely(!svbfile[ihandle].irefcount)) {
110  errno = ENOENT;
111  return -1;
112  }
113  return lseek (svbfile[ihandle].ihandle, toffset, iwhence);
114 }
#define unlikely(x)
Definition: common.h:437
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24

Here is the caller graph for this function:

off_t tvbnodeallocate ( const int  ihandle)

Definition at line 221 of file vbindexio.c.

References DICTNODE::cnodefree, cvbnodetmp, DICTINFO::iisdictlocked, inl_ldint(), inl_ldquad(), inl_stint(), inl_stquad(), DICTINFO::inodesize, iserrno, ivbblockread(), ivbblockwrite(), psvbfile, QUADSIZE, DICTINFO::sdictnode, and tvbnodecountgetnext().

Referenced by inodesplit(), and ivbdatafree().

222 {
223  struct DICTINFO *psvbptr;
224  off_t theadnode, tvalue;
225  int ilengthused;
226 
227  /* Sanity check - Is ihandle a currently open table? */
228  iserrno = ENOTOPEN;
229  psvbptr = psvbfile[ihandle];
230  if (!psvbptr) {
231  return -1;
232  }
233  iserrno = EBADARG;
234  if (!psvbptr->iisdictlocked) {
235  return -1;
236  }
237  iserrno = 0;
238 
239  /* If there's *ANY* nodes in the free list, use them first! */
240  theadnode = inl_ldquad (psvbptr->sdictnode.cnodefree);
241  if (theadnode != 0) {
242  iserrno = ivbblockread (ihandle, 1, theadnode, cvbnodetmp);
243  if (iserrno) {
244  return -1;
245  }
246  iserrno = EBADFILE;
247 /* C-ISAM is not 100% C-ISAM compatible */
248 #if ISAMMODE == 1
249  if (cvbnodetmp[psvbptr->inodesize - 2] != 0x7f) {
250  return -1;
251  }
252 #endif
253  if (cvbnodetmp[psvbptr->inodesize - 3] != -2) {
254  return -1;
255  }
256  ilengthused = inl_ldint (cvbnodetmp);
257  if (ilengthused > (INTSIZE + QUADSIZE)) {
258  tvalue = inl_ldquad (cvbnodetmp + INTSIZE + QUADSIZE);
259  memcpy (cvbnodetmp + INTSIZE + QUADSIZE,
260  cvbnodetmp + INTSIZE + QUADSIZE + QUADSIZE,
261  (size_t)(ilengthused - (INTSIZE + QUADSIZE + QUADSIZE)));
262  ilengthused -= QUADSIZE;
263  memset (cvbnodetmp + ilengthused, 0, QUADSIZE);
264  inl_stint (ilengthused, cvbnodetmp);
265  iserrno = ivbblockwrite (ihandle, 1, theadnode, cvbnodetmp);
266  if (iserrno) {
267  return -1;
268  }
269  return tvalue;
270  }
271  /* If it's last entry in the node, use the node itself! */
272  tvalue = inl_ldquad (cvbnodetmp + INTSIZE);
273  inl_stquad (tvalue, psvbptr->sdictnode.cnodefree);
274  psvbptr->iisdictlocked |= 0x02;
275  return theadnode;
276  }
277  /* If we get here, we need to allocate a NEW node. */
278  /* Since we already hold a dictionary lock, we don't need another */
279  tvalue = tvbnodecountgetnext (ihandle);
280  return tvalue;
281 }
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTNODE sdictnode
Definition: isinternal.h:444
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
static char cvbnodetmp[4096]
Definition: vbindexio.c:22
char cnodefree[8]
Definition: isinternal.h:374
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
off_t tvbnodecountgetnext(const int ihandle)
Definition: vbindexio.c:48
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402

Here is the call graph for this function:

Here is the caller graph for this function:

off_t tvbnodecountgetnext ( const int  ihandle)

Definition at line 48 of file vbindexio.c.

References DICTNODE::cnodecount, DICTINFO::iisdictlocked, inl_ldquad(), inl_stquad(), iserrno, psvbfile, and DICTINFO::sdictnode.

Referenced by iaddkeydescriptor(), ivbvarlenwrite(), ttailnode(), and tvbnodeallocate().

49 {
50  struct DICTINFO *psvbptr;
51  off_t tvalue;
52 
53  psvbptr = psvbfile[ihandle];
54  iserrno = EBADARG;
55  if (!psvbptr->iisdictlocked) {
56  return -1;
57  }
58  iserrno = 0;
59 
60  tvalue = inl_ldquad (psvbptr->sdictnode.cnodecount) + 1;
61  inl_stquad (tvalue, psvbptr->sdictnode.cnodecount);
62  psvbptr->iisdictlocked |= 0x02;
63  return tvalue;
64 }
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTNODE sdictnode
Definition: isinternal.h:444
char cnodecount[8]
Definition: isinternal.h:376
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t tvbread ( const int  ihandle,
void *  pvbuffer,
const size_t  tcount 
)

Definition at line 117 of file vblowlevel.c.

References svbfile, and unlikely.

Referenced by ircvchecktrans(), isrecover(), ivbblockread(), ivbdataread(), ivbrollmeback(), and ivbrollmeforward().

118 {
119  if (unlikely(!svbfile[ihandle].irefcount)) {
120  errno = ENOENT;
121  return -1;
122  }
123  return read (svbfile[ihandle].ihandle, pvbuffer, tcount);
124 }
#define unlikely(x)
Definition: common.h:437
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24

Here is the caller graph for this function:

ssize_t tvbwrite ( const int  ihandle,
const void *  pvbuffer,
const size_t  tcount 
)

Definition at line 127 of file vblowlevel.c.

References svbfile, and unlikely.

Referenced by ivbblockwrite(), ivbdatawrite(), and iwritetrans().

128 {
129  if (unlikely(!svbfile[ihandle].irefcount)) {
130  errno = ENOENT;
131  return -1;
132  }
133  return write (svbfile[ihandle].ihandle, pvbuffer, tcount);
134 }
#define unlikely(x)
Definition: common.h:437
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24

Here is the caller graph for this function:

void vvbfree ( void *  mptr)

Definition at line 59 of file vbmemio.c.

Referenced by ipostamble(), ircvcommit(), ircvfileopen(), ircvrollback(), isbuild(), isdelindex(), isopen(), isrecover(), ivbclose3(), and vvbkeyunmalloc().

60 {
61  if (mptr) {
62  free (mptr);
63  }
64 }

Here is the caller graph for this function:

void vvbkeyallfree ( const int  ihandle,
const int  ikeynumber,
struct VBTREE pstree 
)

Definition at line 143 of file vbmemio.c.

References VBTREE::ikeysinnode, NULL, VBKEY::pschild, VBTREE::pskeycurr, VBTREE::pskeyfirst, DICTINFO::pskeyfree, VBTREE::pskeylast, VBKEY::psnext, psvbfile, VBKEY::trownode, vb_error, and vvbtreeallfree().

Referenced by ichecktree(), and vvbtreeallfree().

144 {
145  struct DICTINFO *psvbptr;
146  struct VBKEY *pskeycurr;
147  struct VBKEY *pskeynext;
148 
149  psvbptr = psvbfile[ihandle];
150  pskeycurr = pstree->pskeyfirst;
151  while (pskeycurr) {
152  if (pskeycurr->trownode == -1) {
153  vb_error ("Keyfreed already free");
154  }
155  pskeynext = pskeycurr->psnext;
156  if (pskeycurr->pschild) {
157  vvbtreeallfree (ihandle, ikeynumber, pskeycurr->pschild);
158  }
159  pskeycurr->pschild = NULL;
160  pskeycurr->psnext = psvbptr->pskeyfree[ikeynumber];
161  psvbptr->pskeyfree[ikeynumber] = pskeycurr;
162  pskeycurr->trownode = -1;
163  pskeycurr = pskeynext;
164  }
165  pstree->pskeyfirst = NULL;
166  pstree->pskeylast = NULL;
167  pstree->pskeycurr = NULL;
168  pstree->ikeysinnode = 0;
169 }
#define vb_error(x)
Definition: vbmemio.c:41
struct VBTREE * pschild
Definition: isinternal.h:327
struct VBKEY * pskeylast
Definition: isinternal.h:341
struct VBKEY * pskeycurr
Definition: isinternal.h:342
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
off_t trownode
Definition: isinternal.h:328
unsigned int ikeysinnode
Definition: isinternal.h:346
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

void vvbkeyfree ( const int  ihandle,
const int  ikeynumber,
struct VBKEY pskey 
)

Definition at line 172 of file vbmemio.c.

References NULL, VBKEY::pschild, DICTINFO::pskeyfree, VBKEY::psnext, VBKEY::psprev, psvbfile, VBKEY::trownode, vb_error, and vvbtreeallfree().

Referenced by ivbkeydelete(), and ivbnodeload().

173 {
174  struct DICTINFO *psvbptr;
175 
176  if (pskey->trownode == -1) {
177  vb_error ("Keyfreed already free");
178  }
179  psvbptr = psvbfile[ihandle];
180  if (pskey->pschild) {
181  vvbtreeallfree (ihandle, ikeynumber, pskey->pschild);
182  }
183  pskey->pschild = NULL;
184  if (pskey->psnext) {
185  pskey->psnext->psprev = pskey->psprev;
186  }
187  if (pskey->psprev) {
188  pskey->psprev->psnext = pskey->psnext;
189  }
190  pskey->psnext = psvbptr->pskeyfree[ikeynumber];
191  psvbptr->pskeyfree[ikeynumber] = pskey;
192  pskey->trownode = -1;
193 }
#define vb_error(x)
Definition: vbmemio.c:41
struct VBTREE * pschild
Definition: isinternal.h:327
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
off_t trownode
Definition: isinternal.h:328
struct VBKEY * psprev
Definition: isinternal.h:325
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

void vvbkeyunmalloc ( const int  ihandle,
const int  ikeynumber 
)

Definition at line 196 of file vbmemio.c.

References DICTINFO::pskeyfree, VBKEY::psnext, psvbfile, and vvbfree().

Referenced by isdelindex(), and ivbclose3().

197 {
198  struct DICTINFO *psvbptr;
199  struct VBKEY *pskeycurr;
200 /* RXW
201  int ilength;
202 */
203 
204  psvbptr = psvbfile[ihandle];
205  pskeycurr = psvbptr->pskeyfree[ikeynumber];
206 /* RXW
207  ilength = sizeof (struct VBKEY) + psvbptr->pskeydesc[ikeynumber]->k_len;
208 */
209  while (pskeycurr) {
210  psvbptr->pskeyfree[ikeynumber] =
211  psvbptr->pskeyfree[ikeynumber]->psnext;
212  vvbfree (pskeycurr);
213  pskeycurr = psvbptr->pskeyfree[ikeynumber];
214  }
215 }
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbfree(void *mptr)
Definition: vbmemio.c:59
struct VBKEY * psnext
Definition: isinternal.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

void vvbkeyvalueset ( const int  ihigh,
struct keydesc *  pskeydesc,
unsigned char *  pckeyvalue 
)

Definition at line 659 of file vbkeysio.c.

References inl_stint(), inl_stlong(), QUADSIZE, stdbl(), and stfloat().

Referenced by inewroot(), ivbkeysearch(), and ivbnodeload().

660 {
661  struct keypart *pskptr;
662  int ipart, iremainder;
663  char cbuffer[QUADSIZE];
664 
665  for (ipart = 0; ipart < pskeydesc->k_nparts; ipart++) {
666  pskptr = &pskeydesc->k_part[ipart];
667  switch (pskptr->kp_type & ~ISDESC) {
668  case CHARTYPE:
669  memset (pckeyvalue, ihigh ? 0xff : 0, (size_t)pskptr->kp_leng);
670  pckeyvalue += pskptr->kp_leng;
671  break;
672 
673  case INTTYPE:
674  iremainder = pskptr->kp_leng;
675  while (iremainder > 0) {
676  inl_stint (ihigh ? SHRT_MAX : SHRT_MIN, pckeyvalue);
677  pckeyvalue += INTSIZE;
678  iremainder -= INTSIZE;
679  }
680  break;
681 
682  case LONGTYPE:
683  iremainder = pskptr->kp_leng;
684  while (iremainder > 0) {
685  inl_stlong (ihigh ? LONG_MAX : LONG_MIN, pckeyvalue);
686  pckeyvalue += LONGSIZE;
687  iremainder -= LONGSIZE;
688  }
689  break;
690 
691  case QUADTYPE:
692  memset (cbuffer, ihigh ? 0xff : 0, QUADSIZE);
693  cbuffer[0] = ihigh ? 0x7f : 0x80;
694  iremainder = pskptr->kp_leng;
695  while (iremainder > 0) {
696  memcpy (pckeyvalue, cbuffer, QUADSIZE);
697  pckeyvalue += QUADSIZE;
698  iremainder -= QUADSIZE;
699  }
700  break;
701 
702  case FLOATTYPE:
703  iremainder = pskptr->kp_leng;
704  while (iremainder > 0) {
705  stfloat (ihigh ? FLT_MAX : FLT_MIN, pckeyvalue);
706  pckeyvalue += FLOATSIZE;
707  iremainder -= FLOATSIZE;
708  }
709  break;
710 
711  case DOUBLETYPE:
712  iremainder = pskptr->kp_leng;
713  while (iremainder > 0) {
714  stdbl (ihigh ? DBL_MAX : DBL_MIN, pckeyvalue);
715  pckeyvalue += DOUBLESIZE;
716  iremainder -= DOUBLESIZE;
717  }
718  break;
719 
720  default:
721  break;
722  }
723  }
724 }
void stdbl(double dsource, void *pcdestination)
Definition: ishelper.c:513
static void inl_stlong(int lvalue, void *pclocation)
Definition: isinternal.h:226
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
void stfloat(double dsource, void *pcdestination)
Definition: ishelper.c:476
#define QUADSIZE
Definition: isinternal.h:108

Here is the call graph for this function:

Here is the caller graph for this function:

void vvblockfree ( struct VBLOCK pslock)

Definition at line 81 of file vbmemio.c.

References pslockfree, and VBLOCK::psnext.

Referenced by ilockdelete(), and ivbclose2().

82 {
83  pslock->psnext = pslockfree;
84  pslockfree = pslock;
85 }
struct VBLOCK * psnext
Definition: isinternal.h:318
static struct VBLOCK * pslockfree
Definition: vbmemio.c:22

Here is the caller graph for this function:

void vvbmakekey ( const struct keydesc *  pskeydesc,
char *  pcrow_buffer,
unsigned char *  pckeyvalue 
)

Definition at line 212 of file vbkeysio.c.

Referenced by imakekeysfromdata(), irowinsert(), irowupdate(), isdelete(), isread(), isrewrite(), isstart(), ivbkeylocaterow(), and vaddkeyforrow().

214 {
215  const struct keypart *pskptr;
216  char *pcsource;
217  int ipart;
218 
219  /* Wierdly enough, a single keypart *CAN* span multiple instances */
220  /* EG: Part number 1 might contain 4 long values */
221  for (ipart = 0; ipart < pskeydesc->k_nparts; ipart++) {
222  pskptr = &pskeydesc->k_part[ipart];
223  pcsource = pcrow_buffer + pskptr->kp_start;
224  memcpy (pckeyvalue, pcsource, (size_t)pskptr->kp_leng);
225  pckeyvalue += pskptr->kp_leng;
226  }
227 }

Here is the caller graph for this function:

void vvbtreeallfree ( const int  ihandle,
const int  ikeynumber,
struct VBTREE pstree 
)

Definition at line 105 of file vbmemio.c.

References VBTREE::psnext, pstreefree, VBTREE::tnodenumber, vb_error, and vvbkeyallfree().

Referenced by iindexcheck(), isdelindex(), itreeload(), ivbclose3(), ivbenter(), ivbexit(), ivbkeydelete(), ivbkeyload(), ivbnodeload(), vvbkeyallfree(), and vvbkeyfree().

106 {
107  if (!pstree) {
108  return;
109  }
110  if (pstree->tnodenumber == -1) {
111  vb_error ("Treefreed not free");
112  }
113  vvbkeyallfree (ihandle, ikeynumber, pstree);
114  pstree->psnext = pstreefree;
115  pstreefree = pstree;
116  pstree->tnodenumber = -1;
117 }
static struct VBTREE * pstreefree
Definition: vbmemio.c:23
#define vb_error(x)
Definition: vbmemio.c:41
struct VBTREE * psnext
Definition: isinternal.h:338
off_t tnodenumber
Definition: isinternal.h:343
void vvbkeyallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:143

Here is the call graph for this function:

Here is the caller graph for this function:

void vvbunmalloc ( void  )

Variable Documentation

struct DICTINFO* psvbfile[128+1]

Definition at line 23 of file vblowlevel.c.

Referenced by iaddkeydescriptor(), icheckkey(), icheckkeydesc(), idatafreecheck(), idelnodes(), idemotelocks(), iindexcheck(), iindexfreecheck(), ilockdelete(), ilockinsert(), imakekeysfromdata(), inewroot(), inodesplit(), ipostamble(), ipreamble(), iprocessdelete(), iquicknodesave(), ircvcreateindex(), ircvdeleteindex(), ircvinsert(), ircvuniqueid(), irowdelete(), irowinsert(), irowupdate(), isaddindex(), isbuild(), ischeck(), iscleanup(), isclose(), iscommit(), isdelcurr(), isdelete(), isdelindex(), isdelrec(), isdi_curidx(), isdi_datfd(), isdi_datlen(), isdi_idxfd(), isdi_kdsc(), isdi_name(), iserase(), isflush(), isindexinfo(), islock(), isopen(), isread(), isrecover(), isrelcurr(), isrelease(), isrelrec(), isrewcurr(), isrewrec(), isrewrite(), isrollback(), issetcollate(), issetunique(), isstart(), istartrownumber(), isuniqueid(), isunlock(), iswrcurr(), iswrite(), itreeload(), ivbcheckkey(), ivbclose2(), ivbclose3(), ivbdatafree(), ivbdatalock(), ivbdataread(), ivbdatawrite(), ivbenter(), ivbexit(), ivbfileopenlock(), ivbforcedataallocate(), ivbforceexit(), ivbkeycompare(), ivbkeydelete(), ivbkeyinsert(), ivbkeyload(), ivbkeylocaterow(), ivbkeysearch(), ivbnodefree(), ivbnodeload(), ivbnodesave(), ivbrollmeback(), ivbrollmeforward(), ivbtransclose(), ivbtranscreateindex(), ivbtransdelete(), ivbtransdeleteindex(), ivbtransinsert(), ivbtransopen(), ivbtranssetunique(), ivbtransuniqueid(), ivbtransupdate(), ivbvarlendelete(), ivbvarlenread(), ivbvarlenwrite(), ivbwriterow(), psvbkeyallocate(), tdelkeydescriptor(), ttailnode(), tvbdataallocate(), tvbdatacountgetnext(), tvbnodeallocate(), tvbnodecountgetnext(), vaddkeyforrow(), vcloseall(), vrebuildindexfree(), vvbkeyallfree(), vvbkeyfree(), and vvbkeyunmalloc().

struct VBFILE svbfile[128 *3]