Skip to content

Commit a17b01f

Browse files
committed
Update btree patches that were missed.
1 parent e230c0b commit a17b01f

File tree

6 files changed

+68
-46
lines changed

6 files changed

+68
-46
lines changed

src/backend/access/nbtree/nbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.13 1997/02/12 05:04:17 scrappy Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.14 1997/02/18 17:13:42 momjian Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.

src/backend/access/nbtree/nbtscan.c

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.6 1996/11/15 18:37:00 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.7 1997/02/18 17:13:45 momjian Exp $
1111
*
1212
*
1313
* NOTES
@@ -40,7 +40,10 @@ typedef struct BTScanListData {
4040
typedef BTScanListData *BTScanList;
4141

4242
static BTScanList BTScans = (BTScanList) NULL;
43-
43+
44+
static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno);
45+
static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
46+
4447
/*
4548
* _bt_regscan() -- register a new scan.
4649
*/
@@ -81,22 +84,47 @@ _bt_dropscan(IndexScanDesc scan)
8184
pfree (chk);
8285
}
8386

87+
/*
88+
* _bt_adjscans() -- adjust all scans in the scan list to compensate
89+
* for a given deletion or insertion
90+
*/
8491
void
85-
_bt_adjscans(Relation rel, ItemPointer tid)
92+
_bt_adjscans(Relation rel, ItemPointer tid, int op)
8693
{
8794
BTScanList l;
8895
Oid relid;
8996

9097
relid = rel->rd_id;
9198
for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next) {
9299
if (relid == l->btsl_scan->relation->rd_id)
93-
_bt_scandel(l->btsl_scan, ItemPointerGetBlockNumber(tid),
100+
_bt_scandel(l->btsl_scan, op,
101+
ItemPointerGetBlockNumber(tid),
94102
ItemPointerGetOffsetNumber(tid));
95103
}
96104
}
97105

98-
void
99-
_bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
106+
/*
107+
* _bt_scandel() -- adjust a single scan
108+
*
109+
* because each index page is always maintained as an ordered array of
110+
* index tuples, the index tuples on a given page shift beneath any
111+
* given scan. an index modification "behind" a scan position (i.e.,
112+
* same page, lower or equal offset number) will therefore force us to
113+
* adjust the scan in the following ways:
114+
*
115+
* - on insertion, we shift the scan forward by one item.
116+
* - on deletion, we shift the scan backward by one item.
117+
*
118+
* note that:
119+
*
120+
* - we need not worry about the actual ScanDirection of the scan
121+
* itself, since the problem is that the "current" scan position has
122+
* shifted.
123+
* - modifications "ahead" of our scan position do not change the
124+
* array index of the current scan position and so can be ignored.
125+
*/
126+
static void
127+
_bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
100128
{
101129
ItemPointer current;
102130
Buffer buf;
@@ -112,7 +140,17 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
112140
if (ItemPointerIsValid(current)
113141
&& ItemPointerGetBlockNumber(current) == blkno
114142
&& ItemPointerGetOffsetNumber(current) >= offno) {
115-
_bt_step(scan, &buf, BackwardScanDirection);
143+
switch (op) {
144+
case BT_INSERT:
145+
_bt_step(scan, &buf, ForwardScanDirection);
146+
break;
147+
case BT_DELETE:
148+
_bt_step(scan, &buf, BackwardScanDirection);
149+
break;
150+
default:
151+
elog(WARN, "_bt_scandel: bad operation '%d'", op);
152+
/*NOTREACHED*/
153+
}
116154
so->btso_curbuf = buf;
117155
}
118156

@@ -124,15 +162,29 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
124162
tmp = *current;
125163
*current = scan->currentItemData;
126164
scan->currentItemData = tmp;
127-
_bt_step(scan, &buf, BackwardScanDirection);
165+
switch (op) {
166+
case BT_INSERT:
167+
_bt_step(scan, &buf, ForwardScanDirection);
168+
break;
169+
case BT_DELETE:
170+
_bt_step(scan, &buf, BackwardScanDirection);
171+
break;
172+
default:
173+
elog(WARN, "_bt_scandel: bad operation '%d'", op);
174+
/*NOTREACHED*/
175+
}
128176
so->btso_mrkbuf = buf;
129177
tmp = *current;
130178
*current = scan->currentItemData;
131179
scan->currentItemData = tmp;
132180
}
133181
}
134182

135-
bool
183+
/*
184+
* _bt_scantouched() -- check to see if a scan is affected by a given
185+
* change to the index
186+
*/
187+
static bool
136188
_bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
137189
{
138190
ItemPointer current;

src/backend/access/nbtree/nbtsearch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.13 1997/01/05 10:56:36 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.14 1997/02/18 17:13:48 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -332,7 +332,7 @@ _bt_binsrch(Relation rel,
332332
else if (result < 0)
333333
high = mid - 1;
334334
else
335-
return (_bt_firsteq(rel, itupdesc, page, keysz, scankey, mid));
335+
return (_bt_firsteq(rel, itupdesc, page, keysz, scankey, mid));
336336
}
337337

338338
/*

src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.40 1997/02/14 04:16:12 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.41 1997/02/18 17:13:58 momjian Exp $
1414
*
1515
* NOTES
1616
*
@@ -287,12 +287,6 @@ PostmasterMain(int argc, char *argv[])
287287
else
288288
DebugLvl = 1;
289289
break;
290-
case 'e':
291-
/*
292-
* Use european date formats.
293-
*/
294-
EuroDates = 1;
295-
break;
296290
case 'm':
297291
MultiplexedBackends = 1;
298292
MultiplexedBackendPort = atoi(optarg);
@@ -424,7 +418,6 @@ usage(const char *progname)
424418
fprintf(stderr, "\t-b backend\tuse a specific backend server executable\n");
425419
fprintf(stderr, "\t-d [1|2|3]\tset debugging level\n");
426420
fprintf(stderr, "\t-D datadir\tset data directory\n");
427-
fprintf(stderr, "\t-e \tturn on European date format\n");
428421
fprintf(stderr, "\t-m \tstart up multiplexing backends\n");
429422
fprintf(stderr, "\t-n\t\tdon't reinitialize shared memory after abnormal exit\n");
430423
fprintf(stderr, "\t-o option\tpass 'option' to each backend servers\n");
@@ -1113,10 +1106,6 @@ DoExec(StartupInfo *packet, int portFd)
11131106
av[ac++] = "-o";
11141107
av[ac++] = ttybuf;
11151108
}
1116-
1117-
/* tell the backend we're using European dates */
1118-
if (EuroDates == 1)
1119-
av[ac++] = "-e";
11201109

11211110
/* tell the multiplexed backend to start on a certain port */
11221111
if (MultiplexedBackends) {

src/include/access/nbtree.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nbtree.h,v 1.7 1997/02/14 22:47:36 momjian Exp $
9+
* $Id: nbtree.h,v 1.8 1997/02/18 17:14:10 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -238,9 +238,7 @@ extern void btdelete(Relation rel, ItemPointer tid);
238238
*/
239239
extern void _bt_regscan(IndexScanDesc scan);
240240
extern void _bt_dropscan(IndexScanDesc scan);
241-
extern void _bt_adjscans(Relation rel, ItemPointer tid);
242-
extern void _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
243-
extern bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
241+
extern void _bt_adjscans(Relation rel, ItemPointer tid, int op);
244242

245243
/*
246244
* prototypes for functions in nbtsearch.c

src/man/postmaster.1

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" This is -*-nroff-*-
22
.\" XXX standard disclaimer belongs here....
3-
.\" $Header: /cvsroot/pgsql/src/man/Attic/postmaster.1,v 1.3 1997/01/26 15:32:28 scrappy Exp $
3+
.\" $Header: /cvsroot/pgsql/src/man/Attic/postmaster.1,v 1.4 1997/02/18 17:14:25 momjian Exp $
44
.TH POSTMASTER UNIX 11/05/95 PostgreSQL PostgreSQL
55
.SH "NAME"
66
postmaster \(em run the Postgres postmaster
@@ -173,23 +173,6 @@ programmer can then use the
173173
.IR shmemdoc
174174
program to examine shared memory and semaphore state.
175175
.TP
176-
.BR "-e"
177-
The
178-
.IR "-e"
179-
option controls how dates are input to and output from the database.
180-
.IP
181-
If the
182-
.IR "-e"
183-
option is supplied, then all dates passed to and from the frontend
184-
processes will be assumed to be in
185-
.IR "European"
186-
format ie.
187-
.IR "DD-MM-YYYY"
188-
otherwise dates are input and output in
189-
.IR "American"
190-
format ie.
191-
.IR "MM-DD-YYYY"
192-
.TP
193176
.BR "-o" " backend_options"
194177
The
195178
.IR postgres (1)

0 commit comments

Comments
 (0)