MonetDB type system

From MonetDB
Revision as of 20:42, 6 October 2015 by Stefan Manegold (talk | contribs)
Jump to navigationJump to search
  • Rule #1
    • 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.
  • Rule #2
    • monetdb_config.h must be the first #include in each .c file (not in any .h file).
MonetDB type system
semantics SQL MAL C width
[byte] ([bit])
signed? NIL value min value max value format string format cast availability C example
1-byte (8-bit)
signed integer
TINYINT :bte bte 1 (8) yes bte_nil ==
GDK_bte_min
GDK_bte_min
-128
GDK_bte_max
127
"%hhd" always bte x = 0;
printf("%hhd", x);
2-byte (16-bit)
signed integer
SMALLINT :sht sht 2 (16) yes sht_nil ==
GDK_sht_min
GDK_sht_min
-65536
GDK_sht_max
65535
"%hd" always sht x = 0;
printf( "%hd", x);
4-byte (32-bit)
signed integer
INT / INTEGER :int int 4 (32) yes int_nil ==
GDK_int_min
GDK_int_min
-2147483648
GDK_int_max
2147483647
"%d" always int x = 0;
printf( "%d", x);
8-byte (64-bit)
signed integer
BIGINT :lng lng 8 (64) yes lng_nil ==
GDK_lng_min
GDK_lng_min
-9223372036854775808
GDK_lng_max
9223372036854775807
LLFMT always lng x = 0;
printf(LLFMT , x);
16-byte (128-bit)
signed integer
HUGEINT :hge hge 16 (128) yes hge_nil ==
GDK_hge_min
GDK_hge_min
-170141183460469231731687303715884105728
GDK_hge_max
170141183460469231731687303715884105727
(none provide by compilers) if supported by compiler
(configure then defines HAVE_HGE)
#ifdef HAVE_HGE
hge x = 0;
printf("%.40g", (dbl) x);
#endif

... to be continued ...