设为首页 收藏本站
查看: 1285|回复: 0

[经验分享] sqlite源码剖析(2)

[复制链接]

尚未签到

发表于 2016-11-28 12:16:11 | 显示全部楼层 |阅读模式
  声明:本SQLite源码剖析系列为刘兴(http://deepfuture.iyunv.com/)原创,未经笔者授权,任何人和机构不能转载
  /*
  ** The maximum number of opcodes in a VDBE program.
  ** Not currently enforced.
  */
  //VDBE程序的最大操作码数目
  #ifndef SQLITE_MAX_VDBE_OP
  # define SQLITE_MAX_VDBE_OP 25000
  #endif
   
  /*
  ** The maximum number of arguments to an SQL function.
  */
  //SQL函数的最大参数数目
  #ifndef SQLITE_MAX_FUNCTION_ARG
  # define SQLITE_MAX_FUNCTION_ARG 127
  #endif
   
  /*
  ** The maximum number of in-memory pages to use for the main database
  ** table and for temporary tables.  The SQLITE_DEFAULT_CACHE_SIZE
  */
  //主数据库表和临时表的最大内存大小
  #ifndef SQLITE_DEFAULT_CACHE_SIZE
  # define SQLITE_DEFAULT_CACHE_SIZE  2000
  #endif
  #ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
  # define SQLITE_DEFAULT_TEMP_CACHE_SIZE  500
  #endif
   
  /*
  ** The maximum number of attached databases.  This must be between 0
  ** and 30.  The upper bound on 30 is because a 32-bit integer bitmap
  ** is used internally to track attached databases.
  */
  //附加数据库的数目
  #ifndef SQLITE_MAX_ATTACHED
  # define SQLITE_MAX_ATTACHED 10
  #endif
   
   
  /*
  ** The maximum value of a ?nnn wildcard that the parser will accept.
  */
  //解析器接受的匹配符参数最大值
  #ifndef SQLITE_MAX_VARIABLE_NUMBER
  # define SQLITE_MAX_VARIABLE_NUMBER 999
  #endif
   
  /* Maximum page size.  The upper bound on this value is 32768.  This a limit
  ** imposed by the necessity of storing the value in a 2-byte unsigned integer
  ** and the fact that the page size must be a power of 2.
  **
  ** If this limit is changed, then the compiled library is technically
  ** incompatible with an SQLite library compiled with a different limit. If
  ** a process operating on a database with a page-size of 65536 bytes
  ** crashes, then an instance of SQLite compiled with the default page-size
  ** limit will not be able to rollback the aborted transaction. This could
  ** lead to database corruption.
  */
  //最大页面大小
  #ifndef SQLITE_MAX_PAGE_SIZE
  # define SQLITE_MAX_PAGE_SIZE 32768
  #endif
   
   
  /*
  ** The default size of a database page.
  */
  //数据库页面的默认大小
  #ifndef SQLITE_DEFAULT_PAGE_SIZE
  # define SQLITE_DEFAULT_PAGE_SIZE 1024
  #endif
  #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
  # undef SQLITE_DEFAULT_PAGE_SIZE
  # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
  #endif
   
  /*
  ** Ordinarily, if no value is explicitly provided, SQLite creates databases
  ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
  ** device characteristics (sector-size and atomic write() support),
  ** SQLite may choose a larger value. This constant is the maximum value
  ** SQLite will choose on its own.
  */
  //数据库页面的最大默认大小
  #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
  # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
  #endif
  #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
  # undef SQLITE_MAX_DEFAULT_PAGE_SIZE
  # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
  #endif
   
   
  /*
  ** Maximum number of pages in one database file.
  **
  ** This is really just the default value for the max_page_count pragma.
  ** This value can be lowered (or raised) at run-time using that the
  ** max_page_count macro.
  */
  //单个数据库文件的最大页数数
  #ifndef SQLITE_MAX_PAGE_COUNT
  # define SQLITE_MAX_PAGE_COUNT 1073741823
  #endif
   
  /*
  ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
  ** operator.
  */
  // LIKE or GLOB模式的最大长度(字节)
  #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
  # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
  #endif
   
  /*
  ** Maximum depth of recursion for triggers.
  **
  ** A value of 1 means that a trigger program will not be able to itself
  ** fire any triggers. A value of 0 means that no trigger programs at all
  ** may be executed.
  */
  //触发器程序的递归深度
  #ifndef SQLITE_MAX_TRIGGER_DEPTH
  # define SQLITE_MAX_TRIGGER_DEPTH 1000
  #endif
  //SQLITE限制参数定义完毕
  /************** End of sqliteLimit.h *****************************************/
  /************** Continuing where we left off in sqliteInt.h ******************/
  //禁止Borland编译器的讨厌的警告
  /* Disable nuisance warnings on Borland compilers */
  #if defined(__BORLANDC__)
  #pragma warn -rch /* unreachable code */
  #pragma warn -ccc /* Condition is always true or false */
  #pragma warn -aus /* Assigned value is never used */
  #pragma warn -csu /* Comparing signed and unsigned */
  #pragma warn -spa /* Suspicious pointer arithmetic */
  #endif
  //定义为GNU源码
  /* Needed for various definitions... */
  #ifndef _GNU_SOURCE
  # define _GNU_SOURCE
  #endif
   
  /*
  ** Include standard header files as necessary
  */
  //包含必要的头文件
  #ifdef HAVE_STDINT_H
  #include <stdint.h>
  #endif
  #ifdef HAVE_INTTYPES_H
  #include <inttypes.h>
  #endif
   
  /*
  ** The number of samples of an index that SQLite takes in order to
  ** construct a histogram of the table content when running ANALYZE
  ** and with SQLITE_ENABLE_STAT2
  */
  //索引样本数
  #define SQLITE_INDEX_SAMPLES 10
   
  /*
  ** The following macros are used to cast pointers to integers and
  ** integers to pointers.  The way you do this varies from one compiler
  ** to the next, so we have developed the following set of #if statements
  ** to generate appropriate macros for a wide range of compilers.
  **
  ** The correct "ANSI" way to do this is to use the intptr_t type.
  ** Unfortunately, that typedef is not available on all compilers, or
  ** if it is available, it requires an #include of specific headers
  ** that very from one machine to the next.
  **
  ** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on
  ** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).
  ** So we have to define the macros in different ways depending on the
  ** compiler.
  */
  //下列宏完成指针转整数和整数转指针
  #if defined(__PTRDIFF_TYPE__)  /* This case should work for GCC */
  # define SQLITE_INT_TO_PTR(X)  ((void*)(__PTRDIFF_TYPE__)(X))
  # define SQLITE_PTR_TO_INT(X)  ((int)(__PTRDIFF_TYPE__)(X))
  #elif !defined(__GNUC__)       /* Works for compilers other than LLVM */
  # define SQLITE_INT_TO_PTR(X)  ((void*)&((char*)0)[X])
  # define SQLITE_PTR_TO_INT(X)  ((int)(((char*)X)-(char*)0))
  #elif defined(HAVE_STDINT_H)   /* Use this case if we have ANSI headers */
  # define SQLITE_INT_TO_PTR(X)  ((void*)(intptr_t)(X))
  # define SQLITE_PTR_TO_INT(X)  ((int)(intptr_t)(X))
  #else                          /* Generates a warning - but it always works */
  # define SQLITE_INT_TO_PTR(X)  ((void*)(X))
  # define SQLITE_PTR_TO_INT(X)  ((int)(X))
  #endif
   
  /*
  ** The SQLITE_THREADSAFE macro must be defined as either 0 or 1.
  ** Older versions of SQLite used an optional THREADSAFE macro.
  ** We support that for legacy
  */
  // SQLITE_THREADSAFE线程安全宏被定义为0或1,
  #if !defined(SQLITE_THREADSAFE)
  #if defined(THREADSAFE)
  # define SQLITE_THREADSAFE THREADSAFE
  #else
  # define SQLITE_THREADSAFE 1
  #endif
  #endif
   
  /*
  ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
  ** It determines whether or not the features related to
  ** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
  ** be overridden at runtime using the sqlite3_config() API.
  */
  // SQLITE_DEFAULT_MEMSTATUS宏被定义为0或1,在运行时可使
  //用sqlite3_config() API修改该值
  #if !defined(SQLITE_DEFAULT_MEMSTATUS)
  # define SQLITE_DEFAULT_MEMSTATUS 1
  #endif

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-306735-1-1.html 上篇帖子: SQLite在Java中的使用 下篇帖子: android之SQlite
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表