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

Commit59786ba

Browse files
author
Andrei Krichinin
committed
Code compatibility with Postgres 15
1 parent1b59ad0 commit59786ba

File tree

7 files changed

+190
-54
lines changed

7 files changed

+190
-54
lines changed

‎Cluster.pm‎

Lines changed: 131 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@ package Cluster;
33
use strict;
44
use warnings;
55

6-
use PostgresNode;
7-
use TestLib;
86
use Test::More;
97
use Cwd;
108
use IPC::Run;
119
use Socket;
1210

11+
our$pg_15_modules;
12+
13+
BEGIN
14+
{
15+
$pg_15_modules =eval
16+
{
17+
require PostgreSQL::Test::Cluster;
18+
require PostgreSQL::Test::Utils;
19+
return 1;
20+
};
21+
22+
unless (defined$pg_15_modules)
23+
{
24+
$pg_15_modules = 0;
25+
26+
require PostgresNode;
27+
require TestLib;
28+
}
29+
}
30+
1331
our$last_port_assigned;
1432
our$mm_listen_address ='127.0.0.1';
1533

@@ -38,10 +56,24 @@ sub mm_get_free_port
3856
# Check first that candidate port number is not included in
3957
# the list of already-registered nodes.
4058
$found = 1;
41-
foreachmy$node (@PostgresNode::all_nodes)
59+
eval
4260
{
43-
$found = 0if ($node->port ==$port);
44-
}
61+
if ($pg_15_modules)
62+
{
63+
foreachmy$node (@PostgreSQL::Test::Cluster::all_nodes)
64+
{
65+
$found = 0if ($node->port ==$port);
66+
}
67+
}
68+
else
69+
{
70+
foreachmy$node (@PostgresNode::all_nodes)
71+
{
72+
$found = 0if ($node->port ==$port);
73+
}
74+
}
75+
};
76+
4577

4678
# Check to see if anything else is listening on this TCP port.
4779
# Seek a port available for all possible listen_addresses values,
@@ -57,15 +89,33 @@ sub mm_get_free_port
5789
# 0.0.0.0 is unnecessary on non-Windows systems.
5890
if ($found == 1)
5991
{
60-
foreachmy$addr (qw(127.0.0.1),
61-
$PostgresNode::use_tcp && ($^Oeq"linux" ||$windows_os) ?qw(127.0.0.2 127.0.0.3 0.0.0.0) : ())
92+
eval
6293
{
63-
if (!PostgresNode::can_bind($addr,$port))
94+
if ($pg_15_modules)
6495
{
65-
$found = 0;
66-
last;
96+
foreachmy$addr (qw(127.0.0.1),
97+
$PostgreSQL::Test::Cluster::use_tcp && ($^Oeq"linux" ||$PostgreSQL::Test::Utils::windows_os) ?qw(127.0.0.2 127.0.0.3 0.0.0.0) : ())
98+
{
99+
if (!PostgreSQL::Test::Cluster::can_bind($addr,$port))
100+
{
101+
$found = 0;
102+
last;
103+
}
104+
}
67105
}
68-
}
106+
else
107+
{
108+
foreachmy$addr (qw(127.0.0.1),
109+
$PostgresNode::use_tcp && ($^Oeq"linux" ||$TestLib::windows_os) ?qw(127.0.0.2 127.0.0.3 0.0.0.0) : ())
110+
{
111+
if (!PostgresNode::can_bind($addr,$port))
112+
{
113+
$found = 0;
114+
last;
115+
}
116+
}
117+
}
118+
};
69119
}
70120
}
71121

@@ -80,21 +130,41 @@ sub mm_get_free_port
80130
subnew
81131
{
82132
my ($class,$n_nodes,$referee) =@_;
133+
my@nodes;
134+
my$self;
83135

84136
# ask PostgresNode to use tcp and listen on mm_listen_address
85-
$PostgresNode::use_tcp = 1;
86-
$PostgresNode::test_pghost =$mm_listen_address;
87-
88-
my@nodes =map { get_new_node("node$_", ('port'=> mm_get_free_port())) } (1..$n_nodes);
89-
90-
my$self = {
91-
nodes=> \@nodes,
92-
recv_timeout=> 6
93-
};
94-
if (defined$referee &&$referee)
137+
eval
95138
{
96-
$self->{referee} = get_new_node("referee", ('port'=> mm_get_free_port() ));
97-
}
139+
if ($pg_15_modules)
140+
{
141+
$PostgreSQL::Test::Cluster::use_tcp = 1;
142+
$PostgreSQL::Test::Cluster::test_pghost =$mm_listen_address;
143+
@nodes =map { PostgreSQL::Test::Cluster->new("node$_", ('port'=> mm_get_free_port())) } (1..$n_nodes);
144+
$self = {
145+
nodes=> \@nodes,
146+
recv_timeout=> 6
147+
};
148+
if (defined$referee &&$referee)
149+
{
150+
$self->{referee} = PostgreSQL::Test::Cluster->new("referee", ('port'=> mm_get_free_port() ));
151+
}
152+
}
153+
else
154+
{
155+
$PostgresNode::use_tcp = 1;
156+
$PostgresNode::test_pghost =$mm_listen_address;
157+
@nodes =map { PostgresNode::get_new_node("node$_", ('port'=> mm_get_free_port())) } (1..$n_nodes);
158+
$self = {
159+
nodes=> \@nodes,
160+
recv_timeout=> 6
161+
};
162+
if (defined$referee &&$referee)
163+
{
164+
$self->{referee} = PostgresNode::get_new_node("referee", ('port'=> mm_get_free_port() ));
165+
}
166+
}
167+
};
98168

99169
bless$self,$class;
100170
return$self;
@@ -106,7 +176,17 @@ sub init
106176
my$nodes =$self->{nodes};
107177

108178
# use port range different to ordinary TAP tests
109-
$PostgresNode::last_port_assigned =int(rand() * 16384) + 32767;
179+
eval
180+
{
181+
if ($pg_15_modules)
182+
{
183+
$PostgreSQL::Test::Cluster::last_port_assigned =int(rand() * 16384) + 32767;
184+
}
185+
else
186+
{
187+
$PostgresNode::last_port_assigned =int(rand() * 16384) + 32767;
188+
}
189+
};
110190

111191
if (defined$self->{referee})
112192
{
@@ -122,7 +202,19 @@ sub init
122202
# everywhere but on arm (which is the only live arch which might be strict
123203
# here)
124204
my$binary_basetypes = 0;
125-
if (!$TestLib::windows_os)
205+
my$is_windows_os;
206+
eval
207+
{
208+
if ($pg_15_modules)
209+
{
210+
$is_windows_os =$PostgreSQL::Test::Utils::windows_os;
211+
}
212+
else
213+
{
214+
$is_windows_os =$TestLib::windows_os;
215+
}
216+
};
217+
if (!$is_windows_os)
126218
{
127219
my$uname_arch =`uname -m`;
128220
if ($? != 0) {
@@ -340,9 +432,21 @@ sub connstr
340432
subadd_node()
341433
{
342434
my ($self) =@_;
435+
my$new_node;
343436

344-
my$new_node = get_new_node("node@{[$#{$self->{nodes}} + 2]}",
345-
(port=> mm_get_free_port()));
437+
eval
438+
{
439+
if ($pg_15_modules)
440+
{
441+
$new_node = PostgreSQL::Test::Cluster->new("node@{[$#{$self->{nodes}} + 2]}",
442+
(port=> mm_get_free_port()));
443+
}
444+
else
445+
{
446+
$new_node = PostgresNode::get_new_node("node@{[$#{$self->{nodes}} + 2]}",
447+
(port=> mm_get_free_port()));
448+
}
449+
};
346450
push(@{$self->{nodes}},$new_node);
347451

348452
return$#{$self->{nodes}};

‎run.pl‎

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,44 @@
2727
$cluster->create_mm('regression');
2828

2929
# prevent PostgresNode.pm from shutting down nodes on exit in END {}
30-
@PostgresNode::all_nodes = ();
30+
eval
31+
{
32+
if ($Cluster::pg_15_modules)
33+
{
34+
@PostgreSQL::Test::Cluster::all_nodes = ();
35+
}
36+
else
37+
{
38+
@PostgresNode::all_nodes = ();
39+
}
40+
};
3141
}
3242
elsif ($actioneq"stop")
3343
{
34-
my@datas = <$TestLib::tmp_check/*data>;
35-
foreachmy$data (@datas) {
36-
TestLib::system_log('pg_ctl',
37-
'-D',"$data/pgdata",
38-
'-m','fast',
39-
'stop');
40-
}
44+
eval
45+
{
46+
if ($Cluster::pg_15_modules)
47+
{
48+
my@datas = <$PostgreSQL::Test::Utils::tmp_check/*data>;
49+
foreachmy$data (@datas) {
50+
PostgreSQL::Test::Utils::system_log('pg_ctl',
51+
'-D',"$data/pgdata",
52+
'-m','fast',
53+
'stop');
54+
}
55+
@PostgreSQL::Test::Cluster::all_nodes = ();
56+
}
57+
else
58+
{
59+
my@datas = <$TestLib::tmp_check/*data>;
60+
foreachmy$data (@datas) {
61+
TestLib::system_log('pg_ctl',
62+
'-D',"$data/pgdata",
63+
'-m','fast',
64+
'stop');
65+
}
66+
}
67+
};
4168
}
4269
else
4370
{

‎src/dmq.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ dmq_handle_message(StringInfo msg, DmqReceiverSlot *my_slot,
11191119
}
11201120
else
11211121
{
1122-
res=shm_mq_send(mq_handles[sub.procno],body_len,body, false);
1122+
res=shm_mq_send(mq_handles[sub.procno],body_len,body, false, true);
11231123
if (res==SHM_MQ_DETACHED)
11241124
mtm_log(COMMERROR,"[DMQ] queue %d is detached, dropping message (stream=%s)",
11251125
sub.procno,stream_name);
@@ -1623,7 +1623,7 @@ dmq_push(DmqDestinationId dest_id, char *stream_name, char *msg)
16231623
buf.len,buf.len,buf.data);
16241624

16251625
/* XXX: use sendv instead */
1626-
res=shm_mq_send(dmq_local.mq_outh,buf.len,buf.data, false);
1626+
res=shm_mq_send(dmq_local.mq_outh,buf.len,buf.data, false, true);
16271627
pfree(buf.data);
16281628
if (res!=SHM_MQ_SUCCESS)
16291629
mtm_log(ERROR,"[DMQ] dmq_push: can't send to queue");
@@ -1648,7 +1648,7 @@ dmq_push_buffer(DmqDestinationId dest_id, char *stream_name, const void *payload
16481648
buf.len,buf.len,buf.data);
16491649

16501650
/* XXX: use sendv instead */
1651-
res=shm_mq_send(dmq_local.mq_outh,buf.len,buf.data, false);
1651+
res=shm_mq_send(dmq_local.mq_outh,buf.len,buf.data, false, true);
16521652
pfree(buf.data);
16531653
if (res!=SHM_MQ_SUCCESS)
16541654
mtm_log(ERROR,"[DMQ] dmq_push: can't send to queue, status = %d",res);

‎src/multimaster.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,12 @@ NULL);
742742

743743
DetectGlobalDeadLock=MtmDetectGlobalDeadLock;
744744

745+
#if0
745746
#ifdefPGPRO_EE
746747
SuspendTransactionHook=MtmSuspendTransaction;
747748
ResumeTransactionHook=MtmResumeTransaction;
748749
#endif
750+
#endif
749751
}
750752

751753
/*
@@ -1095,6 +1097,7 @@ mtm_after_node_create(PG_FUNCTION_ARGS)
10951097
boolconninfo_isnull;
10961098
intn_nodes;
10971099
intrc;
1100+
ParseState*pstate;
10981101

10991102
Assert(CALLED_AS_TRIGGER(fcinfo));
11001103
Assert(TRIGGER_FIRED_FOR_ROW(trigdata->tg_event));
@@ -1135,6 +1138,8 @@ mtm_after_node_create(PG_FUNCTION_ARGS)
11351138

11361139
mtm_log(NodeMgmt,"mtm_after_node_create %d",node_id);
11371140

1141+
pstate=make_parsestate(NULL);
1142+
11381143
if (is_self)
11391144
{
11401145
/*
@@ -1143,11 +1148,11 @@ mtm_after_node_create(PG_FUNCTION_ARGS)
11431148
*/
11441149
pub_stmt->pubname=MULTIMASTER_NAME;
11451150
pub_stmt->for_all_tables= false;
1146-
pub_stmt->tables=NIL;
1151+
pub_stmt->pubobjects=NIL;
11471152
pub_stmt->options=list_make1(
11481153
makeDefElem("publish", (Node*)makeString(pstrdup("insert, truncate")),-1)
11491154
);
1150-
CreatePublication(pub_stmt);
1155+
CreatePublication(pstate,pub_stmt);
11511156

11521157
/* liftoff */
11531158
MtmMonitorStart(MyDatabaseId,GetUserId());
@@ -1186,7 +1191,7 @@ mtm_after_node_create(PG_FUNCTION_ARGS)
11861191
client_min_messages=ERROR;
11871192
log_min_messages=ERROR;
11881193

1189-
CreateSubscription(cs_stmt, true);
1194+
CreateSubscription(pstate,cs_stmt, true);
11901195

11911196
/* restore log_level's */
11921197
client_min_messages=saved_client_min_messages;
@@ -1204,6 +1209,7 @@ mtm_after_node_create(PG_FUNCTION_ARGS)
12041209
origin_name=psprintf(MULTIMASTER_SLOT_PATTERN,node_id);
12051210
replorigin_create(origin_name);
12061211
}
1212+
free_parsestate(pstate);
12071213

12081214
PG_RETURN_VOID();
12091215
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp