Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7d6a2bc

Browse files
committed
Merge branch 'REL9_6_STABLE' into PGPRO9_6
2 parents 23b3cac + 60c1d8f commit 7d6a2bc

File tree

13 files changed

+226
-17
lines changed

13 files changed

+226
-17
lines changed

doc/src/sgml/install-windows.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
161161
<productname>Microsoft Windows SDK</productname> it
162162
is recommended that you upgrade to the latest version (currently
163163
version 7.1), available for download from
164-
<ulink url="http://www.microsoft.com/downloads/"></>.
164+
<ulink url="https://www.microsoft.com/download"></>.
165165
</para>
166166
<para>
167167
You must always include the

src/backend/replication/walreceiver.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,10 @@ XLogWalRcvSendReply(bool force, bool requestReply)
11541154
* in case they don't have a watch.
11551155
*
11561156
* If the user disables feedback, send one final message to tell sender
1157-
* to forget about the xmin on this standby.
1157+
* to forget about the xmin on this standby. We also send this message
1158+
* on first connect because a previous connection might have set xmin
1159+
* on a replication slot. (If we're not using a slot it's harmless to
1160+
* send a feedback message explicitly setting InvalidTransactionId).
11581161
*/
11591162
static void
11601163
XLogWalRcvSendHSFeedback(bool immed)
@@ -1164,7 +1167,8 @@ XLogWalRcvSendHSFeedback(bool immed)
11641167
uint32 nextEpoch;
11651168
TransactionId xmin;
11661169
static TimestampTz sendTime = 0;
1167-
static bool master_has_standby_xmin = false;
1170+
/* initially true so we always send at least one feedback message */
1171+
static bool master_has_standby_xmin = true;
11681172

11691173
/*
11701174
* If the user doesn't want status to be reported to the master, be sure
@@ -1189,14 +1193,17 @@ XLogWalRcvSendHSFeedback(bool immed)
11891193
}
11901194

11911195
/*
1192-
* If Hot Standby is not yet active there is nothing to send. Check this
1193-
* after the interval has expired to reduce number of calls.
1196+
* If Hot Standby is not yet accepting connections there is nothing to
1197+
* send. Check this after the interval has expired to reduce number of
1198+
* calls.
1199+
*
1200+
* Bailing out here also ensures that we don't send feedback until we've
1201+
* read our own replication slot state, so we don't tell the master to
1202+
* discard needed xmin or catalog_xmin from any slots that may exist
1203+
* on this replica.
11941204
*/
11951205
if (!HotStandbyActive())
1196-
{
1197-
Assert(!master_has_standby_xmin);
11981206
return;
1199-
}
12001207

12011208
/*
12021209
* Make the expensive call to get the oldest xmin once we are certain

src/backend/storage/buffer/freelist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ StrategySyncStart(uint32 *complete_passes, uint32 *num_buf_alloc)
406406
/*
407407
* StrategyNotifyBgWriter -- set or clear allocation notification latch
408408
*
409-
* If bgwriterLatch isn't NULL, the next invocation of StrategyGetBuffer will
410-
* set that latch. Pass NULL to clear the pending notification before it
409+
* If bgwprocno isn't -1, the next invocation of StrategyGetBuffer will
410+
* set that latch. Pass -1 to clear the pending notification before it
411411
* happens. This feature is used by the bgwriter process to wake itself up
412412
* from hibernation, and is not meant for anybody else to use.
413413
*/

src/backend/storage/ipc/standby.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ WaitExceedsMaxStandbyDelay(void)
160160
{
161161
TimestampTz ltime;
162162

163+
CHECK_FOR_INTERRUPTS();
164+
163165
/* Are we past the limit time? */
164166
ltime = GetStandbyLimitTime();
165167
if (ltime && GetCurrentTimestamp() >= ltime)

src/backend/tcop/postgres.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ pg_plan_queries(List *querytrees, int cursorOptions, ParamListInfo boundParams)
844844

845845
foreach(query_list, querytrees)
846846
{
847-
Query *query = (Query *) lfirst(query_list);
847+
Query *query = castNode(Query, lfirst(query_list));
848848
Node *stmt;
849849

850850
if (query->commandType == CMD_UTILITY)

src/backend/utils/adt/tsvector_op.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,8 @@ ts_match_vq(PG_FUNCTION_ARGS)
19261926
CHKVAL chkval;
19271927
bool result;
19281928

1929-
if (!val->size || !query->size)
1929+
/* empty query matches nothing */
1930+
if (!query->size)
19301931
{
19311932
PG_FREE_IF_COPY(val, 0);
19321933
PG_FREE_IF_COPY(query, 1);

src/include/nodes/nodes.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,26 @@ extern PGDLLIMPORT Node *newNodeMacroHolder;
543543

544544
#define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
545545

546+
/*
547+
* castNode(type, ptr) casts ptr to "type *", and if assertions are enabled,
548+
* verifies that the node has the appropriate type (using its nodeTag()).
549+
*
550+
* Use an inline function when assertions are enabled, to avoid multiple
551+
* evaluations of the ptr argument (which could e.g. be a function call).
552+
*/
553+
#ifdef USE_ASSERT_CHECKING
554+
static inline Node *
555+
castNodeImpl(NodeTag type, void *ptr)
556+
{
557+
Assert(ptr == NULL || nodeTag(ptr) == type);
558+
return (Node *) ptr;
559+
}
560+
#define castNode(_type_, nodeptr) ((_type_ *) castNodeImpl(T_##_type_, nodeptr))
561+
#else
562+
#define castNode(_type_, nodeptr) ((_type_ *) (nodeptr))
563+
#endif /* USE_ASSERT_CHECKING */
564+
565+
546566
/* ----------------------------------------------------------------
547567
* extern declarations follow
548568
* ----------------------------------------------------------------

src/test/modules/test_ddl_deparse/expected/comment_on.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ COMMENT ON TRIGGER trigger_1 ON datatype_table IS 'TRIGGER test';
2121
NOTICE: DDL test: type simple, tag COMMENT
2222
COMMENT ON RULE rule_1 IS 'RULE test';
2323
NOTICE: DDL test: type simple, tag COMMENT
24-
-- should not fire
25-
COMMENT ON DATABASE contrib_regression IS 'contrib regression';

src/test/modules/test_ddl_deparse/sql/comment_on.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,3 @@ COMMENT ON VIEW datatype_view IS 'This is a view';
1212
COMMENT ON FUNCTION c_function_test() IS 'FUNCTION test';
1313
COMMENT ON TRIGGER trigger_1 ON datatype_table IS 'TRIGGER test';
1414
COMMENT ON RULE rule_1 IS 'RULE test';
15-
16-
-- should not fire
17-
COMMENT ON DATABASE contrib_regression IS 'contrib regression';

src/test/regress/expected/tsearch.out

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,108 @@ SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
9898
494
9999
(1 row)
100100

101+
SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}');
102+
count
103+
-------
104+
158
105+
(1 row)
106+
107+
SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme';
108+
count
109+
-------
110+
0
111+
(1 row)
112+
113+
SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme';
114+
count
115+
-------
116+
508
117+
(1 row)
118+
101119
create index wowidx on test_tsvector using gist (a);
102120
SET enable_seqscan=OFF;
121+
SET enable_indexscan=ON;
122+
SET enable_bitmapscan=OFF;
123+
explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
124+
QUERY PLAN
125+
-------------------------------------------------------
126+
Aggregate
127+
-> Index Scan using wowidx on test_tsvector
128+
Index Cond: (a @@ '''wr'' | ''qh'''::tsquery)
129+
(3 rows)
130+
131+
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
132+
count
133+
-------
134+
158
135+
(1 row)
136+
137+
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh';
138+
count
139+
-------
140+
17
141+
(1 row)
142+
143+
SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt';
144+
count
145+
-------
146+
6
147+
(1 row)
148+
149+
SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt';
150+
count
151+
-------
152+
98
153+
(1 row)
154+
155+
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
156+
count
157+
-------
158+
23
159+
(1 row)
160+
161+
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
162+
count
163+
-------
164+
39
165+
(1 row)
166+
167+
SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
168+
count
169+
-------
170+
494
171+
(1 row)
172+
173+
SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}');
174+
count
175+
-------
176+
158
177+
(1 row)
178+
179+
SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme';
180+
count
181+
-------
182+
0
183+
(1 row)
184+
185+
SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme';
186+
count
187+
-------
188+
508
189+
(1 row)
190+
191+
SET enable_indexscan=OFF;
192+
SET enable_bitmapscan=ON;
193+
explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
194+
QUERY PLAN
195+
-------------------------------------------------------------
196+
Aggregate
197+
-> Bitmap Heap Scan on test_tsvector
198+
Recheck Cond: (a @@ '''wr'' | ''qh'''::tsquery)
199+
-> Bitmap Index Scan on wowidx
200+
Index Cond: (a @@ '''wr'' | ''qh'''::tsquery)
201+
(5 rows)
202+
103203
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
104204
count
105205
-------
@@ -148,10 +248,35 @@ SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}');
148248
158
149249
(1 row)
150250

251+
SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme';
252+
count
253+
-------
254+
0
255+
(1 row)
256+
257+
SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme';
258+
count
259+
-------
260+
508
261+
(1 row)
262+
151263
RESET enable_seqscan;
264+
RESET enable_indexscan;
265+
RESET enable_bitmapscan;
152266
DROP INDEX wowidx;
153267
CREATE INDEX wowidx ON test_tsvector USING gin (a);
154268
SET enable_seqscan=OFF;
269+
-- GIN only supports bitmapscan, so no need to test plain indexscan
270+
explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
271+
QUERY PLAN
272+
-------------------------------------------------------------
273+
Aggregate
274+
-> Bitmap Heap Scan on test_tsvector
275+
Recheck Cond: (a @@ '''wr'' | ''qh'''::tsquery)
276+
-> Bitmap Index Scan on wowidx
277+
Index Cond: (a @@ '''wr'' | ''qh'''::tsquery)
278+
(5 rows)
279+
155280
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
156281
count
157282
-------
@@ -200,6 +325,18 @@ SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}');
200325
158
201326
(1 row)
202327

328+
SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme';
329+
count
330+
-------
331+
0
332+
(1 row)
333+
334+
SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme';
335+
count
336+
-------
337+
508
338+
(1 row)
339+
203340
RESET enable_seqscan;
204341
INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH');
205342
SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10;

src/test/regress/expected/tstypes.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,18 @@ select to_tsvector('simple', 'x y q y') @@ '!x <-> y' AS "true";
773773
t
774774
(1 row)
775775

776+
select to_tsvector('simple', 'x y q y') @@ '!foo' AS "true";
777+
true
778+
------
779+
t
780+
(1 row)
781+
782+
select to_tsvector('simple', '') @@ '!foo' AS "true";
783+
true
784+
------
785+
t
786+
(1 row)
787+
776788
--ranking
777789
SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s');
778790
ts_rank

src/test/regress/sql/tsearch.sql

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,17 @@ SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt';
4848
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
4949
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
5050
SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
51+
SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}');
52+
SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme';
53+
SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme';
5154

5255
create index wowidx on test_tsvector using gist (a);
5356

5457
SET enable_seqscan=OFF;
58+
SET enable_indexscan=ON;
59+
SET enable_bitmapscan=OFF;
60+
61+
explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
5562

5663
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
5764
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh';
@@ -61,14 +68,37 @@ SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
6168
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
6269
SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
6370
SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}');
71+
SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme';
72+
SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme';
73+
74+
SET enable_indexscan=OFF;
75+
SET enable_bitmapscan=ON;
76+
77+
explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
78+
79+
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
80+
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh';
81+
SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt';
82+
SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt';
83+
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
84+
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
85+
SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
86+
SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}');
87+
SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme';
88+
SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme';
6489

6590
RESET enable_seqscan;
91+
RESET enable_indexscan;
92+
RESET enable_bitmapscan;
6693

6794
DROP INDEX wowidx;
6895

6996
CREATE INDEX wowidx ON test_tsvector USING gin (a);
7097

7198
SET enable_seqscan=OFF;
99+
-- GIN only supports bitmapscan, so no need to test plain indexscan
100+
101+
explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
72102

73103
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
74104
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh';
@@ -78,8 +108,11 @@ SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
78108
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
79109
SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
80110
SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}');
111+
SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme';
112+
SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme';
81113

82114
RESET enable_seqscan;
115+
83116
INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH');
84117
SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10;
85118
SELECT * FROM ts_stat('SELECT a FROM test_tsvector', 'AB') ORDER BY ndoc DESC, nentry DESC, word;

src/test/regress/sql/tstypes.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ select to_tsvector('simple', 'x q') @@ '(x | y <-> !z) <-> q' AS "true";
145145
select to_tsvector('simple', 'x q') @@ '(!x | y <-> z) <-> q' AS "false";
146146
select to_tsvector('simple', 'z q') @@ '(!x | y <-> z) <-> q' AS "true";
147147
select to_tsvector('simple', 'x y q y') @@ '!x <-> y' AS "true";
148+
select to_tsvector('simple', 'x y q y') @@ '!foo' AS "true";
149+
select to_tsvector('simple', '') @@ '!foo' AS "true";
148150

149151
--ranking
150152
SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s');

0 commit comments

Comments
 (0)