Skip to content

Commit 9ad3ab9

Browse files
committed
Merge branch 'REL9_5_STABLE' into PGPRO9_5
2 parents d22d445 + 8ee2e5f commit 9ad3ab9

File tree

15 files changed

+121
-12
lines changed

15 files changed

+121
-12
lines changed

config/c-library.m4

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,34 @@ fi
343343
if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
344344
AC_DEFINE(LOCALE_T_IN_XLOCALE, 1,
345345
[Define to 1 if `locale_t' requires <xlocale.h>.])
346-
fi])])# PGAC_HEADER_XLOCALE
346+
fi])# PGAC_TYPE_LOCALE_T
347+
348+
349+
# PGAC_FUNC_WCSTOMBS_L
350+
# --------------------
351+
# Try to find a declaration for wcstombs_l(). It might be in stdlib.h
352+
# (following the POSIX requirement for wcstombs()), or in locale.h, or in
353+
# xlocale.h. If it's in the latter, define WCSTOMBS_L_IN_XLOCALE.
354+
#
355+
AC_DEFUN([PGAC_FUNC_WCSTOMBS_L],
356+
[AC_CACHE_CHECK([for wcstombs_l declaration], pgac_cv_func_wcstombs_l,
357+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
358+
[#include <stdlib.h>
359+
#include <locale.h>],
360+
[#ifndef wcstombs_l
361+
(void) wcstombs_l;
362+
#endif])],
363+
[pgac_cv_func_wcstombs_l='yes'],
364+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
365+
[#include <stdlib.h>
366+
#include <locale.h>
367+
#include <xlocale.h>],
368+
[#ifndef wcstombs_l
369+
(void) wcstombs_l;
370+
#endif])],
371+
[pgac_cv_func_wcstombs_l='yes (in xlocale.h)'],
372+
[pgac_cv_func_wcstombs_l='no'])])])
373+
if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
374+
AC_DEFINE(WCSTOMBS_L_IN_XLOCALE, 1,
375+
[Define to 1 if `wcstombs_l' requires <xlocale.h>.])
376+
fi])# PGAC_FUNC_WCSTOMBS_L

configure

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13429,6 +13429,59 @@ $as_echo "#define GETTIMEOFDAY_1ARG 1" >>confdefs.h
1342913429

1343013430
fi
1343113431

13432+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wcstombs_l declaration" >&5
13433+
$as_echo_n "checking for wcstombs_l declaration... " >&6; }
13434+
if ${pgac_cv_func_wcstombs_l+:} false; then :
13435+
$as_echo_n "(cached) " >&6
13436+
else
13437+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13438+
/* end confdefs.h. */
13439+
#include <stdlib.h>
13440+
#include <locale.h>
13441+
int
13442+
main ()
13443+
{
13444+
#ifndef wcstombs_l
13445+
(void) wcstombs_l;
13446+
#endif
13447+
;
13448+
return 0;
13449+
}
13450+
_ACEOF
13451+
if ac_fn_c_try_compile "$LINENO"; then :
13452+
pgac_cv_func_wcstombs_l='yes'
13453+
else
13454+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13455+
/* end confdefs.h. */
13456+
#include <stdlib.h>
13457+
#include <locale.h>
13458+
#include <xlocale.h>
13459+
int
13460+
main ()
13461+
{
13462+
#ifndef wcstombs_l
13463+
(void) wcstombs_l;
13464+
#endif
13465+
;
13466+
return 0;
13467+
}
13468+
_ACEOF
13469+
if ac_fn_c_try_compile "$LINENO"; then :
13470+
pgac_cv_func_wcstombs_l='yes (in xlocale.h)'
13471+
else
13472+
pgac_cv_func_wcstombs_l='no'
13473+
fi
13474+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13475+
fi
13476+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13477+
fi
13478+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_func_wcstombs_l" >&5
13479+
$as_echo "$pgac_cv_func_wcstombs_l" >&6; }
13480+
if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
13481+
13482+
$as_echo "#define WCSTOMBS_L_IN_XLOCALE 1" >>confdefs.h
13483+
13484+
fi
1343213485

1343313486
# Some versions of libedit contain strlcpy(), setproctitle(), and other
1343413487
# symbols that that library has no business exposing to the world. Pending

configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ fi
14011401
PGAC_VAR_INT_TIMEZONE
14021402
AC_FUNC_ACCEPT_ARGTYPES
14031403
PGAC_FUNC_GETTIMEOFDAY_1ARG
1404+
PGAC_FUNC_WCSTOMBS_L
14041405

14051406
# Some versions of libedit contain strlcpy(), setproctitle(), and other
14061407
# symbols that that library has no business exposing to the world. Pending

src/backend/access/gin/ginget.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ startScanEntry(GinState *ginstate, GinScanEntry entry)
302302
entry->buffer = InvalidBuffer;
303303
ItemPointerSetMin(&entry->curItem);
304304
entry->offset = InvalidOffsetNumber;
305+
if (entry->list)
306+
pfree(entry->list);
305307
entry->list = NULL;
306308
entry->nlist = 0;
307309
entry->matchBitmap = NULL;

src/backend/access/gin/ginscan.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ ginFreeScanKeys(GinScanOpaque so)
249249

250250
if (entry->buffer != InvalidBuffer)
251251
ReleaseBuffer(entry->buffer);
252+
if (entry->list)
253+
pfree(entry->list);
252254
if (entry->matchIterator)
253255
tbm_end_iterate(entry->matchIterator);
254256
if (entry->matchBitmap)
@@ -288,7 +290,7 @@ ginNewScanKey(IndexScanDesc scan)
288290
so->totalentries = 0;
289291
so->allocentries = 32;
290292
so->entries = (GinScanEntry *)
291-
palloc0(so->allocentries * sizeof(GinScanEntry));
293+
palloc(so->allocentries * sizeof(GinScanEntry));
292294

293295
so->isVoidRes = false;
294296

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
30693069
*
30703070
* destsegno: identify segment to be created.
30713071
*
3072-
* srcTLI, srclog, srcseg: identify segment to be copied (could be from
3072+
* srcTLI, srcsegno: identify segment to be copied (could be from
30733073
* a different timeline)
30743074
*
30753075
* upto: how much of the source file to copy (the rest is filled with
@@ -6977,7 +6977,7 @@ StartupXLOG(void)
69776977
* EndOfLogTLI is the TLI in the filename of the XLOG segment containing
69786978
* the end-of-log. It could be different from the timeline that EndOfLog
69796979
* nominally belongs to, if there was a timeline switch in that segment,
6980-
* and we were reading the old wAL from a segment belonging to a higher
6980+
* and we were reading the old WAL from a segment belonging to a higher
69816981
* timeline.
69826982
*/
69836983
EndOfLogTLI = xlogreader->readPageTLI;

src/backend/executor/execIndexing.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ check_exclusion_or_unique_constraint(Relation heap, Relation index,
726726
{
727727
TransactionId xwait;
728728
ItemPointerData ctid_wait;
729+
XLTW_Oper reason_wait;
729730
Datum existing_values[INDEX_MAX_KEYS];
730731
bool existing_isnull[INDEX_MAX_KEYS];
731732
char *error_new;
@@ -784,13 +785,14 @@ check_exclusion_or_unique_constraint(Relation heap, Relation index,
784785
TransactionIdPrecedes(GetCurrentTransactionId(), xwait))))
785786
{
786787
ctid_wait = tup->t_data->t_ctid;
788+
reason_wait = indexInfo->ii_ExclusionOps ?
789+
XLTW_RecheckExclusionConstr : XLTW_InsertIndex;
787790
index_endscan(index_scan);
788791
if (DirtySnapshot.speculativeToken)
789792
SpeculativeInsertionWait(DirtySnapshot.xmin,
790793
DirtySnapshot.speculativeToken);
791794
else
792-
XactLockTableWait(xwait, heap, &ctid_wait,
793-
XLTW_RecheckExclusionConstr);
795+
XactLockTableWait(xwait, heap, &ctid_wait, reason_wait);
794796
goto retry;
795797
}
796798

src/backend/utils/mmgr/mcxt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,13 @@ repalloc(void *pointer, Size size)
969969

970970
ret = (*context->methods->realloc) (context, pointer, size);
971971
if (ret == NULL)
972+
{
973+
MemoryContextStats(TopMemoryContext);
972974
ereport(ERROR,
973975
(errcode(ERRCODE_OUT_OF_MEMORY),
974976
errmsg("out of memory"),
975977
errdetail("Failed on request of size %zu.", size)));
978+
}
976979

977980
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
978981

@@ -1049,10 +1052,13 @@ repalloc_huge(void *pointer, Size size)
10491052

10501053
ret = (*context->methods->realloc) (context, pointer, size);
10511054
if (ret == NULL)
1055+
{
1056+
MemoryContextStats(TopMemoryContext);
10521057
ereport(ERROR,
10531058
(errcode(ERRCODE_OUT_OF_MEMORY),
10541059
errmsg("out of memory"),
10551060
errdetail("Failed on request of size %zu.", size)));
1061+
}
10561062

10571063
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
10581064

src/bin/pgbench/pgbench.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ typedef struct
212212
int state; /* state No. */
213213
int cnt; /* xacts count */
214214
int ecnt; /* error count */
215-
int listen; /* 0 indicates that an async query has been
215+
int listen; /* 1 indicates that an async query has been
216216
* sent */
217217
int sleeping; /* 1 indicates that the client is napping */
218218
bool throttling; /* whether nap is for throttling */
@@ -1405,6 +1405,13 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
14051405
}
14061406
INSTR_TIME_SET_CURRENT(end);
14071407
INSTR_TIME_ACCUM_DIFF(*conn_time, end, start);
1408+
1409+
/* Reset session-local state */
1410+
st->listen = 0;
1411+
st->sleeping = 0;
1412+
st->throttling = false;
1413+
st->is_throttled = false;
1414+
memset(st->prepared, 0, sizeof(st->prepared));
14081415
}
14091416

14101417
/*

src/bin/psql/print.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const printTextFormat pg_asciiformat_old =
9898
};
9999

100100
/* Default unicode linestyle format */
101-
const printTextFormat pg_utf8format;
101+
printTextFormat pg_utf8format;
102102

103103
typedef struct unicodeStyleRowFormat
104104
{
@@ -3410,7 +3410,7 @@ get_line_style(const printTableOpt *opt)
34103410
void
34113411
refresh_utf8format(const printTableOpt *opt)
34123412
{
3413-
printTextFormat *popt = (printTextFormat *) &pg_utf8format;
3413+
printTextFormat *popt = &pg_utf8format;
34143414

34153415
const unicodeStyleBorderFormat *border;
34163416
const unicodeStyleRowFormat *header;

src/bin/psql/print.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ typedef struct printQueryOpt
164164

165165
extern const printTextFormat pg_asciiformat;
166166
extern const printTextFormat pg_asciiformat_old;
167-
extern const printTextFormat pg_utf8format;
167+
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
168168

169169

170170
extern void disable_sigpipe_trap(void);

src/bin/psql/tab-complete.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3419,7 +3419,7 @@ psql_completion(const char *text, int start, int end)
34193419
pg_strcasecmp(prev_wd, "LABEL") == 0)
34203420
{
34213421
static const char *const list_SECURITY_LABEL_preposition[] =
3422-
{"ON", "FOR"};
3422+
{"ON", "FOR", NULL};
34233423

34243424
COMPLETE_WITH_LIST(list_SECURITY_LABEL_preposition);
34253425
}

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@
860860
/* Define to select Win32-style shared memory. */
861861
#undef USE_WIN32_SHARED_MEMORY
862862

863+
/* Define to 1 if `wcstombs_l' requires <xlocale.h>. */
864+
#undef WCSTOMBS_L_IN_XLOCALE
865+
863866
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
864867
significant byte first (like Motorola and SPARC, unlike Intel). */
865868
#if defined AC_APPLE_UNIVERSAL_BUILD

src/include/pg_config.h.win32

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,9 @@
670670
/* Define to select Win32-style semaphores. */
671671
#define USE_WIN32_SEMAPHORES 1
672672

673+
/* Define to 1 if `wcstombs_l' requires <xlocale.h>. */
674+
/* #undef WCSTOMBS_L_IN_XLOCALE */
675+
673676
/* Number of bits in a file offset, on hosts where this is settable. */
674677
/* #undef _FILE_OFFSET_BITS */
675678

src/include/utils/pg_locale.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define _PG_LOCALE_
1414

1515
#include <locale.h>
16-
#ifdef LOCALE_T_IN_XLOCALE
16+
#if defined(LOCALE_T_IN_XLOCALE) || defined(WCSTOMBS_L_IN_XLOCALE)
1717
#include <xlocale.h>
1818
#endif
1919

0 commit comments

Comments
 (0)