GnuCOBOL  2.0
A free COBOL compiler
istrans.c File Reference
#include "isinternal.h"
Include dependency graph for istrans.c:

Go to the source code of this file.

Functions

static void vinitpiduid (void)
 
static void vtranshdr (const char *pctranstype)
 
static int iwritetrans (int itranslength, const int irollback)
 
static int iwritebegin (void)
 
static int idemotelocks (void)
 
static int ivbrollmeback (off_t toffset, const int iinrecover)
 
static int ivbrollmeforward (off_t toffset)
 
int isbegin (void)
 
int iscommit (void)
 
int islogclose (void)
 
int islogopen (const char *pcfilename)
 
int isrollback (void)
 
int ivbtransbuild (const char *pcfilename, const int iminrowlen, const int imaxrowlen, struct keydesc *pskeydesc, const int imode)
 
int ivbtranscreateindex (int const ihandle, struct keydesc *pskeydesc)
 
int ivbtranscluster ()
 
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)
 

Variables

int ivbintrans = 0
 
int ivblogfilehandle = -1
 
static struct SLOGHDRpsvblogheader
 
static pid_t tvbpid
 
static uid_t tvbuid
 
static char cvbtransbuffer [65536]
 

Function Documentation

static int idemotelocks ( void  )
static

Definition at line 167 of file istrans.c.

References DICTINFO::iisdatalocked, DICTINFO::iisopen, DICTINFO::iopenmode, iserrno, ivbdatalock(), ivbmaxusedhandle, psvbfile, and VBUNLOCK.

Referenced by iscommit(), and isrollback().

168 {
169  struct DICTINFO *psvbptr;
170  int ihandle, iresult = 0;
171 
172  for (ihandle = 0; ihandle <= ivbmaxusedhandle; ihandle++) {
173  psvbptr = psvbfile[ihandle];
174  if (!psvbptr || psvbptr->iisopen == 2) {
175  continue;
176  }
177  if (psvbptr->iopenmode & ISEXCLLOCK) {
178  continue;
179  }
180  if (psvbptr->iisdatalocked) {
181  continue;
182  }
183  /* Rather a carte-blanche method huh? */
184  if (ivbdatalock (ihandle, VBUNLOCK, (off_t)0)) { /* BUG Only ours? */
185  iresult = -1;
186  }
187  }
188  if (iresult) {
189  iserrno = EBADFILE;
190  }
191  return iresult;
192 }
int ivbmaxusedhandle
Definition: vblocking.c:26
int iisopen
Definition: isinternal.h:407
int ivbdatalock(const int ihandle, const int imode, const off_t trownumber)
Definition: vblocking.c:432
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
unsigned char iisdatalocked
Definition: isinternal.h:426
int iopenmode
Definition: isinternal.h:412
#define VBUNLOCK
Definition: isinternal.h:294
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int isbegin ( void  )

Definition at line 448 of file istrans.c.

References iserrno, ivbintrans, ivblogfilehandle, and VBBEGIN.

449 {
450  if (ivblogfilehandle < 0) {
451  iserrno = ELOGOPEN;
452  return -1;
453  }
454  /* If we're already *IN* a transaction, don't start another! */
455  if (ivbintrans) {
456  return 0;
457  }
458  ivbintrans = VBBEGIN; /* Just flag that we've BEGUN */
459  return 0;
460 }
#define VBBEGIN
Definition: isinternal.h:307
int ivblogfilehandle
Definition: istrans.c:24
int ivbintrans
Definition: istrans.c:23
int iserrno
Definition: vbmemio.c:27
int iscommit ( void  )

Definition at line 463 of file istrans.c.

References idemotelocks(), DICTINFO::iisopen, iserrno, ivbclose2(), ivbintrans, ivblogfilehandle, ivbmaxusedhandle, ivbrollmeforward(), iwritetrans(), psvbfile, tvblseek(), VBBEGIN, VBCOMMIT, VBL_COMMIT, VBNOTRANS, vinitpiduid(), and vtranshdr().

464 {
465  struct DICTINFO *psvbptr;
466  off_t toffset;
467  int iholdstatus = ivbintrans, iloop, iresult = 0;
468 
469  iserrno = 0;
470  if (ivblogfilehandle == -1) {
471  return 0;
472  }
473  if (!ivbintrans) {
474  iserrno = ENOBEGIN;
475  return -1;
476  }
477  vinitpiduid ();
479  if (iholdstatus != VBBEGIN) {
480  toffset = tvblseek (ivblogfilehandle, (off_t)0, SEEK_END);
481  iserrno = ivbrollmeforward (toffset);
482  }
483  for (iloop = 0; iloop <= ivbmaxusedhandle; iloop++) {
484  psvbptr = psvbfile[iloop];
485  if (psvbptr && psvbptr->iisopen == 1) {
486  iresult = iserrno;
487  if (!ivbclose2 (iloop)) {
488  iserrno = iresult;
489  }
490  }
491  }
492  /* Don't write out a 'null' transaction! */
493  if (iholdstatus != VBBEGIN) {
495  iresult = iwritetrans (0, 1);
496  if (iresult) {
497  iserrno = iresult;
498  }
499  idemotelocks ();
500  }
502  if (iserrno) {
503  return -1;
504  }
505  return 0;
506 }
static void vinitpiduid(void)
Definition: istrans.c:34
#define VBBEGIN
Definition: isinternal.h:307
#define VBL_COMMIT
Definition: isinternal.h:472
static int idemotelocks(void)
Definition: istrans.c:167
static int ivbrollmeforward(off_t toffset)
Definition: istrans.c:334
#define VBCOMMIT
Definition: isinternal.h:309
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
#define VBNOTRANS
Definition: isinternal.h:306
int ivbmaxusedhandle
Definition: vblocking.c:26
int iisopen
Definition: isinternal.h:407
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
int ivbclose2(const int ihandle)
Definition: isopen.c:83
off_t tvblseek(const int ihandle, off_t toffset, const int iwhence)
Definition: vblowlevel.c:107

Here is the call graph for this function:

int islogclose ( void  )

Definition at line 509 of file istrans.c.

References iserrno, isrollback(), ivbclose(), ivbintrans, ivblogfilehandle, VBNEEDFLUSH, and VBNOTRANS.

Referenced by iscleanup(), and islogopen().

510 {
511  int iresult = 0;
512 
513  if (ivbintrans == VBNEEDFLUSH) {
514  if (isrollback ()) {
515  iresult = iserrno;
516  }
517  }
519  if (ivblogfilehandle != -1) {
520  if (ivbclose (ivblogfilehandle)) {
521  iresult = errno;
522  }
523  }
524  ivblogfilehandle = -1;
525  return iresult;
526 }
#define VBNOTRANS
Definition: isinternal.h:306
#define VBNEEDFLUSH
Definition: isinternal.h:308
int isrollback(void)
Definition: istrans.c:543
int ivblogfilehandle
Definition: istrans.c:24
int ivbclose(const int ihandle)
Definition: vblowlevel.c:93
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 islogopen ( const char *  pcfilename)

Definition at line 529 of file istrans.c.

References iserrno, islogclose(), ivblogfilehandle, ivbopen(), and O_BINARY.

530 {
531  if (ivblogfilehandle != -1) {
532  islogclose (); /* Ignore the return value! */
533  }
534  ivblogfilehandle = ivbopen (pcfilename, O_RDWR | O_BINARY, 0);
535  if (ivblogfilehandle < 0) {
536  iserrno = ELOGOPEN;
537  return -1;
538  }
539  return 0;
540 }
int ivbopen(const char *pcfilename, const int iflags, const mode_t tmode)
Definition: vblowlevel.c:32
#define O_BINARY
Definition: fileio.c:90
int ivblogfilehandle
Definition: istrans.c:24
int islogclose(void)
Definition: istrans.c:509
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

int isrollback ( void  )

Definition at line 543 of file istrans.c.

References idemotelocks(), DICTINFO::iisdictlocked, DICTINFO::iisopen, iserrno, ivbclose2(), ivbexit(), ivbintrans, ivblogfilehandle, ivbmaxusedhandle, ivbrollmeback(), iwritetrans(), psvbfile, tvblseek(), VBBEGIN, VBL_ROLLBACK, VBNOTRANS, VBROLLBACK, vinitpiduid(), and vtranshdr().

Referenced by islogclose().

544 {
545  struct DICTINFO *psvbptr;
546  off_t toffset;
547  int iloop, iresult = 0;
548 
549  if (ivblogfilehandle < 0) {
550  return 0;
551  }
552  if (!ivbintrans) {
553  iserrno = ENOBEGIN;
554  return -1;
555  }
556  vinitpiduid ();
557  /* Don't write out a 'null' transaction! */
558  for (iloop = 0; iloop <= ivbmaxusedhandle; iloop++) {
559  psvbptr = psvbfile[iloop];
560  if (psvbptr && psvbptr->iisopen == 1) {
561  iresult = iserrno;
562  if (!ivbclose2 (iloop)) {
563  iserrno = iresult;
564  }
565  iresult = 0;
566  }
567  }
568  if (ivbintrans == VBBEGIN) {
569  return 0;
570  }
572  toffset = tvblseek (ivblogfilehandle, (off_t)0, SEEK_END);
573  /* Write out the log entry */
575  iserrno = iwritetrans (0, 1);
576  if (!iserrno) {
577  iserrno = ivbrollmeback (toffset, 0);
578  }
579  idemotelocks ();
581  if (iserrno) {
582  return -1;
583  }
584  for (iloop = 0; iloop <= ivbmaxusedhandle; iloop++) {
585  psvbptr = psvbfile[iloop];
586  if (psvbptr && psvbptr->iisopen == 1) {
587  if (ivbclose2 (iloop)) {
588  iresult = iserrno;
589  }
590  }
591  if (psvbptr && psvbptr->iisdictlocked & 0x04) {
592  iresult |= ivbexit (iloop);
593  }
594  }
595  return (iresult ? -1 : 0);
596 }
static void vinitpiduid(void)
Definition: istrans.c:34
#define VBBEGIN
Definition: isinternal.h:307
static int idemotelocks(void)
Definition: istrans.c:167
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
#define VBNOTRANS
Definition: isinternal.h:306
int ivbmaxusedhandle
Definition: vblocking.c:26
int iisopen
Definition: isinternal.h:407
unsigned char iisdictlocked
Definition: isinternal.h:427
static int ivbrollmeback(off_t toffset, const int iinrecover)
Definition: istrans.c:195
#define VBL_ROLLBACK
Definition: isinternal.h:480
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivblogfilehandle
Definition: istrans.c:24
int ivbexit(const int ihandle)
Definition: vblocking.c:290
#define VBROLLBACK
Definition: isinternal.h:310
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53
int ivbintrans
Definition: istrans.c:23
int iserrno
Definition: vbmemio.c:27
int ivbclose2(const int ihandle)
Definition: isopen.c:83
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:

static int ivbrollmeback ( off_t  toffset,
const int  iinrecover 
)
static

Definition at line 195 of file istrans.c.

References SLOGHDR::coperation, SLOGHDR::cpid, cvbtransbuffer, DICTINFO::iisdictlocked, inl_ldint(), inl_ldquad(), isclose(), isdelrec(), iserrno, isopen(), isreclen, isrewrec(), ivbdatafree(), ivbenter(), ivbexit(), ivbforcedataallocate(), ivblogfilehandle, ivbwriterow(), psvbfile, QUADSIZE, DICTINFO::trownumber, tvblseek(), tvbpid, tvbread(), VB_MAX_FILES, VBL_BEGIN, VBL_DELETE, VBL_FILECLOSE, VBL_FILEOPEN, VBL_INSERT, and VBL_UPDATE.

Referenced by isrollback().

196 {
197  char *pcbuffer, *pcrow;
198  off_t tlength, trownumber;
199  int iloop;
200  int ierrorencountered = 0;
201  int ifoundbegin = 0;
202  int ihandle;
203  int ilocalhandle[VB_MAX_FILES + 1];
204  int isavedhandle[VB_MAX_FILES + 1];
205 
206  for (iloop = 0; iloop <= VB_MAX_FILES; iloop++) {
207  if (psvbfile[iloop]) {
208  ilocalhandle[iloop] = iloop;
209  } else {
210  ilocalhandle[iloop] = -1;
211  }
212  isavedhandle[iloop] = ilocalhandle[iloop];
213  }
214  psvblogheader = (struct SLOGHDR *)(cvbtransbuffer + INTSIZE);
215  pcbuffer = cvbtransbuffer + INTSIZE + sizeof (struct SLOGHDR);
216  /* Begin by reading the footer of the previous transaction */
217  toffset -= INTSIZE;
218  if (tvblseek (ivblogfilehandle, toffset, SEEK_SET) != toffset) {
219  return EBADFILE;
220  }
221  if (tvbread (ivblogfilehandle, cvbtransbuffer, INTSIZE) != INTSIZE) {
222  return EBADFILE;
223  }
224  /* Now, recurse backwards */
225  while (!ifoundbegin) {
226  tlength = inl_ldint (cvbtransbuffer);
227  if (!tlength) {
228  return EBADFILE;
229  }
230  toffset -= tlength;
231  /* Special case: Handle where the FIRST log entry is our BW */
232  if (toffset == -(INTSIZE)) {
233  if (tvblseek (ivblogfilehandle, (off_t)0, SEEK_SET) != 0) {
234  return EBADFILE;
235  }
236  if (tvbread (ivblogfilehandle, cvbtransbuffer + INTSIZE,
237  tlength - INTSIZE) != tlength - INTSIZE) {
238  return EBADFILE;
239  }
240  if (!memcmp (psvblogheader->coperation, VBL_BEGIN, 2)) {
241  break;
242  }
243  return EBADFILE;
244  } else {
245  if (toffset < INTSIZE) {
246  return EBADFILE;
247  }
248  if (tvblseek (ivblogfilehandle, toffset, SEEK_SET) != toffset) {
249  return EBADFILE;
250  }
251  if (tvbread (ivblogfilehandle, cvbtransbuffer, tlength) != tlength) {
252  return EBADFILE;
253  }
254  }
255  /* Is it OURS? */
256  if (inl_ldint (psvblogheader->cpid) != tvbpid) {
257  continue;
258  }
259  if (!memcmp (psvblogheader->coperation, VBL_BEGIN, 2)) {
260  break;
261  }
262  ihandle = inl_ldint (pcbuffer);
263  trownumber = inl_ldquad (pcbuffer + INTSIZE);
264  if (!memcmp (psvblogheader->coperation, VBL_FILECLOSE, 2)) {
265  if (ilocalhandle[ihandle] != -1 && psvbfile[ihandle]->iisopen == 0) {
266  return EBADFILE;
267  }
268  iloop = inl_ldint (pcbuffer + INTSIZE);
269  ilocalhandle[ihandle] =
270  isopen (pcbuffer + INTSIZE + INTSIZE, iloop + ISMANULOCK + ISINOUT);
271  if (ilocalhandle[ihandle] == -1) {
272  return ETOOMANY;
273  }
274  }
275  if (!memcmp (psvblogheader->coperation, VBL_INSERT, 2)) {
276  if (ilocalhandle[ihandle] == -1) {
277  return EBADFILE;
278  }
279  isreclen = inl_ldint (pcbuffer + INTSIZE + QUADSIZE);
280  pcrow = pcbuffer + INTSIZE + QUADSIZE + INTSIZE;
281  memcpy (psvbfile[ilocalhandle[ihandle]]->ppcrowbuffer, pcrow, isreclen);
282  /* BUG? - Should we READ the row first and compare it? */
283  if (isdelrec (ilocalhandle[ihandle], trownumber)) {
284  return iserrno;
285  }
286  }
287  if (!memcmp (psvblogheader->coperation, VBL_UPDATE, 2)) {
288  if (ilocalhandle[ihandle] == -1) {
289  return EBADFILE;
290  }
291  isreclen = inl_ldint (pcbuffer + INTSIZE + QUADSIZE);
292  pcrow = pcbuffer + INTSIZE + QUADSIZE + INTSIZE + INTSIZE;
293  /* BUG? - Should we READ the row first and compare it? */
294  if (isrewrec (ilocalhandle[ihandle], trownumber, pcrow)) {
295  return iserrno;
296  }
297  }
298  if (!memcmp (psvblogheader->coperation, VBL_DELETE, 2)) {
299  if (ilocalhandle[ihandle] == -1) {
300  return EBADFILE;
301  }
302  isreclen = inl_ldint (pcbuffer + INTSIZE + QUADSIZE);
303  pcrow = pcbuffer + INTSIZE + QUADSIZE + INTSIZE;
304  ivbenter (ilocalhandle[ihandle], 1, 0);
305  psvbfile[ilocalhandle[ihandle]]->iisdictlocked |= 0x02;
306  if (iinrecover
307  && ivbforcedataallocate (ilocalhandle[ihandle], trownumber)) {
308  ierrorencountered = EBADFILE;
309  } else {
310  if (ivbwriterow (ilocalhandle[ihandle], pcrow, trownumber)) {
311  ierrorencountered = EDUPL;
312  ivbdatafree (ilocalhandle[ihandle], trownumber);
313  }
314  }
315  ivbexit (ilocalhandle[ihandle]);
316  }
317  if (!memcmp (psvblogheader->coperation, VBL_FILEOPEN, 2)) {
318  if (ilocalhandle[ihandle] == -1) {
319  return EBADFILE;
320  }
321  isclose (ilocalhandle[ihandle]);
322  ilocalhandle[ihandle] = -1;
323  }
324  }
325  for (iloop = 0; iloop <= VB_MAX_FILES; iloop++) {
326  if (isavedhandle[iloop] != -1 && psvbfile[isavedhandle[iloop]]) {
327  isclose (isavedhandle[iloop]);
328  }
329  }
330  return ierrorencountered;
331 }
int ivbforcedataallocate(const int ihandle, const off_t trownumber)
Definition: vbindexio.c:355
#define VBL_FILEOPEN
Definition: isinternal.h:477
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
#define VBL_UPDATE
Definition: isinternal.h:483
static pid_t tvbpid
Definition: istrans.c:27
int ivbdatafree(const int ihandle, const off_t trownumber)
Definition: vbindexio.c:150
int isrewrec(const int ihandle, const long long trownumber, char *pcrow)
Definition: isrewrite.c:298
int isdelrec(const int ihandle, long long trownumber)
Definition: isdelete.c:189
int isreclen
Definition: vbmemio.c:29
static char cvbtransbuffer[65536]
Definition: istrans.c:29
#define VBL_DELETE
Definition: isinternal.h:473
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
Definition: vblocking.c:178
unsigned char iisdictlocked
Definition: isinternal.h:427
int isopen(const char *pcfilename, int imode)
Definition: isopen.c:270
int ivbwriterow(const int ihandle, char *pcrow, const off_t trownumber)
Definition: iswrite.c:85
#define VB_MAX_FILES
Definition: isinternal.h:120
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
char coperation[2]
Definition: isinternal.h:487
char cpid[2]
Definition: isinternal.h:488
int ivblogfilehandle
Definition: istrans.c:24
int ivbexit(const int ihandle)
Definition: vblocking.c:290
#define VBL_INSERT
Definition: isinternal.h:478
int isclose(const int ihandle)
Definition: isopen.c:182
ssize_t tvbread(const int ihandle, void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:117
#define VBL_FILECLOSE
Definition: isinternal.h:476
#define VBL_BEGIN
Definition: isinternal.h:469
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
off_t trownumber
Definition: isinternal.h:416
int iserrno
Definition: vbmemio.c:27
static struct SLOGHDR * psvblogheader
Definition: istrans.c:26
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:

static int ivbrollmeforward ( off_t  toffset)
static

Definition at line 334 of file istrans.c.

References SLOGHDR::coperation, SLOGHDR::cpid, cvbtransbuffer, DICTINFO::iisdictlocked, inl_ldint(), inl_ldquad(), inl_stquad(), isclose(), isopen(), ivbdatafree(), ivbenter(), ivbexit(), ivblogfilehandle, psvbfile, tvblseek(), tvbpid, tvbread(), VB_MAX_FILES, VBL_BEGIN, VBL_DELETE, VBL_FILECLOSE, VBL_FILEOPEN, and vinitpiduid().

Referenced by iscommit().

335 {
336  char *pcbuffer;
337  off_t tlength, trownumber;
338  int ifoundbegin = 0;
339  int ihandle, iloop;
340  int ilocalhandle[VB_MAX_FILES + 1], isavedhandle[VB_MAX_FILES + 1];
341 
342  vinitpiduid ();
343  for (iloop = 0; iloop <= VB_MAX_FILES; iloop++) {
344  if (psvbfile[iloop]) {
345  ilocalhandle[iloop] = iloop;
346  } else {
347  ilocalhandle[iloop] = -1;
348  }
349  isavedhandle[iloop] = ilocalhandle[iloop];
350  }
351  psvblogheader = (struct SLOGHDR *)(cvbtransbuffer + INTSIZE);
352  pcbuffer = cvbtransbuffer + INTSIZE + sizeof (struct SLOGHDR);
353  /* Begin by reading the footer of the previous transaction */
354  toffset -= INTSIZE;
355  if (tvblseek (ivblogfilehandle, toffset, SEEK_SET) != toffset) {
356  return EBADFILE;
357  }
358  if (tvbread (ivblogfilehandle, cvbtransbuffer, INTSIZE) != INTSIZE) {
359  return EBADFILE;
360  }
361  /* Now, recurse backwards */
362  while (!ifoundbegin) {
363  tlength = inl_ldint (cvbtransbuffer);
364  if (!tlength) {
365  return EBADFILE;
366  }
367  toffset -= tlength;
368  /* Special case: Handle where the FIRST log entry is our BW */
369  if (toffset == -(INTSIZE)) {
370  if (tvblseek (ivblogfilehandle, (off_t)0, SEEK_SET) != 0) {
371  return EBADFILE;
372  }
373  if (tvbread (ivblogfilehandle, cvbtransbuffer + INTSIZE,
374  tlength - INTSIZE) != tlength - INTSIZE) {
375  return EBADFILE;
376  }
377  if (!memcmp (psvblogheader->coperation, VBL_BEGIN, 2)) {
378  break;
379  }
380  return EBADFILE;
381  } else {
382  if (toffset < INTSIZE) {
383  return EBADFILE;
384  }
385  if (tvblseek (ivblogfilehandle, toffset, SEEK_SET) != toffset) {
386  return EBADFILE;
387  }
388  if (tvbread (ivblogfilehandle, cvbtransbuffer, tlength) != tlength) {
389  return EBADFILE;
390  }
391  }
392  /* Is it OURS? */
393  if (inl_ldint (psvblogheader->cpid) != tvbpid) {
394  continue;
395  }
396  if (!memcmp (psvblogheader->coperation, VBL_BEGIN, 2)) {
397  break;
398  }
399  ihandle = inl_ldint (pcbuffer);
400  trownumber = inl_ldquad (pcbuffer + INTSIZE);
401  if (!memcmp (psvblogheader->coperation, VBL_FILECLOSE, 2)) {
402  if (ilocalhandle[ihandle] != -1) {
403  return EBADFILE;
404  }
405  iloop = inl_ldint (pcbuffer + INTSIZE);
406  ilocalhandle[ihandle] =
407  isopen (pcbuffer + INTSIZE + INTSIZE, iloop + ISMANULOCK + ISINOUT);
408  if (ilocalhandle[ihandle] == -1) {
409  return ETOOMANY;
410  }
411  }
412  if (!memcmp (psvblogheader->coperation, VBL_DELETE, 2)) {
413  if (ilocalhandle[ihandle] == -1) {
414  return EBADFILE;
415  }
416  ivbenter (ilocalhandle[ihandle], 1, 0);
417  psvbfile[ilocalhandle[ihandle]]->iisdictlocked |= 0x02;
418  if (trownumber ==
419  inl_ldquad (psvbfile[ilocalhandle[ihandle]]->sdictnode.
420  cdatacount)) {
421  psvbfile[ilocalhandle[ihandle]]->iisdictlocked |= 0x02;
422  inl_stquad (trownumber - 1,
423  psvbfile[ilocalhandle[ihandle]]->sdictnode.
424  cdatacount);
425  } else if (ivbdatafree (ilocalhandle[ihandle], trownumber)) {
426  return EBADFILE;
427  }
428  ivbexit (ilocalhandle[ihandle]);
429  }
430  if (!memcmp (psvblogheader->coperation, VBL_FILEOPEN, 2)) {
431  if (ilocalhandle[ihandle] == -1) {
432  return EBADFILE;
433  }
434  isclose (ilocalhandle[ihandle]);
435  }
436  }
437  for (iloop = 0; iloop <= VB_MAX_FILES; iloop++) {
438  if (isavedhandle[iloop] != -1 && psvbfile[isavedhandle[iloop]]) {
439  isclose (isavedhandle[iloop]);
440  }
441  }
442  return 0;
443 }
static void vinitpiduid(void)
Definition: istrans.c:34
#define VBL_FILEOPEN
Definition: isinternal.h:477
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
static pid_t tvbpid
Definition: istrans.c:27
int ivbdatafree(const int ihandle, const off_t trownumber)
Definition: vbindexio.c:150
static char cvbtransbuffer[65536]
Definition: istrans.c:29
#define VBL_DELETE
Definition: isinternal.h:473
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
Definition: vblocking.c:178
unsigned char iisdictlocked
Definition: isinternal.h:427
int isopen(const char *pcfilename, int imode)
Definition: isopen.c:270
#define VB_MAX_FILES
Definition: isinternal.h:120
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
char coperation[2]
Definition: isinternal.h:487
char cpid[2]
Definition: isinternal.h:488
int ivblogfilehandle
Definition: istrans.c:24
int ivbexit(const int ihandle)
Definition: vblocking.c:290
int isclose(const int ihandle)
Definition: isopen.c:182
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
ssize_t tvbread(const int ihandle, void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:117
#define VBL_FILECLOSE
Definition: isinternal.h:476
#define VBL_BEGIN
Definition: isinternal.h:469
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
static struct SLOGHDR * psvblogheader
Definition: istrans.c:26
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 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 ( int const  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:

static int iwritebegin ( void  )
static

Definition at line 136 of file istrans.c.

References iwritetrans(), VBL_BEGIN, and vtranshdr().

Referenced by ivbtransbuild(), ivbtransclose(), ivbtranscreateindex(), ivbtransdelete(), ivbtransdeleteindex(), ivbtranserase(), ivbtransinsert(), ivbtransopen(), ivbtransrename(), ivbtranssetunique(), ivbtransuniqueid(), and ivbtransupdate().

137 {
139  return iwritetrans (0, 1);
140 }
static int iwritetrans(int itranslength, const int irollback)
Definition: istrans.c:89
#define VBL_BEGIN
Definition: isinternal.h:469
static void vtranshdr(const char *pctranstype)
Definition: istrans.c:53

Here is the call graph for this function:

Here is the caller graph for this function:

static int iwritetrans ( int  itranslength,
const int  irollback 
)
static

Definition at line 89 of file istrans.c.

References SLOGHDR::clastlength, SLOGHDR::clastposn, cvbtransbuffer, inl_stint(), ivbintrans, ivblock(), ivblogfilehandle, tvblseek(), tvbwrite(), VBBEGIN, VBNEEDFLUSH, VBUNLOCK, and VBWRLCKW.

Referenced by iscommit(), isrollback(), ivbtransbuild(), ivbtransclose(), ivbtranscreateindex(), ivbtransdelete(), ivbtransdeleteindex(), ivbtranserase(), ivbtransinsert(), ivbtransopen(), ivbtransrename(), ivbtranssetunique(), ivbtransuniqueid(), ivbtransupdate(), and iwritebegin().

90 {
91  static off_t toffset = 0;
92  static int iprevlen = 0;
93  int iresult;
94 
95  itranslength += sizeof (struct SLOGHDR) + INTSIZE;
96  inl_stint (itranslength, cvbtransbuffer);
97  inl_stint (itranslength, cvbtransbuffer + itranslength - INTSIZE);
98  iresult = ivblock (ivblogfilehandle, (off_t)0, (off_t)1, VBWRLCKW);
99  if (iresult) {
100  return ELOGWRIT;
101  }
103  if (irollback) {
104  inl_stint ((int)toffset, psvblogheader->clastposn);
105  inl_stint (iprevlen, psvblogheader->clastlength);
106  toffset = tvblseek (ivblogfilehandle, (off_t)0, SEEK_END);
107  if (toffset == -1) {
108  goto writerr;
109  }
110  iprevlen = itranslength;
111  } else {
114  if (tvblseek (ivblogfilehandle, (off_t)0, SEEK_END) == -1) {
115  goto writerr;
116  }
117  }
118  if (tvbwrite (ivblogfilehandle, (void *)cvbtransbuffer, (size_t) itranslength) !=
119  (ssize_t) itranslength) {
120  goto writerr;
121  }
122  iresult = ivblock (ivblogfilehandle, (off_t)0, (off_t)1, VBUNLOCK);
123  if (iresult) {
124  return ELOGWRIT;
125  }
126  if (ivbintrans == VBBEGIN) {
128  }
129  return 0;
130 writerr:
131  (void)ivblock (ivblogfilehandle, (off_t)0, (off_t)1, VBUNLOCK);
132  return ELOGWRIT;
133 }
ssize_t tvbwrite(const int ihandle, const void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:127
int ivblock(const int ihandle, const off_t toffset, const off_t tlength, const int imode)
Definition: vblowlevel.c:197
#define VBBEGIN
Definition: isinternal.h:307
static char cvbtransbuffer[65536]
Definition: istrans.c:29
char clastposn[2]
Definition: isinternal.h:492
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
#define VBNEEDFLUSH
Definition: isinternal.h:308
#define VBWRLCKW
Definition: isinternal.h:298
int ivblogfilehandle
Definition: istrans.c:24
int ivbintrans
Definition: istrans.c:23
#define VBUNLOCK
Definition: isinternal.h:294
char clastlength[2]
Definition: isinternal.h:493
static struct SLOGHDR * psvblogheader
Definition: istrans.c:26
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:

static void vinitpiduid ( void  )
static

Definition at line 34 of file istrans.c.

References iinitialized, tvbpid, and tvbuid.

Referenced by iscommit(), isrollback(), ivbrollmeforward(), and vtranshdr().

35 {
36  static size_t iinitialized = 0;
37 
38  if (iinitialized) {
39  return;
40  }
41  iinitialized = 1;
42 #ifdef _WIN32
43  tvbpid = GetCurrentProcessId();
44  /* No getuid ? */
45  tvbuid = 1;
46 #else
47  tvbpid = getpid ();
48  tvbuid = getuid ();
49 #endif
50 }
static pid_t tvbpid
Definition: istrans.c:27
static uid_t tvbuid
Definition: istrans.c:28
static int iinitialized
Definition: vblowlevel.c:26

Here is the caller graph for this function:

static void vtranshdr ( const char *  pctranstype)
static

Definition at line 53 of file istrans.c.

References SLOGHDR::coperation, SLOGHDR::cpid, SLOGHDR::crfu1, SLOGHDR::ctime, SLOGHDR::cuid, cvbtransbuffer, inl_stint(), inl_stlong(), NULL, tvbpid, tvbuid, and vinitpiduid().

Referenced by iscommit(), isrollback(), ivbtransbuild(), ivbtransclose(), ivbtranscreateindex(), ivbtransdelete(), ivbtransdeleteindex(), ivbtranserase(), ivbtransinsert(), ivbtransopen(), ivbtransrename(), ivbtranssetunique(), ivbtransuniqueid(), ivbtransupdate(), and iwritebegin().

54 {
55  vinitpiduid ();
57  memcpy (psvblogheader->coperation, pctranstype, 2);
58  inl_stint ((int)tvbpid, psvblogheader->cpid); /* Assumes pid_t is short */
59  inl_stint ((int)tvbuid, psvblogheader->cuid); /* Assumes uid_t is short */
60  inl_stlong (time (NULL), psvblogheader->ctime); /* Assumes time_t is long */
61  inl_stint (0, psvblogheader->crfu1); /* BUG - WTF is this? */
62 }
static void vinitpiduid(void)
Definition: istrans.c:34
char cuid[2]
Definition: isinternal.h:489
static pid_t tvbpid
Definition: istrans.c:27
static char cvbtransbuffer[65536]
Definition: istrans.c:29
static void inl_stlong(int lvalue, void *pclocation)
Definition: isinternal.h:226
char crfu1[2]
Definition: isinternal.h:491
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
char coperation[2]
Definition: isinternal.h:487
char cpid[2]
Definition: isinternal.h:488
static uid_t tvbuid
Definition: istrans.c:28
char ctime[4]
Definition: isinternal.h:490
static struct SLOGHDR * psvblogheader
Definition: istrans.c:26

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct SLOGHDR* psvblogheader
static

Definition at line 26 of file istrans.c.

pid_t tvbpid
static

Definition at line 27 of file istrans.c.

Referenced by ivbrollmeback(), ivbrollmeforward(), vinitpiduid(), and vtranshdr().

uid_t tvbuid
static

Definition at line 28 of file istrans.c.

Referenced by vinitpiduid(), and vtranshdr().