--- src/backend/access/transam/xlog.c.orig Mon Feb 25 11:04:39 2002 +++ src/backend/access/transam/xlog.c Mon Feb 25 12:30:58 2002 @@ -991,16 +991,17 @@ XLogWrite(XLogwrtRqst WriteRqst) { XLogCtlWrite *Write = &XLogCtl->Write; - char *from; + char *from; bool ispartialpage; bool use_existent; - + uint32 data_size,first_time,current_xrecoff; /* * Update local LogwrtResult (caller probably did this already, * but...) */ LogwrtResult = Write->LogwrtResult; - + first_time=1; + current_xrecoff=LogwrtResult.Write.xrecoff; while (XLByteLT(LogwrtResult.Write, WriteRqst.Write)) { /* @@ -1080,19 +1081,46 @@ openLogOff = 0; } - /* Need to seek in the file? */ - if (openLogOff != (LogwrtResult.Write.xrecoff - BLCKSZ) % XLogSegSize) + /* Need to seek in the file? */ + if (openLogOff != (current_xrecoff ) % XLogSegSize) { - openLogOff = (LogwrtResult.Write.xrecoff - BLCKSZ) % XLogSegSize; + openLogOff = (current_xrecoff ) % XLogSegSize; if (lseek(openLogFile, (off_t) openLogOff, SEEK_SET) < 0) elog(STOP, "lseek of log file %u, segment %u, offset %u failed: %m", openLogId, openLogSeg, openLogOff); - } + } /* OK to write the page */ from = XLogCtl->pages + Write->curridx * BLCKSZ; + data_size=BLCKSZ ; + { /* compute the data size to write in to the file */ + int offset; + int type=0; /* used only for display debug info */ + offset= current_xrecoff % BLCKSZ ; + from = XLogCtl->pages + Write->curridx * BLCKSZ +offset ; + if (!ispartialpage && first_time==0) + { + data_size=BLCKSZ ; + type=1; + }else + { + if(ispartialpage) + { + data_size=WriteRqst.Write.xrecoff-current_xrecoff; + type=2; + }else + { + data_size=BLCKSZ-(current_xrecoff-((current_xrecoff/BLCKSZ)*BLCKSZ)); + type=3; + } + } + current_xrecoff=current_xrecoff+data_size; + if (XLOG_DEBUG) + elog(DEBUG,"XLogWrite type:%d from:%x(%d) size:%d Fileoffset:%d \n",type,from,from,data_size,openLogOff); + first_time=0; + } errno = 0; - if (write(openLogFile, from, BLCKSZ) != BLCKSZ) + if (write(openLogFile, from, data_size) != data_size) { /* if write didn't set errno, assume problem is no disk space */ if (errno == 0) @@ -1100,7 +1128,7 @@ elog(STOP, "write of log file %u, segment %u, offset %u failed: %m", openLogId, openLogSeg, openLogOff); } - openLogOff += BLCKSZ; + openLogOff += data_size; /* * If we just wrote the whole last page of a logfile segment,