/* ------------------------------------------------------- */
/* Header-file SPEEDY 2.0.0, (C) Wabnig Harald, 30.05.2003 */
/* ------------------------------------------------------- */

#ifndef SPEEDYDB_INCLUDE
#define SPEEDYDB_INCLUDE

/* 30.5.2003
#define DB_VERSION     "2.0.0"
#define DB_VERSDATE    "15.12.2002"
*/
/* 12.7.2003
#define DB_VERSION     "2.0.0"
#define DB_VERSDATE    "30.05.2003"
*/
#define DB_VERSION     "2.0.1"
#define DB_VERSDATE    "12.07.2003"

/* Maximum length of an identifier */
#define DB_NAMELEN     32

/* Maximum length of a string (also for internal use) */
#define DB_STRGLEN     10000

/* Size of an error-string */
#define DB_ERRSIZE     256

/* 21.12.2002 */
/* Hashtable-sizes */
#define DB_HASH_SIZE_MIN    1003
#define DB_HASH_SIZE_MORE   30011
#define DB_HASH_SIZE_MAX    300017

/* --- Redo-Log --- */

/* Memory allocation strategy for redo-log-buffer */
#define DBLOG_MIN      50000
#define DBLOG_MORE     100000

/* --- Limiting Resultset of Selects --- */

/* Default number of maximum results from database selects */
#define DB_MAX_RESULTS              30000

/* Maximum number of results from a subselect */
#define DB_MAX_SUBSELECT_RESULTS    1000000

/* --- Main Memory Handling --- */

/* Total memory (main and virtual) is divided by this value */
#define DB_DIV_MAIN_MEM     10

/* Available memory including virtual memory divided by DB_DIV_MAIN_MEM */
#define DB_DEF_MAIN_MEM        24*1024*1024

/* Minimum main memory for the database */
#define DB_MIN_MAIN_MEM        8*1024*1024

/* Free ResData of subselects if memory consumption is greater */
#define DB_SUBSELECT_FREE_MEM    512*1024

/* --- DB-Size-Definitions --- */

/* Maximum number of concurrently open connections */
#define DB_MAXCONNS          15

/* Maximum number of databases */
#define DB_MAXDBS            15

/* Maximum number of tables (changed in one transaction) */
#define DB_MAXTABLES         256

/* Maximum number of concurrently open cursors */
#define DB_MAXCURSORS        20

/* Maximum number of attributes of a table */
#define DB_MAXATTRIBS        256

/* Row allocation strategy */
#define DB_ROWS_MIN          50 
#define DB_ROWS_MORE         10000 

/* Expression values allocation strategy */
#define DB_VALUES_MIN        20
#define DB_VALUES_MORE       70

/* Maximum size of value expression */
#define DB_EXPRVALMAX        100

/* Maximum number of functions in select statement */
#define DB_SELFUNCSMAX       10

/* Memory allocation strategy for save/load-data-buffer */
#define DBIO_MIN             50000
#define DBIO_MORE            100000

/* Maximum number of subselects */
#define DB_SUBSELMAX         10

/* Maximum number of attribute-references to upper selects */
#define DB_ATTRUPSELMAX      20

/* --- DB-Commands --- */

#define DB_ACK            '*'
#define DB_REPLY        '0'
#define DB_CONNECT        '1'
#define DB_DISCONNECT        '2'
#define DB_CREATE_DATABASE    '3'
#define DB_DROP_DATABASE    '4'
#define DB_CREATE_TABLE        '5'
#define DB_DROP_TABLE        '6'
#define DB_CREATE_INDEX        '7'
#define DB_CREATE_UNIQUE_INDEX    '8'
#define DB_DROP_INDEX        '9'
#define DB_SELECT_GEN        'C'
#define DB_INSERT_LOAD        'L'
#define DB_INSERT_STD        'D'
#define DB_INSERT_GEN        'E'
#define DB_DELETE_STD        'F'
#define DB_DELETE_GEN        'G'
#define DB_UPDATE_STD        'H'
#define DB_UPDATE_GEN        'I'
#define DB_BEGIN        'J'
#define DB_END            'K'
#define DB_ABORT        'M'
#define DB_DECLARE        'N'
#define DB_FETCH        'O'
#define DB_CLOSE        'P'
#define DB_STATIC        'Q'
#define DB_SAVE_DATABASE    'R'
#define DB_SHOW            'S'
#define DB_MAX            'T'
#define DB_SECURE        'U'
#define DB_STOP_DATABASE    'V'
#define DB_STOP     'W'
#define DB_SET_DATABASE     'X'

/* --- DB-Tokens --- */

#define DBTK_ERROR        '-'

#define DBTK_Name        'a'
#define DBTK_ErrMsg        'b'
#define DBTK_Short        'c'
#define DBTK_Int        'd'
#define DBTK_Double        'e'
#define DBTK_String        'f'
#define DBTK_Result        'h'
#define DBTK_Bool        'i'
#define DBTK_RowList        '#'
#define DBTK_Binary        '\247'

#define DBTK_ON            'j'
#define DBTK_CREATE_DATABASE    'k'
#define DBTK_CREATE_TABLE    'l'
#define DBTK_CREATE_INDEX    'm'
#define DBTK_CREATE_UNIQUE_INDEX 'n'
#define DBTK_DROP_DATABASE    'o'
#define DBTK_DROP_TABLE        'p'
#define DBTK_DROP_INDEX        'q'
#define DBTK_INSERT_INTO    'r'
#define DBTK_UPDATE        's'
#define DBTK_DELETE_FROM    't'
#define DBTK_SELECT        'u'
#define DBTK_FROM        'v'
#define DBTK_WHERE        'w'
#define DBTK_END        'x'
#define DBTK_AND        'y'
#define DBTK_OR            'z'
#define DBTK_LBR        'A'
#define DBTK_RBR        'B'
#define DBTK_COUNT        'C'
#define DBTK_DOT        'D'
#define DBTK_COMMA        'E'
#define DBTK_NULL        'F'
#define DBTK_ORDER_BY        'H'
#define DBTK_MIN        'I'
#define DBTK_MAX        'J'
#define DBTK_EXISTS        'L'
#define DBTK_IN            'M'
#define DBTK_L            'N'
#define DBTK_G            'O'
#define DBTK_LE            'P'
#define DBTK_GE            'Q'
#define DBTK_EQ            'R'
#define DBTK_NE            'S'
#define DBTK_NOT        'T'
#define DBTK_SET        'U'
#define DBTK_LIKE        'V'
#define DBTK_STAR        'W'
#define DBTK_VALUES        'X'
#define DBTK_BETWEEN        'Y'
#define DBTK_CURSOR        'Z'
#define DBTK_FOR        '!'
#define DBTK_FETCH        '§'
#define DBTK_ALL        '%'
#define DBTK_DECLARE        '$'
#define DBTK_CLOSE        '&'
#define DBTK_COMMIT        '/'
#define DBTK_ABORT        '('
#define DBTK_BEGIN        ')'
#define DBTK_ASC        '['
#define DBTK_DESC        ']'
#define DBTK_TABLE        '?'
#define DBTK_STATIC        'ß'
#define DBTK_SAVE        '{'
#define DBTK_DATABASE        '}'
#define DBTK_SELECT_EXISTS    '='
#define DBTK_DISTINCT        '7'
#define DBTK_SHOW        '8'
#define DBTK_INDEX        '9'
#define DBTK_DATABASES        'ö'
#define DBTK_TABLES        'ü'
#define DBTK_INDICES        'ä'
#define DBTK_SECURE        'Ä'
#define DBTK_STOP         'Ö'

#define DBTK_CHARACTER        '0'
#define DBTK_SMALLINT        '1'
#define DBTK_INTEGER        '2'
#define DBTK_FLOAT        '3'
#define DBTK_DATE        '4'
#define DBTK_TIME        '5'
#define DBTK_TIMESTAMP        '6'
#define DBTK_BINARY        '\246'

#define DB_CHARACTER_SIZE    1
#define DB_CHARACTER_ALIGN    1
#define DB_SMALLINT_SIZE    sizeof(short)
#define DB_SMALLINT_ALIGN    sizeof(int)
#define DB_INTEGER_SIZE        sizeof(int)
#define DB_INTEGER_ALIGN    sizeof(int)
#define DB_FLOAT_SIZE        sizeof(double)
#define DB_FLOAT_ALIGN        sizeof(int)
#define DB_DATE_SIZE        sizeof(DBDATE)
#define DB_DATE_ALIGN        sizeof(int)
#define DB_TIME_SIZE        sizeof(DBTIME)
#define DB_TIME_ALIGN        sizeof(int)
#define DB_TIMESTAMP_SIZE    sizeof(DBDATI)
#define DB_TIMESTAMP_ALIGN    sizeof(long)

#endif

