⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edbinit.h

📁 在VC6环境下开发
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
** This header file defines the interface that the eDb library
** presents to client programs.
*/
#ifndef _eDbInit_H_
#define _eDbInit_H_

#ifdef WIN32
#include <stdio.h>
#endif

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <assert.h>
extern int eDb_malloc_failed;

typedef struct Table Table;
typedef struct Column Column;
typedef struct Index Index;
typedef struct Expr Expr;
typedef struct ExprList ExprList;
typedef struct IdList IdList;
typedef struct IdExprList IdExprList;
typedef struct SrcList SrcList;
typedef struct Token Token;
typedef struct Select Select;
typedef struct eDb eDb;
typedef struct KeyData KeyData;
typedef struct Parser Parser;
typedef struct ParseResult ParseResult;
typedef struct WhereExpr WhereExpr;
typedef struct CExpr CExpr;

/*
** Integers of known sizes.  These typedefs might change for architectures
** where the sizes very.  Preprocessor macros are available so that the
** types can be conveniently redefined at compile-type.  Like this:
**
**         cc '-DUINTPTR_TYPE=long long int' ...
*/
#define eDb_PTR_SZ 4
#ifndef UINT32_TYPE
# define UINT32_TYPE unsigned int
#endif
#ifndef UINT16_TYPE
# define UINT16_TYPE unsigned short int
#endif
#ifndef UINT8_TYPE
# define UINT8_TYPE unsigned char
#endif
#ifndef INT8_TYPE
# define INT8_TYPE signed char
#endif
#ifndef INTPTR_TYPE
# if eDb_PTR_SZ==4
#   define INTPTR_TYPE int
# else
#   define INTPTR_TYPE long long
# endif
#endif
typedef UINT32_TYPE u32;           /* 4-byte unsigned integer */
typedef UINT16_TYPE u16;           /* 2-byte unsigned integer */
typedef UINT8_TYPE u8;             /* 1-byte unsigned integer */
typedef UINT8_TYPE i8;             /* 1-byte signed integer */
typedef INTPTR_TYPE ptr;           /* Big enough to hold a pointer */
typedef unsigned INTPTR_TYPE uptr; /* Big enough to hold a pointer */

#define Addr(X)  ((uptr)X)

#ifndef WIN32
#include "..\S3C44B0\FileIO.h"
#include "uCOS.h"
#else
#include "WinOS.h"
#endif

extern FILE *fout;
extern FILE *fdebug;

#include "pager.h"
#include "Btree.h"
#include "Hash.h"
#include "util.h"
#include "Expr.h"
#include "Select.h"
#include "build.h"
#include "Delete.h"
#include "exec.h"
#include "parse.h"
#include "Insert.h"
#include "Where.h"
#include "Malloc.h"

#ifndef _MALLOC_H_
#define _MALLOC_	malloc
#define _REALLOC_	realloc
#define _FREE_		free
#else
#define _MALLOC_	alloc_mem
#define _REALLOC_	realloc_mem
#define _FREE_		free_mem
#endif

#define keyToInt(X)   (eDbVdbeByteSwap(X) ^ 0x80000000)
#define intToKey(X)   (eDbVdbeByteSwap((X) ^ 0x80000000))
/*
** The version of the eDb library.
*/
#define eDb_VERSION         "1.0.00"
#define SIZEOFINT		sizeof(int)

/*
** The maximum number of in-memory pages to use for 
** the database table.
*/
#define MAX_PAGES			16
#define PAGE_SIZE			1024

#define MAX_CURSORS			8
#define MAXLEN_TABLENAME	20		/* max length of a table name*/
#define MAXLEN_COLUMNNAME	20		/* max length of a column name*/
#define MAXLEN_IDXCOLUMN	20		/* max length of the column value be indexed */
#define MAXLEN_IDXKEY		128		/* max length of a index key */
#define MAX_COLUMNS			128		/* max columns a table contained*/
#define MAXLEN_COLUMN		128
/*
** Permitted values of the SrcList.a.jointype field
*/
#define JT_INNER     0x0001    /* Any kind of inner or cross join */
#define JT_NATURAL   0x0002    /* True for a "natural" join */
#define JT_LEFT      0x0004    /* Left outer join */
#define JT_RIGHT     0x0008    /* Right outer join */
#define JT_OUTER     0x0010    /* The "OUTER" keyword is present */
#define JT_ERROR     0x0020    /* unknown or unsupported join type */
/*
** Return values for eDb_exec() and eDb_step()
*/
#define eDb_OK           0   /* Successful result */
#define eDb_ERROR        1   /* SQL error or missing database */
#define eDb_INTERNAL     2   /* An internal logic error in eDb */
#define eDb_PERM         3   /* Access permission denied */
#define eDb_ABORT        4   /* Callback routine requested an abort */
#define eDb_BUSY         5   /* The database file is locked */
#define eDb_LOCKED       6   /* A table in the database is locked */
#define eDb_NOMEM        7   /* A malloc() failed */
#define eDb_READONLY     8   /* Attempt to write a readonly database */
#define eDb_INTERRUPT    9   /* Operation terminated by eDb_interrupt() */
#define eDb_IOERR       10   /* Some kind of disk I/O error occurred */
#define eDb_CORRUPT     11   /* The database disk image is malformed */
#define eDb_NOTFOUND    12   /* (Internal Only) Table or record not found */
#define eDb_FULL        13   /* Insertion failed because database is full */
#define eDb_CANTOPEN    14   /* Unable to open the database file */
#define eDb_PROTOCOL    15   /* Database lock protocol error */
#define eDb_EMPTY       16   /* (Internal Only) Database table is empty */
#define eDb_MISMATCH    20   /* Data type mismatch */
#define eDb_MISUSE      21   /* Library used incorrectly */
#define eDb_NOTADB      26   /* File opened that is not a database file */
#define eDb_EXISTS		27	 /*file already exists*/
#define eDb_DONE        101  /* eDb_step() has finished executing */

#define eDb_READ	0
#define eDb_WRITEN	1

#define OP_None			0
#define OP_Unique		1
#define OP_PKey			2


#define eDb_SO_UNK       0  /*  */
#define eDb_SO_DEC       2  /* decimal */
#define eDb_SO_NUM		 4	/* integer */
#define eDb_SO_TEXT      8  /* char(n) or text */
#define eDb_SO_TYPEMASK  0x0e  /* Mask to extract the collating sequence */

#define eDb_SO_ASC       0  /* Sort in ascending order */
#define eDb_SO_DESC      1  /* Sort in descending order */
#define eDb_SO_DIRMASK   1  /* Mask to extract the sort direction */

/*
** Each SQL table is represented in memory by an instance of the
** following structure.
**
** Table.zName is the name of the table.  The case of the original
** CREATE TABLE statement is stored, but case is not significant for
** comparisons.
**
** Table.nCol is the number of columns in this table.  Table.aCol is a
** pointer to an array of Column structures, one for each column.
**
** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of
** the column that is that key.   Otherwise Table.iPKey is negative.  Note
** that the datatype of the PRIMARY KEY must be INTEGER for this field to
** be set.  An INTEGER PRIMARY KEY is used as the rowid for each row of
** the table.  If a table has no INTEGER PRIMARY KEY, then a random rowid
** is generated for each row of the table.  Table.hasPrimKey is true if
** the table has any PRIMARY KEY, INTEGER or otherwise.
**
** Table.tnum is the page number for the root BTree page of the table in the
** database file.  If Table.iDb is the index of the database table backend
** in eDb.aDb[].  0 is for the main database and 1 is for the file that
** holds temporary tables and indices.  If Table.isTransient
** is true, then the table is stored in a file that is automatically deleted
** when the VDBE cursor to the table is closed.  In this case Table.tnum 
** refers VDBE cursor number that holds the table open, not to the root
** page number.  Transient tables are used to hold the results of a
** sub-query that appears instead of a real table name in the FROM clause 
** of a SELECT statement.
*/

struct Table {
	char *zName;     /* Name of the table */
	int nCol;        /* Number of columns in this table */
	Column *aCol;    /* Information about each column */
	int iPKey;       /* If not less then 0, use aCol[iPKey] as the primary key */
	Index *pIndex;   /* List of SQL indexes on this table. */
	Select *pSelect;
	int tnum;        /* Root BTree node for this table (see note above) */
	u8 hasPrimKey;   /* True if there exists a primary key */
};

/*
** information about each column of an SQL table is held in an instance
** of this structure.
*/
struct Column {
  char *zName;		/* Name of this column */
  char *zDflt;		/* Default value of this column */
  char *zType;		/* Data type for this column */
  u8 isPrimKey;		/* True if this column is part of the PRIMARY KEY */
  u8 type;			/* column type  */
  u8 dottedName;	/* True if zName contains a "." character */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -