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

Fully support variable sized fields like varchar or varbinary #26

Closed
Valentin-Kaiser opened this issue Oct 11, 2022 · 0 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@Valentin-Kaiser
Copy link
Owner

Varchars need special handling

Varchar can be up to 254 characters (always stored with constant size)

To retrieve the size of the Varchar

The _NullFlags column of the Table needs to be checked. (it's a hidden system column)
Tables that contain a varchar always contain the _NullFlags column.
Depending on, if the null-Flag for the varchar field is set, length is stored in the last byte of the field.
If the length is 0 the value should be interpreted as empty.

For each Varchar and Varbinary field, one bit, or "varlength" bit, is allocated in the last system field, which is a hidden field and stores the null status for all fields that can be null. If the Varchar or Varbinary field can be null, the null bit follows the "varlength" bit. If the "varlength" bit is set to 1, the length of the actual field value length is stored in the last byte of the field. Otherwise, if the bit is set to 0, length of the value is equal to the field size.
https://learn.microsoft.com/en-us/previous-versions/visualstudio/foxpro/st4a0s68(v=vs.80)#table-header-record-structure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant