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
8d02b15e
Commit
8d02b15e
authored
Apr 03, 2006
by
Teodor Sigaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate ajust scan code. Since concurrent GiST it doesn't
do real work. That was missed during concurrence development.
parent
cdfecf6e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
216 deletions
+6
-216
src/backend/access/gist/gist.c
src/backend/access/gist/gist.c
+1
-6
src/backend/access/gist/gistscan.c
src/backend/access/gist/gistscan.c
+3
-205
src/backend/utils/resowner/resowner.c
src/backend/utils/resowner/resowner.c
+1
-2
src/include/access/gistscan.h
src/include/access/gistscan.h
+1
-3
No files found.
src/backend/access/gist/gist.c
View file @
8d02b15e
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.13
1 2006/03/31 23:32:05 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.13
2 2006/04/03 13:44:33 teodor
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -493,11 +493,6 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
END_CRIT_SECTION
();
if
(
!
is_leaf
)
/* small optimization: inform scan ablout
* deleting... */
gistadjscans
(
state
->
r
,
GISTOP_DEL
,
state
->
stack
->
blkno
,
state
->
stack
->
childoffnum
,
PageGetLSN
(
state
->
stack
->
page
),
oldlsn
);
if
(
state
->
ituplen
>
1
)
{
/* previous is_splitted==true */
...
...
src/backend/access/gist/gistscan.c
View file @
8d02b15e
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.6
2 2006/03/05 15:58:20 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.6
3 2006/04/03 13:44:33 teodor
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -20,37 +20,8 @@
#include "utils/memutils.h"
#include "utils/resowner.h"
/* routines defined and used here */
static
void
gistregscan
(
IndexScanDesc
scan
);
static
void
gistdropscan
(
IndexScanDesc
scan
);
static
void
gistadjone
(
IndexScanDesc
scan
,
int
op
,
BlockNumber
blkno
,
OffsetNumber
offnum
,
XLogRecPtr
newlsn
,
XLogRecPtr
oldlsn
);
static
void
adjustiptr
(
IndexScanDesc
scan
,
ItemPointer
iptr
,
GISTSearchStack
*
stk
,
int
op
,
BlockNumber
blkno
,
OffsetNumber
offnum
,
XLogRecPtr
newlsn
,
XLogRecPtr
oldlsn
);
static
void
gistfreestack
(
GISTSearchStack
*
s
);
/*
* Whenever we start a GiST scan in a backend, we register it in
* private space. Then if the GiST index gets updated, we check all
* registered scans and adjust them if the tuple they point at got
* moved by the update. We only need to do this in private space,
* because when we update an GiST we have a write lock on the tree, so
* no other process can have any locks at all on it. A single
* transaction can have write and read locks on the same object, so
* that's why we need to handle this case.
*/
typedef
struct
GISTScanListData
{
IndexScanDesc
gsl_scan
;
ResourceOwner
gsl_owner
;
struct
GISTScanListData
*
gsl_next
;
}
GISTScanListData
;
typedef
GISTScanListData
*
GISTScanList
;
/* pointer to list of local scans on GiSTs */
static
GISTScanList
GISTScans
=
NULL
;
Datum
gistbeginscan
(
PG_FUNCTION_ARGS
)
{
...
...
@@ -60,7 +31,6 @@ gistbeginscan(PG_FUNCTION_ARGS)
IndexScanDesc
scan
;
scan
=
RelationGetIndexScan
(
r
,
nkeys
,
key
);
gistregscan
(
scan
);
PG_RETURN_POINTER
(
scan
);
}
...
...
@@ -254,189 +224,17 @@ gistendscan(PG_FUNCTION_ARGS)
pfree
(
scan
->
opaque
);
}
gistdropscan
(
scan
);
PG_RETURN_VOID
();
}
static
void
gistregscan
(
IndexScanDesc
scan
)
{
GISTScanList
l
;
l
=
(
GISTScanList
)
palloc
(
sizeof
(
GISTScanListData
));
l
->
gsl_scan
=
scan
;
l
->
gsl_owner
=
CurrentResourceOwner
;
l
->
gsl_next
=
GISTScans
;
GISTScans
=
l
;
}
static
void
gistdropscan
(
IndexScanDesc
scan
)
{
GISTScanList
l
;
GISTScanList
prev
;
prev
=
NULL
;
for
(
l
=
GISTScans
;
l
!=
NULL
&&
l
->
gsl_scan
!=
scan
;
l
=
l
->
gsl_next
)
prev
=
l
;
if
(
l
==
NULL
)
elog
(
ERROR
,
"GiST scan list corrupted -- could not find 0x%p"
,
(
void
*
)
scan
);
if
(
prev
==
NULL
)
GISTScans
=
l
->
gsl_next
;
else
prev
->
gsl_next
=
l
->
gsl_next
;
pfree
(
l
);
}
/*
* ReleaseResources_gist() --- clean up gist subsystem resources.
*
* This is here because it needs to touch this module's static var GISTScans.
*/
void
ReleaseResources_gist
(
void
)
{
GISTScanList
l
;
GISTScanList
prev
;
GISTScanList
next
;
/*
* Note: this should be a no-op during normal query shutdown. However, in
* an abort situation ExecutorEnd is not called and so there may be open
* index scans to clean up.
*/
prev
=
NULL
;
for
(
l
=
GISTScans
;
l
!=
NULL
;
l
=
next
)
{
next
=
l
->
gsl_next
;
if
(
l
->
gsl_owner
==
CurrentResourceOwner
)
{
if
(
prev
==
NULL
)
GISTScans
=
next
;
else
prev
->
gsl_next
=
next
;
pfree
(
l
);
/* prev does not change */
}
else
prev
=
l
;
}
}
void
gistadjscans
(
Relation
rel
,
int
op
,
BlockNumber
blkno
,
OffsetNumber
offnum
,
XLogRecPtr
newlsn
,
XLogRecPtr
oldlsn
)
{
GISTScanList
l
;
Oid
relid
;
if
(
XLogRecPtrIsInvalid
(
newlsn
)
||
XLogRecPtrIsInvalid
(
oldlsn
))
return
;
relid
=
RelationGetRelid
(
rel
);
for
(
l
=
GISTScans
;
l
!=
NULL
;
l
=
l
->
gsl_next
)
{
if
(
l
->
gsl_scan
->
indexRelation
->
rd_id
==
relid
)
gistadjone
(
l
->
gsl_scan
,
op
,
blkno
,
offnum
,
newlsn
,
oldlsn
);
}
}
/*
* gistadjone() -- adjust one scan for update.
*
* By here, the scan passed in is on a modified relation. Op tells
* us what the modification is, and blkno and offind tell us what
* block and offset index were affected. This routine checks the
* current and marked positions, and the current and marked stacks,
* to see if any stored location needs to be changed because of the
* update. If so, we make the change here.
*/
static
void
gistadjone
(
IndexScanDesc
scan
,
int
op
,
BlockNumber
blkno
,
OffsetNumber
offnum
,
XLogRecPtr
newlsn
,
XLogRecPtr
oldlsn
)
{
GISTScanOpaque
so
=
(
GISTScanOpaque
)
scan
->
opaque
;
adjustiptr
(
scan
,
&
(
scan
->
currentItemData
),
so
->
stack
,
op
,
blkno
,
offnum
,
newlsn
,
oldlsn
);
adjustiptr
(
scan
,
&
(
scan
->
currentMarkData
),
so
->
markstk
,
op
,
blkno
,
offnum
,
newlsn
,
oldlsn
);
}
/*
* adjustiptr() -- adjust current and marked item pointers in the scan
*
* Depending on the type of update and the place it happened, we
* need to do nothing, to back up one record, or to start over on
* the same page.
*/
static
void
adjustiptr
(
IndexScanDesc
scan
,
ItemPointer
iptr
,
GISTSearchStack
*
stk
,
int
op
,
BlockNumber
blkno
,
OffsetNumber
offnum
,
XLogRecPtr
newlsn
,
XLogRecPtr
oldlsn
)
{
OffsetNumber
curoff
;
GISTScanOpaque
so
;
if
(
ItemPointerIsValid
(
iptr
))
{
if
(
ItemPointerGetBlockNumber
(
iptr
)
==
blkno
)
{
curoff
=
ItemPointerGetOffsetNumber
(
iptr
);
so
=
(
GISTScanOpaque
)
scan
->
opaque
;
switch
(
op
)
{
case
GISTOP_DEL
:
/* back up one if we need to */
if
(
curoff
>=
offnum
&&
XLByteEQ
(
stk
->
lsn
,
oldlsn
))
/* the same vesrion of
* page */
{
if
(
curoff
>
FirstOffsetNumber
)
{
/* just adjust the item pointer */
ItemPointerSet
(
iptr
,
blkno
,
OffsetNumberPrev
(
curoff
));
}
else
{
/*
* remember that we're before the current tuple
*/
ItemPointerSet
(
iptr
,
blkno
,
FirstOffsetNumber
);
if
(
iptr
==
&
(
scan
->
currentItemData
))
so
->
flags
|=
GS_CURBEFORE
;
else
so
->
flags
|=
GS_MRKBEFORE
;
}
stk
->
lsn
=
newlsn
;
}
break
;
default:
elog
(
ERROR
,
"unrecognized GiST scan adjust operation: %d"
,
op
);
}
}
}
}
static
void
gistfreestack
(
GISTSearchStack
*
s
)
{
{
while
(
s
!=
NULL
)
{
GISTSearchStack
*
p
=
s
->
next
;
pfree
(
s
);
s
=
p
;
}
}
src/backend/utils/resowner/resowner.c
View file @
8d02b15e
...
...
@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/resowner/resowner.c,v 1.1
8 2006/03/05 15:58:49 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/resowner/resowner.c,v 1.1
9 2006/04/03 13:44:33 teodor
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -277,7 +277,6 @@ ResourceOwnerReleaseInternal(ResourceOwner owner,
}
/* Clean up index scans too */
ReleaseResources_gist
();
ReleaseResources_hash
();
}
...
...
src/include/access/gistscan.h
View file @
8d02b15e
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/access/gistscan.h,v 1.2
8 2006/03/05 15:58:53 momjian
Exp $
* $PostgreSQL: pgsql/src/include/access/gistscan.h,v 1.2
9 2006/04/03 13:44:33 teodor
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -22,7 +22,5 @@ extern Datum gistrescan(PG_FUNCTION_ARGS);
extern
Datum
gistmarkpos
(
PG_FUNCTION_ARGS
);
extern
Datum
gistrestrpos
(
PG_FUNCTION_ARGS
);
extern
Datum
gistendscan
(
PG_FUNCTION_ARGS
);
extern
void
gistadjscans
(
Relation
r
,
int
op
,
BlockNumber
blkno
,
OffsetNumber
offnum
,
XLogRecPtr
newlsn
,
XLogRecPtr
oldlsn
);
extern
void
ReleaseResources_gist
(
void
);
#endif
/* GISTSCAN_H */
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