From: Cees de Groot Date: Wed, 19 Jun 1996 14:47:17 +0200 Subject: [PG95]: [OpenLink] Postgres'95 patches Hi all, Here are two minor patches which may or may not have been fixed yet (I'm very sorry, but this mailing list didn't receive the attention it deserves my me the last couple of months). Please don't start discussing about the fsync () hack. We know quite well what it does, but it makes for very nice demonstrations ;-). The following files are also available in our private source distribution of Postgres'95: - -------------- patches/README In order to keep track of our local changes, we have imported the Postgres source tree into CVS. As a consequence, some files have an incorrect (unofficial) RCS identifier -- Sorry This directory contains the following patches to the Postgres 95 Release 1.01 source tree. To enable the patches, run patch with the diff file and add a define - -DOPENLINK_PATCHES to the master makefile. varchar.diff - ------------ This patch was necessary for the OpenLink Postgres Database Agent. I think this fixes a bug anyway. The following query demonstrates this bug: create table foo (bar varchar); insert into foo values (''); -- no problem select * from foo where bar = ''; -- fails fsync.diff - ---------- This patch adds an option to disable synchronous writes. It adds an extra option to postgres: -F When started with -F, all fsync() calls will be no-ops, so you'll be in big trouble when your machine suddenly crashes and your disk cache is not flushed. Use at your own risk (but it is *much* faster with large inserts) This also speeds up initdb for initial database bootstrapping To start postmaster with this "feature" enabled, type postmaster -o -F -S - -------patches/varchar.diff Index: src/backend/utils/adt/varchar.c =================================================================== RCS file: /usr/home/cvs/postgres95/src/backend/utils/adt/varchar.c,v retrieving revision 1.1.1.1 diff -r1.1.1.1 varchar.c 70a71 > #ifndef OPENLINK_PATCHES 72a74,77 > #else > if (len > 4096) > elog(WARN, "bpcharin: length of char() must be less than 4096"); > #endif 134a140 > #ifndef OPENLINK_PATCHES 136a143,146 > #else > if (len > 4096) > elog(WARN, "varcharin: length of char() must be less than 4096"); > #endif - --------patches/fsync.diff Index: src/backend/bootstrap/bootstrap.c =================================================================== RCS file: /usr/home/cvs/postgres95/src/backend/bootstrap/bootstrap.c,v retrieving revision 1.1.1.1 diff -r1.1.1.1 bootstrap.c 138a139,141 > #ifdef OPENLINK_PATCHES > extern int fsyncOff; /* do not fsync the database */ > #endif 200a204,206 > #ifdef OPENLINK_PATCHES > fprintf(stderr,"Usage: postgres -boot [-d] [-C] [-F] [-O] [-Q] [-P portno] [dbName]\n"); > #else 201a208 > #endif 203a211,213 > #ifdef OPENLINK_PATCHES > fprintf(stderr," F: turn off fsync\n"); > #endif 259c269,272 < - --- > > #ifdef OPENLINK_PATCHES > while ((flag = getopt(argc, argv, "dCOQP:F")) != EOF) { > #else 260a274 > #endif 275a290,295 > break; > #ifdef OPENLINK_PATCHES > case 'F': > fsyncOff = 1; > break; > #endif Index: src/backend/storage/file/fd.c =================================================================== RCS file: /usr/home/cvs/postgres95/src/backend/storage/file/fd.c,v retrieving revision 1.1.1.1 diff -r1.1.1.1 fd.c 193a194,202 > #ifdef OPENLINK_PATCHES > pg_fsync(fd) > { > extern int fsyncOff; > return fsyncOff ? 0 : fsync(fd); > } > #define fsync pg_fsync > #endif > Index: src/backend/storage/smgr/md.c =================================================================== RCS file: /usr/home/cvs/postgres95/src/backend/storage/smgr/md.c,v retrieving revision 1.1.1.1 diff -r1.1.1.1 md.c 474a475,477 > #ifdef OPENLINK_PATCHES > if (write(fd, buffer, BLCKSZ) != BLCKSZ || (pg_fsync(fd) < 0)) > #else 476a480 > #endif Index: src/backend/tcop/postgres.c =================================================================== RCS file: /usr/home/cvs/postgres95/src/backend/tcop/postgres.c,v retrieving revision 1.1.1.1 diff -r1.1.1.1 postgres.c 95a96,99 > #ifdef OPENLINK_PATCHES > int fsyncOff = 0; > #endif > 701a706,708 > #ifdef OPENLINK_PATCHES > fprintf(stderr,"\t[-P portno] [-t tracetype] [-x opttype] [-bCEiLFNopQSs] [dbname]\n"); > #else 702a710 > #endif 710a719,721 > #ifdef OPENLINK_PATCHES > fprintf(stderr, " F: turn off fsync\n"); > #endif 806a818,820 > #ifdef OPENLINK_PATCHES > while ((flag = getopt(argc, argv, "B:bCd:Ef:iLm:MNo:P:pQSst:x:F")) != EOF) > #else 807a822 > #endif 891c906,916 < - --- > > #ifdef OPENLINK_PATCHES > case 'F': > /* -------------------- > * turn off fsync > * -------------------- > */ > fsyncOff = 1; > break; > #endif > Index: src/bin/initdb/initdb.sh =================================================================== RCS file: /home/cvs/postgres95/src/bin/initdb/initdb.sh,v retrieving revision 1.1.1.1 diff -r1.1.1.1 initdb.sh 62c62 < BACKENDARGS="-boot -C -d" - --- > BACKENDARGS="-boot -C -F -d" 64c64 < BACKENDARGS="-boot -C -Q" - --- > BACKENDARGS="-boot -C -F -Q" 219c219 < echo "vacuum" | postgres -Q template1 > /dev/null - --- > echo "vacuum" | postgres -F -Q template1 > /dev/null 222a223,224 > > sync - ---------- Regards Cees de Groot OpenLink Software