Table of Contents
VField objects have flags which can modify its behavior or state. You can specify field flags on field creation. Flags are numeric constants that can be combined with bitwise OR.
- fNone - zero, the field does not have any flag.
- fNullable - specifies that a field is Nullable, i.e. should accept NULL values.
- fIndexed - specifies that a field should have an index.
- fUnique - specifies that a field should have a unique index, i.e. the field will not accept duplicate values.
- fIndexByWords - specifies that a field should have an index by words.
- fCompressed - specifies that a BLOB field should compress its data.
- fMethod - specifies that this is a calculated field - method. [Read-Only]
- fIdenity - specifies that this field should automatically generate a value for a new record.
- fTemporary - specifies that this field is temporary.
When this flag is ON the field can accept NULL values. To be able do this, one additional bit is used for each value of this column.
You can runtime set this flag ON/OFF. If you set it OFF, be aware that you loose all your NULL values, which are converted into ZERO for numeric columns and empty strings for String columns.
Note that the flags fUnique and fIndexByWords play the role of an Index Modifier. You can have the following combinations of flags:
fIndexed - "normal" index fIndexed + fUnique - unique index fIndexed + fIndexByWords - index by words
When you specify that a field must be UNIQUE, Valentina creates a special kind of index. If you try to insert a new record with a duplicate value the unique index will refuse it.
If you have specified a field to be Unique, Valentina itself makes sure that the flag fIndex also is ON. You even cannot set the flag fIndexed to be OFF. This is prohibited because without the index, there is no way to protect the field from a duplicate insert. This fact was one of the main reasons to introduce the VField.Reindex() function, allowing developers to force reindex.
Note, that UNIQUE field still can be Nullable. NULL values do not go into index and do not cause any conflicts.
This modifier is less strict than fUnique. You can create a field with only the flag fIndexBywords, and the index itself will not be created yet. Or you can set OFF the fIndexed flag, while the modifier fIndexByWords still is ON.
The following table shows what happens if you apply a field flag depending on inital state of field. Action e.g. “+I” means that flag fIndexed was set ON. Column “Engine ACtion” show operation(s) that engine must proceed to execute this action.
|Initial State||Action||Final State||Engine Action|
|fNone||+U||U||BUILD UNIQUE INDEX|
|fNone||+I +U||I U||BUILD UNIQUE INDEX|
|fNone||+I +W||I W||BUILD INDEX BY WORDS|
|I U||-I||I U||NOTHING|
|I + W||-I||W||DROP INDEX|
|I + W||-W||I||REINDEX|
|W||+I||I W||BUILD INDEX BY WORDS|
This flag can only be used with BLOB columns. When it is ON, the BLOB field compresses its data before writing to disk. Actually this flag is useful mainly if the BLOB field can have an index, e.g. a TEXT field.
You cannot change this flag runtime (at least not in the current version).
This flag is read only and can be used e.g. in loops when you need to find only Method fields. This flag is set ON when you create a field and specify a Method Text for it.
This flag is set ON when you create a field and declare it to be an IDENTITY field.
This flag is set ON when you create a Temporary Table automatically.
Also you can specify this flag on field creatio to create in an existed Table temporary field. This is quite unique feature of Valentina database. Such temporary field will be stored in the .tmp hidden volume and it will NOT be stored in the system tables at all. So in case of system failure your main database files are not affected.