Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improvements to OS layer tracing on the unix backend. (CVS 3664) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3ad96dbe09b99bd5f623de0de3072a25 |
User & Date: | drh 2007-02-27 02:01:14.000 |
Context
2007-02-28
| ||
04:47 | Add the undocumented and experimental I/O tracing interface. This interface is likely to change and may be completely abandoned in the near future. (CVS 3665) (check-in: 007ca28389 user: drh tags: trunk) | |
2007-02-27
| ||
02:01 | Improvements to OS layer tracing on the unix backend. (CVS 3664) (check-in: 3ad96dbe09 user: drh tags: trunk) | |
2007-02-24
| ||
15:29 | Add comments to sqlite3ExprCompare() to clarify its operation. Ticket #2216. (CVS 3663) (check-in: fba0a1e508 user: drh tags: trunk) | |
Changes
Changes to src/os_unix.c.
︙ | ︙ | |||
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | /* ** Seek to the offset in id->offset then read cnt bytes into pBuf. ** Return the number of bytes actually read. Update the offset. */ static int seekAndRead(unixFile *id, void *pBuf, int cnt){ int got; i64 newOffset; #ifdef USE_PREAD got = pread(id->h, pBuf, cnt, id->offset); #else newOffset = lseek(id->h, id->offset, SEEK_SET); if( newOffset!=id->offset ){ return -1; } got = read(id->h, pBuf, cnt); #endif if( got>0 ){ id->offset += got; } return got; } /* ** Read data from a file into a buffer. Return SQLITE_OK if all ** bytes were read successfully and SQLITE_IOERR if anything goes ** wrong. */ static int unixRead(OsFile *id, void *pBuf, int amt){ int got; assert( id ); | > > > < < < < < > > > < < < < < < | 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 | /* ** Seek to the offset in id->offset then read cnt bytes into pBuf. ** Return the number of bytes actually read. Update the offset. */ static int seekAndRead(unixFile *id, void *pBuf, int cnt){ int got; i64 newOffset; TIMER_START; #ifdef USE_PREAD got = pread(id->h, pBuf, cnt, id->offset); #else newOffset = lseek(id->h, id->offset, SEEK_SET); if( newOffset!=id->offset ){ return -1; } got = read(id->h, pBuf, cnt); #endif TIMER_END; TRACE5("READ %-3d %5d %7lld %d\n", id->h, got, id->offset, TIMER_ELAPSED); if( got>0 ){ id->offset += got; } return got; } /* ** Read data from a file into a buffer. Return SQLITE_OK if all ** bytes were read successfully and SQLITE_IOERR if anything goes ** wrong. */ static int unixRead(OsFile *id, void *pBuf, int amt){ int got; assert( id ); got = seekAndRead((unixFile*)id, pBuf, amt); SimulateIOError( got = -1 ); if( got==amt ){ return SQLITE_OK; }else if( got<0 ){ return SQLITE_IOERR_READ; }else{ memset(&((char*)pBuf)[got], 0, amt-got); return SQLITE_IOERR_SHORT_READ; } } /* ** Seek to the offset in id->offset then read cnt bytes into pBuf. ** Return the number of bytes actually read. Update the offset. */ static int seekAndWrite(unixFile *id, const void *pBuf, int cnt){ int got; i64 newOffset; TIMER_START; #ifdef USE_PREAD got = pwrite(id->h, pBuf, cnt, id->offset); #else newOffset = lseek(id->h, id->offset, SEEK_SET); if( newOffset!=id->offset ){ return -1; } got = write(id->h, pBuf, cnt); #endif TIMER_END; TRACE5("WRITE %-3d %5d %7lld %d\n", id->h, got, id->offset, TIMER_ELAPSED); if( got>0 ){ id->offset += got; } return got; } /* ** Write data from a buffer into a file. Return SQLITE_OK on success ** or some other error code on failure. */ static int unixWrite(OsFile *id, const void *pBuf, int amt){ int wrote = 0; assert( id ); assert( amt>0 ); while( amt>0 && (wrote = seekAndWrite((unixFile*)id, pBuf, amt))>0 ){ amt -= wrote; pBuf = &((char*)pBuf)[wrote]; } SimulateIOError(( wrote=(-1), amt=1 )); SimulateDiskfullError(( wrote=0, amt=1 )); if( amt>0 ){ if( wrote<0 ){ return SQLITE_IOERR_WRITE; }else{ return SQLITE_FULL; } } return SQLITE_OK; } /* ** Move the read/write pointer in a file. */ static int unixSeek(OsFile *id, i64 offset){ assert( id ); #ifdef SQLITE_TEST if( offset ) SimulateDiskfullError(return SQLITE_FULL); #endif ((unixFile*)id)->offset = offset; return SQLITE_OK; } |
︙ | ︙ |