common.hpp 2.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef ODBC_COMMON_common_hpp
#define ODBC_COMMON_common_hpp

// misc defs

#ifdef NDB_GCC
#define PRINTFLIKE(i,j)	__attribute__ ((format (printf, i, j)))
#else
#define PRINTFLIKE(i,j)
#endif

// odbc defs

#define ODBCVER			0x0351

#ifdef NDB_WIN32
#include <windows.h>
#endif

extern "C" {
#include <sqlext.h>
}
// some types which may be missing
#ifndef SQL_BLOB
#define SQL_BLOB		30
#endif
#ifndef SQL_BLOB_LOCATOR
#define SQL_BLOB_LOCATOR	31
#endif
#ifndef SQL_CLOB
#define SQL_CLOB		40
#endif
#ifndef SQL_CLOB_LOCATOR
#define SQL_CLOB_LOCATOR	41
#endif

// until real blobs use Varchar of this size
#define FAKE_BLOB_SIZE		2000

#define SQL_HANDLE_ROOT	0	// assume real handles != 0

enum OdbcHandle {
    Odbc_handle_root = 0,	// not an odbc handle
    Odbc_handle_env = 1,
    Odbc_handle_dbc = 2,
    Odbc_handle_stmt = 4,
    Odbc_handle_desc = 8,
    Odbc_handle_all = (1|2|4|8)
};

// ndb defs

#undef BOOL
#include <ndb_types.h>
// this info not yet on api side
#include <kernel/ndb_limits.h>
#include <ndb_version.h>

#ifndef MAX_TAB_NAME_SIZE
#define MAX_TAB_NAME_SIZE	128
#endif

#ifndef MAX_ATTR_NAME_SIZE
#define MAX_ATTR_NAME_SIZE	32
#endif

#ifndef MAX_ATTR_DEFAULT_VALUE_SIZE
#define MAX_ATTR_DEFAULT_VALUE_SIZE	128
#endif

typedef Uint32 NdbAttrId;
typedef Uint64 CountType;

// ndb odbc defs

#define NDB_ODBC_COMPONENT_VENDOR	"[MySQL]"
#define NDB_ODBC_COMPONENT_DRIVER	"[ODBC driver]"
#define NDB_ODBC_COMPONENT_DATABASE	"[NDB Cluster]"

#define NDB_ODBC_VERSION_MAJOR		0
#define NDB_ODBC_VERSION_MINOR		22
#define NDB_ODBC_VERSION_STRING		"0.22"

// reserved error codes for non-NDB errors
#define NDB_ODBC_ERROR_MIN		5000
#define NDB_ODBC_ERROR_MAX		5100

// maximum log level compiled in
#ifdef VM_TRACE
#define NDB_ODBC_MAX_LOG_LEVEL		5
#else
#define NDB_ODBC_MAX_LOG_LEVEL		3
#endif

// driver specific statement attribute for number of NDB tuples fetched
#define SQL_ATTR_NDB_TUPLES_FETCHED	66601

#include <BaseString.hpp>
#include <common/Sqlstate.hpp>
#include <common/Ctx.hpp>

#undef assert

#endif