Some *very* major changes by darrenk@insightdist.com (Darren King)

==========================================
What follows is a set of diffs that cleans up the usage of BLCKSZ.

As a side effect, the person compiling the code can change the
value of BLCKSZ _at_their_own_risk_.  By that, I mean that I've
tried it here at 4096 and 16384 with no ill-effects.  A value
of 4096 _shouldn't_ affect much as far as the kernel/file system
goes, but making it bigger than 8192 can have severe consequences
if you don't know what you're doing.  16394 worked for me, _BUT_
when I went to 32768 and did an initdb, the SCSI driver broke and
the partition that I was running under went to hell in a hand
basket. Had to reboot and do a good bit of fsck'ing to fix things up.

The patch can be safely applied though.  Just leave BLCKSZ = 8192
and everything is as before.  It basically only cleans up all of the
references to BLCKSZ in the code.

If this patch is applied, a comment in the config.h file though above
the BLCKSZ define with warning about monkeying around with it would
be a good idea.

Darren  darrenk@insightdist.com

(Also cleans up some of the #includes in files referencing BLCKSZ.)
==========================================
This commit is contained in:
Marc G. Fournier 1998-01-13 04:05:12 +00:00
parent f0445dcbc4
commit 374bb5d261
15 changed files with 156 additions and 167 deletions

View File

@ -5,7 +5,7 @@
*
*
* IDENTIFICATION
* $Id: nbtsort.c,v 1.26 1998/01/07 21:01:59 momjian Exp $
* $Id: nbtsort.c,v 1.27 1998/01/13 04:03:41 scrappy Exp $
*
* NOTES
*
@ -49,13 +49,12 @@
#include <fcntl.h>
#include <postgres.h>
#include <utils/memutils.h>
#include <storage/bufpage.h>
#include <access/nbtree.h>
#include <storage/bufmgr.h>
#include "postgres.h"
#include "access/nbtree.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "utils/memutils.h"
#ifndef HAVE_MEMMOVE
#include <regex/utils.h>
@ -64,7 +63,7 @@
#endif
#ifdef BTREE_BUILD_STATS
#include <tcop/tcopprot.h>
#include "tcop/tcopprot.h"
extern int ShowExecutorStats;
#endif
@ -85,7 +84,7 @@ static void _bt_uppershutdown(Relation index, BTPageState *state);
#define FASTBUILD_MERGE
#define MAXTAPES (7)
#define TAPEBLCKSZ (MAXBLCKSZ << 2)
#define TAPEBLCKSZ (BLCKSZ << 2)
#define TAPETEMP "pg_btsortXXXXXX"
extern int NDirectFileRead;
@ -458,7 +457,7 @@ _bt_tapewrite(BTTapeBlock *tape, int eor)
{
tape->bttb_eor = eor;
FileWrite(tape->bttb_fd, (char *) tape, TAPEBLCKSZ);
NDirectFileWrite += TAPEBLCKSZ / MAXBLCKSZ;
NDirectFileWrite += TAPEBLCKSZ / BLCKSZ;
_bt_tapereset(tape);
}
@ -496,7 +495,7 @@ _bt_taperead(BTTapeBlock *tape)
return (0);
}
Assert(tape->bttb_magic == BTTAPEMAGIC);
NDirectFileRead += TAPEBLCKSZ / MAXBLCKSZ;
NDirectFileRead += TAPEBLCKSZ / BLCKSZ;
return (1);
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.33 1998/01/06 19:42:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.34 1998/01/13 04:03:45 scrappy Exp $
*
*
* INTERFACE ROUTINES
@ -23,34 +23,33 @@
*
*-------------------------------------------------------------------------
*/
#include <postgres.h>
#include "postgres.h"
#include "fmgr.h"
#include <catalog/pg_proc.h>
#include <storage/bufmgr.h>
#include <fmgr.h>
#include <access/genam.h>
#include <access/heapam.h>
#include <access/istrat.h>
#include <access/xact.h>
#include <bootstrap/bootstrap.h>
#include <catalog/catname.h>
#include <catalog/catalog.h>
#include <catalog/indexing.h>
#include <catalog/heap.h>
#include <catalog/index.h>
#include <catalog/pg_type.h>
#include <executor/executor.h>
#include <miscadmin.h>
#include <optimizer/clauses.h>
#include <optimizer/prep.h>
#include <parser/parse_func.h>
#include <storage/lmgr.h>
#include <storage/smgr.h>
#include <utils/builtins.h>
#include <utils/mcxt.h>
#include <utils/relcache.h>
#include <utils/syscache.h>
#include <utils/tqual.h>
#include "access/genam.h"
#include "access/heapam.h"
#include "access/istrat.h"
#include "access/xact.h"
#include "bootstrap/bootstrap.h"
#include "catalog/catalog.h"
#include "catalog/catname.h"
#include "catalog/heap.h"
#include "catalog/index.h"
#include "catalog/indexing.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "optimizer/prep.h"
#include "parser/parse_func.h"
#include "storage/lmgr.h"
#include "storage/smgr.h"
#include "utils/builtins.h"
#include "utils/mcxt.h"
#include "utils/relcache.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
#ifndef HAVE_MEMMOVE
#include <regex/utils.h>

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.15 1998/01/07 21:02:52 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.16 1998/01/13 04:03:53 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -31,15 +31,11 @@
#include "postgres.h"
#include "storage/fd.h" /* for SEEK_ */
#include "storage/ipc.h"
#include "storage/bufmgr.h" /* for BLCKSZ */
#include "executor/execdebug.h"
#include "executor/executor.h"
#include "executor/nodeHash.h"
#include "executor/nodeHashjoin.h"
#include "executor/execdebug.h"
#include "utils/palloc.h"
#include "storage/ipc.h"
#include "utils/hsearch.h"
extern int NBuffers;

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.8 1997/09/08 21:43:12 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.9 1998/01/13 04:03:58 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -17,21 +17,14 @@
#include <sys/stat.h>
#include <fcntl.h>
#include "postgres.h"
#include "storage/bufmgr.h" /* for BLCKSZ */
#include "storage/fd.h" /* for SEEK_ */
#include "executor/executor.h"
#include "executor/execdebug.h"
#include "executor/executor.h"
#include "executor/nodeHash.h"
#include "executor/nodeHashjoin.h"
#include "optimizer/clauses.h" /* for get_leftop */
#include "utils/palloc.h"
static TupleTableSlot *
ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, HashJoinState *hjstate);

View File

@ -7,15 +7,15 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.19 1997/09/08 21:44:50 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.20 1998/01/13 04:04:06 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "config.h"
#include <math.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#ifndef MAXINT
@ -27,15 +27,12 @@
#endif
#endif
#include <utils/lsyscache.h>
#include "nodes/relation.h"
#include "optimizer/cost.h"
#include "optimizer/internal.h"
#include "optimizer/keys.h"
#include "optimizer/tlist.h"
#include "storage/bufmgr.h" /* for BLCKSZ */
#include "utils/lsyscache.h"
extern int NBuffers;

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.11 1998/01/07 21:03:56 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.12 1998/01/13 04:04:07 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -19,29 +19,26 @@
#include <string.h>
#include "postgres.h"
#include "nodes/pg_list.h"
#include "nodes/nodes.h"
#include "nodes/primnodes.h"
#include "nodes/relation.h"
#include "utils/elog.h"
#include "utils/palloc.h"
#include "utils/syscache.h"
#include "access/heapam.h"
#include "catalog/pg_language.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "utils/syscache.h"
#include "catalog/pg_language.h"
#include "optimizer/xfunc.h"
#include "optimizer/clauses.h"
#include "optimizer/pathnode.h"
#include "optimizer/internal.h"
#include "optimizer/cost.h"
#include "optimizer/keys.h"
#include "optimizer/tlist.h"
#include "lib/lispsort.h"
#include "access/heapam.h"
#include "tcop/dest.h"
#include "nodes/nodes.h"
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
#include "nodes/relation.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/internal.h"
#include "optimizer/keys.h"
#include "optimizer/pathnode.h"
#include "optimizer/tlist.h" /* for get_expr */
#include "optimizer/xfunc.h"
#include "storage/buf_internals.h" /* for NBuffers */
#include "optimizer/tlist.h" /* for get_expr */
#include "tcop/dest.h"
#include "utils/syscache.h"
#define ever ; 1 ;

View File

@ -7,29 +7,28 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.13 1998/01/07 21:04:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.14 1998/01/13 04:04:12 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#include "postgres.h"
#include "utils/rel.h" /* for Relation stuff */
#include "access/heapam.h" /* access methods like amopenr */
#include "utils/builtins.h"
#include "utils/elog.h" /* for elog */
#include "utils/palloc.h"
#include "utils/lsyscache.h" /* for get_typlen */
#include "nodes/pg_list.h" /* for Lisp support */
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h" /* for Lisp support */
#include "parser/parse_relation.h"
#include "rewrite/locks.h"
#include "rewrite/rewriteDefine.h"
#include "rewrite/rewriteRemove.h"
#include "rewrite/rewriteSupport.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h" /* for get_typlen */
#include "utils/rel.h" /* for Relation stuff */
Oid LastOidProcessed = InvalidOid;
@ -39,7 +38,7 @@ Oid LastOidProcessed = InvalidOid;
*
* should this be smaller?
*/
#define RULE_PLAN_SIZE 8192
#define RULE_PLAN_SIZE BLCKSZ
static void
strcpyq(char *dest, char *source)

View File

@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.16 1998/01/07 21:04:54 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.17 1998/01/13 04:04:20 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -39,7 +39,6 @@
#include "storage/spin.h"
#include "storage/smgr.h"
#include "storage/lmgr.h"
#include "storage/buf_internals.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/hsearch.h"

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.26 1998/01/07 21:05:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.27 1998/01/13 04:04:31 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -20,14 +20,12 @@
#include "postgres.h"
#include "miscadmin.h" /* for DataDir */
#include "catalog/catalog.h"
#include "storage/block.h"
#include "storage/fd.h"
#include "storage/smgr.h" /* where the declarations go */
#include "storage/fd.h"
#include "utils/mcxt.h"
#include "utils/rel.h"
#include "utils/palloc.h"
#include "catalog/catalog.h"
#undef DIAGNOSTIC
@ -59,7 +57,22 @@ static MemoryContext MdCxt;
#define MDFD_DIRTY (uint16) 0x01
#define MDFD_FREE (uint16) 0x02
#define RELSEG_SIZE 262144 /* (2 ** 31) / 8192 -- 2GB file */
/*
* RELSEG_SIZE appears to be the number of segments that can
* be in a disk file. It was defined as 262144 based on 8k
* blocks, but now that the block size can be changed, this
* has to be calculated at compile time. Otherwise, the file
* size limit would not work out to 2-gig (2147483648).
*
* The number needs to be (2 ** 31) / BLCKSZ, but to be keep
* the math under MAXINT, pre-divide by 256 and use ...
*
* (((2 ** 23) / BLCKSZ) * (2 ** 8))
*
* 07 Jan 98 darrenk
*/
#define RELSEG_SIZE ((8388608 / BLCKSZ) * 256)
/* routines declared here */
static MdfdVec *_mdfd_openseg(Relation reln, int segno, int oflags);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.60 1998/01/09 05:48:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.61 1998/01/13 04:04:36 scrappy Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@ -40,54 +40,48 @@
#include "postgres.h"
#include "miscadmin.h"
#include "catalog/catname.h"
#include "fmgr.h"
#include "access/xact.h"
#include "lib/dllist.h"
#include "catalog/catname.h"
#include "commands/async.h"
#include "tcop/tcopprot.h" /* where declarations for this file go */
#include "optimizer/planner.h"
#include "parser/parser.h"
#include "tcop/tcopprot.h"
#include "tcop/tcopdebug.h"
#include "executor/execdebug.h"
#include "executor/executor.h"
#include "lib/dllist.h"
#include "libpq/libpq.h"
#include "libpq/pqsignal.h"
#include "nodes/pg_list.h"
#include "nodes/print.h"
#include "optimizer/cost.h"
#include "optimizer/planner.h"
#include "optimizer/prep.h"
#include "parser/parser.h"
#include "rewrite/rewriteHandler.h" /* for QueryRewrite() */
#include "storage/bufmgr.h"
#include "tcop/dest.h"
#include "tcop/fastpath.h"
#include "tcop/pquery.h"
#include "tcop/tcopdebug.h"
#include "tcop/tcopprot.h" /* where declarations for this file go */
#include "tcop/utility.h"
#include "utils/mcxt.h"
#include "utils/rel.h"
#if FALSE
#include "nodes/relation.h"
#endif
#include "nodes/print.h"
#include "optimizer/cost.h"
#include "optimizer/planner.h"
#if 0
#include "optimizer/xfunc.h"
#endif
#include "optimizer/prep.h"
#if FALSE
#include "nodes/plannodes.h"
#endif
#include "storage/bufmgr.h"
#include "fmgr.h"
#include "utils/palloc.h"
#include "utils/rel.h"
#include "nodes/pg_list.h"
#include "tcop/dest.h"
#if FALSE
#include "nodes/memnodes.h"
#endif
#include "utils/mcxt.h"
#include "tcop/pquery.h"
#include "tcop/utility.h"
#include "tcop/fastpath.h"
#include "libpq/libpq.h"
#include "libpq/pqsignal.h"
#include "rewrite/rewriteHandler.h" /* for QueryRewrite() */
static void quickdie(SIGNAL_ARGS);
@ -1123,7 +1117,7 @@ PostgresMain(int argc, char *argv[])
int S;
S = atoi(optarg);
if ( S >= 4*MAXBLCKSZ/1024 )
if ( S >= 4*BLCKSZ/1024 )
SortMem = S;
}
break;
@ -1387,7 +1381,7 @@ PostgresMain(int argc, char *argv[])
if (IsUnderPostmaster == false)
{
puts("\nPOSTGRES backend interactive interface");
puts("$Revision: 1.60 $ $Date: 1998/01/09 05:48:22 $");
puts("$Revision: 1.61 $ $Date: 1998/01/13 04:04:36 $");
}
/* ----------------

View File

@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.13 1998/01/05 16:39:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.14 1998/01/13 04:04:47 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -15,26 +15,21 @@
#include <fcntl.h>
#include "postgres.h"
#include <libpq/be-fsstubs.h>
#include "utils/memutils.h"
#include "libpq/libpq-fs.h"
#include "storage/fd.h" /* for SEEK_ */
#include "fmgr.h"
#include "catalog/pg_type.h"
#include "fmgr.h"
#include "utils/array.h"
#include "libpq/be-fsstubs.h"
#include "libpq/libpq-fs.h"
#include "optimizer/internal.h"
#include "utils/array.h"
#include "utils/memutils.h"
#ifndef HAVE_MEMMOVE
#include <regex/utils.h>
#else
#include <string.h>
#endif
#define INFTY 500000000
#define MANY 10000
#define MAXPAT 20

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.30 1998/01/07 21:06:39 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.31 1998/01/13 04:04:57 scrappy Exp $
*
* NOTES
* Sorts the first relation into the second relation.
@ -40,27 +40,22 @@
#include <unistd.h>
#include "postgres.h"
#include "miscadmin.h"
#include "executor/execdebug.h"
#include "access/heapam.h"
#include "access/htup.h"
#include "access/relscan.h"
#include "access/skey.h"
#include "storage/buf.h"
#include "storage/bufmgr.h" /* for BLCKSZ */
#include "utils/portal.h" /* for {Start,End}PortalAllocMode */
#include "utils/elog.h"
#include "utils/rel.h"
#include "executor/execdebug.h"
#include "executor/executor.h"
#include "nodes/execnodes.h"
#include "nodes/plannodes.h"
#include "executor/executor.h"
#include "utils/lselect.h"
#include "utils/psort.h"
#include "miscadmin.h"
#include "storage/buf.h"
#include "storage/fd.h"
#include "utils/lselect.h"
#include "utils/portal.h" /* for {Start,End}PortalAllocMode */
#include "utils/psort.h"
#include "utils/rel.h"
static bool createfirstrun(Sort * node);
static bool createrun(Sort * node, FILE * file);
@ -250,7 +245,7 @@ inittapes(Sort * node)
#define USEMEM(NODE,AMT) PS(node)->treeContext.sortMem -= (AMT)
#define FREEMEM(NODE,AMT) PS(node)->treeContext.sortMem += (AMT)
#define LACKMEM(NODE) (PS(node)->treeContext.sortMem <= MAXBLCKSZ) /* not accurate */
#define LACKMEM(NODE) (PS(node)->treeContext.sortMem <= BLCKSZ) /* not accurate */
#define TRACEMEM(FUNC)
#define TRACEOUT(FUNC, TUP)

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: bufmgr.h,v 1.15 1997/09/08 21:54:18 momjian Exp $
* $Id: bufmgr.h,v 1.16 1998/01/13 04:05:09 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -26,12 +26,16 @@
* in theory this could be anything, but in practice this is actually
* limited to 2^13 bytes because we have limited ItemIdData.lp_off and
* ItemIdData.lp_len to 13 bits (see itemid.h).
*
* limit is now 2^15. Took four bits from ItemIdData.lp_flags and gave
* two apiece to ItemIdData.lp_len and lp_off. darrenk 01/06/98
*
*/
#define MAXBLCKSZ 8192
#define MAXBLCKSZ 32768
typedef void *Block;
/* special pageno for bget */
#define P_NEW InvalidBlockNumber /* grow the file to get a new page */

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: bufpage.h,v 1.13 1997/09/08 21:54:20 momjian Exp $
* $Id: bufpage.h,v 1.14 1998/01/13 04:05:11 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -86,6 +86,9 @@
*
* note that this is actually limited to 2^13 because we have limited
* ItemIdData.lp_off and ItemIdData.lp_len to 13 bits (see itemid.h).
*
* uint16 is still valid, but the limit has been raised to 15 bits.
* 06 Jan 98 - darrenk
*/
typedef uint16 LocationIndex;
@ -98,6 +101,9 @@ typedef uint16 LocationIndex;
* page header, opaque space and a minimal tuple;
* on the high end, we can only support pages up
* to 8KB because lp_off/lp_len are 13 bits.
*
* see above comment. Now use 15 bits and pages
* up to 32KB at your own risk.
*/
typedef struct OpaqueData
{
@ -191,8 +197,11 @@ typedef enum
*
* XXX currently all page sizes are "valid" but we only actually
* use BLCKSZ.
*
* 01/06/98 Now does something useful. darrenk
*
*/
#define PageSizeIsValid(pageSize) 1
#define PageSizeIsValid(pageSize) ((pageSize) == BLCKSZ)
/*
* PageGetPageSize --

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: itemid.h,v 1.4 1997/09/08 21:54:24 momjian Exp $
* $Id: itemid.h,v 1.5 1998/01/13 04:05:12 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -22,10 +22,10 @@ typedef bits16 ItemIdFlags;
typedef struct ItemIdData
{ /* line pointers */
unsigned lp_off:13, /* offset to find tup */
unsigned lp_off:15, /* offset to find tup */
/* can be reduced by 2 if necc. */
lp_flags:6, /* flags on tuple */
lp_len:13; /* length of tuple */
lp_flags:2, /* flags on tuple */
lp_len:15; /* length of tuple */
} ItemIdData;
typedef struct ItemIdData *ItemId;