UNPKG

forge-sql-orm

Version:

Drizzle ORM integration for Atlassian @forge/sql. Provides a custom driver, schema migration, two levels of caching (local and global via @forge/kvs), optimistic locking, and query analysis.

258 lines 23.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.forgeSystemTables = exports.clusterStatementsSummary = exports.statementsSummary = exports.statementsSummaryHistory = exports.clusterStatementsSummaryHistory = exports.slowQuery = exports.migrations = void 0; exports.getTables = getTables; const mysql_core_1 = require("drizzle-orm/mysql-core"); const sql_1 = require("@forge/sql"); exports.migrations = (0, mysql_core_1.mysqlTable)("__migrations", { id: (0, mysql_core_1.bigint)("id", { mode: "number" }).primaryKey().autoincrement(), name: (0, mysql_core_1.varchar)("name", { length: 255 }).notNull(), migratedAt: (0, mysql_core_1.timestamp)("migratedAt").defaultNow().notNull(), }); const informationSchema = (0, mysql_core_1.mysqlSchema)("information_schema"); exports.slowQuery = informationSchema.table("CLUSTER_SLOW_QUERY", { time: (0, mysql_core_1.timestamp)("Time", { fsp: 6, mode: "string" }).notNull(), // Timestamp when the slow query was recorded txnStartTs: (0, mysql_core_1.bigint)("Txn_start_ts", { mode: "bigint", unsigned: true }), // Transaction start timestamp (TSO) user: (0, mysql_core_1.varchar)("User", { length: 64 }), // User executing the query host: (0, mysql_core_1.varchar)("Host", { length: 64 }), // Host from which the query originated connId: (0, mysql_core_1.bigint)("Conn_ID", { mode: "bigint", unsigned: true }), // Connection ID sessionAlias: (0, mysql_core_1.varchar)("Session_alias", { length: 64 }), // Session alias execRetryCount: (0, mysql_core_1.bigint)("Exec_retry_count", { mode: "bigint", unsigned: true }), // Number of retries during execution execRetryTime: (0, mysql_core_1.double)("Exec_retry_time"), // Time spent in retries queryTime: (0, mysql_core_1.double)("Query_time"), // Total execution time parseTime: (0, mysql_core_1.double)("Parse_time"), // Time spent parsing SQL compileTime: (0, mysql_core_1.double)("Compile_time"), // Time spent compiling query plan rewriteTime: (0, mysql_core_1.double)("Rewrite_time"), // Time spent rewriting query preprocSubqueries: (0, mysql_core_1.bigint)("Preproc_subqueries", { mode: "bigint", unsigned: true }), // Number of subqueries preprocessed preprocSubqueriesTime: (0, mysql_core_1.double)("Preproc_subqueries_time"), // Time spent preprocessing subqueries optimizeTime: (0, mysql_core_1.double)("Optimize_time"), // Time spent in optimizer waitTs: (0, mysql_core_1.double)("Wait_TS"), // Wait time for getting TSO prewriteTime: (0, mysql_core_1.double)("Prewrite_time"), // Time spent in prewrite phase waitPrewriteBinlogTime: (0, mysql_core_1.double)("Wait_prewrite_binlog_time"), // Time waiting for binlog prewrite commitTime: (0, mysql_core_1.double)("Commit_time"), // Commit duration getCommitTsTime: (0, mysql_core_1.double)("Get_commit_ts_time"), // Time waiting for commit TSO commitBackoffTime: (0, mysql_core_1.double)("Commit_backoff_time"), // Backoff time during commit backoffTypes: (0, mysql_core_1.varchar)("Backoff_types", { length: 64 }), // Types of backoff occurred resolveLockTime: (0, mysql_core_1.double)("Resolve_lock_time"), // Time resolving locks localLatchWaitTime: (0, mysql_core_1.double)("Local_latch_wait_time"), // Time waiting on local latch writeKeys: (0, mysql_core_1.bigint)("Write_keys", { mode: "bigint" }), // Number of keys written writeSize: (0, mysql_core_1.bigint)("Write_size", { mode: "bigint" }), // Amount of data written prewriteRegion: (0, mysql_core_1.bigint)("Prewrite_region", { mode: "bigint" }), // Regions involved in prewrite txnRetry: (0, mysql_core_1.bigint)("Txn_retry", { mode: "bigint" }), // Transaction retry count copTime: (0, mysql_core_1.double)("Cop_time"), // Time spent in coprocessor processTime: (0, mysql_core_1.double)("Process_time"), // Processing time waitTime: (0, mysql_core_1.double)("Wait_time"), // Wait time in TiKV backoffTime: (0, mysql_core_1.double)("Backoff_time"), // Backoff wait time lockKeysTime: (0, mysql_core_1.double)("LockKeys_time"), // Time spent waiting for locks requestCount: (0, mysql_core_1.bigint)("Request_count", { mode: "bigint", unsigned: true }), // Total number of requests totalKeys: (0, mysql_core_1.bigint)("Total_keys", { mode: "bigint", unsigned: true }), // Total keys scanned processKeys: (0, mysql_core_1.bigint)("Process_keys", { mode: "bigint", unsigned: true }), // Keys processed rocksdbDeleteSkippedCount: (0, mysql_core_1.bigint)("Rocksdb_delete_skipped_count", { mode: "bigint", unsigned: true, }), // RocksDB delete skips rocksdbKeySkippedCount: (0, mysql_core_1.bigint)("Rocksdb_key_skipped_count", { mode: "bigint", unsigned: true }), // RocksDB key skips rocksdbBlockCacheHitCount: (0, mysql_core_1.bigint)("Rocksdb_block_cache_hit_count", { mode: "bigint", unsigned: true, }), // RocksDB block cache hits rocksdbBlockReadCount: (0, mysql_core_1.bigint)("Rocksdb_block_read_count", { mode: "bigint", unsigned: true }), // RocksDB block reads rocksdbBlockReadByte: (0, mysql_core_1.bigint)("Rocksdb_block_read_byte", { mode: "bigint", unsigned: true }), // RocksDB block read bytes db: (0, mysql_core_1.varchar)("DB", { length: 64 }), // Database name indexNames: (0, mysql_core_1.varchar)("Index_names", { length: 100 }), // Indexes used isInternal: (0, mysql_core_1.boolean)("Is_internal"), // Whether the query is internal digest: (0, mysql_core_1.varchar)("Digest", { length: 64 }), // SQL digest hash stats: (0, mysql_core_1.varchar)("Stats", { length: 512 }), // Stats used during planning copProcAvg: (0, mysql_core_1.double)("Cop_proc_avg"), // Coprocessor average processing time copProcP90: (0, mysql_core_1.double)("Cop_proc_p90"), // Coprocessor 90th percentile processing time copProcMax: (0, mysql_core_1.double)("Cop_proc_max"), // Coprocessor max processing time copProcAddr: (0, mysql_core_1.varchar)("Cop_proc_addr", { length: 64 }), // Coprocessor address for processing copWaitAvg: (0, mysql_core_1.double)("Cop_wait_avg"), // Coprocessor average wait time copWaitP90: (0, mysql_core_1.double)("Cop_wait_p90"), // Coprocessor 90th percentile wait time copWaitMax: (0, mysql_core_1.double)("Cop_wait_max"), // Coprocessor max wait time copWaitAddr: (0, mysql_core_1.varchar)("Cop_wait_addr", { length: 64 }), // Coprocessor address for wait memMax: (0, mysql_core_1.bigint)("Mem_max", { mode: "bigint" }), // Max memory usage diskMax: (0, mysql_core_1.bigint)("Disk_max", { mode: "bigint" }), // Max disk usage kvTotal: (0, mysql_core_1.double)("KV_total"), // Total KV request time pdTotal: (0, mysql_core_1.double)("PD_total"), // Total PD request time backoffTotal: (0, mysql_core_1.double)("Backoff_total"), // Total backoff time writeSqlResponseTotal: (0, mysql_core_1.double)("Write_sql_response_total"), // SQL response write time resultRows: (0, mysql_core_1.bigint)("Result_rows", { mode: "bigint" }), // Rows returned warnings: (0, mysql_core_1.longtext)("Warnings"), // Warnings during execution backoffDetail: (0, mysql_core_1.varchar)("Backoff_Detail", { length: 4096 }), // Detailed backoff info prepared: (0, mysql_core_1.boolean)("Prepared"), // Whether query was prepared succ: (0, mysql_core_1.boolean)("Succ"), // Success flag isExplicitTxn: (0, mysql_core_1.boolean)("IsExplicitTxn"), // Whether explicit transaction isWriteCacheTable: (0, mysql_core_1.boolean)("IsWriteCacheTable"), // Whether wrote to cache table planFromCache: (0, mysql_core_1.boolean)("Plan_from_cache"), // Plan was from cache planFromBinding: (0, mysql_core_1.boolean)("Plan_from_binding"), // Plan was from binding hasMoreResults: (0, mysql_core_1.boolean)("Has_more_results"), // Query returned multiple results resourceGroup: (0, mysql_core_1.varchar)("Resource_group", { length: 64 }), // Resource group name requestUnitRead: (0, mysql_core_1.double)("Request_unit_read"), // RU consumed for read requestUnitWrite: (0, mysql_core_1.double)("Request_unit_write"), // RU consumed for write timeQueuedByRc: (0, mysql_core_1.double)("Time_queued_by_rc"), // Time queued by resource control tidbCpuTime: (0, mysql_core_1.double)("Tidb_cpu_time"), // TiDB CPU time tikvCpuTime: (0, mysql_core_1.double)("Tikv_cpu_time"), // TiKV CPU time plan: (0, mysql_core_1.longtext)("Plan"), // Query execution plan planDigest: (0, mysql_core_1.varchar)("Plan_digest", { length: 128 }), // Plan digest hash binaryPlan: (0, mysql_core_1.longtext)("Binary_plan"), // Binary execution plan prevStmt: (0, mysql_core_1.longtext)("Prev_stmt"), // Previous statement in session query: (0, mysql_core_1.longtext)("Query"), // Original SQL query }); // Common schema for cluster statements summary tables const createClusterStatementsSummarySchema = () => ({ instance: (0, mysql_core_1.varchar)("INSTANCE", { length: 64 }), // TiDB/TiKV instance address summaryBeginTime: (0, mysql_core_1.timestamp)("SUMMARY_BEGIN_TIME", { mode: "string" }).notNull(), // Begin time of this summary window summaryEndTime: (0, mysql_core_1.timestamp)("SUMMARY_END_TIME", { mode: "string" }).notNull(), // End time of this summary window stmtType: (0, mysql_core_1.varchar)("STMT_TYPE", { length: 64 }).notNull(), // Statement type (e.g., Select/Insert/Update) schemaName: (0, mysql_core_1.varchar)("SCHEMA_NAME", { length: 64 }), // Current schema name digest: (0, mysql_core_1.varchar)("DIGEST", { length: 64 }), // SQL digest (normalized hash) digestText: (0, mysql_core_1.text)("DIGEST_TEXT").notNull(), // Normalized SQL text tableNames: (0, mysql_core_1.text)("TABLE_NAMES"), // Involved table names indexNames: (0, mysql_core_1.text)("INDEX_NAMES"), // Used index names sampleUser: (0, mysql_core_1.varchar)("SAMPLE_USER", { length: 64 }), // Sampled user who executed the statements execCount: (0, mysql_core_1.bigint)("EXEC_COUNT", { mode: "bigint", unsigned: true }).notNull(), // Total executions sumErrors: (0, mysql_core_1.int)("SUM_ERRORS", { unsigned: true }).notNull(), // Sum of errors sumWarnings: (0, mysql_core_1.int)("SUM_WARNINGS", { unsigned: true }).notNull(), // Sum of warnings sumLatency: (0, mysql_core_1.bigint)("SUM_LATENCY", { mode: "bigint", unsigned: true }).notNull(), // Sum of latency (ns) maxLatency: (0, mysql_core_1.bigint)("MAX_LATENCY", { mode: "bigint", unsigned: true }).notNull(), // Max latency (ns) minLatency: (0, mysql_core_1.bigint)("MIN_LATENCY", { mode: "bigint", unsigned: true }).notNull(), // Min latency (ns) avgLatency: (0, mysql_core_1.bigint)("AVG_LATENCY", { mode: "bigint", unsigned: true }).notNull(), // Avg latency (ns) avgParseLatency: (0, mysql_core_1.bigint)("AVG_PARSE_LATENCY", { mode: "bigint", unsigned: true }).notNull(), // Avg parse time (ns) maxParseLatency: (0, mysql_core_1.bigint)("MAX_PARSE_LATENCY", { mode: "bigint", unsigned: true }).notNull(), // Max parse time (ns) avgCompileLatency: (0, mysql_core_1.bigint)("AVG_COMPILE_LATENCY", { mode: "bigint", unsigned: true }).notNull(), // Avg compile time (ns) maxCompileLatency: (0, mysql_core_1.bigint)("MAX_COMPILE_LATENCY", { mode: "bigint", unsigned: true }).notNull(), // Max compile time (ns) sumCopTaskNum: (0, mysql_core_1.bigint)("SUM_COP_TASK_NUM", { mode: "bigint", unsigned: true }).notNull(), // Total number of cop tasks maxCopProcessTime: (0, mysql_core_1.bigint)("MAX_COP_PROCESS_TIME", { mode: "bigint", unsigned: true }).notNull(), // Max TiKV coprocessor processing time (ns) maxCopProcessAddress: (0, mysql_core_1.varchar)("MAX_COP_PROCESS_ADDRESS", { length: 256 }), // Address of cop task with max processing time maxCopWaitTime: (0, mysql_core_1.bigint)("MAX_COP_WAIT_TIME", { mode: "bigint", unsigned: true }).notNull(), // Max TiKV coprocessor wait time (ns) maxCopWaitAddress: (0, mysql_core_1.varchar)("MAX_COP_WAIT_ADDRESS", { length: 256 }), // Address of cop task with max wait time avgProcessTime: (0, mysql_core_1.bigint)("AVG_PROCESS_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg TiKV processing time (ns) maxProcessTime: (0, mysql_core_1.bigint)("MAX_PROCESS_TIME", { mode: "bigint", unsigned: true }).notNull(), // Max TiKV processing time (ns) avgWaitTime: (0, mysql_core_1.bigint)("AVG_WAIT_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg TiKV wait time (ns) maxWaitTime: (0, mysql_core_1.bigint)("MAX_WAIT_TIME", { mode: "bigint", unsigned: true }).notNull(), // Max TiKV wait time (ns) avgBackoffTime: (0, mysql_core_1.bigint)("AVG_BACKOFF_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg backoff time before retry (ns) maxBackoffTime: (0, mysql_core_1.bigint)("MAX_BACKOFF_TIME", { mode: "bigint", unsigned: true }).notNull(), // Max backoff time before retry (ns) avgTotalKeys: (0, mysql_core_1.bigint)("AVG_TOTAL_KEYS", { mode: "bigint", unsigned: true }).notNull(), // Avg scanned keys maxTotalKeys: (0, mysql_core_1.bigint)("MAX_TOTAL_KEYS", { mode: "bigint", unsigned: true }).notNull(), // Max scanned keys avgProcessedKeys: (0, mysql_core_1.bigint)("AVG_PROCESSED_KEYS", { mode: "bigint", unsigned: true }).notNull(), // Avg processed keys maxProcessedKeys: (0, mysql_core_1.bigint)("MAX_PROCESSED_KEYS", { mode: "bigint", unsigned: true }).notNull(), // Max processed keys avgRocksdbDeleteSkippedCount: (0, mysql_core_1.double)("AVG_ROCKSDB_DELETE_SKIPPED_COUNT").notNull(), // Avg RocksDB deletes skipped maxRocksdbDeleteSkippedCount: (0, mysql_core_1.int)("MAX_ROCKSDB_DELETE_SKIPPED_COUNT", { unsigned: true, }).notNull(), // Max RocksDB deletes skipped avgRocksdbKeySkippedCount: (0, mysql_core_1.double)("AVG_ROCKSDB_KEY_SKIPPED_COUNT").notNull(), // Avg RocksDB keys skipped maxRocksdbKeySkippedCount: (0, mysql_core_1.int)("MAX_ROCKSDB_KEY_SKIPPED_COUNT", { unsigned: true }).notNull(), // Max RocksDB keys skipped avgRocksdbBlockCacheHitCount: (0, mysql_core_1.double)("AVG_ROCKSDB_BLOCK_CACHE_HIT_COUNT").notNull(), // Avg RocksDB block cache hits maxRocksdbBlockCacheHitCount: (0, mysql_core_1.int)("MAX_ROCKSDB_BLOCK_CACHE_HIT_COUNT", { unsigned: true, }).notNull(), // Max RocksDB block cache hits avgRocksdbBlockReadCount: (0, mysql_core_1.double)("AVG_ROCKSDB_BLOCK_READ_COUNT").notNull(), // Avg RocksDB block reads maxRocksdbBlockReadCount: (0, mysql_core_1.int)("MAX_ROCKSDB_BLOCK_READ_COUNT", { unsigned: true }).notNull(), // Max RocksDB block reads avgRocksdbBlockReadByte: (0, mysql_core_1.double)("AVG_ROCKSDB_BLOCK_READ_BYTE").notNull(), // Avg RocksDB block read bytes maxRocksdbBlockReadByte: (0, mysql_core_1.int)("MAX_ROCKSDB_BLOCK_READ_BYTE", { unsigned: true }).notNull(), // Max RocksDB block read bytes avgPrewriteTime: (0, mysql_core_1.bigint)("AVG_PREWRITE_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg prewrite phase time (ns) maxPrewriteTime: (0, mysql_core_1.bigint)("MAX_PREWRITE_TIME", { mode: "bigint", unsigned: true }).notNull(), // Max prewrite phase time (ns) avgCommitTime: (0, mysql_core_1.bigint)("AVG_COMMIT_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg commit phase time (ns) maxCommitTime: (0, mysql_core_1.bigint)("MAX_COMMIT_TIME", { mode: "bigint", unsigned: true }).notNull(), // Max commit phase time (ns) avgGetCommitTsTime: (0, mysql_core_1.bigint)("AVG_GET_COMMIT_TS_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Avg get commit_ts time (ns) maxGetCommitTsTime: (0, mysql_core_1.bigint)("MAX_GET_COMMIT_TS_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Max get commit_ts time (ns) avgCommitBackoffTime: (0, mysql_core_1.bigint)("AVG_COMMIT_BACKOFF_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Avg backoff during commit (ns) maxCommitBackoffTime: (0, mysql_core_1.bigint)("MAX_COMMIT_BACKOFF_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Max backoff during commit (ns) avgResolveLockTime: (0, mysql_core_1.bigint)("AVG_RESOLVE_LOCK_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Avg resolve lock time (ns) maxResolveLockTime: (0, mysql_core_1.bigint)("MAX_RESOLVE_LOCK_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Max resolve lock time (ns) avgLocalLatchWaitTime: (0, mysql_core_1.bigint)("AVG_LOCAL_LATCH_WAIT_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Avg local latch wait (ns) maxLocalLatchWaitTime: (0, mysql_core_1.bigint)("MAX_LOCAL_LATCH_WAIT_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Max local latch wait (ns) avgWriteKeys: (0, mysql_core_1.double)("AVG_WRITE_KEYS").notNull(), // Avg number of written keys maxWriteKeys: (0, mysql_core_1.bigint)("MAX_WRITE_KEYS", { mode: "bigint", unsigned: true }).notNull(), // Max written keys avgWriteSize: (0, mysql_core_1.double)("AVG_WRITE_SIZE").notNull(), // Avg written bytes maxWriteSize: (0, mysql_core_1.bigint)("MAX_WRITE_SIZE", { mode: "bigint", unsigned: true }).notNull(), // Max written bytes avgPrewriteRegions: (0, mysql_core_1.double)("AVG_PREWRITE_REGIONS").notNull(), // Avg regions in prewrite maxPrewriteRegions: (0, mysql_core_1.int)("MAX_PREWRITE_REGIONS", { unsigned: true }).notNull(), // Max regions in prewrite avgTxnRetry: (0, mysql_core_1.double)("AVG_TXN_RETRY").notNull(), // Avg transaction retry count maxTxnRetry: (0, mysql_core_1.int)("MAX_TXN_RETRY", { unsigned: true }).notNull(), // Max transaction retry count sumExecRetry: (0, mysql_core_1.bigint)("SUM_EXEC_RETRY", { mode: "bigint", unsigned: true }).notNull(), // Sum of execution retries (pessimistic) sumExecRetryTime: (0, mysql_core_1.bigint)("SUM_EXEC_RETRY_TIME", { mode: "bigint", unsigned: true }).notNull(), // Sum time of execution retries (ns) sumBackoffTimes: (0, mysql_core_1.bigint)("SUM_BACKOFF_TIMES", { mode: "bigint", unsigned: true }).notNull(), // Sum of backoff retries backoffTypes: (0, mysql_core_1.varchar)("BACKOFF_TYPES", { length: 1024 }), // Backoff types with counts avgMem: (0, mysql_core_1.bigint)("AVG_MEM", { mode: "bigint", unsigned: true }).notNull(), // Avg memory used (bytes) maxMem: (0, mysql_core_1.bigint)("MAX_MEM", { mode: "bigint", unsigned: true }).notNull(), // Max memory used (bytes) avgDisk: (0, mysql_core_1.bigint)("AVG_DISK", { mode: "bigint", unsigned: true }).notNull(), // Avg disk used (bytes) maxDisk: (0, mysql_core_1.bigint)("MAX_DISK", { mode: "bigint", unsigned: true }).notNull(), // Max disk used (bytes) avgKvTime: (0, mysql_core_1.bigint)("AVG_KV_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg time spent in TiKV (ns) avgPdTime: (0, mysql_core_1.bigint)("AVG_PD_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg time spent in PD (ns) avgBackoffTotalTime: (0, mysql_core_1.bigint)("AVG_BACKOFF_TOTAL_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Avg total backoff time (ns) avgWriteSqlRespTime: (0, mysql_core_1.bigint)("AVG_WRITE_SQL_RESP_TIME", { mode: "bigint", unsigned: true, }).notNull(), // Avg write SQL response time (ns) avgTidbCpuTime: (0, mysql_core_1.bigint)("AVG_TIDB_CPU_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg TiDB CPU time (ns) avgTikvCpuTime: (0, mysql_core_1.bigint)("AVG_TIKV_CPU_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg TiKV CPU time (ns) maxResultRows: (0, mysql_core_1.bigint)("MAX_RESULT_ROWS", { mode: "bigint" }).notNull(), // Max number of result rows minResultRows: (0, mysql_core_1.bigint)("MIN_RESULT_ROWS", { mode: "bigint" }).notNull(), // Min number of result rows avgResultRows: (0, mysql_core_1.bigint)("AVG_RESULT_ROWS", { mode: "bigint" }).notNull(), // Avg number of result rows prepared: (0, mysql_core_1.boolean)("PREPARED").notNull(), // Whether statements are prepared avgAffectedRows: (0, mysql_core_1.double)("AVG_AFFECTED_ROWS").notNull(), // Avg affected rows firstSeen: (0, mysql_core_1.timestamp)("FIRST_SEEN", { mode: "string" }).notNull(), // First time statements observed lastSeen: (0, mysql_core_1.timestamp)("LAST_SEEN", { mode: "string" }).notNull(), // Last time statements observed planInCache: (0, mysql_core_1.boolean)("PLAN_IN_CACHE").notNull(), // Whether last stmt hit plan cache planCacheHits: (0, mysql_core_1.bigint)("PLAN_CACHE_HITS", { mode: "bigint" }).notNull(), // Number of plan cache hits planInBinding: (0, mysql_core_1.boolean)("PLAN_IN_BINDING").notNull(), // Whether matched bindings querySampleText: (0, mysql_core_1.text)("QUERY_SAMPLE_TEXT"), // Sampled original SQL prevSampleText: (0, mysql_core_1.text)("PREV_SAMPLE_TEXT"), // Sampled previous SQL before commit planDigest: (0, mysql_core_1.varchar)("PLAN_DIGEST", { length: 64 }), // Plan digest hash plan: (0, mysql_core_1.text)("PLAN"), // Sampled textual plan binaryPlan: (0, mysql_core_1.text)("BINARY_PLAN"), // Sampled binary plan charset: (0, mysql_core_1.varchar)("CHARSET", { length: 64 }), // Sampled charset collation: (0, mysql_core_1.varchar)("COLLATION", { length: 64 }), // Sampled collation planHint: (0, mysql_core_1.varchar)("PLAN_HINT", { length: 64 }), // Sampled plan hint maxRequestUnitRead: (0, mysql_core_1.double)("MAX_REQUEST_UNIT_READ").notNull(), // Max RU cost (read) avgRequestUnitRead: (0, mysql_core_1.double)("AVG_REQUEST_UNIT_READ").notNull(), // Avg RU cost (read) maxRequestUnitWrite: (0, mysql_core_1.double)("MAX_REQUEST_UNIT_WRITE").notNull(), // Max RU cost (write) avgRequestUnitWrite: (0, mysql_core_1.double)("AVG_REQUEST_UNIT_WRITE").notNull(), // Avg RU cost (write) maxQueuedRcTime: (0, mysql_core_1.bigint)("MAX_QUEUED_RC_TIME", { mode: "bigint", unsigned: true }).notNull(), // Max queued time waiting for RU (ns) avgQueuedRcTime: (0, mysql_core_1.bigint)("AVG_QUEUED_RC_TIME", { mode: "bigint", unsigned: true }).notNull(), // Avg queued time waiting for RU (ns) resourceGroup: (0, mysql_core_1.varchar)("RESOURCE_GROUP", { length: 64 }), // Bound resource group name planCacheUnqualified: (0, mysql_core_1.bigint)("PLAN_CACHE_UNQUALIFIED", { mode: "bigint" }).notNull(), // Times not eligible for plan cache planCacheUnqualifiedLastReason: (0, mysql_core_1.text)("PLAN_CACHE_UNQUALIFIED_LAST_REASON"), // Last reason of plan cache ineligibility }); exports.clusterStatementsSummaryHistory = informationSchema.table("CLUSTER_STATEMENTS_SUMMARY_HISTORY", createClusterStatementsSummarySchema()); exports.statementsSummaryHistory = informationSchema.table("STATEMENTS_SUMMARY_HISTORY", createClusterStatementsSummarySchema()); exports.statementsSummary = informationSchema.table("STATEMENTS_SUMMARY", createClusterStatementsSummarySchema()); exports.clusterStatementsSummary = informationSchema.table("CLUSTER_STATEMENTS_SUMMARY", createClusterStatementsSummarySchema()); /** * Retrieves all tables from the database */ async function getTables() { const tables = await sql_1.sql.executeDDL("SHOW TABLES"); return tables.rows.flatMap((tableInfo) => Object.values(tableInfo)); } exports.forgeSystemTables = [exports.migrations]; //# sourceMappingURL=SystemTables.js.map