mridoni / gixsql

GixSQL is an ESQL preprocessor and a series of runtime libraries to enable GnuCOBOL to access PostgreSQL, ODBC, MySQL, Oracle and SQLite databases.
GNU General Public License v3.0
16 stars 8 forks source link

not possible to insert binary data (including low-value) or UTF16 #125

Closed GitMensch closed 1 year ago

GitMensch commented 2 years ago

Using a code like

           MOVE x'0001020304' TO BUFFER-ARR.
           MOVE 5 TO BUFFER-LEN.
      *
           EXEC SQL AT :DBS
              SELECT lowrite (0, :BUFFER)
                     INTO :RESINT
                     FROM TAB WHERE TABID= :TABID
           END-EXEC.

Can not work in libgixsql-pg (possibly also in others) because DbInterfacePGSQL::_pgsql_exec_params uses pvals[i] = (char*)paramValues.at(i).c_str(); - where the return would be be an empty string because of the leading low-value.

This would also be very bad for utf16 content like n"35" - which is x'00330035`.

Note: I do not need that for a current project (actually PIC N / PIC U is to be tested "soon" but I guess that's not supported either at all [it seems to be supported "in general" in gixpp and libgixsql's SqlVar] or in the PG driver), but stumbled over it during debugging.

If this isn't likely to come soon I'd suggest to leave a note in the README about the current support of:

It would be totally reasonable to only allow binary data with a special USAGE or EXEC SQL VAR definition. That would obviously be given for PIC U and PIC N.

mridoni commented 1 year ago

For the PostgreSQL driver, this should be solved in the v1.0.20dev branch with b859affdff7aa5769ed7a834a5c57aa221ec86ff and ad62ffb1bd3658fdce118076362944f570096f6f

Still working on the implementation for the other drivers.

mridoni commented 1 year ago

Solved for the other drivers in the v1.0.20dev branch and in the post-merge main branch, at least for binary data.

UTF16 was not tested. Given that I wanted to add and/or test specific support for correctly handling different charsets I am probably testing and adding specific support after the release of v1.0.20. I will open a new charset-specific issue and close this one.

GitMensch commented 1 year ago

Any idea when the first 1.0.20 preview release is available? BTW: GC's 3.2rc1 should be today.

mridoni commented 1 year ago

Any idea when the first 1.0.20 preview release is available?

I am re-running the packaging and test scripts, there are a few things that need fixing. I guess a pre-release (packages) could be coming by the beginning of next week. Then I need to update the documentation and write the new docs for the test suite, that will require a few more days, depending, as usual, on my day-job.

The v1.0.20dev branch itself is now building from source on Linux, I will complete this round of build-related fixes in the v1.0.20dev branch and, as soon as binary packages can be successfully built and the tests pass inside my Github Actions workflow, I will re-merge this set of modifications into the main branch: unfortunately is a time-consuming process, with many small adjustments here and there.

GitMensch commented 1 year ago

unfortunately is a time-consuming process, with many small adjustments here and there

Yes, I totally know how that feels :-)

mridoni commented 1 year ago

This is nice :smile:

image