@bytebase/dbhub 1.2.2 → 1.2.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/dist/index.js CHANGED
@@ -2068,11 +2068,11 @@ See documentation for more details on configuring database connections.
2068
2068
 
2069
2069
  // src/index.ts
2070
2070
  var connectorModules = [
2071
- { load: () => import("./postgres-2FHS64EO.js"), name: "PostgreSQL", driver: "pg" },
2071
+ { load: () => import("./postgres-M3W3Y6F5.js"), name: "PostgreSQL", driver: "pg" },
2072
2072
  { load: () => import("./sqlserver-WNVSBFJ3.js"), name: "SQL Server", driver: "mssql" },
2073
2073
  { load: () => import("./sqlite-ASYMU5BI.js"), name: "SQLite", driver: "node:sqlite" },
2074
2074
  { load: () => import("./mysql-GXDUNLJ6.js"), name: "MySQL", driver: "mysql2" },
2075
- { load: () => import("./mariadb-DQ6P57IX.js"), name: "MariaDB", driver: "mariadb" }
2075
+ { load: () => import("./mariadb-EVJ5HLYH.js"), name: "MariaDB", driver: "mariadb" }
2076
2076
  ];
2077
2077
  loadConnectors(connectorModules).then(() => main()).catch((error) => {
2078
2078
  console.error("Fatal error:", error);
@@ -125,6 +125,12 @@ var MariaDBConnector = class _MariaDBConnector {
125
125
  try {
126
126
  const connectionConfig = await this.dsnParser.parse(dsn, config);
127
127
  this.pool = mariadb.createPool(connectionConfig);
128
+ this.pool.on("error", (err) => {
129
+ console.error(
130
+ `MariaDB pool (source "${this.sourceId}"): background connection error, pool will retry:`,
131
+ err.message
132
+ );
133
+ });
128
134
  const rows = await this.pool.query("SELECT VERSION() AS version");
129
135
  this.supportsReadOnlyTransaction = !isTiDBVersion(rows?.[0]?.version);
130
136
  } catch (err) {
@@ -19,7 +19,7 @@ import {
19
19
  import fs from "fs";
20
20
  import os from "os";
21
21
  import path from "path";
22
- import pg from "pg";
22
+ import pg2 from "pg";
23
23
 
24
24
  // src/connectors/postgres/failed-to-read-certificate.ts
25
25
  var FailedToReadCertificate = class extends Error {
@@ -29,8 +29,35 @@ var FailedToReadCertificate = class extends Error {
29
29
  }
30
30
  };
31
31
 
32
+ // src/connectors/postgres/type-parsers.ts
33
+ import pg from "pg";
34
+ var VERBATIM_DATE_TIME_OIDS = /* @__PURE__ */ new Set([
35
+ 1082,
36
+ // date
37
+ 1114,
38
+ // timestamp without time zone
39
+ 1184,
40
+ // timestamp with time zone
41
+ 1182,
42
+ // date[]
43
+ 1115,
44
+ // timestamp[]
45
+ 1185
46
+ // timestamptz[]
47
+ ]);
48
+ var passthrough = (value) => value;
49
+ var postgresTypeParsers = {
50
+ getTypeParser(oid, format) {
51
+ if (VERBATIM_DATE_TIME_OIDS.has(oid) && (format === void 0 || format === "text")) {
52
+ return passthrough;
53
+ }
54
+ return pg.types.getTypeParser(oid, format);
55
+ }
56
+ };
57
+
32
58
  // src/connectors/postgres/index.ts
33
- var { Pool } = pg;
59
+ var { Pool } = pg2;
60
+ var POSTGRES_CLIENT_QUERY_TIMEOUT_GRACE_MS = 5e3;
34
61
  var PostgresDSNParser = class {
35
62
  async parse(dsn, config) {
36
63
  const connectionTimeoutSeconds = config?.connectionTimeoutSeconds;
@@ -90,7 +117,9 @@ Expected: ${expectedFormat}`
90
117
  poolConfig.connectionTimeoutMillis = connectionTimeoutSeconds * 1e3;
91
118
  }
92
119
  if (queryTimeoutSeconds !== void 0) {
93
- poolConfig.query_timeout = queryTimeoutSeconds * 1e3;
120
+ const queryTimeoutMs = queryTimeoutSeconds * 1e3;
121
+ poolConfig.statement_timeout = queryTimeoutMs;
122
+ poolConfig.query_timeout = queryTimeoutMs + POSTGRES_CLIENT_QUERY_TIMEOUT_GRACE_MS;
94
123
  }
95
124
  return poolConfig;
96
125
  } catch (error) {
@@ -136,6 +165,7 @@ var PostgresConnector = class _PostgresConnector {
136
165
  this.defaultSchema = "public";
137
166
  try {
138
167
  const poolConfig = await this.dsnParser.parse(dsn, config);
168
+ poolConfig.types = postgresTypeParsers;
139
169
  if (config?.readonly) {
140
170
  poolConfig.options = (poolConfig.options || "") + " -c default_transaction_read_only=on";
141
171
  }
@@ -149,6 +179,12 @@ var PostgresConnector = class _PostgresConnector {
149
179
  }
150
180
  }
151
181
  this.pool = new Pool(poolConfig);
182
+ this.pool.on("error", (err) => {
183
+ console.error(
184
+ `PostgreSQL pool (source "${this.sourceId}"): idle connection dropped, will reconnect on next query:`,
185
+ err.message
186
+ );
187
+ });
152
188
  const client = await this.pool.connect();
153
189
  client.release();
154
190
  } catch (err) {
@@ -196,7 +232,7 @@ var PostgresConnector = class _PostgresConnector {
196
232
  SELECT table_name
197
233
  FROM information_schema.tables
198
234
  WHERE table_schema = $1
199
- AND table_type = 'BASE TABLE'
235
+ AND table_type IN ('BASE TABLE', 'FOREIGN')
200
236
  ORDER BY table_name
201
237
  `,
202
238
  [schemaToUse]
@@ -275,7 +311,7 @@ var PostgresConnector = class _PostgresConnector {
275
311
  AND i.oid = ix.indexrelid
276
312
  AND a.attrelid = t.oid
277
313
  AND a.attnum = ANY(ix.indkey)
278
- AND t.relkind = 'r'
314
+ AND t.relkind IN ('r','p')
279
315
  AND t.relname = $1
280
316
  AND ns.oid = t.relnamespace
281
317
  AND ns.nspname = $2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebase/dbhub",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "mcpName": "io.github.bytebase/dbhub",
5
5
  "description": "Minimal, token-efficient Database MCP Server for PostgreSQL, MySQL, SQL Server, SQLite, MariaDB",
6
6
  "repository": {