Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc56d19d

Browse files
committed
Merge fixes from REL9_5_STABLE
2 parents4deaae8 +c84c87c commitc56d19d

File tree

59 files changed

+1152
-421
lines changed

Some content is hidden

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

59 files changed

+1152
-421
lines changed

‎contrib/ltree/_ltree_gist.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
8585
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
8686
errmsg("array must not contain nulls")));
8787

88-
key= (ltree_gist*)palloc(len);
88+
key= (ltree_gist*)palloc0(len);
8989
SET_VARSIZE(key,len);
9090
key->flag=0;
9191

@@ -116,7 +116,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
116116
PG_RETURN_POINTER(retval);
117117
}
118118
len=LTG_HDRSIZE;
119-
key= (ltree_gist*)palloc(len);
119+
key= (ltree_gist*)palloc0(len);
120120
SET_VARSIZE(key,len);
121121
key->flag=LTG_ALLTRUE;
122122

@@ -196,7 +196,7 @@ _ltree_union(PG_FUNCTION_ARGS)
196196
}
197197

198198
len=LTG_HDRSIZE+ ((flag&LTG_ALLTRUE) ?0 :ASIGLEN);
199-
result= (ltree_gist*)palloc(len);
199+
result= (ltree_gist*)palloc0(len);
200200
SET_VARSIZE(result,len);
201201
result->flag=flag;
202202
if (!LTG_ISALLTRUE(result))
@@ -333,26 +333,26 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
333333
/* form initial .. */
334334
if (LTG_ISALLTRUE(GETENTRY(entryvec,seed_1)))
335335
{
336-
datum_l= (ltree_gist*)palloc(LTG_HDRSIZE);
336+
datum_l= (ltree_gist*)palloc0(LTG_HDRSIZE);
337337
SET_VARSIZE(datum_l,LTG_HDRSIZE);
338338
datum_l->flag=LTG_ALLTRUE;
339339
}
340340
else
341341
{
342-
datum_l= (ltree_gist*)palloc(LTG_HDRSIZE+ASIGLEN);
342+
datum_l= (ltree_gist*)palloc0(LTG_HDRSIZE+ASIGLEN);
343343
SET_VARSIZE(datum_l,LTG_HDRSIZE+ASIGLEN);
344344
datum_l->flag=0;
345345
memcpy((void*)LTG_SIGN(datum_l), (void*)LTG_SIGN(GETENTRY(entryvec,seed_1)),sizeof(ABITVEC));
346346
}
347347
if (LTG_ISALLTRUE(GETENTRY(entryvec,seed_2)))
348348
{
349-
datum_r= (ltree_gist*)palloc(LTG_HDRSIZE);
349+
datum_r= (ltree_gist*)palloc0(LTG_HDRSIZE);
350350
SET_VARSIZE(datum_r,LTG_HDRSIZE);
351351
datum_r->flag=LTG_ALLTRUE;
352352
}
353353
else
354354
{
355-
datum_r= (ltree_gist*)palloc(LTG_HDRSIZE+ASIGLEN);
355+
datum_r= (ltree_gist*)palloc0(LTG_HDRSIZE+ASIGLEN);
356356
SET_VARSIZE(datum_r,LTG_HDRSIZE+ASIGLEN);
357357
datum_r->flag=0;
358358
memcpy((void*)LTG_SIGN(datum_r), (void*)LTG_SIGN(GETENTRY(entryvec,seed_2)),sizeof(ABITVEC));

‎contrib/ltree/_ltree_op.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ _ltree_extract_isparent(PG_FUNCTION_ARGS)
211211
PG_RETURN_NULL();
212212
}
213213

214-
item= (ltree*)palloc(VARSIZE(found));
214+
item= (ltree*)palloc0(VARSIZE(found));
215215
memcpy(item,found,VARSIZE(found));
216216

217217
PG_FREE_IF_COPY(la,0);
@@ -234,7 +234,7 @@ _ltree_extract_risparent(PG_FUNCTION_ARGS)
234234
PG_RETURN_NULL();
235235
}
236236

237-
item= (ltree*)palloc(VARSIZE(found));
237+
item= (ltree*)palloc0(VARSIZE(found));
238238
memcpy(item,found,VARSIZE(found));
239239

240240
PG_FREE_IF_COPY(la,0);
@@ -257,7 +257,7 @@ _ltq_extract_regex(PG_FUNCTION_ARGS)
257257
PG_RETURN_NULL();
258258
}
259259

260-
item= (ltree*)palloc(VARSIZE(found));
260+
item= (ltree*)palloc0(VARSIZE(found));
261261
memcpy(item,found,VARSIZE(found));
262262

263263
PG_FREE_IF_COPY(la,0);
@@ -280,7 +280,7 @@ _ltxtq_extract_exec(PG_FUNCTION_ARGS)
280280
PG_RETURN_NULL();
281281
}
282282

283-
item= (ltree*)palloc(VARSIZE(found));
283+
item= (ltree*)palloc0(VARSIZE(found));
284284
memcpy(item,found,VARSIZE(found));
285285

286286
PG_FREE_IF_COPY(la,0);

‎contrib/ltree/ltree_gist.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ltree_compress(PG_FUNCTION_ARGS)
5656
ltree*val= (ltree*)DatumGetPointer(PG_DETOAST_DATUM(entry->key));
5757
int32len=LTG_HDRSIZE+VARSIZE(val);
5858

59-
key= (ltree_gist*)palloc(len);
59+
key= (ltree_gist*)palloc0(len);
6060
SET_VARSIZE(key,len);
6161
key->flag=LTG_ONENODE;
6262
memcpy((void*)LTG_NODE(key), (void*)val,VARSIZE(val));
@@ -213,7 +213,7 @@ ltree_union(PG_FUNCTION_ARGS)
213213
isleqr= (left==right||ISEQ(left,right)) ? true : false;
214214
*size=LTG_HDRSIZE+ ((isalltrue) ?0 :SIGLEN)+VARSIZE(left)+ ((isleqr) ?0 :VARSIZE(right));
215215

216-
result= (ltree_gist*)palloc(*size);
216+
result= (ltree_gist*)palloc0(*size);
217217
SET_VARSIZE(result,*size);
218218
result->flag=0;
219219

@@ -386,7 +386,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
386386
lu_l=LTG_GETLNODE(GETENTRY(entryvec,array[FirstOffsetNumber].index));
387387
isleqr= (lu_l==lu_r||ISEQ(lu_l,lu_r)) ? true : false;
388388
size=LTG_HDRSIZE+ ((lisat) ?0 :SIGLEN)+VARSIZE(lu_l)+ ((isleqr) ?0 :VARSIZE(lu_r));
389-
lu= (ltree_gist*)palloc(size);
389+
lu= (ltree_gist*)palloc0(size);
390390
SET_VARSIZE(lu,size);
391391
lu->flag=0;
392392
if (lisat)
@@ -403,7 +403,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
403403
ru_l=LTG_GETLNODE(GETENTRY(entryvec,array[1+ ((maxoff-FirstOffsetNumber+1) /2)].index));
404404
isleqr= (ru_l==ru_r||ISEQ(ru_l,ru_r)) ? true : false;
405405
size=LTG_HDRSIZE+ ((risat) ?0 :SIGLEN)+VARSIZE(ru_l)+ ((isleqr) ?0 :VARSIZE(ru_r));
406-
ru= (ltree_gist*)palloc(size);
406+
ru= (ltree_gist*)palloc0(size);
407407
SET_VARSIZE(ru,size);
408408
ru->flag=0;
409409
if (risat)
@@ -445,7 +445,7 @@ gist_isparent(ltree_gist *key, ltree *query)
445445
staticltree*
446446
copy_ltree(ltree*src)
447447
{
448-
ltree*dst= (ltree*)palloc(VARSIZE(src));
448+
ltree*dst= (ltree*)palloc0(VARSIZE(src));
449449

450450
memcpy(dst,src,VARSIZE(src));
451451
returndst;

‎contrib/ltree/ltree_op.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ inner_subltree(ltree *t, int32 startpos, int32 endpos)
211211
ptr=LEVEL_NEXT(ptr);
212212
}
213213

214-
res= (ltree*)palloc(LTREE_HDRSIZE+ (end-start));
214+
res= (ltree*)palloc0(LTREE_HDRSIZE+ (end-start));
215215
SET_VARSIZE(res,LTREE_HDRSIZE+ (end-start));
216216
res->numlevel=endpos-startpos;
217217

@@ -268,7 +268,7 @@ ltree_concat(ltree *a, ltree *b)
268268
{
269269
ltree*r;
270270

271-
r= (ltree*)palloc(VARSIZE(a)+VARSIZE(b)-LTREE_HDRSIZE);
271+
r= (ltree*)palloc0(VARSIZE(a)+VARSIZE(b)-LTREE_HDRSIZE);
272272
SET_VARSIZE(r,VARSIZE(a)+VARSIZE(b)-LTREE_HDRSIZE);
273273
r->numlevel=a->numlevel+b->numlevel;
274274

@@ -450,7 +450,7 @@ lca_inner(ltree **a, int len)
450450
l1=LEVEL_NEXT(l1);
451451
}
452452

453-
res= (ltree*)palloc(reslen);
453+
res= (ltree*)palloc0(reslen);
454454
SET_VARSIZE(res,reslen);
455455
res->numlevel=num;
456456

‎contrib/ltree/ltxtquery_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ queryin(char *buf)
350350
errmsg("ltxtquery is too large")));
351351
commonlen=COMPUTESIZE(state.num,state.sumlen);
352352

353-
query= (ltxtquery*)palloc(commonlen);
353+
query= (ltxtquery*)palloc0(commonlen);
354354
SET_VARSIZE(query,commonlen);
355355
query->size=state.num;
356356
ptr=GETQUERY(query);

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -742,11 +742,7 @@ pgss_shmem_shutdown(int code, Datum arg)
742742
/*
743743
* Rename file into place, so we atomically replace any old one.
744744
*/
745-
if (rename(PGSS_DUMP_FILE".tmp",PGSS_DUMP_FILE)!=0)
746-
ereport(LOG,
747-
(errcode_for_file_access(),
748-
errmsg("could not rename pg_stat_statement file \"%s\": %m",
749-
PGSS_DUMP_FILE".tmp")));
745+
(void)durable_rename(PGSS_DUMP_FILE".tmp",PGSS_DUMP_FILE,LOG);
750746

751747
/* Unlink query-texts file; it's not needed while shutdown */
752748
unlink(PGSS_TEXT_FILE);

‎contrib/test_decoding/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ submake-isolation:
3737
submake-test_decoding:
3838
$(MAKE) -C$(top_builddir)/contrib/test_decoding
3939

40-
REGRESSCHECKS=ddl rewrite toast permissions decoding_in_xact decoding_into_rel\
41-
binary prepared replorigin
40+
REGRESSCHECKS=ddlxactrewrite toast permissions decoding_in_xact\
41+
decoding_into_relbinary prepared replorigin time
4242

4343
regresscheck: | submake-regress submake-test_decoding temp-install
4444
$(MKDIR_P) regression_output

‎contrib/test_decoding/expected/ddl.out

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,21 @@ ORDER BY 1,2;
240240
20467 | table public.tr_etoomuch: DELETE: id[integer]:1 | table public.tr_etoomuch: UPDATE: id[integer]:9999 data[integer]:-9999
241241
(3 rows)
242242

243+
-- check updates of primary keys work correctly
244+
BEGIN;
245+
CREATE TABLE spoolme AS SELECT g.i FROM generate_series(1, 5000) g(i);
246+
UPDATE tr_etoomuch SET id = -id WHERE id = 5000;
247+
DELETE FROM spoolme;
248+
DROP TABLE spoolme;
249+
COMMIT;
250+
SELECT data
251+
FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1')
252+
WHERE data ~ 'UPDATE';
253+
data
254+
-------------------------------------------------------------------------------------------------------------
255+
table public.tr_etoomuch: UPDATE: old-key: id[integer]:5000 new-tuple: id[integer]:-5000 data[integer]:5000
256+
(1 row)
257+
243258
-- check that a large, spooled, upsert works
244259
INSERT INTO tr_etoomuch (id, data)
245260
SELECT g.i, -g.i FROM generate_series(8000, 12000) g(i)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
SET synchronous_commit = on;
2+
CREATE TABLE test_time(data text);
3+
-- remember the current time
4+
SELECT set_config('test.time_before', NOW()::text, false) IS NOT NULL;
5+
?column?
6+
----------
7+
t
8+
(1 row)
9+
10+
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
11+
?column?
12+
----------
13+
init
14+
(1 row)
15+
16+
-- a single transaction, to get the commit time
17+
INSERT INTO test_time(data) VALUES ('');
18+
-- parse the commit time from the changeset
19+
SELECT set_config('test.time_after', regexp_replace(data, '^COMMIT \(at (.*)\)$', '\1'), false) IS NOT NULL
20+
FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-timestamp', '1')
21+
WHERE data ~ 'COMMIT' LIMIT 1;
22+
?column?
23+
----------
24+
t
25+
(1 row)
26+
27+
-- ensure commit time is sane in relation to the previous time
28+
SELECT (time_after - time_before) <= '10 minutes'::interval, time_after >= time_before
29+
FROM (SELECT current_setting('test.time_after')::timestamptz AS time_after, (SELECT current_setting('test.time_before')::timestamptz) AS time_before) AS d;
30+
?column? | ?column?
31+
----------+----------
32+
t | t
33+
(1 row)
34+
35+
SELECT pg_drop_replication_slot('regression_slot');
36+
pg_drop_replication_slot
37+
--------------------------
38+
39+
(1 row)
40+

‎contrib/test_decoding/expected/toast.out

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,64 @@ SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot',
292292
COMMIT
293293
(235 rows)
294294

295+
-- test we can decode "old" tuples bigger than the max heap tuple size correctly
296+
DROP TABLE IF EXISTS toasted_several;
297+
NOTICE: table "toasted_several" does not exist, skipping
298+
CREATE TABLE toasted_several (
299+
id serial unique not null,
300+
toasted_key text primary key,
301+
toasted_col1 text,
302+
toasted_col2 text
303+
);
304+
ALTER TABLE toasted_several REPLICA IDENTITY FULL;
305+
ALTER TABLE toasted_several ALTER COLUMN toasted_key SET STORAGE EXTERNAL;
306+
ALTER TABLE toasted_several ALTER COLUMN toasted_col1 SET STORAGE EXTERNAL;
307+
ALTER TABLE toasted_several ALTER COLUMN toasted_col2 SET STORAGE EXTERNAL;
308+
INSERT INTO toasted_several(toasted_key) VALUES(repeat('9876543210', 2000));
309+
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
310+
regexp_replace
311+
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
312+
BEGIN
313+
table public.toasted_several: INSERT: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..098765432109876543210987654321098765432109876543210' toasted_col1[text]:null toasted_col2[text]:null
314+
COMMIT
315+
(3 rows)
316+
317+
-- test update of a toasted key without changing it
318+
UPDATE toasted_several SET toasted_col1 = toasted_key;
319+
UPDATE toasted_several SET toasted_col2 = toasted_col1;
320+
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
321+
regexp_replace
322+
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
323+
BEGIN
324+
table public.toasted_several: INSERT: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..098765432109876543210987654321098765432109876543210' toasted_col1[text]:null toasted_col2[text]:null
325+
COMMIT
326+
BEGIN
327+
table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..432109876543210987654321098765432109876543210987654321098765432109876543210' toasted_col2[text]:null
328+
COMMIT
329+
BEGIN
330+
table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210'
331+
COMMIT
332+
(9 rows)
333+
334+
/*
335+
* update with large tuplebuf, in a transaction large enough to force to spool to disk
336+
*/
337+
BEGIN;
338+
INSERT INTO toasted_several(toasted_key) SELECT * FROM generate_series(1, 10234);
339+
UPDATE toasted_several SET toasted_col1 = toasted_col2 WHERE id = 1;
340+
DELETE FROM toasted_several WHERE id = 1;
341+
COMMIT;
342+
DROP TABLE toasted_several;
343+
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1')
344+
WHERE data NOT LIKE '%INSERT: %';
345+
regexp_replace
346+
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
347+
BEGIN
348+
table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..7654321098765432109876543210987654321098765432109876543210' toasted_col2[text]:unchanged-toast-datum
349+
table public.toasted_several: DELETE: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210'
350+
COMMIT
351+
(4 rows)
352+
295353
SELECT pg_drop_replication_slot('regression_slot');
296354
pg_drop_replication_slot
297355
--------------------------
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
-- predictability
2+
SET synchronous_commit = on;
3+
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
4+
?column?
5+
----------
6+
init
7+
(1 row)
8+
9+
-- bug #13844, xids in non-decoded records need to be inspected
10+
CREATE TABLE xact_test(data text);
11+
INSERT INTO xact_test VALUES ('before-test');
12+
BEGIN;
13+
-- perform operation in xact that creates and logs xid, but isn't decoded
14+
SELECT * FROM xact_test FOR UPDATE;
15+
data
16+
-------------
17+
before-test
18+
(1 row)
19+
20+
SAVEPOINT foo;
21+
-- and now actually insert in subxact, xid is expected to be known
22+
INSERT INTO xact_test VALUES ('after-assignment');
23+
COMMIT;
24+
-- and now show those changes
25+
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
26+
data
27+
---------------------------------------------------------------
28+
BEGIN
29+
table public.xact_test: INSERT: data[text]:'before-test'
30+
COMMIT
31+
BEGIN
32+
table public.xact_test: INSERT: data[text]:'after-assignment'
33+
COMMIT
34+
(6 rows)
35+
36+
DROP TABLE xact_test;
37+
SELECT pg_drop_replication_slot('regression_slot');
38+
pg_drop_replication_slot
39+
--------------------------
40+
41+
(1 row)
42+

‎contrib/test_decoding/specs/concurrent_ddl_dml.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ teardown
1414
}
1515

1616
session"s1"
17+
setup {SETsynchronous_commit=on; }
18+
1719
step"s1_init" {SELECT'init'FROMpg_create_logical_replication_slot('isolation_slot','test_decoding'); }
1820
step"s1_begin" {BEGIN; }
1921
step"s1_insert_tbl1" {INSERTINTOtbl1 (val1,val2)VALUES (1,1); }
@@ -23,6 +25,8 @@ step "s1_insert_tbl2_3col" { INSERT INTO tbl2 (val1, val2, val3) VALUES (1, 1, 1
2325
step"s1_commit" {COMMIT; }
2426

2527
session"s2"
28+
setup {SETsynchronous_commit=on; }
29+
2630
step"s2_alter_tbl1_float" {ALTERTABLEtbl1ALTERCOLUMNval2TYPEfloat; }
2731
step"s2_alter_tbl1_char" {ALTERTABLEtbl1ALTERCOLUMNval2TYPEcharactervarying; }
2832
step"s2_alter_tbl1_text" {ALTERTABLEtbl1ALTERCOLUMNval2TYPEtext; }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp