
b709e29 Fix URL typo in release notes 01f203c Update release notes c49810a Update COPYRIGHT e327526 Add BSL version number to LICENSE.TXT 07e3a4e Remove superfluous COPURIGHT.md and LICENSE.md 54c3310 Replace Dynamic Data Routing Platform with Database Proxy 305d02f Remove *.cmake wildcard from .gitignore b0b5208 Cleanup of spaces aeca6d0 Extend maxscaled error messages 817d74c Document where the CDC users are stored 9a569db Update license ff8697a MXS-716: Fix table level privilege detection 2071a8c Only check replies of slaves that are in use f8dfa42 Fix possible hangs in CDC python scripts fa1d99e Removed "filestem option" from example 009b549 Removed "filestem option" from example 8d515c2 Add example Kafka producer script for Python 64e976b Fix sporadic SSL authentication failures 5a655dc MXS-814: Check service/monitor permissions on all servers 2a7f596 Add note about galeramon priority to Galera tutorials b90b5a6 Fixed SHOW SLAVE STATUS in binlog router e22fe39 Changed couln size for SHOW SLAVE STATUS ae97b18 Fix avrorouter build failure with older sqlite libraries 56ef8b7 Replace GPL license with BSL license in scripts and tests 552836f Initialize all fields when MySQL users are loaded from cache bf42947 Update all licensing related files b29db9d Remove optimize_wildcard parameter from use 5170844 Make readwritesplit diagnosting output more clear 262ffb1 Fix crash when a config parameter has no section 33ac9e6 Add note about LEAST_BEHIND_MASTER and server weights e13e860 Fix a memory leak when backend authentication fails 75d00c2 MXS-801: Set the default value of strip_db_esc to true bd5f2db MXS-800: Add a log message about the working directory 4b1dd8c Update MySQL Monitor documentation on detect_replication_lag 559bc99 Fix installation of license file b057587 Change LICENSE to LICENSE.TXT 223fa43 Remove null characters from log messages 36fd05b Fix fatal signal handler log message 053dc8a Fix typos in documentation 371dc87 Fix Galera text in Master-Slave tutorial 30b6265 Disable adding of new objects at runtime db92311 Update the documentation on configuration reloading 0923d40 Update Connector-C version c4738b5 Add define for avro-conversion.ini 196e6ac Update license from GPL to BSL. e612366 Correctly calculate the number of bytes read in dcb_read 93a2a03 Update rotate documentation in admin tutorial c5eb854 MXS-585: Fix authentication handling regression 6330070 Fix schemarouter memory leak aa5827e Fix CDC authentication memory leak a5af4ad Fix avro memory leaks 627d73f Fix Avro scripts 0ff7556 Add build instructions to avrorouter documentation 734a1c8 Fix doxygen mainpage e51ce09 Add licence text to avro scripts 4d27c14 Update Avro documentation and fix installation directories a58a330 Fix readconnroute error message about router_options 22b138c MXS-772: Fix postinstall script a9960b7 Fix function declaration in mysql_backend.c cbe1704 Add missing newline 09d76ee Fix avro documentation default values 1d3f8f3 Added refresh users on START SLAVE 880db34 Make router configuration errors fatal 3bad5ca Update documentation and add logging to avrorouter 10f3384 Disable SSLv3 ca8d902 Fix rwsplit error reporting when master is lost e816d65 Fix MaxScale Tutorial deca3e1 Update MaxScale man page f1735b7 Update release notes 9238714 qc: Change type of DEALLOCATE PREPARE 0b77c3b dbfwfilter: Do not require a trailing new line 1152ca9 Remove copyright message a038a85 Remove debug assertion on ERANGE error in galeramon 12ab235 Fix comparison error for connections limit. 5de1a8f qc_sqlite: Correct string recognition b63d754 Fix links in documentation contents 05d457e CDC protocol link fix 50676ef Fix monitor code formatting 218ba09 Remove MaxScale-and-SSL.md 0d6845b Add images to Avro documentation and tutorial 8dd2c9b Update MaxScale-2.0.0-Release-Notes.md 6d4b593 Change avrorouter default transaction grouping 4c629de Add notes about monitor changes to upgrading and release notes 267d0dc Update Binlogrouter.md c624781 Update Replication-Proxy-Binlog-Router-Tutorial.md f3261bc CDC users 1368797 Format authenticator and module headers ab01749 Format filters 8b05d32 Format core and include files f3974e5 Add GPL LICENSE to qc_mysqlembedded bfec36a astyle rabbitmq_consumer/consumer.c 54b960a Check that the Avro directory is writable 3d4cd2e Fix cdc_users using the wrong path for service users cache 1e738dd Add CDC client program documentation f6809fd Remove superfluous rabbitmw_consumer/LICENSE 6b5e667 Update license text in files 9bfcb46 Change CDC protocol documentation formatting 607f25c REQUEST-DATA formatting 8175ab4 CDC protocol update d5ca272 CDC protocol update 6c91764 Only check wsrep_local_index if node is joined f12e2c2 Do not use SSL for monitors and services 6d2cd99 Fix TestAdminUsers f4ae50d Apply astyle to server/core/test/*.c 7cc2824 Update build instructions cf8e2b5 Update release notes 03c7a6c Remove wrong function prototypes 5a11eed Revert "Remove duplicate functions" 80ed488 Remove duplicate functions bb0de8d Add info on SSL and throttling to release notes for 2.0. 0934aee Update MaxAdmin reference guide 2a3fe9b Update source URL in release notes e575cf0 Merge branch 'MXS-177-develop' into develop cc8c88d Change header for BSL ecde266 Change header for BSL 890b208 Log a message when a script is executed 9c365df Added information on server side SSL to config guide. aa3e002 Remove obsolete heading 79dd73a Make dprintAllSessions use dprintSession 1fc0db9 Align output of "show services" 1b9d301 Make monitorShowAll use monitorShow 983615e Adjust output of 'show modules' 436badd qc_sqlite: The module is now beta a7cbbe5 Update Upgrade document 71ac13f Remove obsolete user/password from example eb20ff8 Fix and clean up Avrorouter diagnostics code 31d4052 Change MaxScale to MariaDB MaxScale e6e4858 Fix `source` parameter not working with `router_options` d8de99a Update module version numbers eb81add Merge remote-tracking branch 'origin/develop' into MXS-177-develop daba563 Merge remote-tracking branch 'origin/MXS-651-develop-merge' into develop 678f417 Changes in response to reviews. 410fb81 Changes in response to reviews. 60135e5 Add initial release notes about Avrorouter 7400ecc qc_sqlite: Remove uninitialized read 536962c Update version number 018f044 Fix debug assertion in client command processing 51f0804 Prevent 'show monitor' from crashing with failed monitor 559347e Fix "Too many connections" message; add comments. 01d3929 Add printf format checking to dcb_printf fbd49a6 dbfwfilter: Require complete parsing only when needed 1885863 Add information to release notes about readwritesplit changes 73b56a2 Update MaxScale section in release notes. 0a2f56f MaxAdmin: Remove debug information from 'show users' 3cf3279 MaxAdmin: Report SSL information as well 29c2b66 Always use SSL if server configured with SSL 7d6b335 dprintAllServers should use dprintServer 02a5246 qc_sqlite: Correctly detect parsing context 469419b compare: Add strict mode 8c5b3d3 compare: Allow the comparison of a single statement 4691514 Add Updgrade to 2.0 document 38b3ecb Expand the checks done before a monitor is stopped 8e2cfb9 Add backend name to authentication error message 9600a07 Fix MaxInfo crash 91c58b0 Removed log message for duplicate entry while adding an user 40392fe Fixed log message priority 0ec35b8 maxadmin: Allow the last user to be removed 5a0ebed maxadmin: Change name of user file 87aa8f1 maxadmin: Always allow root to connect bf37751 Fix COM_QUIT packet detection 7c93ee4 Update avrorouter documentation and tutorial 95ce463 Fix wrong directory in avrorouter log message cfe54c7 Update ChangeLog d69562c Fix LOAD DATA LOCAL INFILE data size tracking 24e7cd6 MXS-584: added support for SET @@session.autocommit d6f6f76 Fixes, correct too many connections message efeb924 Update release notes for 2.0.0 8f71a87 qc_sqlite: Adjust error messages b967d60 Remove copy of enum enum_server_command 822b7e3 Update package license b58301a Update MaxScale License for overlooked files c09ee47 Update MaxScale License 49f46fa Tidy up. Comment out config items not yet supported. f5c3470 Updated and simplified the Building from Source document 98b98e2 Add note about master failure modes to documentation e036f2c Update Limitations document 62219a5 Merge remote-tracking branch 'origin/drain-writeq' into develop 5caf667 Invoke DCB_REASON_DRAINED more frequently. 77b107b qc_sqlite: Add support for LOAD DATA INFILE 8e70f26 compare: Optionally print out the parse result ad750e6 Merge remote-tracking branch 'origin/MXS-651-develop-merge' into develop ef85779 Merge remote-tracking branch 'origin/develop' into MXS-651-develop-merge ea9fdda MXS-477: Add LONGBLOB support for readconnroute eae6d42 qc_sqlite: Remove superfluous columnname definition 8fe2b21 Add binlog source to avrorouter b25cc37 qc_sqlite: Add missing destructors 8a749e7 qc_sqlite: Reduce number of keywords 5f4bb8b compare: Output query immediately 2456e52 dbfwfilter: Reject queries that cannot be parsed 5f1fbbd qc_sqlite: Extend SET grammar b8d8418 dbfwfilter: Remove 'allow' from firewall filter rule 0bd2a44 MXS-741 When no events are read from binlog file, ... a07c491 Remove duplicated function (merge error, probably) b237008 Save conflict resolution, missed last time. a0c0b40 Merge remote-tracking branch 'origin/develop' into MXS-651-develop 385d47d Change SSL logic, fix large read problem. b93b5e0 Remove false debug assertion b953b1f Turn off SSL read ahead. e0d46a5 Fix error messages and remove commented code 49b4655 MXS-739: Fix invalid JSON in Maxinfo 0c30692 qc_sqlite: Handle GROUP_CONCAT arguments 54e48a1 qc_sqlite: Consider \ as an escape character in strings 713a5d6 qc_sqlite: Add test cases 20d1b51 qc_sqlite: Handle qualified names in CREATE VIEW 1019313 qc_sqlite: Make QUERY_TYPE_WRITE default for SHOW 059c14e qc_sqlite: Accept qualified function names in SELECT db34989 qc_sqlite: Accept qualified function names b93e2f1 qc_sqlite: Add limited support for GRAND and REVOKE 678672d qc_sqlite: Cleanup copying of database and table names 9b744b9 qc_sqlite: Update table and database names at the same time db75e61 qc: Support getting the qualified table names 1f867f4 qc: Add join.test 9c7e02a qc_sqlite: Accept "...from NATURAL straight_join..." 93d1c31 qc_sqlite: Both " and ' can enclose a string literal 8055b21 qc_sqlite: Set more information based upon tokens 37e3663 qc_sqlite: Do not blindly add affected fields 50f1360 qc: Correctly collect affected fields 71c234e qc_sqlite: Recognize CREATE TABLE ... UNION 01803f1 qc_sqlite: Recognize {DEALLOCATE|DROP} PREPARE ... 6ecd4b3 qc_sqlite: Parse index hints 0bdab01 qc: Compare sets of tables b908c8f Fix double freeing of internal DCBs 8903556 qc_sqlite: Recognize LEFT, INSERT and REPLACE 266e6c0 qc: Log all problems by default (compare program) 7b54cac qc_sqlite: Fix logging bug 9566e9f qc_sqlite: Plug a leak b0a860d qc: Run compare a specified number of times 050d698 qc_sqlite: Simplified argument handling 97c56b8 qc: Allow arguments to be passed to the query classifier 09a46e0 qc_sqlite: Add argument log_unrecognized_statements fd98153 qc: Allow arguments to be provided to the query classifier 313aa7e Fix Problems SSL assertion; non SSL connect to SSL 1d721e6 Fix DEB packaging errors 96bdc39 Fix RPM packaging failures on CentOS 7 6ba900d qc_sqlite: Recognize more SHOW commands 2869d0b qc_sqlite: Exclude support for sqlite's PRAGMA 0be68a3 qc_sqlite: Enhance SELECT syntax 28f3e1a Merge branch 'develop' into MXS-729 e18bd41 qc: Expose the result of the parsing 5896085 Add BUILD_AVRO to the CMake cache daeb896 Remove changes to blr_master.c memory handling d523821 Add comments 4eb9a66 Empty admin users file is now handled 52b46c6 qc: Update create.test db09711 qc_sqlite: Ignore case when looking for test language keywords f042a1d qc_sqlite: Extend CREATE TABLE syntax 177d2de qc_sqlite: Extend CREATE TABLE syntax d3ca8e6 qc_sqlite: Add some support for HANDLER 86c6a96 qc_sqlite: Recognize RENAME TABLE 471594f qc_sqlite: Accept more table options at CREATE TABLE 3da6cde qc_sqlite: Remove unused keywords bd89662 Fix crash on corrupted passwd file b5d1764 MXS-733: Always print session states 043e2db Remove unused CMake variables 5604fe2 Restore missing line, fixes logic error. 66d15a5 Added log message warning for old users found 5be9fca Changes in response to review by Johan 899e0e2 Removed password parameter from admin_user_add and admin_remove_user a2d9302 Merge branch 'develop' into MXS-729 bcaf82f Code review update e61c716 Nagios plugin update with Maxadmin using UNIX socket only d7150a2 qc_sqlite: Extend column syntax 3b78df0 qc_sqlite: Accept VALUE in addition to VALUES 85a705b qc_sqlite: Accept CHARSET in addition to CHARACTER SET db9cec8 qc_sqlite: Accept qualified column names in CREATE TABLE a9cabb0 qc_sqlite: Extend SELECT syntax f5e9878 qc_sqlite: Add set type 675cb93 qc_sqlite: Allow BINARY to turn into an identifier b04a760 qc_sqlite: Accept DROP TABLES 1075d9c qc_sqlite: Allow qualified name with LIKE in CREATE 420ac56 qc_sqlite: Extend EXPLAIN grammar 727d626 Add missing error message to readwritesplit f4fd09e Change templates and testing configurations to use sockets 1ef2e06 Add configurable default admin user a723731 Remove wrong file 7c3b02b Maxadmin/maxscaled UNIX socket update eed78d4 qc_sqlite: Pick out more information from select when CREATEing 267f091 qc_sqlite: Recognise DROP TEMPORARY TABLE 54fc29f qc_sqlite: Accept $ as a valid character in identifiers afa2ec9 qc_sqlite: Allow keywords to be used in qualified name db0427d MXS-729 code review update a3b3000 Merge branch 'develop' into MXS-729 e73d66c qc_sqlite: Identify qualified identifiers 5bacade Trailing space fix 3bc9be3 MXS-729 socket=default support in maxscale.cnf 1a5c23c Code review update for MXS-729 d6665c7 qc_sqlite: Extend CREATE TABLE grammar 91725ce qc_sqlite: Dequote table and database names cd7a022 qc: Add create test 1aa4e6b qc: Update test files 762b0c2 qc_mysqlembedded: Do not return "*" as table name cd9968f qc_sqlite: Update delete.test f16703d qc_sqlite: Add support for CALL e3ca9b4 qc_mysqlembedded: Do not return an array of empty strings 5878a22 qc_sqlite: Support selects in DELETE 1cf0444 qc_sqlite: Fix bug in DELETE grammar 0bf39a1 qc_sqlite: Add support for CHECK TABLE 4a8feca qc_sqlite: Add helper for catenating SrcLists ab299b3 qc_sqlite: Extend DELETE syntax 5778856 qc_sqlite: Extract database name as well 99901f1 qc_sqlite: Extend DELETE syntax 63396f8 qc_sqlite: Match "autocommit" caseinsensitively e804dd3 qc_sqlite: Add support for LOCK/UNLOCK c23e442 qc_sqlite: Extend DELETE syntax 5460e31 qc: Add delete test ab392ad qc_sqlite: Free unused data 598c6f0 qc: Measure time of parsing 2fa3844 qc_sqlite: Put all changes being {%|#}ifdefs 1b43992 qc_sqlite: Modified update.test 1676ea4 qc_sqlite: LEFT|RIGHT are not required with JOIN 224ebd3 qc_sqlite: Extend UPDATE grammar dbecca9 qc_sqlite: Extend UPDATE grammar b6ca3b3 MaxAdmin security modification MXS-729 8fb47dd Remove copying of MariaDB embedded library files 22e1257 Normalize whitespace when canonicalizing queries 269cff2 MXS-697: Fix dbfwfilter logging for matched queries 6344f6f Ignore Apple .DS_Store files. d606977 Improve comments in response to code review. 619aa13 Add configuration check flag to MaxScale 27c860b Drain write queue improvements. 33d4154 Read only one configuration file d104c19 Format more core files 83fdead Format part of core source code 311d5de Format gateway.c and config.c with Astyle 8cbb48e Don't build maxavro library if BUILD_AVRO is not defined 32bb77a Merge branch 'MXS-483' into develop db72c5d Format CDC/Avro related files 3c26e27 qc_sqlite: Use SrcList instead of Expr f96ad6a Merge branch 'develop' into MXS-729 0728734 Fix query canonical form tests e68262d Merge remote-tracking branch 'gpl-maxscale/master' into develop 65460dc Fix missing symbols from MySQLAuth 791c821 MaxAdmin listens on UNIX socket only and maxadmin can connect 89afed6 MXS-66: All configuration errors are fatal errors d613053 Add more details to galeramon documentation 22f4f57 qc: Add support for multi UPDATE 0dba25a Added default port to blr_make_registration 9d8248c qc_sqlit: Plug leaks and access errors 057551a qc_sqlite: Fix to small an allocation 1f73820 qc_sqlite: Free memory allocated during parsing 93fefb9 qc: Enable compare to run the same test repeatedly e52c578 qc_sqlite: Handle last_insert_id() 929e02a qc_sqlite: Extend UPDATE grammar de3b9f7 qc_sqlite: Defines provided when running cmake and make 4d5c3b2 qc_sqlite: Add support for multiple-table DELETE FROM 36a4296 qc_mysqlembedded: Handle SQLCOM_DELETE_MULTI 41f613a Fix DCB and SESSION removal from free object pools 00f2ddd Move some common code used in only one protocol into protocol. 6fbd0b0 Format Go source with gofmt abfbbcb Fix build failures and internal test suite 31de74a Merge branch 'develop' into MXS-483 20d461d Remove uniqueness constrain on oneshot tasks 6c09288 Add missing error message to converter task 0c2c389 Merge branch 'develop' into MXS-483 fa0accc Set freed memory to NULL after authentication failure 63f24e4 Install cdc_schema.go 5123c21 Fix ALTER TABLE parsing 004acc2 Merge branch 'develop' into MXS-483 f69a671 Remove array foreach macro use a159cd9 qc_sqlite: Add support for SHOW DATABASES 31a2118 Make qc_mysqlembedded optional 27ef30e Changed the default query classifier 359010d Add -h flag as the alias for --host bebc086 Fix minor bugs c7ca253 qc_sqlite: Recognize START [TRANSACTION] 240f8bf qc_sqlite: Collect info from nested SELECTs 93ea393 qc_sqlite: Pass along the relative position of a token cc960af qc_sqlite: Fix incorrect assigment 22a6fef Fix `gtid` avro index table 4c38bef qc_sqlite: STATUS is not a registered word cace998 qc_sqlite: Include all fields of UPDATE 997b19c qc: Add update tests 7601b3f qc_sqlite: Parse "INSERT INTO t VALUES (), ();" correctly ca426f1 qc_sqlite: Handle CREATE TRIGGER f54f963 qc_sqlite: Allow INSERT without INTO e4a1b6d Remove foreign keys from Avro index e4501a2 Merge branch 'develop' into MXS-483 82b9585 Fix MMMon never assigning master status a45a709 qc_mysqlembedded: Find the leaf name 2f3ca8f qc_mysqlembedded: Recognize SQLCOM_REPLACE cc7ad83 qc_mysqlembedded: Pick up fields for INSERT SELECT as well 0e6b39e qc: Cleanup of select.test 9113f4f qc_sqlite: Pickup more fields from INSERT 4d58f98 Dummy query classifier dfe824f Document `query_classifier` option 4aa329b MXS-718: Collect fields of INSERT 53818f2 Modify packet number for SSL backend connection 346f973 qc_sqlite: Accept qualified column names 8a83616 Fix in-memory SQLite table structure 6f2c884 Further backend SSL development 4444e92 qc_sqlite: Extend INSERT grammar 2aebcab qc_sqlite: Add support for TRUNCATE 1a6742e qc_sqlite: Accept DEFAULT as value in INSERT 07dec05 qc_sqlite: Crude classification made based on seen keywords a90a579 Add missing function documentation 72bd0cf qc_sqlite: Change CREATE TABLE grammar 6e04bc8 qc: Add INSERT tests 3666bda qc_sqlite: Add SELECT test d27e173 Add server/mysql-test/t/select.test to query_classifier 562d004 qc_sqlite: Cleanup error logging. 819cacb Merge branch 'develop' into MXS-483 0d3a789 Add warnings and comments to Avro row event processing 2fab570 Added support for SET autocommit=1 1aa83cf Code review fix c999f0a Addition of SELECT USER() 8c723da Clean up avro_client.c and avro_file.c eb21ee8 Clean up avro.c 946a284 Added Avro schema to table metadata processing 72f90be qc_sqlite: Add support for CREATE {FUNCTION|PROCEDURE} ... 4a4ab49 qc: Update line number also when skipping a block ffddb2a qc_sqlite: Allow queries using INTERVAL b8b03bd qc_sqlite: Add support for SELECT * FROM tbl2 = tbl1; 77a261a qc_sqlite: Add support for GROUP BY ... WITH ROLLUP 0ead41e cdc_schema now generates lowercase JSON 66e327a Classifier has to be specified explicitly 9074b91 Updated Avrorouter documentation cf06c7a qc_sqlite: Some comments added. f579eff Added simple Go based Avro schema generator f448e90 MXS-419: Added ulimit calls to init scripts b4ad257 Added FindAvro.cmake 56cc9b9 Added the last transaction script to installations 2d52da2 Added temporary avro-alpha package name 6ada071 Fixed cdc_users script 61f0206 Renaming and minor fixes to CDC Python scripts 9d77c32 Moved GTID table tracking to an in-memory database 8ae7cb0 MXS-704: Fixed `which` usage in post-install scripts 195e118 Readwritesplit sessions aren't created if master is down 2be91da Added affected tables to avro diagnostics b185320 QUERY-LAST-TRANSACTION now returns proper table names 90860b5 Log stale master message only once 4859c60 Table name to GTID mapping f77bd23 First steps to backend SSL, not yet working. 68b5bf0 qc_sqlite: Don't treat TRUE and FALSE as identifiers fca8e59 qc_sqlite: Collect database names as well 6b0e04d qc_sqlite: Add support for SHOW CREATE VIEW 77f4b34 qc_mysqlembedded: Report more, rather than less a73e033 qc_sqlite: Extend builtin functions 9d9650e qc_sqlite: SQL_BUFFER_RESULT must decay to an id 83fe99d qc_sqlite: Support INSERT IGNORE 9d1c9ca Added avrorouter limitations and tutorial 8dd094d qc_sqlite: Recognize builtin functions 2edc3d6 Moved write operations of the maxavro library to a different file 1364e54 Added more comments to the Avro RBR handling code f711588 Added warnign about unsupported field types df0d250 Added SQLite3 based indexing to avrorouter 0c55706 Added GTID event flag check in AVRO processing bfe28dd qc_sqlite: Accept SET GLOBAL|SESSION ... a8d2068 qc_mysqlembedded: Exlude code that won't compile on 5.5.42 16ea0b3 qc_sqlite: Add support for DROP FUNCTION 1c0f1fc qc: Report stats after comparison 02345b2 qc_sqlite: Recognize builtin readonly functions c7a5e75 qc_sqlite: Recognize := 0aa849d qc: Make compare undestand the delimiter command fb0a877 qc_mysqlembedded: Examine Item::SUBSELECT_ITEMs 045cf8d qc: Add missing mtl commands e5c6f45 qc_sqlite: Relax qc_get_type comparison ac3b2df qc_sqlite: Add support for SHOW STATUS 73a34fb qc_sqlite: Add initial support for FLUSH 4ffbe79 qc_sqlite: Extend CREATE TABLE syntax 009af81 qc_sqlite: Add support for SHOW WARNINGS 001de97 qc: Ignore mysqltest constructs 128307d Merge branch 'release-1.4.3' into gpl-master 5e8a06a SET NAMES XXX added 3ca12ba MXS-685: MMMon clears server state before setting it dc4d2b0 Further steps to connection limit, non-working. ef70257 MXS-636: Master failures are no longer fatal errors 99f4c64 Updated QUERY-LAST-TRANSACTION format d1ff157 Changed QUERY-LAST-TRANSACTION format to JSON 8b2f1ac Fixed formatting of the avrorouter 61543df Added QUERY-LAST-TRANSACTION command c10d10b qc_sqlite: Add support for SHOW CREATE TABLE 106a38f qc_sqlite: Add support for DROP INDEX 2a85421 qc_sqlite: Extend what can be stated about a table 794cd1c qc_sqlite: Add support for MATCH ... AGAINST dd7b747 qc_sqlite: Accept FULLTEXT and SPATIAL in CREATE TABLE a13d6ce qc_sqlite: Add support for PREPARE and EXECUTE 0c5d29f qc_sqlite: Add support for ANALYZE a6cd32b qc_sqlite: Extend SET syntax 5d47704 qc_sqlite: Pick out fields from UPDATE t SET i = ... 0e05735 qc: Understand --error in server test files 8535975 qc_sqlite: Extend CREATE VIEW syntax b35e638 qc: Igore read type bit if write bit is on 818a814 qc_sqlite: Add support for SHOW VARIABLES 1aa877b qc_sqlite: Add initial support for DO e92913a qc_sqlite: Add support for CREATE VIEW d53a46d qc_sqlite: Recognize bit field literals b'1010' 1fb7977 Added GTID event timestmap into struct gtid_pos 8f95b10 Added new fields in AVRO diagnostics cb4db54 Added tests with large SQL packets to modutil tests e4dbd6b MXS-621: More fixes to log messages at startup 4f1e9ee qc: compare tester can now read server MySQL tests cd8154b qc_sqlite: Allow CHARACTER SET to be specified for column 6f8d053 Added MariaDB 10.1 check for new flags in GTID event 71c471b qc_mysqlembedded: Fix type bits setting 26b00a7 qc_sqlite: Extend ALTER grammar ea6057c qc_sqlite: Handle also pInto when dupping a struct select 2271559 qc_sqlite: Add support for SHOW TABLE STATUS 9caaf27 qc_sqlite: Add support for CREATE ... LIKE oldtable cd19932 Merge tag '1.4.2' into master 9e9e4d8 Merge branch 'develop' of https://github.com/mariadb-corporation/maxscale-bsl into develop 267cb60 qc_mysqlembedded: Look into parenthesized comma expressions 77c6ca9 qc_sqlite: Recognize token "<=>" 5ca9a9f qc_sqlite: Allow comma expressions in where clause b08e910 qc_sqlite: Add SELECT options d11e581 qc_sqlite: Some recursion cleanup d53d063 Add but don't invoke connection queue functionality. 6818104 Fix logic error in connections limiter 3c61605 qc_sqlite: Find more affected fields 9af8dfd Allow the classifiers to be specified on the command line 5d4a134 Activate call to protocol for max connections error message. 16638e7 Fix another mistake 234f9e6 Fix mistake 843a6fc Fix mistake. 2c6e9ad Fix errors in config.c; enable call to protocol on connection limit. fd27849 Introduce configuration items for Maximum and Queued Service connections 60d198d Implement very simple connection limit. 84d8f0f Merge remote-tracking branch 'origin/develop' into MXS-177 8a58e63 Merge remote-tracking branch 'origin/develop' into develop 08487cd Add assertion to enforce number of free DCBs not being negative. f73af2f Added MariaDB 10.1 check for new flags in GTID event 23898ec Fix wrong sprintf specifier, trailing white space. ea6cfa3 readwritesplit: Cleaned up routeQuery 3858df0 Cleaned up select_connect_backend_servers c38ee13 Added more buffer tests 48816df Added more modutils tests 537eac2 Added tests for modutil_get_complete_packets 22a6095 MXS-669: modutil_get_complete_packets no longer makes the buffer contiguous 51af97e qc_sqlite: Add support for CREATE INDEX e50c573 qc_sqlite: Dig out fields for IN f58c6df qc_sqlite: Dequote table name 319422b qc_sqlite: Accept ENUM as type for a column 5d6a45c qc_sqlite: Allow UNSIGNED to fallback to an id 16a5f20 qc_sqlite: Extend CREATE TABLE syntax d6268da qc_sqlite: Accept RIGHT and FULL OUTER joins 2207415 qc_sqlite: Allow STRAIGHT_JOIN in SELECT 6fee546 qc_sqlite: Pick upp more table names 9de5f84 Remove trailing white space. 758f84d Improve comments and messages in dcb.c and session.c re recycle memory. 1c2de21 Merge remote-tracking branch 'origin/develop' into dcb-optimise 6614944 DCB code tidying. Fix missing spinlock release; remove redundant variables ecd5e5c Remove extra code introduced by merge. 877127a Merge commit '3c0d3e5ab6ddde59da764ec904b517759074a31e' into develop 4275bbe Updated the Connector-C version to 2.2.3 c71042b Some tentative list management code; provide for counting service clients. ad0c8a6 qc_sqlite: Allow empty insert statement 72e75e5 qc_sqlite: Add support for SELECT ... INTO cc553fa qc_sqlite: MAXSCALE define can now be used everywhere 3305c6e qc_sqlite: Handle CASE in SELECT 702f62e qc_sqlite: Extend CREATE TABLE grammar 941c212 qc_sqlite: Add support for SHOW [INDEX|INDEXES|KEYS] 6a79136 qc_sqlite: Extend grammar for SHOW TABLES and SHOW COLUMNS f175d2d qc_sqlite: Add SHOW COLUMNS support 6e47951 qc_sqlite: Add support for SHOW TABLES bcfa0e7 qc_mysqlembedded: Return the actual name and not as-name 3e19f2e Fixed qlafilter build failure 810b24e MXS-675: Standardized qlafilter output be92173 qc_sqlite: Exclude alias names from affected fields 9479280 qc_sqlite: Add support for explain EXTENDED 13b0e10 qc_sqlite: Add support for DELETE a6ccfea qc_mysqlembedded: Look at all conditional items b428041 qc_sqlite: Extend SELECT options 83f829f query_classifier: Correctly calculate the length of a GWBUF 2ddb24c query_classifier: Ensure that -- comments are handled fa7a746 qc_sqlite: Allow STRAIGHT_JOIN in SELECTS 6f47819 FindLibUUID update 5ed897b Added FindLibUUID cmake file 16e02bb Added FindLibUUID cmake file aff63e0 MXS-680: qc_mysqlembedded does not look into functions 8a0eeb4 query_classifier: Improve output of compare 6f08185 Query classifier can now convert enums to strings 124e2b9 MXS-679: Correctly collect fields of WHERE 353c97c transaction_safety default is off 896e37b qc_sqlite: Invert stop logic and be more verbose 7a44d4d qc_sqlite: Extend what is accepted in CREATE TABLE 4dbf499 qc_sqlite: Accept FIRST in ALTER TABLE 3f655c0 qc_sqlite: Update table and affected fields for INSERT 8e1e275 qc_sqlite: Make AS optional in CREATE statement 5f2084b qc_sqlite: Add support for ENGINE when creating a table 242f183 qc_sqlite: CREATE paramters handled in the correct place 8ed2e25 qc_sqlite: Trace only when needed 63d4531 qc_sqlite: Update affected fields also from functions 118cdc3 qc_sqlite: Allow multiple index names in USE|IGNORE INDEX 912da76 qc_sqlite: Add initial support for ...IGNORE INDEX... 0aa7de6 qc_sqlite: Log detailed message on error 3e3bf1a qc_sqlite: Extend create syntax. c4a4572 qc_sqlite: Exclude quoted values 1621f49 Removed MYSQL_EMBEDDED_LIBRARIES d3e324c UUID generation now comes from libuuid e8fe678 qc_sqlite: Enable confitional compilation a9522ba qc_sqlite: Handle X.Y selects 9bc9770 qc_sqlite: Use same stream when outputting padding 366257a qc_sqlite: Add support for UNSIGNED and ZEROFILL d4d90ff qc_sqlite: Add support for DROP VIEW d0519bd qc_sqlite: Extend DROP TABLE syntax c1e4894 qc_sqlite: Add flag to compare for stopping at first error 9fd6344 MXS-674: Maxinfo generates invalid JSON 3c0d3e5 Fix stupid errors. 9d32b2d Include read queue in buffer provided by dcb_read; changes to match. b690797 Fix double spinlock release in random_jkiss. 6a4328f Fix problems of memory not being freed in some error cases. 2112e56 Change DCB and Session handling to recycle memory; fix bug in random_jkiss. 3912f72 MXS-631, MXS-632: Cleaned up default value CMake files 383ccb8 Fixed build failure on MariaDB 5.5 a60bca5 Merge branch '1.2.1-binlog_router_trx' into develop 3c2a062 Fix to crashes in embedded library with MariaDB 10.0 d3fe938 MXS-662: Service protocol check no longer ignores bind address c3da49b qc_sqlite: Update affected fields from everywhere 7a0fab8 qc_sqlite: Allow verbosity of compare test to be controlled 81d6822 qc_sqlite: Cleanup handling of select columns 13e5c59 qc_sqlite: Introduce custom allocation functions 026f27d qc_sqlite: Add support for "USE database" 99079df qc_sqlite: Ignore duplicates when comparing affected fields ca45cd6 qc_sqlite: Add initial support for qc_get_database_names 75970b6 qc_sqlite: Add support for DROP TABLE. b97e45d qc_sqlite: Move get_affected_fields() to other helpers cb0fa96 qc_sqlite: Collect table names of INSERT 3a7c513 qc_mysqlembedded: Only look for created name if CREATE 308b0a4 qc_sqlite: Add support for gc_get_created_table_name. 0dc4af2 qc_sqlite: Add qc_has_clause() handling to update e9f2d1d qc_sqlite: Update now also provides table names c3192e4 qc_sqlite: Add initial support for get_table_names c51eafd qc_sqlite: Add support for qc_has_clause f318fb2 qc_mysqlembedded: Work around embedded lib bug 4ba2e11 qc_sqlite: Add initial support for qc_get_affected_fields 080dea5 qc_sqlite: Support is_read_query 3f94df1 Fixed compare.cc build failure 868a712 Updated freeing of buffer chains in readwritesplit 9bf7fca Formatted readwritesplit source code de4da2b Add assertion to spinlock release to detect release of already released spinlock. d30955a qc_sqlite: Handle the default case of affected fields. 5d02b3f qc_sqlite: Set operation when creating table 94a334d Add test for comparing qc-output aa6f5d6 Allow a specific query classifier to be loaded explicitly c799d37 Test both qc_mysqlembedded and qc_sqlite f8d9aa1 qc_sqlite: Enable "set @user_var=@@system_var" f190bdc qc_sqlite: Recognize /*!-comments b694b55 Fixed binary Avro format streaming c95fa86 qc_sqlite: Report correctly the type of set autocommit 9cb236c qc_sqlite: Add test case 77b4e62 Ensure classify test checks all types 962039e Change return type of qc_get_type ae00df8 qc_sqlite: Add initial support for the SET statement. 88253c5 qc_sqlite: Rename functions fa48043 Rework of MySQL backend protocol clean up to fix fault. 3851064 qc_sqlite: Correct recognition of system variables (@@xyz). 9d86f7f qc_sqlite: Detect user and system variables. a683297 qc_sqlite: Recognize and accept system variables (@@xyz). a4f64dd qc_sqlite: Add initial support for CREATE [TEMPORARY] TABLE f834b4f MXS-661: Only COM_QUERY packets are parsed 30077c1 CMake policies set only for correct versions a166f34 Suppress warning about unknown CMake target 1412730 Added more variables to launchable monitor scripts 358c194 MXS-656: Galera nodes with index 0 can be master again 842aec5 qc_sqlite: Add support for BEGIN, COMMIT, ROLLBACK b9cad6d Add initial support for UPDATE. 95741cb Add initial support for insert. 3796158 Re-install sqlite whenever parse.y has changed 5bcd8cf Ensure that the query is the one passed cf05533 Add support for obtaining the type of a query 400d8b4 Always log the outcome 45cf632 Fixed resource leaks and minor bugs fa9e970 Printout the query when there is a mismatch. 263cb07 All classify to be used with any query classifier ea381b9 Further cleanup of classify.c 23f6f30 Merge pull request #107 from godmodelabs/typo-dpkg 8c2a64e Fixed classify build failure 0c3070b Fixed binlog to Avro conversion bugs b827ba9 MXS-653: Silence maxpasswd 30d981c MXS-654: Add test for checking maxpasswd 984039b Rearrange classify.c 837e46d Add log initialization 1cc7a6e Reformat query_classifier/test/classify.c 065a4e5 Merge branch 'develop' into develop-MXS-544-b-merge ca27f13 Fixed binlog build failure fb81be2 fixed typo dpgk <-> dpkg 1e88d5d Added python based CDC user creation script 040bbdd MXS-633: Monitor permission checks moved to modules cde7595 Master-Slave clusters are now robust by default 158c776 Cleaned up core test suite 94c6e66 Fixed bugs resulting from merge a491e11 Merge remote-tracking branch 'origin/MXS-544-b' into develop-MXS-544-b-merge 30f9f25 Cleaned up avro.c 6286f64 Merge branch 'release-1.4.1' into develop 00206ac MXS-194: Added support for more query types to dbfwfilter 267832b Fixed diagnostic output a64b694 Fixed bugs in avrorouter 8faaba1 Fixed a bug in GTID seeking a5fafb7 Fixed typos in avrorouter documentation 8080379 Added avrorouter documentation fa07d8a Fixed dbfwfilter rule parser build failure 744ce0d Constraints are ignored in DDL statement processing 50808c6 Cleaned up avrorouter 47f6032 Merge branch '1.2.1-binlog_router_trx_lint' into develop caa0956 Added missing dependencies to maxscale-core 92df61a Remove parallel make from travis coverity builds fa2b2b4 Added more error logging to Avro record reading 9a98e8b Support for GTID requests and data bursts c2a787b Small diagnostic fix c4cee7e Added format output requested by client 50483c7 Cleaning up of Avro code d485379 Added support for binary Avro protocol c22cdbb Converted Avro GTID from string to integer representation 5795ca9 Added coverity notification email to .travis.yml a06e44d Added coverity_scan to Travis 6b94384 Fixed memory leak in avro_schema.c a11096c Support for db.table request for Avrorouter 4e5cbbf Fixed bugs in Avro record reading a99e427 Fixed minor bugs in avrorouter 01db8ae Fixed errors with CREATE TABLE statements f5f3d7a Diagnostic routine update 209324f Added missing include for log_manager.h e62f764 Added sending of schemas and file rotation 8c8fcbb Added missing log_manager.h include b13942d Changed printf calls in maxavro library to MXS_ERROR 1168962 More lint inspired changes, mainly in blr_master.c and blr_slave.c ced8f2f Fixed directory checks in avrorouter a8ae6be Minor fix to string processing fbd2d95 Fixed typo in dbfwfilter's CMakeLists.txt 29c3cf4 Merge pull request #106 from mariadb-corporation/willfong-patch-1 854d4e9 Add password column name to example 2f956df Moved server state change logging to a common function 007121f Fixed truncated string values 782892b Fix lint errors and warnings for blr_file.c 4f99fc5 Added Avro testing script 2820980 Small fix to help clear lint problems in blr.c 3afeda4 Fixed errors and warnings located by lint ecfff82 Fix most lint problems in blr.c 223689c Added ALTER TABLE support 80bc935 Fix final lint problems with mysql_common protocol functions. e068310 Added preliminary alter table parsing 8c723f1 Lint monitor modules fdb5620 Fix lint issues in authenticators. 84f0e04 Added function documentation and renamed files 365d9f5 Tidy up, mainly for lint 2ff3005 Added update rows event processing and event types to avro records 2ae0371 Fixed failing regex and improved data streaming f19206a Renamed avrorouter header aa7174b Moved relpacement and storage of ddl statements to a separate function 0c10be8 Improved client notification and added Avro block size managemet 91405a7 Cleaned up instance creation dd97485 Removed useless vars af64e9e Added CDC authentication with a db file b73a118 Streamline and lint MySQL backend protocol. 65034ce Merge branch 'release-1.4.0' into develop 28f7e4e Added callback for AVRO client async data transmission 628c27a Added MAXAVRO_FILE struct to AVRO_CLIENT 32b3645 Fixed slavelag build failure 7b15542 Added default authentication method for CDC protocol 5f8e20f Renamed maxavro types and formatted files that use them 882cf84 Added more function documentation to maxavro library 9532f0b Fixed CDC protocol build failure 35a1d3a Added support for offsets in client requests 94577ac Fixed, formatted and refactored CDC protocol da9bcad Use the maxavro library to read data from Avro files 3ececee Added low level error checking to maxavro library 01b0b8b Tidy and lint mysql_client.c 943f0a7 Added handling of Avro boolean data types to maxavro library 4c781f7 Cleaned up maxavro library and avrorouter 6b2e85d Renamed functions more consistently and cleaned up code e07158a Moved query event handling to its own function df7d4c0 Added avro_ prefix to rbr.c fcbfceb Added seeking to a position in an Avro file 068243a CDC auth decoding 3584d54 Add checks to simplify downstream logic. 9b2c323 Removed useless fprintf bd5cd52 Added missing authfunc setup e4aff59 Added record value processing 5cc8615 Added value length functions 7921ecc Merge branch 'MXS-615' into MXS-483 4b09cca Added Travis status to readme.md cca3a48 Simplify interface to max admin authentication. 4739838 Authenticator API update 233505f Maxavrocheck now accepts multiple files 3fdd137 Improved the Avro file handling a6ba913 Merge from MXS-615 417d742 Added maxavrocheck 014f9cf Remove obsolete second parameter from authenticate function in authenticators. ece7ece MaxAdmin authentication converted to a module. Fix quirk in SSL setup. 7c8b37e Moved contents of avro_schema.h into mxs_avro.h d6660cf Improvements to type handling 71ed0cf Protocol API to have entry point for obtaining default authenticator name. 9d35de2 Fixed transaction tracking 5be02a2 Avrorouter internal state is now stored in the Avro file directory 9293464 Added new info to avro diagnostics 06e0e93 Protocol modules can still handle the authentication outside authenticator modules 6d7108b Added JSON output when Requesting an avro file 6188211 Added new CDC protocol state c8af27f CDC authentication uses its own authenticator 6590f94 Factor out qc_get_qtype_str b7880f1 Fix qc_sqlite CMakeLists.txt bd4ff43 Fixed connector-c being updated and built after every make invokation 0d9e57b Fixed non-MariaDB connectors being used in builds 3d3b779 FIX BUG IN CLIENT DCB SHUTDOWN THAT CAN CAUSE CRASHES e45ba33 Fixed Connector-C .cmake files c130189 Fixed connector-c being updated and built after every make invokation 7f3cdf3 Fixed errors on binlog rotation 9d3c83a Remove qc_sqlite 15e8ba5 CDC protocol is now compliant with new protocol structure 4460869 Merge branch 'release-1.4.0' into MXS-483 ea40812 Cleaned up the binlog processing loop cb646ca Add minimal select recognition to qc_sqlite ac1a9c5 Fixed binlogrouter test 85dd227 Re-route sqlite's sqlite3Select. 7a2e6f3 Update CMakeLists.txt for qc_sqlite 7a751c3 Added timestamps to records and fixed minor bugs f73bdde Avrorouter state storage to disk fcf0488 Fixed Connector-C .cmake files 48b8e4e Merge branch 'MXS-615' into MXS-615-binlog-merge 7c8e19f Add missing dependencies for qc_sqlite bb9b667 Improvements to type handling and binlog position tracking dc66b74 Client UUID added f12fce4 AVRO registration is now handled by avro router 575b809 Add skeleton sqlite-based query classifier. d09d5fc Build sqlite 146d1f9 Fixed BLOB type handling and refined error messages 6e9e521 Added client user to diagnostics 4538bb8 Merge pull request #104 from rasmushoj/develop 7e18d95 Avro router diagnostics routine update 01e3f75 reverted changes in CMakeLists.txt 52f7c78 reverted changes in postinst.in eaed577 Added sqlite 3110100 a58cdda Travis configuration for MaxScale. ... 38b452d MIGRATE FREE CLIENT DATA TO AUTH MODULE; BUG FIXES; TIDY UP 6e64506 Fixed minor bugs aff2411 Enabled CDC protocol f669100 Fixed NULL Avro value being assigned to a field which cannot be NULL 8f6b16a Added row event processing to avrorouter 2939fe0 Updated Avro schema management to use actual column names 9e3b0cb Removed use of RBR related functions in binlogrouter d674903 Formatted avro files fe028d1 DEVELOPMENT OF AUTHENTICATION AS MODULE - WILL NOT WORK YET 977aded Added authenticator modules to the build a2b384f MOVE MYSQL AUTH CODE INTO AUTHENTICATOR MODULES DIRECTORY a5d7484 PRELIMINARY CHANGES TO CREATE AUTHENTICATORS AS MODULES 66cf802 Merge remote-tracking branch 'origin/develop' into MXS-615 bca0a7d MINOR CHANGES TO SATISFY LINT 5a9e397 Added Avrorouter binlog file walking fbc737f Fixed binlogrouter test 3c7c9d7 Added avrorouter main event handling loop 07ad81b Moved common binlogrouter code to a separate file 8c605ed Fixed avrorouter build failures aa1ba05 Moved binlog definitions to a separate header and fixed build failures eee7c55 Added create table statement detection e52b27e Added AVRO_INSTANCE and AVRO_CLIENT 0830caa Change test for client DCB to use role being DCB_ROLE_CLIENT_HANDLER. ... 997bbca Change protocols to continue looping if an accept fails; ... 522e42d Make use of dcb_accept and dcb_listen in httpd and telnetd protocols. 4e692b0 Generalise dcb_listen to tailor log messages to different protocols. ... 52c431d Remove support for passing default port number when handling ... afe5abc Fix bug in creation of SSL listener structure; fix bugs in ... 0bd6c77 Merge remote-tracking branch 'origin/MXS-544' into MXS-544-a ... 7598597 Add dcb_listen function to make a given DCB into a listener, ... a275d89 Maxbinlogcheck avro version can detect proper end of file 9bb55a5 Moved row event and table map event handling to a separate file b7d9e09 Add/improve comments, fix mistake with premature return. c598770 First attempt at extracting general code into dcb_accept, ... f20f28f Testing with maxbinlogcheck b3c60b7 Added mysql_binlog files 0ff9971 Added MariaDB/MySQL binary data processing functions 124560c Merge branch '1.2.1-binlog_router_trx' into MXS-483 4deccff New router fro cdc client 2c11434 Fixed test compiler errors c1f7d24 Obliged to merge remote-tracking branch 'origin/develop' ... 1775599 Merge remote-tracking branch 'origin/MXS-544' into Test-dev-544-merge c5317da Small modifications in comments 11c0666 Code cleanup 64a5e9a Merge branch 'release-1.3.0' into MXS-483 2c11e89 First Implementation of CDC
4168 lines
173 KiB
C
4168 lines
173 KiB
C
/*
|
|
** 2001 September 15
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
*************************************************************************
|
|
** Internal interface definitions for SQLite.
|
|
**
|
|
*/
|
|
#ifndef _SQLITEINT_H_
|
|
#define _SQLITEINT_H_
|
|
|
|
/*
|
|
** Include the header file used to customize the compiler options for MSVC.
|
|
** This should be done first so that it can successfully prevent spurious
|
|
** compiler warnings due to subsequent content in this file and other files
|
|
** that are included by this file.
|
|
*/
|
|
#include "msvc.h"
|
|
|
|
/*
|
|
** Special setup for VxWorks
|
|
*/
|
|
#include "vxworks.h"
|
|
|
|
/*
|
|
** These #defines should enable >2GB file support on POSIX if the
|
|
** underlying operating system supports it. If the OS lacks
|
|
** large file support, or if the OS is windows, these should be no-ops.
|
|
**
|
|
** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any
|
|
** system #includes. Hence, this block of code must be the very first
|
|
** code in all source files.
|
|
**
|
|
** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
|
|
** on the compiler command line. This is necessary if you are compiling
|
|
** on a recent machine (ex: Red Hat 7.2) but you want your code to work
|
|
** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2
|
|
** without this option, LFS is enable. But LFS does not exist in the kernel
|
|
** in Red Hat 6.0, so the code won't work. Hence, for maximum binary
|
|
** portability you should omit LFS.
|
|
**
|
|
** The previous paragraph was written in 2005. (This paragraph is written
|
|
** on 2008-11-28.) These days, all Linux kernels support large files, so
|
|
** you should probably leave LFS enabled. But some embedded platforms might
|
|
** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.
|
|
**
|
|
** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later.
|
|
*/
|
|
#ifndef SQLITE_DISABLE_LFS
|
|
# define _LARGE_FILE 1
|
|
# ifndef _FILE_OFFSET_BITS
|
|
# define _FILE_OFFSET_BITS 64
|
|
# endif
|
|
# define _LARGEFILE_SOURCE 1
|
|
#endif
|
|
|
|
/* What version of GCC is being used. 0 means GCC is not being used */
|
|
#ifdef __GNUC__
|
|
# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)
|
|
#else
|
|
# define GCC_VERSION 0
|
|
#endif
|
|
|
|
/* Needed for various definitions... */
|
|
#if defined(__GNUC__) && !defined(_GNU_SOURCE)
|
|
# define _GNU_SOURCE
|
|
#endif
|
|
|
|
#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
|
|
# define _BSD_SOURCE
|
|
#endif
|
|
|
|
/*
|
|
** For MinGW, check to see if we can include the header file containing its
|
|
** version information, among other things. Normally, this internal MinGW
|
|
** header file would [only] be included automatically by other MinGW header
|
|
** files; however, the contained version information is now required by this
|
|
** header file to work around binary compatibility issues (see below) and
|
|
** this is the only known way to reliably obtain it. This entire #if block
|
|
** would be completely unnecessary if there was any other way of detecting
|
|
** MinGW via their preprocessor (e.g. if they customized their GCC to define
|
|
** some MinGW-specific macros). When compiling for MinGW, either the
|
|
** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be
|
|
** defined; otherwise, detection of conditions specific to MinGW will be
|
|
** disabled.
|
|
*/
|
|
#if defined(_HAVE_MINGW_H)
|
|
# include "mingw.h"
|
|
#elif defined(_HAVE__MINGW_H)
|
|
# include "_mingw.h"
|
|
#endif
|
|
|
|
/*
|
|
** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T
|
|
** define is required to maintain binary compatibility with the MSVC runtime
|
|
** library in use (e.g. for Windows XP).
|
|
*/
|
|
#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \
|
|
defined(_WIN32) && !defined(_WIN64) && \
|
|
defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
|
|
defined(__MSVCRT__)
|
|
# define _USE_32BIT_TIME_T
|
|
#endif
|
|
|
|
/* The public SQLite interface. The _FILE_OFFSET_BITS macro must appear
|
|
** first in QNX. Also, the _USE_32BIT_TIME_T macro must appear first for
|
|
** MinGW.
|
|
*/
|
|
#include "sqlite3.h"
|
|
|
|
/*
|
|
** Include the configuration header output by 'configure' if we're using the
|
|
** autoconf-based build
|
|
*/
|
|
#ifdef _HAVE_SQLITE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "sqliteLimit.h"
|
|
|
|
/* 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
|
|
|
|
/*
|
|
** Include standard header files as necessary
|
|
*/
|
|
#ifdef HAVE_STDINT_H
|
|
#include <stdint.h>
|
|
#endif
|
|
#ifdef HAVE_INTTYPES_H
|
|
#include <inttypes.h>
|
|
#endif
|
|
|
|
/*
|
|
** 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 vary 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_WITHIN(P,S,E) macro checks to see if pointer P points to
|
|
** something between S (inclusive) and E (exclusive).
|
|
**
|
|
** In other words, S is a buffer and E is a pointer to the first byte after
|
|
** the end of buffer S. This macro returns true if P points to something
|
|
** contained within the buffer S.
|
|
*/
|
|
#if defined(HAVE_STDINT_H)
|
|
# define SQLITE_WITHIN(P,S,E) \
|
|
((uintptr_t)(P)>=(uintptr_t)(S) && (uintptr_t)(P)<(uintptr_t)(E))
|
|
#else
|
|
# define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E))
|
|
#endif
|
|
|
|
/*
|
|
** A macro to hint to the compiler that a function should not be
|
|
** inlined.
|
|
*/
|
|
#if defined(__GNUC__)
|
|
# define SQLITE_NOINLINE __attribute__((noinline))
|
|
#elif defined(_MSC_VER) && _MSC_VER>=1310
|
|
# define SQLITE_NOINLINE __declspec(noinline)
|
|
#else
|
|
# define SQLITE_NOINLINE
|
|
#endif
|
|
|
|
/*
|
|
** Make sure that the compiler intrinsics we desire are enabled when
|
|
** compiling with an appropriate version of MSVC unless prevented by
|
|
** the SQLITE_DISABLE_INTRINSIC define.
|
|
*/
|
|
#if !defined(SQLITE_DISABLE_INTRINSIC)
|
|
# if defined(_MSC_VER) && _MSC_VER>=1300
|
|
# if !defined(_WIN32_WCE)
|
|
# include <intrin.h>
|
|
# pragma intrinsic(_byteswap_ushort)
|
|
# pragma intrinsic(_byteswap_ulong)
|
|
# pragma intrinsic(_ReadWriteBarrier)
|
|
# else
|
|
# include <cmnintrin.h>
|
|
# endif
|
|
# endif
|
|
#endif
|
|
|
|
/*
|
|
** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
|
|
** 0 means mutexes are permanently disable and the library is never
|
|
** threadsafe. 1 means the library is serialized which is the highest
|
|
** level of threadsafety. 2 means the library is multithreaded - multiple
|
|
** threads can use SQLite as long as no two threads try to use the same
|
|
** database connection at the same time.
|
|
**
|
|
** Older versions of SQLite used an optional THREADSAFE macro.
|
|
** We support that for legacy.
|
|
*/
|
|
#if !defined(SQLITE_THREADSAFE)
|
|
# if defined(THREADSAFE)
|
|
# define SQLITE_THREADSAFE THREADSAFE
|
|
# else
|
|
# define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */
|
|
# endif
|
|
#endif
|
|
|
|
/*
|
|
** Powersafe overwrite is on by default. But can be turned off using
|
|
** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.
|
|
*/
|
|
#ifndef SQLITE_POWERSAFE_OVERWRITE
|
|
# define SQLITE_POWERSAFE_OVERWRITE 1
|
|
#endif
|
|
|
|
/*
|
|
** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by
|
|
** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in
|
|
** which case memory allocation statistics are disabled by default.
|
|
*/
|
|
#if !defined(SQLITE_DEFAULT_MEMSTATUS)
|
|
# define SQLITE_DEFAULT_MEMSTATUS 1
|
|
#endif
|
|
|
|
/*
|
|
** Exactly one of the following macros must be defined in order to
|
|
** specify which memory allocation subsystem to use.
|
|
**
|
|
** SQLITE_SYSTEM_MALLOC // Use normal system malloc()
|
|
** SQLITE_WIN32_MALLOC // Use Win32 native heap API
|
|
** SQLITE_ZERO_MALLOC // Use a stub allocator that always fails
|
|
** SQLITE_MEMDEBUG // Debugging version of system malloc()
|
|
**
|
|
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
|
|
** assert() macro is enabled, each call into the Win32 native heap subsystem
|
|
** will cause HeapValidate to be called. If heap validation should fail, an
|
|
** assertion will be triggered.
|
|
**
|
|
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
|
|
** the default.
|
|
*/
|
|
#if defined(SQLITE_SYSTEM_MALLOC) \
|
|
+ defined(SQLITE_WIN32_MALLOC) \
|
|
+ defined(SQLITE_ZERO_MALLOC) \
|
|
+ defined(SQLITE_MEMDEBUG)>1
|
|
# error "Two or more of the following compile-time configuration options\
|
|
are defined but at most one is allowed:\
|
|
SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\
|
|
SQLITE_ZERO_MALLOC"
|
|
#endif
|
|
#if defined(SQLITE_SYSTEM_MALLOC) \
|
|
+ defined(SQLITE_WIN32_MALLOC) \
|
|
+ defined(SQLITE_ZERO_MALLOC) \
|
|
+ defined(SQLITE_MEMDEBUG)==0
|
|
# define SQLITE_SYSTEM_MALLOC 1
|
|
#endif
|
|
|
|
/*
|
|
** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
|
|
** sizes of memory allocations below this value where possible.
|
|
*/
|
|
#if !defined(SQLITE_MALLOC_SOFT_LIMIT)
|
|
# define SQLITE_MALLOC_SOFT_LIMIT 1024
|
|
#endif
|
|
|
|
/*
|
|
** We need to define _XOPEN_SOURCE as follows in order to enable
|
|
** recursive mutexes on most Unix systems and fchmod() on OpenBSD.
|
|
** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit
|
|
** it.
|
|
*/
|
|
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
|
|
# define _XOPEN_SOURCE 600
|
|
#endif
|
|
|
|
/*
|
|
** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
|
|
** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
|
|
** make it true by defining or undefining NDEBUG.
|
|
**
|
|
** Setting NDEBUG makes the code smaller and faster by disabling the
|
|
** assert() statements in the code. So we want the default action
|
|
** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
|
|
** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
|
|
** feature.
|
|
*/
|
|
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
|
|
# define NDEBUG 1
|
|
#endif
|
|
#if defined(NDEBUG) && defined(SQLITE_DEBUG)
|
|
# undef NDEBUG
|
|
#endif
|
|
|
|
/*
|
|
** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
|
|
*/
|
|
#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
|
|
# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
|
|
#endif
|
|
|
|
/*
|
|
** The testcase() macro is used to aid in coverage testing. When
|
|
** doing coverage testing, the condition inside the argument to
|
|
** testcase() must be evaluated both true and false in order to
|
|
** get full branch coverage. The testcase() macro is inserted
|
|
** to help ensure adequate test coverage in places where simple
|
|
** condition/decision coverage is inadequate. For example, testcase()
|
|
** can be used to make sure boundary values are tested. For
|
|
** bitmask tests, testcase() can be used to make sure each bit
|
|
** is significant and used at least once. On switch statements
|
|
** where multiple cases go to the same block of code, testcase()
|
|
** can insure that all cases are evaluated.
|
|
**
|
|
*/
|
|
#ifdef SQLITE_COVERAGE_TEST
|
|
void sqlite3Coverage(int);
|
|
# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
|
|
#else
|
|
# define testcase(X)
|
|
#endif
|
|
|
|
/*
|
|
** The TESTONLY macro is used to enclose variable declarations or
|
|
** other bits of code that are needed to support the arguments
|
|
** within testcase() and assert() macros.
|
|
*/
|
|
#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
|
|
# define TESTONLY(X) X
|
|
#else
|
|
# define TESTONLY(X)
|
|
#endif
|
|
|
|
/*
|
|
** Sometimes we need a small amount of code such as a variable initialization
|
|
** to setup for a later assert() statement. We do not want this code to
|
|
** appear when assert() is disabled. The following macro is therefore
|
|
** used to contain that setup code. The "VVA" acronym stands for
|
|
** "Verification, Validation, and Accreditation". In other words, the
|
|
** code within VVA_ONLY() will only run during verification processes.
|
|
*/
|
|
#ifndef NDEBUG
|
|
# define VVA_ONLY(X) X
|
|
#else
|
|
# define VVA_ONLY(X)
|
|
#endif
|
|
|
|
/*
|
|
** The ALWAYS and NEVER macros surround boolean expressions which
|
|
** are intended to always be true or false, respectively. Such
|
|
** expressions could be omitted from the code completely. But they
|
|
** are included in a few cases in order to enhance the resilience
|
|
** of SQLite to unexpected behavior - to make the code "self-healing"
|
|
** or "ductile" rather than being "brittle" and crashing at the first
|
|
** hint of unplanned behavior.
|
|
**
|
|
** In other words, ALWAYS and NEVER are added for defensive code.
|
|
**
|
|
** When doing coverage testing ALWAYS and NEVER are hard-coded to
|
|
** be true and false so that the unreachable code they specify will
|
|
** not be counted as untested code.
|
|
*/
|
|
#if defined(SQLITE_COVERAGE_TEST)
|
|
# define ALWAYS(X) (1)
|
|
# define NEVER(X) (0)
|
|
#elif !defined(NDEBUG)
|
|
# define ALWAYS(X) ((X)?1:(assert(0),0))
|
|
# define NEVER(X) ((X)?(assert(0),1):0)
|
|
#else
|
|
# define ALWAYS(X) (X)
|
|
# define NEVER(X) (X)
|
|
#endif
|
|
|
|
/*
|
|
** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is
|
|
** defined. We need to defend against those failures when testing with
|
|
** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches
|
|
** during a normal build. The following macro can be used to disable tests
|
|
** that are always false except when SQLITE_TEST_REALLOC_STRESS is set.
|
|
*/
|
|
#if defined(SQLITE_TEST_REALLOC_STRESS)
|
|
# define ONLY_IF_REALLOC_STRESS(X) (X)
|
|
#elif !defined(NDEBUG)
|
|
# define ONLY_IF_REALLOC_STRESS(X) ((X)?(assert(0),1):0)
|
|
#else
|
|
# define ONLY_IF_REALLOC_STRESS(X) (0)
|
|
#endif
|
|
|
|
/*
|
|
** Declarations used for tracing the operating system interfaces.
|
|
*/
|
|
#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \
|
|
(defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
|
|
extern int sqlite3OSTrace;
|
|
# define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
|
|
# define SQLITE_HAVE_OS_TRACE
|
|
#else
|
|
# define OSTRACE(X)
|
|
# undef SQLITE_HAVE_OS_TRACE
|
|
#endif
|
|
|
|
/*
|
|
** Is the sqlite3ErrName() function needed in the build? Currently,
|
|
** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when
|
|
** OSTRACE is enabled), and by several "test*.c" files (which are
|
|
** compiled using SQLITE_TEST).
|
|
*/
|
|
#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \
|
|
(defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
|
|
# define SQLITE_NEED_ERR_NAME
|
|
#else
|
|
# undef SQLITE_NEED_ERR_NAME
|
|
#endif
|
|
|
|
/*
|
|
** Return true (non-zero) if the input is an integer that is too large
|
|
** to fit in 32-bits. This macro is used inside of various testcase()
|
|
** macros to verify that we have tested SQLite for large-file support.
|
|
*/
|
|
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
|
|
|
|
/*
|
|
** The macro unlikely() is a hint that surrounds a boolean
|
|
** expression that is usually false. Macro likely() surrounds
|
|
** a boolean expression that is usually true. These hints could,
|
|
** in theory, be used by the compiler to generate better code, but
|
|
** currently they are just comments for human readers.
|
|
*/
|
|
#define likely(X) (X)
|
|
#define unlikely(X) (X)
|
|
|
|
#include "hash.h"
|
|
#include "parse.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
#include <stddef.h>
|
|
|
|
/*
|
|
** If compiling for a processor that lacks floating point support,
|
|
** substitute integer for floating-point
|
|
*/
|
|
#ifdef SQLITE_OMIT_FLOATING_POINT
|
|
# define double sqlite_int64
|
|
# define float sqlite_int64
|
|
# define LONGDOUBLE_TYPE sqlite_int64
|
|
# ifndef SQLITE_BIG_DBL
|
|
# define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)
|
|
# endif
|
|
# define SQLITE_OMIT_DATETIME_FUNCS 1
|
|
# define SQLITE_OMIT_TRACE 1
|
|
# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
|
|
# undef SQLITE_HAVE_ISNAN
|
|
#endif
|
|
#ifndef SQLITE_BIG_DBL
|
|
# define SQLITE_BIG_DBL (1e99)
|
|
#endif
|
|
|
|
/*
|
|
** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0
|
|
** afterward. Having this macro allows us to cause the C compiler
|
|
** to omit code used by TEMP tables without messy #ifndef statements.
|
|
*/
|
|
#ifdef SQLITE_OMIT_TEMPDB
|
|
#define OMIT_TEMPDB 1
|
|
#else
|
|
#define OMIT_TEMPDB 0
|
|
#endif
|
|
|
|
/*
|
|
** The "file format" number is an integer that is incremented whenever
|
|
** the VDBE-level file format changes. The following macros define the
|
|
** the default file format for new databases and the maximum file format
|
|
** that the library can read.
|
|
*/
|
|
#define SQLITE_MAX_FILE_FORMAT 4
|
|
#ifndef SQLITE_DEFAULT_FILE_FORMAT
|
|
# define SQLITE_DEFAULT_FILE_FORMAT 4
|
|
#endif
|
|
|
|
/*
|
|
** Determine whether triggers are recursive by default. This can be
|
|
** changed at run-time using a pragma.
|
|
*/
|
|
#ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS
|
|
# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0
|
|
#endif
|
|
|
|
/*
|
|
** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
|
|
** on the command-line
|
|
*/
|
|
#ifndef SQLITE_TEMP_STORE
|
|
# define SQLITE_TEMP_STORE 1
|
|
# define SQLITE_TEMP_STORE_xc 1 /* Exclude from ctime.c */
|
|
#endif
|
|
|
|
/*
|
|
** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if
|
|
** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it
|
|
** to zero.
|
|
*/
|
|
#if SQLITE_TEMP_STORE==3 || SQLITE_THREADSAFE==0
|
|
# undef SQLITE_MAX_WORKER_THREADS
|
|
# define SQLITE_MAX_WORKER_THREADS 0
|
|
#endif
|
|
#ifndef SQLITE_MAX_WORKER_THREADS
|
|
# define SQLITE_MAX_WORKER_THREADS 8
|
|
#endif
|
|
#ifndef SQLITE_DEFAULT_WORKER_THREADS
|
|
# define SQLITE_DEFAULT_WORKER_THREADS 0
|
|
#endif
|
|
#if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS
|
|
# undef SQLITE_MAX_WORKER_THREADS
|
|
# define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS
|
|
#endif
|
|
|
|
/*
|
|
** The default initial allocation for the pagecache when using separate
|
|
** pagecaches for each database connection. A positive number is the
|
|
** number of pages. A negative number N translations means that a buffer
|
|
** of -1024*N bytes is allocated and used for as many pages as it will hold.
|
|
*/
|
|
#ifndef SQLITE_DEFAULT_PCACHE_INITSZ
|
|
# define SQLITE_DEFAULT_PCACHE_INITSZ 100
|
|
#endif
|
|
|
|
/*
|
|
** GCC does not define the offsetof() macro so we'll have to do it
|
|
** ourselves.
|
|
*/
|
|
#ifndef offsetof
|
|
#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
|
|
#endif
|
|
|
|
/*
|
|
** Macros to compute minimum and maximum of two numbers.
|
|
*/
|
|
#define MIN(A,B) ((A)<(B)?(A):(B))
|
|
#define MAX(A,B) ((A)>(B)?(A):(B))
|
|
|
|
/*
|
|
** Swap two objects of type TYPE.
|
|
*/
|
|
#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}
|
|
|
|
/*
|
|
** Check to see if this machine uses EBCDIC. (Yes, believe it or
|
|
** not, there are still machines out there that use EBCDIC.)
|
|
*/
|
|
#if 'A' == '\301'
|
|
# define SQLITE_EBCDIC 1
|
|
#else
|
|
# define SQLITE_ASCII 1
|
|
#endif
|
|
|
|
/*
|
|
** 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' ...
|
|
*/
|
|
#ifndef UINT32_TYPE
|
|
# ifdef HAVE_UINT32_T
|
|
# define UINT32_TYPE uint32_t
|
|
# else
|
|
# define UINT32_TYPE unsigned int
|
|
# endif
|
|
#endif
|
|
#ifndef UINT16_TYPE
|
|
# ifdef HAVE_UINT16_T
|
|
# define UINT16_TYPE uint16_t
|
|
# else
|
|
# define UINT16_TYPE unsigned short int
|
|
# endif
|
|
#endif
|
|
#ifndef INT16_TYPE
|
|
# ifdef HAVE_INT16_T
|
|
# define INT16_TYPE int16_t
|
|
# else
|
|
# define INT16_TYPE short int
|
|
# endif
|
|
#endif
|
|
#ifndef UINT8_TYPE
|
|
# ifdef HAVE_UINT8_T
|
|
# define UINT8_TYPE uint8_t
|
|
# else
|
|
# define UINT8_TYPE unsigned char
|
|
# endif
|
|
#endif
|
|
#ifndef INT8_TYPE
|
|
# ifdef HAVE_INT8_T
|
|
# define INT8_TYPE int8_t
|
|
# else
|
|
# define INT8_TYPE signed char
|
|
# endif
|
|
#endif
|
|
#ifndef LONGDOUBLE_TYPE
|
|
# define LONGDOUBLE_TYPE long double
|
|
#endif
|
|
typedef sqlite_int64 i64; /* 8-byte signed integer */
|
|
typedef sqlite_uint64 u64; /* 8-byte unsigned integer */
|
|
typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
|
|
typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
|
|
typedef INT16_TYPE i16; /* 2-byte signed integer */
|
|
typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
|
|
typedef INT8_TYPE i8; /* 1-byte signed integer */
|
|
|
|
/*
|
|
** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value
|
|
** that can be stored in a u32 without loss of data. The value
|
|
** is 0x00000000ffffffff. But because of quirks of some compilers, we
|
|
** have to specify the value in the less intuitive manner shown:
|
|
*/
|
|
#define SQLITE_MAX_U32 ((((u64)1)<<32)-1)
|
|
|
|
/*
|
|
** The datatype used to store estimates of the number of rows in a
|
|
** table or index. This is an unsigned integer type. For 99.9% of
|
|
** the world, a 32-bit integer is sufficient. But a 64-bit integer
|
|
** can be used at compile-time if desired.
|
|
*/
|
|
#ifdef SQLITE_64BIT_STATS
|
|
typedef u64 tRowcnt; /* 64-bit only if requested at compile-time */
|
|
#else
|
|
typedef u32 tRowcnt; /* 32-bit is the default */
|
|
#endif
|
|
|
|
/*
|
|
** Estimated quantities used for query planning are stored as 16-bit
|
|
** logarithms. For quantity X, the value stored is 10*log2(X). This
|
|
** gives a possible range of values of approximately 1.0e986 to 1e-986.
|
|
** But the allowed values are "grainy". Not every value is representable.
|
|
** For example, quantities 16 and 17 are both represented by a LogEst
|
|
** of 40. However, since LogEst quantities are suppose to be estimates,
|
|
** not exact values, this imprecision is not a problem.
|
|
**
|
|
** "LogEst" is short for "Logarithmic Estimate".
|
|
**
|
|
** Examples:
|
|
** 1 -> 0 20 -> 43 10000 -> 132
|
|
** 2 -> 10 25 -> 46 25000 -> 146
|
|
** 3 -> 16 100 -> 66 1000000 -> 199
|
|
** 4 -> 20 1000 -> 99 1048576 -> 200
|
|
** 10 -> 33 1024 -> 100 4294967296 -> 320
|
|
**
|
|
** The LogEst can be negative to indicate fractional values.
|
|
** Examples:
|
|
**
|
|
** 0.5 -> -10 0.1 -> -33 0.0625 -> -40
|
|
*/
|
|
typedef INT16_TYPE LogEst;
|
|
|
|
/*
|
|
** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
|
|
*/
|
|
#ifndef SQLITE_PTRSIZE
|
|
# if defined(__SIZEOF_POINTER__)
|
|
# define SQLITE_PTRSIZE __SIZEOF_POINTER__
|
|
# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
|
|
defined(_M_ARM) || defined(__arm__) || defined(__x86)
|
|
# define SQLITE_PTRSIZE 4
|
|
# else
|
|
# define SQLITE_PTRSIZE 8
|
|
# endif
|
|
#endif
|
|
|
|
/*
|
|
** Macros to determine whether the machine is big or little endian,
|
|
** and whether or not that determination is run-time or compile-time.
|
|
**
|
|
** For best performance, an attempt is made to guess at the byte-order
|
|
** using C-preprocessor macros. If that is unsuccessful, or if
|
|
** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined
|
|
** at run-time.
|
|
*/
|
|
#if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \
|
|
defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \
|
|
defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \
|
|
defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER)
|
|
# define SQLITE_BYTEORDER 1234
|
|
# define SQLITE_BIGENDIAN 0
|
|
# define SQLITE_LITTLEENDIAN 1
|
|
# define SQLITE_UTF16NATIVE SQLITE_UTF16LE
|
|
#endif
|
|
#if (defined(sparc) || defined(__ppc__)) \
|
|
&& !defined(SQLITE_RUNTIME_BYTEORDER)
|
|
# define SQLITE_BYTEORDER 4321
|
|
# define SQLITE_BIGENDIAN 1
|
|
# define SQLITE_LITTLEENDIAN 0
|
|
# define SQLITE_UTF16NATIVE SQLITE_UTF16BE
|
|
#endif
|
|
#if !defined(SQLITE_BYTEORDER)
|
|
# ifdef SQLITE_AMALGAMATION
|
|
const int sqlite3one = 1;
|
|
# else
|
|
extern const int sqlite3one;
|
|
# endif
|
|
# define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */
|
|
# define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0)
|
|
# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
|
|
# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
|
|
#endif
|
|
|
|
/*
|
|
** Constants for the largest and smallest possible 64-bit signed integers.
|
|
** These macros are designed to work correctly on both 32-bit and 64-bit
|
|
** compilers.
|
|
*/
|
|
#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
|
|
#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
|
|
|
|
/*
|
|
** Round up a number to the next larger multiple of 8. This is used
|
|
** to force 8-byte alignment on 64-bit architectures.
|
|
*/
|
|
#define ROUND8(x) (((x)+7)&~7)
|
|
|
|
/*
|
|
** Round down to the nearest multiple of 8
|
|
*/
|
|
#define ROUNDDOWN8(x) ((x)&~7)
|
|
|
|
/*
|
|
** Assert that the pointer X is aligned to an 8-byte boundary. This
|
|
** macro is used only within assert() to verify that the code gets
|
|
** all alignment restrictions correct.
|
|
**
|
|
** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the
|
|
** underlying malloc() implementation might return us 4-byte aligned
|
|
** pointers. In that case, only verify 4-byte alignment.
|
|
*/
|
|
#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
|
|
# define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&3)==0)
|
|
#else
|
|
# define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0)
|
|
#endif
|
|
|
|
/*
|
|
** Disable MMAP on platforms where it is known to not work
|
|
*/
|
|
#if defined(__OpenBSD__) || defined(__QNXNTO__)
|
|
# undef SQLITE_MAX_MMAP_SIZE
|
|
# define SQLITE_MAX_MMAP_SIZE 0
|
|
#endif
|
|
|
|
/*
|
|
** Default maximum size of memory used by memory-mapped I/O in the VFS
|
|
*/
|
|
#ifdef __APPLE__
|
|
# include <TargetConditionals.h>
|
|
#endif
|
|
#ifndef SQLITE_MAX_MMAP_SIZE
|
|
# if defined(__linux__) \
|
|
|| defined(_WIN32) \
|
|
|| (defined(__APPLE__) && defined(__MACH__)) \
|
|
|| defined(__sun) \
|
|
|| defined(__FreeBSD__) \
|
|
|| defined(__DragonFly__)
|
|
# define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */
|
|
# else
|
|
# define SQLITE_MAX_MMAP_SIZE 0
|
|
# endif
|
|
# define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */
|
|
#endif
|
|
|
|
/*
|
|
** The default MMAP_SIZE is zero on all platforms. Or, even if a larger
|
|
** default MMAP_SIZE is specified at compile-time, make sure that it does
|
|
** not exceed the maximum mmap size.
|
|
*/
|
|
#ifndef SQLITE_DEFAULT_MMAP_SIZE
|
|
# define SQLITE_DEFAULT_MMAP_SIZE 0
|
|
# define SQLITE_DEFAULT_MMAP_SIZE_xc 1 /* Exclude from ctime.c */
|
|
#endif
|
|
#if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE
|
|
# undef SQLITE_DEFAULT_MMAP_SIZE
|
|
# define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE
|
|
#endif
|
|
|
|
/*
|
|
** Only one of SQLITE_ENABLE_STAT3 or SQLITE_ENABLE_STAT4 can be defined.
|
|
** Priority is given to SQLITE_ENABLE_STAT4. If either are defined, also
|
|
** define SQLITE_ENABLE_STAT3_OR_STAT4
|
|
*/
|
|
#ifdef SQLITE_ENABLE_STAT4
|
|
# undef SQLITE_ENABLE_STAT3
|
|
# define SQLITE_ENABLE_STAT3_OR_STAT4 1
|
|
#elif SQLITE_ENABLE_STAT3
|
|
# define SQLITE_ENABLE_STAT3_OR_STAT4 1
|
|
#elif SQLITE_ENABLE_STAT3_OR_STAT4
|
|
# undef SQLITE_ENABLE_STAT3_OR_STAT4
|
|
#endif
|
|
|
|
/*
|
|
** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not
|
|
** the Select query generator tracing logic is turned on.
|
|
*/
|
|
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_SELECTTRACE)
|
|
# define SELECTTRACE_ENABLED 1
|
|
#else
|
|
# define SELECTTRACE_ENABLED 0
|
|
#endif
|
|
|
|
/*
|
|
** An instance of the following structure is used to store the busy-handler
|
|
** callback for a given sqlite handle.
|
|
**
|
|
** The sqlite.busyHandler member of the sqlite struct contains the busy
|
|
** callback for the database handle. Each pager opened via the sqlite
|
|
** handle is passed a pointer to sqlite.busyHandler. The busy-handler
|
|
** callback is currently invoked only from within pager.c.
|
|
*/
|
|
typedef struct BusyHandler BusyHandler;
|
|
struct BusyHandler {
|
|
int (*xFunc)(void *,int); /* The busy callback */
|
|
void *pArg; /* First arg to busy callback */
|
|
int nBusy; /* Incremented with each busy call */
|
|
};
|
|
|
|
/*
|
|
** Name of the master database table. The master database table
|
|
** is a special table that holds the names and attributes of all
|
|
** user tables and indices.
|
|
*/
|
|
#define MASTER_NAME "sqlite_master"
|
|
#define TEMP_MASTER_NAME "sqlite_temp_master"
|
|
|
|
/*
|
|
** The root-page of the master database table.
|
|
*/
|
|
#define MASTER_ROOT 1
|
|
|
|
/*
|
|
** The name of the schema table.
|
|
*/
|
|
#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)
|
|
|
|
/*
|
|
** A convenience macro that returns the number of elements in
|
|
** an array.
|
|
*/
|
|
#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0])))
|
|
|
|
/*
|
|
** Determine if the argument is a power of two
|
|
*/
|
|
#define IsPowerOfTwo(X) (((X)&((X)-1))==0)
|
|
|
|
/*
|
|
** The following value as a destructor means to use sqlite3DbFree().
|
|
** The sqlite3DbFree() routine requires two parameters instead of the
|
|
** one parameter that destructors normally want. So we have to introduce
|
|
** this magic value that the code knows to handle differently. Any
|
|
** pointer will work here as long as it is distinct from SQLITE_STATIC
|
|
** and SQLITE_TRANSIENT.
|
|
*/
|
|
#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3MallocSize)
|
|
|
|
/*
|
|
** When SQLITE_OMIT_WSD is defined, it means that the target platform does
|
|
** not support Writable Static Data (WSD) such as global and static variables.
|
|
** All variables must either be on the stack or dynamically allocated from
|
|
** the heap. When WSD is unsupported, the variable declarations scattered
|
|
** throughout the SQLite code must become constants instead. The SQLITE_WSD
|
|
** macro is used for this purpose. And instead of referencing the variable
|
|
** directly, we use its constant as a key to lookup the run-time allocated
|
|
** buffer that holds real variable. The constant is also the initializer
|
|
** for the run-time allocated buffer.
|
|
**
|
|
** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL
|
|
** macros become no-ops and have zero performance impact.
|
|
*/
|
|
#ifdef SQLITE_OMIT_WSD
|
|
#define SQLITE_WSD const
|
|
#define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
|
|
#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
|
|
int sqlite3_wsd_init(int N, int J);
|
|
void *sqlite3_wsd_find(void *K, int L);
|
|
#else
|
|
#define SQLITE_WSD
|
|
#define GLOBAL(t,v) v
|
|
#define sqlite3GlobalConfig sqlite3Config
|
|
#endif
|
|
|
|
/*
|
|
** The following macros are used to suppress compiler warnings and to
|
|
** make it clear to human readers when a function parameter is deliberately
|
|
** left unused within the body of a function. This usually happens when
|
|
** a function is called via a function pointer. For example the
|
|
** implementation of an SQL aggregate step callback may not use the
|
|
** parameter indicating the number of arguments passed to the aggregate,
|
|
** if it knows that this is enforced elsewhere.
|
|
**
|
|
** When a function parameter is not used at all within the body of a function,
|
|
** it is generally named "NotUsed" or "NotUsed2" to make things even clearer.
|
|
** However, these macros may also be used to suppress warnings related to
|
|
** parameters that may or may not be used depending on compilation options.
|
|
** For example those parameters only used in assert() statements. In these
|
|
** cases the parameters are named as per the usual conventions.
|
|
*/
|
|
#define UNUSED_PARAMETER(x) (void)(x)
|
|
#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y)
|
|
|
|
/*
|
|
** Forward references to structures
|
|
*/
|
|
typedef struct AggInfo AggInfo;
|
|
typedef struct AuthContext AuthContext;
|
|
typedef struct AutoincInfo AutoincInfo;
|
|
typedef struct Bitvec Bitvec;
|
|
typedef struct CollSeq CollSeq;
|
|
typedef struct Column Column;
|
|
typedef struct Db Db;
|
|
typedef struct Schema Schema;
|
|
typedef struct Expr Expr;
|
|
typedef struct ExprList ExprList;
|
|
typedef struct ExprSpan ExprSpan;
|
|
typedef struct FKey FKey;
|
|
typedef struct FuncDestructor FuncDestructor;
|
|
typedef struct FuncDef FuncDef;
|
|
typedef struct FuncDefHash FuncDefHash;
|
|
typedef struct IdList IdList;
|
|
typedef struct Index Index;
|
|
typedef struct IndexSample IndexSample;
|
|
typedef struct KeyClass KeyClass;
|
|
typedef struct KeyInfo KeyInfo;
|
|
typedef struct Lookaside Lookaside;
|
|
typedef struct LookasideSlot LookasideSlot;
|
|
typedef struct Module Module;
|
|
typedef struct NameContext NameContext;
|
|
typedef struct Parse Parse;
|
|
typedef struct PrintfArguments PrintfArguments;
|
|
typedef struct RowSet RowSet;
|
|
typedef struct Savepoint Savepoint;
|
|
typedef struct Select Select;
|
|
typedef struct SQLiteThread SQLiteThread;
|
|
typedef struct SelectDest SelectDest;
|
|
typedef struct SrcList SrcList;
|
|
typedef struct StrAccum StrAccum;
|
|
typedef struct Table Table;
|
|
typedef struct TableLock TableLock;
|
|
typedef struct Token Token;
|
|
typedef struct TreeView TreeView;
|
|
typedef struct Trigger Trigger;
|
|
typedef struct TriggerPrg TriggerPrg;
|
|
typedef struct TriggerStep TriggerStep;
|
|
typedef struct UnpackedRecord UnpackedRecord;
|
|
typedef struct VTable VTable;
|
|
typedef struct VtabCtx VtabCtx;
|
|
typedef struct Walker Walker;
|
|
typedef struct WhereInfo WhereInfo;
|
|
typedef struct With With;
|
|
|
|
/*
|
|
** Defer sourcing vdbe.h and btree.h until after the "u8" and
|
|
** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque
|
|
** pointer types (i.e. FuncDef) defined above.
|
|
*/
|
|
#include "btree.h"
|
|
#include "vdbe.h"
|
|
#include "pager.h"
|
|
#include "pcache.h"
|
|
|
|
#include "os.h"
|
|
#include "mutex.h"
|
|
|
|
|
|
/*
|
|
** Each database file to be accessed by the system is an instance
|
|
** of the following structure. There are normally two of these structures
|
|
** in the sqlite.aDb[] array. aDb[0] is the main database file and
|
|
** aDb[1] is the database file used to hold temporary tables. Additional
|
|
** databases may be attached.
|
|
*/
|
|
struct Db {
|
|
char *zName; /* Name of this database */
|
|
Btree *pBt; /* The B*Tree structure for this database file */
|
|
u8 safety_level; /* How aggressive at syncing data to disk */
|
|
Schema *pSchema; /* Pointer to database schema (possibly shared) */
|
|
};
|
|
|
|
/*
|
|
** An instance of the following structure stores a database schema.
|
|
**
|
|
** Most Schema objects are associated with a Btree. The exception is
|
|
** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.
|
|
** In shared cache mode, a single Schema object can be shared by multiple
|
|
** Btrees that refer to the same underlying BtShared object.
|
|
**
|
|
** Schema objects are automatically deallocated when the last Btree that
|
|
** references them is destroyed. The TEMP Schema is manually freed by
|
|
** sqlite3_close().
|
|
*
|
|
** A thread must be holding a mutex on the corresponding Btree in order
|
|
** to access Schema content. This implies that the thread must also be
|
|
** holding a mutex on the sqlite3 connection pointer that owns the Btree.
|
|
** For a TEMP Schema, only the connection mutex is required.
|
|
*/
|
|
struct Schema {
|
|
int schema_cookie; /* Database schema version number for this file */
|
|
int iGeneration; /* Generation counter. Incremented with each change */
|
|
Hash tblHash; /* All tables indexed by name */
|
|
Hash idxHash; /* All (named) indices indexed by name */
|
|
Hash trigHash; /* All triggers indexed by name */
|
|
Hash fkeyHash; /* All foreign keys by referenced table name */
|
|
Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
|
|
u8 file_format; /* Schema format version for this file */
|
|
u8 enc; /* Text encoding used by this database */
|
|
u16 schemaFlags; /* Flags associated with this schema */
|
|
int cache_size; /* Number of pages to use in the cache */
|
|
};
|
|
|
|
/*
|
|
** These macros can be used to test, set, or clear bits in the
|
|
** Db.pSchema->flags field.
|
|
*/
|
|
#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->schemaFlags&(P))==(P))
|
|
#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->schemaFlags&(P))!=0)
|
|
#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->schemaFlags|=(P)
|
|
#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->schemaFlags&=~(P)
|
|
|
|
/*
|
|
** Allowed values for the DB.pSchema->flags field.
|
|
**
|
|
** The DB_SchemaLoaded flag is set after the database schema has been
|
|
** read into internal hash tables.
|
|
**
|
|
** DB_UnresetViews means that one or more views have column names that
|
|
** have been filled out. If the schema changes, these column names might
|
|
** changes and so the view will need to be reset.
|
|
*/
|
|
#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */
|
|
#define DB_UnresetViews 0x0002 /* Some views have defined column names */
|
|
#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */
|
|
|
|
/*
|
|
** The number of different kinds of things that can be limited
|
|
** using the sqlite3_limit() interface.
|
|
*/
|
|
#define SQLITE_N_LIMIT (SQLITE_LIMIT_WORKER_THREADS+1)
|
|
|
|
/*
|
|
** Lookaside malloc is a set of fixed-size buffers that can be used
|
|
** to satisfy small transient memory allocation requests for objects
|
|
** associated with a particular database connection. The use of
|
|
** lookaside malloc provides a significant performance enhancement
|
|
** (approx 10%) by avoiding numerous malloc/free requests while parsing
|
|
** SQL statements.
|
|
**
|
|
** The Lookaside structure holds configuration information about the
|
|
** lookaside malloc subsystem. Each available memory allocation in
|
|
** the lookaside subsystem is stored on a linked list of LookasideSlot
|
|
** objects.
|
|
**
|
|
** Lookaside allocations are only allowed for objects that are associated
|
|
** with a particular database connection. Hence, schema information cannot
|
|
** be stored in lookaside because in shared cache mode the schema information
|
|
** is shared by multiple database connections. Therefore, while parsing
|
|
** schema information, the Lookaside.bEnabled flag is cleared so that
|
|
** lookaside allocations are not used to construct the schema objects.
|
|
*/
|
|
struct Lookaside {
|
|
u32 bDisable; /* Only operate the lookaside when zero */
|
|
u16 sz; /* Size of each buffer in bytes */
|
|
u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */
|
|
int nOut; /* Number of buffers currently checked out */
|
|
int mxOut; /* Highwater mark for nOut */
|
|
int anStat[3]; /* 0: hits. 1: size misses. 2: full misses */
|
|
LookasideSlot *pFree; /* List of available buffers */
|
|
void *pStart; /* First byte of available memory space */
|
|
void *pEnd; /* First byte past end of available space */
|
|
};
|
|
struct LookasideSlot {
|
|
LookasideSlot *pNext; /* Next buffer in the list of free buffers */
|
|
};
|
|
|
|
/*
|
|
** A hash table for function definitions.
|
|
**
|
|
** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.
|
|
** Collisions are on the FuncDef.pHash chain.
|
|
*/
|
|
struct FuncDefHash {
|
|
FuncDef *a[23]; /* Hash table for functions */
|
|
};
|
|
|
|
#ifdef SQLITE_USER_AUTHENTICATION
|
|
/*
|
|
** Information held in the "sqlite3" database connection object and used
|
|
** to manage user authentication.
|
|
*/
|
|
typedef struct sqlite3_userauth sqlite3_userauth;
|
|
struct sqlite3_userauth {
|
|
u8 authLevel; /* Current authentication level */
|
|
int nAuthPW; /* Size of the zAuthPW in bytes */
|
|
char *zAuthPW; /* Password used to authenticate */
|
|
char *zAuthUser; /* User name used to authenticate */
|
|
};
|
|
|
|
/* Allowed values for sqlite3_userauth.authLevel */
|
|
#define UAUTH_Unknown 0 /* Authentication not yet checked */
|
|
#define UAUTH_Fail 1 /* User authentication failed */
|
|
#define UAUTH_User 2 /* Authenticated as a normal user */
|
|
#define UAUTH_Admin 3 /* Authenticated as an administrator */
|
|
|
|
/* Functions used only by user authorization logic */
|
|
int sqlite3UserAuthTable(const char*);
|
|
int sqlite3UserAuthCheckLogin(sqlite3*,const char*,u8*);
|
|
void sqlite3UserAuthInit(sqlite3*);
|
|
void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);
|
|
|
|
#endif /* SQLITE_USER_AUTHENTICATION */
|
|
|
|
/*
|
|
** typedef for the authorization callback function.
|
|
*/
|
|
#ifdef SQLITE_USER_AUTHENTICATION
|
|
typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
|
|
const char*, const char*);
|
|
#else
|
|
typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
|
|
const char*);
|
|
#endif
|
|
|
|
|
|
/*
|
|
** Each database connection is an instance of the following structure.
|
|
*/
|
|
struct sqlite3 {
|
|
sqlite3_vfs *pVfs; /* OS Interface */
|
|
struct Vdbe *pVdbe; /* List of active virtual machines */
|
|
CollSeq *pDfltColl; /* The default collating sequence (BINARY) */
|
|
sqlite3_mutex *mutex; /* Connection mutex */
|
|
Db *aDb; /* All backends */
|
|
int nDb; /* Number of backends currently in use */
|
|
int flags; /* Miscellaneous flags. See below */
|
|
i64 lastRowid; /* ROWID of most recent insert (see above) */
|
|
i64 szMmap; /* Default mmap_size setting */
|
|
unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
|
|
int errCode; /* Most recent error code (SQLITE_*) */
|
|
int errMask; /* & result codes with this before returning */
|
|
u16 dbOptFlags; /* Flags to enable/disable optimizations */
|
|
u8 enc; /* Text encoding */
|
|
u8 autoCommit; /* The auto-commit flag. */
|
|
u8 temp_store; /* 1: file 2: memory 0: default */
|
|
u8 mallocFailed; /* True if we have seen a malloc failure */
|
|
u8 bBenignMalloc; /* Do not require OOMs if true */
|
|
u8 dfltLockMode; /* Default locking-mode for attached dbs */
|
|
signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
|
|
u8 suppressErr; /* Do not issue error messages if true */
|
|
u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
|
|
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
|
|
int nextPagesize; /* Pagesize after VACUUM if >0 */
|
|
u32 magic; /* Magic number for detect library misuse */
|
|
int nChange; /* Value returned by sqlite3_changes() */
|
|
int nTotalChange; /* Value returned by sqlite3_total_changes() */
|
|
int aLimit[SQLITE_N_LIMIT]; /* Limits */
|
|
int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
|
|
struct sqlite3InitInfo { /* Information used during initialization */
|
|
int newTnum; /* Rootpage of table being initialized */
|
|
u8 iDb; /* Which db file is being initialized */
|
|
u8 busy; /* TRUE if currently initializing */
|
|
u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */
|
|
u8 imposterTable; /* Building an imposter table */
|
|
} init;
|
|
int nVdbeActive; /* Number of VDBEs currently running */
|
|
int nVdbeRead; /* Number of active VDBEs that read or write */
|
|
int nVdbeWrite; /* Number of active VDBEs that read and write */
|
|
int nVdbeExec; /* Number of nested calls to VdbeExec() */
|
|
int nVDestroy; /* Number of active OP_VDestroy operations */
|
|
int nExtension; /* Number of loaded extensions */
|
|
void **aExtension; /* Array of shared library handles */
|
|
void (*xTrace)(void*,const char*); /* Trace function */
|
|
void *pTraceArg; /* Argument to the trace function */
|
|
void (*xProfile)(void*,const char*,u64); /* Profiling function */
|
|
void *pProfileArg; /* Argument to profile function */
|
|
void *pCommitArg; /* Argument to xCommitCallback() */
|
|
int (*xCommitCallback)(void*); /* Invoked at every commit. */
|
|
void *pRollbackArg; /* Argument to xRollbackCallback() */
|
|
void (*xRollbackCallback)(void*); /* Invoked at every commit. */
|
|
void *pUpdateArg;
|
|
void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
|
|
#ifndef SQLITE_OMIT_WAL
|
|
int (*xWalCallback)(void *, sqlite3 *, const char *, int);
|
|
void *pWalArg;
|
|
#endif
|
|
void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*);
|
|
void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*);
|
|
void *pCollNeededArg;
|
|
sqlite3_value *pErr; /* Most recent error message */
|
|
union {
|
|
volatile int isInterrupted; /* True if sqlite3_interrupt has been called */
|
|
double notUsed1; /* Spacer */
|
|
} u1;
|
|
Lookaside lookaside; /* Lookaside malloc configuration */
|
|
#ifndef SQLITE_OMIT_AUTHORIZATION
|
|
sqlite3_xauth xAuth; /* Access authorization function */
|
|
void *pAuthArg; /* 1st argument to the access auth function */
|
|
#endif
|
|
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
|
|
int (*xProgress)(void *); /* The progress callback */
|
|
void *pProgressArg; /* Argument to the progress callback */
|
|
unsigned nProgressOps; /* Number of opcodes for progress callback */
|
|
#endif
|
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
|
int nVTrans; /* Allocated size of aVTrans */
|
|
Hash aModule; /* populated by sqlite3_create_module() */
|
|
VtabCtx *pVtabCtx; /* Context for active vtab connect/create */
|
|
VTable **aVTrans; /* Virtual tables with open transactions */
|
|
VTable *pDisconnect; /* Disconnect these in next sqlite3_prepare() */
|
|
#endif
|
|
FuncDefHash aFunc; /* Hash table of connection functions */
|
|
Hash aCollSeq; /* All collating sequences */
|
|
BusyHandler busyHandler; /* Busy callback */
|
|
Db aDbStatic[2]; /* Static space for the 2 default backends */
|
|
Savepoint *pSavepoint; /* List of active savepoints */
|
|
int busyTimeout; /* Busy handler timeout, in msec */
|
|
int nSavepoint; /* Number of non-transaction savepoints */
|
|
int nStatement; /* Number of nested statement-transactions */
|
|
i64 nDeferredCons; /* Net deferred constraints this transaction. */
|
|
i64 nDeferredImmCons; /* Net deferred immediate constraints */
|
|
int *pnBytesFreed; /* If not NULL, increment this in DbFree() */
|
|
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
|
|
/* The following variables are all protected by the STATIC_MASTER
|
|
** mutex, not by sqlite3.mutex. They are used by code in notify.c.
|
|
**
|
|
** When X.pUnlockConnection==Y, that means that X is waiting for Y to
|
|
** unlock so that it can proceed.
|
|
**
|
|
** When X.pBlockingConnection==Y, that means that something that X tried
|
|
** tried to do recently failed with an SQLITE_LOCKED error due to locks
|
|
** held by Y.
|
|
*/
|
|
sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */
|
|
sqlite3 *pUnlockConnection; /* Connection to watch for unlock */
|
|
void *pUnlockArg; /* Argument to xUnlockNotify */
|
|
void (*xUnlockNotify)(void **, int); /* Unlock notify callback */
|
|
sqlite3 *pNextBlocked; /* Next in list of all blocked connections */
|
|
#endif
|
|
#ifdef SQLITE_USER_AUTHENTICATION
|
|
sqlite3_userauth auth; /* User authentication information */
|
|
#endif
|
|
};
|
|
|
|
/*
|
|
** A macro to discover the encoding of a database.
|
|
*/
|
|
#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)
|
|
#define ENC(db) ((db)->enc)
|
|
|
|
/*
|
|
** Possible values for the sqlite3.flags.
|
|
*/
|
|
#define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
|
|
#define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */
|
|
#define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */
|
|
#define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */
|
|
#define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */
|
|
#define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */
|
|
#define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
|
|
#define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
|
|
/* DELETE, or UPDATE and return */
|
|
/* the count using a callback. */
|
|
#define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
|
|
/* result set is empty */
|
|
#define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */
|
|
#define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */
|
|
#define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */
|
|
#define SQLITE_VdbeAddopTrace 0x00001000 /* Trace sqlite3VdbeAddOp() calls */
|
|
#define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */
|
|
#define SQLITE_ReadUncommitted 0x0004000 /* For shared-cache mode */
|
|
#define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */
|
|
#define SQLITE_RecoveryMode 0x00010000 /* Ignore schema errors */
|
|
#define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */
|
|
#define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */
|
|
#define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */
|
|
#define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */
|
|
#define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
|
|
#define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
|
|
#define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */
|
|
#define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */
|
|
#define SQLITE_QueryOnly 0x02000000 /* Disable database changes */
|
|
#define SQLITE_VdbeEQP 0x04000000 /* Debug EXPLAIN QUERY PLAN */
|
|
#define SQLITE_Vacuum 0x08000000 /* Currently in a VACUUM */
|
|
#define SQLITE_CellSizeCk 0x10000000 /* Check btree cell sizes on load */
|
|
|
|
|
|
/*
|
|
** Bits of the sqlite3.dbOptFlags field that are used by the
|
|
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
|
|
** selectively disable various optimizations.
|
|
*/
|
|
#define SQLITE_QueryFlattener 0x0001 /* Query flattening */
|
|
#define SQLITE_ColumnCache 0x0002 /* Column cache */
|
|
#define SQLITE_GroupByOrder 0x0004 /* GROUPBY cover of ORDERBY */
|
|
#define SQLITE_FactorOutConst 0x0008 /* Constant factoring */
|
|
/* not used 0x0010 // Was: SQLITE_IdxRealAsInt */
|
|
#define SQLITE_DistinctOpt 0x0020 /* DISTINCT using indexes */
|
|
#define SQLITE_CoverIdxScan 0x0040 /* Covering index scans */
|
|
#define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */
|
|
#define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
|
|
#define SQLITE_Transitive 0x0200 /* Transitive constraints */
|
|
#define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
|
|
#define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
|
|
#define SQLITE_CursorHints 0x2000 /* Add OP_CursorHint opcodes */
|
|
#define SQLITE_AllOpts 0xffff /* All optimizations */
|
|
|
|
/*
|
|
** Macros for testing whether or not optimizations are enabled or disabled.
|
|
*/
|
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
|
#define OptimizationDisabled(db, mask) (((db)->dbOptFlags&(mask))!=0)
|
|
#define OptimizationEnabled(db, mask) (((db)->dbOptFlags&(mask))==0)
|
|
#else
|
|
#define OptimizationDisabled(db, mask) 0
|
|
#define OptimizationEnabled(db, mask) 1
|
|
#endif
|
|
|
|
/*
|
|
** Return true if it OK to factor constant expressions into the initialization
|
|
** code. The argument is a Parse object for the code generator.
|
|
*/
|
|
#define ConstFactorOk(P) ((P)->okConstFactor)
|
|
|
|
/*
|
|
** Possible values for the sqlite.magic field.
|
|
** The numbers are obtained at random and have no special meaning, other
|
|
** than being distinct from one another.
|
|
*/
|
|
#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */
|
|
#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */
|
|
#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */
|
|
#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */
|
|
#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */
|
|
#define SQLITE_MAGIC_ZOMBIE 0x64cffc7f /* Close with last statement close */
|
|
|
|
/*
|
|
** Each SQL function is defined by an instance of the following
|
|
** structure. A pointer to this structure is stored in the sqlite.aFunc
|
|
** hash table. When multiple functions have the same name, the hash table
|
|
** points to a linked list of these structures.
|
|
*/
|
|
struct FuncDef {
|
|
i16 nArg; /* Number of arguments. -1 means unlimited */
|
|
u16 funcFlags; /* Some combination of SQLITE_FUNC_* */
|
|
void *pUserData; /* User data parameter */
|
|
FuncDef *pNext; /* Next function with same name */
|
|
void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
|
|
void (*xFinalize)(sqlite3_context*); /* Agg finalizer */
|
|
char *zName; /* SQL name of the function. */
|
|
FuncDef *pHash; /* Next with a different name but the same hash */
|
|
FuncDestructor *pDestructor; /* Reference counted destructor function */
|
|
};
|
|
|
|
/*
|
|
** This structure encapsulates a user-function destructor callback (as
|
|
** configured using create_function_v2()) and a reference counter. When
|
|
** create_function_v2() is called to create a function with a destructor,
|
|
** a single object of this type is allocated. FuncDestructor.nRef is set to
|
|
** the number of FuncDef objects created (either 1 or 3, depending on whether
|
|
** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor
|
|
** member of each of the new FuncDef objects is set to point to the allocated
|
|
** FuncDestructor.
|
|
**
|
|
** Thereafter, when one of the FuncDef objects is deleted, the reference
|
|
** count on this object is decremented. When it reaches 0, the destructor
|
|
** is invoked and the FuncDestructor structure freed.
|
|
*/
|
|
struct FuncDestructor {
|
|
int nRef;
|
|
void (*xDestroy)(void *);
|
|
void *pUserData;
|
|
};
|
|
|
|
/*
|
|
** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF
|
|
** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. And
|
|
** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC. There
|
|
** are assert() statements in the code to verify this.
|
|
*/
|
|
#define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
|
|
#define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */
|
|
#define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */
|
|
#define SQLITE_FUNC_EPHEM 0x0010 /* Ephemeral. Delete with VDBE */
|
|
#define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/
|
|
#define SQLITE_FUNC_LENGTH 0x0040 /* Built-in length() function */
|
|
#define SQLITE_FUNC_TYPEOF 0x0080 /* Built-in typeof() function */
|
|
#define SQLITE_FUNC_COUNT 0x0100 /* Built-in count(*) aggregate */
|
|
#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */
|
|
#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
|
|
#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
|
|
#define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */
|
|
#define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
|
|
** single query - might change over time */
|
|
|
|
/*
|
|
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
|
|
** used to create the initializers for the FuncDef structures.
|
|
**
|
|
** FUNCTION(zName, nArg, iArg, bNC, xFunc)
|
|
** Used to create a scalar function definition of a function zName
|
|
** implemented by C function xFunc that accepts nArg arguments. The
|
|
** value passed as iArg is cast to a (void*) and made available
|
|
** as the user-data (sqlite3_user_data()) for the function. If
|
|
** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set.
|
|
**
|
|
** VFUNCTION(zName, nArg, iArg, bNC, xFunc)
|
|
** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag.
|
|
**
|
|
** DFUNCTION(zName, nArg, iArg, bNC, xFunc)
|
|
** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and
|
|
** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions
|
|
** and functions like sqlite_version() that can change, but not during
|
|
** a single query.
|
|
**
|
|
** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
|
|
** Used to create an aggregate function definition implemented by
|
|
** the C functions xStep and xFinal. The first four parameters
|
|
** are interpreted in the same way as the first 4 parameters to
|
|
** FUNCTION().
|
|
**
|
|
** LIKEFUNC(zName, nArg, pArg, flags)
|
|
** Used to create a scalar function definition of a function zName
|
|
** that accepts nArg arguments and is implemented by a call to C
|
|
** function likeFunc. Argument pArg is cast to a (void *) and made
|
|
** available as the function user-data (sqlite3_user_data()). The
|
|
** FuncDef.flags variable is set to the value passed as the flags
|
|
** parameter.
|
|
*/
|
|
#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
|
|
{nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
|
|
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
|
|
#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
|
|
{nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
|
|
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
|
|
#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
|
|
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
|
|
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
|
|
#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
|
|
{nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
|
|
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
|
|
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
|
|
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
|
|
pArg, 0, xFunc, 0, #zName, 0, 0}
|
|
#define LIKEFUNC(zName, nArg, arg, flags) \
|
|
{nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
|
|
(void *)arg, 0, likeFunc, 0, #zName, 0, 0}
|
|
#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \
|
|
{nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
|
|
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName,0,0}
|
|
#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
|
|
{nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
|
|
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName,0,0}
|
|
|
|
/*
|
|
** All current savepoints are stored in a linked list starting at
|
|
** sqlite3.pSavepoint. The first element in the list is the most recently
|
|
** opened savepoint. Savepoints are added to the list by the vdbe
|
|
** OP_Savepoint instruction.
|
|
*/
|
|
struct Savepoint {
|
|
char *zName; /* Savepoint name (nul-terminated) */
|
|
i64 nDeferredCons; /* Number of deferred fk violations */
|
|
i64 nDeferredImmCons; /* Number of deferred imm fk. */
|
|
Savepoint *pNext; /* Parent savepoint (if any) */
|
|
};
|
|
|
|
/*
|
|
** The following are used as the second parameter to sqlite3Savepoint(),
|
|
** and as the P1 argument to the OP_Savepoint instruction.
|
|
*/
|
|
#define SAVEPOINT_BEGIN 0
|
|
#define SAVEPOINT_RELEASE 1
|
|
#define SAVEPOINT_ROLLBACK 2
|
|
|
|
|
|
/*
|
|
** Each SQLite module (virtual table definition) is defined by an
|
|
** instance of the following structure, stored in the sqlite3.aModule
|
|
** hash table.
|
|
*/
|
|
struct Module {
|
|
const sqlite3_module *pModule; /* Callback pointers */
|
|
const char *zName; /* Name passed to create_module() */
|
|
void *pAux; /* pAux passed to create_module() */
|
|
void (*xDestroy)(void *); /* Module destructor function */
|
|
Table *pEpoTab; /* Eponymous table for this module */
|
|
};
|
|
|
|
/*
|
|
** information about each column of an SQL table is held in an instance
|
|
** of this structure.
|
|
*/
|
|
struct Column {
|
|
char *zName; /* Name of this column */
|
|
Expr *pDflt; /* Default value of this column */
|
|
char *zDflt; /* Original text of the default value */
|
|
char *zType; /* Data type for this column */
|
|
char *zColl; /* Collating sequence. If NULL, use the default */
|
|
u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
|
|
char affinity; /* One of the SQLITE_AFF_... values */
|
|
u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */
|
|
u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */
|
|
};
|
|
|
|
/* Allowed values for Column.colFlags:
|
|
*/
|
|
#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */
|
|
#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
|
|
|
|
/*
|
|
** A "Collating Sequence" is defined by an instance of the following
|
|
** structure. Conceptually, a collating sequence consists of a name and
|
|
** a comparison routine that defines the order of that sequence.
|
|
**
|
|
** If CollSeq.xCmp is NULL, it means that the
|
|
** collating sequence is undefined. Indices built on an undefined
|
|
** collating sequence may not be read or written.
|
|
*/
|
|
struct CollSeq {
|
|
char *zName; /* Name of the collating sequence, UTF-8 encoded */
|
|
u8 enc; /* Text encoding handled by xCmp() */
|
|
void *pUser; /* First argument to xCmp() */
|
|
int (*xCmp)(void*,int, const void*, int, const void*);
|
|
void (*xDel)(void*); /* Destructor for pUser */
|
|
};
|
|
|
|
/*
|
|
** A sort order can be either ASC or DESC.
|
|
*/
|
|
#define SQLITE_SO_ASC 0 /* Sort in ascending order */
|
|
#define SQLITE_SO_DESC 1 /* Sort in ascending order */
|
|
#define SQLITE_SO_UNDEFINED -1 /* No sort order specified */
|
|
|
|
/*
|
|
** Column affinity types.
|
|
**
|
|
** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and
|
|
** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve
|
|
** the speed a little by numbering the values consecutively.
|
|
**
|
|
** But rather than start with 0 or 1, we begin with 'A'. That way,
|
|
** when multiple affinity types are concatenated into a string and
|
|
** used as the P4 operand, they will be more readable.
|
|
**
|
|
** Note also that the numeric types are grouped together so that testing
|
|
** for a numeric type is a single comparison. And the BLOB type is first.
|
|
*/
|
|
#define SQLITE_AFF_BLOB 'A'
|
|
#define SQLITE_AFF_TEXT 'B'
|
|
#define SQLITE_AFF_NUMERIC 'C'
|
|
#define SQLITE_AFF_INTEGER 'D'
|
|
#define SQLITE_AFF_REAL 'E'
|
|
|
|
#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC)
|
|
|
|
/*
|
|
** The SQLITE_AFF_MASK values masks off the significant bits of an
|
|
** affinity value.
|
|
*/
|
|
#define SQLITE_AFF_MASK 0x47
|
|
|
|
/*
|
|
** Additional bit values that can be ORed with an affinity without
|
|
** changing the affinity.
|
|
**
|
|
** The SQLITE_NOTNULL flag is a combination of NULLEQ and JUMPIFNULL.
|
|
** It causes an assert() to fire if either operand to a comparison
|
|
** operator is NULL. It is added to certain comparison operators to
|
|
** prove that the operands are always NOT NULL.
|
|
*/
|
|
#define SQLITE_JUMPIFNULL 0x10 /* jumps if either operand is NULL */
|
|
#define SQLITE_STOREP2 0x20 /* Store result in reg[P2] rather than jump */
|
|
#define SQLITE_NULLEQ 0x80 /* NULL=NULL */
|
|
#define SQLITE_NOTNULL 0x90 /* Assert that operands are never NULL */
|
|
|
|
/*
|
|
** An object of this type is created for each virtual table present in
|
|
** the database schema.
|
|
**
|
|
** If the database schema is shared, then there is one instance of this
|
|
** structure for each database connection (sqlite3*) that uses the shared
|
|
** schema. This is because each database connection requires its own unique
|
|
** instance of the sqlite3_vtab* handle used to access the virtual table
|
|
** implementation. sqlite3_vtab* handles can not be shared between
|
|
** database connections, even when the rest of the in-memory database
|
|
** schema is shared, as the implementation often stores the database
|
|
** connection handle passed to it via the xConnect() or xCreate() method
|
|
** during initialization internally. This database connection handle may
|
|
** then be used by the virtual table implementation to access real tables
|
|
** within the database. So that they appear as part of the callers
|
|
** transaction, these accesses need to be made via the same database
|
|
** connection as that used to execute SQL operations on the virtual table.
|
|
**
|
|
** All VTable objects that correspond to a single table in a shared
|
|
** database schema are initially stored in a linked-list pointed to by
|
|
** the Table.pVTable member variable of the corresponding Table object.
|
|
** When an sqlite3_prepare() operation is required to access the virtual
|
|
** table, it searches the list for the VTable that corresponds to the
|
|
** database connection doing the preparing so as to use the correct
|
|
** sqlite3_vtab* handle in the compiled query.
|
|
**
|
|
** When an in-memory Table object is deleted (for example when the
|
|
** schema is being reloaded for some reason), the VTable objects are not
|
|
** deleted and the sqlite3_vtab* handles are not xDisconnect()ed
|
|
** immediately. Instead, they are moved from the Table.pVTable list to
|
|
** another linked list headed by the sqlite3.pDisconnect member of the
|
|
** corresponding sqlite3 structure. They are then deleted/xDisconnected
|
|
** next time a statement is prepared using said sqlite3*. This is done
|
|
** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.
|
|
** Refer to comments above function sqlite3VtabUnlockList() for an
|
|
** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect
|
|
** list without holding the corresponding sqlite3.mutex mutex.
|
|
**
|
|
** The memory for objects of this type is always allocated by
|
|
** sqlite3DbMalloc(), using the connection handle stored in VTable.db as
|
|
** the first argument.
|
|
*/
|
|
struct VTable {
|
|
sqlite3 *db; /* Database connection associated with this table */
|
|
Module *pMod; /* Pointer to module implementation */
|
|
sqlite3_vtab *pVtab; /* Pointer to vtab instance */
|
|
int nRef; /* Number of pointers to this structure */
|
|
u8 bConstraint; /* True if constraints are supported */
|
|
int iSavepoint; /* Depth of the SAVEPOINT stack */
|
|
VTable *pNext; /* Next in linked list (see above) */
|
|
};
|
|
|
|
/*
|
|
** The schema for each SQL table and view is represented in memory
|
|
** by an instance of the following structure.
|
|
*/
|
|
struct Table {
|
|
char *zName; /* Name of the table or view */
|
|
Column *aCol; /* Information about each column */
|
|
Index *pIndex; /* List of SQL indexes on this table. */
|
|
Select *pSelect; /* NULL for tables. Points to definition if a view. */
|
|
FKey *pFKey; /* Linked list of all foreign keys in this table */
|
|
char *zColAff; /* String defining the affinity of each column */
|
|
ExprList *pCheck; /* All CHECK constraints */
|
|
/* ... also used as column name list in a VIEW */
|
|
int tnum; /* Root BTree page for this table */
|
|
i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
|
|
i16 nCol; /* Number of columns in this table */
|
|
u16 nRef; /* Number of pointers to this Table */
|
|
LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
|
|
LogEst szTabRow; /* Estimated size of each table row in bytes */
|
|
#ifdef SQLITE_ENABLE_COSTMULT
|
|
LogEst costMult; /* Cost multiplier for using this table */
|
|
#endif
|
|
u8 tabFlags; /* Mask of TF_* values */
|
|
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
|
|
#ifndef SQLITE_OMIT_ALTERTABLE
|
|
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
|
|
#endif
|
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
|
int nModuleArg; /* Number of arguments to the module */
|
|
char **azModuleArg; /* 0: module 1: schema 2: vtab name 3...: args */
|
|
VTable *pVTable; /* List of VTable objects. */
|
|
#endif
|
|
Trigger *pTrigger; /* List of triggers stored in pSchema */
|
|
Schema *pSchema; /* Schema that contains this table */
|
|
Table *pNextZombie; /* Next on the Parse.pZombieTab list */
|
|
};
|
|
|
|
/*
|
|
** Allowed values for Table.tabFlags.
|
|
**
|
|
** TF_OOOHidden applies to tables or view that have hidden columns that are
|
|
** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
|
|
** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
|
|
** the TF_OOOHidden attribute would apply in this case. Such tables require
|
|
** special handling during INSERT processing.
|
|
*/
|
|
#define TF_Readonly 0x01 /* Read-only system table */
|
|
#define TF_Ephemeral 0x02 /* An ephemeral table */
|
|
#define TF_HasPrimaryKey 0x04 /* Table has a primary key */
|
|
#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */
|
|
#define TF_Virtual 0x10 /* Is a virtual table */
|
|
#define TF_WithoutRowid 0x20 /* No rowid. PRIMARY KEY is the key */
|
|
#define TF_NoVisibleRowid 0x40 /* No user-visible "rowid" column */
|
|
#define TF_OOOHidden 0x80 /* Out-of-Order hidden columns */
|
|
|
|
|
|
/*
|
|
** Test to see whether or not a table is a virtual table. This is
|
|
** done as a macro so that it will be optimized out when virtual
|
|
** table support is omitted from the build.
|
|
*/
|
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
|
# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0)
|
|
#else
|
|
# define IsVirtual(X) 0
|
|
#endif
|
|
|
|
/*
|
|
** Macros to determine if a column is hidden. IsOrdinaryHiddenColumn()
|
|
** only works for non-virtual tables (ordinary tables and views) and is
|
|
** always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined. The
|
|
** IsHiddenColumn() macro is general purpose.
|
|
*/
|
|
#if defined(SQLITE_ENABLE_HIDDEN_COLUMNS)
|
|
# define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
|
|
# define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
|
|
#elif !defined(SQLITE_OMIT_VIRTUALTABLE)
|
|
# define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
|
|
# define IsOrdinaryHiddenColumn(X) 0
|
|
#else
|
|
# define IsHiddenColumn(X) 0
|
|
# define IsOrdinaryHiddenColumn(X) 0
|
|
#endif
|
|
|
|
|
|
/* Does the table have a rowid */
|
|
#define HasRowid(X) (((X)->tabFlags & TF_WithoutRowid)==0)
|
|
#define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)
|
|
|
|
/*
|
|
** Each foreign key constraint is an instance of the following structure.
|
|
**
|
|
** A foreign key is associated with two tables. The "from" table is
|
|
** the table that contains the REFERENCES clause that creates the foreign
|
|
** key. The "to" table is the table that is named in the REFERENCES clause.
|
|
** Consider this example:
|
|
**
|
|
** CREATE TABLE ex1(
|
|
** a INTEGER PRIMARY KEY,
|
|
** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x)
|
|
** );
|
|
**
|
|
** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2".
|
|
** Equivalent names:
|
|
**
|
|
** from-table == child-table
|
|
** to-table == parent-table
|
|
**
|
|
** Each REFERENCES clause generates an instance of the following structure
|
|
** which is attached to the from-table. The to-table need not exist when
|
|
** the from-table is created. The existence of the to-table is not checked.
|
|
**
|
|
** The list of all parents for child Table X is held at X.pFKey.
|
|
**
|
|
** A list of all children for a table named Z (which might not even exist)
|
|
** is held in Schema.fkeyHash with a hash key of Z.
|
|
*/
|
|
struct FKey {
|
|
Table *pFrom; /* Table containing the REFERENCES clause (aka: Child) */
|
|
FKey *pNextFrom; /* Next FKey with the same in pFrom. Next parent of pFrom */
|
|
char *zTo; /* Name of table that the key points to (aka: Parent) */
|
|
FKey *pNextTo; /* Next with the same zTo. Next child of zTo. */
|
|
FKey *pPrevTo; /* Previous with the same zTo */
|
|
int nCol; /* Number of columns in this key */
|
|
/* EV: R-30323-21917 */
|
|
u8 isDeferred; /* True if constraint checking is deferred till COMMIT */
|
|
u8 aAction[2]; /* ON DELETE and ON UPDATE actions, respectively */
|
|
Trigger *apTrigger[2];/* Triggers for aAction[] actions */
|
|
struct sColMap { /* Mapping of columns in pFrom to columns in zTo */
|
|
int iFrom; /* Index of column in pFrom */
|
|
char *zCol; /* Name of column in zTo. If NULL use PRIMARY KEY */
|
|
} aCol[1]; /* One entry for each of nCol columns */
|
|
};
|
|
|
|
/*
|
|
** SQLite supports many different ways to resolve a constraint
|
|
** error. ROLLBACK processing means that a constraint violation
|
|
** causes the operation in process to fail and for the current transaction
|
|
** to be rolled back. ABORT processing means the operation in process
|
|
** fails and any prior changes from that one operation are backed out,
|
|
** but the transaction is not rolled back. FAIL processing means that
|
|
** the operation in progress stops and returns an error code. But prior
|
|
** changes due to the same operation are not backed out and no rollback
|
|
** occurs. IGNORE means that the particular row that caused the constraint
|
|
** error is not inserted or updated. Processing continues and no error
|
|
** is returned. REPLACE means that preexisting database rows that caused
|
|
** a UNIQUE constraint violation are removed so that the new insert or
|
|
** update can proceed. Processing continues and no error is reported.
|
|
**
|
|
** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys.
|
|
** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the
|
|
** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign
|
|
** key is set to NULL. CASCADE means that a DELETE or UPDATE of the
|
|
** referenced table row is propagated into the row that holds the
|
|
** foreign key.
|
|
**
|
|
** The following symbolic values are used to record which type
|
|
** of action to take.
|
|
*/
|
|
#define OE_None 0 /* There is no constraint to check */
|
|
#define OE_Rollback 1 /* Fail the operation and rollback the transaction */
|
|
#define OE_Abort 2 /* Back out changes but do no rollback transaction */
|
|
#define OE_Fail 3 /* Stop the operation but leave all prior changes */
|
|
#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */
|
|
#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */
|
|
|
|
#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
|
|
#define OE_SetNull 7 /* Set the foreign key value to NULL */
|
|
#define OE_SetDflt 8 /* Set the foreign key value to its default */
|
|
#define OE_Cascade 9 /* Cascade the changes */
|
|
|
|
#define OE_Default 10 /* Do whatever the default action is */
|
|
|
|
|
|
/*
|
|
** An instance of the following structure is passed as the first
|
|
** argument to sqlite3VdbeKeyCompare and is used to control the
|
|
** comparison of the two index keys.
|
|
**
|
|
** Note that aSortOrder[] and aColl[] have nField+1 slots. There
|
|
** are nField slots for the columns of an index then one extra slot
|
|
** for the rowid at the end.
|
|
*/
|
|
struct KeyInfo {
|
|
u32 nRef; /* Number of references to this KeyInfo object */
|
|
u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
|
|
u16 nField; /* Number of key columns in the index */
|
|
u16 nXField; /* Number of columns beyond the key columns */
|
|
sqlite3 *db; /* The database connection */
|
|
u8 *aSortOrder; /* Sort order for each column. */
|
|
CollSeq *aColl[1]; /* Collating sequence for each term of the key */
|
|
};
|
|
|
|
/*
|
|
** This object holds a record which has been parsed out into individual
|
|
** fields, for the purposes of doing a comparison.
|
|
**
|
|
** A record is an object that contains one or more fields of data.
|
|
** Records are used to store the content of a table row and to store
|
|
** the key of an index. A blob encoding of a record is created by
|
|
** the OP_MakeRecord opcode of the VDBE and is disassembled by the
|
|
** OP_Column opcode.
|
|
**
|
|
** An instance of this object serves as a "key" for doing a search on
|
|
** an index b+tree. The goal of the search is to find the entry that
|
|
** is closed to the key described by this object. This object might hold
|
|
** just a prefix of the key. The number of fields is given by
|
|
** pKeyInfo->nField.
|
|
**
|
|
** The r1 and r2 fields are the values to return if this key is less than
|
|
** or greater than a key in the btree, respectively. These are normally
|
|
** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree
|
|
** is in DESC order.
|
|
**
|
|
** The key comparison functions actually return default_rc when they find
|
|
** an equals comparison. default_rc can be -1, 0, or +1. If there are
|
|
** multiple entries in the b-tree with the same key (when only looking
|
|
** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to
|
|
** cause the search to find the last match, or +1 to cause the search to
|
|
** find the first match.
|
|
**
|
|
** The key comparison functions will set eqSeen to true if they ever
|
|
** get and equal results when comparing this structure to a b-tree record.
|
|
** When default_rc!=0, the search might end up on the record immediately
|
|
** before the first match or immediately after the last match. The
|
|
** eqSeen field will indicate whether or not an exact match exists in the
|
|
** b-tree.
|
|
*/
|
|
struct UnpackedRecord {
|
|
KeyInfo *pKeyInfo; /* Collation and sort-order information */
|
|
Mem *aMem; /* Values */
|
|
u16 nField; /* Number of entries in apMem[] */
|
|
i8 default_rc; /* Comparison result if keys are equal */
|
|
u8 errCode; /* Error detected by xRecordCompare (CORRUPT or NOMEM) */
|
|
i8 r1; /* Value to return if (lhs > rhs) */
|
|
i8 r2; /* Value to return if (rhs < lhs) */
|
|
u8 eqSeen; /* True if an equality comparison has been seen */
|
|
};
|
|
|
|
|
|
/*
|
|
** Each SQL index is represented in memory by an
|
|
** instance of the following structure.
|
|
**
|
|
** The columns of the table that are to be indexed are described
|
|
** by the aiColumn[] field of this structure. For example, suppose
|
|
** we have the following table and index:
|
|
**
|
|
** CREATE TABLE Ex1(c1 int, c2 int, c3 text);
|
|
** CREATE INDEX Ex2 ON Ex1(c3,c1);
|
|
**
|
|
** In the Table structure describing Ex1, nCol==3 because there are
|
|
** three columns in the table. In the Index structure describing
|
|
** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.
|
|
** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the
|
|
** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].
|
|
** The second column to be indexed (c1) has an index of 0 in
|
|
** Ex1.aCol[], hence Ex2.aiColumn[1]==0.
|
|
**
|
|
** The Index.onError field determines whether or not the indexed columns
|
|
** must be unique and what to do if they are not. When Index.onError=OE_None,
|
|
** it means this is not a unique index. Otherwise it is a unique index
|
|
** and the value of Index.onError indicate the which conflict resolution
|
|
** algorithm to employ whenever an attempt is made to insert a non-unique
|
|
** element.
|
|
**
|
|
** While parsing a CREATE TABLE or CREATE INDEX statement in order to
|
|
** generate VDBE code (as opposed to parsing one read from an sqlite_master
|
|
** table as part of parsing an existing database schema), transient instances
|
|
** of this structure may be created. In this case the Index.tnum variable is
|
|
** used to store the address of a VDBE instruction, not a database page
|
|
** number (it cannot - the database page is not allocated until the VDBE
|
|
** program is executed). See convertToWithoutRowidTable() for details.
|
|
*/
|
|
struct Index {
|
|
char *zName; /* Name of this index */
|
|
i16 *aiColumn; /* Which columns are used by this index. 1st is 0 */
|
|
LogEst *aiRowLogEst; /* From ANALYZE: Est. rows selected by each column */
|
|
Table *pTable; /* The SQL table being indexed */
|
|
char *zColAff; /* String defining the affinity of each column */
|
|
Index *pNext; /* The next index associated with the same table */
|
|
Schema *pSchema; /* Schema containing this index */
|
|
u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
|
|
const char **azColl; /* Array of collation sequence names for index */
|
|
Expr *pPartIdxWhere; /* WHERE clause for partial indices */
|
|
ExprList *aColExpr; /* Column expressions */
|
|
int tnum; /* DB Page containing root of this index */
|
|
LogEst szIdxRow; /* Estimated average row size in bytes */
|
|
u16 nKeyCol; /* Number of columns forming the key */
|
|
u16 nColumn; /* Number of columns stored in the index */
|
|
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
|
|
unsigned idxType:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
|
|
unsigned bUnordered:1; /* Use this index for == or IN queries only */
|
|
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
|
|
unsigned isResized:1; /* True if resizeIndexObject() has been called */
|
|
unsigned isCovering:1; /* True if this is a covering index */
|
|
unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
|
|
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
|
|
int nSample; /* Number of elements in aSample[] */
|
|
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
|
|
tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
|
|
IndexSample *aSample; /* Samples of the left-most key */
|
|
tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
|
|
tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */
|
|
#endif
|
|
};
|
|
|
|
/*
|
|
** Allowed values for Index.idxType
|
|
*/
|
|
#define SQLITE_IDXTYPE_APPDEF 0 /* Created using CREATE INDEX */
|
|
#define SQLITE_IDXTYPE_UNIQUE 1 /* Implements a UNIQUE constraint */
|
|
#define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */
|
|
|
|
/* Return true if index X is a PRIMARY KEY index */
|
|
#define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)
|
|
|
|
/* Return true if index X is a UNIQUE index */
|
|
#define IsUniqueIndex(X) ((X)->onError!=OE_None)
|
|
|
|
/* The Index.aiColumn[] values are normally positive integer. But
|
|
** there are some negative values that have special meaning:
|
|
*/
|
|
#define XN_ROWID (-1) /* Indexed column is the rowid */
|
|
#define XN_EXPR (-2) /* Indexed column is an expression */
|
|
|
|
/*
|
|
** Each sample stored in the sqlite_stat3 table is represented in memory
|
|
** using a structure of this type. See documentation at the top of the
|
|
** analyze.c source file for additional information.
|
|
*/
|
|
struct IndexSample {
|
|
void *p; /* Pointer to sampled record */
|
|
int n; /* Size of record in bytes */
|
|
tRowcnt *anEq; /* Est. number of rows where the key equals this sample */
|
|
tRowcnt *anLt; /* Est. number of rows where key is less than this sample */
|
|
tRowcnt *anDLt; /* Est. number of distinct keys less than this sample */
|
|
};
|
|
|
|
/*
|
|
** Each token coming out of the lexer is an instance of
|
|
** this structure. Tokens are also used as part of an expression.
|
|
**
|
|
** Note if Token.z==0 then Token.dyn and Token.n are undefined and
|
|
** may contain random values. Do not make any assumptions about Token.dyn
|
|
** and Token.n when Token.z==0.
|
|
*/
|
|
struct Token {
|
|
const char *z; /* Text of the token. Not NULL-terminated! */
|
|
unsigned int n; /* Number of characters in this token */
|
|
};
|
|
|
|
/*
|
|
** An instance of this structure contains information needed to generate
|
|
** code for a SELECT that contains aggregate functions.
|
|
**
|
|
** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a
|
|
** pointer to this structure. The Expr.iColumn field is the index in
|
|
** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate
|
|
** code for that node.
|
|
**
|
|
** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the
|
|
** original Select structure that describes the SELECT statement. These
|
|
** fields do not need to be freed when deallocating the AggInfo structure.
|
|
*/
|
|
struct AggInfo {
|
|
u8 directMode; /* Direct rendering mode means take data directly
|
|
** from source tables rather than from accumulators */
|
|
u8 useSortingIdx; /* In direct mode, reference the sorting index rather
|
|
** than the source table */
|
|
int sortingIdx; /* Cursor number of the sorting index */
|
|
int sortingIdxPTab; /* Cursor number of pseudo-table */
|
|
int nSortingColumn; /* Number of columns in the sorting index */
|
|
int mnReg, mxReg; /* Range of registers allocated for aCol and aFunc */
|
|
ExprList *pGroupBy; /* The group by clause */
|
|
struct AggInfo_col { /* For each column used in source tables */
|
|
Table *pTab; /* Source table */
|
|
int iTable; /* Cursor number of the source table */
|
|
int iColumn; /* Column number within the source table */
|
|
int iSorterColumn; /* Column number in the sorting index */
|
|
int iMem; /* Memory location that acts as accumulator */
|
|
Expr *pExpr; /* The original expression */
|
|
} *aCol;
|
|
int nColumn; /* Number of used entries in aCol[] */
|
|
int nAccumulator; /* Number of columns that show through to the output.
|
|
** Additional columns are used only as parameters to
|
|
** aggregate functions */
|
|
struct AggInfo_func { /* For each aggregate function */
|
|
Expr *pExpr; /* Expression encoding the function */
|
|
FuncDef *pFunc; /* The aggregate function implementation */
|
|
int iMem; /* Memory location that acts as accumulator */
|
|
int iDistinct; /* Ephemeral table used to enforce DISTINCT */
|
|
} *aFunc;
|
|
int nFunc; /* Number of entries in aFunc[] */
|
|
};
|
|
|
|
/*
|
|
** The datatype ynVar is a signed integer, either 16-bit or 32-bit.
|
|
** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater
|
|
** than 32767 we have to make it 32-bit. 16-bit is preferred because
|
|
** it uses less memory in the Expr object, which is a big memory user
|
|
** in systems with lots of prepared statements. And few applications
|
|
** need more than about 10 or 20 variables. But some extreme users want
|
|
** to have prepared statements with over 32767 variables, and for them
|
|
** the option is available (at compile-time).
|
|
*/
|
|
#if SQLITE_MAX_VARIABLE_NUMBER<=32767
|
|
typedef i16 ynVar;
|
|
#else
|
|
typedef int ynVar;
|
|
#endif
|
|
|
|
/*
|
|
** Each node of an expression in the parse tree is an instance
|
|
** of this structure.
|
|
**
|
|
** Expr.op is the opcode. The integer parser token codes are reused
|
|
** as opcodes here. For example, the parser defines TK_GE to be an integer
|
|
** code representing the ">=" operator. This same integer code is reused
|
|
** to represent the greater-than-or-equal-to operator in the expression
|
|
** tree.
|
|
**
|
|
** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB,
|
|
** or TK_STRING), then Expr.token contains the text of the SQL literal. If
|
|
** the expression is a variable (TK_VARIABLE), then Expr.token contains the
|
|
** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),
|
|
** then Expr.token contains the name of the function.
|
|
**
|
|
** Expr.pRight and Expr.pLeft are the left and right subexpressions of a
|
|
** binary operator. Either or both may be NULL.
|
|
**
|
|
** Expr.x.pList is a list of arguments if the expression is an SQL function,
|
|
** a CASE expression or an IN expression of the form "<lhs> IN (<y>, <z>...)".
|
|
** Expr.x.pSelect is used if the expression is a sub-select or an expression of
|
|
** the form "<lhs> IN (SELECT ...)". If the EP_xIsSelect bit is set in the
|
|
** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is
|
|
** valid.
|
|
**
|
|
** An expression of the form ID or ID.ID refers to a column in a table.
|
|
** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is
|
|
** the integer cursor number of a VDBE cursor pointing to that table and
|
|
** Expr.iColumn is the column number for the specific column. If the
|
|
** expression is used as a result in an aggregate SELECT, then the
|
|
** value is also stored in the Expr.iAgg column in the aggregate so that
|
|
** it can be accessed after all aggregates are computed.
|
|
**
|
|
** If the expression is an unbound variable marker (a question mark
|
|
** character '?' in the original SQL) then the Expr.iTable holds the index
|
|
** number for that variable.
|
|
**
|
|
** If the expression is a subquery then Expr.iColumn holds an integer
|
|
** register number containing the result of the subquery. If the
|
|
** subquery gives a constant result, then iTable is -1. If the subquery
|
|
** gives a different answer at different times during statement processing
|
|
** then iTable is the address of a subroutine that computes the subquery.
|
|
**
|
|
** If the Expr is of type OP_Column, and the table it is selecting from
|
|
** is a disk table or the "old.*" pseudo-table, then pTab points to the
|
|
** corresponding table definition.
|
|
**
|
|
** ALLOCATION NOTES:
|
|
**
|
|
** Expr objects can use a lot of memory space in database schema. To
|
|
** help reduce memory requirements, sometimes an Expr object will be
|
|
** truncated. And to reduce the number of memory allocations, sometimes
|
|
** two or more Expr objects will be stored in a single memory allocation,
|
|
** together with Expr.zToken strings.
|
|
**
|
|
** If the EP_Reduced and EP_TokenOnly flags are set when
|
|
** an Expr object is truncated. When EP_Reduced is set, then all
|
|
** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees
|
|
** are contained within the same memory allocation. Note, however, that
|
|
** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately
|
|
** allocated, regardless of whether or not EP_Reduced is set.
|
|
*/
|
|
struct Expr {
|
|
u8 op; /* Operation performed by this node */
|
|
char affinity; /* The affinity of the column or 0 if not a column */
|
|
u32 flags; /* Various flags. EP_* See below */
|
|
union {
|
|
char *zToken; /* Token value. Zero terminated and dequoted */
|
|
int iValue; /* Non-negative integer value if EP_IntValue */
|
|
} u;
|
|
|
|
/* If the EP_TokenOnly flag is set in the Expr.flags mask, then no
|
|
** space is allocated for the fields below this point. An attempt to
|
|
** access them will result in a segfault or malfunction.
|
|
*********************************************************************/
|
|
|
|
Expr *pLeft; /* Left subnode */
|
|
Expr *pRight; /* Right subnode */
|
|
union {
|
|
ExprList *pList; /* op = IN, EXISTS, SELECT, CASE, FUNCTION, BETWEEN */
|
|
Select *pSelect; /* EP_xIsSelect and op = IN, EXISTS, SELECT */
|
|
} x;
|
|
|
|
/* If the EP_Reduced flag is set in the Expr.flags mask, then no
|
|
** space is allocated for the fields below this point. An attempt to
|
|
** access them will result in a segfault or malfunction.
|
|
*********************************************************************/
|
|
|
|
#if SQLITE_MAX_EXPR_DEPTH>0
|
|
int nHeight; /* Height of the tree headed by this node */
|
|
#endif
|
|
int iTable; /* TK_COLUMN: cursor number of table holding column
|
|
** TK_REGISTER: register number
|
|
** TK_TRIGGER: 1 -> new, 0 -> old
|
|
** EP_Unlikely: 134217728 times likelihood */
|
|
ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
|
|
** TK_VARIABLE: variable number (always >= 1). */
|
|
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
|
|
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
|
|
u8 op2; /* TK_REGISTER: original value of Expr.op
|
|
** TK_COLUMN: the value of p5 for OP_Column
|
|
** TK_AGG_FUNCTION: nesting depth */
|
|
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
|
|
Table *pTab; /* Table for TK_COLUMN expressions. */
|
|
};
|
|
|
|
/*
|
|
** The following are the meanings of bits in the Expr.flags field.
|
|
*/
|
|
#define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
|
|
#define EP_Agg 0x000002 /* Contains one or more aggregate functions */
|
|
#define EP_Resolved 0x000004 /* IDs have been resolved to COLUMNs */
|
|
#define EP_Error 0x000008 /* Expression contains one or more errors */
|
|
#define EP_Distinct 0x000010 /* Aggregate function with DISTINCT keyword */
|
|
#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
|
|
#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
|
|
#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
|
|
#define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
|
|
#define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */
|
|
#define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
|
|
#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
|
|
#define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */
|
|
#define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
|
|
#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
|
|
#define EP_Static 0x008000 /* Held in memory not obtained from malloc() */
|
|
#define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
|
|
#define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
|
|
#define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
|
|
#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
|
|
#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
|
|
#define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
|
|
#define EP_Alias 0x400000 /* Is an alias for a result set column */
|
|
|
|
/*
|
|
** Combinations of two or more EP_* flags
|
|
*/
|
|
#define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */
|
|
|
|
/*
|
|
** These macros can be used to test, set, or clear bits in the
|
|
** Expr.flags field.
|
|
*/
|
|
#define ExprHasProperty(E,P) (((E)->flags&(P))!=0)
|
|
#define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P))
|
|
#define ExprSetProperty(E,P) (E)->flags|=(P)
|
|
#define ExprClearProperty(E,P) (E)->flags&=~(P)
|
|
|
|
/* The ExprSetVVAProperty() macro is used for Verification, Validation,
|
|
** and Accreditation only. It works like ExprSetProperty() during VVA
|
|
** processes but is a no-op for delivery.
|
|
*/
|
|
#ifdef SQLITE_DEBUG
|
|
# define ExprSetVVAProperty(E,P) (E)->flags|=(P)
|
|
#else
|
|
# define ExprSetVVAProperty(E,P)
|
|
#endif
|
|
|
|
/*
|
|
** Macros to determine the number of bytes required by a normal Expr
|
|
** struct, an Expr struct with the EP_Reduced flag set in Expr.flags
|
|
** and an Expr struct with the EP_TokenOnly flag set.
|
|
*/
|
|
#define EXPR_FULLSIZE sizeof(Expr) /* Full size */
|
|
#define EXPR_REDUCEDSIZE offsetof(Expr,iTable) /* Common features */
|
|
#define EXPR_TOKENONLYSIZE offsetof(Expr,pLeft) /* Fewer features */
|
|
|
|
/*
|
|
** Flags passed to the sqlite3ExprDup() function. See the header comment
|
|
** above sqlite3ExprDup() for details.
|
|
*/
|
|
#define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */
|
|
|
|
/*
|
|
** A list of expressions. Each expression may optionally have a
|
|
** name. An expr/name combination can be used in several ways, such
|
|
** as the list of "expr AS ID" fields following a "SELECT" or in the
|
|
** list of "ID = expr" items in an UPDATE. A list of expressions can
|
|
** also be used as the argument to a function, in which case the a.zName
|
|
** field is not used.
|
|
**
|
|
** By default the Expr.zSpan field holds a human-readable description of
|
|
** the expression that is used in the generation of error messages and
|
|
** column labels. In this case, Expr.zSpan is typically the text of a
|
|
** column expression as it exists in a SELECT statement. However, if
|
|
** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name
|
|
** of the result column in the form: DATABASE.TABLE.COLUMN. This later
|
|
** form is used for name resolution with nested FROM clauses.
|
|
*/
|
|
struct ExprList {
|
|
int nExpr; /* Number of expressions on the list */
|
|
struct ExprList_item { /* For each expression in the list */
|
|
Expr *pExpr; /* The list of expressions */
|
|
char *zName; /* Token associated with this expression */
|
|
char *zSpan; /* Original text of the expression */
|
|
u8 sortOrder; /* 1 for DESC or 0 for ASC */
|
|
unsigned done :1; /* A flag to indicate when processing is finished */
|
|
unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
|
|
unsigned reusable :1; /* Constant expression is reusable */
|
|
union {
|
|
struct {
|
|
u16 iOrderByCol; /* For ORDER BY, column number in result set */
|
|
u16 iAlias; /* Index into Parse.aAlias[] for zName */
|
|
} x;
|
|
int iConstExprReg; /* Register in which Expr value is cached */
|
|
} u;
|
|
} *a; /* Alloc a power of two greater or equal to nExpr */
|
|
};
|
|
|
|
/*
|
|
** An instance of this structure is used by the parser to record both
|
|
** the parse tree for an expression and the span of input text for an
|
|
** expression.
|
|
*/
|
|
struct ExprSpan {
|
|
Expr *pExpr; /* The expression parse tree */
|
|
const char *zStart; /* First character of input text */
|
|
const char *zEnd; /* One character past the end of input text */
|
|
};
|
|
|
|
/*
|
|
** An instance of this structure can hold a simple list of identifiers,
|
|
** such as the list "a,b,c" in the following statements:
|
|
**
|
|
** INSERT INTO t(a,b,c) VALUES ...;
|
|
** CREATE INDEX idx ON t(a,b,c);
|
|
** CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...;
|
|
**
|
|
** The IdList.a.idx field is used when the IdList represents the list of
|
|
** column names after a table name in an INSERT statement. In the statement
|
|
**
|
|
** INSERT INTO t(a,b,c) ...
|
|
**
|
|
** If "a" is the k-th column of table "t", then IdList.a[0].idx==k.
|
|
*/
|
|
struct IdList {
|
|
struct IdList_item {
|
|
char *zName; /* Name of the identifier */
|
|
int idx; /* Index in some Table.aCol[] of a column named zName */
|
|
} *a;
|
|
int nId; /* Number of identifiers on the list */
|
|
};
|
|
|
|
/*
|
|
** The bitmask datatype defined below is used for various optimizations.
|
|
**
|
|
** Changing this from a 64-bit to a 32-bit type limits the number of
|
|
** tables in a join to 32 instead of 64. But it also reduces the size
|
|
** of the library by 738 bytes on ix86.
|
|
*/
|
|
typedef u64 Bitmask;
|
|
|
|
/*
|
|
** The number of bits in a Bitmask. "BMS" means "BitMask Size".
|
|
*/
|
|
#define BMS ((int)(sizeof(Bitmask)*8))
|
|
|
|
/*
|
|
** A bit in a Bitmask
|
|
*/
|
|
#define MASKBIT(n) (((Bitmask)1)<<(n))
|
|
#define MASKBIT32(n) (((unsigned int)1)<<(n))
|
|
|
|
/*
|
|
** The following structure describes the FROM clause of a SELECT statement.
|
|
** Each table or subquery in the FROM clause is a separate element of
|
|
** the SrcList.a[] array.
|
|
**
|
|
** With the addition of multiple database support, the following structure
|
|
** can also be used to describe a particular table such as the table that
|
|
** is modified by an INSERT, DELETE, or UPDATE statement. In standard SQL,
|
|
** such a table must be a simple name: ID. But in SQLite, the table can
|
|
** now be identified by a database name, a dot, then the table name: ID.ID.
|
|
**
|
|
** The jointype starts out showing the join type between the current table
|
|
** and the next table on the list. The parser builds the list this way.
|
|
** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each
|
|
** jointype expresses the join between the table and the previous table.
|
|
**
|
|
** In the colUsed field, the high-order bit (bit 63) is set if the table
|
|
** contains more than 63 columns and the 64-th or later column is used.
|
|
*/
|
|
struct SrcList {
|
|
int nSrc; /* Number of tables or subqueries in the FROM clause */
|
|
u32 nAlloc; /* Number of entries allocated in a[] below */
|
|
struct SrcList_item {
|
|
Schema *pSchema; /* Schema to which this item is fixed */
|
|
char *zDatabase; /* Name of database holding this table */
|
|
char *zName; /* Name of the table */
|
|
char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */
|
|
Table *pTab; /* An SQL table corresponding to zName */
|
|
Select *pSelect; /* A SELECT statement used in place of a table name */
|
|
int addrFillSub; /* Address of subroutine to manifest a subquery */
|
|
int regReturn; /* Register holding return address of addrFillSub */
|
|
int regResult; /* Registers holding results of a co-routine */
|
|
struct {
|
|
u8 jointype; /* Type of join between this able and the previous */
|
|
unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
|
|
unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */
|
|
unsigned isTabFunc :1; /* True if table-valued-function syntax */
|
|
unsigned isCorrelated :1; /* True if sub-query is correlated */
|
|
unsigned viaCoroutine :1; /* Implemented as a co-routine */
|
|
unsigned isRecursive :1; /* True for recursive reference in WITH */
|
|
} fg;
|
|
#ifndef SQLITE_OMIT_EXPLAIN
|
|
u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
|
|
#endif
|
|
int iCursor; /* The VDBE cursor number used to access this table */
|
|
Expr *pOn; /* The ON clause of a join */
|
|
IdList *pUsing; /* The USING clause of a join */
|
|
Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
|
|
union {
|
|
char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */
|
|
ExprList *pFuncArg; /* Arguments to table-valued-function */
|
|
} u1;
|
|
Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */
|
|
} a[1]; /* One entry for each identifier on the list */
|
|
};
|
|
|
|
/*
|
|
** Permitted values of the SrcList.a.jointype field
|
|
*/
|
|
#define JT_INNER 0x0001 /* Any kind of inner or cross join */
|
|
#define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */
|
|
#define JT_NATURAL 0x0004 /* True for a "natural" join */
|
|
#define JT_LEFT 0x0008 /* Left outer join */
|
|
#define JT_RIGHT 0x0010 /* Right outer join */
|
|
#define JT_OUTER 0x0020 /* The "OUTER" keyword is present */
|
|
#define JT_ERROR 0x0040 /* unknown or unsupported join type */
|
|
|
|
|
|
/*
|
|
** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin()
|
|
** and the WhereInfo.wctrlFlags member.
|
|
*/
|
|
#define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */
|
|
#define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */
|
|
#define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */
|
|
#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
|
|
#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
|
|
#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
|
|
#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
|
|
#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
|
|
#define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */
|
|
#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
|
|
#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
|
|
#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
|
|
#define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
|
|
#define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */
|
|
#define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */
|
|
|
|
/* Allowed return values from sqlite3WhereIsDistinct()
|
|
*/
|
|
#define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */
|
|
#define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */
|
|
#define WHERE_DISTINCT_ORDERED 2 /* All duplicates are adjacent */
|
|
#define WHERE_DISTINCT_UNORDERED 3 /* Duplicates are scattered */
|
|
|
|
/*
|
|
** A NameContext defines a context in which to resolve table and column
|
|
** names. The context consists of a list of tables (the pSrcList) field and
|
|
** a list of named expression (pEList). The named expression list may
|
|
** be NULL. The pSrc corresponds to the FROM clause of a SELECT or
|
|
** to the table being operated on by INSERT, UPDATE, or DELETE. The
|
|
** pEList corresponds to the result set of a SELECT and is NULL for
|
|
** other statements.
|
|
**
|
|
** NameContexts can be nested. When resolving names, the inner-most
|
|
** context is searched first. If no match is found, the next outer
|
|
** context is checked. If there is still no match, the next context
|
|
** is checked. This process continues until either a match is found
|
|
** or all contexts are check. When a match is found, the nRef member of
|
|
** the context containing the match is incremented.
|
|
**
|
|
** Each subquery gets a new NameContext. The pNext field points to the
|
|
** NameContext in the parent query. Thus the process of scanning the
|
|
** NameContext list corresponds to searching through successively outer
|
|
** subqueries looking for a match.
|
|
*/
|
|
struct NameContext {
|
|
Parse *pParse; /* The parser */
|
|
SrcList *pSrcList; /* One or more tables used to resolve names */
|
|
ExprList *pEList; /* Optional list of result-set columns */
|
|
AggInfo *pAggInfo; /* Information about aggregates at this level */
|
|
NameContext *pNext; /* Next outer name context. NULL for outermost */
|
|
int nRef; /* Number of names resolved by this context */
|
|
int nErr; /* Number of errors encountered while resolving names */
|
|
u16 ncFlags; /* Zero or more NC_* flags defined below */
|
|
};
|
|
|
|
/*
|
|
** Allowed values for the NameContext, ncFlags field.
|
|
**
|
|
** Note: NC_MinMaxAgg must have the same value as SF_MinMaxAgg and
|
|
** SQLITE_FUNC_MINMAX.
|
|
**
|
|
*/
|
|
#define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */
|
|
#define NC_HasAgg 0x0002 /* One or more aggregate functions seen */
|
|
#define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */
|
|
#define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */
|
|
#define NC_PartIdx 0x0010 /* True if resolving a partial index WHERE */
|
|
#define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */
|
|
#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
|
|
|
|
/*
|
|
** An instance of the following structure contains all information
|
|
** needed to generate code for a single SELECT statement.
|
|
**
|
|
** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0.
|
|
** If there is a LIMIT clause, the parser sets nLimit to the value of the
|
|
** limit and nOffset to the value of the offset (or 0 if there is not
|
|
** offset). But later on, nLimit and nOffset become the memory locations
|
|
** in the VDBE that record the limit and offset counters.
|
|
**
|
|
** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes.
|
|
** These addresses must be stored so that we can go back and fill in
|
|
** the P4_KEYINFO and P2 parameters later. Neither the KeyInfo nor
|
|
** the number of columns in P2 can be computed at the same time
|
|
** as the OP_OpenEphm instruction is coded because not
|
|
** enough information about the compound query is known at that point.
|
|
** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences
|
|
** for the result set. The KeyInfo for addrOpenEphm[2] contains collating
|
|
** sequences for the ORDER BY clause.
|
|
*/
|
|
struct Select {
|
|
ExprList *pEList; /* The fields of the result */
|
|
u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
|
|
u16 selFlags; /* Various SF_* values */
|
|
int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */
|
|
#if SELECTTRACE_ENABLED
|
|
char zSelName[12]; /* Symbolic name of this SELECT use for debugging */
|
|
#endif
|
|
int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */
|
|
u64 nSelectRow; /* Estimated number of result rows */
|
|
SrcList *pSrc; /* The FROM clause */
|
|
Expr *pWhere; /* The WHERE clause */
|
|
ExprList *pGroupBy; /* The GROUP BY clause */
|
|
Expr *pHaving; /* The HAVING clause */
|
|
ExprList *pOrderBy; /* The ORDER BY clause */
|
|
Select *pPrior; /* Prior select in a compound select statement */
|
|
Select *pNext; /* Next select to the left in a compound */
|
|
Expr *pLimit; /* LIMIT expression. NULL means not used. */
|
|
Expr *pOffset; /* OFFSET expression. NULL means not used. */
|
|
With *pWith; /* WITH clause attached to this select. Or NULL. */
|
|
#ifdef MAXSCALE
|
|
ExprList* pInto; /* The INTO clause */
|
|
#endif
|
|
};
|
|
|
|
/*
|
|
** Allowed values for Select.selFlags. The "SF" prefix stands for
|
|
** "Select Flag".
|
|
*/
|
|
#define SF_Distinct 0x0001 /* Output should be DISTINCT */
|
|
#define SF_All 0x0002 /* Includes the ALL keyword */
|
|
#define SF_Resolved 0x0004 /* Identifiers have been resolved */
|
|
#define SF_Aggregate 0x0008 /* Contains aggregate functions */
|
|
#define SF_UsesEphemeral 0x0010 /* Uses the OpenEphemeral opcode */
|
|
#define SF_Expanded 0x0020 /* sqlite3SelectExpand() called on this */
|
|
#define SF_HasTypeInfo 0x0040 /* FROM subqueries have Table metadata */
|
|
#define SF_Compound 0x0080 /* Part of a compound query */
|
|
#define SF_Values 0x0100 /* Synthesized from VALUES clause */
|
|
#define SF_MultiValue 0x0200 /* Single VALUES term with multiple rows */
|
|
#define SF_NestedFrom 0x0400 /* Part of a parenthesized FROM clause */
|
|
#define SF_MaybeConvert 0x0800 /* Need convertCompoundSelectToSubquery() */
|
|
#define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */
|
|
#define SF_Recursive 0x2000 /* The recursive part of a recursive CTE */
|
|
#define SF_Converted 0x4000 /* By convertCompoundSelectToSubquery() */
|
|
#define SF_IncludeHidden 0x8000 /* Include hidden columns in output */
|
|
|
|
|
|
/*
|
|
** The results of a SELECT can be distributed in several ways, as defined
|
|
** by one of the following macros. The "SRT" prefix means "SELECT Result
|
|
** Type".
|
|
**
|
|
** SRT_Union Store results as a key in a temporary index
|
|
** identified by pDest->iSDParm.
|
|
**
|
|
** SRT_Except Remove results from the temporary index pDest->iSDParm.
|
|
**
|
|
** SRT_Exists Store a 1 in memory cell pDest->iSDParm if the result
|
|
** set is not empty.
|
|
**
|
|
** SRT_Discard Throw the results away. This is used by SELECT
|
|
** statements within triggers whose only purpose is
|
|
** the side-effects of functions.
|
|
**
|
|
** All of the above are free to ignore their ORDER BY clause. Those that
|
|
** follow must honor the ORDER BY clause.
|
|
**
|
|
** SRT_Output Generate a row of output (using the OP_ResultRow
|
|
** opcode) for each row in the result set.
|
|
**
|
|
** SRT_Mem Only valid if the result is a single column.
|
|
** Store the first column of the first result row
|
|
** in register pDest->iSDParm then abandon the rest
|
|
** of the query. This destination implies "LIMIT 1".
|
|
**
|
|
** SRT_Set The result must be a single column. Store each
|
|
** row of result as the key in table pDest->iSDParm.
|
|
** Apply the affinity pDest->affSdst before storing
|
|
** results. Used to implement "IN (SELECT ...)".
|
|
**
|
|
** SRT_EphemTab Create an temporary table pDest->iSDParm and store
|
|
** the result there. The cursor is left open after
|
|
** returning. This is like SRT_Table except that
|
|
** this destination uses OP_OpenEphemeral to create
|
|
** the table first.
|
|
**
|
|
** SRT_Coroutine Generate a co-routine that returns a new row of
|
|
** results each time it is invoked. The entry point
|
|
** of the co-routine is stored in register pDest->iSDParm
|
|
** and the result row is stored in pDest->nDest registers
|
|
** starting with pDest->iSdst.
|
|
**
|
|
** SRT_Table Store results in temporary table pDest->iSDParm.
|
|
** SRT_Fifo This is like SRT_EphemTab except that the table
|
|
** is assumed to already be open. SRT_Fifo has
|
|
** the additional property of being able to ignore
|
|
** the ORDER BY clause.
|
|
**
|
|
** SRT_DistFifo Store results in a temporary table pDest->iSDParm.
|
|
** But also use temporary table pDest->iSDParm+1 as
|
|
** a record of all prior results and ignore any duplicate
|
|
** rows. Name means: "Distinct Fifo".
|
|
**
|
|
** SRT_Queue Store results in priority queue pDest->iSDParm (really
|
|
** an index). Append a sequence number so that all entries
|
|
** are distinct.
|
|
**
|
|
** SRT_DistQueue Store results in priority queue pDest->iSDParm only if
|
|
** the same record has never been stored before. The
|
|
** index at pDest->iSDParm+1 hold all prior stores.
|
|
*/
|
|
#define SRT_Union 1 /* Store result as keys in an index */
|
|
#define SRT_Except 2 /* Remove result from a UNION index */
|
|
#define SRT_Exists 3 /* Store 1 if the result is not empty */
|
|
#define SRT_Discard 4 /* Do not save the results anywhere */
|
|
#define SRT_Fifo 5 /* Store result as data with an automatic rowid */
|
|
#define SRT_DistFifo 6 /* Like SRT_Fifo, but unique results only */
|
|
#define SRT_Queue 7 /* Store result in an queue */
|
|
#define SRT_DistQueue 8 /* Like SRT_Queue, but unique results only */
|
|
|
|
/* The ORDER BY clause is ignored for all of the above */
|
|
#define IgnorableOrderby(X) ((X->eDest)<=SRT_DistQueue)
|
|
|
|
#define SRT_Output 9 /* Output each row of result */
|
|
#define SRT_Mem 10 /* Store result in a memory cell */
|
|
#define SRT_Set 11 /* Store results as keys in an index */
|
|
#define SRT_EphemTab 12 /* Create transient tab and store like SRT_Table */
|
|
#define SRT_Coroutine 13 /* Generate a single row of result */
|
|
#define SRT_Table 14 /* Store result as data with an automatic rowid */
|
|
|
|
/*
|
|
** An instance of this object describes where to put of the results of
|
|
** a SELECT statement.
|
|
*/
|
|
struct SelectDest {
|
|
u8 eDest; /* How to dispose of the results. On of SRT_* above. */
|
|
char affSdst; /* Affinity used when eDest==SRT_Set */
|
|
int iSDParm; /* A parameter used by the eDest disposal method */
|
|
int iSdst; /* Base register where results are written */
|
|
int nSdst; /* Number of registers allocated */
|
|
ExprList *pOrderBy; /* Key columns for SRT_Queue and SRT_DistQueue */
|
|
};
|
|
|
|
/*
|
|
** During code generation of statements that do inserts into AUTOINCREMENT
|
|
** tables, the following information is attached to the Table.u.autoInc.p
|
|
** pointer of each autoincrement table to record some side information that
|
|
** the code generator needs. We have to keep per-table autoincrement
|
|
** information in case inserts are done within triggers. Triggers do not
|
|
** normally coordinate their activities, but we do need to coordinate the
|
|
** loading and saving of autoincrement information.
|
|
*/
|
|
struct AutoincInfo {
|
|
AutoincInfo *pNext; /* Next info block in a list of them all */
|
|
Table *pTab; /* Table this info block refers to */
|
|
int iDb; /* Index in sqlite3.aDb[] of database holding pTab */
|
|
int regCtr; /* Memory register holding the rowid counter */
|
|
};
|
|
|
|
/*
|
|
** Size of the column cache
|
|
*/
|
|
#ifndef SQLITE_N_COLCACHE
|
|
# define SQLITE_N_COLCACHE 10
|
|
#endif
|
|
|
|
/*
|
|
** At least one instance of the following structure is created for each
|
|
** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
|
|
** statement. All such objects are stored in the linked list headed at
|
|
** Parse.pTriggerPrg and deleted once statement compilation has been
|
|
** completed.
|
|
**
|
|
** A Vdbe sub-program that implements the body and WHEN clause of trigger
|
|
** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of
|
|
** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable.
|
|
** The Parse.pTriggerPrg list never contains two entries with the same
|
|
** values for both pTrigger and orconf.
|
|
**
|
|
** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns
|
|
** accessed (or set to 0 for triggers fired as a result of INSERT
|
|
** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to
|
|
** a mask of new.* columns used by the program.
|
|
*/
|
|
struct TriggerPrg {
|
|
Trigger *pTrigger; /* Trigger this program was coded from */
|
|
TriggerPrg *pNext; /* Next entry in Parse.pTriggerPrg list */
|
|
SubProgram *pProgram; /* Program implementing pTrigger/orconf */
|
|
int orconf; /* Default ON CONFLICT policy */
|
|
u32 aColmask[2]; /* Masks of old.*, new.* columns accessed */
|
|
};
|
|
|
|
/*
|
|
** The yDbMask datatype for the bitmask of all attached databases.
|
|
*/
|
|
#if SQLITE_MAX_ATTACHED>30
|
|
typedef unsigned char yDbMask[(SQLITE_MAX_ATTACHED+9)/8];
|
|
# define DbMaskTest(M,I) (((M)[(I)/8]&(1<<((I)&7)))!=0)
|
|
# define DbMaskZero(M) memset((M),0,sizeof(M))
|
|
# define DbMaskSet(M,I) (M)[(I)/8]|=(1<<((I)&7))
|
|
# define DbMaskAllZero(M) sqlite3DbMaskAllZero(M)
|
|
# define DbMaskNonZero(M) (sqlite3DbMaskAllZero(M)==0)
|
|
#else
|
|
typedef unsigned int yDbMask;
|
|
# define DbMaskTest(M,I) (((M)&(((yDbMask)1)<<(I)))!=0)
|
|
# define DbMaskZero(M) (M)=0
|
|
# define DbMaskSet(M,I) (M)|=(((yDbMask)1)<<(I))
|
|
# define DbMaskAllZero(M) (M)==0
|
|
# define DbMaskNonZero(M) (M)!=0
|
|
#endif
|
|
|
|
/*
|
|
** An SQL parser context. A copy of this structure is passed through
|
|
** the parser and down into all the parser action routine in order to
|
|
** carry around information that is global to the entire parse.
|
|
**
|
|
** The structure is divided into two parts. When the parser and code
|
|
** generate call themselves recursively, the first part of the structure
|
|
** is constant but the second part is reset at the beginning and end of
|
|
** each recursion.
|
|
**
|
|
** The nTableLock and aTableLock variables are only used if the shared-cache
|
|
** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are
|
|
** used to store the set of table-locks required by the statement being
|
|
** compiled. Function sqlite3TableLock() is used to add entries to the
|
|
** list.
|
|
*/
|
|
struct Parse {
|
|
sqlite3 *db; /* The main database structure */
|
|
char *zErrMsg; /* An error message */
|
|
Vdbe *pVdbe; /* An engine for executing database bytecode */
|
|
int rc; /* Return code from execution */
|
|
u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */
|
|
u8 checkSchema; /* Causes schema cookie check after an error */
|
|
u8 nested; /* Number of nested calls to the parser/code generator */
|
|
u8 nTempReg; /* Number of temporary registers in aTempReg[] */
|
|
u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
|
|
u8 mayAbort; /* True if statement may throw an ABORT exception */
|
|
u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
|
|
u8 okConstFactor; /* OK to factor out constants */
|
|
u8 disableLookaside; /* Number of times lookaside has been disabled */
|
|
int aTempReg[8]; /* Holding area for temporary registers */
|
|
int nRangeReg; /* Size of the temporary register block */
|
|
int iRangeReg; /* First register in temporary register block */
|
|
int nErr; /* Number of errors seen */
|
|
int nTab; /* Number of previously allocated VDBE cursors */
|
|
int nMem; /* Number of memory cells used so far */
|
|
int nSet; /* Number of sets used so far */
|
|
int nOnce; /* Number of OP_Once instructions so far */
|
|
int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
|
|
int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
|
|
int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */
|
|
int ckBase; /* Base register of data during check constraints */
|
|
int iSelfTab; /* Table of an index whose exprs are being coded */
|
|
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
|
|
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
|
|
int nLabel; /* Number of labels used */
|
|
int *aLabel; /* Space to hold the labels */
|
|
struct yColCache {
|
|
int iTable; /* Table cursor number */
|
|
i16 iColumn; /* Table column number */
|
|
u8 tempReg; /* iReg is a temp register that needs to be freed */
|
|
int iLevel; /* Nesting level */
|
|
int iReg; /* Reg with value of this column. 0 means none. */
|
|
int lru; /* Least recently used entry has the smallest value */
|
|
} aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */
|
|
ExprList *pConstExpr;/* Constant expressions */
|
|
Token constraintName;/* Name of the constraint currently being parsed */
|
|
yDbMask writeMask; /* Start a write transaction on these databases */
|
|
yDbMask cookieMask; /* Bitmask of schema verified databases */
|
|
int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */
|
|
int regRowid; /* Register holding rowid of CREATE TABLE entry */
|
|
int regRoot; /* Register holding root page number for new objects */
|
|
int nMaxArg; /* Max args passed to user function by sub-program */
|
|
#if SELECTTRACE_ENABLED
|
|
int nSelect; /* Number of SELECT statements seen */
|
|
int nSelectIndent; /* How far to indent SELECTTRACE() output */
|
|
#endif
|
|
#ifndef SQLITE_OMIT_SHARED_CACHE
|
|
int nTableLock; /* Number of locks in aTableLock */
|
|
TableLock *aTableLock; /* Required table locks for shared-cache mode */
|
|
#endif
|
|
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
|
|
|
|
/* Information used while coding trigger programs. */
|
|
Parse *pToplevel; /* Parse structure for main program (or NULL) */
|
|
Table *pTriggerTab; /* Table triggers are being coded for */
|
|
int addrCrTab; /* Address of OP_CreateTable opcode on CREATE TABLE */
|
|
u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */
|
|
u32 oldmask; /* Mask of old.* columns referenced */
|
|
u32 newmask; /* Mask of new.* columns referenced */
|
|
u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
|
|
u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
|
|
u8 disableTriggers; /* True to disable triggers */
|
|
|
|
/************************************************************************
|
|
** Above is constant between recursions. Below is reset before and after
|
|
** each recursion. The boundary between these two regions is determined
|
|
** using offsetof(Parse,nVar) so the nVar field must be the first field
|
|
** in the recursive region.
|
|
************************************************************************/
|
|
|
|
ynVar nVar; /* Number of '?' variables seen in the SQL so far */
|
|
int nzVar; /* Number of available slots in azVar[] */
|
|
u8 iPkSortOrder; /* ASC or DESC for INTEGER PRIMARY KEY */
|
|
u8 explain; /* True if the EXPLAIN flag is found on the query */
|
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
|
u8 declareVtab; /* True if inside sqlite3_declare_vtab() */
|
|
int nVtabLock; /* Number of virtual tables to lock */
|
|
#endif
|
|
int nAlias; /* Number of aliased result set columns */
|
|
int nHeight; /* Expression tree height of current sub-select */
|
|
#ifndef SQLITE_OMIT_EXPLAIN
|
|
int iSelectId; /* ID of current select for EXPLAIN output */
|
|
int iNextSelectId; /* Next available select ID for EXPLAIN output */
|
|
#endif
|
|
char **azVar; /* Pointers to names of parameters */
|
|
Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
|
|
const char *zTail; /* All SQL text past the last semicolon parsed */
|
|
Table *pNewTable; /* A table being constructed by CREATE TABLE */
|
|
Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
|
|
const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
|
|
Token sNameToken; /* Token with unqualified schema object name */
|
|
Token sLastToken; /* The last token parsed */
|
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
|
Token sArg; /* Complete text of a module argument */
|
|
Table **apVtabLock; /* Pointer to virtual tables needing locking */
|
|
#endif
|
|
Table *pZombieTab; /* List of Table objects to delete after code gen */
|
|
TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
|
|
With *pWith; /* Current WITH clause, or NULL */
|
|
With *pWithToFree; /* Free this WITH object at the end of the parse */
|
|
};
|
|
|
|
/*
|
|
** Return true if currently inside an sqlite3_declare_vtab() call.
|
|
*/
|
|
#ifdef SQLITE_OMIT_VIRTUALTABLE
|
|
#define IN_DECLARE_VTAB 0
|
|
#else
|
|
#define IN_DECLARE_VTAB (pParse->declareVtab)
|
|
#endif
|
|
|
|
/*
|
|
** An instance of the following structure can be declared on a stack and used
|
|
** to save the Parse.zAuthContext value so that it can be restored later.
|
|
*/
|
|
struct AuthContext {
|
|
const char *zAuthContext; /* Put saved Parse.zAuthContext here */
|
|
Parse *pParse; /* The Parse structure */
|
|
};
|
|
|
|
/*
|
|
** Bitfield flags for P5 value in various opcodes.
|
|
*/
|
|
#define OPFLAG_NCHANGE 0x01 /* OP_Insert: Set to update db->nChange */
|
|
/* Also used in P2 (not P5) of OP_Delete */
|
|
#define OPFLAG_EPHEM 0x01 /* OP_Column: Ephemeral output is ok */
|
|
#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */
|
|
#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
|
|
#define OPFLAG_APPEND 0x08 /* This is likely to be an append */
|
|
#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
|
|
#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
|
|
#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
|
|
#define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */
|
|
#define OPFLAG_SEEKEQ 0x02 /* OP_Open** cursor uses EQ seek only */
|
|
#define OPFLAG_FORDELETE 0x08 /* OP_Open should use BTREE_FORDELETE */
|
|
#define OPFLAG_P2ISREG 0x10 /* P2 to OP_Open** is a register number */
|
|
#define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */
|
|
#define OPFLAG_SAVEPOSITION 0x02 /* OP_Delete: keep cursor position */
|
|
#define OPFLAG_AUXDELETE 0x04 /* OP_Delete: index in a DELETE op */
|
|
|
|
/*
|
|
* Each trigger present in the database schema is stored as an instance of
|
|
* struct Trigger.
|
|
*
|
|
* Pointers to instances of struct Trigger are stored in two ways.
|
|
* 1. In the "trigHash" hash table (part of the sqlite3* that represents the
|
|
* database). This allows Trigger structures to be retrieved by name.
|
|
* 2. All triggers associated with a single table form a linked list, using the
|
|
* pNext member of struct Trigger. A pointer to the first element of the
|
|
* linked list is stored as the "pTrigger" member of the associated
|
|
* struct Table.
|
|
*
|
|
* The "step_list" member points to the first element of a linked list
|
|
* containing the SQL statements specified as the trigger program.
|
|
*/
|
|
struct Trigger {
|
|
char *zName; /* The name of the trigger */
|
|
char *table; /* The table or view to which the trigger applies */
|
|
u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */
|
|
u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */
|
|
Expr *pWhen; /* The WHEN clause of the expression (may be NULL) */
|
|
IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger,
|
|
the <column-list> is stored here */
|
|
Schema *pSchema; /* Schema containing the trigger */
|
|
Schema *pTabSchema; /* Schema containing the table */
|
|
TriggerStep *step_list; /* Link list of trigger program steps */
|
|
Trigger *pNext; /* Next trigger associated with the table */
|
|
};
|
|
|
|
/*
|
|
** A trigger is either a BEFORE or an AFTER trigger. The following constants
|
|
** determine which.
|
|
**
|
|
** If there are multiple triggers, you might of some BEFORE and some AFTER.
|
|
** In that cases, the constants below can be ORed together.
|
|
*/
|
|
#define TRIGGER_BEFORE 1
|
|
#define TRIGGER_AFTER 2
|
|
|
|
/*
|
|
* An instance of struct TriggerStep is used to store a single SQL statement
|
|
* that is a part of a trigger-program.
|
|
*
|
|
* Instances of struct TriggerStep are stored in a singly linked list (linked
|
|
* using the "pNext" member) referenced by the "step_list" member of the
|
|
* associated struct Trigger instance. The first element of the linked list is
|
|
* the first step of the trigger-program.
|
|
*
|
|
* The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or
|
|
* "SELECT" statement. The meanings of the other members is determined by the
|
|
* value of "op" as follows:
|
|
*
|
|
* (op == TK_INSERT)
|
|
* orconf -> stores the ON CONFLICT algorithm
|
|
* pSelect -> If this is an INSERT INTO ... SELECT ... statement, then
|
|
* this stores a pointer to the SELECT statement. Otherwise NULL.
|
|
* zTarget -> Dequoted name of the table to insert into.
|
|
* pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
|
|
* this stores values to be inserted. Otherwise NULL.
|
|
* pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ...
|
|
* statement, then this stores the column-names to be
|
|
* inserted into.
|
|
*
|
|
* (op == TK_DELETE)
|
|
* zTarget -> Dequoted name of the table to delete from.
|
|
* pWhere -> The WHERE clause of the DELETE statement if one is specified.
|
|
* Otherwise NULL.
|
|
*
|
|
* (op == TK_UPDATE)
|
|
* zTarget -> Dequoted name of the table to update.
|
|
* pWhere -> The WHERE clause of the UPDATE statement if one is specified.
|
|
* Otherwise NULL.
|
|
* pExprList -> A list of the columns to update and the expressions to update
|
|
* them to. See sqlite3Update() documentation of "pChanges"
|
|
* argument.
|
|
*
|
|
*/
|
|
struct TriggerStep {
|
|
u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
|
|
u8 orconf; /* OE_Rollback etc. */
|
|
Trigger *pTrig; /* The trigger that this step is a part of */
|
|
Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */
|
|
char *zTarget; /* Target table for DELETE, UPDATE, INSERT */
|
|
Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */
|
|
ExprList *pExprList; /* SET clause for UPDATE. */
|
|
IdList *pIdList; /* Column names for INSERT */
|
|
TriggerStep *pNext; /* Next in the link-list */
|
|
TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
|
|
};
|
|
|
|
/*
|
|
** The following structure contains information used by the sqliteFix...
|
|
** routines as they walk the parse tree to make database references
|
|
** explicit.
|
|
*/
|
|
typedef struct DbFixer DbFixer;
|
|
struct DbFixer {
|
|
Parse *pParse; /* The parsing context. Error messages written here */
|
|
Schema *pSchema; /* Fix items to this schema */
|
|
int bVarOnly; /* Check for variable references only */
|
|
const char *zDb; /* Make sure all objects are contained in this database */
|
|
const char *zType; /* Type of the container - used for error messages */
|
|
const Token *pName; /* Name of the container - used for error messages */
|
|
};
|
|
|
|
/*
|
|
** An objected used to accumulate the text of a string where we
|
|
** do not necessarily know how big the string will be in the end.
|
|
*/
|
|
struct StrAccum {
|
|
sqlite3 *db; /* Optional database for lookaside. Can be NULL */
|
|
char *zBase; /* A base allocation. Not from malloc. */
|
|
char *zText; /* The string collected so far */
|
|
u32 nChar; /* Length of the string so far */
|
|
u32 nAlloc; /* Amount of space allocated in zText */
|
|
u32 mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */
|
|
u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */
|
|
u8 printfFlags; /* SQLITE_PRINTF flags below */
|
|
};
|
|
#define STRACCUM_NOMEM 1
|
|
#define STRACCUM_TOOBIG 2
|
|
#define SQLITE_PRINTF_INTERNAL 0x01 /* Internal-use-only converters allowed */
|
|
#define SQLITE_PRINTF_SQLFUNC 0x02 /* SQL function arguments to VXPrintf */
|
|
#define SQLITE_PRINTF_MALLOCED 0x04 /* True if xText is allocated space */
|
|
|
|
#define isMalloced(X) (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0)
|
|
|
|
|
|
/*
|
|
** A pointer to this structure is used to communicate information
|
|
** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.
|
|
*/
|
|
typedef struct {
|
|
sqlite3 *db; /* The database being initialized */
|
|
char **pzErrMsg; /* Error message stored here */
|
|
int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
|
|
int rc; /* Result code stored here */
|
|
} InitData;
|
|
|
|
/*
|
|
** Structure containing global configuration data for the SQLite library.
|
|
**
|
|
** This structure also contains some state information.
|
|
*/
|
|
struct Sqlite3Config {
|
|
int bMemstat; /* True to enable memory status */
|
|
int bCoreMutex; /* True to enable core mutexing */
|
|
int bFullMutex; /* True to enable full mutexing */
|
|
int bOpenUri; /* True to interpret filenames as URIs */
|
|
int bUseCis; /* Use covering indices for full-scans */
|
|
int mxStrlen; /* Maximum string length */
|
|
int neverCorrupt; /* Database is always well-formed */
|
|
int szLookaside; /* Default lookaside buffer size */
|
|
int nLookaside; /* Default lookaside buffer count */
|
|
sqlite3_mem_methods m; /* Low-level memory allocation interface */
|
|
sqlite3_mutex_methods mutex; /* Low-level mutex interface */
|
|
sqlite3_pcache_methods2 pcache2; /* Low-level page-cache interface */
|
|
void *pHeap; /* Heap storage space */
|
|
int nHeap; /* Size of pHeap[] */
|
|
int mnReq, mxReq; /* Min and max heap requests sizes */
|
|
sqlite3_int64 szMmap; /* mmap() space per open file */
|
|
sqlite3_int64 mxMmap; /* Maximum value for szMmap */
|
|
void *pScratch; /* Scratch memory */
|
|
int szScratch; /* Size of each scratch buffer */
|
|
int nScratch; /* Number of scratch buffers */
|
|
void *pPage; /* Page cache memory */
|
|
int szPage; /* Size of each page in pPage[] */
|
|
int nPage; /* Number of pages in pPage[] */
|
|
int mxParserStack; /* maximum depth of the parser stack */
|
|
int sharedCacheEnabled; /* true if shared-cache mode enabled */
|
|
u32 szPma; /* Maximum Sorter PMA size */
|
|
/* The above might be initialized to non-zero. The following need to always
|
|
** initially be zero, however. */
|
|
int isInit; /* True after initialization has finished */
|
|
int inProgress; /* True while initialization in progress */
|
|
int isMutexInit; /* True after mutexes are initialized */
|
|
int isMallocInit; /* True after malloc is initialized */
|
|
int isPCacheInit; /* True after malloc is initialized */
|
|
int nRefInitMutex; /* Number of users of pInitMutex */
|
|
sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */
|
|
void (*xLog)(void*,int,const char*); /* Function for logging */
|
|
void *pLogArg; /* First argument to xLog() */
|
|
#ifdef SQLITE_ENABLE_SQLLOG
|
|
void(*xSqllog)(void*,sqlite3*,const char*, int);
|
|
void *pSqllogArg;
|
|
#endif
|
|
#ifdef SQLITE_VDBE_COVERAGE
|
|
/* The following callback (if not NULL) is invoked on every VDBE branch
|
|
** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.
|
|
*/
|
|
void (*xVdbeBranch)(void*,int iSrcLine,u8 eThis,u8 eMx); /* Callback */
|
|
void *pVdbeBranchArg; /* 1st argument */
|
|
#endif
|
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
|
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
|
|
#endif
|
|
int bLocaltimeFault; /* True to fail localtime() calls */
|
|
};
|
|
|
|
/*
|
|
** This macro is used inside of assert() statements to indicate that
|
|
** the assert is only valid on a well-formed database. Instead of:
|
|
**
|
|
** assert( X );
|
|
**
|
|
** One writes:
|
|
**
|
|
** assert( X || CORRUPT_DB );
|
|
**
|
|
** CORRUPT_DB is true during normal operation. CORRUPT_DB does not indicate
|
|
** that the database is definitely corrupt, only that it might be corrupt.
|
|
** For most test cases, CORRUPT_DB is set to false using a special
|
|
** sqlite3_test_control(). This enables assert() statements to prove
|
|
** things that are always true for well-formed databases.
|
|
*/
|
|
#define CORRUPT_DB (sqlite3Config.neverCorrupt==0)
|
|
|
|
/*
|
|
** Context pointer passed down through the tree-walk.
|
|
*/
|
|
struct Walker {
|
|
Parse *pParse; /* Parser context. */
|
|
int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */
|
|
int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
|
|
void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */
|
|
int walkerDepth; /* Number of subqueries */
|
|
u8 eCode; /* A small processing code */
|
|
union { /* Extra data for callback */
|
|
NameContext *pNC; /* Naming context */
|
|
int n; /* A counter */
|
|
int iCur; /* A cursor number */
|
|
SrcList *pSrcList; /* FROM clause */
|
|
struct SrcCount *pSrcCount; /* Counting column references */
|
|
struct CCurHint *pCCurHint; /* Used by codeCursorHint() */
|
|
int *aiCol; /* array of column indexes */
|
|
} u;
|
|
};
|
|
|
|
/* Forward declarations */
|
|
int sqlite3WalkExpr(Walker*, Expr*);
|
|
int sqlite3WalkExprList(Walker*, ExprList*);
|
|
int sqlite3WalkSelect(Walker*, Select*);
|
|
int sqlite3WalkSelectExpr(Walker*, Select*);
|
|
int sqlite3WalkSelectFrom(Walker*, Select*);
|
|
int sqlite3ExprWalkNoop(Walker*, Expr*);
|
|
|
|
/*
|
|
** Return code from the parse-tree walking primitives and their
|
|
** callbacks.
|
|
*/
|
|
#define WRC_Continue 0 /* Continue down into children */
|
|
#define WRC_Prune 1 /* Omit children but continue walking siblings */
|
|
#define WRC_Abort 2 /* Abandon the tree walk */
|
|
|
|
/*
|
|
** An instance of this structure represents a set of one or more CTEs
|
|
** (common table expressions) created by a single WITH clause.
|
|
*/
|
|
struct With {
|
|
int nCte; /* Number of CTEs in the WITH clause */
|
|
With *pOuter; /* Containing WITH clause, or NULL */
|
|
struct Cte { /* For each CTE in the WITH clause.... */
|
|
char *zName; /* Name of this CTE */
|
|
ExprList *pCols; /* List of explicit column names, or NULL */
|
|
Select *pSelect; /* The definition of this CTE */
|
|
const char *zCteErr; /* Error message for circular references */
|
|
} a[1];
|
|
};
|
|
|
|
#ifdef SQLITE_DEBUG
|
|
/*
|
|
** An instance of the TreeView object is used for printing the content of
|
|
** data structures on sqlite3DebugPrintf() using a tree-like view.
|
|
*/
|
|
struct TreeView {
|
|
int iLevel; /* Which level of the tree we are on */
|
|
u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
|
|
};
|
|
#endif /* SQLITE_DEBUG */
|
|
|
|
/*
|
|
** Assuming zIn points to the first byte of a UTF-8 character,
|
|
** advance zIn to point to the first byte of the next UTF-8 character.
|
|
*/
|
|
#define SQLITE_SKIP_UTF8(zIn) { \
|
|
if( (*(zIn++))>=0xc0 ){ \
|
|
while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
|
|
} \
|
|
}
|
|
|
|
/*
|
|
** The SQLITE_*_BKPT macros are substitutes for the error codes with
|
|
** the same name but without the _BKPT suffix. These macros invoke
|
|
** routines that report the line-number on which the error originated
|
|
** using sqlite3_log(). The routines also provide a convenient place
|
|
** to set a debugger breakpoint.
|
|
*/
|
|
int sqlite3CorruptError(int);
|
|
int sqlite3MisuseError(int);
|
|
int sqlite3CantopenError(int);
|
|
#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)
|
|
#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
|
|
#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
|
|
|
|
/*
|
|
** FTS3 and FTS4 both require virtual table support
|
|
*/
|
|
#if defined(SQLITE_OMIT_VIRTUALTABLE)
|
|
# undef SQLITE_ENABLE_FTS3
|
|
# undef SQLITE_ENABLE_FTS4
|
|
#endif
|
|
|
|
/*
|
|
** FTS4 is really an extension for FTS3. It is enabled using the
|
|
** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also call
|
|
** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.
|
|
*/
|
|
#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
|
|
# define SQLITE_ENABLE_FTS3 1
|
|
#endif
|
|
|
|
/*
|
|
** The ctype.h header is needed for non-ASCII systems. It is also
|
|
** needed by FTS3 when FTS3 is included in the amalgamation.
|
|
*/
|
|
#if !defined(SQLITE_ASCII) || \
|
|
(defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))
|
|
# include <ctype.h>
|
|
#endif
|
|
|
|
/*
|
|
** The following macros mimic the standard library functions toupper(),
|
|
** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
|
|
** sqlite versions only work for ASCII characters, regardless of locale.
|
|
*/
|
|
#ifdef SQLITE_ASCII
|
|
# define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20))
|
|
# define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01)
|
|
# define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06)
|
|
# define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02)
|
|
# define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04)
|
|
# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08)
|
|
# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)])
|
|
#else
|
|
# define sqlite3Toupper(x) toupper((unsigned char)(x))
|
|
# define sqlite3Isspace(x) isspace((unsigned char)(x))
|
|
# define sqlite3Isalnum(x) isalnum((unsigned char)(x))
|
|
# define sqlite3Isalpha(x) isalpha((unsigned char)(x))
|
|
# define sqlite3Isdigit(x) isdigit((unsigned char)(x))
|
|
# define sqlite3Isxdigit(x) isxdigit((unsigned char)(x))
|
|
# define sqlite3Tolower(x) tolower((unsigned char)(x))
|
|
#endif
|
|
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
|
|
int sqlite3IsIdChar(u8);
|
|
#endif
|
|
|
|
/*
|
|
** Internal function prototypes
|
|
*/
|
|
#define sqlite3StrICmp sqlite3_stricmp
|
|
int sqlite3Strlen30(const char*);
|
|
#define sqlite3StrNICmp sqlite3_strnicmp
|
|
|
|
int sqlite3MallocInit(void);
|
|
void sqlite3MallocEnd(void);
|
|
void *sqlite3Malloc(u64);
|
|
void *sqlite3MallocZero(u64);
|
|
void *sqlite3DbMallocZero(sqlite3*, u64);
|
|
void *sqlite3DbMallocRaw(sqlite3*, u64);
|
|
void *sqlite3DbMallocRawNN(sqlite3*, u64);
|
|
char *sqlite3DbStrDup(sqlite3*,const char*);
|
|
char *sqlite3DbStrNDup(sqlite3*,const char*, u64);
|
|
void *sqlite3Realloc(void*, u64);
|
|
void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);
|
|
void *sqlite3DbRealloc(sqlite3 *, void *, u64);
|
|
void sqlite3DbFree(sqlite3*, void*);
|
|
int sqlite3MallocSize(void*);
|
|
int sqlite3DbMallocSize(sqlite3*, void*);
|
|
void *sqlite3ScratchMalloc(int);
|
|
void sqlite3ScratchFree(void*);
|
|
void *sqlite3PageMalloc(int);
|
|
void sqlite3PageFree(void*);
|
|
void sqlite3MemSetDefault(void);
|
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
|
void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));
|
|
#endif
|
|
int sqlite3HeapNearlyFull(void);
|
|
|
|
/*
|
|
** On systems with ample stack space and that support alloca(), make
|
|
** use of alloca() to obtain space for large automatic objects. By default,
|
|
** obtain space from malloc().
|
|
**
|
|
** The alloca() routine never returns NULL. This will cause code paths
|
|
** that deal with sqlite3StackAlloc() failures to be unreachable.
|
|
*/
|
|
#ifdef SQLITE_USE_ALLOCA
|
|
# define sqlite3StackAllocRaw(D,N) alloca(N)
|
|
# define sqlite3StackAllocZero(D,N) memset(alloca(N), 0, N)
|
|
# define sqlite3StackFree(D,P)
|
|
#else
|
|
# define sqlite3StackAllocRaw(D,N) sqlite3DbMallocRaw(D,N)
|
|
# define sqlite3StackAllocZero(D,N) sqlite3DbMallocZero(D,N)
|
|
# define sqlite3StackFree(D,P) sqlite3DbFree(D,P)
|
|
#endif
|
|
|
|
#ifdef SQLITE_ENABLE_MEMSYS3
|
|
const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);
|
|
#endif
|
|
#ifdef SQLITE_ENABLE_MEMSYS5
|
|
const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
|
|
#endif
|
|
|
|
|
|
#ifndef SQLITE_MUTEX_OMIT
|
|
sqlite3_mutex_methods const *sqlite3DefaultMutex(void);
|
|
sqlite3_mutex_methods const *sqlite3NoopMutex(void);
|
|
sqlite3_mutex *sqlite3MutexAlloc(int);
|
|
int sqlite3MutexInit(void);
|
|
int sqlite3MutexEnd(void);
|
|
#endif
|
|
#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP)
|
|
void sqlite3MemoryBarrier(void);
|
|
#else
|
|
# define sqlite3MemoryBarrier()
|
|
#endif
|
|
|
|
sqlite3_int64 sqlite3StatusValue(int);
|
|
void sqlite3StatusUp(int, int);
|
|
void sqlite3StatusDown(int, int);
|
|
void sqlite3StatusHighwater(int, int);
|
|
|
|
/* Access to mutexes used by sqlite3_status() */
|
|
sqlite3_mutex *sqlite3Pcache1Mutex(void);
|
|
sqlite3_mutex *sqlite3MallocMutex(void);
|
|
|
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
|
int sqlite3IsNaN(double);
|
|
#else
|
|
# define sqlite3IsNaN(X) 0
|
|
#endif
|
|
|
|
/*
|
|
** An instance of the following structure holds information about SQL
|
|
** functions arguments that are the parameters to the printf() function.
|
|
*/
|
|
struct PrintfArguments {
|
|
int nArg; /* Total number of arguments */
|
|
int nUsed; /* Number of arguments used so far */
|
|
sqlite3_value **apArg; /* The argument values */
|
|
};
|
|
|
|
void sqlite3VXPrintf(StrAccum*, const char*, va_list);
|
|
void sqlite3XPrintf(StrAccum*, const char*, ...);
|
|
char *sqlite3MPrintf(sqlite3*,const char*, ...);
|
|
char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
|
|
#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
|
|
void sqlite3DebugPrintf(const char*, ...);
|
|
#endif
|
|
#if defined(SQLITE_TEST)
|
|
void *sqlite3TestTextToPtr(const char*);
|
|
#endif
|
|
|
|
#if defined(SQLITE_DEBUG)
|
|
void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
|
|
void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
|
|
void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
|
|
void sqlite3TreeViewWith(TreeView*, const With*, u8);
|
|
#endif
|
|
|
|
|
|
void sqlite3SetString(char **, sqlite3*, const char*);
|
|
void sqlite3ErrorMsg(Parse*, const char*, ...);
|
|
int sqlite3Dequote(char*);
|
|
void sqlite3TokenInit(Token*,char*);
|
|
int sqlite3KeywordCode(const unsigned char*, int);
|
|
int sqlite3RunParser(Parse*, const char*, char **);
|
|
void sqlite3FinishCoding(Parse*);
|
|
int sqlite3GetTempReg(Parse*);
|
|
void sqlite3ReleaseTempReg(Parse*,int);
|
|
int sqlite3GetTempRange(Parse*,int);
|
|
void sqlite3ReleaseTempRange(Parse*,int,int);
|
|
void sqlite3ClearTempRegCache(Parse*);
|
|
Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);
|
|
Expr *sqlite3Expr(sqlite3*,int,const char*);
|
|
void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);
|
|
Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*);
|
|
Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
|
|
Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);
|
|
void sqlite3ExprAssignVarNumber(Parse*, Expr*);
|
|
void sqlite3ExprDelete(sqlite3*, Expr*);
|
|
ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
|
|
void sqlite3ExprListSetSortOrder(ExprList*,int);
|
|
void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
|
|
void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
|
|
void sqlite3ExprListDelete(sqlite3*, ExprList*);
|
|
u32 sqlite3ExprListFlags(const ExprList*);
|
|
int sqlite3Init(sqlite3*, char**);
|
|
int sqlite3InitCallback(void*, int, char**, char**);
|
|
void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
|
|
void sqlite3ResetAllSchemasOfConnection(sqlite3*);
|
|
void sqlite3ResetOneSchema(sqlite3*,int);
|
|
void sqlite3CollapseDatabaseArray(sqlite3*);
|
|
void sqlite3CommitInternalChanges(sqlite3*);
|
|
void sqlite3DeleteColumnNames(sqlite3*,Table*);
|
|
int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
|
|
Table *sqlite3ResultSetOfSelect(Parse*,Select*);
|
|
void sqlite3OpenMasterTable(Parse *, int);
|
|
Index *sqlite3PrimaryKeyIndex(Table*);
|
|
i16 sqlite3ColumnOfIndex(Index*, i16);
|
|
void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
|
|
#if SQLITE_ENABLE_HIDDEN_COLUMNS
|
|
void sqlite3ColumnPropertiesFromName(Table*, Column*);
|
|
#else
|
|
# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
|
|
#endif
|
|
void sqlite3AddColumn(Parse*,Token*);
|
|
void sqlite3AddNotNull(Parse*, int);
|
|
void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
|
|
void sqlite3AddCheckConstraint(Parse*, Expr*);
|
|
void sqlite3AddColumnType(Parse*,Token*);
|
|
void sqlite3AddDefaultValue(Parse*,ExprSpan*);
|
|
void sqlite3AddCollateType(Parse*, Token*);
|
|
void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
|
|
int sqlite3ParseUri(const char*,const char*,unsigned int*,
|
|
sqlite3_vfs**,char**,char **);
|
|
Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
|
|
int sqlite3CodeOnce(Parse *);
|
|
|
|
#ifdef SQLITE_OMIT_BUILTIN_TEST
|
|
# define sqlite3FaultSim(X) SQLITE_OK
|
|
#else
|
|
int sqlite3FaultSim(int);
|
|
#endif
|
|
|
|
Bitvec *sqlite3BitvecCreate(u32);
|
|
int sqlite3BitvecTest(Bitvec*, u32);
|
|
int sqlite3BitvecTestNotNull(Bitvec*, u32);
|
|
int sqlite3BitvecSet(Bitvec*, u32);
|
|
void sqlite3BitvecClear(Bitvec*, u32, void*);
|
|
void sqlite3BitvecDestroy(Bitvec*);
|
|
u32 sqlite3BitvecSize(Bitvec*);
|
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
|
int sqlite3BitvecBuiltinTest(int,int*);
|
|
#endif
|
|
|
|
RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);
|
|
void sqlite3RowSetClear(RowSet*);
|
|
void sqlite3RowSetInsert(RowSet*, i64);
|
|
int sqlite3RowSetTest(RowSet*, int iBatch, i64);
|
|
int sqlite3RowSetNext(RowSet*, i64*);
|
|
|
|
void sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int);
|
|
|
|
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
|
|
int sqlite3ViewGetColumnNames(Parse*,Table*);
|
|
#else
|
|
# define sqlite3ViewGetColumnNames(A,B) 0
|
|
#endif
|
|
|
|
#if SQLITE_MAX_ATTACHED>30
|
|
int sqlite3DbMaskAllZero(yDbMask);
|
|
#endif
|
|
void sqlite3DropTable(Parse*, SrcList*, int, int);
|
|
void sqlite3CodeDropTable(Parse*, Table*, int, int);
|
|
void sqlite3DeleteTable(sqlite3*, Table*);
|
|
#ifndef SQLITE_OMIT_AUTOINCREMENT
|
|
void sqlite3AutoincrementBegin(Parse *pParse);
|
|
void sqlite3AutoincrementEnd(Parse *pParse);
|
|
#else
|
|
# define sqlite3AutoincrementBegin(X)
|
|
# define sqlite3AutoincrementEnd(X)
|
|
#endif
|
|
void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int);
|
|
void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
|
|
IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);
|
|
int sqlite3IdListIndex(IdList*,const char*);
|
|
SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
|
|
SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
|
|
#ifdef MAXSCALE
|
|
SrcList* sqlite3SrcListCat(sqlite3*, SrcList*, SrcList*);
|
|
#endif
|
|
SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
|
|
Token*, Select*, Expr*, IdList*);
|
|
void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);
|
|
void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*);
|
|
int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);
|
|
void sqlite3SrcListShiftJoinType(SrcList*);
|
|
void sqlite3SrcListAssignCursors(Parse*, SrcList*);
|
|
void sqlite3IdListDelete(sqlite3*, IdList*);
|
|
void sqlite3SrcListDelete(sqlite3*, SrcList*);
|
|
Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);
|
|
Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
|
|
Expr*, int, int);
|
|
void sqlite3DropIndex(Parse*, SrcList*, int);
|
|
int sqlite3Select(Parse*, Select*, SelectDest*);
|
|
#ifdef MAXSCALE
|
|
Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
|
|
Expr*,ExprList*,u16,Expr*,Expr*,ExprList*);
|
|
#else
|
|
Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
|
|
Expr*,ExprList*,u16,Expr*,Expr*);
|
|
#endif
|
|
void sqlite3SelectDelete(sqlite3*, Select*);
|
|
Table *sqlite3SrcListLookup(Parse*, SrcList*);
|
|
int sqlite3IsReadOnly(Parse*, Table*, int);
|
|
void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
|
|
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
|
|
Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,Expr*,char*);
|
|
#endif
|
|
void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
|
|
void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
|
|
WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
|
|
void sqlite3WhereEnd(WhereInfo*);
|
|
u64 sqlite3WhereOutputRowCount(WhereInfo*);
|
|
int sqlite3WhereIsDistinct(WhereInfo*);
|
|
int sqlite3WhereIsOrdered(WhereInfo*);
|
|
int sqlite3WhereIsSorted(WhereInfo*);
|
|
int sqlite3WhereContinueLabel(WhereInfo*);
|
|
int sqlite3WhereBreakLabel(WhereInfo*);
|
|
int sqlite3WhereOkOnePass(WhereInfo*, int*);
|
|
#define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
|
|
#define ONEPASS_SINGLE 1 /* ONEPASS valid for a single row update */
|
|
#define ONEPASS_MULTI 2 /* ONEPASS is valid for multiple rows */
|
|
void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
|
|
int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
|
|
void sqlite3ExprCodeGetColumnToReg(Parse*, Table*, int, int, int);
|
|
void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
|
|
void sqlite3ExprCodeMove(Parse*, int, int, int);
|
|
void sqlite3ExprCacheStore(Parse*, int, int, int);
|
|
void sqlite3ExprCachePush(Parse*);
|
|
void sqlite3ExprCachePop(Parse*);
|
|
void sqlite3ExprCacheRemove(Parse*, int, int);
|
|
void sqlite3ExprCacheClear(Parse*);
|
|
void sqlite3ExprCacheAffinityChange(Parse*, int, int);
|
|
void sqlite3ExprCode(Parse*, Expr*, int);
|
|
void sqlite3ExprCodeCopy(Parse*, Expr*, int);
|
|
void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
|
|
void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8);
|
|
int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
|
|
int sqlite3ExprCodeTarget(Parse*, Expr*, int);
|
|
void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
|
|
int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
|
|
#define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */
|
|
#define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */
|
|
#define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
|
|
void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
|
|
void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
|
|
void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
|
|
Table *sqlite3FindTable(sqlite3*,const char*, const char*);
|
|
Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*);
|
|
Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *);
|
|
Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
|
|
void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
|
|
void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
|
|
void sqlite3Vacuum(Parse*);
|
|
int sqlite3RunVacuum(char**, sqlite3*);
|
|
char *sqlite3NameFromToken(sqlite3*, Token*);
|
|
int sqlite3ExprCompare(Expr*, Expr*, int);
|
|
int sqlite3ExprListCompare(ExprList*, ExprList*, int);
|
|
int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
|
|
void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
|
|
void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
|
|
int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
|
|
Vdbe *sqlite3GetVdbe(Parse*);
|
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
|
void sqlite3PrngSaveState(void);
|
|
void sqlite3PrngRestoreState(void);
|
|
#endif
|
|
void sqlite3RollbackAll(sqlite3*,int);
|
|
void sqlite3CodeVerifySchema(Parse*, int);
|
|
void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
|
|
void sqlite3BeginTransaction(Parse*, int);
|
|
void sqlite3CommitTransaction(Parse*);
|
|
void sqlite3RollbackTransaction(Parse*);
|
|
void sqlite3Savepoint(Parse*, int, Token*);
|
|
void sqlite3CloseSavepoints(sqlite3 *);
|
|
void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
|
|
int sqlite3ExprIsConstant(Expr*);
|
|
int sqlite3ExprIsConstantNotJoin(Expr*);
|
|
int sqlite3ExprIsConstantOrFunction(Expr*, u8);
|
|
int sqlite3ExprIsTableConstant(Expr*,int);
|
|
#ifdef SQLITE_ENABLE_CURSOR_HINTS
|
|
int sqlite3ExprContainsSubquery(Expr*);
|
|
#endif
|
|
int sqlite3ExprIsInteger(Expr*, int*);
|
|
int sqlite3ExprCanBeNull(const Expr*);
|
|
int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
|
|
int sqlite3IsRowid(const char*);
|
|
void sqlite3GenerateRowDelete(
|
|
Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
|
|
void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
|
|
int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
|
|
void sqlite3ResolvePartIdxLabel(Parse*,int);
|
|
void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
|
|
u8,u8,int,int*,int*);
|
|
void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
|
|
int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
|
|
void sqlite3BeginWriteOperation(Parse*, int, int);
|
|
void sqlite3MultiWrite(Parse*);
|
|
void sqlite3MayAbort(Parse*);
|
|
void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8);
|
|
void sqlite3UniqueConstraint(Parse*, int, Index*);
|
|
void sqlite3RowidConstraint(Parse*, int, Table*);
|
|
Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
|
|
ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
|
|
SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
|
|
IdList *sqlite3IdListDup(sqlite3*,IdList*);
|
|
Select *sqlite3SelectDup(sqlite3*,Select*,int);
|
|
#if SELECTTRACE_ENABLED
|
|
void sqlite3SelectSetName(Select*,const char*);
|
|
#else
|
|
# define sqlite3SelectSetName(A,B)
|
|
#endif
|
|
void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*);
|
|
FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,u8);
|
|
void sqlite3RegisterBuiltinFunctions(sqlite3*);
|
|
void sqlite3RegisterDateTimeFunctions(void);
|
|
void sqlite3RegisterGlobalFunctions(void);
|
|
int sqlite3SafetyCheckOk(sqlite3*);
|
|
int sqlite3SafetyCheckSickOrOk(sqlite3*);
|
|
void sqlite3ChangeCookie(Parse*, int);
|
|
|
|
#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
|
|
void sqlite3MaterializeView(Parse*, Table*, Expr*, int);
|
|
#endif
|
|
|
|
#ifndef SQLITE_OMIT_TRIGGER
|
|
void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,
|
|
Expr*,int, int);
|
|
void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);
|
|
void sqlite3DropTrigger(Parse*, SrcList*, int);
|
|
void sqlite3DropTriggerPtr(Parse*, Trigger*);
|
|
Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
|
|
Trigger *sqlite3TriggerList(Parse *, Table *);
|
|
void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
|
|
int, int, int);
|
|
void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
|
|
void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
|
|
void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
|
|
TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
|
|
TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
|
|
Select*,u8);
|
|
TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);
|
|
TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
|
|
void sqlite3DeleteTrigger(sqlite3*, Trigger*);
|
|
void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
|
|
u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
|
|
# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
|
|
# define sqlite3IsToplevel(p) ((p)->pToplevel==0)
|
|
#else
|
|
# define sqlite3TriggersExist(B,C,D,E,F) 0
|
|
# define sqlite3DeleteTrigger(A,B)
|
|
# define sqlite3DropTriggerPtr(A,B)
|
|
# define sqlite3UnlinkAndDeleteTrigger(A,B,C)
|
|
# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)
|
|
# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)
|
|
# define sqlite3TriggerList(X, Y) 0
|
|
# define sqlite3ParseToplevel(p) p
|
|
# define sqlite3IsToplevel(p) 1
|
|
# define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0
|
|
#endif
|
|
|
|
int sqlite3JoinType(Parse*, Token*, Token*, Token*);
|
|
void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
|
|
void sqlite3DeferForeignKey(Parse*, int);
|
|
#ifndef SQLITE_OMIT_AUTHORIZATION
|
|
void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
|
|
int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
|
|
void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);
|
|
void sqlite3AuthContextPop(AuthContext*);
|
|
int sqlite3AuthReadCol(Parse*, const char *, const char *, int);
|
|
#else
|
|
# define sqlite3AuthRead(a,b,c,d)
|
|
# define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK
|
|
# define sqlite3AuthContextPush(a,b,c)
|
|
# define sqlite3AuthContextPop(a) ((void)(a))
|
|
#endif
|
|
void sqlite3Attach(Parse*, Expr*, Expr*, Expr*);
|
|
void sqlite3Detach(Parse*, Expr*);
|
|
void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
|
|
int sqlite3FixSrcList(DbFixer*, SrcList*);
|
|
int sqlite3FixSelect(DbFixer*, Select*);
|
|
int sqlite3FixExpr(DbFixer*, Expr*);
|
|
int sqlite3FixExprList(DbFixer*, ExprList*);
|
|
int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
|
|
int sqlite3AtoF(const char *z, double*, int, u8);
|
|
int sqlite3GetInt32(const char *, int*);
|
|
int sqlite3Atoi(const char*);
|
|
int sqlite3Utf16ByteLen(const void *pData, int nChar);
|
|
int sqlite3Utf8CharLen(const char *pData, int nByte);
|
|
u32 sqlite3Utf8Read(const u8**);
|
|
LogEst sqlite3LogEst(u64);
|
|
LogEst sqlite3LogEstAdd(LogEst,LogEst);
|
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
|
LogEst sqlite3LogEstFromDouble(double);
|
|
#endif
|
|
u64 sqlite3LogEstToInt(LogEst);
|
|
|
|
/*
|
|
** Routines to read and write variable-length integers. These used to
|
|
** be defined locally, but now we use the varint routines in the util.c
|
|
** file.
|
|
*/
|
|
int sqlite3PutVarint(unsigned char*, u64);
|
|
u8 sqlite3GetVarint(const unsigned char *, u64 *);
|
|
u8 sqlite3GetVarint32(const unsigned char *, u32 *);
|
|
int sqlite3VarintLen(u64 v);
|
|
|
|
/*
|
|
** The common case is for a varint to be a single byte. They following
|
|
** macros handle the common case without a procedure call, but then call
|
|
** the procedure for larger varints.
|
|
*/
|
|
#define getVarint32(A,B) \
|
|
(u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))
|
|
#define putVarint32(A,B) \
|
|
(u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\
|
|
sqlite3PutVarint((A),(B)))
|
|
#define getVarint sqlite3GetVarint
|
|
#define putVarint sqlite3PutVarint
|
|
|
|
|
|
const char *sqlite3IndexAffinityStr(sqlite3*, Index*);
|
|
void sqlite3TableAffinity(Vdbe*, Table*, int);
|
|
char sqlite3CompareAffinity(Expr *pExpr, char aff2);
|
|
int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
|
|
char sqlite3ExprAffinity(Expr *pExpr);
|
|
int sqlite3Atoi64(const char*, i64*, int, u8);
|
|
int sqlite3DecOrHexToI64(const char*, i64*);
|
|
void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
|
|
void sqlite3Error(sqlite3*,int);
|
|
void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
|
|
u8 sqlite3HexToInt(int h);
|
|
int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
|
|
|
|
#if defined(SQLITE_NEED_ERR_NAME)
|
|
const char *sqlite3ErrName(int);
|
|
#endif
|
|
|
|
const char *sqlite3ErrStr(int);
|
|
int sqlite3ReadSchema(Parse *pParse);
|
|
CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
|
|
CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
|
|
CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
|
|
Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
|
|
Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
|
|
Expr *sqlite3ExprSkipCollate(Expr*);
|
|
int sqlite3CheckCollSeq(Parse *, CollSeq *);
|
|
int sqlite3CheckObjectName(Parse *, const char *);
|
|
void sqlite3VdbeSetChanges(sqlite3 *, int);
|
|
int sqlite3AddInt64(i64*,i64);
|
|
int sqlite3SubInt64(i64*,i64);
|
|
int sqlite3MulInt64(i64*,i64);
|
|
int sqlite3AbsInt32(int);
|
|
#ifdef SQLITE_ENABLE_8_3_NAMES
|
|
void sqlite3FileSuffix3(const char*, char*);
|
|
#else
|
|
# define sqlite3FileSuffix3(X,Y)
|
|
#endif
|
|
u8 sqlite3GetBoolean(const char *z,u8);
|
|
|
|
const void *sqlite3ValueText(sqlite3_value*, u8);
|
|
int sqlite3ValueBytes(sqlite3_value*, u8);
|
|
void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,
|
|
void(*)(void*));
|
|
void sqlite3ValueSetNull(sqlite3_value*);
|
|
void sqlite3ValueFree(sqlite3_value*);
|
|
sqlite3_value *sqlite3ValueNew(sqlite3 *);
|
|
char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
|
|
int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
|
|
void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
|
|
#ifndef SQLITE_AMALGAMATION
|
|
extern const unsigned char sqlite3OpcodeProperty[];
|
|
extern const char sqlite3StrBINARY[];
|
|
extern const unsigned char sqlite3UpperToLower[];
|
|
extern const unsigned char sqlite3CtypeMap[];
|
|
extern const Token sqlite3IntTokens[];
|
|
extern SQLITE_WSD struct Sqlite3Config sqlite3Config;
|
|
extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
|
|
#ifndef SQLITE_OMIT_WSD
|
|
extern int sqlite3PendingByte;
|
|
#endif
|
|
#endif
|
|
void sqlite3RootPageMoved(sqlite3*, int, int, int);
|
|
void sqlite3Reindex(Parse*, Token*, Token*);
|
|
void sqlite3AlterFunctions(void);
|
|
void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
|
|
#ifdef MAXSCALE
|
|
int sqlite3GetToken(Parse*, const unsigned char *, int *);
|
|
#else
|
|
int sqlite3GetToken(const unsigned char *, int *);
|
|
#endif
|
|
void sqlite3NestedParse(Parse*, const char*, ...);
|
|
void sqlite3ExpirePreparedStatements(sqlite3*);
|
|
int sqlite3CodeSubselect(Parse *, Expr *, int, int);
|
|
void sqlite3SelectPrep(Parse*, Select*, NameContext*);
|
|
void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
|
|
int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
|
|
int sqlite3ResolveExprNames(NameContext*, Expr*);
|
|
int sqlite3ResolveExprListNames(NameContext*, ExprList*);
|
|
void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
|
|
void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
|
|
int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
|
|
void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
|
|
void sqlite3AlterFinishAddColumn(Parse *, Token *);
|
|
void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
|
|
CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
|
|
char sqlite3AffinityType(const char*, u8*);
|
|
void sqlite3Analyze(Parse*, Token*, Token*);
|
|
int sqlite3InvokeBusyHandler(BusyHandler*);
|
|
int sqlite3FindDb(sqlite3*, Token*);
|
|
int sqlite3FindDbName(sqlite3 *, const char *);
|
|
int sqlite3AnalysisLoad(sqlite3*,int iDB);
|
|
void sqlite3DeleteIndexSamples(sqlite3*,Index*);
|
|
void sqlite3DefaultRowEst(Index*);
|
|
void sqlite3RegisterLikeFunctions(sqlite3*, int);
|
|
int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
|
|
void sqlite3SchemaClear(void *);
|
|
Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
|
|
int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
|
|
KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
|
|
void sqlite3KeyInfoUnref(KeyInfo*);
|
|
KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
|
|
KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
|
|
#ifdef SQLITE_DEBUG
|
|
int sqlite3KeyInfoIsWriteable(KeyInfo*);
|
|
#endif
|
|
int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
|
|
void (*)(sqlite3_context*,int,sqlite3_value **),
|
|
void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
|
|
FuncDestructor *pDestructor
|
|
);
|
|
void sqlite3OomFault(sqlite3*);
|
|
void sqlite3OomClear(sqlite3*);
|
|
int sqlite3ApiExit(sqlite3 *db, int);
|
|
int sqlite3OpenTempDatabase(Parse *);
|
|
|
|
void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
|
|
void sqlite3StrAccumAppend(StrAccum*,const char*,int);
|
|
void sqlite3StrAccumAppendAll(StrAccum*,const char*);
|
|
void sqlite3AppendChar(StrAccum*,int,char);
|
|
char *sqlite3StrAccumFinish(StrAccum*);
|
|
void sqlite3StrAccumReset(StrAccum*);
|
|
void sqlite3SelectDestInit(SelectDest*,int,int);
|
|
Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
|
|
|
|
void sqlite3BackupRestart(sqlite3_backup *);
|
|
void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
|
|
|
|
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
|
|
void sqlite3AnalyzeFunctions(void);
|
|
int sqlite3Stat4ProbeSetValue(Parse*,Index*,UnpackedRecord**,Expr*,u8,int,int*);
|
|
int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
|
|
void sqlite3Stat4ProbeFree(UnpackedRecord*);
|
|
int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
|
|
#endif
|
|
|
|
/*
|
|
** The interface to the LEMON-generated parser
|
|
*/
|
|
void *sqlite3ParserAlloc(void*(*)(u64));
|
|
void sqlite3ParserFree(void*, void(*)(void*));
|
|
void sqlite3Parser(void*, int, Token, Parse*);
|
|
#ifdef YYTRACKMAXSTACKDEPTH
|
|
int sqlite3ParserStackPeak(void*);
|
|
#endif
|
|
|
|
void sqlite3AutoLoadExtensions(sqlite3*);
|
|
#ifndef SQLITE_OMIT_LOAD_EXTENSION
|
|
void sqlite3CloseExtensions(sqlite3*);
|
|
#else
|
|
# define sqlite3CloseExtensions(X)
|
|
#endif
|
|
|
|
#ifndef SQLITE_OMIT_SHARED_CACHE
|
|
void sqlite3TableLock(Parse *, int, int, u8, const char *);
|
|
#else
|
|
#define sqlite3TableLock(v,w,x,y,z)
|
|
#endif
|
|
|
|
#ifdef SQLITE_TEST
|
|
int sqlite3Utf8To8(unsigned char*);
|
|
#endif
|
|
|
|
#ifdef SQLITE_OMIT_VIRTUALTABLE
|
|
# define sqlite3VtabClear(Y)
|
|
# define sqlite3VtabSync(X,Y) SQLITE_OK
|
|
# define sqlite3VtabRollback(X)
|
|
# define sqlite3VtabCommit(X)
|
|
# define sqlite3VtabInSync(db) 0
|
|
# define sqlite3VtabLock(X)
|
|
# define sqlite3VtabUnlock(X)
|
|
# define sqlite3VtabUnlockList(X)
|
|
# define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK
|
|
# define sqlite3GetVTable(X,Y) ((VTable*)0)
|
|
#else
|
|
void sqlite3VtabClear(sqlite3 *db, Table*);
|
|
void sqlite3VtabDisconnect(sqlite3 *db, Table *p);
|
|
int sqlite3VtabSync(sqlite3 *db, Vdbe*);
|
|
int sqlite3VtabRollback(sqlite3 *db);
|
|
int sqlite3VtabCommit(sqlite3 *db);
|
|
void sqlite3VtabLock(VTable *);
|
|
void sqlite3VtabUnlock(VTable *);
|
|
void sqlite3VtabUnlockList(sqlite3*);
|
|
int sqlite3VtabSavepoint(sqlite3 *, int, int);
|
|
void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);
|
|
VTable *sqlite3GetVTable(sqlite3*, Table*);
|
|
# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
|
|
#endif
|
|
int sqlite3VtabEponymousTableInit(Parse*,Module*);
|
|
void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
|
|
void sqlite3VtabMakeWritable(Parse*,Table*);
|
|
void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
|
|
void sqlite3VtabFinishParse(Parse*, Token*);
|
|
void sqlite3VtabArgInit(Parse*);
|
|
void sqlite3VtabArgExtend(Parse*, Token*);
|
|
int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
|
|
int sqlite3VtabCallConnect(Parse*, Table*);
|
|
int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
|
|
int sqlite3VtabBegin(sqlite3 *, VTable *);
|
|
FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
|
|
void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);
|
|
sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
|
|
int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
|
|
int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
|
|
void sqlite3ParserReset(Parse*);
|
|
int sqlite3Reprepare(Vdbe*);
|
|
void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
|
|
CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
|
|
int sqlite3TempInMemory(const sqlite3*);
|
|
const char *sqlite3JournalModename(int);
|
|
#ifndef SQLITE_OMIT_WAL
|
|
int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
|
|
int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);
|
|
#endif
|
|
#ifndef SQLITE_OMIT_CTE
|
|
With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*);
|
|
void sqlite3WithDelete(sqlite3*,With*);
|
|
void sqlite3WithPush(Parse*, With*, u8);
|
|
#else
|
|
#define sqlite3WithPush(x,y,z)
|
|
#define sqlite3WithDelete(x,y)
|
|
#endif
|
|
|
|
/* Declarations for functions in fkey.c. All of these are replaced by
|
|
** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
|
|
** key functionality is available. If OMIT_TRIGGER is defined but
|
|
** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
|
|
** this case foreign keys are parsed, but no other functionality is
|
|
** provided (enforcement of FK constraints requires the triggers sub-system).
|
|
*/
|
|
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
|
|
void sqlite3FkCheck(Parse*, Table*, int, int, int*, int);
|
|
void sqlite3FkDropTable(Parse*, SrcList *, Table*);
|
|
void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int);
|
|
int sqlite3FkRequired(Parse*, Table*, int*, int);
|
|
u32 sqlite3FkOldmask(Parse*, Table*);
|
|
FKey *sqlite3FkReferences(Table *);
|
|
#else
|
|
#define sqlite3FkActions(a,b,c,d,e,f)
|
|
#define sqlite3FkCheck(a,b,c,d,e,f)
|
|
#define sqlite3FkDropTable(a,b,c)
|
|
#define sqlite3FkOldmask(a,b) 0
|
|
#define sqlite3FkRequired(a,b,c,d) 0
|
|
#endif
|
|
#ifndef SQLITE_OMIT_FOREIGN_KEY
|
|
void sqlite3FkDelete(sqlite3 *, Table*);
|
|
int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
|
|
#else
|
|
#define sqlite3FkDelete(a,b)
|
|
#define sqlite3FkLocateIndex(a,b,c,d,e)
|
|
#endif
|
|
|
|
|
|
/*
|
|
** Available fault injectors. Should be numbered beginning with 0.
|
|
*/
|
|
#define SQLITE_FAULTINJECTOR_MALLOC 0
|
|
#define SQLITE_FAULTINJECTOR_COUNT 1
|
|
|
|
/*
|
|
** The interface to the code in fault.c used for identifying "benign"
|
|
** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST
|
|
** is not defined.
|
|
*/
|
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
|
void sqlite3BeginBenignMalloc(void);
|
|
void sqlite3EndBenignMalloc(void);
|
|
#else
|
|
#define sqlite3BeginBenignMalloc()
|
|
#define sqlite3EndBenignMalloc()
|
|
#endif
|
|
|
|
/*
|
|
** Allowed return values from sqlite3FindInIndex()
|
|
*/
|
|
#define IN_INDEX_ROWID 1 /* Search the rowid of the table */
|
|
#define IN_INDEX_EPH 2 /* Search an ephemeral b-tree */
|
|
#define IN_INDEX_INDEX_ASC 3 /* Existing index ASCENDING */
|
|
#define IN_INDEX_INDEX_DESC 4 /* Existing index DESCENDING */
|
|
#define IN_INDEX_NOOP 5 /* No table available. Use comparisons */
|
|
/*
|
|
** Allowed flags for the 3rd parameter to sqlite3FindInIndex().
|
|
*/
|
|
#define IN_INDEX_NOOP_OK 0x0001 /* OK to return IN_INDEX_NOOP */
|
|
#define IN_INDEX_MEMBERSHIP 0x0002 /* IN operator used for membership test */
|
|
#define IN_INDEX_LOOP 0x0004 /* IN operator used as a loop */
|
|
int sqlite3FindInIndex(Parse *, Expr *, u32, int*);
|
|
|
|
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
|
|
int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
|
|
int sqlite3JournalSize(sqlite3_vfs *);
|
|
int sqlite3JournalCreate(sqlite3_file *);
|
|
int sqlite3JournalExists(sqlite3_file *p);
|
|
#else
|
|
#define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile)
|
|
#define sqlite3JournalExists(p) 1
|
|
#endif
|
|
|
|
void sqlite3MemJournalOpen(sqlite3_file *);
|
|
int sqlite3MemJournalSize(void);
|
|
int sqlite3IsMemJournal(sqlite3_file *);
|
|
|
|
void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);
|
|
#if SQLITE_MAX_EXPR_DEPTH>0
|
|
int sqlite3SelectExprHeight(Select *);
|
|
int sqlite3ExprCheckHeight(Parse*, int);
|
|
#else
|
|
#define sqlite3SelectExprHeight(x) 0
|
|
#define sqlite3ExprCheckHeight(x,y)
|
|
#endif
|
|
|
|
u32 sqlite3Get4byte(const u8*);
|
|
void sqlite3Put4byte(u8*, u32);
|
|
|
|
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
|
|
void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *);
|
|
void sqlite3ConnectionUnlocked(sqlite3 *db);
|
|
void sqlite3ConnectionClosed(sqlite3 *db);
|
|
#else
|
|
#define sqlite3ConnectionBlocked(x,y)
|
|
#define sqlite3ConnectionUnlocked(x)
|
|
#define sqlite3ConnectionClosed(x)
|
|
#endif
|
|
|
|
#ifdef SQLITE_DEBUG
|
|
void sqlite3ParserTrace(FILE*, char *);
|
|
#endif
|
|
|
|
/*
|
|
** If the SQLITE_ENABLE IOTRACE exists then the global variable
|
|
** sqlite3IoTrace is a pointer to a printf-like routine used to
|
|
** print I/O tracing messages.
|
|
*/
|
|
#ifdef SQLITE_ENABLE_IOTRACE
|
|
# define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
|
|
void sqlite3VdbeIOTraceSql(Vdbe*);
|
|
SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
|
|
#else
|
|
# define IOTRACE(A)
|
|
# define sqlite3VdbeIOTraceSql(X)
|
|
#endif
|
|
|
|
/*
|
|
** These routines are available for the mem2.c debugging memory allocator
|
|
** only. They are used to verify that different "types" of memory
|
|
** allocations are properly tracked by the system.
|
|
**
|
|
** sqlite3MemdebugSetType() sets the "type" of an allocation to one of
|
|
** the MEMTYPE_* macros defined below. The type must be a bitmask with
|
|
** a single bit set.
|
|
**
|
|
** sqlite3MemdebugHasType() returns true if any of the bits in its second
|
|
** argument match the type set by the previous sqlite3MemdebugSetType().
|
|
** sqlite3MemdebugHasType() is intended for use inside assert() statements.
|
|
**
|
|
** sqlite3MemdebugNoType() returns true if none of the bits in its second
|
|
** argument match the type set by the previous sqlite3MemdebugSetType().
|
|
**
|
|
** Perhaps the most important point is the difference between MEMTYPE_HEAP
|
|
** and MEMTYPE_LOOKASIDE. If an allocation is MEMTYPE_LOOKASIDE, that means
|
|
** it might have been allocated by lookaside, except the allocation was
|
|
** too large or lookaside was already full. It is important to verify
|
|
** that allocations that might have been satisfied by lookaside are not
|
|
** passed back to non-lookaside free() routines. Asserts such as the
|
|
** example above are placed on the non-lookaside free() routines to verify
|
|
** this constraint.
|
|
**
|
|
** All of this is no-op for a production build. It only comes into
|
|
** play when the SQLITE_MEMDEBUG compile-time option is used.
|
|
*/
|
|
#ifdef SQLITE_MEMDEBUG
|
|
void sqlite3MemdebugSetType(void*,u8);
|
|
int sqlite3MemdebugHasType(void*,u8);
|
|
int sqlite3MemdebugNoType(void*,u8);
|
|
#else
|
|
# define sqlite3MemdebugSetType(X,Y) /* no-op */
|
|
# define sqlite3MemdebugHasType(X,Y) 1
|
|
# define sqlite3MemdebugNoType(X,Y) 1
|
|
#endif
|
|
#define MEMTYPE_HEAP 0x01 /* General heap allocations */
|
|
#define MEMTYPE_LOOKASIDE 0x02 /* Heap that might have been lookaside */
|
|
#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */
|
|
#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */
|
|
|
|
/*
|
|
** Threading interface
|
|
*/
|
|
#if SQLITE_MAX_WORKER_THREADS>0
|
|
int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);
|
|
int sqlite3ThreadJoin(SQLiteThread*, void**);
|
|
#endif
|
|
|
|
#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
|
|
int sqlite3DbstatRegister(sqlite3*);
|
|
#endif
|
|
|
|
#ifdef MAXSCALE
|
|
|
|
typedef enum mxs_drop
|
|
{
|
|
MXS_DROP_FUNCTION,
|
|
} mxs_drop_t;
|
|
|
|
typedef struct MxsDrop
|
|
{
|
|
mxs_drop_t what;
|
|
Token token;
|
|
} MxsDrop;
|
|
|
|
typedef enum mxs_set
|
|
{
|
|
MXS_SET_VARIABLES,
|
|
MXS_SET_TRANSACTION
|
|
} mxs_set_t;
|
|
|
|
typedef enum mxs_show
|
|
{
|
|
MXS_SHOW_COLUMNS,
|
|
MXS_SHOW_CREATE_TABLE,
|
|
MXS_SHOW_CREATE_VIEW,
|
|
MXS_SHOW_DATABASES,
|
|
MXS_SHOW_INDEX,
|
|
MXS_SHOW_INDEXES,
|
|
MXS_SHOW_KEYS,
|
|
MXS_SHOW_STATUS,
|
|
MXS_SHOW_TABLE_STATUS,
|
|
MXS_SHOW_TABLES,
|
|
MXS_SHOW_VARIABLES,
|
|
MXS_SHOW_WARNINGS,
|
|
} mxs_show_t;
|
|
|
|
enum mxs_show_data
|
|
{
|
|
MXS_SHOW_COLUMNS_FULL = 1,
|
|
|
|
// NOTE: The following are used both in MXS_SHOW_VARIABLES and MXS_SHOW_STATUS
|
|
MXS_SHOW_VARIABLES_GLOBAL,
|
|
MXS_SHOW_VARIABLES_SESSION,
|
|
MXS_SHOW_VARIABLES_UNSPECIFIED,
|
|
MXS_SHOW_STATUS_MASTER,
|
|
MXS_SHOW_STATUS_SLAVE,
|
|
MXS_SHOW_STATUS_ALL_SLAVES,
|
|
};
|
|
|
|
typedef struct MxsShow
|
|
{
|
|
mxs_show_t what;
|
|
u32 data;
|
|
Token* pName;
|
|
Token* pDatabase;
|
|
} MxsShow;
|
|
|
|
typedef enum mxs_alter
|
|
{
|
|
MXS_ALTER_DISABLE_KEYS,
|
|
MXS_ALTER_ENABLE_KEYS,
|
|
MXS_ALTER_RENAME,
|
|
} mxs_alter_t;
|
|
|
|
typedef enum mxs_lock
|
|
{
|
|
MXS_LOCK_LOCK,
|
|
MXS_LOCK_UNLOCK,
|
|
} mxs_lock_t;
|
|
|
|
typedef enum mxs_handler
|
|
{
|
|
MXS_HANDLER_OPEN,
|
|
MXS_HANDLER_CLOSE
|
|
} mxs_handler_t;
|
|
|
|
#endif /* MAXSCALE */
|
|
|
|
#endif /* _SQLITEINT_H_ */
|