Skip to content

Commit a3c8f1d

Browse files
committed
Merge remote-tracking branch 'pg/master' into fast2pc
2 parents 0bc1a10 + cfe96ae commit a3c8f1d

File tree

195 files changed

+6205
-1638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+6205
-1638
lines changed

configure

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ with_python
827827
with_gssapi
828828
with_krb_srvnam
829829
with_pam
830+
with_bsd_auth
830831
with_ldap
831832
with_bonjour
832833
with_openssl
@@ -1516,6 +1517,7 @@ Optional Packages:
15161517
--with-krb-srvnam=NAME default service principal name in Kerberos (GSSAPI)
15171518
[postgres]
15181519
--with-pam build with PAM support
1520+
--with-bsd-auth build with BSD Authentication support
15191521
--with-ldap build with LDAP support
15201522
--with-bonjour build with Bonjour support
15211523
--with-openssl build with OpenSSL support
@@ -5570,6 +5572,41 @@ fi
55705572
$as_echo "$with_pam" >&6; }
55715573

55725574

5575+
#
5576+
# BSD AUTH
5577+
#
5578+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with BSD Authentication support" >&5
5579+
$as_echo_n "checking whether to build with BSD Authentication support... " >&6; }
5580+
5581+
5582+
5583+
# Check whether --with-bsd-auth was given.
5584+
if test "${with_bsd_auth+set}" = set; then :
5585+
withval=$with_bsd_auth;
5586+
case $withval in
5587+
yes)
5588+
5589+
$as_echo "#define USE_BSD_AUTH 1" >>confdefs.h
5590+
5591+
;;
5592+
no)
5593+
:
5594+
;;
5595+
*)
5596+
as_fn_error $? "no argument expected for --with-bsd-auth option" "$LINENO" 5
5597+
;;
5598+
esac
5599+
5600+
else
5601+
with_bsd_auth=no
5602+
5603+
fi
5604+
5605+
5606+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_bsd_auth" >&5
5607+
$as_echo "$with_bsd_auth" >&6; }
5608+
5609+
55735610
#
55745611
# LDAP
55755612
#
@@ -10522,6 +10559,17 @@ fi
1052210559

1052310560
done
1052410561

10562+
fi
10563+
10564+
if test "$with_bsd_auth" = yes ; then
10565+
ac_fn_c_check_header_mongrel "$LINENO" "bsd_auth.h" "ac_cv_header_bsd_auth_h" "$ac_includes_default"
10566+
if test "x$ac_cv_header_bsd_auth_h" = xyes; then :
10567+
10568+
else
10569+
as_fn_error $? "header file <bsd_auth.h> is required for BSD Authentication support" "$LINENO" 5
10570+
fi
10571+
10572+
1052510573
fi
1052610574

1052710575
if test "$with_systemd" = yes ; then

configure.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,16 @@ PGAC_ARG_BOOL(with, pam, no,
673673
AC_MSG_RESULT([$with_pam])
674674

675675

676+
#
677+
# BSD AUTH
678+
#
679+
AC_MSG_CHECKING([whether to build with BSD Authentication support])
680+
PGAC_ARG_BOOL(with, bsd-auth, no,
681+
[build with BSD Authentication support],
682+
[AC_DEFINE([USE_BSD_AUTH], 1, [Define to 1 to build with BSD Authentication support. (--with-bsd-auth)])])
683+
AC_MSG_RESULT([$with_bsd_auth])
684+
685+
676686
#
677687
# LDAP
678688
#
@@ -1269,6 +1279,10 @@ if test "$with_pam" = yes ; then
12691279
[AC_MSG_ERROR([header file <security/pam_appl.h> or <pam/pam_appl.h> is required for PAM.])])])
12701280
fi
12711281

1282+
if test "$with_bsd_auth" = yes ; then
1283+
AC_CHECK_HEADER(bsd_auth.h, [], [AC_MSG_ERROR([header file <bsd_auth.h> is required for BSD Authentication support])])
1284+
fi
1285+
12721286
if test "$with_systemd" = yes ; then
12731287
AC_CHECK_HEADER(systemd/sd-daemon.h, [], [AC_MSG_ERROR([header file <systemd/sd-daemon.h> is required for systemd support])])
12741288
fi

contrib/bloom/blinsert.c

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -200,44 +200,47 @@ blinsert(Relation index, Datum *values, bool *isnull,
200200

201201
/*
202202
* At first, try to insert new tuple to the first page in notFullPage
203-
* array. If success we don't need to modify the meta page.
203+
* array. If successful, we don't need to modify the meta page.
204204
*/
205205
metaBuffer = ReadBuffer(index, BLOOM_METAPAGE_BLKNO);
206206
LockBuffer(metaBuffer, BUFFER_LOCK_SHARE);
207-
metaData = BloomPageGetMeta(BufferGetPage(metaBuffer));
207+
metaData = BloomPageGetMeta(BufferGetPage(metaBuffer, NULL, NULL,
208+
BGP_NO_SNAPSHOT_TEST));
208209

209210
if (metaData->nEnd > metaData->nStart)
210211
{
211212
Page page;
212213

213214
blkno = metaData->notFullPage[metaData->nStart];
214-
215215
Assert(blkno != InvalidBlockNumber);
216+
217+
/* Don't hold metabuffer lock while doing insert */
216218
LockBuffer(metaBuffer, BUFFER_LOCK_UNLOCK);
217219

218220
buffer = ReadBuffer(index, blkno);
219221
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
222+
220223
state = GenericXLogStart(index);
221224
page = GenericXLogRegister(state, buffer, false);
222225

223226
if (BloomPageAddItem(&blstate, page, itup))
224227
{
228+
/* Success! Apply the change, clean up, and exit */
225229
GenericXLogFinish(state);
226230
UnlockReleaseBuffer(buffer);
227231
ReleaseBuffer(metaBuffer);
228232
MemoryContextSwitchTo(oldCtx);
229233
MemoryContextDelete(insertCtx);
230234
return false;
231235
}
232-
else
233-
{
234-
GenericXLogAbort(state);
235-
UnlockReleaseBuffer(buffer);
236-
}
236+
237+
/* Didn't fit, must try other pages */
238+
GenericXLogAbort(state);
239+
UnlockReleaseBuffer(buffer);
237240
}
238241
else
239242
{
240-
/* First page in notFullPage isn't suitable */
243+
/* No entries in notFullPage */
241244
LockBuffer(metaBuffer, BUFFER_LOCK_UNLOCK);
242245
}
243246

@@ -247,20 +250,30 @@ blinsert(Relation index, Datum *values, bool *isnull,
247250
*/
248251
LockBuffer(metaBuffer, BUFFER_LOCK_EXCLUSIVE);
249252

250-
state = GenericXLogStart(index);
251-
metaPage = GenericXLogRegister(state, metaBuffer, false);
252-
metaData = BloomPageGetMeta(metaPage);
253-
254-
/*
255-
* Iterate over notFullPage array. Skip page we already tried first.
256-
*/
253+
/* nStart might have changed while we didn't have lock */
257254
nStart = metaData->nStart;
258-
if (metaData->nEnd > nStart &&
255+
256+
/* Skip first page if we already tried it above */
257+
if (nStart < metaData->nEnd &&
259258
blkno == metaData->notFullPage[nStart])
260259
nStart++;
261260

262-
while (metaData->nEnd > nStart)
261+
/*
262+
* This loop iterates for each page we try from the notFullPage array, and
263+
* will also initialize a GenericXLogState for the fallback case of having
264+
* to allocate a new page.
265+
*/
266+
for (;;)
263267
{
268+
state = GenericXLogStart(index);
269+
270+
/* get modifiable copy of metapage */
271+
metaPage = GenericXLogRegister(state, metaBuffer, false);
272+
metaData = BloomPageGetMeta(metaPage);
273+
274+
if (nStart >= metaData->nEnd)
275+
break; /* no more entries in notFullPage array */
276+
264277
blkno = metaData->notFullPage[nStart];
265278
Assert(blkno != InvalidBlockNumber);
266279

@@ -270,6 +283,7 @@ blinsert(Relation index, Datum *values, bool *isnull,
270283

271284
if (BloomPageAddItem(&blstate, page, itup))
272285
{
286+
/* Success! Apply the changes, clean up, and exit */
273287
metaData->nStart = nStart;
274288
GenericXLogFinish(state);
275289
UnlockReleaseBuffer(buffer);
@@ -278,41 +292,41 @@ blinsert(Relation index, Datum *values, bool *isnull,
278292
MemoryContextDelete(insertCtx);
279293
return false;
280294
}
281-
else
282-
{
283-
GenericXLogUnregister(state, buffer);
284-
UnlockReleaseBuffer(buffer);
285-
}
295+
296+
/* Didn't fit, must try other pages */
297+
GenericXLogAbort(state);
298+
UnlockReleaseBuffer(buffer);
286299
nStart++;
287300
}
288301

289-
GenericXLogAbort(state);
290-
291302
/*
292303
* Didn't find place to insert in notFullPage array. Allocate new page.
304+
* (XXX is it good to do this while holding ex-lock on the metapage??)
293305
*/
294306
buffer = BloomNewBuffer(index);
295307

296-
state = GenericXLogStart(index);
297-
metaPage = GenericXLogRegister(state, metaBuffer, false);
298-
metaData = BloomPageGetMeta(metaPage);
299308
page = GenericXLogRegister(state, buffer, true);
300309
BloomInitPage(page, 0);
301310

302311
if (!BloomPageAddItem(&blstate, page, itup))
303312
{
304-
/* We shouldn't be here since we're inserting to the empty page */
313+
/* We shouldn't be here since we're inserting to an empty page */
305314
elog(ERROR, "could not add new bloom tuple to empty page");
306315
}
307316

317+
/* Reset notFullPage array to contain just this new page */
308318
metaData->nStart = 0;
309319
metaData->nEnd = 1;
310320
metaData->notFullPage[0] = BufferGetBlockNumber(buffer);
311321

322+
/* Apply the changes, clean up, and exit */
312323
GenericXLogFinish(state);
313324

314325
UnlockReleaseBuffer(buffer);
315326
UnlockReleaseBuffer(metaBuffer);
316327

328+
MemoryContextSwitchTo(oldCtx);
329+
MemoryContextDelete(insertCtx);
330+
317331
return false;
318332
}

contrib/bloom/blscan.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
138138
blkno, RBM_NORMAL, bas);
139139

140140
LockBuffer(buffer, BUFFER_LOCK_SHARE);
141-
page = BufferGetPage(buffer);
141+
page = BufferGetPage(buffer, scan->xs_snapshot, scan->indexRelation,
142+
BGP_TEST_FOR_OLD_SNAPSHOT);
142143

143144
if (!BloomPageIsDeleted(page))
144145
{

contrib/bloom/blutils.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ initBloomState(BloomState *state, Relation index)
139139
buffer = ReadBuffer(index, BLOOM_METAPAGE_BLKNO);
140140
LockBuffer(buffer, BUFFER_LOCK_SHARE);
141141

142-
page = BufferGetPage(buffer);
142+
page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
143143

144144
if (!BloomPageIsMeta(page))
145145
elog(ERROR, "Relation is not a bloom index");
146-
meta = BloomPageGetMeta(BufferGetPage(buffer));
146+
meta = BloomPageGetMeta(BufferGetPage(buffer, NULL, NULL,
147+
BGP_NO_SNAPSHOT_TEST));
147148

148149
if (meta->magickNumber != BLOOM_MAGICK_NUMBER)
149150
elog(ERROR, "Relation is not a bloom index");
@@ -315,7 +316,8 @@ BloomNewBuffer(Relation index)
315316
*/
316317
if (ConditionalLockBuffer(buffer))
317318
{
318-
Page page = BufferGetPage(buffer);
319+
Page page = BufferGetPage(buffer, NULL, NULL,
320+
BGP_NO_SNAPSHOT_TEST);
319321

320322
if (PageIsNew(page))
321323
return buffer; /* OK to use, if never initialized */

contrib/bloom/blvacuum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ blvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
194194
buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno,
195195
RBM_NORMAL, info->strategy);
196196
LockBuffer(buffer, BUFFER_LOCK_SHARE);
197-
page = (Page) BufferGetPage(buffer);
197+
page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
198198

199199
if (BloomPageIsDeleted(page))
200200
{

0 commit comments

Comments
 (0)