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
ce2586db
Commit
ce2586db
authored
May 29, 1999
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up inefficient and just plain bad code in some hot-spot
cache access routines.
parent
dc6d4049
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
239 additions
and
187 deletions
+239
-187
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/lsyscache.c
+192
-146
src/backend/utils/cache/syscache.c
src/backend/utils/cache/syscache.c
+47
-41
No files found.
src/backend/utils/cache/lsyscache.c
View file @
ce2586db
This diff is collapsed.
Click to expand it.
src/backend/utils/cache/syscache.c
View file @
ce2586db
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.2
6 1999/05/25 22:42:15 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.2
7 1999/05/29 01:45:20 tgl
Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
...
...
@@ -23,11 +23,7 @@
#include "access/htup.h"
#include "catalog/catname.h"
#include "utils/catcache.h"
#ifndef HAVE_MEMMOVE
#include <regex/utils.h>
#else
#include <string.h>
#endif
/* ----------------
...
...
@@ -386,8 +382,7 @@ static struct cachedesc cacheinfo[] = {
NULL
}
};
static
struct
catcache
*
SysCache
[
lengthof
(
cacheinfo
)];
static
struct
catcache
*
SysCache
[
lengthof
(
cacheinfo
)];
static
int32
SysCacheSize
=
lengthof
(
cacheinfo
);
...
...
@@ -547,7 +542,7 @@ SearchSysCacheStruct(int cacheId, /* cache selection code */
tp
=
SearchSysCacheTuple
(
cacheId
,
key1
,
key2
,
key3
,
key4
);
if
(
!
HeapTupleIsValid
(
tp
))
return
0
;
mem
move
(
returnStruct
,
(
char
*
)
GETSTRUCT
(
tp
),
cacheinfo
[
cacheId
].
size
);
mem
cpy
(
returnStruct
,
(
char
*
)
GETSTRUCT
(
tp
),
cacheinfo
[
cacheId
].
size
);
return
1
;
}
...
...
@@ -555,9 +550,12 @@ SearchSysCacheStruct(int cacheId, /* cache selection code */
/*
* SearchSysCacheGetAttribute
* Returns the attribute corresponding to 'attributeNumber' for
* a given cached tuple.
* a given cached tuple. This routine usually needs to be used for
* attributes that might be NULL or might be at a variable offset
* in the tuple.
*
* XXX This re-opens a relation, so this is slower.
* XXX This re-opens the relation, so this is slower than just pulling
* fixed-location fields out of the struct returned by SearchSysCacheTuple.
*
* [callers all assume this returns a (struct varlena *). -ay 10/94]
*/
...
...
@@ -638,7 +636,7 @@ SearchSysCacheGetAttribute(int cacheId,
:
attributeLength
;
/* fixed length */
tmp
=
(
char
*
)
palloc
(
size
);
mem
move
(
tmp
,
(
void
*
)
attributeValue
,
size
);
mem
cpy
(
tmp
,
(
void
*
)
attributeValue
,
size
);
returnValue
=
(
void
*
)
tmp
;
}
...
...
@@ -650,11 +648,8 @@ SearchSysCacheGetAttribute(int cacheId,
* TypeDefaultRetrieve
*
* Given a type OID, return the typdefault field associated with that
* type. The typdefault is returned as the car of a dotted pair which
* is passed to TypeDefaultRetrieve by the calling routine.
*
* Returns a fixnum for types which are passed by value and a ppreserve'd
* vectori for types which are not.
* type. The result is a Datum, and points to palloc'd storage for
* non-pass-by-value types.
*
* [identical to get_typdefault, expecting a (struct varlena *) as ret val.
* some day, either of the functions should be removed -ay 10/94]
...
...
@@ -662,68 +657,79 @@ SearchSysCacheGetAttribute(int cacheId,
void
*
TypeDefaultRetrieve
(
Oid
typId
)
{
struct
varlena
*
typDefault
;
int32
dataSize
;
HeapTuple
typeTuple
;
Form_pg_type
type
;
int32
typByVal
,
typLen
;
struct
varlena
*
typDefault
;
int32
dataSize
;
void
*
returnValue
;
typeTuple
=
SearchSysCacheTuple
(
TYPOID
,
ObjectIdGetDatum
(
typId
),
0
,
0
,
0
);
/*
* First, see if there is a non-null typdefault field (usually there isn't)
*/
typDefault
=
(
struct
varlena
*
)
SearchSysCacheGetAttribute
(
TYPOID
,
Anum_pg_type_typdefault
,
ObjectIdGetDatum
(
typId
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
typeTuple
)
)
if
(
typDefault
==
NULL
)
{
#ifdef CACHEDEBUG
elog
(
DEBUG
,
"TypeDefaultRetrieve:
Lookup in %s(%d) failed
"
,
elog
(
DEBUG
,
"TypeDefaultRetrieve:
No extractable typdefault in %s(%d)
"
,
cacheinfo
[
TYPOID
].
name
,
TYPOID
);
#endif
/* defined(CACHEDEBUG) */
return
NULL
;
}
type
=
(
Form_pg_type
)
GETSTRUCT
(
typeTuple
);
typByVal
=
type
->
typbyval
;
typLen
=
type
->
typlen
;
dataSize
=
VARSIZE
(
typDefault
)
-
VARHDRSZ
;
typDefault
=
(
struct
varlena
*
)
SearchSysCacheGetAttribute
(
TYPOID
,
Anum_pg_type_typdefault
,
ObjectIdGetDatum
(
typId
),
0
,
0
,
0
);
/*
* Need the type's length and byVal fields.
*
* XXX silly to repeat the syscache search that SearchSysCacheGetAttribute
* just did --- but at present this path isn't taken often enough to
* make it worth fixing.
*/
typeTuple
=
SearchSysCacheTuple
(
TYPOID
,
ObjectIdGetDatum
(
typId
),
0
,
0
,
0
);
if
(
typDefault
==
(
struct
varlena
*
)
NULL
)
if
(
!
HeapTupleIsValid
(
typeTuple
)
)
{
/* should never get here, really... */
#ifdef CACHEDEBUG
elog
(
DEBUG
,
"TypeDefaultRetrieve:
No extractable typdefault in %s(%d)
"
,
elog
(
DEBUG
,
"TypeDefaultRetrieve:
Lookup in %s(%d) failed
"
,
cacheinfo
[
TYPOID
].
name
,
TYPOID
);
#endif
/* defined(CACHEDEBUG) */
return
NULL
;
}
dataSize
=
VARSIZE
(
typDefault
)
-
VARHDRSZ
;
type
=
(
Form_pg_type
)
GETSTRUCT
(
typeTuple
);
typLen
=
type
->
typlen
;
typByVal
=
type
->
typbyval
;
if
(
typByVal
)
{
int8
i8
;
int16
i16
;
int32
i32
;
int32
i32
=
0
;
if
(
dataSize
==
typLen
)
{
switch
(
typLen
)
{
case
sizeof
(
int8
):
mem
move
((
char
*
)
&
i8
,
VARDATA
(
typDefault
),
sizeof
(
int8
));
mem
cpy
((
char
*
)
&
i8
,
VARDATA
(
typDefault
),
sizeof
(
int8
));
i32
=
i8
;
break
;
case
sizeof
(
int16
):
mem
move
((
char
*
)
&
i16
,
VARDATA
(
typDefault
),
sizeof
(
int16
));
mem
cpy
((
char
*
)
&
i16
,
VARDATA
(
typDefault
),
sizeof
(
int16
));
i32
=
i16
;
break
;
case
sizeof
(
int32
):
mem
move
((
char
*
)
&
i32
,
VARDATA
(
typDefault
),
sizeof
(
int32
));
mem
cpy
((
char
*
)
&
i32
,
VARDATA
(
typDefault
),
sizeof
(
int32
));
break
;
}
returnValue
=
(
void
*
)
i32
;
...
...
@@ -738,9 +744,9 @@ TypeDefaultRetrieve(Oid typId)
else
{
returnValue
=
(
void
*
)
palloc
(
VARSIZE
(
typDefault
));
mem
move
((
char
*
)
returnValue
,
(
char
*
)
typDefault
,
(
int
)
VARSIZE
(
typDefault
));
mem
cpy
((
char
*
)
returnValue
,
(
char
*
)
typDefault
,
(
int
)
VARSIZE
(
typDefault
));
}
}
...
...
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