@powersync/service-module-mysql 0.12.3 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/api/MySQLRouteAPIAdapter.js.map +1 -1
- package/dist/common/common-index.d.ts +1 -1
- package/dist/common/common-index.js +1 -1
- package/dist/common/common-index.js.map +1 -1
- package/dist/common/mysql-to-sqlite.d.ts +2 -2
- package/dist/common/mysql-to-sqlite.js +1 -1
- package/dist/common/mysql-to-sqlite.js.map +1 -1
- package/dist/common/schema-utils.d.ts +1 -1
- package/dist/common/schema-utils.js.map +1 -1
- package/dist/module/MySQLModule.js +3 -3
- package/dist/module/MySQLModule.js.map +1 -1
- package/dist/replication/BinLogReplicator.js +1 -1
- package/dist/replication/BinLogReplicator.js.map +1 -1
- package/dist/replication/MySQLConnectionManager.d.ts +3 -3
- package/dist/replication/MySQLConnectionManager.js +1 -1
- package/dist/replication/MySQLConnectionManager.js.map +1 -1
- package/dist/replication/MySQLConnectionManagerFactory.d.ts +1 -1
- package/dist/replication/MySQLConnectionManagerFactory.js.map +1 -1
- package/dist/replication/zongji/BinLogListener.d.ts +4 -4
- package/dist/replication/zongji/BinLogListener.js +4 -4
- package/dist/replication/zongji/BinLogListener.js.map +1 -1
- package/dist/replication/zongji/zongji-utils.d.ts +1 -1
- package/dist/utils/mysql-utils.d.ts +1 -1
- package/dist/utils/mysql-utils.js.map +1 -1
- package/dist/utils/parser-utils.d.ts +1 -1
- package/package.json +8 -8
- package/src/api/MySQLRouteAPIAdapter.ts +1 -1
- package/src/common/common-index.ts +1 -1
- package/src/common/mysql-to-sqlite.ts +3 -3
- package/src/common/schema-utils.ts +2 -2
- package/src/module/MySQLModule.ts +3 -3
- package/src/replication/BinLogReplicator.ts +1 -1
- package/src/replication/MySQLConnectionManager.ts +4 -4
- package/src/replication/MySQLConnectionManagerFactory.ts +1 -1
- package/src/replication/zongji/BinLogListener.ts +7 -7
- package/src/replication/zongji/zongji-utils.ts +6 -6
- package/src/utils/mysql-utils.ts +2 -2
- package/src/utils/parser-utils.ts +1 -1
- package/test/src/BinLogListener.test.ts +11 -7
- package/test/src/BinLogStream.test.ts +1 -1
- package/test/src/BinlogStreamUtils.ts +1 -1
- package/test/src/config.test.ts +1 -1
- package/test/src/mysql-to-sqlite.test.ts +5 -6
- package/test/src/mysql-utils.test.ts +1 -1
- package/test/src/parser-utils.test.ts +1 -1
- package/test/src/schema-changes.test.ts +4 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BinLogEvent,
|
|
3
3
|
BinLogGTIDLogEvent,
|
|
4
|
-
|
|
4
|
+
BinLogHeartbeatEvent,
|
|
5
|
+
BinLogHeartbeatEvent_V2,
|
|
6
|
+
BinLogQueryEvent,
|
|
5
7
|
BinLogRotationEvent,
|
|
6
|
-
|
|
8
|
+
BinLogRowEvent,
|
|
7
9
|
BinLogRowUpdateEvent,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
BinLogHeartbeatEvent,
|
|
11
|
-
BinLogHeartbeatEvent_V2
|
|
10
|
+
BinLogTableMapEvent,
|
|
11
|
+
BinLogXidEvent
|
|
12
12
|
} from '@powersync/mysql-zongji';
|
|
13
13
|
|
|
14
14
|
export function eventIsGTIDLog(event: BinLogEvent): event is BinLogGTIDLogEvent {
|
package/src/utils/mysql-utils.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { logger } from '@powersync/lib-services-framework';
|
|
2
|
+
import { SourceEntityDescriptor } from '@powersync/service-core';
|
|
2
3
|
import mysql from 'mysql2';
|
|
3
4
|
import mysqlPromise from 'mysql2/promise';
|
|
4
|
-
import * as types from '../types/types.js';
|
|
5
5
|
import { coerce, gte, satisfies } from 'semver';
|
|
6
|
-
import
|
|
6
|
+
import * as types from '../types/types.js';
|
|
7
7
|
|
|
8
8
|
export type RetriedQueryOptions = {
|
|
9
9
|
connection: mysqlPromise.Connection;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Alter, AST, Create, Drop,
|
|
1
|
+
import { Alter, AST, Create, Drop, DropIndexStatement, RenameStatement, TruncateStatement } from 'node-sql-parser';
|
|
2
2
|
|
|
3
3
|
// We ignore create table statements, since even in the worst case we will pick up the changes when row events for that
|
|
4
4
|
// table are received.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
|
-
import { BinLogListener, SchemaChange, SchemaChangeType } from '@module/replication/zongji/BinLogListener.js';
|
|
3
1
|
import { MySQLConnectionManager } from '@module/replication/MySQLConnectionManager.js';
|
|
2
|
+
import { BinLogListener, SchemaChange, SchemaChangeType } from '@module/replication/zongji/BinLogListener.js';
|
|
3
|
+
import { getMySQLVersion, qualifiedMySQLTable, satisfiesVersion } from '@module/utils/mysql-utils.js';
|
|
4
|
+
import { TablePattern } from '@powersync/service-sync-rules';
|
|
5
|
+
import crypto from 'crypto';
|
|
6
|
+
import { v4 as uuid } from 'uuid';
|
|
7
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
4
8
|
import {
|
|
5
9
|
clearTestDb,
|
|
6
10
|
createBinlogListener,
|
|
@@ -8,10 +12,6 @@ import {
|
|
|
8
12
|
TEST_CONNECTION_OPTIONS,
|
|
9
13
|
TestBinLogEventHandler
|
|
10
14
|
} from './util.js';
|
|
11
|
-
import { v4 as uuid } from 'uuid';
|
|
12
|
-
import { getMySQLVersion, qualifiedMySQLTable, satisfiesVersion } from '@module/utils/mysql-utils.js';
|
|
13
|
-
import crypto from 'crypto';
|
|
14
|
-
import { TablePattern } from '@powersync/service-sync-rules';
|
|
15
15
|
|
|
16
16
|
describe('BinlogListener tests', { timeout: 60_000 }, () => {
|
|
17
17
|
const MAX_QUEUE_CAPACITY_MB = 1;
|
|
@@ -463,9 +463,13 @@ describe('BinlogListener tests', { timeout: 60_000 }, () => {
|
|
|
463
463
|
await insertRows(connectionManager, 1);
|
|
464
464
|
// multi_schema database insert into test_DATA_multi
|
|
465
465
|
await connectionManager.query(`INSERT INTO ${testTable}(id, description) VALUES('${uuid()}','test')`);
|
|
466
|
-
|
|
466
|
+
// Wait for both row entries to appear on the binlog. This avoids a rare race condition in MySQL 5.7
|
|
467
|
+
// where the drop table can hang if run immediately after the table was locked by an insert
|
|
468
|
+
await vi.waitFor(() => expect(eventHandler.rowsWritten).equals(2), { timeout: 5000 });
|
|
467
469
|
|
|
470
|
+
await connectionManager.query(`DROP TABLE ${testTable}`);
|
|
468
471
|
await waitForSchemaChanges(1);
|
|
472
|
+
|
|
469
473
|
await binLogListener.stop();
|
|
470
474
|
expect(eventHandler.rowsWritten).toBe(2);
|
|
471
475
|
assertSchemaChange(eventHandler.schemaChanges[0], SchemaChangeType.DROP_TABLE, 'multi_schema', 'test_DATA_multi');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { qualifiedMySQLTable } from '@module/utils/mysql-utils.js';
|
|
1
2
|
import { storage } from '@powersync/service-core';
|
|
2
3
|
import { METRICS_HELPER, putOp, removeOp } from '@powersync/service-core-tests';
|
|
3
4
|
import { ReplicationMetric } from '@powersync/service-types';
|
|
@@ -5,7 +6,6 @@ import { v4 as uuid } from 'uuid';
|
|
|
5
6
|
import { describe, expect, test } from 'vitest';
|
|
6
7
|
import { BinlogStreamTestContext } from './BinlogStreamUtils.js';
|
|
7
8
|
import { createTestDb, describeWithStorage } from './util.js';
|
|
8
|
-
import { qualifiedMySQLTable } from '@module/utils/mysql-utils.js';
|
|
9
9
|
|
|
10
10
|
const BASIC_SYNC_RULES = `
|
|
11
11
|
bucket_definitions:
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
} from '@powersync/service-core';
|
|
18
18
|
import { bucketRequest, METRICS_HELPER, test_utils } from '@powersync/service-core-tests';
|
|
19
19
|
import mysqlPromise from 'mysql2/promise';
|
|
20
|
-
import { clearTestDb, TEST_CONNECTION_OPTIONS } from './util.js';
|
|
21
20
|
import timers from 'timers/promises';
|
|
21
|
+
import { clearTestDb, TEST_CONNECTION_OPTIONS } from './util.js';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Tests operating on the binlog stream need to configure the stream and manage asynchronous
|
package/test/src/config.test.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
1
|
import {
|
|
3
2
|
normalizeConnectionConfig,
|
|
4
3
|
parseMySQLConnectionParam,
|
|
5
4
|
parseMySQLConnectionParams
|
|
6
5
|
} from '@module/types/types.js';
|
|
6
|
+
import { describe, expect, test } from 'vitest';
|
|
7
7
|
|
|
8
8
|
describe('config', () => {
|
|
9
9
|
test('Should resolve database', () => {
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import * as common from '@module/common/common-index.js';
|
|
2
|
+
import { toColumnDescriptors } from '@module/common/common-index.js';
|
|
3
|
+
import { MySQLConnectionManager } from '@module/replication/MySQLConnectionManager.js';
|
|
4
|
+
import { eventIsWriteMutation, eventIsXid } from '@module/replication/zongji/zongji-utils.js';
|
|
5
|
+
import { BinLogEvent, ZongJi } from '@powersync/mysql-zongji';
|
|
1
6
|
import {
|
|
2
7
|
applyRowContext,
|
|
3
8
|
CompatibilityContext,
|
|
4
9
|
SqliteInputRow,
|
|
5
|
-
SqliteRow,
|
|
6
10
|
TimeValuePrecision
|
|
7
11
|
} from '@powersync/service-sync-rules';
|
|
8
12
|
import { afterAll, describe, expect, test } from 'vitest';
|
|
9
13
|
import { clearTestDb, TEST_CONNECTION_OPTIONS } from './util.js';
|
|
10
|
-
import { eventIsWriteMutation, eventIsXid } from '@module/replication/zongji/zongji-utils.js';
|
|
11
|
-
import * as common from '@module/common/common-index.js';
|
|
12
|
-
import { BinLogEvent, ZongJi } from '@powersync/mysql-zongji';
|
|
13
|
-
import { MySQLConnectionManager } from '@module/replication/MySQLConnectionManager.js';
|
|
14
|
-
import { toColumnDescriptors } from '@module/common/common-index.js';
|
|
15
14
|
|
|
16
15
|
describe('MySQL Data Types', () => {
|
|
17
16
|
const connectionManager = new MySQLConnectionManager(TEST_CONNECTION_OPTIONS, {});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
1
|
import { matchedSchemaChangeQuery } from '@module/utils/parser-utils.js';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
3
|
|
|
4
4
|
describe('MySQL Parser Util Tests', () => {
|
|
5
5
|
test('matchedSchemaChangeQuery function', () => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { compareIds, putOp, removeOp, test_utils } from '@powersync/service-core-tests';
|
|
2
2
|
import { beforeAll, describe, expect, test } from 'vitest';
|
|
3
3
|
|
|
4
|
-
import { storage } from '@powersync/service-core';
|
|
5
|
-
import { createTestDb, describeWithStorage, TEST_CONNECTION_OPTIONS } from './util.js';
|
|
6
|
-
import { BinlogStreamTestContext } from './BinlogStreamUtils.js';
|
|
7
|
-
import timers from 'timers/promises';
|
|
8
4
|
import { MySQLConnectionManager } from '@module/replication/MySQLConnectionManager.js';
|
|
9
5
|
import { getMySQLVersion, qualifiedMySQLTable, satisfiesVersion } from '@module/utils/mysql-utils.js';
|
|
6
|
+
import { storage } from '@powersync/service-core';
|
|
7
|
+
import timers from 'timers/promises';
|
|
8
|
+
import { BinlogStreamTestContext } from './BinlogStreamUtils.js';
|
|
9
|
+
import { createTestDb, describeWithStorage, TEST_CONNECTION_OPTIONS } from './util.js';
|
|
10
10
|
|
|
11
11
|
describe('MySQL Schema Changes', () => {
|
|
12
12
|
describeWithStorage({ timeout: 20_000 }, defineTests);
|