Skip to content

Commit ebe8abc

Browse files
committed
Imported patches from REL9_6_STABLE up to today
2 parents c8b6d48 + 1ec36a9 commit ebe8abc

File tree

128 files changed

+2349
-990
lines changed

Some content is hidden

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

128 files changed

+2349
-990
lines changed

contrib/adminpack/adminpack.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,22 @@ pg_file_write(PG_FUNCTION_ARGS)
136136
(ERRCODE_DUPLICATE_FILE,
137137
errmsg("file \"%s\" exists", filename)));
138138

139-
f = fopen(filename, "wb");
139+
f = AllocateFile(filename, "wb");
140140
}
141141
else
142-
f = fopen(filename, "ab");
142+
f = AllocateFile(filename, "ab");
143143

144144
if (!f)
145145
ereport(ERROR,
146146
(errcode_for_file_access(),
147147
errmsg("could not open file \"%s\" for writing: %m",
148148
filename)));
149149

150-
if (VARSIZE(data) != 0)
151-
{
152-
count = fwrite(VARDATA(data), 1, VARSIZE(data) - VARHDRSZ, f);
153-
154-
if (count != VARSIZE(data) - VARHDRSZ)
155-
ereport(ERROR,
156-
(errcode_for_file_access(),
157-
errmsg("could not write file \"%s\": %m", filename)));
158-
}
159-
fclose(f);
150+
count = fwrite(VARDATA(data), 1, VARSIZE(data) - VARHDRSZ, f);
151+
if (count != VARSIZE(data) - VARHDRSZ || FreeFile(f))
152+
ereport(ERROR,
153+
(errcode_for_file_access(),
154+
errmsg("could not write file \"%s\": %m", filename)));
160155

161156
PG_RETURN_INT64(count);
162157
}

contrib/dblink/dblink.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ dblink_connect(PG_FUNCTION_ARGS)
301301
createNewConnection(connname, rconn);
302302
}
303303
else
304+
{
305+
if (pconn->conn)
306+
PQfinish(pconn->conn);
304307
pconn->conn = conn;
308+
}
305309

306310
PG_RETURN_TEXT_P(cstring_to_text("OK"));
307311
}

contrib/ltree/ltxtquery_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ gettoken_query(QPRS_STATE *state, int32 *val, int32 *lenval, char **strval, uint
9696
if (*flag)
9797
ereport(ERROR,
9898
(errcode(ERRCODE_SYNTAX_ERROR),
99-
errmsg("modificators syntax error")));
99+
errmsg("modifiers syntax error")));
100100
*lenval += charlen;
101101
}
102102
else if (charlen == 1 && t_iseq(state->buf, '%'))

contrib/pg_trgm/expected/pg_trgm.out

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,12 @@ select t <-> 'q0987wertyu0988', t from test_trgm order by t <-> 'q0987wertyu0988
11941194
0.5 | qwertyu0987
11951195
(2 rows)
11961196

1197+
select count(*) from test_trgm where t ~ '[qwerty]{2}-?[qwerty]{2}';
1198+
count
1199+
-------
1200+
1000
1201+
(1 row)
1202+
11971203
create index trgm_idx on test_trgm using gist (t gist_trgm_ops);
11981204
set enable_seqscan=off;
11991205
select t,similarity(t,'qwertyu0988') as sml from test_trgm where t % 'qwertyu0988' order by sml desc, t;
@@ -2338,6 +2344,12 @@ select t <-> 'q0987wertyu0988', t from test_trgm order by t <-> 'q0987wertyu0988
23382344
0.5 | qwertyu0987
23392345
(2 rows)
23402346

2347+
select count(*) from test_trgm where t ~ '[qwerty]{2}-?[qwerty]{2}';
2348+
count
2349+
-------
2350+
1000
2351+
(1 row)
2352+
23412353
drop index trgm_idx;
23422354
create index trgm_idx on test_trgm using gin (t gin_trgm_ops);
23432355
set enable_seqscan=off;
@@ -3467,10 +3479,17 @@ select t,similarity(t,'gwertyu1988') as sml from test_trgm where t % 'gwertyu198
34673479
qwertyu0988 | 0.333333
34683480
(1 row)
34693481

3482+
select count(*) from test_trgm where t ~ '[qwerty]{2}-?[qwerty]{2}';
3483+
count
3484+
-------
3485+
1000
3486+
(1 row)
3487+
34703488
create table test2(t text COLLATE "C");
34713489
insert into test2 values ('abcdef');
34723490
insert into test2 values ('quark');
34733491
insert into test2 values (' z foo bar');
3492+
insert into test2 values ('/123/-45/');
34743493
create index test2_idx_gin on test2 using gin (t gin_trgm_ops);
34753494
set enable_seqscan=off;
34763495
explain (costs off)
@@ -3572,7 +3591,8 @@ select * from test2 where t ~ '(abc)*$';
35723591
abcdef
35733592
quark
35743593
z foo bar
3575-
(3 rows)
3594+
/123/-45/
3595+
(4 rows)
35763596

35773597
select * from test2 where t ~* 'DEF';
35783598
t
@@ -3658,6 +3678,18 @@ select * from test2 where t ~ ' z foo';
36583678
z foo bar
36593679
(1 row)
36603680

3681+
select * from test2 where t ~ 'qua(?!foo)';
3682+
t
3683+
-------
3684+
quark
3685+
(1 row)
3686+
3687+
select * from test2 where t ~ '/\d+/-\d';
3688+
t
3689+
-----------
3690+
/123/-45/
3691+
(1 row)
3692+
36613693
drop index test2_idx_gin;
36623694
create index test2_idx_gist on test2 using gist (t gist_trgm_ops);
36633695
set enable_seqscan=off;
@@ -3752,7 +3784,8 @@ select * from test2 where t ~ '(abc)*$';
37523784
abcdef
37533785
quark
37543786
z foo bar
3755-
(3 rows)
3787+
/123/-45/
3788+
(4 rows)
37563789

37573790
select * from test2 where t ~* 'DEF';
37583791
t
@@ -3838,6 +3871,18 @@ select * from test2 where t ~ ' z foo';
38383871
z foo bar
38393872
(1 row)
38403873

3874+
select * from test2 where t ~ 'qua(?!foo)';
3875+
t
3876+
-------
3877+
quark
3878+
(1 row)
3879+
3880+
select * from test2 where t ~ '/\d+/-\d';
3881+
t
3882+
-----------
3883+
/123/-45/
3884+
(1 row)
3885+
38413886
-- Check similarity threshold (bug #14202)
38423887
CREATE TEMP TABLE restaurants (city text);
38433888
INSERT INTO restaurants SELECT 'Warsaw' FROM generate_series(1, 10000);

contrib/pg_trgm/sql/pg_trgm.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ select t,similarity(t,'qwertyu0988') as sml from test_trgm where t % 'qwertyu098
2121
select t,similarity(t,'gwertyu0988') as sml from test_trgm where t % 'gwertyu0988' order by sml desc, t;
2222
select t,similarity(t,'gwertyu1988') as sml from test_trgm where t % 'gwertyu1988' order by sml desc, t;
2323
select t <-> 'q0987wertyu0988', t from test_trgm order by t <-> 'q0987wertyu0988' limit 2;
24+
select count(*) from test_trgm where t ~ '[qwerty]{2}-?[qwerty]{2}';
2425

2526
create index trgm_idx on test_trgm using gist (t gist_trgm_ops);
2627
set enable_seqscan=off;
@@ -31,6 +32,7 @@ select t,similarity(t,'gwertyu1988') as sml from test_trgm where t % 'gwertyu198
3132
explain (costs off)
3233
select t <-> 'q0987wertyu0988', t from test_trgm order by t <-> 'q0987wertyu0988' limit 2;
3334
select t <-> 'q0987wertyu0988', t from test_trgm order by t <-> 'q0987wertyu0988' limit 2;
35+
select count(*) from test_trgm where t ~ '[qwerty]{2}-?[qwerty]{2}';
3436

3537
drop index trgm_idx;
3638
create index trgm_idx on test_trgm using gin (t gin_trgm_ops);
@@ -39,11 +41,13 @@ set enable_seqscan=off;
3941
select t,similarity(t,'qwertyu0988') as sml from test_trgm where t % 'qwertyu0988' order by sml desc, t;
4042
select t,similarity(t,'gwertyu0988') as sml from test_trgm where t % 'gwertyu0988' order by sml desc, t;
4143
select t,similarity(t,'gwertyu1988') as sml from test_trgm where t % 'gwertyu1988' order by sml desc, t;
44+
select count(*) from test_trgm where t ~ '[qwerty]{2}-?[qwerty]{2}';
4245

4346
create table test2(t text COLLATE "C");
4447
insert into test2 values ('abcdef');
4548
insert into test2 values ('quark');
4649
insert into test2 values (' z foo bar');
50+
insert into test2 values ('/123/-45/');
4751
create index test2_idx_gin on test2 using gin (t gin_trgm_ops);
4852
set enable_seqscan=off;
4953
explain (costs off)
@@ -78,7 +82,10 @@ select * from test2 where t ~ 'z foo bar';
7882
select * from test2 where t ~ ' z foo bar';
7983
select * from test2 where t ~ ' z foo bar';
8084
select * from test2 where t ~ ' z foo';
85+
select * from test2 where t ~ 'qua(?!foo)';
86+
select * from test2 where t ~ '/\d+/-\d';
8187
drop index test2_idx_gin;
88+
8289
create index test2_idx_gist on test2 using gist (t gist_trgm_ops);
8390
set enable_seqscan=off;
8491
explain (costs off)
@@ -113,6 +120,8 @@ select * from test2 where t ~ 'z foo bar';
113120
select * from test2 where t ~ ' z foo bar';
114121
select * from test2 where t ~ ' z foo bar';
115122
select * from test2 where t ~ ' z foo';
123+
select * from test2 where t ~ 'qua(?!foo)';
124+
select * from test2 where t ~ '/\d+/-\d';
116125

117126
-- Check similarity threshold (bug #14202)
118127

0 commit comments

Comments
 (0)