Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
ead64f31
Commit
ead64f31
authored
Feb 06, 1999
by
Jan Wieck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New alloc set code using a memory block pool for small allocations.
Jan
parent
7d2b3874
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1661 additions
and
309 deletions
+1661
-309
src/backend/catalog/pg_type.c
src/backend/catalog/pg_type.c
+6
-3
src/backend/executor/execMain.c
src/backend/executor/execMain.c
+2
-2
src/backend/nodes/Makefile
src/backend/nodes/Makefile
+3
-3
src/backend/nodes/freefuncs.c
src/backend/nodes/freefuncs.c
+1381
-0
src/backend/utils/mmgr/aset.c
src/backend/utils/mmgr/aset.c
+169
-198
src/backend/utils/mmgr/mcxt.c
src/backend/utils/mmgr/mcxt.c
+6
-5
src/backend/utils/mmgr/palloc.c
src/backend/utils/mmgr/palloc.c
+9
-81
src/backend/utils/mmgr/portalmem.c
src/backend/utils/mmgr/portalmem.c
+20
-1
src/include/nodes/memnodes.h
src/include/nodes/memnodes.h
+5
-5
src/include/nodes/nodes.h
src/include/nodes/nodes.h
+6
-1
src/include/utils/memutils.h
src/include/utils/memutils.h
+30
-2
src/include/utils/palloc.h
src/include/utils/palloc.h
+21
-5
src/include/utils/portal.h
src/include/utils/portal.h
+3
-3
No files found.
src/backend/catalog/pg_type.c
View file @
ead64f31
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.3
3 1999/02/03 21:15:56 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.3
4 1999/02/06 16:50:22 wieck
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -53,6 +53,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
{
HeapScanDesc
scan
;
HeapTuple
tup
;
Oid
typoid
;
static
ScanKeyData
typeKey
[
1
]
=
{
{
0
,
Anum_pg_type_typname
,
F_NAMEEQ
}
...
...
@@ -96,10 +97,12 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
* oid, which is the oid of the type.
* ----------------
*/
heap_endscan
(
scan
);
*
defined
=
(
bool
)
((
Form_pg_type
)
GETSTRUCT
(
tup
))
->
typisdefined
;
typoid
=
tup
->
t_data
->
t_oid
;
return
tup
->
t_data
->
t_oid
;
heap_endscan
(
scan
);
return
typoid
;
}
/* ----------------------------------------------------------------
...
...
src/backend/executor/execMain.c
View file @
ead64f31
...
...
@@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.7
0 1999/02/02 03:44:23 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.7
1 1999/02/06 16:50:23 wieck
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1492,7 +1492,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple)
res
=
ExecQual
(
qual
,
econtext
);
pfree
(
qual
);
freeObject
(
qual
);
if
(
!
res
)
return
check
[
i
].
ccname
;
...
...
src/backend/nodes/Makefile
View file @
ead64f31
...
...
@@ -4,7 +4,7 @@
# Makefile for nodes
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/nodes/Makefile,v 1.
6 1998/04/06 00:23:00 momjian
Exp $
# $Header: /cvsroot/pgsql/src/backend/nodes/Makefile,v 1.
7 1999/02/06 16:50:24 wieck
Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -14,8 +14,8 @@ include ../../Makefile.global
CFLAGS
+=
-I
..
OBJS
=
nodeFuncs.o nodes.o list.o
\
copyfuncs.o equalfuncs.o
makefuncs.o outfuncs.o read
funcs.o
\
print.o read.o
copyfuncs.o equalfuncs.o
freefuncs.o makefuncs.o out
funcs.o
\
readfuncs.o
print.o read.o
all
:
SUBSYS.o
...
...
src/backend/nodes/freefuncs.c
0 → 100644
View file @
ead64f31
This diff is collapsed.
Click to expand it.
src/backend/utils/mmgr/aset.c
View file @
ead64f31
This diff is collapsed.
Click to expand it.
src/backend/utils/mmgr/mcxt.c
View file @
ead64f31
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.1
0 1998/09/01 04:33:36 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.1
1 1999/02/06 16:50:26 wieck
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -103,10 +103,11 @@ static struct MemoryContextMethodsData GlobalContextMethodsData = {
*/
/* extern bool EqualGlobalMemory(); */
static
struct
GlobalMemory
TopGlobalMemoryData
=
{
static
struct
GlobalMemory
Data
TopGlobalMemoryData
=
{
T_GlobalMemory
,
/* NodeTag tag */
&
GlobalContextMethodsData
,
/* ContextMethods method */
{{
0
}},
/* uninitialized OrderedSetData allocSetD */
{
NULL
,
{
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
}},
/* free AllocSet */
"TopGlobal"
,
/* char* name */
{
0
}
/* uninitialized OrderedElemData elemD */
};
...
...
@@ -162,7 +163,7 @@ EnableMemoryContext(bool on)
/* make TopGlobalMemoryData member of ActiveGlobalMemorySet */
OrderedSetInit
(
ActiveGlobalMemorySet
,
offsetof
(
struct
GlobalMemory
,
elemData
));
offsetof
(
struct
GlobalMemory
Data
,
elemData
));
OrderedElemPushInto
(
&
TopGlobalMemoryData
.
elemData
,
ActiveGlobalMemorySet
);
...
...
@@ -371,7 +372,7 @@ CreateGlobalMemory(char *name) /* XXX MemoryContextName */
savecxt
=
MemoryContextSwitchTo
(
TopMemoryContext
);
context
=
(
GlobalMemory
)
newNode
(
sizeof
(
struct
GlobalMemory
),
T_GlobalMemory
);
context
=
(
GlobalMemory
)
newNode
(
sizeof
(
struct
GlobalMemory
Data
),
T_GlobalMemory
);
context
->
method
=
&
GlobalContextMethodsData
;
context
->
name
=
name
;
/* assumes name is static */
AllocSetInit
(
&
context
->
setData
,
DynamicAllocMode
,
(
Size
)
0
);
...
...
src/backend/utils/mmgr/palloc.c
View file @
ead64f31
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.
9 1999/01/17 03:04:54 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.
10 1999/02/06 16:50:27 wieck
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -22,98 +22,26 @@
#include "nodes/memnodes.h"
#include "utils/palloc.h"
/* ----------------------------------------------------------------
* User library functions
* ----------------------------------------------------------------
*/
#undef palloc
#undef pfree
#undef MemoryContextAlloc
#undef MemoryContextFree
#undef malloc
#undef free
/* define PALLOC_IS_MALLOC if you want palloc to go straight to the
raw malloc, without concern for the extra bookkeeping needed to
ensure garbage is collected at the end of transactions - jolly 1/12/94 */
/*
* palloc --
* Returns pointer to aligned memory of specified size.
*
* Exceptions:
* BadArgument if size < 1 or size >= MaxAllocSize.
* ExhaustedMemory if allocation fails.
* NonallocatedPointer if pointer was not returned by palloc or repalloc
* or may have been freed already.
*
* pfree --
* Frees memory associated with pointer returned from palloc or repalloc.
*
* Exceptions:
* BadArgument if pointer is invalid.
* FreeInWrongContext if pointer was allocated in a different "context."
* NonallocatedPointer if pointer was not returned by palloc or repalloc
* or may have been subsequently freed.
/* ----------
* palloc(), pfree() and repalloc() are now macros in palloc.h
* ----------
*/
void
*
palloc
(
Size
size
)
{
#ifdef PALLOC_IS_MALLOC
return
malloc
(
size
);
#else
return
MemoryContextAlloc
(
CurrentMemoryContext
,
size
);
#endif
/* PALLOC_IS_MALLOC */
}
void
pfree
(
void
*
pointer
)
{
#ifdef PALLOC_IS_MALLOC
free
(
pointer
);
#else
MemoryContextFree
(
CurrentMemoryContext
,
pointer
);
#endif
/* PALLOC_IS_MALLOC */
}
/*
* repalloc --
* Returns pointer to aligned memory of specified size.
*
* Side effects:
* The returned memory is first filled with the contents of *pointer
* up to the minimum of size and psize(pointer). Pointer is freed.
*
* Exceptions:
* BadArgument if pointer is invalid or size < 1 or size >= MaxAllocSize.
* ExhaustedMemory if allocation fails.
* NonallocatedPointer if pointer was not returned by palloc or repalloc
* or may have been freed already.
*/
void
*
repalloc
(
void
*
pointer
,
Size
size
)
{
#ifdef PALLOC_IS_MALLOC
return
realloc
(
pointer
,
size
);
#else
return
MemoryContextRealloc
(
CurrentMemoryContext
,
pointer
,
size
);
#endif
}
/* pstrdup
allocates space for and copies a string
just like strdup except it uses palloc instead of malloc */
char
*
pstrdup
(
char
*
string
)
{
char
*
nstr
;
char
*
nstr
;
int
len
;
nstr
=
(
char
*
)
palloc
(
strlen
(
string
)
+
1
);
strcpy
(
nstr
,
string
);
nstr
=
palloc
(
len
=
strlen
(
string
)
+
1
);
MemoryCopy
(
nstr
,
string
,
len
);
return
nstr
;
}
src/backend/utils/mmgr/portalmem.c
View file @
ead64f31
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.1
6 1999/02/03 21:17:40 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.1
7 1999/02/06 16:50:28 wieck
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -812,6 +812,25 @@ PortalDestroy(Portal *portalP)
(
Pointer
)
portal
->
name
);
AllocSetReset
(
&
portal
->
variable
.
setData
);
/* XXX log */
/*
* In the case of a transaction abort it is possible that
* we get called while one of the memory contexts of the portal
* we're destroying is the current memory context.
*
* Don't know how to handle that cleanly because it is required
* to be in that context right now. This portal struct remains
* allocated in the PortalMemory context until backend dies.
*
* Not happy with that, but it's better to loose some bytes of
* memory than to have the backend dump core.
*
* --- Feb. 04, 1999 Jan Wieck
*/
if
(
CurrentMemoryContext
==
(
MemoryContext
)
PortalGetHeapMemory
(
portal
))
return
;
if
(
CurrentMemoryContext
==
(
MemoryContext
)
PortalGetVariableMemory
(
portal
))
return
;
if
(
portal
!=
BlankPortal
)
MemoryContextFree
((
MemoryContext
)
PortalMemory
,
(
Pointer
)
portal
);
}
...
...
src/include/nodes/memnodes.h
View file @
ead64f31
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: memnodes.h,v 1.
8 1998/09/01 04:36:39 momjian
Exp $
* $Id: memnodes.h,v 1.
9 1999/02/06 16:50:30 wieck
Exp $
*
* XXX the typedefs in this file are different from the other ???nodes.h;
* they are pointers to structures instead of the structures themselves.
...
...
@@ -56,7 +56,7 @@ typedef struct MemoryContextMethodsData
void
(
*
dump
)
();
}
*
MemoryContextMethods
;
typedef
struct
MemoryContext
typedef
struct
MemoryContext
Data
{
NodeTag
type
;
MemoryContextMethods
method
;
...
...
@@ -64,7 +64,7 @@ typedef struct MemoryContext
/* think about doing this right some time but we'll have explicit fields
for now -ay 10/94 */
typedef
struct
GlobalMemory
typedef
struct
GlobalMemory
Data
{
NodeTag
type
;
MemoryContextMethods
method
;
...
...
@@ -75,14 +75,14 @@ typedef struct GlobalMemory
typedef
MemoryContext
*
PortalMemoryContext
;
typedef
struct
PortalVariableMemory
typedef
struct
PortalVariableMemory
Data
{
NodeTag
type
;
MemoryContextMethods
method
;
AllocSetData
setData
;
}
*
PortalVariableMemory
;
typedef
struct
PortalHeapMemory
typedef
struct
PortalHeapMemory
Data
{
NodeTag
type
;
MemoryContextMethods
method
;
...
...
src/include/nodes/nodes.h
View file @
ead64f31
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodes.h,v 1.3
8 1999/02/04 03:19:10 momjian
Exp $
* $Id: nodes.h,v 1.3
9 1999/02/06 16:50:31 wieck
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -282,6 +282,11 @@ extern void *stringToNode(char *str);
*/
extern
void
*
copyObject
(
void
*
obj
);
/*
* nodes/freefuncs.c
*/
extern
void
freeObject
(
void
*
obj
);
/*
* nodes/equalfuncs.c
*/
...
...
src/include/utils/memutils.h
View file @
ead64f31
...
...
@@ -15,7 +15,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: memutils.h,v 1.
19 1998/12/26 18:15:53 momjian
Exp $
* $Id: memutils.h,v 1.
20 1999/02/06 16:50:33 wieck
Exp $
*
* NOTES
* some of the information in this file will be moved to
...
...
@@ -208,13 +208,41 @@ typedef enum AllocMode
#define DefaultAllocMode DynamicAllocMode
/*
* AllocBlock --
* Small pieces of memory are taken from bigger blocks of
* memory with a size aligned to a power of two. These
* pieces are not free's separately, instead they are reused
* for the next allocation of a fitting size.
*/
typedef
struct
AllocBlockData
{
struct
AllocSetData
*
aset
;
struct
AllocBlockData
*
next
;
char
*
freeptr
;
char
*
endptr
;
}
AllocBlockData
;
typedef
AllocBlockData
*
AllocBlock
;
/*
* AllocChunk --
* The prefix of each piece of memory in an AllocBlock
*/
typedef
struct
AllocChunkData
{
void
*
aset
;
Size
size
;
}
AllocChunkData
;
typedef
AllocChunkData
*
AllocChunk
;
/*
* AllocSet --
* Allocation set.
*/
typedef
struct
AllocSetData
{
OrderedSetData
setData
;
struct
AllocBlockData
*
blocks
;
struct
AllocChunkData
*
freelist
[
8
];
/* Note: this will change in the future to support other modes */
}
AllocSetData
;
...
...
src/include/utils/palloc.h
View file @
ead64f31
...
...
@@ -6,18 +6,34 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: palloc.h,v 1.
6 1998/09/01 04:39:24 momjian
Exp $
* $Id: palloc.h,v 1.
7 1999/02/06 16:50:34 wieck
Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PALLOC_H
#define PALLOC_H
#include
<c.h>
#include
"c.h"
extern
void
*
palloc
(
Size
size
);
extern
void
pfree
(
void
*
pointer
);
extern
void
*
repalloc
(
void
*
pointer
,
Size
size
);
#ifdef PALLOC_IS_MALLOC
# define palloc(s) malloc(s)
# define pfree(p) free(p)
# define repalloc(p,s) realloc((p),(s))
#else
/* ! PALLOC_IS_MALLOC */
/* ----------
* In the case we use memory contexts, use macro's for palloc() etc.
* ----------
*/
# include "utils/mcxt.h"
# define palloc(s) ((void *)MemoryContextAlloc(CurrentMemoryContext,(Size)(s)))
# define pfree(p) MemoryContextFree(CurrentMemoryContext,(Pointer)(p))
# define repalloc(p,s) ((void *)MemoryContextRealloc(CurrentMemoryContext,(Pointer)(p),(Size)(s)))
#endif
/* PALLOC_IS_MALLOC */
/* like strdup except uses palloc */
extern
char
*
pstrdup
(
char
*
pointer
);
...
...
src/include/utils/portal.h
View file @
ead64f31
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: portal.h,v 1.1
0 1998/09/01 04:39:25 momjian
Exp $
* $Id: portal.h,v 1.1
1 1999/02/06 16:50:34 wieck
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -44,8 +44,8 @@ typedef PortalD *Portal;
struct
PortalD
{
char
*
name
;
/* XXX PortalName */
struct
PortalVariableMemory
variable
;
struct
PortalHeapMemory
heap
;
struct
PortalVariableMemory
Data
variable
;
struct
PortalHeapMemory
Data
heap
;
QueryDesc
*
queryDesc
;
TupleDesc
attinfo
;
EState
*
state
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment