Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap our DSPFD for object_statistics #1992

Closed
worksofliam opened this issue Apr 17, 2024 · 9 comments · Fixed by #1997
Closed

Swap our DSPFD for object_statistics #1992

worksofliam opened this issue Apr 17, 2024 · 9 comments · Fixed by #1997
Labels
discussion For questions, or when something isn't working as expected enhancement New feature or request
Milestone

Comments

@worksofliam
Copy link
Contributor

As we found in this comment, we are having issues with DSPFD when it comes to multiple encodings and a bad QCCSID. This is solved by using object_statistics.

Right now, this logic only has to be changed here:

async getObjectList(filters: { library: string; object?: string; types?: string[]; filterType?: FilterType }, sortOrder?: SortOrder): Promise<IBMiObject[]> {

select 
  objlib as LIBRARY,
  objname as NAME,
  objtype as TYPE,
  objattribute as ATTRIBUTE,
  objtext as TEXT,
  0 as NB_MBR,
  0 as IS_SOURCE,
  0 as SOURCE_LENGTH,
  65535 as CCSID,
  objsize as SIZE,
  objcreated as CREATED_TS,
  objowner as OWNER
from table(qsys2.object_statistics('AURORAKOR', '*ALL')) limit 1
@worksofliam worksofliam added enhancement New feature or request discussion For questions, or when something isn't working as expected labels Apr 17, 2024
@worksofliam worksofliam added this to the 2.10.0 milestone Apr 17, 2024
@worksofliam
Copy link
Contributor Author

We can also replace DSPFFD with a select from SYSTABLES

@worksofliam worksofliam mentioned this issue Apr 18, 2024
19 tasks
@chrjorgensen
Copy link
Collaborator

We can also replace DSPFFD with a select from SYSTABLES

I think you mean select from SYSCOLUMNS?

@sebjulliand
Copy link
Collaborator

I think it's actually SYSTABLES. If I'm not mistaken, it holds the FILE_TYPE = 'S' information needed to know which *FILE is a SPF.

@chrjorgensen
Copy link
Collaborator

@sebjulliand SYSTABLES correspond to DSPFD and SYSCOLUMNS correspond to DSPFFD - so the answer depends on whether we're talking about DSPFD or DSPFFD... 😉 😄

@chrjorgensen
Copy link
Collaborator

I just remembered that SYSCOLUMNS has been deprecated in favor of SYSCOLUMNS2, which should be faster and return more informartion: https://www.ibm.com/docs/en/i/7.3?topic=views-syscolumns2

@worksofliam
Copy link
Contributor Author

worksofliam commented Apr 18, 2024

@sebjulliand @chrjorgensen

We need:

  • object_statistics for all objects (prev. DSPOBJD)
  • SYSTABLES for the special *SRCPF type (prev. DSPFD)

@sebjulliand
Copy link
Collaborator

@sebjulliand SYSTABLES correspond to DSPFD and SYSCOLUMNS correspond to DSPFFD - so the answer depends on whether we're talking about DSPFD or DSPFFD... 😉 😄

Ugh, my bad, DSPFD it is!

@worksofliam
Copy link
Contributor Author

worksofliam commented Apr 19, 2024

-- only source
select 
  t.SYSTEM_TABLE_NAME as name,
  '*FILE' as type,
  '' as attribute,
  t.table_text as text,
  1 as is_source,
  -1 as nb_mbr, -- no idea how to get this
  c.character_maximum_length as SOURCE_LENGTH,
  c.ccsid
from qsys2.systables as t
right join qsys2.syscolumns2 as c on t.system_table_schema = c.system_table_schema and t.SYSTEM_TABLE_NAME = c.SYSTEM_TABLE_NAME and c.column_name = 'SRCDTA'
where t.table_schema = 'LIAMA' and t.file_type = 'S';

-- all objects
select 
  o.objlib as LIBRARY,
  o.objname as NAME,
  o.objtype as TYPE,
  o.objattribute as ATTRIBUTE,
  o.objtext as TEXT,
  0 as NB_MBR,
  0 as IS_SOURCE,
  0 as SOURCE_LENGTH,
  65535 as CCSID,
  o.objsize as SIZE,
  o.objcreated as CREATED_TS,
  o.objowner as OWNER,
  o.objdefiner as CREATED_BY,
  o.objsize as SIZE_IN_UNITS,
  0 as BYTES_PER_UNIT
from table(qsys2.object_statistics('LIAMA', '*ALL')) as o;

-- get all objects and figure out which files are source files
select 
  o.objlib as LIBRARY,
  o.objname as NAME,
  o.objtype as TYPE,
  o.objattribute as ATTRIBUTE,
  o.objtext as TEXT,
  -1 as NB_MBR,
  case when c.character_maximum_length is null then 0 else 1 end as IS_SOURCE,
  c.character_maximum_length as SOURCE_LENGTH,
  c.ccsid as CCSID,
  o.objsize as SIZE,
  o.objcreated as CREATED_TS,
  o.objowner as OWNER,
  o.objdefiner as CREATED_BY,
  o.objsize as SIZE_IN_UNITS,
  0 as BYTES_PER_UNIT
from table(qsys2.object_statistics('LIAMA', '*ALL')) as o
left outer join qsys2.syscolumns2 as c on o.objlib = c.system_table_schema and o.objname = c.SYSTEM_TABLE_NAME and c.column_name = 'SRCDTA'

@worksofliam worksofliam linked a pull request Apr 19, 2024 that will close this issue
7 tasks
@edmundreinhardt
Copy link
Collaborator

@worksofliam @sebjulliand
If we were to go to common code, the usage and name mapping can be found below.
BUT - this is only for database files and does not work for DSPF/PRTF files
Based on that limitation, I am disposed not to attempt a replacement at this time.

cmd old name new service USE new name
FD WHLIB SF.SYSTEM_TABLE_SCHEMA MI- Library of file
FFD WHNAME SF.FORMAT_NAME MII record name
FD APKEYN SF.NUMBER_KEY_FIELDS M-- number of keys
WHPSUD M-- DDS Field data type
WHFLDT SC.DATA_TYPE (map) MCI Field type
WHFLDI M-- Internal Field Name
WHCSID SC.CCSID M-- CCSID
WHNULL SC.IS_NULLABLE M-- Is NULLable
WHALIS SC.COLUMN_NAME MCR ALIAS field name
WHFIOB SC.HIDDEN M-- Field usage
. WHFLDP SC.NUMERIC_SCALE MCI Decimal Positions
WHIBO SC.ORDINAL_POSITION (map) M-- input buffer position
. WHFOBO SC.ORDINAL_POSITION (map) M-- output buffer position
. WHFMT M-- Date time format
WHVARL SC.DATA_TYPE (map) M-R Variable length field boolean)
. WHFLDB SC.STORAGE MCI byte length
WHFLDD SC.NUMERIC_PRECISION MCI digit count
. WHFLDE SC.SYSTEM_COLUMN_NAME -CR external field name
WHFILE SF.SYSTEM_TABLE_NAME -I- System name
WHFTXT SC.COLUMN_TEXT -II Column text
SF = QSYS2.SYSFILES
SC = QSYS2.SYSCOLUMNS

M - used by Merlin RPGLE LSP
C - used by CL vscode-clle LSP
R - used by RPG vscode-rpgle LSP
I - used in interface of CL or RPG extension but not in the logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion For questions, or when something isn't working as expected enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants