Irgendetwas stimmt in den Quellcode-Kommentaren nicht.
Zitat aus der vdbeInt.h:
/*
** Internally, the vdbe manipulates nearly all SQL values as Mem
** structures. Each Mem struct may cache multiple representations (string,
** integer etc.) of the same value. A value (and therefore Mem structure)
** has the following properties:
**
** Each value has a manifest type. The manifest type of the value stored
** in a Mem struct is returned by the MemType(Mem*) macro. The type is
** one of SQLITE_NULL, SQLITE_INTEGER, SQLITE_REAL SQLITE_FLOAT, SQLITE_TEXT or
** SQLITE_BLOB.
*/
struct Mem {
i64 i; /* Integer value */
int n; /* Number of characters in string value, including '\0' */
u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
u8 type; /* One of MEM_Null, MEM_Str
SQLITE_NULL, SQLITE_TEXT, etc. */
u8 enc; /* TEXT_Utf8, TEXT_Utf16le, or TEXT_Utf16be
SQLITE_UTF8, SQLITE_UTF16BE or SQLITE_UTF16LE */
double r; /* Real value */
char *z; /* String or BLOB value */
void (*xDel)(void *); /* If not null, call this function to delete Mem.z */
char zShort[NBFS]; /* Space for short strings */
};
typedef struct Mem Mem
Ich habe da schonmal ein paar Sachen berichtigt und ergänzt. Es ist so, dass
Member
type
genau einen Wert annimmt. Den Typ nämlich, den man
speichern will (Zahl, Text etc.) - den Datentyp der jeweiligen Spalte der Tabelle. Member
flags
gibt an, welche Werte
tatsächlich alles angegeben/gespeichert/hinterlegt sind (String, Int, Float); welche Member gültig sind (
i
,
z
/
zShort
,
r
).
TEXT_Utf8
,
TEXT_Utf16le
und
TEXT_Utf16be
, die als
enc
angegeben können werden sollen, existieren einfach überhaupt nicht.
Die
möglichen Werte für
type
sind:
/*
** Values are stored in the database in one of the following fundamental
** types.
*/
#define SQLITE_INTEGER 1
#define SQLITE_FLOAT 2
/* #define SQLITE_TEXT 3 // See below */
#define SQLITE_BLOB 4
#define SQLITE_NULL 5
/*
** SQLite version 2 defines SQLITE_TEXT differently. To allow both
** version 2 and version 3 to be included, undefine them both if a
** conflict is seen. Define SQLITE3_TEXT to be the version 3 value.
*/
#ifdef SQLITE_TEXT
# undef SQLITE_TEXT
#else
# define SQLITE_TEXT 3
#endif
#define SQLITE3_TEXT 3
Dieser Typ wird beispielsweise beim Aufruf von
sqlite3_column_type(...)
oder
sqlite3_value_type(...)
zurückgegeben.
MEM_Null
,
MEM_Str
o.ä. sind hier unzulässig; auch wenn es in der vdbeInt.h im Kommentar steht.
Die
möglichen Werte für
flags
sind:
/*
** Multiple of these values can appear in Mem.flags. But only one
** at a time can appear in Mem.type.
*/
#define MEM_Null 0x0001 /* Value is NULL */
#define MEM_Str 0x0002 /* Value is a string */
#define MEM_Int 0x0004 /* Value is an integer */
#define MEM_Real 0x0008 /* Value is a real number */
#define MEM_Blob 0x0010 /* Value is a BLOB */
/*
** Whenever Mem contains a valid string or blob representation, one of
** the following flags must be set to determine the memory management
** policy for Mem.z. The MEM_Term flag tells us whether or not the
** string is \000 or \u0000 terminated
*/
#define MEM_Term 0x0020 /* String rep is nul terminated */
#define MEM_Dyn 0x0040 /* Need to call sqliteFree() on Mem.z */
#define MEM_Static 0x0080 /* Mem.z points to a static string */
#define MEM_Ephem 0x0100 /* Mem.z points to an ephemeral string */
#define MEM_Short 0x0200 /* Mem.z points to Mem.zShort */
Hier habe ich wieder einen Kommentar durchgestrichen. Soweit mir ersichtlich ist, kann nämlich
keiner dieser Werte als
type
angegeben werden und wird im Code auch
nicht als
type
verwendet.
Ich hatte dazu auch in der SQLite-Mailingliste gepostet:
http://permalink.gmane.org/gmane.comp.db.sqlite.general/11198