修探查脚本把 SQL 的 LIKE 写法照抄进 PowerShell 通配符,导致测试库全被判成"其他库"

PowerShell 的 -like 里 * 才是任意字符,% 只是普通字符;照抄 SQL 的 'DB[_]%' 一个库都匹配不上,
于是 5141 个库全进了"其他库",探查的 100 个恰好是最新的测试库(每个只有一张 Ws<N>_IV_0),
命中 0——上一次运行等于没查到东西。

- 抽出 Test-TestDatabase 用 'DB_*' 判定,并注明不能用 SQL 的 LIKE 写法;
- 第 1 块固定打印"其他库前 10 个"的库名,库名本身就能看出这批库是干什么的;
- 演练补上该判定的用例(含小写库名与几个不该匹配的名字)。
1个文件已修改
13 ■■■■■ 已修改文件
scripts/j22-introspect.ps1 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts/j22-introspect.ps1
@@ -40,6 +40,10 @@
# 只允许常规库名/表名:库名与表名会被拼进查询(标识符不能用参数),异常字符一律跳过。
function Test-SafeName([string]$name) { return $name -match '^[A-Za-z0-9_$]+$' }
# 测试库是 DB_<起始时间>:取数程序只读这些,其余库从来没有看过,所以本探查只看其余库。
# 注意这里用的是 PowerShell 通配符:* 才是"任意字符",% 只是普通字符——不要照抄 SQL 的 LIKE 写法。
function Test-TestDatabase([string]$name) { return $name -like 'DB_*' }
# 所有查询都经过这里:显式设 CommandTimeout,读满即断,不发加锁读、不开启事务。
function Invoke-ReadOnlyQuery($connection, [string]$sql) {
    $command = $connection.CreateCommand()
@@ -88,7 +92,7 @@
    $tests = New-Object System.Collections.ArrayList
    $others = New-Object System.Collections.ArrayList
    foreach ($row in $all) {
        if ([string]$row[0] -like 'DB[_]%') { [void]$tests.Add($row) } else { [void]$others.Add($row) }
        if (Test-TestDatabase ([string]$row[0])) { [void]$tests.Add($row) } else { [void]$others.Add($row) }
    }
    if ($Database) {
@@ -108,8 +112,11 @@
            [void]$targets.Add([string]$row[0])
            $index++
        }
        if ($others.Count -gt 0 -and $others.Count -le 20) {
            Say ("  其他库清单:" + (($others | ForEach-Object { [string]$_[0] }) -join '、'))
        if ($others.Count -gt 0) {
            # 前几个名字一定打出来:库名本身就能看出这批库是干什么的。
            $preview = ($others | Select-Object -First 10 | ForEach-Object { [string]$_[0] }) -join '、'
            $suffix = if ($others.Count -gt 10) { ' …' } else { '' }
            Say ("  其他库前 10 个:" + $preview + $suffix)
        }
    }
    if ($targets.Count -eq 0) {