neonctl 2.27.1 → 2.29.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.
Files changed (136) hide show
  1. package/README.md +35 -3
  2. package/dist/analytics.js +52 -34
  3. package/dist/api.js +643 -13
  4. package/dist/auth.js +50 -44
  5. package/dist/cli.js +8 -1
  6. package/dist/commands/auth.js +64 -51
  7. package/dist/commands/bootstrap.js +115 -157
  8. package/dist/commands/branches.js +160 -150
  9. package/dist/commands/bucket.js +183 -146
  10. package/dist/commands/checkout.js +51 -51
  11. package/dist/commands/config.js +228 -82
  12. package/dist/commands/connection_string.js +62 -62
  13. package/dist/commands/data_api.js +100 -101
  14. package/dist/commands/databases.js +29 -26
  15. package/dist/commands/deploy.js +12 -12
  16. package/dist/commands/dev.js +114 -114
  17. package/dist/commands/env.js +43 -43
  18. package/dist/commands/functions.js +101 -104
  19. package/dist/commands/index.js +27 -25
  20. package/dist/commands/init.js +23 -22
  21. package/dist/commands/ip_allow.js +29 -29
  22. package/dist/commands/link.js +232 -182
  23. package/dist/commands/neon_auth.js +385 -370
  24. package/dist/commands/operations.js +11 -11
  25. package/dist/commands/orgs.js +8 -8
  26. package/dist/commands/projects.js +103 -101
  27. package/dist/commands/psql.js +31 -31
  28. package/dist/commands/roles.js +27 -24
  29. package/dist/commands/schema_diff.js +25 -26
  30. package/dist/commands/set_context.js +17 -17
  31. package/dist/commands/status.js +40 -0
  32. package/dist/commands/user.js +5 -5
  33. package/dist/commands/vpc_endpoints.js +50 -50
  34. package/dist/config.js +7 -7
  35. package/dist/config_format.js +5 -5
  36. package/dist/context.js +37 -14
  37. package/dist/current_branch_fast_path.js +55 -0
  38. package/dist/dev/env.js +33 -33
  39. package/dist/dev/functions.js +4 -4
  40. package/dist/dev/inputs.js +6 -6
  41. package/dist/dev/runtime.js +25 -25
  42. package/dist/env.js +14 -14
  43. package/dist/env_file.js +13 -13
  44. package/dist/errors.js +68 -5
  45. package/dist/functions_api.js +10 -10
  46. package/dist/help.js +15 -15
  47. package/dist/index.js +110 -107
  48. package/dist/log.js +2 -2
  49. package/dist/parameters.gen.js +14 -14
  50. package/dist/pkg.js +5 -5
  51. package/dist/psql/cli.js +4 -2
  52. package/dist/psql/command/cmd_cond.js +61 -61
  53. package/dist/psql/command/cmd_connect.js +159 -154
  54. package/dist/psql/command/cmd_copy.js +107 -97
  55. package/dist/psql/command/cmd_describe.js +368 -363
  56. package/dist/psql/command/cmd_format.js +276 -263
  57. package/dist/psql/command/cmd_io.js +269 -263
  58. package/dist/psql/command/cmd_lo.js +74 -66
  59. package/dist/psql/command/cmd_meta.js +148 -148
  60. package/dist/psql/command/cmd_misc.js +17 -17
  61. package/dist/psql/command/cmd_pipeline.js +142 -135
  62. package/dist/psql/command/cmd_restrict.js +25 -25
  63. package/dist/psql/command/cmd_show.js +183 -168
  64. package/dist/psql/command/dispatch.js +26 -26
  65. package/dist/psql/command/shared.js +14 -14
  66. package/dist/psql/complete/filenames.js +16 -16
  67. package/dist/psql/complete/index.js +4 -4
  68. package/dist/psql/complete/matcher.js +33 -32
  69. package/dist/psql/complete/psqlVars.js +173 -173
  70. package/dist/psql/complete/queries.js +5 -3
  71. package/dist/psql/complete/rules.js +900 -863
  72. package/dist/psql/core/common.js +136 -133
  73. package/dist/psql/core/help.js +343 -343
  74. package/dist/psql/core/mainloop.js +160 -153
  75. package/dist/psql/core/prompt.js +126 -123
  76. package/dist/psql/core/settings.js +111 -111
  77. package/dist/psql/core/sqlHelp.js +150 -150
  78. package/dist/psql/core/startup.js +211 -205
  79. package/dist/psql/core/syncVars.js +14 -14
  80. package/dist/psql/core/variables.js +24 -24
  81. package/dist/psql/describe/formatters.js +302 -289
  82. package/dist/psql/describe/processNamePattern.js +28 -28
  83. package/dist/psql/describe/queries.js +656 -651
  84. package/dist/psql/index.js +436 -411
  85. package/dist/psql/io/history.js +36 -36
  86. package/dist/psql/io/input.js +15 -15
  87. package/dist/psql/io/lineEditor/buffer.js +27 -25
  88. package/dist/psql/io/lineEditor/complete.js +15 -15
  89. package/dist/psql/io/lineEditor/filename.js +22 -22
  90. package/dist/psql/io/lineEditor/index.js +65 -62
  91. package/dist/psql/io/lineEditor/keymap.js +325 -318
  92. package/dist/psql/io/lineEditor/vt100.js +60 -60
  93. package/dist/psql/io/pgpass.js +18 -18
  94. package/dist/psql/io/pgservice.js +14 -14
  95. package/dist/psql/io/psqlrc.js +46 -46
  96. package/dist/psql/print/aligned.js +175 -166
  97. package/dist/psql/print/asciidoc.js +51 -51
  98. package/dist/psql/print/crosstab.js +34 -31
  99. package/dist/psql/print/csv.js +25 -22
  100. package/dist/psql/print/html.js +54 -54
  101. package/dist/psql/print/json.js +12 -12
  102. package/dist/psql/print/latex.js +118 -118
  103. package/dist/psql/print/pager.js +28 -26
  104. package/dist/psql/print/troff.js +48 -48
  105. package/dist/psql/print/unaligned.js +15 -14
  106. package/dist/psql/print/units.js +17 -17
  107. package/dist/psql/scanner/slash.js +48 -46
  108. package/dist/psql/scanner/sql.js +88 -84
  109. package/dist/psql/scanner/stringutils.js +21 -17
  110. package/dist/psql/types/index.js +7 -7
  111. package/dist/psql/types/scanner.js +8 -8
  112. package/dist/psql/wire/connection.js +341 -327
  113. package/dist/psql/wire/copy.js +7 -7
  114. package/dist/psql/wire/pipeline.js +26 -24
  115. package/dist/psql/wire/protocol.js +102 -102
  116. package/dist/psql/wire/sasl.js +62 -62
  117. package/dist/psql/wire/tls.js +79 -73
  118. package/dist/storage_api.js +22 -23
  119. package/dist/test_utils/fixtures.js +74 -41
  120. package/dist/test_utils/oauth_server.js +5 -5
  121. package/dist/utils/api_enums.js +33 -0
  122. package/dist/utils/branch_notice.js +5 -5
  123. package/dist/utils/branch_picker.js +26 -26
  124. package/dist/utils/compute_units.js +4 -4
  125. package/dist/utils/enrichers.js +28 -16
  126. package/dist/utils/esbuild.js +28 -28
  127. package/dist/utils/formats.js +1 -1
  128. package/dist/utils/middlewares.js +3 -3
  129. package/dist/utils/package_manager.js +68 -0
  130. package/dist/utils/point_in_time.js +12 -12
  131. package/dist/utils/psql.js +30 -30
  132. package/dist/utils/string.js +2 -2
  133. package/dist/utils/ui.js +9 -9
  134. package/dist/utils/zip.js +1 -1
  135. package/dist/writer.js +17 -17
  136. package/package.json +10 -12
@@ -33,10 +33,10 @@
33
33
  * Connection guard: every command checks `ctx.settings.db` is non-null
34
34
  * and emits `\<cmd>: no current connection` to stderr on miss.
35
35
  */
36
- import { describeOneSequence, describeOneTableDetails, describeOneViewDetails, lookupOneRelation, runListQuery, } from '../describe/formatters.js';
37
- import { describeAccessMethods, describeAggregates, describeConfigurationParameters, describeFunctions, describeOperators, describeRoleGrants, describeRoles, describeSubscriptions, describeTableDetails, describeTablespaces, describeTypes, listAllDbs, listCasts, listCollations, listConversions, listDbRoleSettings, listDefaultACLs, listDomains, listEventTriggers, listExtendedStats, listExtensions, listForeignDataWrappers, listForeignServers, listForeignTables, listLanguages, listLargeObjects, listOpFamilyFunctions, listOpFamilyOperators, listOperatorClasses, listOperatorFamilies, listPartitionedTables, listPublications, listSchemas, listTSConfigs, listTSDictionaries, listTSParsers, listTSTemplates, listTables, listUserMappings, objectDescription, permissionsList, } from '../describe/queries.js';
38
- import { processSQLNamePattern, } from '../describe/processNamePattern.js';
39
- import { writeErr } from './shared.js';
36
+ import { describeOneSequence, describeOneTableDetails, describeOneViewDetails, lookupOneRelation, runListQuery, } from "../describe/formatters.js";
37
+ import { processSQLNamePattern, } from "../describe/processNamePattern.js";
38
+ import { describeAccessMethods, describeAggregates, describeConfigurationParameters, describeFunctions, describeOperators, describeRoleGrants, describeRoles, describeSubscriptions, describeTableDetails, describeTablespaces, describeTypes, listAllDbs, listCasts, listCollations, listConversions, listDbRoleSettings, listDefaultACLs, listDomains, listEventTriggers, listExtendedStats, listExtensions, listForeignDataWrappers, listForeignServers, listForeignTables, listLanguages, listLargeObjects, listOperatorClasses, listOperatorFamilies, listOpFamilyFunctions, listOpFamilyOperators, listPartitionedTables, listPublications, listSchemas, listTables, listTSConfigs, listTSDictionaries, listTSParsers, listTSTemplates, listUserMappings, objectDescription, permissionsList, } from "../describe/queries.js";
39
+ import { writeErr } from "./shared.js";
40
40
  /**
41
41
  * Helper: split a `\dXY+` command name into base, verbose, showSystem.
42
42
  *
@@ -50,9 +50,9 @@ const decodeSuffix = (cmdName, base) => {
50
50
  let showSystem = false;
51
51
  // Suffix order is unrestricted in psql.
52
52
  for (const ch of tail) {
53
- if (ch === '+')
53
+ if (ch === "+")
54
54
  verbose = true;
55
- else if (ch === 'S')
55
+ else if (ch === "S")
56
56
  showSystem = true;
57
57
  }
58
58
  return { verbose, showSystem };
@@ -62,7 +62,7 @@ const conn = (ctx) => ctx.settings.db;
62
62
  /** Emit "no current connection" error. */
63
63
  const noConn = (ctx) => {
64
64
  writeErr(`\\${ctx.cmdName}: no current connection\n`);
65
- return { status: 'error', errorWritten: true };
65
+ return { status: "error", errorWritten: true };
66
66
  };
67
67
  /**
68
68
  * Read the connection's current database. Mirrors upstream's
@@ -73,7 +73,7 @@ const noConn = (ctx) => {
73
73
  */
74
74
  const currentDb = (c) => {
75
75
  const meta = c;
76
- return typeof meta.database === 'string' ? meta.database : '';
76
+ return typeof meta.database === "string" ? meta.database : "";
77
77
  };
78
78
  /**
79
79
  * Validate a `processSQLNamePattern` result against the command's max
@@ -114,7 +114,7 @@ const runWithPattern = async (ctx, pattern, query, patternOpts, maxDots = 2, ove
114
114
  const dotErr = validatePattern(pattern, result, maxDots, currentDb(c));
115
115
  if (dotErr !== null) {
116
116
  writeErr(`${dotErr}\n`);
117
- return { status: 'error', errorWritten: true };
117
+ return { status: "error", errorWritten: true };
118
118
  }
119
119
  try {
120
120
  const basePopt = ctx.settings.popt;
@@ -122,11 +122,11 @@ const runWithPattern = async (ctx, pattern, query, patternOpts, maxDots = 2, ove
122
122
  ? { ...basePopt, topt: { ...basePopt.topt, defaultFooter: false } }
123
123
  : basePopt;
124
124
  await runListQuery(c, query, result, process.stdout, popt);
125
- return { status: 'ok' };
125
+ return { status: "ok" };
126
126
  }
127
127
  catch (err) {
128
128
  writeErr(`\\${ctx.cmdName}: ${errMsg(err)}\n`);
129
- return { status: 'error', errorWritten: true };
129
+ return { status: "error", errorWritten: true };
130
130
  }
131
131
  };
132
132
  /**
@@ -142,7 +142,7 @@ const runWithPattern = async (ctx, pattern, query, patternOpts, maxDots = 2, ove
142
142
  * parameter list renumbered so `$N` references stay distinct.
143
143
  */
144
144
  const applyTwoPatterns = (sql, baseParams, results) => {
145
- const placeholder = 'true /* TODO(WP-20): pattern matching */';
145
+ const placeholder = "true /* TODO(WP-20): pattern matching */";
146
146
  let rendered = sql;
147
147
  const params = [...baseParams];
148
148
  for (const result of results) {
@@ -157,7 +157,7 @@ const applyTwoPatterns = (sql, baseParams, results) => {
157
157
  const slotOffset = params.length;
158
158
  const renumbered = conds.map((c) => c.replace(/\$(\d+)/g, (_, n) => `$${Number(n) + slotOffset}`));
159
159
  params.push(...result.params);
160
- const replacement = renumbered.length === 0 ? 'true' : `(${renumbered.join(' AND ')})`;
160
+ const replacement = renumbered.length === 0 ? "true" : `(${renumbered.join(" AND ")})`;
161
161
  rendered =
162
162
  rendered.slice(0, idx) +
163
163
  replacement +
@@ -197,11 +197,11 @@ const runDualPatternList = async (ctx, query, results) => {
197
197
  };
198
198
  try {
199
199
  await runListQuery(c, finalQuery, empty, process.stdout, ctx.settings.popt);
200
- return { status: 'ok' };
200
+ return { status: "ok" };
201
201
  }
202
202
  catch (err) {
203
203
  writeErr(`\\${ctx.cmdName}: ${errMsg(err)}\n`);
204
- return { status: 'error', errorWritten: true };
204
+ return { status: "error", errorWritten: true };
205
205
  }
206
206
  };
207
207
  /**
@@ -226,7 +226,7 @@ const applyArgPatterns = (sql, baseParams, argResults) => {
226
226
  if (idx < 0)
227
227
  continue;
228
228
  const r = argResults[i];
229
- let replacement = 'true';
229
+ let replacement = "true";
230
230
  if (r !== null) {
231
231
  const conds = [
232
232
  ...r.schemaConditions,
@@ -237,7 +237,7 @@ const applyArgPatterns = (sql, baseParams, argResults) => {
237
237
  const slotOffset = params.length;
238
238
  const renumbered = conds.map((c) => c.replace(/\$(\d+)/g, (_, n) => `$${Number(n) + slotOffset}`));
239
239
  params.push(...r.params);
240
- replacement = `(${renumbered.join(' AND ')})`;
240
+ replacement = `(${renumbered.join(" AND ")})`;
241
241
  }
242
242
  }
243
243
  rendered =
@@ -255,24 +255,24 @@ const applyArgPatterns = (sql, baseParams, argResults) => {
255
255
  * literal, so this is the only place the user's input gets rewritten.
256
256
  */
257
257
  const TYPENAME_ALIASES = {
258
- decimal: 'numeric',
259
- float: 'double precision',
260
- int: 'integer',
261
- 'bool[]': 'boolean[]',
262
- 'decimal[]': 'numeric[]',
263
- 'float[]': 'double precision[]',
264
- 'float4[]': 'real[]',
265
- 'float8[]': 'double precision[]',
266
- 'int[]': 'integer[]',
267
- 'int2[]': 'smallint[]',
268
- 'int4[]': 'integer[]',
269
- 'int8[]': 'bigint[]',
270
- 'time[]': 'time without time zone[]',
271
- 'timetz[]': 'time with time zone[]',
272
- 'timestamp[]': 'timestamp without time zone[]',
273
- 'timestamptz[]': 'timestamp with time zone[]',
274
- 'varbit[]': 'bit varying[]',
275
- 'varchar[]': 'character varying[]',
258
+ decimal: "numeric",
259
+ float: "double precision",
260
+ int: "integer",
261
+ "bool[]": "boolean[]",
262
+ "decimal[]": "numeric[]",
263
+ "float[]": "double precision[]",
264
+ "float4[]": "real[]",
265
+ "float8[]": "double precision[]",
266
+ "int[]": "integer[]",
267
+ "int2[]": "smallint[]",
268
+ "int4[]": "integer[]",
269
+ "int8[]": "bigint[]",
270
+ "time[]": "time without time zone[]",
271
+ "timetz[]": "time with time zone[]",
272
+ "timestamp[]": "timestamp without time zone[]",
273
+ "timestamptz[]": "timestamp with time zone[]",
274
+ "varbit[]": "bit varying[]",
275
+ "varchar[]": "character varying[]",
276
276
  };
277
277
  const mapTypenamePattern = (pattern) => TYPENAME_ALIASES[pattern.toLowerCase()] ?? pattern;
278
278
  /**
@@ -283,7 +283,7 @@ const mapTypenamePattern = (pattern) => TYPENAME_ALIASES[pattern.toLowerCase()]
283
283
  * altnamevar so `\df foo int4` matches `oid -> integer` correctly.
284
284
  */
285
285
  const processArgPattern = (slot, raw) => {
286
- if (raw === '-')
286
+ if (raw === "-")
287
287
  return null;
288
288
  const mapped = mapTypenamePattern(raw);
289
289
  return processSQLNamePattern({
@@ -306,7 +306,7 @@ const collectArgPatterns = (ctx) => {
306
306
  // from the scanner; describeFunctions caps at FUNC_MAX_ARGS (100).
307
307
  // We let the caller decide what to do with extras (mostly: ignore).
308
308
  for (;;) {
309
- const arg = ctx.nextArg('normal');
309
+ const arg = ctx.nextArg("normal");
310
310
  if (arg === null)
311
311
  break;
312
312
  args.push(arg);
@@ -327,7 +327,7 @@ const runFunctionOrOperatorQuery = async (ctx, pattern, argPatternResults, query
327
327
  const dotErr = validatePattern(pattern, result, 2, currentDb(c));
328
328
  if (dotErr !== null) {
329
329
  writeErr(`${dotErr}\n`);
330
- return { status: 'error', errorWritten: true };
330
+ return { status: "error", errorWritten: true };
331
331
  }
332
332
  // Substitute the arg-pattern placeholders first so the params they
333
333
  // contribute precede the main pattern's `$N` allocations.
@@ -339,11 +339,11 @@ const runFunctionOrOperatorQuery = async (ctx, pattern, argPatternResults, query
339
339
  };
340
340
  try {
341
341
  await runListQuery(c, finalQuery, result, process.stdout, ctx.settings.popt);
342
- return { status: 'ok' };
342
+ return { status: "ok" };
343
343
  }
344
344
  catch (err) {
345
345
  writeErr(`\\${ctx.cmdName}: ${errMsg(err)}\n`);
346
- return { status: 'error', errorWritten: true };
346
+ return { status: "error", errorWritten: true };
347
347
  }
348
348
  };
349
349
  const errMsg = (err) => err instanceof Error ? err.message : String(err);
@@ -355,7 +355,7 @@ const errMsg = (err) => err instanceof Error ? err.message : String(err);
355
355
  const makeDescribeCmd = (baseName) => ({
356
356
  name: baseName,
357
357
  run: async (ctx) => {
358
- const pattern = ctx.nextArg('normal');
358
+ const pattern = ctx.nextArg("normal");
359
359
  const c = conn(ctx);
360
360
  if (!c)
361
361
  return noConn(ctx);
@@ -369,12 +369,12 @@ const makeDescribeCmd = (baseName) => ({
369
369
  const rel = await lookupOneRelation(c, pattern);
370
370
  if (rel) {
371
371
  await dispatchDetail(ctx, c, rel, verbose);
372
- return { status: 'ok' };
372
+ return { status: "ok" };
373
373
  }
374
374
  }
375
375
  catch (err) {
376
376
  writeErr(`\\${ctx.cmdName}: ${errMsg(err)}\n`);
377
- return { status: 'error', errorWritten: true };
377
+ return { status: "error", errorWritten: true };
378
378
  }
379
379
  // Fall through to list (mirrors upstream behaviour: if no exact
380
380
  // relation, treat the name as a list pattern).
@@ -382,12 +382,13 @@ const makeDescribeCmd = (baseName) => ({
382
382
  // `\d`-family `x` suffix toggles expanded mode for the LIST view
383
383
  // only — upstream `command.c` declines to apply it when a pattern is
384
384
  // present and would dispatch to per-relation detail rendering.
385
- const forceExpanded = ctx.cmdName.slice(baseName.length).includes('x') && pattern === null;
385
+ const forceExpanded = ctx.cmdName.slice(baseName.length).includes("x") &&
386
+ pattern === null;
386
387
  const savedPopt = ctx.settings.popt;
387
388
  if (forceExpanded) {
388
389
  ctx.settings.popt = {
389
390
  ...savedPopt,
390
- topt: { ...savedPopt.topt, expanded: 'on' },
391
+ topt: { ...savedPopt.topt, expanded: "on" },
391
392
  };
392
393
  }
393
394
  try {
@@ -403,10 +404,10 @@ const makeDescribeCmd = (baseName) => ({
403
404
  const dispatchDetail = async (ctx, c, rel, verbose) => {
404
405
  const popt = ctx.settings.popt;
405
406
  switch (rel.relkind) {
406
- case 'S':
407
+ case "S":
407
408
  await describeOneSequence(c, rel.oid, rel.nspname, rel.relname, process.stdout, popt);
408
409
  return;
409
- case 'v':
410
+ case "v":
410
411
  await describeOneViewDetails(c, rel.oid, rel.nspname, rel.relname, process.stdout, popt, verbose, ctx.settings.hideCompression);
411
412
  return;
412
413
  default:
@@ -417,9 +418,9 @@ const runTypedList = async (ctx, c, baseName, pattern, verbose, showSystem) => {
417
418
  const serverVersion = c.serverVersion;
418
419
  const hideTableam = ctx.settings.hideTableam;
419
420
  let query;
420
- let tabtypes = '';
421
+ let tabtypes = "";
421
422
  switch (baseName) {
422
- case 'd':
423
+ case "d":
423
424
  query = describeTableDetails({
424
425
  pattern: pattern ?? undefined,
425
426
  verbose,
@@ -428,8 +429,8 @@ const runTypedList = async (ctx, c, baseName, pattern, verbose, showSystem) => {
428
429
  hideTableam,
429
430
  });
430
431
  break;
431
- case 'dt':
432
- tabtypes = 't';
432
+ case "dt":
433
+ tabtypes = "t";
433
434
  query = listTables({
434
435
  pattern: pattern ?? undefined,
435
436
  verbose,
@@ -439,8 +440,8 @@ const runTypedList = async (ctx, c, baseName, pattern, verbose, showSystem) => {
439
440
  hideTableam,
440
441
  });
441
442
  break;
442
- case 'di':
443
- tabtypes = 'i';
443
+ case "di":
444
+ tabtypes = "i";
444
445
  query = listTables({
445
446
  pattern: pattern ?? undefined,
446
447
  verbose,
@@ -450,8 +451,8 @@ const runTypedList = async (ctx, c, baseName, pattern, verbose, showSystem) => {
450
451
  hideTableam,
451
452
  });
452
453
  break;
453
- case 'dv':
454
- tabtypes = 'v';
454
+ case "dv":
455
+ tabtypes = "v";
455
456
  query = listTables({
456
457
  pattern: pattern ?? undefined,
457
458
  verbose,
@@ -461,8 +462,8 @@ const runTypedList = async (ctx, c, baseName, pattern, verbose, showSystem) => {
461
462
  hideTableam,
462
463
  });
463
464
  break;
464
- case 'dm':
465
- tabtypes = 'm';
465
+ case "dm":
466
+ tabtypes = "m";
466
467
  query = listTables({
467
468
  pattern: pattern ?? undefined,
468
469
  verbose,
@@ -472,8 +473,8 @@ const runTypedList = async (ctx, c, baseName, pattern, verbose, showSystem) => {
472
473
  hideTableam,
473
474
  });
474
475
  break;
475
- case 'ds':
476
- tabtypes = 's';
476
+ case "ds":
477
+ tabtypes = "s";
477
478
  query = listTables({
478
479
  pattern: pattern ?? undefined,
479
480
  verbose,
@@ -483,8 +484,8 @@ const runTypedList = async (ctx, c, baseName, pattern, verbose, showSystem) => {
483
484
  hideTableam,
484
485
  });
485
486
  break;
486
- case 'dE':
487
- tabtypes = 'E';
487
+ case "dE":
488
+ tabtypes = "E";
488
489
  query = listTables({
489
490
  pattern: pattern ?? undefined,
490
491
  verbose,
@@ -495,25 +496,25 @@ const runTypedList = async (ctx, c, baseName, pattern, verbose, showSystem) => {
495
496
  });
496
497
  break;
497
498
  default:
498
- return { status: 'error' };
499
+ return { status: "error" };
499
500
  }
500
- const visibility = baseName === 'd'
501
- ? 'pg_catalog.pg_table_is_visible(c.oid)'
502
- : 'pg_catalog.pg_table_is_visible(c.oid)';
501
+ const visibility = baseName === "d"
502
+ ? "pg_catalog.pg_table_is_visible(c.oid)"
503
+ : "pg_catalog.pg_table_is_visible(c.oid)";
503
504
  return runWithPattern(ctx, pattern, query, {
504
- namevar: 'c.relname',
505
- schemavar: 'n.nspname',
505
+ namevar: "c.relname",
506
+ schemavar: "n.nspname",
506
507
  visibilityrule: visibility,
507
508
  });
508
509
  };
509
510
  // Register all the relation-list-style commands with all suffix combos.
510
- const RELATION_BASES = ['d', 'dt', 'di', 'dv', 'dm', 'ds', 'dE'];
511
+ const RELATION_BASES = ["d", "dt", "di", "dv", "dm", "ds", "dE"];
511
512
  // Standard suffix matrix. `x` is added separately for the bases that
512
513
  // accept the expanded-mode toggle (currently `\d`/`\d+`).
513
- const SUFFIX_COMBOS = ['', '+', 'S', 'S+', '+S'];
514
+ const SUFFIX_COMBOS = ["", "+", "S", "S+", "+S"];
514
515
  // Extended suffix matrix for `\d` only — adds the `x` (expanded) suffix
515
516
  // in the same combinations regress exercises.
516
- const DESCRIBE_X_SUFFIXES = ['x', '+x', 'x+', 'Sx', 'xS', '+Sx', '+xS'];
517
+ const DESCRIBE_X_SUFFIXES = ["x", "+x", "x+", "Sx", "xS", "+Sx", "+xS"];
517
518
  // ---- \df / \df+ / \dfS / \dfa / \dfn / \dfp / \dft / \dfw / \dfx -------
518
519
  // Upstream's `command.c::exec_command_df` accepts a free-form suffix after
519
520
  // `\df`: `+` for verbose, `S` to include system schemas, `x` to force
@@ -523,15 +524,19 @@ const DESCRIBE_X_SUFFIXES = ['x', '+x', 'x+', 'Sx', 'xS', '+Sx', '+xS'];
523
524
  const cmdDescribeFunctions = (cmdName) => ({
524
525
  name: cmdName,
525
526
  run: async (ctx) => {
526
- const pattern = ctx.nextArg('normal');
527
+ const pattern = ctx.nextArg("normal");
527
528
  const c = conn(ctx);
528
529
  if (!c)
529
530
  return noConn(ctx);
530
- const { verbose, showSystem } = decodeSuffix(cmdName, 'df');
531
- let functypes = '';
531
+ const { verbose, showSystem } = decodeSuffix(cmdName, "df");
532
+ let functypes = "";
532
533
  const tail = cmdName.slice(2);
533
534
  for (const ch of tail) {
534
- if (ch === 'a' || ch === 'n' || ch === 'p' || ch === 't' || ch === 'w') {
535
+ if (ch === "a" ||
536
+ ch === "n" ||
537
+ ch === "p" ||
538
+ ch === "t" ||
539
+ ch === "w") {
535
540
  functypes += ch;
536
541
  }
537
542
  }
@@ -548,12 +553,12 @@ const cmdDescribeFunctions = (cmdName) => ({
548
553
  // applies the toggle whether or not a pattern is present (unlike `\d`,
549
554
  // which only toggles when no pattern is given). Override popt locally
550
555
  // so we don't leak the change to subsequent commands.
551
- const forceExpanded = tail.includes('x');
556
+ const forceExpanded = tail.includes("x");
552
557
  const savedPopt = ctx.settings.popt;
553
558
  if (forceExpanded) {
554
559
  ctx.settings.popt = {
555
560
  ...savedPopt,
556
- topt: { ...savedPopt.topt, expanded: 'on' },
561
+ topt: { ...savedPopt.topt, expanded: "on" },
557
562
  };
558
563
  }
559
564
  try {
@@ -566,9 +571,9 @@ const cmdDescribeFunctions = (cmdName) => ({
566
571
  serverVersion: c.serverVersion,
567
572
  });
568
573
  return await runFunctionOrOperatorQuery(ctx, pattern, argPatternResults, query, {
569
- namevar: 'p.proname',
570
- schemavar: 'n.nspname',
571
- visibilityrule: 'pg_catalog.pg_function_is_visible(p.oid)',
574
+ namevar: "p.proname",
575
+ schemavar: "n.nspname",
576
+ visibilityrule: "pg_catalog.pg_function_is_visible(p.oid)",
572
577
  });
573
578
  }
574
579
  finally {
@@ -580,20 +585,20 @@ const cmdDescribeFunctions = (cmdName) => ({
580
585
  const cmdDescribeAggregates = (cmdName) => ({
581
586
  name: cmdName,
582
587
  run: async (ctx) => {
583
- const pattern = ctx.nextArg('normal');
588
+ const pattern = ctx.nextArg("normal");
584
589
  const c = conn(ctx);
585
590
  if (!c)
586
591
  return noConn(ctx);
587
- const { showSystem } = decodeSuffix(cmdName, 'da');
592
+ const { showSystem } = decodeSuffix(cmdName, "da");
588
593
  const query = describeAggregates({
589
594
  pattern: pattern ?? undefined,
590
595
  showSystem,
591
596
  serverVersion: c.serverVersion,
592
597
  });
593
598
  return runWithPattern(ctx, pattern, query, {
594
- namevar: 'p.proname',
595
- schemavar: 'n.nspname',
596
- visibilityrule: 'pg_catalog.pg_function_is_visible(p.oid)',
599
+ namevar: "p.proname",
600
+ schemavar: "n.nspname",
601
+ visibilityrule: "pg_catalog.pg_function_is_visible(p.oid)",
597
602
  });
598
603
  },
599
604
  });
@@ -606,12 +611,12 @@ const cmdDescribeAggregates = (cmdName) => ({
606
611
  const cmdDescribeAccessMethods = (cmdName) => ({
607
612
  name: cmdName,
608
613
  run: async (ctx) => {
609
- const pattern = ctx.nextArg('normal');
614
+ const pattern = ctx.nextArg("normal");
610
615
  const c = conn(ctx);
611
616
  if (!c)
612
617
  return noConn(ctx);
613
- const isAlias = cmdName.startsWith('dAm');
614
- const base = isAlias ? 'dAm' : 'dA';
618
+ const isAlias = cmdName.startsWith("dAm");
619
+ const base = isAlias ? "dAm" : "dA";
615
620
  const { verbose } = decodeSuffix(cmdName, base);
616
621
  // `\dAm[+]` always displays the verbose columns; trailing `+` is
617
622
  // accepted for syntactic parity but doesn't change output.
@@ -622,15 +627,15 @@ const cmdDescribeAccessMethods = (cmdName) => ({
622
627
  });
623
628
  // Access methods are global, never schema-qualified; first dot is
624
629
  // "too many dotted names".
625
- const result = await runWithPattern(ctx, pattern, query, { namevar: 'amname' }, 0);
630
+ const result = await runWithPattern(ctx, pattern, query, { namevar: "amname" }, 0);
626
631
  // Upstream `exec_command_d` drains any args past the first AFTER
627
632
  // running the query and writing the result, emitting one warning
628
633
  // per leftover token via `pg_log_warning`. Mirror that ordering so
629
634
  // `\dA foo bar` prints the (empty) result first, then
630
635
  // `\dA: extra argument "bar" ignored` to stderr.
631
- for (let extra = ctx.nextArg('normal'); extra !== null;) {
636
+ for (let extra = ctx.nextArg("normal"); extra !== null;) {
632
637
  writeErr(`\\${base}: extra argument "${extra}" ignored\n`);
633
- extra = ctx.nextArg('normal');
638
+ extra = ctx.nextArg("normal");
634
639
  }
635
640
  return result;
636
641
  },
@@ -643,12 +648,12 @@ const cmdDescribeAccessMethods = (cmdName) => ({
643
648
  const cmdListOperatorClasses = (cmdName) => ({
644
649
  name: cmdName,
645
650
  run: async (ctx) => {
646
- const amPat = ctx.nextArg('normal');
647
- const typePat = amPat ? ctx.nextArg('normal') : null;
651
+ const amPat = ctx.nextArg("normal");
652
+ const typePat = amPat ? ctx.nextArg("normal") : null;
648
653
  const c = conn(ctx);
649
654
  if (!c)
650
655
  return noConn(ctx);
651
- const { verbose } = decodeSuffix(cmdName, 'dAc');
656
+ const { verbose } = decodeSuffix(cmdName, "dAc");
652
657
  const query = listOperatorClasses({
653
658
  amPattern: amPat ?? undefined,
654
659
  typePattern: typePat ?? undefined,
@@ -659,28 +664,28 @@ const cmdListOperatorClasses = (cmdName) => ({
659
664
  const curDb = currentDb(c);
660
665
  if (amPat !== null) {
661
666
  const r = processSQLNamePattern({
662
- namevar: 'am.amname',
667
+ namevar: "am.amname",
663
668
  pattern: amPat,
664
669
  });
665
670
  // Access method names are flat — first dot is "too many".
666
671
  const err = validatePattern(amPat, r, 0, curDb);
667
672
  if (err !== null) {
668
673
  writeErr(`${err}\n`);
669
- return { status: 'error', errorWritten: true };
674
+ return { status: "error", errorWritten: true };
670
675
  }
671
676
  results.push(r);
672
677
  }
673
678
  if (typePat !== null) {
674
679
  const r = processSQLNamePattern({
675
- namevar: 't.typname',
676
- schemavar: 'tn.nspname',
680
+ namevar: "t.typname",
681
+ schemavar: "tn.nspname",
677
682
  pattern: typePat,
678
683
  });
679
684
  // Type pattern accepts db.schema.name; cross-db check on 2-dot.
680
685
  const err = validatePattern(typePat, r, 2, curDb);
681
686
  if (err !== null) {
682
687
  writeErr(`${err}\n`);
683
- return { status: 'error', errorWritten: true };
688
+ return { status: "error", errorWritten: true };
684
689
  }
685
690
  results.push(r);
686
691
  }
@@ -694,12 +699,12 @@ const cmdListOperatorClasses = (cmdName) => ({
694
699
  const cmdListOperatorFamilies = (cmdName) => ({
695
700
  name: cmdName,
696
701
  run: async (ctx) => {
697
- const amPat = ctx.nextArg('normal');
698
- const typePat = amPat ? ctx.nextArg('normal') : null;
702
+ const amPat = ctx.nextArg("normal");
703
+ const typePat = amPat ? ctx.nextArg("normal") : null;
699
704
  const c = conn(ctx);
700
705
  if (!c)
701
706
  return noConn(ctx);
702
- const { verbose } = decodeSuffix(cmdName, 'dAf');
707
+ const { verbose } = decodeSuffix(cmdName, "dAf");
703
708
  const query = listOperatorFamilies({
704
709
  amPattern: amPat ?? undefined,
705
710
  typePattern: typePat ?? undefined,
@@ -710,26 +715,26 @@ const cmdListOperatorFamilies = (cmdName) => ({
710
715
  const curDb = currentDb(c);
711
716
  if (amPat !== null) {
712
717
  const r = processSQLNamePattern({
713
- namevar: 'am.amname',
718
+ namevar: "am.amname",
714
719
  pattern: amPat,
715
720
  });
716
721
  const err = validatePattern(amPat, r, 0, curDb);
717
722
  if (err !== null) {
718
723
  writeErr(`${err}\n`);
719
- return { status: 'error', errorWritten: true };
724
+ return { status: "error", errorWritten: true };
720
725
  }
721
726
  results.push(r);
722
727
  }
723
728
  if (typePat !== null) {
724
729
  const r = processSQLNamePattern({
725
- namevar: 't.typname',
726
- schemavar: 'tn.nspname',
730
+ namevar: "t.typname",
731
+ schemavar: "tn.nspname",
727
732
  pattern: typePat,
728
733
  });
729
734
  const err = validatePattern(typePat, r, 2, curDb);
730
735
  if (err !== null) {
731
736
  writeErr(`${err}\n`);
732
- return { status: 'error', errorWritten: true };
737
+ return { status: "error", errorWritten: true };
733
738
  }
734
739
  results.push(r);
735
740
  }
@@ -742,12 +747,12 @@ const cmdListOperatorFamilies = (cmdName) => ({
742
747
  const cmdListOpFamilyOperators = (cmdName) => ({
743
748
  name: cmdName,
744
749
  run: async (ctx) => {
745
- const amPat = ctx.nextArg('normal');
746
- const familyPat = amPat ? ctx.nextArg('normal') : null;
750
+ const amPat = ctx.nextArg("normal");
751
+ const familyPat = amPat ? ctx.nextArg("normal") : null;
747
752
  const c = conn(ctx);
748
753
  if (!c)
749
754
  return noConn(ctx);
750
- const { verbose } = decodeSuffix(cmdName, 'dAo');
755
+ const { verbose } = decodeSuffix(cmdName, "dAo");
751
756
  const query = listOpFamilyOperators({
752
757
  amPattern: amPat ?? undefined,
753
758
  familyPattern: familyPat ?? undefined,
@@ -758,26 +763,26 @@ const cmdListOpFamilyOperators = (cmdName) => ({
758
763
  const curDb = currentDb(c);
759
764
  if (amPat !== null) {
760
765
  const r = processSQLNamePattern({
761
- namevar: 'am.amname',
766
+ namevar: "am.amname",
762
767
  pattern: amPat,
763
768
  });
764
769
  const err = validatePattern(amPat, r, 0, curDb);
765
770
  if (err !== null) {
766
771
  writeErr(`${err}\n`);
767
- return { status: 'error', errorWritten: true };
772
+ return { status: "error", errorWritten: true };
768
773
  }
769
774
  results.push(r);
770
775
  }
771
776
  if (familyPat !== null) {
772
777
  const r = processSQLNamePattern({
773
- namevar: 'of.opfname',
774
- schemavar: 'nsf.nspname',
778
+ namevar: "of.opfname",
779
+ schemavar: "nsf.nspname",
775
780
  pattern: familyPat,
776
781
  });
777
782
  const err = validatePattern(familyPat, r, 2, curDb);
778
783
  if (err !== null) {
779
784
  writeErr(`${err}\n`);
780
- return { status: 'error', errorWritten: true };
785
+ return { status: "error", errorWritten: true };
781
786
  }
782
787
  results.push(r);
783
788
  }
@@ -790,19 +795,19 @@ const cmdListOpFamilyOperators = (cmdName) => ({
790
795
  const cmdListOpFamilyFunctions = (cmdName) => ({
791
796
  name: cmdName,
792
797
  run: async (ctx) => {
793
- const amPat = ctx.nextArg('normal');
794
- const familyPat = amPat ? ctx.nextArg('normal') : null;
798
+ const amPat = ctx.nextArg("normal");
799
+ const familyPat = amPat ? ctx.nextArg("normal") : null;
795
800
  const c = conn(ctx);
796
801
  if (!c)
797
802
  return noConn(ctx);
798
- const { verbose } = decodeSuffix(cmdName, 'dAp');
803
+ const { verbose } = decodeSuffix(cmdName, "dAp");
799
804
  // `\dApx[+]` — expanded toggle, same convention as `\df`/`\z`.
800
- const forceExpanded = cmdName.slice(3).includes('x');
805
+ const forceExpanded = cmdName.slice(3).includes("x");
801
806
  const savedPopt = ctx.settings.popt;
802
807
  if (forceExpanded) {
803
808
  ctx.settings.popt = {
804
809
  ...savedPopt,
805
- topt: { ...savedPopt.topt, expanded: 'on' },
810
+ topt: { ...savedPopt.topt, expanded: "on" },
806
811
  };
807
812
  }
808
813
  try {
@@ -816,26 +821,26 @@ const cmdListOpFamilyFunctions = (cmdName) => ({
816
821
  const curDb = currentDb(c);
817
822
  if (amPat !== null) {
818
823
  const r = processSQLNamePattern({
819
- namevar: 'am.amname',
824
+ namevar: "am.amname",
820
825
  pattern: amPat,
821
826
  });
822
827
  const err = validatePattern(amPat, r, 0, curDb);
823
828
  if (err !== null) {
824
829
  writeErr(`${err}\n`);
825
- return { status: 'error', errorWritten: true };
830
+ return { status: "error", errorWritten: true };
826
831
  }
827
832
  results.push(r);
828
833
  }
829
834
  if (familyPat !== null) {
830
835
  const r = processSQLNamePattern({
831
- namevar: 'of.opfname',
832
- schemavar: 'ns.nspname',
836
+ namevar: "of.opfname",
837
+ schemavar: "ns.nspname",
833
838
  pattern: familyPat,
834
839
  });
835
840
  const err = validatePattern(familyPat, r, 2, curDb);
836
841
  if (err !== null) {
837
842
  writeErr(`${err}\n`);
838
- return { status: 'error', errorWritten: true };
843
+ return { status: "error", errorWritten: true };
839
844
  }
840
845
  results.push(r);
841
846
  }
@@ -850,11 +855,11 @@ const cmdListOpFamilyFunctions = (cmdName) => ({
850
855
  const cmdDescribeTypes = (cmdName) => ({
851
856
  name: cmdName,
852
857
  run: async (ctx) => {
853
- const pattern = ctx.nextArg('normal');
858
+ const pattern = ctx.nextArg("normal");
854
859
  const c = conn(ctx);
855
860
  if (!c)
856
861
  return noConn(ctx);
857
- const { verbose, showSystem } = decodeSuffix(cmdName, 'dT');
862
+ const { verbose, showSystem } = decodeSuffix(cmdName, "dT");
858
863
  const query = describeTypes({
859
864
  pattern: pattern ?? undefined,
860
865
  verbose,
@@ -862,9 +867,9 @@ const cmdDescribeTypes = (cmdName) => ({
862
867
  serverVersion: c.serverVersion,
863
868
  });
864
869
  return runWithPattern(ctx, pattern, query, {
865
- namevar: 't.typname',
866
- schemavar: 'n.nspname',
867
- visibilityrule: 'pg_catalog.pg_type_is_visible(t.oid)',
870
+ namevar: "t.typname",
871
+ schemavar: "n.nspname",
872
+ visibilityrule: "pg_catalog.pg_type_is_visible(t.oid)",
868
873
  });
869
874
  },
870
875
  });
@@ -872,11 +877,11 @@ const cmdDescribeTypes = (cmdName) => ({
872
877
  const cmdDescribeOperators = (cmdName) => ({
873
878
  name: cmdName,
874
879
  run: async (ctx) => {
875
- const pattern = ctx.nextArg('normal');
880
+ const pattern = ctx.nextArg("normal");
876
881
  const c = conn(ctx);
877
882
  if (!c)
878
883
  return noConn(ctx);
879
- const { verbose, showSystem } = decodeSuffix(cmdName, 'do');
884
+ const { verbose, showSystem } = decodeSuffix(cmdName, "do");
880
885
  // Upstream: same arg-collection rule as `\df` (only when main
881
886
  // pattern is non-null). describeOperators caps at 2 args; we still
882
887
  // forward the user's input so the SQL builder can decide which
@@ -896,9 +901,9 @@ const cmdDescribeOperators = (cmdName) => ({
896
901
  serverVersion: c.serverVersion,
897
902
  });
898
903
  return runFunctionOrOperatorQuery(ctx, pattern, argPatternResults, query, {
899
- namevar: 'o.oprname',
900
- schemavar: 'n.nspname',
901
- visibilityrule: 'pg_catalog.pg_operator_is_visible(o.oid)',
904
+ namevar: "o.oprname",
905
+ schemavar: "n.nspname",
906
+ visibilityrule: "pg_catalog.pg_operator_is_visible(o.oid)",
902
907
  });
903
908
  },
904
909
  });
@@ -906,11 +911,11 @@ const cmdDescribeOperators = (cmdName) => ({
906
911
  const cmdDescribeRoles = (cmdName) => ({
907
912
  name: cmdName,
908
913
  run: async (ctx) => {
909
- const pattern = ctx.nextArg('normal');
914
+ const pattern = ctx.nextArg("normal");
910
915
  const c = conn(ctx);
911
916
  if (!c)
912
917
  return noConn(ctx);
913
- const base = cmdName.startsWith('du') ? 'du' : 'dg';
918
+ const base = cmdName.startsWith("du") ? "du" : "dg";
914
919
  const { verbose, showSystem } = decodeSuffix(cmdName, base);
915
920
  const query = describeRoles({
916
921
  pattern: pattern ?? undefined,
@@ -922,7 +927,7 @@ const cmdDescribeRoles = (cmdName) => ({
922
927
  // `printQuery` with `default_footer = false` (describe.c
923
928
  // `describeRoles`), so suppress the `(N rows)` counter for both
924
929
  // populated and empty results to match `psql -E \du`.
925
- return runWithPattern(ctx, pattern, query, { namevar: 'r.rolname' }, 0, {
930
+ return runWithPattern(ctx, pattern, query, { namevar: "r.rolname" }, 0, {
926
931
  suppressDefaultFooter: true,
927
932
  });
928
933
  },
@@ -934,10 +939,10 @@ const cmdDescribeRoles = (cmdName) => ({
934
939
  // stderr notice ("Did not find any settings…") when not in quiet mode,
935
940
  // mirroring upstream `describe.c::listDbRoleSettings`.
936
941
  const cmdListDbRoleSettings = {
937
- name: 'drds',
942
+ name: "drds",
938
943
  run: async (ctx) => {
939
- const rolePat = ctx.nextArg('normal');
940
- const dbPat = rolePat ? ctx.nextArg('normal') : null;
944
+ const rolePat = ctx.nextArg("normal");
945
+ const dbPat = rolePat ? ctx.nextArg("normal") : null;
941
946
  const c = conn(ctx);
942
947
  if (!c)
943
948
  return noConn(ctx);
@@ -950,27 +955,27 @@ const cmdListDbRoleSettings = {
950
955
  const curDb = currentDb(c);
951
956
  if (rolePat !== null) {
952
957
  const r = processSQLNamePattern({
953
- namevar: 'r.rolname',
958
+ namevar: "r.rolname",
954
959
  pattern: rolePat,
955
960
  });
956
961
  // Role names are flat — first dot is "too many".
957
962
  const err = validatePattern(rolePat, r, 0, curDb);
958
963
  if (err !== null) {
959
964
  writeErr(`${err}\n`);
960
- return { status: 'error', errorWritten: true };
965
+ return { status: "error", errorWritten: true };
961
966
  }
962
967
  results.push(r);
963
968
  }
964
969
  if (dbPat !== null) {
965
970
  const r = processSQLNamePattern({
966
- namevar: 'd.datname',
971
+ namevar: "d.datname",
967
972
  pattern: dbPat,
968
973
  });
969
974
  // Database names are top-level — first dot is "too many".
970
975
  const err = validatePattern(dbPat, r, 0, curDb);
971
976
  if (err !== null) {
972
977
  writeErr(`${err}\n`);
973
- return { status: 'error', errorWritten: true };
978
+ return { status: "error", errorWritten: true };
974
979
  }
975
980
  results.push(r);
976
981
  }
@@ -996,7 +1001,7 @@ const cmdListDbRoleSettings = {
996
1001
  else if (rolePat !== null) {
997
1002
  writeErr(`Did not find any settings for role "${rolePat}".\n`);
998
1003
  }
999
- return { status: 'ok' };
1004
+ return { status: "ok" };
1000
1005
  }
1001
1006
  // Re-print via the standard runner so the title and formatting
1002
1007
  // match peer list queries. We pass the already-substituted SQL
@@ -1012,11 +1017,11 @@ const cmdListDbRoleSettings = {
1012
1017
  dbLiteral: null,
1013
1018
  };
1014
1019
  await runListQuery(c, finalQuery, empty, process.stdout, ctx.settings.popt);
1015
- return { status: 'ok' };
1020
+ return { status: "ok" };
1016
1021
  }
1017
1022
  catch (err) {
1018
1023
  writeErr(`\\${ctx.cmdName}: ${errMsg(err)}\n`);
1019
- return { status: 'error', errorWritten: true };
1024
+ return { status: "error", errorWritten: true };
1020
1025
  }
1021
1026
  },
1022
1027
  };
@@ -1024,11 +1029,11 @@ const cmdListDbRoleSettings = {
1024
1029
  const cmdListSchemas = (cmdName) => ({
1025
1030
  name: cmdName,
1026
1031
  run: async (ctx) => {
1027
- const pattern = ctx.nextArg('normal');
1032
+ const pattern = ctx.nextArg("normal");
1028
1033
  const c = conn(ctx);
1029
1034
  if (!c)
1030
1035
  return noConn(ctx);
1031
- const { verbose, showSystem } = decodeSuffix(cmdName, 'dn');
1036
+ const { verbose, showSystem } = decodeSuffix(cmdName, "dn");
1032
1037
  const query = listSchemas({
1033
1038
  pattern: pattern ?? undefined,
1034
1039
  verbose,
@@ -1038,7 +1043,7 @@ const cmdListSchemas = (cmdName) => ({
1038
1043
  // Schemas live in a single namespace; the optional qualifier slot
1039
1044
  // is interpreted as a database name (cross-database check fires on
1040
1045
  // mismatch). `maxDots = 1`.
1041
- return runWithPattern(ctx, pattern, query, { namevar: 'n.nspname' }, 1);
1046
+ return runWithPattern(ctx, pattern, query, { namevar: "n.nspname" }, 1);
1042
1047
  },
1043
1048
  });
1044
1049
  // ---- \db / \db+ ---------------------------------------------------------
@@ -1047,29 +1052,29 @@ const cmdListSchemas = (cmdName) => ({
1047
1052
  const cmdDescribeTablespaces = (cmdName) => ({
1048
1053
  name: cmdName,
1049
1054
  run: async (ctx) => {
1050
- const pattern = ctx.nextArg('normal');
1055
+ const pattern = ctx.nextArg("normal");
1051
1056
  const c = conn(ctx);
1052
1057
  if (!c)
1053
1058
  return noConn(ctx);
1054
- const { verbose } = decodeSuffix(cmdName, 'db');
1059
+ const { verbose } = decodeSuffix(cmdName, "db");
1055
1060
  const query = describeTablespaces({
1056
1061
  pattern: pattern ?? undefined,
1057
1062
  verbose,
1058
1063
  serverVersion: c.serverVersion,
1059
1064
  });
1060
1065
  // Tablespaces are flat — first dot is "too many".
1061
- return runWithPattern(ctx, pattern, query, { namevar: 'spcname' }, 0);
1066
+ return runWithPattern(ctx, pattern, query, { namevar: "spcname" }, 0);
1062
1067
  },
1063
1068
  });
1064
1069
  // ---- \dD / \dDS / \dD+ -------------------------------------------------
1065
1070
  const cmdListDomains = (cmdName) => ({
1066
1071
  name: cmdName,
1067
1072
  run: async (ctx) => {
1068
- const pattern = ctx.nextArg('normal');
1073
+ const pattern = ctx.nextArg("normal");
1069
1074
  const c = conn(ctx);
1070
1075
  if (!c)
1071
1076
  return noConn(ctx);
1072
- const { verbose, showSystem } = decodeSuffix(cmdName, 'dD');
1077
+ const { verbose, showSystem } = decodeSuffix(cmdName, "dD");
1073
1078
  const query = listDomains({
1074
1079
  pattern: pattern ?? undefined,
1075
1080
  verbose,
@@ -1077,9 +1082,9 @@ const cmdListDomains = (cmdName) => ({
1077
1082
  serverVersion: c.serverVersion,
1078
1083
  });
1079
1084
  return runWithPattern(ctx, pattern, query, {
1080
- namevar: 't.typname',
1081
- schemavar: 'n.nspname',
1082
- visibilityrule: 'pg_catalog.pg_type_is_visible(t.oid)',
1085
+ namevar: "t.typname",
1086
+ schemavar: "n.nspname",
1087
+ visibilityrule: "pg_catalog.pg_type_is_visible(t.oid)",
1083
1088
  });
1084
1089
  },
1085
1090
  });
@@ -1087,11 +1092,11 @@ const cmdListDomains = (cmdName) => ({
1087
1092
  const cmdListConversions = (cmdName) => ({
1088
1093
  name: cmdName,
1089
1094
  run: async (ctx) => {
1090
- const pattern = ctx.nextArg('normal');
1095
+ const pattern = ctx.nextArg("normal");
1091
1096
  const c = conn(ctx);
1092
1097
  if (!c)
1093
1098
  return noConn(ctx);
1094
- const { verbose, showSystem } = decodeSuffix(cmdName, 'dc');
1099
+ const { verbose, showSystem } = decodeSuffix(cmdName, "dc");
1095
1100
  const query = listConversions({
1096
1101
  pattern: pattern ?? undefined,
1097
1102
  verbose,
@@ -1099,9 +1104,9 @@ const cmdListConversions = (cmdName) => ({
1099
1104
  serverVersion: c.serverVersion,
1100
1105
  });
1101
1106
  return runWithPattern(ctx, pattern, query, {
1102
- namevar: 'c.conname',
1103
- schemavar: 'n.nspname',
1104
- visibilityrule: 'pg_catalog.pg_conversion_is_visible(c.oid)',
1107
+ namevar: "c.conname",
1108
+ schemavar: "n.nspname",
1109
+ visibilityrule: "pg_catalog.pg_conversion_is_visible(c.oid)",
1105
1110
  });
1106
1111
  },
1107
1112
  });
@@ -1109,19 +1114,19 @@ const cmdListConversions = (cmdName) => ({
1109
1114
  const cmdListCasts = (cmdName) => ({
1110
1115
  name: cmdName,
1111
1116
  run: async (ctx) => {
1112
- const pattern = ctx.nextArg('normal');
1117
+ const pattern = ctx.nextArg("normal");
1113
1118
  const c = conn(ctx);
1114
1119
  if (!c)
1115
1120
  return noConn(ctx);
1116
- const { verbose } = decodeSuffix(cmdName, 'dC');
1121
+ const { verbose } = decodeSuffix(cmdName, "dC");
1117
1122
  const query = listCasts({
1118
1123
  pattern: pattern ?? undefined,
1119
1124
  verbose,
1120
1125
  serverVersion: c.serverVersion,
1121
1126
  });
1122
1127
  return runWithPattern(ctx, pattern, query, {
1123
- namevar: 'ts.typname',
1124
- schemavar: 'ns.nspname',
1128
+ namevar: "ts.typname",
1129
+ schemavar: "ns.nspname",
1125
1130
  });
1126
1131
  },
1127
1132
  });
@@ -1129,11 +1134,11 @@ const cmdListCasts = (cmdName) => ({
1129
1134
  const cmdListLanguages = (cmdName) => ({
1130
1135
  name: cmdName,
1131
1136
  run: async (ctx) => {
1132
- const pattern = ctx.nextArg('normal');
1137
+ const pattern = ctx.nextArg("normal");
1133
1138
  const c = conn(ctx);
1134
1139
  if (!c)
1135
1140
  return noConn(ctx);
1136
- const { verbose, showSystem } = decodeSuffix(cmdName, 'dL');
1141
+ const { verbose, showSystem } = decodeSuffix(cmdName, "dL");
1137
1142
  const query = listLanguages({
1138
1143
  pattern: pattern ?? undefined,
1139
1144
  verbose,
@@ -1141,18 +1146,18 @@ const cmdListLanguages = (cmdName) => ({
1141
1146
  serverVersion: c.serverVersion,
1142
1147
  });
1143
1148
  // Languages are global; first dot is a database qualifier (cross-db).
1144
- return runWithPattern(ctx, pattern, query, { namevar: 'l.lanname' }, 1);
1149
+ return runWithPattern(ctx, pattern, query, { namevar: "l.lanname" }, 1);
1145
1150
  },
1146
1151
  });
1147
1152
  // ---- \dO / \dO+ / \dOS -------------------------------------------------
1148
1153
  const cmdListCollations = (cmdName) => ({
1149
1154
  name: cmdName,
1150
1155
  run: async (ctx) => {
1151
- const pattern = ctx.nextArg('normal');
1156
+ const pattern = ctx.nextArg("normal");
1152
1157
  const c = conn(ctx);
1153
1158
  if (!c)
1154
1159
  return noConn(ctx);
1155
- const { verbose, showSystem } = decodeSuffix(cmdName, 'dO');
1160
+ const { verbose, showSystem } = decodeSuffix(cmdName, "dO");
1156
1161
  const query = listCollations({
1157
1162
  pattern: pattern ?? undefined,
1158
1163
  verbose,
@@ -1160,9 +1165,9 @@ const cmdListCollations = (cmdName) => ({
1160
1165
  serverVersion: c.serverVersion,
1161
1166
  });
1162
1167
  return runWithPattern(ctx, pattern, query, {
1163
- namevar: 'c.collname',
1164
- schemavar: 'n.nspname',
1165
- visibilityrule: 'pg_catalog.pg_collation_is_visible(c.oid)',
1168
+ namevar: "c.collname",
1169
+ schemavar: "n.nspname",
1170
+ visibilityrule: "pg_catalog.pg_collation_is_visible(c.oid)",
1166
1171
  });
1167
1172
  },
1168
1173
  });
@@ -1170,20 +1175,20 @@ const cmdListCollations = (cmdName) => ({
1170
1175
  const cmdPermissionsList = (cmdName) => ({
1171
1176
  name: cmdName,
1172
1177
  run: async (ctx) => {
1173
- const pattern = ctx.nextArg('normal');
1178
+ const pattern = ctx.nextArg("normal");
1174
1179
  const c = conn(ctx);
1175
1180
  if (!c)
1176
1181
  return noConn(ctx);
1177
- const base = cmdName.startsWith('z') ? 'z' : 'dp';
1182
+ const base = cmdName.startsWith("z") ? "z" : "dp";
1178
1183
  const { showSystem } = decodeSuffix(cmdName, base);
1179
1184
  // `\z[x]`, `\dp[x]` — same expanded-mode toggle convention as `\df`,
1180
1185
  // applied whether or not a pattern is present.
1181
- const forceExpanded = cmdName.slice(base.length).includes('x');
1186
+ const forceExpanded = cmdName.slice(base.length).includes("x");
1182
1187
  const savedPopt = ctx.settings.popt;
1183
1188
  if (forceExpanded) {
1184
1189
  ctx.settings.popt = {
1185
1190
  ...savedPopt,
1186
- topt: { ...savedPopt.topt, expanded: 'on' },
1191
+ topt: { ...savedPopt.topt, expanded: "on" },
1187
1192
  };
1188
1193
  }
1189
1194
  try {
@@ -1193,9 +1198,9 @@ const cmdPermissionsList = (cmdName) => ({
1193
1198
  serverVersion: c.serverVersion,
1194
1199
  });
1195
1200
  return await runWithPattern(ctx, pattern, query, {
1196
- namevar: 'c.relname',
1197
- schemavar: 'n.nspname',
1198
- visibilityrule: 'pg_catalog.pg_table_is_visible(c.oid)',
1201
+ namevar: "c.relname",
1202
+ schemavar: "n.nspname",
1203
+ visibilityrule: "pg_catalog.pg_table_is_visible(c.oid)",
1199
1204
  });
1200
1205
  }
1201
1206
  finally {
@@ -1205,9 +1210,9 @@ const cmdPermissionsList = (cmdName) => ({
1205
1210
  });
1206
1211
  // ---- \ddp --------------------------------------------------------------
1207
1212
  const cmdListDefaultACLs = {
1208
- name: 'ddp',
1213
+ name: "ddp",
1209
1214
  run: async (ctx) => {
1210
- const pattern = ctx.nextArg('normal');
1215
+ const pattern = ctx.nextArg("normal");
1211
1216
  const c = conn(ctx);
1212
1217
  if (!c)
1213
1218
  return noConn(ctx);
@@ -1216,76 +1221,76 @@ const cmdListDefaultACLs = {
1216
1221
  serverVersion: c.serverVersion,
1217
1222
  });
1218
1223
  return runWithPattern(ctx, pattern, query, {
1219
- namevar: 'pg_catalog.pg_get_userbyid(d.defaclrole)',
1220
- schemavar: 'n.nspname',
1224
+ namevar: "pg_catalog.pg_get_userbyid(d.defaclrole)",
1225
+ schemavar: "n.nspname",
1221
1226
  });
1222
1227
  },
1223
1228
  };
1224
1229
  // ---- \dd ---------------------------------------------------------------
1225
1230
  const cmdObjectDescription = {
1226
- name: 'dd',
1231
+ name: "dd",
1227
1232
  run: async (ctx) => {
1228
- const pattern = ctx.nextArg('normal');
1233
+ const pattern = ctx.nextArg("normal");
1229
1234
  const c = conn(ctx);
1230
1235
  if (!c)
1231
1236
  return noConn(ctx);
1232
- const { showSystem } = decodeSuffix(ctx.cmdName, 'dd');
1237
+ const { showSystem } = decodeSuffix(ctx.cmdName, "dd");
1233
1238
  const query = objectDescription({
1234
1239
  pattern: pattern ?? undefined,
1235
1240
  showSystem,
1236
1241
  serverVersion: c.serverVersion,
1237
1242
  });
1238
1243
  return runWithPattern(ctx, pattern, query, {
1239
- namevar: 'tt.name',
1240
- schemavar: 'tt.nspname',
1244
+ namevar: "tt.name",
1245
+ schemavar: "tt.nspname",
1241
1246
  });
1242
1247
  },
1243
1248
  };
1244
1249
  // ---- \l / \list -------------------------------------------------------
1245
1250
  const cmdListAllDbs = {
1246
- name: 'l',
1247
- aliases: ['list'],
1251
+ name: "l",
1252
+ aliases: ["list"],
1248
1253
  run: async (ctx) => {
1249
- const pattern = ctx.nextArg('normal');
1254
+ const pattern = ctx.nextArg("normal");
1250
1255
  const c = conn(ctx);
1251
1256
  if (!c)
1252
1257
  return noConn(ctx);
1253
- const { verbose } = decodeSuffix(ctx.cmdName, 'l');
1258
+ const { verbose } = decodeSuffix(ctx.cmdName, "l");
1254
1259
  const query = listAllDbs({
1255
1260
  pattern: pattern ?? undefined,
1256
1261
  verbose,
1257
1262
  serverVersion: c.serverVersion,
1258
1263
  });
1259
- return runWithPattern(ctx, pattern, query, { namevar: 'd.datname' });
1264
+ return runWithPattern(ctx, pattern, query, { namevar: "d.datname" });
1260
1265
  },
1261
1266
  };
1262
1267
  // ---- \dconfig ----------------------------------------------------------
1263
1268
  const cmdDescribeConfigParams = {
1264
- name: 'dconfig',
1269
+ name: "dconfig",
1265
1270
  run: async (ctx) => {
1266
- const pattern = ctx.nextArg('normal');
1271
+ const pattern = ctx.nextArg("normal");
1267
1272
  const c = conn(ctx);
1268
1273
  if (!c)
1269
1274
  return noConn(ctx);
1270
- const { verbose } = decodeSuffix(ctx.cmdName, 'dconfig');
1275
+ const { verbose } = decodeSuffix(ctx.cmdName, "dconfig");
1271
1276
  const query = describeConfigurationParameters({
1272
1277
  pattern: pattern ?? undefined,
1273
1278
  verbose,
1274
1279
  serverVersion: c.serverVersion,
1275
1280
  });
1276
1281
  // GUC names are flat — any dot is "too many".
1277
- return runWithPattern(ctx, pattern, query, { namevar: 'pg_catalog.lower(s.name)' }, 0);
1282
+ return runWithPattern(ctx, pattern, query, { namevar: "pg_catalog.lower(s.name)" }, 0);
1278
1283
  },
1279
1284
  };
1280
1285
  // ---- \dy ---------------------------------------------------------------
1281
1286
  const cmdListEventTriggers = {
1282
- name: 'dy',
1287
+ name: "dy",
1283
1288
  run: async (ctx) => {
1284
- const pattern = ctx.nextArg('normal');
1289
+ const pattern = ctx.nextArg("normal");
1285
1290
  const c = conn(ctx);
1286
1291
  if (!c)
1287
1292
  return noConn(ctx);
1288
- const { verbose } = decodeSuffix(ctx.cmdName, 'dy');
1293
+ const { verbose } = decodeSuffix(ctx.cmdName, "dy");
1289
1294
  const query = listEventTriggers({
1290
1295
  pattern: pattern ?? undefined,
1291
1296
  verbose,
@@ -1294,14 +1299,14 @@ const cmdListEventTriggers = {
1294
1299
  // Event triggers are global with no schema or database qualifier
1295
1300
  // (upstream `validateSQLNamePattern(..., NULL, 1)`): any dot in
1296
1301
  // the pattern is "too many".
1297
- return runWithPattern(ctx, pattern, query, { namevar: 'evtname' }, 0);
1302
+ return runWithPattern(ctx, pattern, query, { namevar: "evtname" }, 0);
1298
1303
  },
1299
1304
  };
1300
1305
  // ---- \dx / \dx+ -------------------------------------------------------
1301
1306
  const cmdListExtensions = {
1302
- name: 'dx',
1307
+ name: "dx",
1303
1308
  run: async (ctx) => {
1304
- const pattern = ctx.nextArg('normal');
1309
+ const pattern = ctx.nextArg("normal");
1305
1310
  const c = conn(ctx);
1306
1311
  if (!c)
1307
1312
  return noConn(ctx);
@@ -1312,111 +1317,111 @@ const cmdListExtensions = {
1312
1317
  // Extensions are global with no schema or database qualifier
1313
1318
  // (upstream `validateSQLNamePattern(..., NULL, 1)`): any dot is
1314
1319
  // "too many".
1315
- return runWithPattern(ctx, pattern, query, { namevar: 'e.extname' }, 0);
1320
+ return runWithPattern(ctx, pattern, query, { namevar: "e.extname" }, 0);
1316
1321
  },
1317
1322
  };
1318
1323
  // ---- \dl / \lo_list ---------------------------------------------------
1319
1324
  const cmdListLargeObjects = {
1320
- name: 'dl',
1321
- aliases: ['lo_list'],
1325
+ name: "dl",
1326
+ aliases: ["lo_list"],
1322
1327
  run: async (ctx) => {
1323
1328
  const c = conn(ctx);
1324
1329
  if (!c)
1325
1330
  return noConn(ctx);
1326
- const { verbose } = decodeSuffix(ctx.cmdName, 'dl');
1331
+ const { verbose } = decodeSuffix(ctx.cmdName, "dl");
1327
1332
  const query = listLargeObjects({
1328
1333
  verbose,
1329
1334
  serverVersion: c.serverVersion,
1330
1335
  });
1331
- return runWithPattern(ctx, null, query, { namevar: 'oid' });
1336
+ return runWithPattern(ctx, null, query, { namevar: "oid" });
1332
1337
  },
1333
1338
  };
1334
1339
  // ---- \dF / \dFp / \dFd / \dFt ----------------------------------------
1335
1340
  const cmdListTSConfigs = {
1336
- name: 'dF',
1341
+ name: "dF",
1337
1342
  run: async (ctx) => {
1338
- const pattern = ctx.nextArg('normal');
1343
+ const pattern = ctx.nextArg("normal");
1339
1344
  const c = conn(ctx);
1340
1345
  if (!c)
1341
1346
  return noConn(ctx);
1342
- const { verbose } = decodeSuffix(ctx.cmdName, 'dF');
1347
+ const { verbose } = decodeSuffix(ctx.cmdName, "dF");
1343
1348
  const query = listTSConfigs({
1344
1349
  pattern: pattern ?? undefined,
1345
1350
  verbose,
1346
1351
  serverVersion: c.serverVersion,
1347
1352
  });
1348
1353
  return runWithPattern(ctx, pattern, query, {
1349
- namevar: 'c.cfgname',
1350
- schemavar: 'n.nspname',
1354
+ namevar: "c.cfgname",
1355
+ schemavar: "n.nspname",
1351
1356
  });
1352
1357
  },
1353
1358
  };
1354
1359
  const cmdListTSParsers = {
1355
- name: 'dFp',
1360
+ name: "dFp",
1356
1361
  run: async (ctx) => {
1357
- const pattern = ctx.nextArg('normal');
1362
+ const pattern = ctx.nextArg("normal");
1358
1363
  const c = conn(ctx);
1359
1364
  if (!c)
1360
1365
  return noConn(ctx);
1361
- const { verbose } = decodeSuffix(ctx.cmdName, 'dFp');
1366
+ const { verbose } = decodeSuffix(ctx.cmdName, "dFp");
1362
1367
  const query = listTSParsers({
1363
1368
  pattern: pattern ?? undefined,
1364
1369
  verbose,
1365
1370
  serverVersion: c.serverVersion,
1366
1371
  });
1367
1372
  return runWithPattern(ctx, pattern, query, {
1368
- namevar: 'p.prsname',
1369
- schemavar: 'n.nspname',
1373
+ namevar: "p.prsname",
1374
+ schemavar: "n.nspname",
1370
1375
  });
1371
1376
  },
1372
1377
  };
1373
1378
  const cmdListTSDictionaries = {
1374
- name: 'dFd',
1379
+ name: "dFd",
1375
1380
  run: async (ctx) => {
1376
- const pattern = ctx.nextArg('normal');
1381
+ const pattern = ctx.nextArg("normal");
1377
1382
  const c = conn(ctx);
1378
1383
  if (!c)
1379
1384
  return noConn(ctx);
1380
- const { verbose } = decodeSuffix(ctx.cmdName, 'dFd');
1385
+ const { verbose } = decodeSuffix(ctx.cmdName, "dFd");
1381
1386
  const query = listTSDictionaries({
1382
1387
  pattern: pattern ?? undefined,
1383
1388
  verbose,
1384
1389
  serverVersion: c.serverVersion,
1385
1390
  });
1386
1391
  return runWithPattern(ctx, pattern, query, {
1387
- namevar: 'd.dictname',
1388
- schemavar: 'n.nspname',
1392
+ namevar: "d.dictname",
1393
+ schemavar: "n.nspname",
1389
1394
  });
1390
1395
  },
1391
1396
  };
1392
1397
  const cmdListTSTemplates = {
1393
- name: 'dFt',
1398
+ name: "dFt",
1394
1399
  run: async (ctx) => {
1395
- const pattern = ctx.nextArg('normal');
1400
+ const pattern = ctx.nextArg("normal");
1396
1401
  const c = conn(ctx);
1397
1402
  if (!c)
1398
1403
  return noConn(ctx);
1399
- const { verbose } = decodeSuffix(ctx.cmdName, 'dFt');
1404
+ const { verbose } = decodeSuffix(ctx.cmdName, "dFt");
1400
1405
  const query = listTSTemplates({
1401
1406
  pattern: pattern ?? undefined,
1402
1407
  verbose,
1403
1408
  serverVersion: c.serverVersion,
1404
1409
  });
1405
1410
  return runWithPattern(ctx, pattern, query, {
1406
- namevar: 't.tmplname',
1407
- schemavar: 'n.nspname',
1411
+ namevar: "t.tmplname",
1412
+ schemavar: "n.nspname",
1408
1413
  });
1409
1414
  },
1410
1415
  };
1411
1416
  // ---- \dew / \des / \deu / \det ---------------------------------------
1412
1417
  const cmdListForeignDataWrappers = {
1413
- name: 'dew',
1418
+ name: "dew",
1414
1419
  run: async (ctx) => {
1415
- const pattern = ctx.nextArg('normal');
1420
+ const pattern = ctx.nextArg("normal");
1416
1421
  const c = conn(ctx);
1417
1422
  if (!c)
1418
1423
  return noConn(ctx);
1419
- const { verbose } = decodeSuffix(ctx.cmdName, 'dew');
1424
+ const { verbose } = decodeSuffix(ctx.cmdName, "dew");
1420
1425
  const query = listForeignDataWrappers({
1421
1426
  pattern: pattern ?? undefined,
1422
1427
  verbose,
@@ -1424,17 +1429,17 @@ const cmdListForeignDataWrappers = {
1424
1429
  });
1425
1430
  // FDWs are global with no schema or database qualifier (upstream
1426
1431
  // `validateSQLNamePattern(..., NULL, 1)`): any dot is "too many".
1427
- return runWithPattern(ctx, pattern, query, { namevar: 'fdwname' }, 0);
1432
+ return runWithPattern(ctx, pattern, query, { namevar: "fdwname" }, 0);
1428
1433
  },
1429
1434
  };
1430
1435
  const cmdListForeignServers = {
1431
- name: 'des',
1436
+ name: "des",
1432
1437
  run: async (ctx) => {
1433
- const pattern = ctx.nextArg('normal');
1438
+ const pattern = ctx.nextArg("normal");
1434
1439
  const c = conn(ctx);
1435
1440
  if (!c)
1436
1441
  return noConn(ctx);
1437
- const { verbose } = decodeSuffix(ctx.cmdName, 'des');
1442
+ const { verbose } = decodeSuffix(ctx.cmdName, "des");
1438
1443
  const query = listForeignServers({
1439
1444
  pattern: pattern ?? undefined,
1440
1445
  verbose,
@@ -1443,17 +1448,17 @@ const cmdListForeignServers = {
1443
1448
  // Foreign servers are global with no schema or database qualifier
1444
1449
  // (upstream `validateSQLNamePattern(..., NULL, 1)`): any dot is
1445
1450
  // "too many".
1446
- return runWithPattern(ctx, pattern, query, { namevar: 's.srvname' }, 0);
1451
+ return runWithPattern(ctx, pattern, query, { namevar: "s.srvname" }, 0);
1447
1452
  },
1448
1453
  };
1449
1454
  const cmdListUserMappings = {
1450
- name: 'deu',
1455
+ name: "deu",
1451
1456
  run: async (ctx) => {
1452
- const pattern = ctx.nextArg('normal');
1457
+ const pattern = ctx.nextArg("normal");
1453
1458
  const c = conn(ctx);
1454
1459
  if (!c)
1455
1460
  return noConn(ctx);
1456
- const { verbose } = decodeSuffix(ctx.cmdName, 'deu');
1461
+ const { verbose } = decodeSuffix(ctx.cmdName, "deu");
1457
1462
  const query = listUserMappings({
1458
1463
  pattern: pattern ?? undefined,
1459
1464
  verbose,
@@ -1461,44 +1466,44 @@ const cmdListUserMappings = {
1461
1466
  });
1462
1467
  // User mappings live alongside foreign servers (global, no schema
1463
1468
  // or db qualifier per upstream `validateSQLNamePattern(..., 1)`).
1464
- return runWithPattern(ctx, pattern, query, { namevar: 'um.srvname' }, 0);
1469
+ return runWithPattern(ctx, pattern, query, { namevar: "um.srvname" }, 0);
1465
1470
  },
1466
1471
  };
1467
1472
  const cmdListForeignTables = {
1468
- name: 'det',
1473
+ name: "det",
1469
1474
  run: async (ctx) => {
1470
- const pattern = ctx.nextArg('normal');
1475
+ const pattern = ctx.nextArg("normal");
1471
1476
  const c = conn(ctx);
1472
1477
  if (!c)
1473
1478
  return noConn(ctx);
1474
- const { verbose } = decodeSuffix(ctx.cmdName, 'det');
1479
+ const { verbose } = decodeSuffix(ctx.cmdName, "det");
1475
1480
  const query = listForeignTables({
1476
1481
  pattern: pattern ?? undefined,
1477
1482
  verbose,
1478
1483
  serverVersion: c.serverVersion,
1479
1484
  });
1480
1485
  return runWithPattern(ctx, pattern, query, {
1481
- namevar: 'c.relname',
1482
- schemavar: 'n.nspname',
1486
+ namevar: "c.relname",
1487
+ schemavar: "n.nspname",
1483
1488
  });
1484
1489
  },
1485
1490
  };
1486
1491
  // ---- \dP / \dPi / \dPt / \dPn -----------------------------------------
1487
1492
  const cmdListPartitionedTables = {
1488
- name: 'dP',
1493
+ name: "dP",
1489
1494
  run: async (ctx) => {
1490
- const pattern = ctx.nextArg('normal');
1495
+ const pattern = ctx.nextArg("normal");
1491
1496
  const c = conn(ctx);
1492
1497
  if (!c)
1493
1498
  return noConn(ctx);
1494
- const { verbose } = decodeSuffix(ctx.cmdName, 'dP');
1495
- let reltypes = '';
1496
- if (ctx.cmdName.includes('i'))
1497
- reltypes += 'i';
1498
- if (ctx.cmdName.includes('t'))
1499
- reltypes += 't';
1500
- if (ctx.cmdName.includes('n'))
1501
- reltypes += 'n';
1499
+ const { verbose } = decodeSuffix(ctx.cmdName, "dP");
1500
+ let reltypes = "";
1501
+ if (ctx.cmdName.includes("i"))
1502
+ reltypes += "i";
1503
+ if (ctx.cmdName.includes("t"))
1504
+ reltypes += "t";
1505
+ if (ctx.cmdName.includes("n"))
1506
+ reltypes += "n";
1502
1507
  const query = listPartitionedTables({
1503
1508
  pattern: pattern ?? undefined,
1504
1509
  verbose,
@@ -1506,8 +1511,8 @@ const cmdListPartitionedTables = {
1506
1511
  serverVersion: c.serverVersion,
1507
1512
  });
1508
1513
  return runWithPattern(ctx, pattern, query, {
1509
- namevar: 'c.relname',
1510
- schemavar: 'n.nspname',
1514
+ namevar: "c.relname",
1515
+ schemavar: "n.nspname",
1511
1516
  });
1512
1517
  },
1513
1518
  };
@@ -1518,19 +1523,19 @@ const cmdListPartitionedTables = {
1518
1523
  const cmdListExtendedStats = (cmdName) => ({
1519
1524
  name: cmdName,
1520
1525
  run: async (ctx) => {
1521
- const pattern = ctx.nextArg('normal');
1526
+ const pattern = ctx.nextArg("normal");
1522
1527
  const c = conn(ctx);
1523
1528
  if (!c)
1524
1529
  return noConn(ctx);
1525
- const { verbose } = decodeSuffix(cmdName, 'dX');
1530
+ const { verbose } = decodeSuffix(cmdName, "dX");
1526
1531
  const query = listExtendedStats({
1527
1532
  pattern: pattern ?? undefined,
1528
1533
  verbose,
1529
1534
  serverVersion: c.serverVersion,
1530
1535
  });
1531
1536
  return runWithPattern(ctx, pattern, query, {
1532
- namevar: 'es.stxname',
1533
- schemavar: 'es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text',
1537
+ namevar: "es.stxname",
1538
+ schemavar: "es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text",
1534
1539
  });
1535
1540
  },
1536
1541
  });
@@ -1542,24 +1547,24 @@ const cmdListExtendedStats = (cmdName) => ({
1542
1547
  const cmdDescribeRoleGrants = (cmdName) => ({
1543
1548
  name: cmdName,
1544
1549
  run: async (ctx) => {
1545
- const pattern = ctx.nextArg('normal');
1550
+ const pattern = ctx.nextArg("normal");
1546
1551
  const c = conn(ctx);
1547
1552
  if (!c)
1548
1553
  return noConn(ctx);
1549
- const { showSystem } = decodeSuffix(cmdName, 'drg');
1554
+ const { showSystem } = decodeSuffix(cmdName, "drg");
1550
1555
  const query = describeRoleGrants({
1551
1556
  pattern: pattern ?? undefined,
1552
1557
  showSystem,
1553
1558
  serverVersion: c.serverVersion,
1554
1559
  });
1555
- return runWithPattern(ctx, pattern, query, { namevar: 'm.rolname' }, 0);
1560
+ return runWithPattern(ctx, pattern, query, { namevar: "m.rolname" }, 0);
1556
1561
  },
1557
1562
  });
1558
1563
  // ---- \dRp / \dRs ------------------------------------------------------
1559
1564
  const cmdListPublications = {
1560
- name: 'dRp',
1565
+ name: "dRp",
1561
1566
  run: async (ctx) => {
1562
- const pattern = ctx.nextArg('normal');
1567
+ const pattern = ctx.nextArg("normal");
1563
1568
  const c = conn(ctx);
1564
1569
  if (!c)
1565
1570
  return noConn(ctx);
@@ -1570,17 +1575,17 @@ const cmdListPublications = {
1570
1575
  // Publications are global with no schema or database qualifier
1571
1576
  // (upstream `validateSQLNamePattern(..., NULL, 1)`): any dot is
1572
1577
  // "too many".
1573
- return runWithPattern(ctx, pattern, query, { namevar: 'pubname' }, 0);
1578
+ return runWithPattern(ctx, pattern, query, { namevar: "pubname" }, 0);
1574
1579
  },
1575
1580
  };
1576
1581
  const cmdDescribeSubscriptions = {
1577
- name: 'dRs',
1582
+ name: "dRs",
1578
1583
  run: async (ctx) => {
1579
- const pattern = ctx.nextArg('normal');
1584
+ const pattern = ctx.nextArg("normal");
1580
1585
  const c = conn(ctx);
1581
1586
  if (!c)
1582
1587
  return noConn(ctx);
1583
- const { verbose } = decodeSuffix(ctx.cmdName, 'dRs');
1588
+ const { verbose } = decodeSuffix(ctx.cmdName, "dRs");
1584
1589
  const query = describeSubscriptions({
1585
1590
  pattern: pattern ?? undefined,
1586
1591
  verbose,
@@ -1589,7 +1594,7 @@ const cmdDescribeSubscriptions = {
1589
1594
  // Subscriptions are global with no schema or database qualifier
1590
1595
  // (upstream `validateSQLNamePattern(..., NULL, 1)`): any dot is
1591
1596
  // "too many".
1592
- return runWithPattern(ctx, pattern, query, { namevar: 'subname' }, 0);
1597
+ return runWithPattern(ctx, pattern, query, { namevar: "subname" }, 0);
1593
1598
  },
1594
1599
  };
1595
1600
  // ===========================================================================
@@ -1618,7 +1623,7 @@ export const registerDescribeCommands = (registry) => {
1618
1623
  // register only for the bare `\d` base — upstream only honours it for
1619
1624
  // `\d` itself, not for typed variants like `\dt` or `\dv`.
1620
1625
  for (const suffix of DESCRIBE_X_SUFFIXES) {
1621
- registry.register({ ...makeDescribeCmd('d'), name: 'd' + suffix });
1626
+ registry.register({ ...makeDescribeCmd("d"), name: "d" + suffix });
1622
1627
  }
1623
1628
  // Functions. Beyond the standard `\df[+S]` matrix, upstream accepts
1624
1629
  // function-kind filter letters (a / n / p / t / w) and an expanded-mode
@@ -1627,107 +1632,107 @@ export const registerDescribeCommands = (registry) => {
1627
1632
  // letter sequences (`\dfax+`, `\dfxw`, …) are handled by the runtime
1628
1633
  // suffix walk in `cmdDescribeFunctions`.
1629
1634
  const dfTails = [
1630
- '',
1631
- '+',
1632
- 'S',
1633
- 'S+',
1634
- '+S',
1635
- 'a',
1636
- 'n',
1637
- 'p',
1638
- 't',
1639
- 'w',
1640
- 'x',
1641
- 'ax',
1642
- 'nx',
1643
- 'px',
1644
- 'tx',
1645
- 'wx',
1646
- 'xa',
1647
- 'xn',
1648
- 'xp',
1649
- 'xt',
1650
- 'xw',
1651
- 'a+',
1652
- 'n+',
1653
- 'p+',
1654
- 't+',
1655
- 'w+',
1656
- 'x+',
1657
- 'a+x',
1658
- 'x+a',
1635
+ "",
1636
+ "+",
1637
+ "S",
1638
+ "S+",
1639
+ "+S",
1640
+ "a",
1641
+ "n",
1642
+ "p",
1643
+ "t",
1644
+ "w",
1645
+ "x",
1646
+ "ax",
1647
+ "nx",
1648
+ "px",
1649
+ "tx",
1650
+ "wx",
1651
+ "xa",
1652
+ "xn",
1653
+ "xp",
1654
+ "xt",
1655
+ "xw",
1656
+ "a+",
1657
+ "n+",
1658
+ "p+",
1659
+ "t+",
1660
+ "w+",
1661
+ "x+",
1662
+ "a+x",
1663
+ "x+a",
1659
1664
  ];
1660
1665
  for (const tail of dfTails) {
1661
- registry.register(cmdDescribeFunctions('df' + tail));
1666
+ registry.register(cmdDescribeFunctions("df" + tail));
1662
1667
  }
1663
1668
  // Aggregates.
1664
- for (const suffix of ['', 'S']) {
1665
- registry.register(cmdDescribeAggregates('da' + suffix));
1669
+ for (const suffix of ["", "S"]) {
1670
+ registry.register(cmdDescribeAggregates("da" + suffix));
1666
1671
  }
1667
1672
  // Access methods. `\dA[+]` is upstream; `\dAm[+]` is a Neon-friendly
1668
1673
  // alias that some docs reach for. `\dAc[+]`, `\dAf[+]`, `\dAo[+]`,
1669
1674
  // `\dAp[+]` cover the operator-class / family / family-operator /
1670
1675
  // family-function families upstream's `command.c::exec_command_d`
1671
1676
  // dispatches.
1672
- for (const suffix of ['', '+']) {
1673
- registry.register(cmdDescribeAccessMethods('dA' + suffix));
1674
- registry.register(cmdDescribeAccessMethods('dAm' + suffix));
1675
- registry.register(cmdListOperatorClasses('dAc' + suffix));
1676
- registry.register(cmdListOperatorFamilies('dAf' + suffix));
1677
- registry.register(cmdListOpFamilyOperators('dAo' + suffix));
1678
- registry.register(cmdListOpFamilyFunctions('dAp' + suffix));
1677
+ for (const suffix of ["", "+"]) {
1678
+ registry.register(cmdDescribeAccessMethods("dA" + suffix));
1679
+ registry.register(cmdDescribeAccessMethods("dAm" + suffix));
1680
+ registry.register(cmdListOperatorClasses("dAc" + suffix));
1681
+ registry.register(cmdListOperatorFamilies("dAf" + suffix));
1682
+ registry.register(cmdListOpFamilyOperators("dAo" + suffix));
1683
+ registry.register(cmdListOpFamilyFunctions("dAp" + suffix));
1679
1684
  }
1680
1685
  // `x` (expanded) variants of the two-pattern access-method families.
1681
- for (const tail of ['x', 'x+', '+x', 'xS', 'Sx']) {
1682
- registry.register(cmdListOpFamilyFunctions('dAp' + tail));
1686
+ for (const tail of ["x", "x+", "+x", "xS", "Sx"]) {
1687
+ registry.register(cmdListOpFamilyFunctions("dAp" + tail));
1683
1688
  }
1684
1689
  // Types.
1685
1690
  for (const suffix of SUFFIX_COMBOS) {
1686
- registry.register(cmdDescribeTypes('dT' + suffix));
1691
+ registry.register(cmdDescribeTypes("dT" + suffix));
1687
1692
  }
1688
1693
  // Operators.
1689
1694
  for (const suffix of SUFFIX_COMBOS) {
1690
- registry.register(cmdDescribeOperators('do' + suffix));
1695
+ registry.register(cmdDescribeOperators("do" + suffix));
1691
1696
  }
1692
1697
  // Roles.
1693
- for (const suffix of ['', '+', 'S', 'S+', '+S']) {
1694
- registry.register(cmdDescribeRoles('du' + suffix));
1695
- registry.register(cmdDescribeRoles('dg' + suffix));
1698
+ for (const suffix of ["", "+", "S", "S+", "+S"]) {
1699
+ registry.register(cmdDescribeRoles("du" + suffix));
1700
+ registry.register(cmdDescribeRoles("dg" + suffix));
1696
1701
  }
1697
1702
  // Schemas.
1698
1703
  for (const suffix of SUFFIX_COMBOS) {
1699
- registry.register(cmdListSchemas('dn' + suffix));
1704
+ registry.register(cmdListSchemas("dn" + suffix));
1700
1705
  }
1701
1706
  // Domains.
1702
1707
  for (const suffix of SUFFIX_COMBOS) {
1703
- registry.register(cmdListDomains('dD' + suffix));
1708
+ registry.register(cmdListDomains("dD" + suffix));
1704
1709
  }
1705
1710
  // Conversions.
1706
1711
  for (const suffix of SUFFIX_COMBOS) {
1707
- registry.register(cmdListConversions('dc' + suffix));
1712
+ registry.register(cmdListConversions("dc" + suffix));
1708
1713
  }
1709
1714
  // Casts.
1710
- for (const suffix of ['', '+']) {
1711
- registry.register(cmdListCasts('dC' + suffix));
1715
+ for (const suffix of ["", "+"]) {
1716
+ registry.register(cmdListCasts("dC" + suffix));
1712
1717
  }
1713
1718
  // Tablespaces.
1714
- for (const suffix of ['', '+']) {
1715
- registry.register(cmdDescribeTablespaces('db' + suffix));
1719
+ for (const suffix of ["", "+"]) {
1720
+ registry.register(cmdDescribeTablespaces("db" + suffix));
1716
1721
  }
1717
1722
  // Languages.
1718
1723
  for (const suffix of SUFFIX_COMBOS) {
1719
- registry.register(cmdListLanguages('dL' + suffix));
1724
+ registry.register(cmdListLanguages("dL" + suffix));
1720
1725
  }
1721
1726
  // Collations.
1722
1727
  for (const suffix of SUFFIX_COMBOS) {
1723
- registry.register(cmdListCollations('dO' + suffix));
1728
+ registry.register(cmdListCollations("dO" + suffix));
1724
1729
  }
1725
1730
  // Permissions / default ACLs. `\dp` and `\z` are independent base names
1726
1731
  // (aliasing them via `aliases` couldn't carry separate `x`-suffix
1727
1732
  // variants), so register each with its own suffix matrix.
1728
- for (const tail of ['', 'S', 'x', 'Sx', 'xS']) {
1729
- registry.register(cmdPermissionsList('dp' + tail));
1730
- registry.register(cmdPermissionsList('z' + tail));
1733
+ for (const tail of ["", "S", "x", "Sx", "xS"]) {
1734
+ registry.register(cmdPermissionsList("dp" + tail));
1735
+ registry.register(cmdPermissionsList("z" + tail));
1731
1736
  }
1732
1737
  registry.register(cmdListDefaultACLs);
1733
1738
  // Descriptions.
@@ -1737,34 +1742,34 @@ export const registerDescribeCommands = (registry) => {
1737
1742
  // registration or it dispatches to nothing. `decodeSuffix`
1738
1743
  // reads the verbose flag back off `ctx.cmdName` at runtime.
1739
1744
  registry.register(cmdListAllDbs);
1740
- registry.register({ ...cmdListAllDbs, name: 'l+', aliases: ['list+'] });
1745
+ registry.register({ ...cmdListAllDbs, name: "l+", aliases: ["list+"] });
1741
1746
  // Config / event triggers / extensions / large objects.
1742
1747
  registry.register(cmdDescribeConfigParams);
1743
- registry.register({ ...cmdDescribeConfigParams, name: 'dconfig+' });
1748
+ registry.register({ ...cmdDescribeConfigParams, name: "dconfig+" });
1744
1749
  registry.register(cmdListEventTriggers);
1745
1750
  registry.register(cmdListExtensions);
1746
- registry.register({ ...cmdListExtensions, name: 'dx+' });
1751
+ registry.register({ ...cmdListExtensions, name: "dx+" });
1747
1752
  registry.register(cmdListLargeObjects);
1748
1753
  // Text search family.
1749
1754
  registry.register(cmdListTSConfigs);
1750
- registry.register({ ...cmdListTSConfigs, name: 'dF+' });
1755
+ registry.register({ ...cmdListTSConfigs, name: "dF+" });
1751
1756
  registry.register(cmdListTSParsers);
1752
- registry.register({ ...cmdListTSParsers, name: 'dFp+' });
1757
+ registry.register({ ...cmdListTSParsers, name: "dFp+" });
1753
1758
  registry.register(cmdListTSDictionaries);
1754
- registry.register({ ...cmdListTSDictionaries, name: 'dFd+' });
1759
+ registry.register({ ...cmdListTSDictionaries, name: "dFd+" });
1755
1760
  registry.register(cmdListTSTemplates);
1756
- registry.register({ ...cmdListTSTemplates, name: 'dFt+' });
1761
+ registry.register({ ...cmdListTSTemplates, name: "dFt+" });
1757
1762
  // Foreign-data family.
1758
- for (const variant of ['dew', 'dew+']) {
1763
+ for (const variant of ["dew", "dew+"]) {
1759
1764
  registry.register({ ...cmdListForeignDataWrappers, name: variant });
1760
1765
  }
1761
- for (const variant of ['des', 'des+']) {
1766
+ for (const variant of ["des", "des+"]) {
1762
1767
  registry.register({ ...cmdListForeignServers, name: variant });
1763
1768
  }
1764
- for (const variant of ['deu', 'deu+']) {
1769
+ for (const variant of ["deu", "deu+"]) {
1765
1770
  registry.register({ ...cmdListUserMappings, name: variant });
1766
1771
  }
1767
- for (const variant of ['det', 'det+']) {
1772
+ for (const variant of ["det", "det+"]) {
1768
1773
  registry.register({ ...cmdListForeignTables, name: variant });
1769
1774
  }
1770
1775
  // Partitioned tables. Upstream's `\dP` accepts any concatenation of
@@ -1774,37 +1779,37 @@ export const registerDescribeCommands = (registry) => {
1774
1779
  // suffix-decoding loop (`includes('i'|'t'|'n')`) drives the actual
1775
1780
  // `reltypes` selection at runtime.
1776
1781
  for (const variant of [
1777
- 'dP',
1778
- 'dP+',
1779
- 'dPi',
1780
- 'dPi+',
1781
- 'dPin',
1782
- 'dPin+',
1783
- 'dPt',
1784
- 'dPt+',
1785
- 'dPtn',
1786
- 'dPtn+',
1787
- 'dPn',
1788
- 'dPn+',
1782
+ "dP",
1783
+ "dP+",
1784
+ "dPi",
1785
+ "dPi+",
1786
+ "dPin",
1787
+ "dPin+",
1788
+ "dPt",
1789
+ "dPt+",
1790
+ "dPtn",
1791
+ "dPtn+",
1792
+ "dPn",
1793
+ "dPn+",
1789
1794
  ]) {
1790
1795
  registry.register({ ...cmdListPartitionedTables, name: variant });
1791
1796
  }
1792
1797
  // Role-database settings.
1793
1798
  registry.register(cmdListDbRoleSettings);
1794
- registry.register({ ...cmdListDbRoleSettings, name: 'drds+' });
1799
+ registry.register({ ...cmdListDbRoleSettings, name: "drds+" });
1795
1800
  // Extended statistics (\dX / \dX+).
1796
- for (const suffix of ['', '+']) {
1797
- registry.register(cmdListExtendedStats('dX' + suffix));
1801
+ for (const suffix of ["", "+"]) {
1802
+ registry.register(cmdListExtendedStats("dX" + suffix));
1798
1803
  }
1799
1804
  // Role grants (\drg / \drg+ / \drgS).
1800
- for (const suffix of ['', '+', 'S', 'S+', '+S']) {
1801
- registry.register(cmdDescribeRoleGrants('drg' + suffix));
1805
+ for (const suffix of ["", "+", "S", "S+", "+S"]) {
1806
+ registry.register(cmdDescribeRoleGrants("drg" + suffix));
1802
1807
  }
1803
1808
  // Publication / subscription.
1804
- for (const variant of ['dRp', 'dRp+']) {
1809
+ for (const variant of ["dRp", "dRp+"]) {
1805
1810
  registry.register({ ...cmdListPublications, name: variant });
1806
1811
  }
1807
- for (const variant of ['dRs', 'dRs+']) {
1812
+ for (const variant of ["dRs", "dRs+"]) {
1808
1813
  registry.register({ ...cmdDescribeSubscriptions, name: variant });
1809
1814
  }
1810
1815
  };