--- src/backend/access/transam/xlog.c.orig Mon Feb 25 11:04:39 2002 +++ src/backend/access/transam/xlog.c Tue Feb 26 14:33: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,total_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,56 @@ 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 ; + total_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 ; + total_size=BLCKSZ ; + type=1; + }else + { + if(ispartialpage) + { + type=2; + data_size=WriteRqst.Write.xrecoff-current_xrecoff; + if ( (offset+data_size+sizeof(XLogRecord)) <= BLCKSZ) + { + total_size=data_size+sizeof(XLogRecord); type=5; + }else + { + total_size=BLCKSZ-offset; + } + }else + { + data_size=BLCKSZ-(current_xrecoff-((current_xrecoff/BLCKSZ)*BLCKSZ)); + total_size=data_size; + type=3; + } + } + current_xrecoff=current_xrecoff+data_size; + if (XLOG_DEBUG) + elog(DEBUG,"XLogWrite type:%d from:%x(%d) data size:%d totalsize:%d Fileoffset:%d \n",type,from,from,data_size,total_size,openLogOff); + first_time=0; + } errno = 0; - if (write(openLogFile, from, BLCKSZ) != BLCKSZ) + if (write(openLogFile, from, total_size) != total_size) { /* if write didn't set errno, assume problem is no disk space */ if (errno == 0) @@ -1100,7 +1138,7 @@ elog(STOP, "write of log file %u, segment %u, offset %u failed: %m", openLogId, openLogSeg, openLogOff); } - openLogOff += BLCKSZ; + openLogOff += total_size; /* * If we just wrote the whole last page of a logfile segment,