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

Commit c39f288

Browse files
committed
Merge branch 'PGPROEE10_MULTIMASTER' of https://gitlab.postgrespro.ru/pgpro-dev/postgrespro into PGPROEE10_MULTIMASTER
2 parents 5051e72 + c94467f commit c39f288

File tree

491 files changed

+11097
-8787
lines changed

Some content is hidden

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

491 files changed

+11097
-8787
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2788,7 +2788,7 @@ fi
27882788

27892789

27902790

2791-
PGPRO_VERSION="$PACKAGE_VERSION.1"
2791+
PGPRO_VERSION="$PACKAGE_VERSION.3"
27922792
PGPRO_PACKAGE_NAME="PostgresPro"
27932793
PGPRO_EDITION="enterprise"
27942794
PGPRO_EDN="ent"

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
3939
[PG_VERSION="$PACKAGE_VERSION$withval"],
4040
[PG_VERSION="$PACKAGE_VERSION"])
4141

42-
PGPRO_VERSION="$PACKAGE_VERSION.1"
42+
PGPRO_VERSION="$PACKAGE_VERSION.3"
4343
PGPRO_PACKAGE_NAME="PostgresPro"
4444
PGPRO_EDITION="enterprise"
4545
PGPRO_EDN="ent"

contrib/mchar/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ OBJS = mchar_io.o mchar_proc.o mchar_op.o mchar_recode.o \
44
EXTENSION = mchar
55
DATA = mchar--1.0.sql
66
DOCS = README.mchar
7-
REGRESS = init mchar mvarchar mm like compat
7+
REGRESS = init mchar mvarchar like
8+
ifndef NO_LOCALE
9+
REGRESS += mm compat
10+
endif
811
PGFIELDDESC = "mchar - mchar type implementation"
912

1013
ifdef USE_PGXS

contrib/mchar/expected/mm.out

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,3 +803,44 @@ SELECT * FROM a, c WHERE mvarchar255 = mchar2;
803803

804804
DROP TABLE a;
805805
DROP TABLE c;
806+
select * from (values ('е'::mchar),('ё'),('еа'),('еб'),('ее'),('еж'),('ёа'),('ёб'),('ёё'),('ёж'),('ёе'),('её')) z order by 1;
807+
column1
808+
---------
809+
е
810+
еа
811+
еб
812+
ее
813+
её
814+
еж
815+
ё
816+
ёа
817+
ёб
818+
ёе
819+
ёё
820+
ёж
821+
(12 rows)
822+
823+
select mvarchar_icase_cmp('ё', 'е');
824+
mvarchar_icase_cmp
825+
--------------------
826+
1
827+
(1 row)
828+
829+
select mvarchar_icase_cmp('Ё', 'Е');
830+
mvarchar_icase_cmp
831+
--------------------
832+
1
833+
(1 row)
834+
835+
select mvarchar_icase_cmp('й', 'и');
836+
mvarchar_icase_cmp
837+
--------------------
838+
1
839+
(1 row)
840+
841+
select mvarchar_icase_cmp('Й', 'И');
842+
mvarchar_icase_cmp
843+
--------------------
844+
1
845+
(1 row)
846+

contrib/mchar/mchar_recode.c

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ createUObjs() {
3131
elog(ERROR,"ICU ucol_open returns %d (%s)", err, u_errorName(err));
3232
}
3333

34+
/* UCOL_PRIMARY doesn't distinguish И & Й, Е & Ё */
3435
ucol_setStrength( colCaseInsensitive, UCOL_SECONDARY );
3536
}
3637

@@ -114,29 +115,49 @@ FillWhiteSpace( UChar *dst, int n ) {
114115
int
115116
UCharCaseCompare(UChar * a, int alen, UChar *b, int blen) {
116117
int len = Min(alen, blen);
117-
int res;
118+
int i, res;
118119

119120
createUObjs();
120121

121-
res = (int)ucol_strcoll( colCaseInsensitive,
122-
a, len,
123-
b, len);
124-
if ( res == 0 && alen != blen )
122+
/*
123+
* Preventing any influence of following characters to
124+
* current one, try
125+
* select * from (values ('е'::mchar),('ё'),('еа'),('еб'),('ее'),('еж'),
126+
* ('ёа'),('ёб'),('ёё'),('ёж'),('ёе'),('её')) z
127+
* order by 1;
128+
*/
129+
for (i=0; i<len; i++)
130+
{
131+
res = (int)ucol_strcoll(colCaseInsensitive,
132+
a + i, 1,
133+
b + i, 1);
134+
if (res)
135+
return res;
136+
}
137+
138+
if (alen != blen)
125139
return (alen > blen) ? 1 : - 1;
126-
return res;
140+
return 0;
127141
}
128142

129143
int
130144
UCharCompare(UChar * a, int alen, UChar *b, int blen) {
131145
int len = Min(alen, blen);
132-
int res;
146+
int i, res;
133147

134148
createUObjs();
135149

136-
res = (int)ucol_strcoll( colCaseSensitive,
137-
a, len,
138-
b, len);
139-
if ( res == 0 && alen != blen )
150+
/* see above */
151+
for (i=0; i<len; i++)
152+
{
153+
res = (int)ucol_strcoll(colCaseSensitive,
154+
a + i, 1,
155+
b + i, 1);
156+
if (res)
157+
return res;
158+
}
159+
160+
if (alen != blen)
140161
return (alen > blen) ? 1 : - 1;
141-
return res;
162+
return 0;
142163
}

contrib/mchar/sql/mm.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,8 @@ SELECT * FROM a, c WHERE mvarchar255 = mchar2;
183183
DROP TABLE a;
184184
DROP TABLE c;
185185

186+
select * from (values ('е'::mchar),('ё'),('еа'),('еб'),('ее'),('еж'),('ёа'),('ёб'),('ёё'),('ёж'),('ёе'),('её')) z order by 1;
187+
select mvarchar_icase_cmp('ё', 'е');
188+
select mvarchar_icase_cmp('Ё', 'Е');
189+
select mvarchar_icase_cmp('й', 'и');
190+
select mvarchar_icase_cmp('Й', 'И');

contrib/mmts/bgwpool.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void BgwPoolDynamicWorkerMainLoop(Datum arg);
2626

2727
static void BgwShutdownWorker(int sig)
2828
{
29-
MTM_LOG1("Background worker %d receive shutdown request", MyProcPid);
29+
MTM_LOG1("Background worker %d received shutdown request", MyProcPid);
3030
if (MtmPool) {
3131
BgwPoolStop(MtmPool);
3232
}
@@ -137,16 +137,15 @@ timestamp_t BgwGetLastPeekTime(BgwPool* pool)
137137

138138
void BgwPoolStaticWorkerMainLoop(Datum arg)
139139
{
140-
BgwPoolConstructor constructor = (BgwPoolConstructor)DatumGetPointer(arg);
141-
BgwPoolMainLoop(constructor());
140+
BgwPoolMainLoop((BgwPool*)DatumGetPointer(arg));
142141
}
143142

144143
void BgwPoolDynamicWorkerMainLoop(Datum arg)
145144
{
146-
BgwPoolMainLoop((BgwPool*)DatumGetPointer(arg));
145+
BgwPoolMainLoop((BgwPool*)DatumGetPointer(arg));
147146
}
148147

149-
void BgwPoolStart(int nWorkers, BgwPoolConstructor constructor)
148+
void BgwPoolStart(BgwPool* pool, char *poolName)
150149
{
151150
int i;
152151
BackgroundWorker worker;
@@ -158,9 +157,12 @@ void BgwPoolStart(int nWorkers, BgwPoolConstructor constructor)
158157
sprintf(worker.bgw_function_name, "BgwPoolStaticWorkerMainLoop");
159158
worker.bgw_restart_time = MULTIMASTER_BGW_RESTART_TIMEOUT;
160159

161-
for (i = 0; i < nWorkers; i++) {
162-
snprintf(worker.bgw_name, BGW_MAXLEN, "bgw_pool_worker_%d", i+1);
163-
worker.bgw_main_arg = PointerGetDatum(constructor);
160+
strncpy(pool->poolName, poolName, MAX_NAME_LEN);
161+
162+
for (i = 0; i < pool->nWorkers; i++)
163+
{
164+
snprintf(worker.bgw_name, BGW_MAXLEN, "%s_worker_%d", pool->poolName, i+1);
165+
worker.bgw_main_arg = PointerGetDatum(pool);
164166
RegisterBackgroundWorker(&worker);
165167
}
166168
}
@@ -189,7 +191,7 @@ static void BgwStartExtraWorker(BgwPool* pool)
189191
sprintf(worker.bgw_library_name, "multimaster");
190192
sprintf(worker.bgw_function_name, "BgwPoolDynamicWorkerMainLoop");
191193
worker.bgw_restart_time = MULTIMASTER_BGW_RESTART_TIMEOUT;
192-
snprintf(worker.bgw_name, BGW_MAXLEN, "bgw_pool_dynworker_%d", (int)++pool->nWorkers);
194+
snprintf(worker.bgw_name, BGW_MAXLEN, "%s-dynworker-%d", pool->poolName, (int)++pool->nWorkers);
193195
worker.bgw_main_arg = PointerGetDatum(pool);
194196
pool->lastDynamicWorkerStartTime = now;
195197
if (!RegisterDynamicBackgroundWorker(&worker, &handle)) {

contrib/mmts/bgwpool.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ typedef ulong64 timestamp_t;
1313

1414
#define MAX_DBNAME_LEN 30
1515
#define MAX_DBUSER_LEN 30
16+
#define MAX_NAME_LEN 30
1617
#define MULTIMASTER_BGW_RESTART_TIMEOUT BGW_NEVER_RESTART /* seconds */
1718

1819
extern timestamp_t MtmGetSystemTime(void); /* non-adjusted current system time */
@@ -37,14 +38,15 @@ typedef struct
3738
timestamp_t lastDynamicWorkerStartTime;
3839
bool producerBlocked;
3940
bool shutdown;
41+
char poolName[MAX_NAME_LEN];
4042
char dbname[MAX_DBNAME_LEN];
4143
char dbuser[MAX_DBUSER_LEN];
4244
char* queue;
4345
} BgwPool;
4446

4547
typedef BgwPool*(*BgwPoolConstructor)(void);
4648

47-
extern void BgwPoolStart(int nWorkers, BgwPoolConstructor constructor);
49+
extern void BgwPoolStart(BgwPool* pool, char *poolName);
4850

4951
extern void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, char const* dbuser, size_t queueSize, size_t nWorkers);
5052

contrib/mmts/multimaster--1.0.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CREATE FUNCTION mtm.make_table_local(relation regclass) RETURNS void
8484
AS 'MODULE_PATHNAME','mtm_make_table_local'
8585
LANGUAGE C;
8686

87-
CREATE FUNCTION mtm.broadcast_table(srcTable regclass, dstNodesMask bigint) RETURNS void
87+
CREATE FUNCTION mtm.broadcast_table(srcTable regclass) RETURNS void
8888
AS 'MODULE_PATHNAME','mtm_broadcast_table'
8989
LANGUAGE C;
9090

@@ -112,9 +112,9 @@ CREATE FUNCTION mtm.referee_poll(xid bigint) RETURNS bigint
112112
AS 'MODULE_PATHNAME','mtm_referee_poll'
113113
LANGUAGE C;
114114

115-
CREATE LOCAL TABLE IF NOT EXISTS mtm.local_tables(rel_schema name, rel_name name, primary key(rel_schema, rel_name));
115+
CREATE TABLE IF NOT EXISTS mtm.local_tables(rel_schema name, rel_name name, primary key(rel_schema, rel_name));
116116

117-
CREATE LOCAL TABLE mtm.referee_decision(key text primary key not null, node_id int);
117+
CREATE TABLE mtm.referee_decision(key text primary key not null, node_id int);
118118

119119
CREATE OR REPLACE FUNCTION mtm.alter_sequences() RETURNS boolean AS
120120
$$

0 commit comments

Comments
 (0)