Switch to: V9V8V7V6V5

VField Flags

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.
  • fIndexHashed - specifies that a field should have a hash index.
  • fIndexByWords - specifies that a field should have an index by words.
  • fIndexUnique - specifies that a field should have a unique index, i.e. the field will not accept duplicate values.
  • fCompressed - specifies that a BLOB field should compress its data.
  • fIdenity - specifies that this field should automatically generate a value for a new record.
  • fMethod - specifies that this is a calculated field - method. [Read-Only]
  • fTemporary - specifies that this field is temporary.

fNullable flag

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.

Index Modifiers

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

fIndexUnique flag

When you specify that a field must be UNIQUE, Valentina DB 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 DB 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.

fIndexHash flag

[NEW in v5.6]

This flag changes the type of index to be hash index. Can be used in combination with fIndexUnique.

fIndexByWords flag

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.

Switching states

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 +I I BUILD INDEX
fNone +U I U BUILD UNIQUE INDEX
fNone +I +U I U BUILD UNIQUE INDEX
fNone +W W NOTHING
fNone +I +W I W BUILD INDEX BY WORDS
fNone +U +W fNone ERROR
I +U I U REINDEX
I +W I W REINDEX
I U -I I U NOTHING
I U -U I REINDEX
I + W -I W DROP INDEX
I + W -W I REINDEX
W +I I W BUILD INDEX BY WORDS

fCompressed flag

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

fMethod flag

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.

fIdentity flag

This flag is set ON when you create a field and declare it to be an IDENTITY field.

In Valentina DB such field just repeat RecID values, i.e. values can be reused. This was added to simplify transform of existed databases made with other DBMS.

To have not repeated values, prefer to use Sequences. Check Serial Types and CREATE SEQUENCE

fTemporary flag

This flag is set ON when you create a Temporary Table automatically.

Also you can specify this flag on field creation 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.