-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
FR: support EXEC SQL VAR #21
Comments
Things that this will be useful for:
|
Introduced in v1.0.8 |
Did not found the option to test that, but the parser looks good.
To fully support that (if in question then possibly with a warning "pending feature") the optional items need to be added - you already were so clever to do it in the lexer for the "length", the piece missing (not at all important for me) is the "precision, scale" format. Also missing are the external types: Note: for Oracle |
Yes, I intend to do that
Currently it's the first one (implicit -LEN and -ARR sub-fields) |
To be more clear: the length parameter as it is written already supports passing precision and scale : they are encoded as 16 bits integers shifted into a 64 bit int which is passed between the various definitions in the parser. I just need to implement the types and test. |
OK, that matches the Oracle definition. Please add VARCHAR2, too :-) And: Big thanks for your work on GixSQL - I hope the time invested in testing, issue and PR creation is at least a slight motivation to go on. |
Of course it is. I made some modifications in the parser: the cursor handling part was not really a work of art, but it was one of the first things I put together when I started fiddling with my modifications to ocesql 3 or 4 years ago (they were just that at the time) and I didn't know the then-current codebase, so I didn't want to change too much. I have reorganized that part and a lot more stuff in the parser/scanner, so it is now cleaner and more maintainable. This will obviously need a lot of testing to avoid regressions, and this is why I still cannot give a timeline for the next release, but we are getting there. |
Reopening to keep track of the modifications on EXEC SQL VAR and the implementation of VARCHAR2 |
By the way: maybe I am missing something but Visual COBOL (at least v6.0) seems to ignore the EXEC SQL VAR declarations. They are parsed but no actual check seems to take place. In the following source snippet:
the compiler doesn't catch three quite obvious errors:
As I said I might very well be missing something. |
|
Mostly done, except for |
Started to check with some ProCOB targetted code, result:
This is a check that is not happening with ProCOB. Maybe it can be lowered to a warning instead? If the 01/77 is needed for the |
OK, GixSQL has no issue with the bind parameters being level 05 either, so I think that error message should only - if at all - happen if it defines an implicit variable length structure - but even then this seems questionable. Note: this is not a show-stopper for me currently, can also be handled "correctly" later if that would mean much work. |
This is currently more a limitation in the runtime library, that expects host variables to be a top-level group with level 01. I have to check in there to assess the impact. For context: the "level 01" assumption/limitation was ok for the code I was porting and allowed me to develop faster, but obviously it must be removed now . |
That doesn't seem like the case, because the following (peudocode) works fine: 01 some-rec.
05 some-value1 pic xxxx.
05 some-value2 pic 99.
EXEC SQL
SELECT A, B FROM X WHERE val1 = :some-value1 val2 = :some-value2
END-EXEC ... or I did not understand what you've said, also possible. |
More likely: I don't remember it well, but I will look into it |
- Fixed "More formats for connect" (#43) - Fixed "length/power issues with COMP-3 (#92)" (and zoned TC/LS) - Fixed "pass postgres cast operator as token (#93)" - Fixed "Long queries break COBOL compiler" (#89) - Fixed (partially) "GixSQL 1.0.9 compiler warnings" (#53) - Fixed a couple of regressions for "support EXEC SQL VAR" (#47) - Fixed "add OCCURS UNBOUNDED (#80)
- Gix-IDE: fixed additional compiler/linker parameters in project properties - Gix-IDE: fixed working directory for running/debugged project (Linux) - GixSQL: Fixed "More formats for connect" (#43) - GixSQL: Fixed "length/power issues with COMP-3 (#92)" (and zoned TC/LS) - GixSQL: Fixed "pass postgres cast operator as token (#93)" - GixSQL: Fixed "Long queries break COBOL compiler" (#89) - GixSQL: Fixed (partially) "GixSQL 1.0.9 compiler warnings" (#53) - GixSQL: Fixed a couple of regressions for "support EXEC SQL VAR" (#47) - GixSQL: Fixed "add OCCURS UNBOUNDED (#80) - GixSQL: Fixed several parser problems - GixSQL: Fixed error reporting bugs (wrong/invalid location of the error) - GixSQL: Fixed "prevent excessive filename conversions to absolute path" (merged PR45) - GixSQL: Fixed "DbInterfacePGSQL::get_resultset_value C string handling" (merged PR85) - GixSQL: Fixed "DbInterfacePGSQL cstring -> std::string" (merged PR86) - GixSQL: Fixed a problem with cursors in "add support for multiple connections" (#44) - GixSQL: Fixed "outputs too many periods - breaks code flow" (#82) - GixSQL: Fixed allocation of "realdata" buffer"
@mridoni Any update for |
Leaving a ping on |
That's the next item on my list for GixSQL. Just one thing: in the Oracle documentation I couldn't actually find a difference between And from what I see PostgreSQL does not directly support |
I think that For Oracle the difference in the preprocessor is, that VARCHAR2 is right-trimmed (see link in the opening post):
(and on reading in VARCHAR2 are blank padded again to be of the expected COBOL size and type). |
From my understanding that's correct for VARCHAR2, but defining a variable as VARCHAR in ProCOB leads to be identical to |
Ok, I'll do a test with ProCOB (and report the results here): I have just re-read the documentation and, while it is very detailed on the behaviour of VARCHAR VARCHAR2 On Input. Oracle reads the number of bytes specified for the input host variable, strips On Output. Oracle returns the number of bytes specified for the output host variable, If the output value is longer than the declared length of the host variable, Oracle |
Thanks for the note, and yes, I'm not sure about VARCHAR2 vs. VARCHAR any more. My potential confusion on this may root in https://docs.oracle.com/cd/B13789_01/appdev.101/a96109/pco14opt.htm with VARCHAR2 notes about trailing space part and VARCHAR about the group. Thanks for testing, looking forward to see this in 1.0.80! |
This is "almost" done. "Almost" means that the the feature per se works, but it casually exposed a bug in generation of string constants. I am trying to resolve that, than I will release the modified code to the GitHub repository.
|
I'm confused - that would mean it is current a global setting, no? That sound very likely to break existing data in keyfelds as "keyfield " != "keyfield". The whole point of |
Ok, I will look into it again |
I will try to test with ProCOBOL but if there is no difference between VARCHAR and VARCHAR2, as I suspect, how do you suggest to proceed? Just throwing ideas around here: I could implement a different behaviour for VARCHAR and VARCHAR2, but this would be absolutely non-standard, and VARCHAR2 is an Oracle-only thing anyway, since in EDB it is apparently just a synonym for VARCHAR. Since every preprocessor, for many reasons, does things a little bit differently, is there a way this could be implemented without using VARCHAR2, but instead using a different syntax? Thanks |
Then just do the same, using it as Oracle synonym. The important difference is between VARCHAR and CHARF (with CHARF being the default). If I remember correctly there was a switch with procob to say "if the variable type is not explicit specified: change the default type from CHARF to VARCHAR (preprocessor switch, not connection option)". You may want to add something similar instead of the connection option.
Supporting the existing variants - if necessary with a new switch to gixsql - is a very useful goal. :-) |
This gets even weirder. Oracle also says (look here, page 44):
This is obviously not applicable to other DBMSs, including PostgreSQL, but explains why Oracle treats In the meantime, while experimenting with ProCOBOL, I have found out the following things. They might just be details I was missing, but I am listing them anyway:
|
BTW: this restriction (using EXEC SQL VAR declarations as specifiers and not autogenerating variable length groups from an I think I will be heading this way (and of course adding to gixpp a switch similar to PICX=… .
This restriction would make preprocessing easier and more linear, even if support for handling variables declared in the “wrong” order is already there. I have to check whether it is still needed. |
Agreed - if it does make things easier and is necessary for at least one option/code path: go that way. |
I am working on this but at the moment is unlikely it will see the light this week: unfortunately I need to test and re-test a lot of stuff and the pre-release I had in mind is probably going to slide, also depending on my day-job. |
#88 is the most important and alone would be definitely enough for a pre-release version; but don't feel any pressure. |
The version in the internal repository should now be working as defined in #21 (comment).
|
This is a maintenance pre-release for GixSQL. It fixes a few issues and adds two new databases drivers (Oracle and SQLite). The next "standard" release (presumably v1.0.18) will have feature parity for all database drivers. - Added new Oracle driver, based on ODPI - Added new SQLite driver - Solution for "PG: issue with prepared statements" (#99) - Solution for "PCursors cannot be re-opened after close" (#98) - Solution for "libgixpp: setStatus is called for errors without DBI parm passed - sets SQLERRM" (#94) - Solution for "error handling (especially for 07001)" (#92) - Solution for "show-stopper bug in pgsql_prepare" (#91) - Solution for "PREPARE does not work with VARLENGTH groups (ocesql compat)" (#79) - Partial solution for "PREPARE does not work with VARLENGTH groups (ocesql compat)" (#68) - Solution for "The PostgreSQL driver needs START TRANSACTION before using cursors" (#14) - Solution for "FR: support EXEC SQL VAR" (#21) - Fixed a bug in "problems with "codegen / logic issue for "GIXSQLCursorDeclareParams" (#88) - Fixed COMP-3 handling in drivers other than PostgreSQL - Rewrote the test suite (still MSTest-based) to dynamically generate a matrix of test to be run on the various platforms/database drivers
- Added new Oracle driver, based on ODPI - Added new SQLite driver - All the drivers have been updated and now implement the complete set of supported features - Solution for "PG: issue with prepared statements" (#99) - Solution for "PCursors cannot be re-opened after close" (#98) - Solution for "libgixpp: setStatus is called for errors without DBI parm passed - sets SQLERRM" (#94) - Solution for "error handling (especially for 07001)" (#92) - Solution for "show-stopper bug in pgsql_prepare" (#91) - Solution for "PREPARE does not work with VARLENGTH groups (ocesql compat)" (#79) - Partial solution for "PREPARE does not work with VARLENGTH groups (ocesql compat)" (#68) - Solution for "The PostgreSQL driver needs START TRANSACTION before using cursors" (#14) - Solution for "FR: support EXEC SQL VAR" (#21) - Fixed a bug in "problems with "codegen / logic issue for "GIXSQLCursorDeclareParams" (#88) - Solution for "FR: allow mapping of "NoRecCode"' (#95) - added --no-rec-code parameter to gixpp - Tokens in the parser have been labeled to improve diagnostics (pulled PR #96 by @GitMensch) - Fixed COMP-3 handling in drivers other than PostgreSQL - Rewrote the test suite (still MSTest-based) to dynamically generate a matrix of test to be run on the various platforms/database drivers - Added options for parameter generation in gixpp (-a was removed) - Added new GIXSQL_FIXUP_PARAMS option for runtime, to automatically convert parameter format in prepared statments - "Native" cursors are now the default for the PostgreSQL driver - "Smart" cursor initialization is now the default for all cursors, including those declared in WORKING-STORAGE (-L was removed from gixpp), should fix #101 - Removed dynamic cursor emulation from the ODBC driver when using PostgreSQL
What is open in this issue? |
I see that there is no explicit handling of gixsql/runtime/libgixsql/SqlVar.cpp Lines 261 to 279 in debeeea
Does this mean that one still has both separate -ARR and -LEN fields with the manual setting of the length (presumably using |
I tried to impllement the same behavior as ProCOBOL (see my previous comment) so the |
For some reasons I've not looked that well... gixsql/runtime/libgixsql/SqlVar.cpp Lines 265 to 268 in debeeea
I guess autotrim is set with IS VARCHAR2 , correct? If the answer is yes, then this works "as planned", if not then it should be.
|
Yes, on the preprocessor side it is set here: gixsql/libgixpp/TPESQLProcessing.cpp Lines 1225 to 1226 in debeeea
Some of this stuff will have to change to account for #125, that I have not started to work on. As I refactored the runtime libraries to use smart pointers, I am also trying to "C++ize" the interface and code a bit more, and trying to eliminate some dead/old/dangerous/ code) so it will be at least a week until I can start to work on it. |
From the README it looks like VARCHAR2 (=like varchar but with auto-trim instead of manually calculating the length) is still not available, while the code above looks like it is. I did not found a testcase with VARCHAR2. Is there anything else open for |
On other thing found to be open: EXEC SQL VAR TABKEY1 IS CHARF END-EXEC. raises
maybe this can this be used at least at a syntactical level as an alias for |
... but something is strange here: EXEC SQL VAR BUFFER IS RAW (20200) END-EXEC. raises (1.0.20 and 1.0.20b - both installed from tarball and showing the expected version):
|
I guess that further adjustments will take a while, but as I've just seen that again... friendly ping on CHARF and "unexpected FLOAT". |
Add EXEC SQL VAR statements - Example:
EXEC SQL VAR SOME-ID IS CHAR END-EXEC.
Currently this leads to a syntax error.
Some details are noted in ProCOB docs.
The text was updated successfully, but these errors were encountered: