Difference between revisions of "MonetDB type system"

From MonetDB
Jump to navigationJump to search
(Created page with "{| class="wikitable" style="text-align: center;" |+ MonetDB type system |- ! SQL !! MAL !! C !! width <br> [byte] ([bit]) !! signed? !! range <br> ("raw")...")
 
Line 1: Line 1:
 +
* '''''Rule #1'''''
 +
** ''monetdb_config.h '''must''' be the '''first''' #include in '''each''' .c file ('''not''' in any .h file).''
 +
 +
* '''''Rule #2'''''
 +
** C types ''long'' & ''unsigned long'' are '''evil''' and '''must NOT be used'''; while they are 32/64-bit on 32/64-bit systems under Unix, ''they are '''always 32-bit''' (also on 64-bit systems) under '''Windows'''''.
 +
 
{| class="wikitable" style="text-align: center;"
 
{| class="wikitable" style="text-align: center;"
 
|+ MonetDB type system
 
|+ MonetDB type system

Revision as of 18:16, 6 October 2015

  • Rule #1
    • monetdb_config.h must be the first #include in each .c file (not in any .h file).
  • Rule #2
    • C types long & unsigned long are evil and must NOT be used; while they are 32/64-bit on 32/64-bit systems under Unix, they are always 32-bit (also on 64-bit systems) under Windows.
MonetDB type system
SQL MAL C width
[byte] ([bit])
signed? range
("raw")
NIL
value
range
(non-NIL)
format string format cast availability C example semantics
TINYINT :bte bte 1 (8) yes [-128:127] -128 [-127:127] "%hhd" always bte x = 0; printf("%hhd", x); 1-byte (8-bit) signed integer
SMALLINT :sht sht 2 (16) yes [-65536:65535] -65536 [-65535:65535] "%hd" always sht x = 0; printf( "%hd", x); 2-byte (16-bit) signed integer
INT / INTEGER :int int 4 (32) yes [-2147483648:2147483647] -2147483647 [-2147483647:2147483647] "%d" always int x = 0; printf( "%d", x); 4-byte (32-bit) signed integer
BIGINT :lng lng 8 (64) yes [-9223372036854775808:9223372036854775807] -9223372036854775808 [-9223372036854775807:9223372036854775807] LLFMT always lng x = 0; printf(LLFMT , x); 8-byte (64-bit) signed integer