Skip to content

Commit 59ae5bf

Browse files
committed
Merge branch 'main' into feature/peek
Signed-off-by: worksofliam <[email protected]>
2 parents b690143 + 47c72e8 commit 59ae5bf

28 files changed

+824
-212
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-db2i",
33
"displayName": "Db2 for IBM i",
44
"description": "Db2 for IBM i tools in VS Code",
5-
"version": "1.9.4",
5+
"version": "1.11.0",
66
"engines": {
77
"vscode": "^1.95.0"
88
},
@@ -32,7 +32,7 @@
3232
],
3333
"main": "./dist/extension.js",
3434
"scripts": {
35-
"language:test": "vitest",
35+
"test": "vitest",
3636
"dsc": "npx tsx src/dsc",
3737
"package": "vsce package",
3838
"vscode:prepublish": "rm -rf dist && npm run webpack && npm run dsc",
@@ -227,7 +227,7 @@
227227
},
228228
{
229229
"id": "vscode-db2i.syntax",
230-
"title": "SQL Syntax Checking",
230+
"title": "SQL Syntax Options",
231231
"properties": {
232232
"vscode-db2i.syntax.checkOnOpen": {
233233
"type": "boolean",
@@ -248,6 +248,11 @@
248248
"type": "boolean",
249249
"description": "Whether SQL syntax warnings should show in the editor",
250250
"default": false
251+
},
252+
"vscode-db2i.syntax.useSystemNames": {
253+
"type": "boolean",
254+
"description": "Whether to use system names for columns in the content assist",
255+
"default": false
251256
}
252257
}
253258
}
@@ -393,6 +398,11 @@
393398
"title": "Get Object Locks",
394399
"category": "Db2 for i"
395400
},
401+
{
402+
"command": "vscode-db2i.getRecordLocks",
403+
"title": "Get Record Locks",
404+
"category": "Db2 for i"
405+
},
396406
{
397407
"command": "vscode-db2i.clearData",
398408
"title": "Clear...",
@@ -435,6 +445,11 @@
435445
"category": "Db2 for i",
436446
"icon": "$(search)"
437447
},
448+
{
449+
"command": "vscode-db2i.viewPermissions",
450+
"title": "View permissions",
451+
"category": "Db2 for i"
452+
},
438453
{
439454
"command": "vscode-db2i.runEditorStatement",
440455
"title": "Run statement",
@@ -745,6 +760,58 @@
745760
"command": "vscode-db2i.setSchemaFilter",
746761
"when": "never"
747762
},
763+
{
764+
"command": "vscode-db2i.generateSQL",
765+
"when": "never"
766+
},
767+
{
768+
"command": "vscode-db2i.getRelatedObjects",
769+
"when": "never"
770+
},
771+
{
772+
"command": "vscode-db2i.getMTIs",
773+
"when": "never"
774+
},
775+
{
776+
"command": "vscode-db2i.getIndexes",
777+
"when": "never"
778+
},
779+
{
780+
"command": "vscode-db2i.getAuthorities",
781+
"when": "never"
782+
},
783+
{
784+
"command": "vscode-db2i.getObjectLocks",
785+
"when": "never"
786+
},
787+
{
788+
"command": "vscode-db2i.getRecordLocks",
789+
"when": "never"
790+
},
791+
{
792+
"command": "vscode-db2i.clearData",
793+
"when": "never"
794+
},
795+
{
796+
"command": "vscode-db2i.copyData",
797+
"when": "never"
798+
},
799+
{
800+
"command": "vscode-db2i.deleteObject",
801+
"when": "never"
802+
},
803+
{
804+
"command": "vscode-db2i.renameObject",
805+
"when": "never"
806+
},
807+
{
808+
"command": "vscode-db2i.advisedIndexes",
809+
"when": "never"
810+
},
811+
{
812+
"command": "vscode-db2i.clearAdvisedIndexes",
813+
"when": "never"
814+
},
748815
{
749816
"command": "vscode-db2i.resultset.settings",
750817
"when": "never"
@@ -1003,6 +1070,11 @@
10031070
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
10041071
"group": "db2workWith@5"
10051072
},
1073+
{
1074+
"command": "vscode-db2i.getRecordLocks",
1075+
"when": "viewItem == table",
1076+
"group": "db2workWith@6"
1077+
},
10061078
{
10071079
"command": "vscode-db2i.clearData",
10081080
"when": "viewItem == table",
@@ -1023,6 +1095,11 @@
10231095
"when": "viewItem == table || viewItem == view || viewItem == index",
10241096
"group": "db2data@4"
10251097
},
1098+
{
1099+
"command": "vscode-db2i.viewPermissions",
1100+
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
1101+
"group": "db2data@5"
1102+
},
10261103
{
10271104
"command": "vscode-db2i.advisedIndexes",
10281105
"when": "viewItem == table || viewItem == schema",
@@ -1400,7 +1477,7 @@
14001477
"webpack-cli": "^4.5.0"
14011478
},
14021479
"dependencies": {
1403-
"@ibm/mapepire-js": "^0.3.0",
1480+
"@ibm/mapepire-js": "^0.5.0",
14041481
"@octokit/rest": "^21.1.1",
14051482
"chart.js": "^4.4.2",
14061483
"csv": "^6.1.3",

src/connection/SCVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
export const VERSION = `2.1.4`;
2+
export const VERSION = `2.2.2`;
33
export const SERVER_VERSION_TAG = `v${VERSION}`;
44
export const SERVER_VERSION_FILE = `mapepire-server-${VERSION}.jar`;

src/connection/manager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export class SQLJobManager {
3838
"full open": false,
3939
"transaction isolation": "none",
4040
"query optimize goal": "1",
41-
"block size": "512"
41+
"block size": "512",
42+
"date format": "iso",
43+
"extended metadata": true,
4244
}));
4345

4446
try {
@@ -132,6 +134,9 @@ export class SQLJobManager {
132134
// 2147483647 is NOT arbitrary. On the server side, this is processed as a Java
133135
// int. This is the largest number available without overflow (Integer.MAX_VALUE)
134136

137+
// const s = performance.now()
138+
// console.log(`Running statement: ${query.padEnd(40).substring(0, 40)}`);
139+
135140
const statement = await this.getPagingStatement<T>(query, opts);
136141
const results = await statement.execute(rowsToFetch);
137142
statement.close();

src/connection/sqlJob.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { getInstance } from "../base";
22
import { ServerComponent } from "./serverComponent";
33
import { SelfValue } from "../views/jobManager/selfCodes/nodes";
44
import { SQLJob } from "@ibm/mapepire-js";
5-
import { ConnectionResult, JobStatus, QueryResult, ServerRequest, ServerResponse } from "@ibm/mapepire-js/dist/src/types";
6-
import { JobLogEntry } from "./types";
5+
import { ConnectionResult, QueryResult, ServerRequest, ServerResponse } from "@ibm/mapepire-js/dist/src/types";
6+
import { JobLogEntry, JobStatus } from "./types";
77
import Statement from "../database/statement";
88
import { NamingFormats } from "./manager";
99

@@ -131,7 +131,7 @@ export class OldSQLJob extends SQLJob {
131131
getStatus(): JobStatus {
132132
const currentListenerCount = this.responseEmitter.eventNames().length;
133133

134-
return this.channel && currentListenerCount > 0 ? "busy" : this.status;
134+
return this.channel && currentListenerCount > 0 ? JobStatus.BUSY : this.status as JobStatus;
135135
}
136136

137137
async connect(): Promise<ConnectionResult> {
@@ -141,12 +141,12 @@ export class OldSQLJob extends SQLJob {
141141

142142
this.channel.on(`error`, (err) => {
143143
ServerComponent.writeOutput(err);
144-
this.dispose();
144+
this.end();
145145
})
146146

147147
this.channel.on(`close`, (code: number) => {
148148
ServerComponent.writeOutput(`Exited with code ${code}.`)
149-
this.dispose();
149+
this.end();
150150
})
151151

152152
const props = Object
@@ -172,10 +172,10 @@ export class OldSQLJob extends SQLJob {
172172
const connectResult = await this.send<ConnectionResult>(connectionObject);
173173

174174
if (connectResult.success === true) {
175-
this.status = "ready";
175+
this.status = JobStatus.READY;
176176
} else {
177-
this.dispose();
178-
this.status = "notStarted";
177+
this.end();
178+
this.status = JobStatus.NOT_STARTED;
179179
throw new Error(connectResult.error || `Failed to connect to server.`);
180180
}
181181

@@ -229,13 +229,13 @@ export class OldSQLJob extends SQLJob {
229229
}));
230230
});
231231

232-
this.dispose();
232+
this.end();
233233
}
234234

235-
dispose() {
235+
private end() {
236236
this.channel.close();
237237
this.channel = undefined;
238-
this.status = "ended";
238+
this.status = JobStatus.ENDED;
239239
this.responseEmitter.removeAllListeners();
240240
}
241241
}

src/connection/types.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
import { QueryMetaData, QueryResult } from "@ibm/mapepire-js/dist/src/types";
1+
2+
// Redefined from mapepire-js
3+
export enum JobStatus {
4+
NOT_STARTED = "notStarted",
5+
CONNECTING = "connecting",
6+
READY = "ready",
7+
BUSY = "busy",
8+
ENDED = "ended"
9+
}
10+
11+
export enum TransactionEndType {
12+
COMMIT = "COMMIT",
13+
ROLLBACK = "ROLLBACK"
14+
}
15+
16+
export enum ExplainType {
17+
RUN = "run",
18+
DO_NOT_RUN = "doNotRun"
19+
}
20+
// End
221

322
export interface JobLogEntry {
423
MESSAGE_ID: string;

src/database/schemas.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { JobManager } from "../config";
55
import { ResolvedSqlObject, BasicSQLObject } from "../types";
66

77
export type SQLType = "schemas" | "tables" | "views" | "aliases" | "constraints" | "functions" | "variables" | "indexes" | "procedures" | "sequences" | "packages" | "triggers" | "types" | "logicals";
8-
export type PageData = { filter?: string, offset?: number, limit?: number };
8+
export type PageData = { filter?: string, offset?: number, limit?: number, sort?: boolean };
99

1010
const typeMap = {
1111
'tables': [`T`, `P`, `M`],
@@ -252,10 +252,11 @@ export default class Schemas {
252252
case `schemas`:
253253
selects.push(
254254
[
255-
`select '${type}' as OBJ_TYPE, '' as TABLE_TYPE, SCHEMA_NAME as NAME, SCHEMA_TEXT as TEXT, SYSTEM_SCHEMA_NAME as SYS_NAME, '' as SYS_SCHEMA, '' as SPECNAME, '' as BASE_SCHEMA, '' as BASE_OBJ`,
256-
`from QSYS2.SYSSCHEMAS`,
255+
``,
256+
`SELECT '${type}' as OBJ_TYPE, '' as TABLE_TYPE, OBJLONGNAME AS NAME, '' as TEXT, OBJNAME AS SYS_NAME, '' as SYS_SCHEMA, '' as SPECNAME, '' as BASE_SCHEMA, '' as BASE_OBJ`,
257+
`FROM TABLE(QSYS2.OBJECT_STATISTICS('*ALLSIMPLE', 'LIB')) Z`,
257258
details.filter
258-
? `where UPPER(SCHEMA_NAME) = ? or UPPER(SYSTEM_SCHEMA_NAME) = ?`
259+
? `where UPPER(OBJLONGNAME) = ? or UPPER(OBJNAME) = ?`
259260
: ``,
260261
].join(` `)
261262
);
@@ -398,9 +399,15 @@ export default class Schemas {
398399
}
399400
}
400401

401-
const query = `with results as (${selects.join(
402-
" UNION ALL "
403-
)}) select * from results Order by QSYS2.DELIMIT_NAME(NAME) asc`;
402+
let query: string;
403+
404+
if (details.sort) {
405+
query = `with results as (${selects.join(
406+
" UNION ALL "
407+
)}) select * from results Order by QSYS2.DELIMIT_NAME(NAME) asc`;
408+
} else {
409+
query = selects.join(` UNION ALL `);
410+
}
404411

405412
const objects: any[] = await JobManager.runSQL(
406413
[
@@ -417,7 +424,7 @@ export default class Schemas {
417424
type: object.OBJ_TYPE,
418425
tableType: object.TABLE_TYPE,
419426
schema,
420-
name: object.NAME || undefined,
427+
name: object.NAME || object.SYS_NAME || undefined,
421428
specificName: object.SPECNAME || undefined,
422429
text: object.TEXT || undefined,
423430
system: {

src/database/table.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default class Table {
1515
`SELECT `,
1616
` column.TABLE_SCHEMA,`,
1717
` column.TABLE_NAME,`,
18+
` column.SYSTEM_COLUMN_NAME,`,
1819
` column.COLUMN_NAME,`,
1920
` key.CONSTRAINT_NAME,`,
2021
` column.DATA_TYPE, `,
@@ -70,8 +71,8 @@ export default class Table {
7071
}
7172

7273
static async isPartitioned(schema: string, name: string): Promise<boolean> {
73-
const sql = `select table_name, partitioned_table from qsys2.sysfiles where table_schema = ? and table_name = ? and partitioned_table is not null and partitioned_table = 'YES'`;
74-
const parameters = [schema, name];
74+
const sql = `select table_name, partitioned_table from qsys2.sysfiles where ((table_schema = ? and table_name = ?) or (system_table_schema = ? and system_table_name = ?)) and partitioned_table is not null and partitioned_table = 'YES'`;
75+
const parameters = [schema, name, schema, name];
7576

7677
const result = await JobManager.runSQL(sql, {parameters});
7778
return result.length > 0;

0 commit comments

Comments
 (0)