kadler / db2sock-test

1 stars 0 forks source link

Useless empty DS data when counter = 0 #32

Closed kadler closed 6 years ago

kadler commented 6 years ago

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


When a DS has a counter value of 0 it will return a bunch of blank useless data up to the dim specified. It should return an empty DS with 0 records.

You can use the same test PGM from Issue #30. The result set is too large to paste here.

kadler commented 6 years ago

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


Thanks! Looks better now.

kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


Ok, I have a new version that should fix your missing open bracket.

You probably are not running latest db2sock code.

I also added a version json feature.

#!bash

bash-4.3$ ./test4000_sql400json_procj32 ../json/j9101_admin_version
input(5000000):
{"admin":[{"info":"version"}]}

output(49):
{"script":[{"admin":[{"version":"1.1.4-sg13"}]}]}

result:
success (0)
kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


... with a missing open bracket

I may have found this ... wait a moment for new version.

kadler commented 6 years ago

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


Got it running correctly now. Tried it on a few other PGMs and having an issue with a missing open bracket:

#!json

{"script":[{"pgm":["PGMNAME","PGMLIB",{"DSCOUNT":0},{"DS":]}]}]}

It might have something to do with the DS being both input and output, but will have to try creating a test PGM to reproduce.

kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


can this change also be added to the experimental driver?

For clarity, changes in db2sock are not directly tied to experimental node driver. Aka, db2sock is the driver for node db2ia ( under/below node db2ia).

Works fine for me (below). You probably are not running latest db2sock code. Speculation includes, not ftp new files to IBM i, or, perhaps installed wrong directory for node to see, or .. and number of user errors.

#!bash

bash-4.3$ node toobigtozero.js 
input:
{"pgm":[
    {"name":"DANNY04", "lib":"DB2JSON"},
    {"s": {"name":"inCount", "type":"10i0", "value":0, "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"}}
]}
so big = 643

output:
{"script":[{"pgm":["DANNY04","DB2JSON",
{"outCount":0},
{"outputA":[]},
{"last":"\"quoted\" text"}]}]}
so big = 99
kadler commented 6 years ago

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


Looks good, but can this change also be added to the experimental driver? I tried running the input with toolkitasync and it gives me all the blank data still.

kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


Ok, extra record pest has been eliminated (i think). Give a try.

#!bash

bash-4.3$ ./test4000_sql400json_procj64 ../json/j0169_pgm_danny04-ds_dou_zero
input(5000000):
{"pgm":[
    {"name":"DANNY04", "lib":"DB2JSON"},
    {"s": {"name":"inCount", "type":"10i0", "value":0, "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"}}
]}

output(99):
{"script":[{"pgm":["DANNY04","DB2JSON",
{"outCount":0},
{"outputA":[]},
{"last":"\"quoted\" text"}]}]}

result:
success (0)
kadler commented 6 years ago

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


Almost..

I changed the JSON input to

#!json

{"pgm":[
    {"name":"DRTEST04", "lib":"BJEROME"},
    {"s": {"name":"inCount", "type":"10i0", "value":0, "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"},
            {"name":"o2", "type":"500a"}
        ]}
    ]},
    {"s": {"name":"last", "type":"20a", "value":"ll"}}
]}

Still got one record in outputA:

#!json

{"script":[{"pgm":["DRTEST04","BJEROME",{"outCount":0},{"outputA":[[{"o1":""},{"o2":""}]]},{"last":"\"quoted\" text"}]}]}

I'm expecting:

#!json

{"script":[{"pgm":["DRTEST04","BJEROME",{"outCount":0},{"outputA":[]},{"last":"\"quoted\" text"}]}]}
kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


... counter value of 0 it will return a bunch of blank useless data ...

Ok, made a change to allow for zero count dou in ds array

#!bash

bash-4.3$ ./test1000_sql400json32 ../json/j0169_pgm_danny04-ds_dou_zero            
input(5000000):
{"pgm":[
    {"name":"DANNY04", "lib":"DB2JSON"},
    {"s": {"name":"inCount", "type":"10i0", "value":0, "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"}}
]}

output(124):
{"script":[{"pgm":["DANNY04","DB2JSON",
{"outCount":0},
{"outputA":[[{"o1":"i1"},{"o2":"i2"}]]},
{"last":"\"quoted\" text"}]}]}

result:
success (0)