@rex0220/kintone-sql-tools 3.78.0 → 3.80.0

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-cli/ksql.js CHANGED
@@ -16622,7 +16622,8 @@ __export(index_exports, {
16622
16622
  runWithArgv: () => runWithArgv,
16623
16623
  shouldExitOnEmpty: () => shouldExitOnEmpty,
16624
16624
  toCliImportError: () => toCliImportError,
16625
- writeBatchOutput: () => writeBatchOutput
16625
+ writeBatchOutput: () => writeBatchOutput,
16626
+ writeSingleSelectWarnings: () => writeSingleSelectWarnings
16626
16627
  });
16627
16628
  module.exports = __toCommonJS(index_exports);
16628
16629
  var import_fs3 = require("fs");
@@ -31747,7 +31748,7 @@ function hasAggregateColumns(columns) {
31747
31748
  (c) => c.type === "AGGREGATE" || c.type === "ARITH_AGG_COL" || c.type === "ARITH_COL" && containsAggregate2(c.expr) || c.type === "CASE_COL" && containsAggregate2(c.expr) || c.type === "STRFUNC_COL" && hasAggregateInStringFuncExpr2(c.expr) || c.type === "SCALAR_VALUE_COL" && scalarValueHasAggregate2(c.expr)
31748
31749
  );
31749
31750
  }
31750
- function applyGroupBy(rows, groupByKeys, columns, resolveAggSortKind, resolutionPlan, aliasEvaluationContext = {}) {
31751
+ function applyGroupBy(rows, groupByKeys, columns, resolveAggSortKind, resolutionPlan, aliasEvaluationContext = {}, having = null) {
31751
31752
  if (resolutionPlan && resolutionPlan.items.length !== groupByKeys.length) {
31752
31753
  throw new Error("InternalError: plain GROUP BY resolution plan length does not match group keys.");
31753
31754
  }
@@ -31796,11 +31797,18 @@ function applyGroupBy(rows, groupByKeys, columns, resolveAggSortKind, resolution
31796
31797
  resolveAggSortKind,
31797
31798
  aliasEvaluationContext.evaluationContext
31798
31799
  );
31800
+ materializeAggregateDependencies(
31801
+ outRow,
31802
+ groupRows,
31803
+ having,
31804
+ resolveAggSortKind,
31805
+ aliasEvaluationContext.evaluationContext
31806
+ );
31799
31807
  result.push(outRow);
31800
31808
  }
31801
31809
  return result;
31802
31810
  }
31803
- function applyGroupingSets(rows, spec, columns, resolveAggSortKind, limits = {}) {
31811
+ function applyGroupingSets(rows, spec, columns, resolveAggSortKind, limits = {}, having = null) {
31804
31812
  const result = [];
31805
31813
  let generatedRows = 0;
31806
31814
  const countBucket = () => {
@@ -31860,6 +31868,13 @@ function applyGroupingSets(rows, spec, columns, resolveAggSortKind, limits = {})
31860
31868
  resolveAggSortKind,
31861
31869
  limits.evaluationContext
31862
31870
  );
31871
+ materializeAggregateDependencies(
31872
+ outRow,
31873
+ groupRows,
31874
+ having,
31875
+ resolveAggSortKind,
31876
+ limits.evaluationContext
31877
+ );
31863
31878
  attachGroupingRowMeta(outRow, includedCanonicalIds);
31864
31879
  result.push(outRow);
31865
31880
  }
@@ -33120,7 +33135,8 @@ function runFullScan(input) {
33120
33135
  resolvedGroupingSpec,
33121
33136
  stmt.columns,
33122
33137
  aggregateSortKindResolver,
33123
- { maxGeneratedRows: B65_MAX_GENERATED_ROWS, evaluationContext }
33138
+ { maxGeneratedRows: B65_MAX_GENERATED_ROWS, evaluationContext },
33139
+ stmt.having
33124
33140
  );
33125
33141
  } else if (grouping.type === "PLAIN" || hasAggregateColumns(stmt.columns)) {
33126
33142
  rows = applyGroupBy(
@@ -33134,7 +33150,8 @@ function runFullScan(input) {
33134
33150
  resolveFieldType: fieldTypeResolver,
33135
33151
  resolveFieldSemantics: fieldSemanticsResolver,
33136
33152
  evaluationContext
33137
- }
33153
+ },
33154
+ stmt.having
33138
33155
  );
33139
33156
  }
33140
33157
  warnOnUnresolvedAggregateComparisons(stmt.columns, rows, warnings);
@@ -35211,6 +35228,15 @@ function getSelectColumnMeta(result) {
35211
35228
  }
35212
35229
  var materializedMetaByValidationResult = /* @__PURE__ */ new WeakMap();
35213
35230
  var importSourceByDmlStatement = /* @__PURE__ */ new WeakMap();
35231
+ var sourceWarningsByDmlStatement = /* @__PURE__ */ new WeakMap();
35232
+ function rememberDmlSourceWarnings(statement, warnings) {
35233
+ if (!warnings?.length) return;
35234
+ sourceWarningsByDmlStatement.set(statement, [...new Set(warnings)]);
35235
+ }
35236
+ function outcomeWithResultWarnings(statement, result) {
35237
+ const warnings = sourceWarningsByDmlStatement.get(statement);
35238
+ return { result, ...warnings?.length ? { warnings } : {} };
35239
+ }
35214
35240
  var statementEvaluationContextKey = /* @__PURE__ */ Symbol("statementEvaluationContext");
35215
35241
  var importSourceMaterializedCallbackKey = /* @__PURE__ */ Symbol("importSourceMaterializedCallback");
35216
35242
  var nativeUpsertExecutionKey = /* @__PURE__ */ Symbol("nativeUpsertExecution");
@@ -36011,13 +36037,17 @@ async function executeBatch(sql, client, options = {}) {
36011
36037
  }
36012
36038
  }
36013
36039
  metrics.elapsedMs = Date.now() - startedAt;
36040
+ const warnings = [.../* @__PURE__ */ new Set([
36041
+ ...dialect1Warnings,
36042
+ ...results.flatMap((statement) => statement.warnings ?? [])
36043
+ ])];
36014
36044
  const batchResult = {
36015
36045
  ok: results.every((r) => r.status === "success" || r.skippedReason === "exit"),
36016
36046
  statementCount: statements.length,
36017
36047
  statements: results,
36018
36048
  analysis,
36019
36049
  metrics,
36020
- ...dialect1Warnings.length > 0 ? { warnings: dialect1Warnings } : {}
36050
+ ...warnings.length > 0 ? { warnings } : {}
36021
36051
  };
36022
36052
  const observer = options[batchCompletionObserverKey];
36023
36053
  if (observer) {
@@ -36128,7 +36158,7 @@ async function executeBatchStatement(context) {
36128
36158
  }
36129
36159
  await assertRelativeDateExecutionPlan(resolvedStmt, client, cacheContext);
36130
36160
  if (resolvedStmt.type === "VALIDATE") {
36131
- const result = await executeExistingRecordValidationCore(
36161
+ const result2 = await executeExistingRecordValidationCore(
36132
36162
  resolvedStmt,
36133
36163
  client,
36134
36164
  { ...options, onLimitReached: "error" },
@@ -36138,19 +36168,20 @@ async function executeBatchStatement(context) {
36138
36168
  appendValidationErrors(
36139
36169
  tempTables,
36140
36170
  resolvedStmt.errorTable,
36141
- result.columns,
36142
- result.rows,
36171
+ result2.columns,
36172
+ result2.rows,
36143
36173
  options.tempTableMaxRows ?? TEMP_TABLE_MAX_ROWS,
36144
- materializedMetaBySelectResult.get(result) ?? existingValidationColumnMeta(resolvedStmt.summary === true)
36174
+ materializedMetaBySelectResult.get(result2) ?? existingValidationColumnMeta(resolvedStmt.summary === true)
36145
36175
  );
36146
36176
  }
36147
- return { result };
36177
+ return { result: result2 };
36148
36178
  }
36149
36179
  if (resolvedStmt.type === "IMPORT") {
36150
- return { result: await executeImport(resolvedStmt, client, options, cacheContext, tempTables) };
36180
+ const result2 = await executeImport(resolvedStmt, client, options, cacheContext, tempTables);
36181
+ return outcomeWithResultWarnings(resolvedStmt, result2);
36151
36182
  }
36152
36183
  if ("validateOnly" in resolvedStmt && resolvedStmt.validateOnly === true) {
36153
- const result = await executeDmlValidation(
36184
+ const result2 = await executeDmlValidation(
36154
36185
  resolvedStmt,
36155
36186
  client,
36156
36187
  { ...options, onLimitReached: "error" },
@@ -36162,25 +36193,24 @@ async function executeBatchStatement(context) {
36162
36193
  appendValidationErrors(
36163
36194
  tempTables,
36164
36195
  resolvedStmt.validationErrorTable,
36165
- result.columns,
36166
- result.errors,
36196
+ result2.columns,
36197
+ result2.errors,
36167
36198
  options.tempTableMaxRows ?? TEMP_TABLE_MAX_ROWS,
36168
- materializedMetaByValidationResult.get(result) ?? /* @__PURE__ */ new Map()
36199
+ materializedMetaByValidationResult.get(result2) ?? /* @__PURE__ */ new Map()
36169
36200
  );
36170
36201
  }
36171
- return { result };
36202
+ return outcomeWithResultWarnings(resolvedStmt, result2);
36172
36203
  }
36173
36204
  if ("onErrorSkip" in resolvedStmt && resolvedStmt.onErrorSkip === true) {
36174
- return {
36175
- result: await executeOnErrorSkip(
36176
- resolvedStmt,
36177
- client,
36178
- { ...options, onLimitReached: "error" },
36179
- cacheContext,
36180
- tempTables,
36181
- info.index + 1
36182
- )
36183
- };
36205
+ const result2 = await executeOnErrorSkip(
36206
+ resolvedStmt,
36207
+ client,
36208
+ { ...options, onLimitReached: "error" },
36209
+ cacheContext,
36210
+ tempTables,
36211
+ info.index + 1
36212
+ );
36213
+ return outcomeWithResultWarnings(resolvedStmt, result2);
36184
36214
  }
36185
36215
  if (resolvedStmt.type === "CREATE_TEMP_TABLE") {
36186
36216
  const materializeOptions = {
@@ -36188,13 +36218,17 @@ async function executeBatchStatement(context) {
36188
36218
  maxRecords: options.tempTableMaxRows ?? TEMP_TABLE_MAX_ROWS,
36189
36219
  onLimitReached: "error"
36190
36220
  };
36191
- const result = await runSelectLike(resolvedStmt.query, client, materializeOptions, cacheContext, tempTables);
36221
+ const result2 = await runSelectLike(resolvedStmt.query, client, materializeOptions, cacheContext, tempTables);
36192
36222
  tempTables.set(resolvedStmt.name, {
36193
- rows: result.rows,
36194
- columns: result.columns,
36195
- columnMeta: materializedMetaBySelectResult.get(result)
36223
+ rows: result2.rows,
36224
+ columns: result2.columns,
36225
+ columnMeta: materializedMetaBySelectResult.get(result2)
36196
36226
  });
36197
- return { tempTable: resolvedStmt.name, rowCount: result.rows.length };
36227
+ return {
36228
+ tempTable: resolvedStmt.name,
36229
+ rowCount: result2.rows.length,
36230
+ ...result2.warnings?.length ? { warnings: [...result2.warnings] } : {}
36231
+ };
36198
36232
  }
36199
36233
  if (stmt.type === "DROP_TEMP_TABLE") {
36200
36234
  tempTables.delete(stmt.name);
@@ -36210,12 +36244,12 @@ async function executeBatchStatement(context) {
36210
36244
  }
36211
36245
  }
36212
36246
  if (resolvedStmt.type === "ASSERT") {
36213
- const result = await executeAssert(resolvedStmt, client, options, cacheContext, tempTables);
36214
- return result.warning !== void 0 ? { result } : {};
36247
+ const result2 = await executeAssert(resolvedStmt, client, options, cacheContext, tempTables);
36248
+ return result2.warning !== void 0 ? { result: result2 } : {};
36215
36249
  }
36216
36250
  if (resolvedStmt.type === "EXIT") {
36217
- const result = await executeExit(resolvedStmt, client, options, cacheContext, tempTables);
36218
- return { result, ...result.exited ? { exitTriggered: true } : {} };
36251
+ const result2 = await executeExit(resolvedStmt, client, options, cacheContext, tempTables);
36252
+ return { result: result2, ...result2.exited ? { exitTriggered: true } : {} };
36219
36253
  }
36220
36254
  if (info.tempTablesReferenced.length > 0) {
36221
36255
  if (resolvedStmt.type === "SELECT" || resolvedStmt.type === "UNION") {
@@ -36234,17 +36268,20 @@ async function executeBatchStatement(context) {
36234
36268
  return { result: await executeWith(resolvedStmt, client, options, cacheContext, tempTables) };
36235
36269
  }
36236
36270
  if (resolvedStmt.type === "INSERT_SELECT") {
36237
- return { result: await executeInsertSelect(resolvedStmt, client, options, cacheContext, tempTables) };
36271
+ const result2 = await executeInsertSelect(resolvedStmt, client, options, cacheContext, tempTables);
36272
+ return outcomeWithResultWarnings(resolvedStmt, result2);
36238
36273
  }
36239
36274
  if (resolvedStmt.type === "UPSERT_SELECT") {
36240
- return { result: await executeUpsertSelect(resolvedStmt, client, options, cacheContext, tempTables) };
36275
+ const result2 = await executeUpsertSelect(resolvedStmt, client, options, cacheContext, tempTables);
36276
+ return outcomeWithResultWarnings(resolvedStmt, result2);
36241
36277
  }
36242
36278
  if (resolvedStmt.type === "UPDATE" && resolvedStmt.from?.cteName != null) {
36243
36279
  return { result: await executeUpdate(resolvedStmt, client, options, cacheContext, tempTables) };
36244
36280
  }
36245
36281
  throw new Error(`ArgumentError: temp table references in ${stmt.type} are not supported yet.`);
36246
36282
  }
36247
- return { result: await executeParsedStatement(resolvedStmt, client, options, cacheContext) };
36283
+ const result = await executeParsedStatement(resolvedStmt, client, options, cacheContext);
36284
+ return outcomeWithResultWarnings(resolvedStmt, result);
36248
36285
  }
36249
36286
  async function runSelectLike(query, client, options, cacheContext, tempTables) {
36250
36287
  if (query.type === "WITH") {
@@ -36757,7 +36794,8 @@ async function buildWhereFieldSemanticsResolver(stmt, client, cacheContext, mate
36757
36794
  return fromPhysical(stmt.from, field.field, true);
36758
36795
  }
36759
36796
  const matches = tables.flatMap((table) => {
36760
- const semantics = table.cteName !== null ? resolveMaterializedColumnMeta(materializedTables?.get(table.cteName), field.field)?.semantics : fromPhysical(table, field.field, true);
36797
+ const materialized = table.cteName !== null ? materializedTables?.get(table.cteName) : void 0;
36798
+ const semantics = table.cteName !== null ? resolveMaterializedColumn(materialized, field.field) !== void 0 ? resolveMaterializedColumnMeta(materialized, field.field)?.semantics ?? syntheticSemantics("string") : void 0 : fromPhysical(table, field.field, true);
36761
36799
  return semantics ? [semantics] : [];
36762
36800
  });
36763
36801
  if (matches.length === 1) return matches[0];
@@ -37806,9 +37844,10 @@ function collectB86Subqueries(stmt) {
37806
37844
  }
37807
37845
  return queries;
37808
37846
  }
37809
- async function validateB86SelectFieldCodes(stmt, client, cteCache, cacheContext) {
37847
+ async function validateB86SelectFieldCodes(stmt, client, cteCache, cacheContext, cachedPhysicalFieldsOnly = false) {
37810
37848
  const tables = [stmt.from, ...stmt.joins.map((join3) => join3.table)];
37811
37849
  const materializedByTable = /* @__PURE__ */ new Map();
37850
+ const unavailableMaterializedTables = /* @__PURE__ */ new Set();
37812
37851
  const effectiveAliases = /* @__PURE__ */ new Set();
37813
37852
  for (const table of tables) {
37814
37853
  const alias = effectiveTableAlias(table);
@@ -37822,6 +37861,10 @@ async function validateB86SelectFieldCodes(stmt, client, cteCache, cacheContext)
37822
37861
  if (table.cteName === null || table.cteName === NO_FROM_CTE_NAME) continue;
37823
37862
  const materialized = cteCache.get(table.cteName);
37824
37863
  if (!materialized) {
37864
+ if (cachedPhysicalFieldsOnly) {
37865
+ unavailableMaterializedTables.add(table);
37866
+ continue;
37867
+ }
37825
37868
  throw new Error(`ArgumentError: materialized source ${table.cteName} is not available.`);
37826
37869
  }
37827
37870
  if (materialized.rows.length > 0 && materialized.columns.length === 0) {
@@ -37838,6 +37881,16 @@ async function validateB86SelectFieldCodes(stmt, client, cteCache, cacheContext)
37838
37881
  }
37839
37882
  const schemas = /* @__PURE__ */ new Map();
37840
37883
  await Promise.all(tables.map(async (table) => {
37884
+ if (unavailableMaterializedTables.has(table)) {
37885
+ schemas.set(table, {
37886
+ table,
37887
+ label: b86SourceLabel(table),
37888
+ validCodes: /* @__PURE__ */ new Set(),
37889
+ authoritative: false,
37890
+ schemaUnavailable: true
37891
+ });
37892
+ return;
37893
+ }
37841
37894
  const materialized = materializedByTable.get(table);
37842
37895
  if (materialized) {
37843
37896
  schemas.set(table, {
@@ -37850,12 +37903,12 @@ async function validateB86SelectFieldCodes(stmt, client, cteCache, cacheContext)
37850
37903
  return;
37851
37904
  }
37852
37905
  if (table.cteName === NO_FROM_CTE_NAME) return;
37853
- const defs = await getFieldsCached(table.appId, client, cacheContext);
37906
+ const defs = cachedPhysicalFieldsOnly ? await getFieldsIfCached(table.appId, cacheContext) : await getFieldsCached(table.appId, client, cacheContext);
37854
37907
  schemas.set(table, {
37855
37908
  table,
37856
37909
  label: b86SourceLabel(table),
37857
- validCodes: new Set(defs.map((def) => def.code)),
37858
- authoritative: defs.length > 0,
37910
+ validCodes: new Set((defs ?? []).map((def) => def.code)),
37911
+ authoritative: defs !== null && defs.length > 0,
37859
37912
  schemaUnavailable: false
37860
37913
  });
37861
37914
  }));
@@ -41767,6 +41820,8 @@ async function executeImport(stmt, client, options, cacheContext, tempTables) {
41767
41820
  importSourceByDmlStatement.set(generated, executionSource);
41768
41821
  const withAudit = (result2) => {
41769
41822
  if (executionSource.audit) Object.assign(result2, { importAudit: executionSource.audit });
41823
+ const warnings = sourceWarningsByDmlStatement.get(generated);
41824
+ if (warnings?.length) sourceWarningsByDmlStatement.set(stmt, warnings);
41770
41825
  return result2;
41771
41826
  };
41772
41827
  if (generated.validateOnly) {
@@ -42056,6 +42111,7 @@ async function materializeDmlSource(stmt, client, options, cacheContext, tempTab
42056
42111
  const imported = importSourceByDmlStatement.get(stmt);
42057
42112
  if (!imported) {
42058
42113
  const selected2 = tempTables && tempTables.size > 0 ? await executeQueryWithCte(stmt.select, client, options, tempTables, cacheContext, true) : await executeSelect(stmt.select, client, options, cacheContext, void 0, true);
42114
+ rememberDmlSourceWarnings(stmt, selected2.warnings);
42059
42115
  return { rows: selected2.rows, columns: selected2.columns, columnMeta: materializedMetaBySelectResult.get(selected2) };
42060
42116
  }
42061
42117
  const payload = await loadImportSource(imported.handle, imported.cache);
@@ -42071,6 +42127,7 @@ async function materializeDmlSource(stmt, client, options, cacheContext, tempTab
42071
42127
  const tables = new Map(tempTables ?? []);
42072
42128
  tables.set(IMPORT_PROJECTION_SOURCE, raw);
42073
42129
  const selected = await executeQueryWithCte(projection, client, { ...options, onLimitReached: "error" }, tables, cacheContext, true);
42130
+ rememberDmlSourceWarnings(stmt, selected.warnings);
42074
42131
  return { rows: selected.rows, columns: selected.columns, columnMeta: materializedMetaBySelectResult.get(selected) };
42075
42132
  }
42076
42133
  var dmlSourceMaterializer = { materialize: materializeDmlSource };
@@ -43503,6 +43560,7 @@ async function buildExplainWhereAnalysis(query, client, cacheContext, maxRecords
43503
43560
  const capabilities = /* @__PURE__ */ new Map();
43504
43561
  const orderPlans = /* @__PURE__ */ new Map();
43505
43562
  const plainGroupByPlans = /* @__PURE__ */ new Map();
43563
+ const explainSelectsForColumnCheck = [];
43506
43564
  const seen = /* @__PURE__ */ new Set();
43507
43565
  const sharedRelativeDatePlan = relativeDatePlan ?? await resolveRelativeDateExecutionPlan(query, tracedClient, cacheContext);
43508
43566
  const relativeNodeFor = (source) => sharedRelativeDatePlan.nodes.find(
@@ -43636,6 +43694,13 @@ async function buildExplainWhereAnalysis(query, client, cacheContext, maxRecords
43636
43694
  if (typed["type"] === "WITH") {
43637
43695
  const withStatement = node;
43638
43696
  for (const cte of withStatement.ctes) {
43697
+ if (cte.recursiveSpec) {
43698
+ const columns2 = recursiveOutputColumns(cte);
43699
+ if (cte.recursiveSpec.cycle) columns2.push(cte.recursiveSpec.cycle.markColumn);
43700
+ explainRelations.set(cte.name, { rows: [], columns: columns2 });
43701
+ await preflightExplainRelations(cte.query);
43702
+ continue;
43703
+ }
43639
43704
  await preflightExplainRelations(cte.query);
43640
43705
  if (cte.query.type === "GENERATE_SERIES") {
43641
43706
  if (cte.query.args.some((arg) => arg.type === "VARIABLE")) {
@@ -43671,6 +43736,8 @@ async function buildExplainWhereAnalysis(query, client, cacheContext, maxRecords
43671
43736
  if (typed["type"] === "SELECT") {
43672
43737
  const select = node;
43673
43738
  await bindProjectedNamesForSelectWithSchemas(select, explainRelations, tracedClient, cacheContext);
43739
+ await validateB86SelectFieldCodes(select, tracedClient, explainRelations, cacheContext, true);
43740
+ explainSelectsForColumnCheck.push(select);
43674
43741
  analyzeStaticSelectRows(select);
43675
43742
  for (const column of select.columns) {
43676
43743
  if (column.type === "SCALAR_SUBQUERY_COL") await preflightExplainRelations(column.query);
@@ -43734,7 +43801,8 @@ async function buildExplainWhereAnalysis(query, client, cacheContext, maxRecords
43734
43801
  const { resolver, rewrites } = await normalizeSelectChoiceEquality(
43735
43802
  select,
43736
43803
  tracedClient,
43737
- cacheContext
43804
+ cacheContext,
43805
+ explainRelations
43738
43806
  );
43739
43807
  if (rewrites.length > 0) explainChoiceEqualityRewrites.set(select, rewrites);
43740
43808
  const capability = classifyWhereCapability(select.where, resolver);
@@ -43932,6 +44000,9 @@ async function buildExplainWhereAnalysis(query, client, cacheContext, maxRecords
43932
44000
  }));
43933
44001
  }
43934
44002
  }
44003
+ for (const select of explainSelectsForColumnCheck) {
44004
+ await validateB86SelectFieldCodes(select, tracedClient, explainRelations, cacheContext, true);
44005
+ }
43935
44006
  return {
43936
44007
  capabilities,
43937
44008
  orderPlans,
@@ -46704,6 +46775,7 @@ function buildBatchEnvelope(batch, options = {}) {
46704
46775
  if (s.status === "skipped" && s.skippedReason) entry.skippedReason = s.skippedReason;
46705
46776
  if (s.tempTable !== void 0) entry.tempTable = s.tempTable;
46706
46777
  if (s.rowCount !== void 0) entry.rowCount = s.rowCount;
46778
+ if (s.warnings?.length) entry.warnings = s.warnings;
46707
46779
  if (s.status === "success" && s.result?.type === "SELECT") {
46708
46780
  totalRows += s.result.rowCount;
46709
46781
  if (maxTotalRecords !== void 0 && totalRows > maxTotalRecords) {
@@ -46760,8 +46832,9 @@ function buildBatchEnvelope(batch, options = {}) {
46760
46832
  statementCount: batch.statementCount,
46761
46833
  statements,
46762
46834
  results,
46763
- // バッチ全体の警告(仕様 §6.2)。文ごとの警告は results[].warnings に入る
46764
- warnings: []
46835
+ // バッチ全体の警告(仕様 §6.2)=dialect 1 の警告 + 結果セットを持たない文(CREATE TEMP TABLE・
46836
+ // SELECT-based DML)の実行時警告(B188・文順・重複なし)。SELECT の文ごとの警告は従来どおり results[].warnings
46837
+ warnings: batch.warnings ?? []
46765
46838
  };
46766
46839
  }
46767
46840
 
@@ -49323,12 +49396,23 @@ function buildBatchStatementSummary(s) {
49323
49396
  }
49324
49397
  }
49325
49398
  if (s.status === "skipped" && s.skippedReason) parts.push(`reason=${s.skippedReason}`);
49399
+ const warnings = s.warnings ?? (s.result?.type === "SELECT" ? s.result.warnings : void 0);
49400
+ if (s.status === "success" && warnings) {
49401
+ for (const warning of warnings) parts.push(`warning=${warning}`);
49402
+ }
49326
49403
  return parts.join(" ");
49327
49404
  }
49328
49405
  function buildSelectSummary(result) {
49329
49406
  const validateSummary = result.validateStats ? ` errorRecords=${result.validateStats.errorRecords} errorCount=${result.validateStats.errorCount}` : "";
49330
49407
  return `rowCount=${result.rowCount}${validateSummary}`;
49331
49408
  }
49409
+ function writeSingleSelectWarnings(result, format, quiet) {
49410
+ if (quiet || format === "json") return;
49411
+ for (const warning of result.warnings ?? []) {
49412
+ process.stderr.write(`warning=${warning}
49413
+ `);
49414
+ }
49415
+ }
49332
49416
  function buildBatchDmlConfirmMessage(analysis) {
49333
49417
  const lines = ["[DML Confirm] batch"];
49334
49418
  for (const s of analysis.statements) {
@@ -50792,6 +50876,7 @@ query=${label}`);
50792
50876
  process.stderr.write(`${buildSelectSummary(result)}
50793
50877
  `);
50794
50878
  }
50879
+ writeSingleSelectWarnings(result, format, quiet);
50795
50880
  if (exportPlan) {
50796
50881
  const exportCode = runSingleSelectCliExport(exportPlan, result, quiet);
50797
50882
  if (exportCode !== 0) return exportCode;
@@ -50852,5 +50937,6 @@ if (isDirectCliRun()) {
50852
50937
  runWithArgv,
50853
50938
  shouldExitOnEmpty,
50854
50939
  toCliImportError,
50855
- writeBatchOutput
50940
+ writeBatchOutput,
50941
+ writeSingleSelectWarnings
50856
50942
  });