Skip to content
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 for VARLEN fields with different size #54

Open
GitMensch opened this issue May 22, 2022 · 4 comments
Open

FR: Support for VARLEN fields with different size #54

GitMensch opened this issue May 22, 2022 · 4 comments

Comments

@GitMensch
Copy link
Contributor

GitMensch commented May 22, 2022

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

// These must be in sync with the ones in SqlVar.h
#ifdef USE_VARLEN_32
#define VARLEN_LENGTH_PIC "9(8) COMP-5"
#define VARLEN_PIC_SZ 9
#define VARLEN_LENGTH_SZ 4
#define VARLEN_LENGTH_T uint32_t
#define VARLEN_BSWAP COB_BSWAP_32
#else
#define VARLEN_LENGTH_PIC "9(4) COMP-5"
#define VARLEN_PIC_SZ 4
#define VARLEN_LENGTH_SZ 2
#define VARLEN_LENGTH_T uint16_t
#define VARLEN_BSWAP COB_BSWAP_16
#endif

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 #38 (comment)

So things to do:

  • support both 2 and 4 byte sizes in the runtime together, likely adding an internal type
  • adjust the preprocessor to insert the matching type when explicit specified via EXEX SQL VAR and to use the 4byte type for VARYING groups which extend the 2byte size
@GitMensch
Copy link
Contributor Author

GitMensch commented May 23, 2022

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
Copy link
Owner

mridoni commented May 23, 2022

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
Copy link
Contributor Author

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
Copy link
Owner

mridoni commented Sep 9, 2023

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".

mridoni added a commit that referenced this issue Sep 9, 2023
- Logs can be rotated (parameters are: GIXSQL_LOG_ROTATE, GIXSQL_LOG_ROTATE_MAX_SIZE, GIXSQL_LOG_ROTATE_MAX_FILES, more documentation will follow)
- The size of indicator for VARYING fields can be set at runtime with an environment variable (GIXSQL_VARYING_LEN_SZ_SHORT) that must coincide with the size specifying when preprocessing (a new parameter -N/--varying-length-size has been added to gixpp). See here: #54 (comment)
- The handling of continuation lines has been fixed
- Several pull requests by @GitMensch have been merged (thanks!!) that fix some memory bugs here and there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants