Coder Social home page Coder Social logo

db2sock-test's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

db2sock-test's Issues

Why is uname coming back blank from stored proc call?

Original report by Jesse G (Bitbucket: ThePrez, GitHub: ThePrez).


Other commands (tested echo, ls) seem to work, but uname comes back empty. Fully-qualifying uname to /QOpenSys/usr/bin/uname or /usr/bin/uname do not seem to make a difference. "-a" also renders a blank result.

***********************************************
*****uname:
***********
in:
{"script":[{"cmd":{"qsh":"uname -s"}}]}
********************
output:
{"script":[{"cmd":["uname -s",{"records":[{"R1":""}]}]}]}


****************************************************

%parms gives incorrect value

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


%parms() seems to give a value 128 although program gets fewer parameters. This probably has something to do with calling through stored procedure, but is there something that could be done about this? This might also be the reason why things don't crash although you don't give all the necessary parameters in the json.

     H AlwNull(*UsrCtl)

       dcl-pr Main extpgm;
         paramCount int(10);
         p1 char(5);
         p2 char(5) options(*nopass);
         p3 char(5) options(*nopass);
       end-pr;

       dcl-pi Main;
         paramCount int(10);
         p1 char(5);
         p2 char(5) options(*nopass);
         p3 char(5) options(*nopass);
       end-pi;
         paramCount = %parms();
       return;
input(271):
{"pgm":[
    {"name":"TPGM4", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0},
        {"name":"p1", "type":"5a", "value":""},
        {"name":"p2", "type":"5a", "value":""},
        {"name":"p3", "type":"5a", "value":""}
    ]}
]}


output(89): {"script":[{"pgm":["TPGM4","DB2JSON",{"paramCount":128},{"p1":{}},{"p2":{}},{"p3":{}}]}]}
input(222):
{"pgm":[
    {"name":"TPGM4", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0},
        {"name":"p1", "type":"5a", "value":""},
        {"name":"p2", "type":"5a", "value":""}
    ]}
]}

output(79): {"script":[{"pgm":["TPGM4","DB2JSON",{"paramCount":128},{"p1":{}},{"p2":{}}]}]}
input(174):
{"pgm":[
    {"name":"TPGM4", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0},
        {"name":"p1", "type":"5a", "value":""}
    ]}
]}

output(69): {"script":[{"pgm":["TPGM4","DB2JSON",{"paramCount":128},{"p1":{}}]}]}
input(126):
{"pgm":[
    {"name":"TPGM4", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0}
    ]}
]}

output(59): {"script":[{"pgm":["TPGM4","DB2JSON",{"paramCount":128}]}]}

Need to trim results in stored proc call (Rexx-specific?)

Original report by Jesse G (Bitbucket: ThePrez, GitHub: ThePrez).


In the following test output, I do not expect the "USRLIBL" key in the output to have trailing spaces. I do not believe this happens during HTTP rest calls and may be isolated to invocations via stored proc (I am using DB2JSON.DB2PROCJR) and possibly even Rexx-based calls.

***********************************************
*****RTVJOBA ERROR:
***********
in:
{"script":[{"cmd":{"exec":"CHGLIBL LIBL(DB2JSON QTEMP) CURLIB(DB2JSON)"}},{"cmd":{"rexx":"RTVJOBA USRLIBL(?)"}}]}
********************
output:
{"script":[{"cmd":["CHGLIBL LIBL(DB2JSON QTEMP) CURLIB(DB2JSON)"]},{"cmd":["STRREXPRC SRCMBR(CMDIO) SRCFILE(DB2JSON/QREXSRC) PARM('3 RTVJOBA USRLIBL(?)')",{"records":[{"USRLIBL                                                             ":"DB2JSON    QTEMP"}]}]}]}


****************************************************

Same named parameters as JSON keys will be changed to 'name'

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


I found some weird behavior during my testing.

If I have a json which has parameters that are named same as some JSON parsing values, the parameter name is changed to 'name' in the output json.

This is easily tested with the example hello program by changing the parameter name.

input(108):
{"pgm":[{"name":"HELLO",  "lib":"DB2JSON"},
    {"s":{"name":"type", "type":"128a", "value":"Hi there"}}
]}

output(63): {"script":[{"pgm":["HELLO","DB2JSON",{"name":"Hello World"}]}]}


input(109):
{"pgm":[{"name":"HELLO",  "lib":"DB2JSON"},
    {"s":{"name":"typea", "type":"128a", "value":"Hi there"}}
]}

output(64): {"script":[{"pgm":["HELLO","DB2JSON",{"typea":"Hello World"}]}]}

These seem to be the offending keys https://bitbucket.org/litmis/db2sock/src/aaa30597c6fcc85f39852f22858af674cdd121f7/toolkit/parser-json/PaseJson.c?at=master&fileviewer=file-view-default#PaseJson.c-74

cmd call with output parameters

Original report by Steven Scott (Bitbucket: fresche_sscott, GitHub: Unknown).


Hey guys,

I've been looking at making an iToolkit alternative for Node based around db2sock and its JSON transit format, and noticed that the base toolkit/XMLSERVICE combination uses 'rexx' to call CMD objects with return parameters.

It doesn't seem like db2sock has something like this implemented yet, and was wondering what the plan was in this regard. Is this something that will be added to db2sock in the future, or will it need to be handled by some external method?

Trim trailing 0 decimals

Original report by Danny Roessner (Bitbucket: droessner, GitHub: danny-hcs).


This is not technically a bug, but I think zoned/packed/etc fields that return decimals should trim trailing 0's. The example in Issue #24 shows this, but I can create a separate test case if necessary. In JSON trailing decimal 0's don't mean anything. Parsing {"num":1000.000} for example turns it into {"num":1000} anyway. Any trailing 0 decimals should be removed in the data in the output string.

Don't convert 'out' data from EBCDIC to UTF8

Original report by Sebastian Misiewicz (Bitbucket: SMisiewicz, GitHub: sebastian-misiewicz).


I'm wondering if it's possible to force Toolkit/JSON parser to
return data without conversion from EBCDIC to UTF8 (my RPG program returns data
already encoded as UTF8). Currently the toolkit unconditionally converts data from EBCDIC
to UTF8 (I believe it's ile_pgm_char_2_output in PaseToIle.c)

The XMLSERVICE has nice feature where you can ask to convert data 'after'

#!c
var pgm = new xt.iPgm("MYPGM", { lib: "MYLIB", func: "MYFUNC", error: "on" } );	
pgm.addParam('', '1000000A', {after:1208} );

so is it possible add something like 'dontConvertOutData' to 'pgm' invocation

#!json

{"pgm":[{"name":"HELLO",  "lib":"DB2JSON"},
        {"s":{"name":"char", "type":"128a", "value":"Hi there","dontConvertOutData":true}}
       ]}

I know I could use Binary data then convert data by myself.

Regards
Sebastian

Output parsing issue containing JSON string as value

Original report by Brian Jerome (Bitbucket: bjerome, GitHub: brianmjerome).


I am calling a program that returns a JSON string, but using the SQL400Json while testing is not returning the correct output. It also looks like one of the input parameters is coming back when it shouldn't -- I thought this was fixed recently but it might be because of this other issue?

Input

#!json
{"pgm":[
  {"name":"GETJSONDATA",  "lib":"DB2JSON"},
  {"ds": [{"name":"REQPARMS", "dim":1, "by":"in"},
    {"s": [
      {"name":"TEST1", "type":"6p0", "value":1},
      {"name":"TEST2", "type":"12p0", "value":12345678}
    ]}
  ]},
  {"ds": [{"name":"JSONDATA", "dim":100, "by":"out", "dou":"JSONCOUNT"},
    {"s": [
      {"name":"JSONDATA", "type":"64000a"}
    ]}
  ]},
  {"s": {"name":"JSONCOUNT", "type":"10i0", "by":"out", "setlen":"JSONDATA"}},
  {"s": {"name":"RTRNCD", "type":"8a", "by":"out"}}

Output

#!json
{"script":[{"pgm":["GETJSONDATA","DB2JSON",{"REQPARMS":[]},{"JSONDATA":[[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}],[{"JSONDATA":""}]]},{"JSONCOUNT":64000},{"RTRNCD":""}]}]}

The JSONDATA field in the JSONDATA DS should contain a JSON String. It's weird that the JSONCOUNT is coming back as 64000 -- i'm expecting it to come back as 2.

Defining multiarray DS json

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


I'm trying to test db2sock with our system. But I have a problem defining a json which contains DS arrays.

For example with a program like this.

     H AlwNull(*UsrCtl)

       dcl-ds itemDS qualified;
            field1 char(5);
            field2 char(5);
            field3 char(5);
            field4 char(5);
       end-ds;

       dcl-pr Main extpgm;
         rows zoned(5:0);
         items likeds(itemDS) dim(20);
         last char(10);
       end-pr;

       dcl-pi Main;
         rows zoned(5:0);
         items likeds(itemDS) dim(20);
         last char(10);
       end-pi;

         dcl-s i int(10);
         for i = 1 to rows;
           items(i).field4 = items(i).field1;
           items(i).field3 = items(i).field2;
         endfor;
         last = 'TEST';

       return;

This json doesn't crash and gives almost the right results.

{"pgm":[
    {"name":"TPGM",  "lib":"DB2JSON"},
    {"s": {"name":"rows", "type":"5s0", "value":2}},
    {"ds": [
        {"s":[
            {"name":"field1", "type":"5a", "value":"ff1"},
            {"name":"field2", "type":"5a", "value":"ff2"},
            {"name":"field3", "type":"5a", "value":""},
            {"name":"field4", "type":"5a", "value":""}
        ]},
        {"s":[
            {"name":"field1", "type":"5a", "value":"gg1"},
            {"name":"field2", "type":"5a", "value":"gg2"},
            {"name":"field3", "type":"5a", "value":""},
            {"name":"field4", "type":"5a", "value":""}
        ]}
    ]},
    {"s": {"name":"last", "type":"10a", "value":""}}
]}
output(201): {"script":[{"pgm":["TPGM","DB2JSON",{"rows":2},{"":{"field1":"TEST"},{"field2":{}},{"field3":"ff2"},{"field4":"ff1"},{"field1":"gg1"},{"field2":"gg2"},{"field3":"gg2"},{"field4":"gg1"}},{"last":{}}]}]}

Weird thing is value TEST goes into DS field1.
Should I define the ds name and dim somewhere? Db2socks is still work in progress but is there currently a way to get this working?

I am testing this on v7.3 using the newest db2sock build by hand.

Packed/zoned decimals not working correctly

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


Decimal aren't working as expected with packed and zoned numbers. If I give number 100 to 5p2 it becomes 1.00 when parsed.

I made some tests for this problem.

$ ./test1000_sql400json32 ../json/j0030_decimal_numbers1                                                                                                       
input(5000000):                                                                                                                                                                    
{"pgm":[{"name":"DECIMALS",  "lib":"DB2JSON"},
    {"s":[
        {"name":"afloat",     "type":"4f2",   "value":1000},
        {"name":"adouble",    "type":"8f3",   "value":1000},
        {"name":"apacked",    "type":"12p2",  "value":1000},
        {"name":"azoned",     "type":"12s2",  "value":1000}
    ]}
]}

output(118):
{"script":[{"pgm":["DECIMALS","DB2JSON",{"afloat":1000.00},{"adouble":1000.000},{"apacked":10.00},{"azoned":10.00}]}]}

result:
fail missing ("apacked":1000.00)
fail (-1)

PGM Complex JSON String Output Distorted

Original report by Brian Jerome (Bitbucket: bjerome, GitHub: brianmjerome).


I have a simple pgm returning a JSON string:

#!rpg
H main(RETURNJSON)                                                         
 **************************************************************************
 **  Web Service PCML Parameter Setup:                                   **
 **                                                                      **
 **    Parameter    Usage        Counter     Description                 **
 **    =========    ==========   ==========  ================            **
 **    outone       output                   JSON One                    **
 **************************************************************************
d*---------------------------------------------------------------------    
d RETURNJSON      pr                  extpgm('RETURNJSON')                 
d  outone                    64000                                         
d*info|use:output|jType:S|                                                 
d*cmnt|comment:This field is the first JSON Output.|                       
 **************************************************************************
 ** Procedure (Local) Definitions                                        **
 **************************************************************************
p RETURNJSON      b                                                        
d                 pi                                                       
d  outone                    64000                                         
 **************************************************************************
 **************************************************************************
 **                          Main Routine Code                           **
 **************************************************************************
 /free                                                                     
  outone = '{"title":"Hello World","content":"<span' +                     
  'class=\"subheading\">Subhead</span>","footer":' +                       
  '{"links":["www.google.com","www.mysite.co"],"height":50}}';             
 /end-free                                                                 
 **************************************************************************
p RETURNJSON      e                                                        

And I'm calling the PGM with the following with the sg10 build:

#!sql
CALL
DB2JSON.DB2PROCJR('{"pgm":[
    {"name":"RETURNJSON",  "lib":"BJEROME"},
    {"s": {"name":"outone", "type":"64000a", "by":"out"}}
]}');

I'm expecting it to return something like:

#!json
{"script":[{"pgm":["RETURNJSON","BJEROME",{"outone":"{\"title\":\"Hello World\",\"content\":\"<span class=\\\"subheading\\\">Subhead</span>\",\"footer\":{\"links\":[\"www.google.com\",\"www.mysite.co\"],\"height\":50}}"}]}]}

What I get is the output distorted in a weird way:

#!json
{"script":[{"pgm":["RETURNJSON","BJEROME",{"outone":"{\"title\"\"\"HellloWorld\",\"\"oontent:\"<spancccass=\\\"\"bheaddinn\\\">>ubbad</sspaa>\"\",fooeer:{{\"llnkks:[[wwwgooogge..cm\"\"www.mmysstee.o\"\"\"heighttt50`"}]}]}

Might this be related to the change in sg8 to escape quotes in strings? I ran this code with sg6 and the text was fine but not escaped.

Latest libdb400 download wrong version #

Original report by Brian Jerome (Bitbucket: bjerome, GitHub: brianmjerome).


The YIPS test version binary download shows the latest as:
libdb400–1.1.4-sg2 (2018–02–21 15:44)

When I download the latest via Attach:libdb400-latest.zip it downloads as libdb400-1.1.1-sg2.

I'm assuming it has the latest content still from 2/21.

Negative numbers don't work

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


Negative numbers doesn't seems to work.

     H AlwNull(*UsrCtl)

       dcl-pr Main extpgm;
         aint8 int(3);
         aint16 int(5);
         aint32 int(10);
         aint64 int(20);
         afloat float(4);
         adouble float(8);
         apacked packed(12:2);
         azonded zoned(12:2);
       end-pr;

       dcl-pi Main;
         aint8 int(3);
         aint16 int(5);
         aint32 int(10);
         aint64 int(20);
         afloat float(4);
         adouble float(8);
         apacked packed(12:2);
         azonded zoned(12:2);
       end-pi;
         aint8 -= 10;
         aint16 -= 10;
         aint32 -= 10;
         aint64 -= 10;
         afloat -= 10.11;
         adouble -= 10.111;
         apacked -= 10.11;
         azonded -= 10.11;
       return;
$ ./test1000_sql400json32 ../json/j0020_negative_numbers                                                                                                       
input(5000000):                                                                                                                                                                    
{"pgm":[{"name":"NEGATIVE",  "lib":"DB2JSON"},
        {"s":[{"name":"aint8",      "type":"3i0",   "value":-1},
              {"name":"aint16",     "type":"5i0",   "value":-2},
              {"name":"aint32",     "type":"10i0",  "value":-3},
              {"name":"aint64",     "type":"20i0",  "value":-4},
              {"name":"afloat",     "type":"4f2",   "value":-5.55},
              {"name":"adouble",    "type":"8f3",   "value":-6.666},
              {"name":"apacked",    "type":"12p2",  "value":-7.77},
              {"name":"azoned",     "type":"12s2",  "value":-8.88}
             ]}
       ]}

output(167):
{"script":[{"pgm":["NEGATIVE","DB2JSON",{"aint8":-9},{"aint16":-8},{"aint32":-7},{"aint64":-6},{"afloat":-4.56},{"adouble":-3.445},{"apacked":2.34},{"azoned":1.23}]}]}

result:
fail missing ("aint8":-11)
fail (-1)

Ints and floats seem to return negatives correctly, but they seem to lose the sign when sending. Packed and zoned also won't return negative number.

Test files can be found in my fork.

PGM Call JSON Output Issues

Original report by Danny Roessner (Bitbucket: droessner, GitHub: danny-hcs).


I’m not sure if I’m understanding the “by” functionality correctly or if this is incomplete, but when I add a “by”:”in” config to a parameter it is still included in the output. For example, I send something like {"s":{"name":"INPUT","type":"10a","value":"DATA","by":"in"}} and the output passes "pgm":["TEST","DANNY",{"INPUT":"DATA"}]. I would think if I specify "in" it should not be in the output.

Additionally, I have a simple RPG program that just returns a string. The config I’m sending for the parm is {"s":{"name":"RTRNCD","type":"8a","by":"out”}}. The RPG code is setting RTRNCD to an empty string, but the JSON output I’m getting for this parameter is {"RTRNCD":{}}. I would expect it to be {"RTRNCD":""}

SQL400Json - memory leak ?

Original report by Sebastian Misiewicz (Bitbucket: SMisiewicz, GitHub: sebastian-misiewicz).


Hi

I have created a simple program which calls SQL400Json in a loop.

#!c

#include <stdio.h>
#include <sqlcli1.h>
#include "PaseCliAsync.h"

  char injson[] = "{\"script\":[ {\"cmd\":{\"exec\":\"CHGLIBL LIBL(MYLIB QTEMP) CURLIB(MYLIB)\"}},\
  {\"pgm\":[{\"name\":\"HELLO\"},\
  {\"s\":[{\"name\":\"char\", \"type\":\"10000000a\", \"value\":{\"Hi there\"}},\
          {\"name\":\"char\", \"type\":\"128a\", \"value\":\"Hi there\"}]} ]}]}\x00";


char outjson[1000000];

void calljson()
{
  SQLINTEGER inlen = strlen(injson);
  outjson[0] = 0;
  SQLINTEGER outlen = sizeof(outjson);
  SQL400Json(0, injson, inlen, outjson, outlen);
  printf("result %s\n", outjson);
}

int main()
{
  for(int i = 0; i < 100; i++) {
   calljson();
   sleep(5);
  }
  return 0;
}

Looks like it doesn't free memory or did I miss something obvious?

Regards

Sebastian

DB2Sock Toolkit

Original report by Steven Scott (Bitbucket: fresche_sscott, GitHub: Unknown).


Hey guys,

I've been toying around with the start of a replacement toolkit that utilizes db2sock's REST interface. What I have so far is basic CMD, QSH and PGM calling.

I've written it in TypeScript, as a fully-JS module, no native code compilation required. I'm currently aiming for a more "functional" approach, compared to the existing toolkit's "array"-based approach to passing parameters around.

At the moment, I'm working on getting authorization to post it online under the MIT license, and I'm hoping to have it up within the next few weeks.

I wanted to open this task so that there can be public discourse and knowledge that it's something being worked on.

Calling multiple actions of the same type

Original report by me.


Due to the format of the JSON that db2sock uses, it seems that there is no way to execute multiple actions of the same type in the same request. The problem is that it uses the key in the parent object to define the action to be performed, but JSON keys must be unique. If you can only have one pgm or cmd key, how would you be able to call mulitple programs or commands in the same invocation.

eg.

{
	"pgm": [{
			"name": "HELLO",
			"lib": "DB2JSON"
		},
		{
			"s": {
				"name": "char",
				"type": "128a",
				"value": "Hi there"
			}
		}
	],
	"pgm": [{                                    <--- this is invalid JSON
			"name": "HELLO",
			"lib": "DB2JSON"
		},
		{
			"s": {
				"name": "char",
				"type": "128a",
				"value": "Hi there"
			}
		}
	]
}

MCH0601 Error

Original report by Danny Roessner (Bitbucket: droessner, GitHub: danny-hcs).


This will be a long shot because I don't have a test case to post at the moment as I have yet to figure out what part of the RPG is causing an issue (but I will continue to look into it).

I'm getting a MCH0601 error when running the RPG program using a remote call. db2sock returns the following error: TKIT400 at statement 0000000002 (bb). The actual error is Space offset X'00000000' or X'0000000000FFF000' is outside current limit for object QZDASOINIT.

The RPG program can be called without issue from greenscreen and it is also currently implemented in production on an IWS (2.6) server and runs fine. It only throws that error when called remotely using db2sock. If I start a service job to try to debug the RPG it never actually hits the RPG code so it seems to error out before it gets into the program.

Is any of that helpful at all to determine what the issue might be? As I said I'll continue to try to put together an example test case to reproduce the issue with.

Illegal Instruction - TKIT400 Error

Original report by Brian Jerome (Bitbucket: bjerome, GitHub: brianmjerome).


I'm not sure exactly what could be causing this. I am getting an Illegal instruction error using the experimental toolkit and running sql directly results in the following error message:

#!

Message: [CEE9901] Application error.  

MCH3601 unmonitored by TKIT400 at statement [0000000016 (bb)](https://bitbucket.org/litmis/db2sock/commits/0000000016), instruction X'0000'. 

Cause . . . . . :   
The application ended abnormally because an exception occurred and was not handled.  
The name of the program to which the unhandled exception is sent is TKIT400 PASETOILE. 
The program was stopped at the high-level language statement number(s) at the time the message was sent.  
If more than one statement number is shown, the program is an optimized ILE program.  
Optimization does not allow a single statement number to be determined.  
If *N is shown as a value, it means the real value was not available. 

Recovery  . . . :   
See the low level messages previously listed to locate the cause of the exception.  
Correct any errors, and then try the request again.

Here's the test PGM:

#!rpg

H AlwNull(*UsrCtl)
    dcl-ds oDS qualified;
        outputA char(7);
        outputB char(1);
    end-ds;


    dcl-pr Main extpgm;
        inputOne packed(8:0);
        outArray packed(8:0) dim(100);
        bothArray packed(8:0) dim(100);
        outDS likeds(oDS) dim(100);
        outCount int(10);
        last char(8);
    end-pr;


    dcl-pi Main;
        inputOne packed(8:0);
        outArray packed(8:0) dim(100);
        bothArray packed(8:0) dim(100);
        outDS likeds(oDS) dim(100);
        outCount int(10);
        last char(8);
    end-pi;


    last = 'last';
    outCount = 1;
    return;

Test JSON input:

#!json

{"pgm":[{"name":"DRTEST05","lib":"BJEROME"},
    {"s":{"name":"inputOne","type":"8p0","by":"in","value":""}},
    {"s":{"name":"outArray","type":"8p0","by":"out","dim":100}},
    {"s":{"name":"bothArray","type":"8p0","by":"both","dim":100,"value":""}},
    {"ds":[
        {"name":"outDS","by":"out","dim":100,"dou":"outCount"},
        {"s":[
            {"name":"outputA","type":"7a"},
            {"name":"outputB","type":"1a"}
        ]}
    ]},
    {"s":{"name":"outCount","type":"10i0","by":"out"}},
    {"s":{"name":"last","type":"8a","by":"out"}}
]}

No output should be expected -- just created this to reproduce the error. I think it might have something to do with the "bothArray" param.

PGM JSON Output Issues

Original report by Danny Roessner (Bitbucket: droessner, GitHub: danny-hcs).


Found several issues with JSON output. I'm using this sample RPG:

#!rpg
     H AlwNull(*UsrCtl)

       dcl-ds inputDS qualified;
         in1 varchar(5:2);
         in2 varchar(5:2);
       end-ds;

       dcl-pr Main extpgm;
         inCount int(10);
         input likeds(inputDS) dim(20);
         outCount int(10);
         outputA char(10) dim(20);
         last char(20);
       end-pr;

       dcl-pi Main;
         inCount int(10);
         input likeds(inputDS) dim(20);
         outCount int(10);
         outputA char(10) dim(20);
         last char(20);
       end-pi;

       dcl-s i int(10);
       outCount = inCount;
       for i = 1 to inCount;
         outputA(i) = 'test' + %char(i);
       endfor;
       last = '"quoted" text';
       outCount = i - 1;
       return;  

Sample call:

#!javascript
{"pgm":[
    {"name":"DRTEST01",  "lib":"DROESSNER"},
    {"s": {"name":"inCount", "type":"10i0", "value":1, "by":"in"}},
    {"ds": [{"name":"inputDS","dim":20, "by": "in"},
        {"s":[
            {"name":"in1", "type":"5av2", "value":"i1"},
            {"name":"in2", "type":"5av2", "value":"i2"}
        ]}
    ]},
    {"s": {"name":"outCount", "type":"10i0", "value":1, "setlen":"outputA"}},
    {"s": {"name":"outputA", "type":"10a", "dim":20, "dou": "outCount"}},
    {"s": {"name":"last", "type":"20a", "value":"ll"}}
]}

Sample output:

#!javascript

{"script":[{"pgm":["DRTEST01","DROESSNER",{"inputDS":[[]]},{"outCount":1},{"outputA":["test1","","","","","","","","","","","","","","","","","","",""]},{"last":""quoted" text"}]}]}

Noticing the following issues from this example:

  1. inputDS specifies "by": "in", but the output still passes it back
  2. outputA array should only be the size of outCount
  3. Quotes are not escaped in strings so the output JSON is invalid

Let me know if you need me to provide any additional info.

Negative values with decimal

Original report by Sebastian Misiewicz (Bitbucket: SMisiewicz, GitHub: sebastian-misiewicz).


Hi

There seems to be an issue when converting negative values (gt > -1 and lt < 0).
Here is an example , SQL result

val.png

however when I use JSON400 query I got an error due to missing '0'

val2.png

the correct value is -0.9

val_ok.png

It might help - PaseJson.c - json_output_record_name_value

#!c

  char * fmt_key_val_zero_neg_dec = "\"%s\":-%s";

and

#!c

	 } else if (value[0] == '-' && value[1] == '.') {
	value[0] = '0';
        fmt_val = fmt_val_zero_dec;
        fmt_key_val = fmt_key_val_zero_neg_dec;				
      } else {

Regards
Sebastian Misiewicz

Make connection using ODBC

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


I'd like to make the connection to the database using ODBC. And actually I also want to run this whole thing on linux and windows machines.

We develop our PHP code on developers own machines. They run windows/linux and run the code on their own server. RPG calls happens through xmlservice and ODBC connection.

Currently libtkit400 depends on libdb400 and other ibm stuff. I guess those are not available on linux/windows, so compiling isn't currently happening.

Is there some way this could happen?

Experimental Driver - Segmentation Fault with Large Result Set

Original report by Brian Jerome (Bitbucket: bjerome, GitHub: brianmjerome).


This is an issue with the db2sock toolkit found at the bottom of the SuperDriver page.

I have test PGM that returns a large result set (DS with 15000 records). I've tested this with the db2sock toolkit (toolkitasync.js) and calling the DB2PROCJR (sql) stored procedure. The latter works fine. With the former I am getting a Segmentation fault (core dumped) when I try to return around >11000 records.

RPG

#!rpg

H AlwNull(*UsrCtl)

       dcl-ds inputDS qualified;
         in1 char(100);
         in2 char(100);
       end-ds;

       dcl-ds oDS qualified;
         o1 char(500);
         o2 char(500);
       end-ds;

       dcl-pr Main extpgm;
         inCount int(10);
         input likeds(inputDS) dim(20);
         outCount int(10);
         outputA likeds(oDS) dim(15000);
         last char(20);
       end-pr;

       dcl-pi Main;
         inCount int(10);
         input likeds(inputDS) dim(20);
         outCount int(10);
         outputA likeds(oDS) dim(15000);
         last char(20);
       end-pi;

       dcl-s i int(10);
       outCount = inCount;
       for i = 1 to inCount;
         outputA(i).o1 ='Lorem ipsum dolor sit amet, consectetur ' +
          'adipiscing elit, sed do eiusmod tempor incididunt ut ' +
          'labore et dolore magna aliqua. Ut enim ad minim veniam, ' +
          'quis nostrud exercitation ullamco laboris nisi ut ' +
          'aliquip ex ea commodo consequat. Duis aute irure dolor ' +
          'in reprehenderit in voluptate velit esse cillum dolore ' +
          'eu fugiat nulla pariatur. Excepteur sint occaecat ' +
          'cupidatat non proident, sunt in culpa qui officia ' +
          'deserunt mollit anim id est laborum.';
         outputA(i).o2 = 'value';
       endfor;
       last = '"quoted" text';
       outCount = i - 1;
       return;

Input JSON

#!json
{"pgm":[
    {"name":"DRTEST04", "lib":"BJEROME"},
    {"s": {"name":"inCount", "type":"10i0", "value":15000, "by":"in"}},
    {"ds": [{"name":"inputDS","dim":20, "by": "in"},
        {"s":[
            {"name":"in1", "type":"100a", "value":"i1"},
            {"name":"in2", "type":"100a", "value":"i2"}
        ]}
    ]},
    {"s": {"name":"outCount", "type":"10i0"}},
    {"ds": [{"name":"outputA","dim":15000, "by": "out", "dou": "outCount"},
        {"s":[
            {"name":"o1", "type":"500a", "value":"i1"},
            {"name":"o2", "type":"500a", "value":"i2"}
        ]}
    ]},
    {"s": {"name":"last", "type":"20a", "value":"ll"}}
]}

Changing the value of inCount changes the outCount value.

Changing job description

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


Is there any way you could select what job description is used when calling a program through db2sock?

I've also been toying around with _PGMCALL for faster program call. If there is a way to specify a job description for that it would be a great help.

I call _PGMCALL like this

In PaseTool.c tool_key_pgm_call_run()

  void *pgm_args[ILE_PGM_MAX_ARGS+1];
  int argc, offset, parmc;
  for (argc=0; argc < ILE_PGM_MAX_ARGS; argc++) {
    if (argc < layout->argc) {
      if (layout->argv_parm[argc] > -1) {
        parmc = layout->argv_parm[argc];
        offset = layout->arg_pos[parmc];
        pgm_args[argc] = (void *)layout + offset;
      }
    } else {
      pgm_args[argc] = NULL;
    }
  }
  char *libl = "*LIBL";
  if(tpgm->pgm_ile_lib){
    libl = tpgm->pgm_ile_lib;
  }

  ILEpointer pgm_pointer;
  int rc = _RSLOBJ2(&pgm_pointer,
                 RSLOBJ_TS_PGM,
                 tpgm->pgm_ile_name,
                 libl);

  rc = _PGMCALL(&pgm_pointer,
                (void*)&pgm_args,
                0);

Unparsable results from stored proc call

Original report by Jesse G (Bitbucket: ThePrez, GitHub: ThePrez).


I encounter a JSON parsing error when trying to run QSH commands via "CALL DB2JSON.DB2PROCJR(?)"

Position 62 seems to be the first newline, but there seem to be issues beyond that, with "R2" (row 2) starting mid-row on later records

***********************************************
*****JSON PARSE ERROR: SyntaxError: Unexpected token
 in JSON at position 62
***********
in:
{"script":[{"cmd":{"qsh":"ls -1 /QOpenSys"}}]}
********************
output (unparsable):
{"script":[{"cmd":["ls -1 /QOpenSys",{"records":[{"R1":"austin
austin.20180129.105931.tmp
austin.20180129.105949.tmp
bin
build"},{"R2":"r
c"},{"R3":"rt
c"},{"R4":"rt.crt
c"},{"R5":"rt.k"},{"R6":"y
c"},{"R7":"rt.p12
c"},{"R8":"rtificat"},{"R9":".p12
c"},{"R10":"rtificat"},{"R11":".p"},{"R12":"m
chroot1
db2sock
d"},{"R13":"v
"},{"R14":"tc
git
git."},{"R15":"nv
git.job
git.log
hom"},{"R16":"
j"},{"R17":"nkins
lib
lib64
myd"},{"R18":"bug.txt
n"},{"R19":"w_chroot
nod"},{"R20":"4
nod"},{"R21":"6
opt
pkgs
QIBM
QOp"},{"R22":"nSys
QOp"},{"R23":"nSys.bak
QSR
rang"},{"R24":"r
sbin
tmp
tools
tools-int"},{"R25":"rnal
usr
vac101
var
yum
yum2
z"},{"R26":"nd5
z"},{"R27":""}]}]}]}

The following is the actual result of running this command in an SSH terminal:


QIBM
QOpenSys
QOpenSys.bak
QSR
austin
austin.20180129.105931.tmp
austin.20180129.105949.tmp
bin
builder
cert
cert.crt
cert.key
cert.p12
certificate.p12
certificate.pem
chroot1
db2sock
dev
etc
git
git.env
git.job
git.log
home
jenkins
lib
lib64
mydebug.txt
new_chroot
node4
node6
opt
pkgs
ranger
sbin
tmp
tools
tools-internal
usr
vac101
var
yum
yum2
zend5
zend7

Buffer with garbage could cause problems

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


If the toolkit is given a non empty buffer the output will include content of this buffer.

This can be fixed by not taking the output length with strlen and just going with our counter. FIX and test

Note: My silly test overflows the buffer when the fix isn't applied. Maybe there should be a check for that overflow?

$ ./test0100_outjson_garbage_buffer32                                 
input(97):            
{"pgm":[{"name":"HELLO","lib":"DB2JSON"},{"s":{"name":"char","type":"128a","value":"Hi there"}}]}
output(587):          
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXޭ"script":[{"pgm":["HELLO","DB2JSON",{"char":"Hello World"}]}]}

result:               
fail found(X)         
fail (-1)             
Segmentation fault (core dumped)

PHP db_connect problems

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


I seem to have some weird problems when using db2sock libdb400.a and trying to connect to database using PHP db_connect.

This script fails when it is called through a running web server.

<?php

$db = "*LOCAL";
$user = "USER";
$password = "PASSWORD";
$options = array();
$result = db2_connect($db, $user, $password, $options);
var_dump($result);
if($result){
    db2_close($result);
}

Error it gives is this, https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/codes/src/tpc/n950.html

[08-Feb-2018 09:32:16 Europe/Helsinki] PHP Warning:  db2_connect(): Connection failure userid (THA) in /www/zendphp7/htdocs/dbconnect.php on line 7
[08-Feb-2018 09:32:16 Europe/Helsinki] PHP Warning:  db2_connect(): Relaatiotietokantaa *LOCAL ei ole relaatiotietokantahakemistossa. SQLCODE=-950 in /www/zendphp7/htdocs/dbconnect.php on line 7

It works correctly if running straight from the command line

$ /usr/local/zendphp7/bin/php dbconnect.php                      
resource(4) of type (DB2 Connection)

It also works through the web server when I change libdb400.a back to the original.

Are you able to reproduce this problem?

Multiple action execution order not guaranteed

Original report by me.


Due to the format of the JSON that db2sock uses, it seems that when specifying multiple actions there is no way to ensure the actions will be performed in a specific order. The problem is that it uses the key in the parent object to define the action to be performed, but JSON keys are not defined to be in a specified order. Thus when it is parsed, it could be executed in any order:

eg. The following json could call DB2JSON/HELLO or some other HELLO:

{
	"cmd": {
		"exec": "ADDLIBLE DB2JSON"
	},
	"pgm": [{
			"name": "HELLO"
		},
		{
			"s": {
				"name": "char",
				"type": "128a",
				"value": "Hi there"
			}
		}
	]
}

Crash when parsing a big json file

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


If I try to parse this json file the toolkit crashes. This is the same test as j0185 except it has newlines and spaces removed.

It crashes because bigkey->count isn't incremented when bigkey is expanded and this mismatch compounds over time and things start to crash. The normal version isn't crashing because the count is incremented on empty chars, so the bigkey will grow (unnecessarily) and we have enough room to put all the real values.

By discarding the empty chars (code) the normal version will also crash.

To fix this crash we can apply this fix.

Other way and maybe better, so we don't need the empty char stuff, might be this fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.