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

FR: Support for VARLEN fields with different size #54

Open GitMensch opened 2 years ago

GitMensch commented 2 years ago

The size of sub-items to store the length of variable-length-fields can be currently chosen at compile-time like this:

https://github.com/mridoni/gixsql/blob/f28e208bea487b91c159ecd50023fe764bbb034b/libgixpp/TPESQLProcessing.cpp#L107-L120

The problem is that short/long field length indicators cannot be currently mixed, so in practice there is no difference between VARCHAR and LONG VARCHAR, provided that you define USE_VARLEN_32 (except at declaration time, where I think LONG VARCHAR is still not supported, so you have to use standard VARCHAR).

Originally posted by @mridoni in https://github.com/mridoni/gixsql/issues/38#issuecomment-1117389355

So things to do:

GitMensch commented 2 years ago

Rechecked: OCESQL uses the following:

#define OCDB_VARCHAR_HEADER_BYTE 4 // size of PIC S9(8) COMP-5`

So I do wonder: Shouldn't USE_VARLEN_32 be the default as long as there's a fixed varlen only?

mridoni commented 2 years ago

So I do wonder: Shouldn't USE_VARLEN_32 be the default as long as there's a fixed varlen only?

Yes, that's probably for the better, I'll add this to the next batch of fixes.

GitMensch commented 1 year ago

Should the "variable" support instead of GixSQL compile time be in the backlog or planned for a version? For now I have no need for it, just want to get some overview where GixSQL stands and what issues are "in progress".

mridoni commented 1 year ago

This will be partially solved in v1.0.21dev (to be released in about a week). It will be possible to specify the size of the length indicator both during preprocessing and at runtime (with an environment variable). It is a stopgap but at least it allows for different indicator field sizes without having to recompile (or use a separate version of) GixSQL. This will be definitely fixed by adding a flag to the ones currently passed to define SQL parameters (along with type, size, etc.) but I don't know if it will be possible for v1.0.21 "final".