Sources and license file added
This commit is contained in:
470
LICENSE
Normal file
470
LICENSE
Normal file
@@ -0,0 +1,470 @@
|
|||||||
|
MOZILLA PUBLIC LICENSE
|
||||||
|
Version 1.1
|
||||||
|
|
||||||
|
---------------
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
1.0.1. "Commercial Use" means distribution or otherwise making the
|
||||||
|
Covered Code available to a third party.
|
||||||
|
|
||||||
|
1.1. "Contributor" means each entity that creates or contributes to
|
||||||
|
the creation of Modifications.
|
||||||
|
|
||||||
|
1.2. "Contributor Version" means the combination of the Original
|
||||||
|
Code, prior Modifications used by a Contributor, and the Modifications
|
||||||
|
made by that particular Contributor.
|
||||||
|
|
||||||
|
1.3. "Covered Code" means the Original Code or Modifications or the
|
||||||
|
combination of the Original Code and Modifications, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.4. "Electronic Distribution Mechanism" means a mechanism generally
|
||||||
|
accepted in the software development community for the electronic
|
||||||
|
transfer of data.
|
||||||
|
|
||||||
|
1.5. "Executable" means Covered Code in any form other than Source
|
||||||
|
Code.
|
||||||
|
|
||||||
|
1.6. "Initial Developer" means the individual or entity identified
|
||||||
|
as the Initial Developer in the Source Code notice required by Exhibit
|
||||||
|
A.
|
||||||
|
|
||||||
|
1.7. "Larger Work" means a work which combines Covered Code or
|
||||||
|
portions thereof with code not governed by the terms of this License.
|
||||||
|
|
||||||
|
1.8. "License" means this document.
|
||||||
|
|
||||||
|
1.8.1. "Licensable" means having the right to grant, to the maximum
|
||||||
|
extent possible, whether at the time of the initial grant or
|
||||||
|
subsequently acquired, any and all of the rights conveyed herein.
|
||||||
|
|
||||||
|
1.9. "Modifications" means any addition to or deletion from the
|
||||||
|
substance or structure of either the Original Code or any previous
|
||||||
|
Modifications. When Covered Code is released as a series of files, a
|
||||||
|
Modification is:
|
||||||
|
A. Any addition to or deletion from the contents of a file
|
||||||
|
containing Original Code or previous Modifications.
|
||||||
|
|
||||||
|
B. Any new file that contains any part of the Original Code or
|
||||||
|
previous Modifications.
|
||||||
|
|
||||||
|
1.10. "Original Code" means Source Code of computer software code
|
||||||
|
which is described in the Source Code notice required by Exhibit A as
|
||||||
|
Original Code, and which, at the time of its release under this
|
||||||
|
License is not already Covered Code governed by this License.
|
||||||
|
|
||||||
|
1.10.1. "Patent Claims" means any patent claim(s), now owned or
|
||||||
|
hereafter acquired, including without limitation, method, process,
|
||||||
|
and apparatus claims, in any patent Licensable by grantor.
|
||||||
|
|
||||||
|
1.11. "Source Code" means the preferred form of the Covered Code for
|
||||||
|
making modifications to it, including all modules it contains, plus
|
||||||
|
any associated interface definition files, scripts used to control
|
||||||
|
compilation and installation of an Executable, or source code
|
||||||
|
differential comparisons against either the Original Code or another
|
||||||
|
well known, available Covered Code of the Contributor's choice. The
|
||||||
|
Source Code can be in a compressed or archival form, provided the
|
||||||
|
appropriate decompression or de-archiving software is widely available
|
||||||
|
for no charge.
|
||||||
|
|
||||||
|
1.12. "You" (or "Your") means an individual or a legal entity
|
||||||
|
exercising rights under, and complying with all of the terms of, this
|
||||||
|
License or a future version of this License issued under Section 6.1.
|
||||||
|
For legal entities, "You" includes any entity which controls, is
|
||||||
|
controlled by, or is under common control with You. For purposes of
|
||||||
|
this definition, "control" means (a) the power, direct or indirect,
|
||||||
|
to cause the direction or management of such entity, whether by
|
||||||
|
contract or otherwise, or (b) ownership of more than fifty percent
|
||||||
|
(50%) of the outstanding shares or beneficial ownership of such
|
||||||
|
entity.
|
||||||
|
|
||||||
|
2. Source Code License.
|
||||||
|
|
||||||
|
2.1. The Initial Developer Grant.
|
||||||
|
The Initial Developer hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license, subject to third party intellectual property
|
||||||
|
claims:
|
||||||
|
(a) under intellectual property rights (other than patent or
|
||||||
|
trademark) Licensable by Initial Developer to use, reproduce,
|
||||||
|
modify, display, perform, sublicense and distribute the Original
|
||||||
|
Code (or portions thereof) with or without Modifications, and/or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patents Claims infringed by the making, using or
|
||||||
|
selling of Original Code, to make, have made, use, practice,
|
||||||
|
sell, and offer for sale, and/or otherwise dispose of the
|
||||||
|
Original Code (or portions thereof).
|
||||||
|
|
||||||
|
(c) the licenses granted in this Section 2.1(a) and (b) are
|
||||||
|
effective on the date Initial Developer first distributes
|
||||||
|
Original Code under the terms of this License.
|
||||||
|
|
||||||
|
(d) Notwithstanding Section 2.1(b) above, no patent license is
|
||||||
|
granted: 1) for code that You delete from the Original Code; 2)
|
||||||
|
separate from the Original Code; or 3) for infringements caused
|
||||||
|
by: i) the modification of the Original Code or ii) the
|
||||||
|
combination of the Original Code with other software or devices.
|
||||||
|
|
||||||
|
2.2. Contributor Grant.
|
||||||
|
Subject to third party intellectual property claims, each Contributor
|
||||||
|
hereby grants You a world-wide, royalty-free, non-exclusive license
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or
|
||||||
|
trademark) Licensable by Contributor, to use, reproduce, modify,
|
||||||
|
display, perform, sublicense and distribute the Modifications
|
||||||
|
created by such Contributor (or portions thereof) either on an
|
||||||
|
unmodified basis, with other Modifications, as Covered Code
|
||||||
|
and/or as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims infringed by the making, using, or
|
||||||
|
selling of Modifications made by that Contributor either alone
|
||||||
|
and/or in combination with its Contributor Version (or portions
|
||||||
|
of such combination), to make, use, sell, offer for sale, have
|
||||||
|
made, and/or otherwise dispose of: 1) Modifications made by that
|
||||||
|
Contributor (or portions thereof); and 2) the combination of
|
||||||
|
Modifications made by that Contributor with its Contributor
|
||||||
|
Version (or portions of such combination).
|
||||||
|
|
||||||
|
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
|
||||||
|
effective on the date Contributor first makes Commercial Use of
|
||||||
|
the Covered Code.
|
||||||
|
|
||||||
|
(d) Notwithstanding Section 2.2(b) above, no patent license is
|
||||||
|
granted: 1) for any code that Contributor has deleted from the
|
||||||
|
Contributor Version; 2) separate from the Contributor Version;
|
||||||
|
3) for infringements caused by: i) third party modifications of
|
||||||
|
Contributor Version or ii) the combination of Modifications made
|
||||||
|
by that Contributor with other software (except as part of the
|
||||||
|
Contributor Version) or other devices; or 4) under Patent Claims
|
||||||
|
infringed by Covered Code in the absence of Modifications made by
|
||||||
|
that Contributor.
|
||||||
|
|
||||||
|
3. Distribution Obligations.
|
||||||
|
|
||||||
|
3.1. Application of License.
|
||||||
|
The Modifications which You create or to which You contribute are
|
||||||
|
governed by the terms of this License, including without limitation
|
||||||
|
Section 2.2. The Source Code version of Covered Code may be
|
||||||
|
distributed only under the terms of this License or a future version
|
||||||
|
of this License released under Section 6.1, and You must include a
|
||||||
|
copy of this License with every copy of the Source Code You
|
||||||
|
distribute. You may not offer or impose any terms on any Source Code
|
||||||
|
version that alters or restricts the applicable version of this
|
||||||
|
License or the recipients' rights hereunder. However, You may include
|
||||||
|
an additional document offering the additional rights described in
|
||||||
|
Section 3.5.
|
||||||
|
|
||||||
|
3.2. Availability of Source Code.
|
||||||
|
Any Modification which You create or to which You contribute must be
|
||||||
|
made available in Source Code form under the terms of this License
|
||||||
|
either on the same media as an Executable version or via an accepted
|
||||||
|
Electronic Distribution Mechanism to anyone to whom you made an
|
||||||
|
Executable version available; and if made available via Electronic
|
||||||
|
Distribution Mechanism, must remain available for at least twelve (12)
|
||||||
|
months after the date it initially became available, or at least six
|
||||||
|
(6) months after a subsequent version of that particular Modification
|
||||||
|
has been made available to such recipients. You are responsible for
|
||||||
|
ensuring that the Source Code version remains available even if the
|
||||||
|
Electronic Distribution Mechanism is maintained by a third party.
|
||||||
|
|
||||||
|
3.3. Description of Modifications.
|
||||||
|
You must cause all Covered Code to which You contribute to contain a
|
||||||
|
file documenting the changes You made to create that Covered Code and
|
||||||
|
the date of any change. You must include a prominent statement that
|
||||||
|
the Modification is derived, directly or indirectly, from Original
|
||||||
|
Code provided by the Initial Developer and including the name of the
|
||||||
|
Initial Developer in (a) the Source Code, and (b) in any notice in an
|
||||||
|
Executable version or related documentation in which You describe the
|
||||||
|
origin or ownership of the Covered Code.
|
||||||
|
|
||||||
|
3.4. Intellectual Property Matters
|
||||||
|
(a) Third Party Claims.
|
||||||
|
If Contributor has knowledge that a license under a third party's
|
||||||
|
intellectual property rights is required to exercise the rights
|
||||||
|
granted by such Contributor under Sections 2.1 or 2.2,
|
||||||
|
Contributor must include a text file with the Source Code
|
||||||
|
distribution titled "LEGAL" which describes the claim and the
|
||||||
|
party making the claim in sufficient detail that a recipient will
|
||||||
|
know whom to contact. If Contributor obtains such knowledge after
|
||||||
|
the Modification is made available as described in Section 3.2,
|
||||||
|
Contributor shall promptly modify the LEGAL file in all copies
|
||||||
|
Contributor makes available thereafter and shall take other steps
|
||||||
|
(such as notifying appropriate mailing lists or newsgroups)
|
||||||
|
reasonably calculated to inform those who received the Covered
|
||||||
|
Code that new knowledge has been obtained.
|
||||||
|
|
||||||
|
(b) Contributor APIs.
|
||||||
|
If Contributor's Modifications include an application programming
|
||||||
|
interface and Contributor has knowledge of patent licenses which
|
||||||
|
are reasonably necessary to implement that API, Contributor must
|
||||||
|
also include this information in the LEGAL file.
|
||||||
|
|
||||||
|
(c) Representations.
|
||||||
|
Contributor represents that, except as disclosed pursuant to
|
||||||
|
Section 3.4(a) above, Contributor believes that Contributor's
|
||||||
|
Modifications are Contributor's original creation(s) and/or
|
||||||
|
Contributor has sufficient rights to grant the rights conveyed by
|
||||||
|
this License.
|
||||||
|
|
||||||
|
3.5. Required Notices.
|
||||||
|
You must duplicate the notice in Exhibit A in each file of the Source
|
||||||
|
Code. If it is not possible to put such notice in a particular Source
|
||||||
|
Code file due to its structure, then You must include such notice in a
|
||||||
|
location (such as a relevant directory) where a user would be likely
|
||||||
|
to look for such a notice. If You created one or more Modification(s)
|
||||||
|
You may add your name as a Contributor to the notice described in
|
||||||
|
Exhibit A. You must also duplicate this License in any documentation
|
||||||
|
for the Source Code where You describe recipients' rights or ownership
|
||||||
|
rights relating to Covered Code. You may choose to offer, and to
|
||||||
|
charge a fee for, warranty, support, indemnity or liability
|
||||||
|
obligations to one or more recipients of Covered Code. However, You
|
||||||
|
may do so only on Your own behalf, and not on behalf of the Initial
|
||||||
|
Developer or any Contributor. You must make it absolutely clear than
|
||||||
|
any such warranty, support, indemnity or liability obligation is
|
||||||
|
offered by You alone, and You hereby agree to indemnify the Initial
|
||||||
|
Developer and every Contributor for any liability incurred by the
|
||||||
|
Initial Developer or such Contributor as a result of warranty,
|
||||||
|
support, indemnity or liability terms You offer.
|
||||||
|
|
||||||
|
3.6. Distribution of Executable Versions.
|
||||||
|
You may distribute Covered Code in Executable form only if the
|
||||||
|
requirements of Section 3.1-3.5 have been met for that Covered Code,
|
||||||
|
and if You include a notice stating that the Source Code version of
|
||||||
|
the Covered Code is available under the terms of this License,
|
||||||
|
including a description of how and where You have fulfilled the
|
||||||
|
obligations of Section 3.2. The notice must be conspicuously included
|
||||||
|
in any notice in an Executable version, related documentation or
|
||||||
|
collateral in which You describe recipients' rights relating to the
|
||||||
|
Covered Code. You may distribute the Executable version of Covered
|
||||||
|
Code or ownership rights under a license of Your choice, which may
|
||||||
|
contain terms different from this License, provided that You are in
|
||||||
|
compliance with the terms of this License and that the license for the
|
||||||
|
Executable version does not attempt to limit or alter the recipient's
|
||||||
|
rights in the Source Code version from the rights set forth in this
|
||||||
|
License. If You distribute the Executable version under a different
|
||||||
|
license You must make it absolutely clear that any terms which differ
|
||||||
|
from this License are offered by You alone, not by the Initial
|
||||||
|
Developer or any Contributor. You hereby agree to indemnify the
|
||||||
|
Initial Developer and every Contributor for any liability incurred by
|
||||||
|
the Initial Developer or such Contributor as a result of any such
|
||||||
|
terms You offer.
|
||||||
|
|
||||||
|
3.7. Larger Works.
|
||||||
|
You may create a Larger Work by combining Covered Code with other code
|
||||||
|
not governed by the terms of this License and distribute the Larger
|
||||||
|
Work as a single product. In such a case, You must make sure the
|
||||||
|
requirements of this License are fulfilled for the Covered Code.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation.
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Code due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description
|
||||||
|
must be included in the LEGAL file described in Section 3.4 and must
|
||||||
|
be included with all distributions of the Source Code. Except to the
|
||||||
|
extent prohibited by statute or regulation, such description must be
|
||||||
|
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||||
|
understand it.
|
||||||
|
|
||||||
|
5. Application of this License.
|
||||||
|
|
||||||
|
This License applies to code to which the Initial Developer has
|
||||||
|
attached the notice in Exhibit A and to related Covered Code.
|
||||||
|
|
||||||
|
6. Versions of the License.
|
||||||
|
|
||||||
|
6.1. New Versions.
|
||||||
|
Netscape Communications Corporation ("Netscape") may publish revised
|
||||||
|
and/or new versions of the License from time to time. Each version
|
||||||
|
will be given a distinguishing version number.
|
||||||
|
|
||||||
|
6.2. Effect of New Versions.
|
||||||
|
Once Covered Code has been published under a particular version of the
|
||||||
|
License, You may always continue to use it under the terms of that
|
||||||
|
version. You may also choose to use such Covered Code under the terms
|
||||||
|
of any subsequent version of the License published by Netscape. No one
|
||||||
|
other than Netscape has the right to modify the terms applicable to
|
||||||
|
Covered Code created under this License.
|
||||||
|
|
||||||
|
6.3. Derivative Works.
|
||||||
|
If You create or use a modified version of this License (which you may
|
||||||
|
only do in order to apply it to code which is not already Covered Code
|
||||||
|
governed by this License), You must (a) rename Your license so that
|
||||||
|
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
|
||||||
|
"MPL", "NPL" or any confusingly similar phrase do not appear in your
|
||||||
|
license (except to note that your license differs from this License)
|
||||||
|
and (b) otherwise make it clear that Your version of the license
|
||||||
|
contains terms which differ from the Mozilla Public License and
|
||||||
|
Netscape Public License. (Filling in the name of the Initial
|
||||||
|
Developer, Original Code or Contributor in the notice described in
|
||||||
|
Exhibit A shall not of themselves be deemed to be modifications of
|
||||||
|
this License.)
|
||||||
|
|
||||||
|
7. DISCLAIMER OF WARRANTY.
|
||||||
|
|
||||||
|
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||||
|
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
|
||||||
|
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
|
||||||
|
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
|
||||||
|
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
|
||||||
|
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
|
||||||
|
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
|
||||||
|
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
|
||||||
|
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||||
|
|
||||||
|
8. TERMINATION.
|
||||||
|
|
||||||
|
8.1. This License and the rights granted hereunder will terminate
|
||||||
|
automatically if You fail to comply with terms herein and fail to cure
|
||||||
|
such breach within 30 days of becoming aware of the breach. All
|
||||||
|
sublicenses to the Covered Code which are properly granted shall
|
||||||
|
survive any termination of this License. Provisions which, by their
|
||||||
|
nature, must remain in effect beyond the termination of this License
|
||||||
|
shall survive.
|
||||||
|
|
||||||
|
8.2. If You initiate litigation by asserting a patent infringement
|
||||||
|
claim (excluding declatory judgment actions) against Initial Developer
|
||||||
|
or a Contributor (the Initial Developer or Contributor against whom
|
||||||
|
You file such action is referred to as "Participant") alleging that:
|
||||||
|
|
||||||
|
(a) such Participant's Contributor Version directly or indirectly
|
||||||
|
infringes any patent, then any and all rights granted by such
|
||||||
|
Participant to You under Sections 2.1 and/or 2.2 of this License
|
||||||
|
shall, upon 60 days notice from Participant terminate prospectively,
|
||||||
|
unless if within 60 days after receipt of notice You either: (i)
|
||||||
|
agree in writing to pay Participant a mutually agreeable reasonable
|
||||||
|
royalty for Your past and future use of Modifications made by such
|
||||||
|
Participant, or (ii) withdraw Your litigation claim with respect to
|
||||||
|
the Contributor Version against such Participant. If within 60 days
|
||||||
|
of notice, a reasonable royalty and payment arrangement are not
|
||||||
|
mutually agreed upon in writing by the parties or the litigation claim
|
||||||
|
is not withdrawn, the rights granted by Participant to You under
|
||||||
|
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
|
||||||
|
the 60 day notice period specified above.
|
||||||
|
|
||||||
|
(b) any software, hardware, or device, other than such Participant's
|
||||||
|
Contributor Version, directly or indirectly infringes any patent, then
|
||||||
|
any rights granted to You by such Participant under Sections 2.1(b)
|
||||||
|
and 2.2(b) are revoked effective as of the date You first made, used,
|
||||||
|
sold, distributed, or had made, Modifications made by that
|
||||||
|
Participant.
|
||||||
|
|
||||||
|
8.3. If You assert a patent infringement claim against Participant
|
||||||
|
alleging that such Participant's Contributor Version directly or
|
||||||
|
indirectly infringes any patent where such claim is resolved (such as
|
||||||
|
by license or settlement) prior to the initiation of patent
|
||||||
|
infringement litigation, then the reasonable value of the licenses
|
||||||
|
granted by such Participant under Sections 2.1 or 2.2 shall be taken
|
||||||
|
into account in determining the amount or value of any payment or
|
||||||
|
license.
|
||||||
|
|
||||||
|
8.4. In the event of termination under Sections 8.1 or 8.2 above,
|
||||||
|
all end user license agreements (excluding distributors and resellers)
|
||||||
|
which have been validly granted by You or any distributor hereunder
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
9. LIMITATION OF LIABILITY.
|
||||||
|
|
||||||
|
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
|
||||||
|
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
|
||||||
|
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
|
||||||
|
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
|
||||||
|
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
|
||||||
|
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
|
||||||
|
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
|
||||||
|
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
|
||||||
|
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
|
||||||
|
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
|
||||||
|
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
|
||||||
|
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
|
||||||
|
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
|
||||||
|
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||||
|
|
||||||
|
10. U.S. GOVERNMENT END USERS.
|
||||||
|
|
||||||
|
The Covered Code is a "commercial item," as that term is defined in
|
||||||
|
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
|
||||||
|
software" and "commercial computer software documentation," as such
|
||||||
|
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
|
||||||
|
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
|
||||||
|
all U.S. Government End Users acquire Covered Code with only those
|
||||||
|
rights set forth herein.
|
||||||
|
|
||||||
|
11. MISCELLANEOUS.
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. This License shall be governed by
|
||||||
|
California law provisions (except to the extent applicable law, if
|
||||||
|
any, provides otherwise), excluding its conflict-of-law provisions.
|
||||||
|
With respect to disputes in which at least one party is a citizen of,
|
||||||
|
or an entity chartered or registered to do business in the United
|
||||||
|
States of America, any litigation relating to this License shall be
|
||||||
|
subject to the jurisdiction of the Federal Courts of the Northern
|
||||||
|
District of California, with venue lying in Santa Clara County,
|
||||||
|
California, with the losing party responsible for costs, including
|
||||||
|
without limitation, court costs and reasonable attorneys' fees and
|
||||||
|
expenses. The application of the United Nations Convention on
|
||||||
|
Contracts for the International Sale of Goods is expressly excluded.
|
||||||
|
Any law or regulation which provides that the language of a contract
|
||||||
|
shall be construed against the drafter shall not apply to this
|
||||||
|
License.
|
||||||
|
|
||||||
|
12. RESPONSIBILITY FOR CLAIMS.
|
||||||
|
|
||||||
|
As between Initial Developer and the Contributors, each party is
|
||||||
|
responsible for claims and damages arising, directly or indirectly,
|
||||||
|
out of its utilization of rights under this License and You agree to
|
||||||
|
work with Initial Developer and Contributors to distribute such
|
||||||
|
responsibility on an equitable basis. Nothing herein is intended or
|
||||||
|
shall be deemed to constitute any admission of liability.
|
||||||
|
|
||||||
|
13. MULTIPLE-LICENSED CODE.
|
||||||
|
|
||||||
|
Initial Developer may designate portions of the Covered Code as
|
||||||
|
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
|
||||||
|
Developer permits you to utilize portions of the Covered Code under
|
||||||
|
Your choice of the NPL or the alternative licenses, if any, specified
|
||||||
|
by the Initial Developer in the file described in Exhibit A.
|
||||||
|
|
||||||
|
EXHIBIT A -Mozilla Public License.
|
||||||
|
|
||||||
|
``The contents of this file are subject to the Mozilla Public License
|
||||||
|
Version 1.1 (the "License"); you may not use this file except in
|
||||||
|
compliance with the License. You may obtain a copy of the License at
|
||||||
|
http://www.mozilla.org/MPL/
|
||||||
|
|
||||||
|
Software distributed under the License is distributed on an "AS IS"
|
||||||
|
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||||
|
License for the specific language governing rights and limitations
|
||||||
|
under the License.
|
||||||
|
|
||||||
|
The Original Code is ______________________________________.
|
||||||
|
|
||||||
|
The Initial Developer of the Original Code is ________________________.
|
||||||
|
Portions created by ______________________ are Copyright (C) ______
|
||||||
|
_______________________. All Rights Reserved.
|
||||||
|
|
||||||
|
Contributor(s): ______________________________________.
|
||||||
|
|
||||||
|
Alternatively, the contents of this file may be used under the terms
|
||||||
|
of the _____ license (the "[___] License"), in which case the
|
||||||
|
provisions of [______] License are applicable instead of those
|
||||||
|
above. If you wish to allow use of your version of this file only
|
||||||
|
under the terms of the [____] License and not to allow others to use
|
||||||
|
your version of this file under the MPL, indicate your decision by
|
||||||
|
deleting the provisions above and replace them with the notice and
|
||||||
|
other provisions required by the [___] License. If you do not delete
|
||||||
|
the provisions above, a recipient may use your version of this file
|
||||||
|
under either the MPL or the [___] License."
|
||||||
|
|
||||||
|
[NOTE: The text of this Exhibit A may differ slightly from the text of
|
||||||
|
the notices in the Source Code files of the Original Code. You should
|
||||||
|
use the text of this Exhibit A rather than the text found in the
|
||||||
|
Original Code Source Code for Your Modifications.]
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@ SQLite for Delphi and FreePascal/Lazarus
|
|||||||
This package contains complete SQLite3 API translation for Delphi and FreePascal, as well as a
|
This package contains complete SQLite3 API translation for Delphi and FreePascal, as well as a
|
||||||
simple Unicode-enabled object wrapper to simplify the use of this database engine.
|
simple Unicode-enabled object wrapper to simplify the use of this database engine.
|
||||||
|
|
||||||
Compatible with Delphi/C++Builder 6–XE2 and FreePascal/Lazarus.
|
Compatible with Delphi/C++Builder 6–XE3 and FreePascal/Lazarus.
|
||||||
|
|
||||||
SQLite
|
SQLite
|
||||||
------
|
------
|
||||||
|
|||||||
877
Source/SQLite3.pas
Normal file
877
Source/SQLite3.pas
Normal file
@@ -0,0 +1,877 @@
|
|||||||
|
{
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
Complete SQLite3 API translation and simple wrapper for Delphi and FreePascal
|
||||||
|
Copyright © 2010 IndaSoftware Inc. and contributors. All rights reserved.
|
||||||
|
http://www.indasoftware.com/fordev/sqlite3/
|
||||||
|
|
||||||
|
SQLite is a software library that implements a self-contained, serverless,
|
||||||
|
zero-configuration, transactional SQL database engine. The source code for
|
||||||
|
SQLite is in the public domain and is thus free for use for any purpose,
|
||||||
|
commercial or private. SQLite is the most widely deployed SQL database engine
|
||||||
|
in the world.
|
||||||
|
|
||||||
|
This package contains complete SQLite3 API translation for Delphi and
|
||||||
|
FreePascal, as well as a simple Unicode-enabled object wrapper to simplify
|
||||||
|
the use of this database engine.
|
||||||
|
|
||||||
|
The contents of this file are used with permission, subject to the Mozilla
|
||||||
|
Public License Version 1.1 (the "License"); you may not use this file except
|
||||||
|
in compliance with the License. You may obtain a copy of the License at
|
||||||
|
http://www.mozilla.org/MPL/MPL-1.1.html
|
||||||
|
|
||||||
|
Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||||
|
the specific language governing rights and limitations under the License.
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SQLite3 API translation
|
||||||
|
Version of SQLite: 3.6.22
|
||||||
|
}
|
||||||
|
unit SQLite3;
|
||||||
|
|
||||||
|
{ $DEFINE SQLITE_DEPRECATED} // Enable deprecated functions
|
||||||
|
{ $DEFINE SQLITE_EXPERIMENTAL} // Enable experimental functions
|
||||||
|
|
||||||
|
{$DEFINE SQLITE_ENABLE_COLUMN_METADATA} // Enable functions to work with
|
||||||
|
// column metadata:
|
||||||
|
// table name, DB name, etc.
|
||||||
|
|
||||||
|
{$DEFINE SQLITE_ENABLE_UNLOCK_NOTIFY} // Enable sqlite3_unlock_notify()
|
||||||
|
// function to receive DB unlock
|
||||||
|
// notification
|
||||||
|
|
||||||
|
{ $DEFINE SQLITE_DEBUG} // Enable sqlite3_mutex_held() and
|
||||||
|
// sqlite3_mutex_notheld() functions
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
type
|
||||||
|
PPAnsiCharArray = ^TPAnsiCharArray;
|
||||||
|
TPAnsiCharArray = array[0..MaxInt div SizeOf(PAnsiChar) - 1] of PAnsiChar;
|
||||||
|
|
||||||
|
const
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
sqlite3_lib = 'sqlite3.dll';
|
||||||
|
{$ENDIF}
|
||||||
|
{$IFDEF UNIX}
|
||||||
|
sqlite3_lib = 'sqlite3.so';
|
||||||
|
{$ENDIF}
|
||||||
|
{$IFDEF DARWIN}
|
||||||
|
sqlite3_lib = 'libsqlite3.dylib';
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
//var sqlite3_version: PAnsiChar;
|
||||||
|
function sqlite3_libversion: PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_sourceid: PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_libversion_number: Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_threadsafe: Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3 = type Pointer;
|
||||||
|
|
||||||
|
function sqlite3_close(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3Callback = function(pArg: Pointer; nCol: Integer; argv: PPAnsiCharArray; colv: PPAnsiCharArray): Integer; cdecl;
|
||||||
|
|
||||||
|
function sqlite3_exec(db: PSQLite3; const sql: PAnsiChar; callback: TSQLite3Callback; pArg: Pointer; errmsg: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_OK = 0;
|
||||||
|
SQLITE_ERROR = 1;
|
||||||
|
SQLITE_INTERNAL = 2;
|
||||||
|
SQLITE_PERM = 3;
|
||||||
|
SQLITE_ABORT = 4;
|
||||||
|
SQLITE_BUSY = 5;
|
||||||
|
SQLITE_LOCKED = 6;
|
||||||
|
SQLITE_NOMEM = 7;
|
||||||
|
SQLITE_READONLY = 8;
|
||||||
|
SQLITE_INTERRUPT = 9;
|
||||||
|
SQLITE_IOERR = 10;
|
||||||
|
SQLITE_CORRUPT = 11;
|
||||||
|
SQLITE_NOTFOUND = 12;
|
||||||
|
SQLITE_FULL = 13;
|
||||||
|
SQLITE_CANTOPEN = 14;
|
||||||
|
SQLITE_PROTOCOL = 15;
|
||||||
|
SQLITE_EMPTY = 16;
|
||||||
|
SQLITE_SCHEMA = 17;
|
||||||
|
SQLITE_TOOBIG = 18;
|
||||||
|
SQLITE_CONSTRAINT = 19;
|
||||||
|
SQLITE_MISMATCH = 20;
|
||||||
|
SQLITE_MISUSE = 21;
|
||||||
|
SQLITE_NOLFS = 22;
|
||||||
|
SQLITE_AUTH = 23;
|
||||||
|
SQLITE_FORMAT = 24;
|
||||||
|
SQLITE_RANGE = 25;
|
||||||
|
SQLITE_NOTADB = 26;
|
||||||
|
SQLITE_ROW = 100;
|
||||||
|
SQLITE_DONE = 101;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_IOERR_READ = SQLITE_IOERR or (1 shl 8);
|
||||||
|
SQLITE_IOERR_SHORT_READ = SQLITE_IOERR or (2 shl 8);
|
||||||
|
SQLITE_IOERR_WRITE = SQLITE_IOERR or (3 shl 8);
|
||||||
|
SQLITE_IOERR_FSYNC = SQLITE_IOERR or (4 shl 8);
|
||||||
|
SQLITE_IOERR_DIR_FSYNC = SQLITE_IOERR or (5 shl 8);
|
||||||
|
SQLITE_IOERR_TRUNCATE = SQLITE_IOERR or (6 shl 8);
|
||||||
|
SQLITE_IOERR_FSTAT = SQLITE_IOERR or (7 shl 8);
|
||||||
|
SQLITE_IOERR_UNLOCK = SQLITE_IOERR or (8 shl 8);
|
||||||
|
SQLITE_IOERR_RDLOCK = SQLITE_IOERR or (9 shl 8);
|
||||||
|
SQLITE_IOERR_DELETE = SQLITE_IOERR or (10 shl 8);
|
||||||
|
SQLITE_IOERR_BLOCKED = SQLITE_IOERR or (11 shl 8);
|
||||||
|
SQLITE_IOERR_NOMEM = SQLITE_IOERR or (12 shl 8);
|
||||||
|
SQLITE_IOERR_ACCESS = SQLITE_IOERR or (13 shl 8);
|
||||||
|
SQLITE_IOERR_CHECKRESERVEDLOCK = SQLITE_IOERR or (14 shl 8);
|
||||||
|
SQLITE_IOERR_LOCK = SQLITE_IOERR or (15 shl 8);
|
||||||
|
SQLITE_IOERR_CLOSE = SQLITE_IOERR or (16 shl 8);
|
||||||
|
SQLITE_IOERR_DIR_CLOSE = SQLITE_IOERR or (17 shl 8);
|
||||||
|
SQLITE_LOCKED_SHAREDCACHE = SQLITE_LOCKED or (1 shl 8);
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_OPEN_READONLY = $00000001;
|
||||||
|
SQLITE_OPEN_READWRITE = $00000002;
|
||||||
|
SQLITE_OPEN_CREATE = $00000004;
|
||||||
|
SQLITE_OPEN_DELETEONCLOSE = $00000008;
|
||||||
|
SQLITE_OPEN_EXCLUSIVE = $00000010;
|
||||||
|
SQLITE_OPEN_MAIN_DB = $00000100;
|
||||||
|
SQLITE_OPEN_TEMP_DB = $00000200;
|
||||||
|
SQLITE_OPEN_TRANSIENT_DB = $00000400;
|
||||||
|
SQLITE_OPEN_MAIN_JOURNAL = $00000800;
|
||||||
|
SQLITE_OPEN_TEMP_JOURNAL = $00001000;
|
||||||
|
SQLITE_OPEN_SUBJOURNAL = $00002000;
|
||||||
|
SQLITE_OPEN_MASTER_JOURNAL = $00004000;
|
||||||
|
SQLITE_OPEN_NOMUTEX = $00008000;
|
||||||
|
SQLITE_OPEN_FULLMUTEX = $00010000;
|
||||||
|
SQLITE_OPEN_SHAREDCACHE = $00020000;
|
||||||
|
SQLITE_OPEN_PRIVATECACHE = $00040000;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_IOCAP_ATOMIC = $00000001;
|
||||||
|
SQLITE_IOCAP_ATOMIC512 = $00000002;
|
||||||
|
SQLITE_IOCAP_ATOMIC1K = $00000004;
|
||||||
|
SQLITE_IOCAP_ATOMIC2K = $00000008;
|
||||||
|
SQLITE_IOCAP_ATOMIC4K = $00000010;
|
||||||
|
SQLITE_IOCAP_ATOMIC8K = $00000020;
|
||||||
|
SQLITE_IOCAP_ATOMIC16K = $00000040;
|
||||||
|
SQLITE_IOCAP_ATOMIC32K = $00000080;
|
||||||
|
SQLITE_IOCAP_ATOMIC64K = $00000100;
|
||||||
|
SQLITE_IOCAP_SAFE_APPEND = $00000200;
|
||||||
|
SQLITE_IOCAP_SEQUENTIAL = $00000400;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_LOCK_NONE = 0;
|
||||||
|
SQLITE_LOCK_SHARED = 1;
|
||||||
|
SQLITE_LOCK_RESERVED = 2;
|
||||||
|
SQLITE_LOCK_PENDING = 3;
|
||||||
|
SQLITE_LOCK_EXCLUSIVE = 4;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_SYNC_NORMAL = $00002;
|
||||||
|
SQLITE_SYNC_FULL = $00003;
|
||||||
|
SQLITE_SYNC_DATAONLY = $00010;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3File = ^TSQLite3File;
|
||||||
|
PSQLite3IOMethods = ^TSQLite3IOMethods;
|
||||||
|
|
||||||
|
sqlite3_file = record
|
||||||
|
pMethods: PSQLite3IOMethods;
|
||||||
|
end;
|
||||||
|
TSQLite3File = sqlite3_file;
|
||||||
|
|
||||||
|
sqlite3_io_methods = record
|
||||||
|
iVersion: Integer;
|
||||||
|
xClose: function(id: PSQLite3File): Integer; cdecl;
|
||||||
|
xRead: function(id: PSQLite3File; pBuf: Pointer; iAmt: Integer; iOfst: Int64): Integer; cdecl;
|
||||||
|
xWrite: function(id: PSQLite3File; const pBuf: Pointer; iAmt: Integer; iOfst: Int64): Integer; cdecl;
|
||||||
|
xTruncate: function(id: PSQLite3File; size: Int64): Integer; cdecl;
|
||||||
|
xSync: function(id: PSQLite3File; flags: Integer): Integer; cdecl;
|
||||||
|
xFileSize: function(id: PSQLite3File; var pSize: Int64): Integer; cdecl;
|
||||||
|
xLock: function(id: PSQLite3File; locktype: Integer): Integer; cdecl;
|
||||||
|
xUnlock: function(id: PSQLite3File; locktype: Integer): Integer; cdecl;
|
||||||
|
xCheckReservedLock: function(f: PSQLite3File; var pResOut: Integer): Integer; cdecl;
|
||||||
|
xFileControl: function(id: PSQLite3File; op: Integer; pArg: Pointer): Integer; cdecl;
|
||||||
|
xSectorSize: function(id: PSQLite3File): Integer; cdecl;
|
||||||
|
xDeviceCharacteristics: function(id: PSQLite3File): Integer; cdecl;
|
||||||
|
end;
|
||||||
|
TSQLite3IOMethods = sqlite3_io_methods;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_FCNTL_LOCKSTATE = 1;
|
||||||
|
SQLITE_GET_LOCKPROXYFILE = 2;
|
||||||
|
SQLITE_SET_LOCKPROXYFILE = 3;
|
||||||
|
SQLITE_LAST_ERRNO = 4;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3Mutex = type Pointer;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3VFS = ^TSQLite3VFS;
|
||||||
|
sqlite3_vfs = record
|
||||||
|
iVersion: Integer;
|
||||||
|
szOsFile: Integer;
|
||||||
|
mxPathname: Integer;
|
||||||
|
pNext: PSQLite3VFS;
|
||||||
|
zName: PAnsiChar;
|
||||||
|
pAppData: Pointer;
|
||||||
|
xOpen: function(pVfs: PSQLite3VFS; const zName: PAnsiChar; id: PSQLite3File; flags: Integer; pOutFlags: PInteger): Integer; cdecl;
|
||||||
|
xDelete: function(pVfs: PSQLite3VFS; const zName: PAnsiChar; syncDir: Integer): Integer; cdecl;
|
||||||
|
xAccess: function(pVfs: PSQLite3VFS; const zName: PAnsiChar; flags: Integer; var pResOut: Integer): Integer; cdecl;
|
||||||
|
xFullPathname: function(pVfs: PSQLite3VFS; const zName: PAnsiChar; nOut: Integer; zOut: PAnsiChar): Integer; cdecl;
|
||||||
|
xDlOpen: function(pVfs: PSQLite3VFS; const zFilename: PAnsiChar): Pointer; cdecl;
|
||||||
|
xDlError: procedure(pVfs: PSQLite3VFS; nByte: Integer; zErrMsg: PAnsiChar); cdecl;
|
||||||
|
xDlSym: function(pVfs: PSQLite3VFS; pHandle: Pointer; const zSymbol: PAnsiChar): Pointer; cdecl;
|
||||||
|
xDlClose: procedure(pVfs: PSQLite3VFS; pHandle: Pointer); cdecl;
|
||||||
|
xRandomness: function(pVfs: PSQLite3VFS; nByte: Integer; zOut: PAnsiChar): Integer; cdecl;
|
||||||
|
xSleep: function(pVfs: PSQLite3VFS; microseconds: Integer): Integer; cdecl;
|
||||||
|
xCurrentTime: function(pVfs: PSQLite3VFS; var prNow: Double): Integer; cdecl;
|
||||||
|
xGetLastError: function(pVfs: PSQLite3VFS; nBuf: Integer; zBuf: PAnsiChar): Integer; cdecl;
|
||||||
|
end;
|
||||||
|
TSQLite3VFS = sqlite3_vfs;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_ACCESS_EXISTS = 0;
|
||||||
|
SQLITE_ACCESS_READWRITE = 1;
|
||||||
|
SQLITE_ACCESS_READ = 2;
|
||||||
|
|
||||||
|
function sqlite3_initialize: Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_shutdown: Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_os_init: Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_os_end: Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_EXPERIMENTAL}
|
||||||
|
function sqlite3_config(op: Integer{; ...}): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_db_config(db: PSQLite3; op: Integer{; ...}): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
sqlite3_mem_methods = record
|
||||||
|
xMalloc: function(nByte: Integer): Pointer; cdecl;
|
||||||
|
xFree: procedure(pPrior: Pointer); cdecl;
|
||||||
|
xRealloc: function(pPrior: Pointer; nByte: Integer): Pointer; cdecl;
|
||||||
|
xSize: function(pPrior: Pointer): Integer; cdecl;
|
||||||
|
xRoundup: function(n: Integer): Integer; cdecl;
|
||||||
|
xInit: function(NotUsed: Pointer): Integer; cdecl;
|
||||||
|
xShutdown: procedure(NotUsed: Pointer); cdecl;
|
||||||
|
pAppData: Pointer;
|
||||||
|
end;
|
||||||
|
TSQLite3MemMethods = sqlite3_mem_methods;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_CONFIG_SINGLETHREAD = 1;
|
||||||
|
SQLITE_CONFIG_MULTITHREAD = 2;
|
||||||
|
SQLITE_CONFIG_SERIALIZED = 3;
|
||||||
|
SQLITE_CONFIG_MALLOC = 4;
|
||||||
|
SQLITE_CONFIG_GETMALLOC = 5;
|
||||||
|
SQLITE_CONFIG_SCRATCH = 6;
|
||||||
|
SQLITE_CONFIG_PAGECACHE = 7;
|
||||||
|
SQLITE_CONFIG_HEAP = 8;
|
||||||
|
SQLITE_CONFIG_MEMSTATUS = 9;
|
||||||
|
SQLITE_CONFIG_MUTEX = 10;
|
||||||
|
SQLITE_CONFIG_GETMUTEX = 11;
|
||||||
|
//SQLITE_CONFIG_CHUNKALLOC = 12;
|
||||||
|
SQLITE_CONFIG_LOOKASIDE = 13;
|
||||||
|
SQLITE_CONFIG_PCACHE = 14;
|
||||||
|
SQLITE_CONFIG_GETPCACHE = 15;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_DBCONFIG_LOOKASIDE = 1001;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
function sqlite3_extended_result_codes(db: PSQLite3; onoff: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_last_insert_rowid(db: PSQLite3): Int64; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_changes(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_total_changes(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
procedure sqlite3_interrupt(db: PSQLite3); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_complete(const sql: PAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_complete16(const sql: PWideChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3BusyCallback = function(ptr: Pointer; count: Integer): Integer; cdecl;
|
||||||
|
|
||||||
|
function sqlite3_busy_handler(db: PSQLite3; xBusy: TSQLite3BusyCallback; pArg: Pointer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_busy_timeout(db: PSQLite3; ms: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_get_table(db: PSQLite3; const zSql: PAnsiChar; var pazResult: PPAnsiCharArray; pnRow: PInteger; pnColumn: PInteger; pzErrmsg: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_free_table(result: PPAnsiCharArray); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_mprintf(const zFormat: PAnsiChar{; ...}): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_vmprintf(const zFormat: PAnsiChar; ap: Pointer{va_list}): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_snprintf(n: Integer; zBuf: PAnsiChar; const zFormat: PAnsiChar{; ...}): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_malloc(n: Integer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_realloc(pOld: Pointer; n: Integer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_free(p: Pointer); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_memory_used: Int64; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_memory_highwater(resetFlag: Integer): Int64; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
procedure sqlite3_randomness(N: Integer; P: Pointer); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3AuthorizerCallback = function(pAuthArg: Pointer; code: Integer; const zTab: PAnsiChar; const zCol: PAnsiChar; const zDb: PAnsiChar; const zAuthContext: PAnsiChar): Integer; cdecl;
|
||||||
|
|
||||||
|
function sqlite3_set_authorizer(db: PSQLite3; xAuth: TSQLite3AuthorizerCallback; pUserData: Pointer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_DENY = 1;
|
||||||
|
SQLITE_IGNORE = 2;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_CREATE_INDEX = 1;
|
||||||
|
SQLITE_CREATE_TABLE = 2;
|
||||||
|
SQLITE_CREATE_TEMP_INDEX = 3;
|
||||||
|
SQLITE_CREATE_TEMP_TABLE = 4;
|
||||||
|
SQLITE_CREATE_TEMP_TRIGGER = 5;
|
||||||
|
SQLITE_CREATE_TEMP_VIEW = 6;
|
||||||
|
SQLITE_CREATE_TRIGGER = 7;
|
||||||
|
SQLITE_CREATE_VIEW = 8;
|
||||||
|
SQLITE_DELETE = 9;
|
||||||
|
SQLITE_DROP_INDEX = 10;
|
||||||
|
SQLITE_DROP_TABLE = 11;
|
||||||
|
SQLITE_DROP_TEMP_INDEX = 12;
|
||||||
|
SQLITE_DROP_TEMP_TABLE = 13;
|
||||||
|
SQLITE_DROP_TEMP_TRIGGER = 14;
|
||||||
|
SQLITE_DROP_TEMP_VIEW = 15;
|
||||||
|
SQLITE_DROP_TRIGGER = 16;
|
||||||
|
SQLITE_DROP_VIEW = 17;
|
||||||
|
SQLITE_INSERT = 18;
|
||||||
|
SQLITE_PRAGMA = 19;
|
||||||
|
SQLITE_READ = 20;
|
||||||
|
SQLITE_SELECT = 21;
|
||||||
|
SQLITE_TRANSACTION = 22;
|
||||||
|
SQLITE_UPDATE = 23;
|
||||||
|
SQLITE_ATTACH = 24;
|
||||||
|
SQLITE_DETACH = 25;
|
||||||
|
SQLITE_ALTER_TABLE = 26;
|
||||||
|
SQLITE_REINDEX = 27;
|
||||||
|
SQLITE_ANALYZE = 28;
|
||||||
|
SQLITE_CREATE_VTABLE = 29;
|
||||||
|
SQLITE_DROP_VTABLE = 30;
|
||||||
|
SQLITE_FUNCTION = 31;
|
||||||
|
SQLITE_SAVEPOINT = 32;
|
||||||
|
SQLITE_COPY = 0;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_EXPERIMENTAL}
|
||||||
|
type
|
||||||
|
TSQLite3TraceCallback = procedure(pTraceArg: Pointer; const zTrace: PAnsiChar); cdecl;
|
||||||
|
TSQLite3ProfileCallback = procedure(pProfileArg: Pointer; const zSql: PAnsiChar; elapseTime: UInt64); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_trace(db: PSQLite3; xTrace: TSQLite3TraceCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_profile(db: PSQLite3; xProfile: TSQLite3ProfileCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3ProgressCallback = function(pProgressArg: Pointer): Integer; cdecl;
|
||||||
|
|
||||||
|
procedure sqlite3_progress_handler(db: PSQLite3; nOps: Integer; xProgress: TSQLite3ProgressCallback; pArg: Pointer); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_open(const filename: PAnsiChar; var ppDb: PSQLite3): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_open16(const filename: PWideChar; var ppDb: PSQLite3): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_open_v2(const filename: PAnsiChar; var ppDb: PSQLite3; flags: Integer; const zVfs: PAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_errcode(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_extended_errcode(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_errmsg(db: PSQLite3): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_errmsg16(db: PSQLite3): PWideChar; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3Stmt = type Pointer;
|
||||||
|
|
||||||
|
function sqlite3_limit(db: PSQLite3; limitId: Integer; newLimit: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_LIMIT_LENGTH = 0;
|
||||||
|
SQLITE_LIMIT_SQL_LENGTH = 1;
|
||||||
|
SQLITE_LIMIT_COLUMN = 2;
|
||||||
|
SQLITE_LIMIT_EXPR_DEPTH = 3;
|
||||||
|
SQLITE_LIMIT_COMPOUND_SELECT = 4;
|
||||||
|
SQLITE_LIMIT_VDBE_OP = 5;
|
||||||
|
SQLITE_LIMIT_FUNCTION_ARG = 6;
|
||||||
|
SQLITE_LIMIT_ATTACHED = 7;
|
||||||
|
SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8;
|
||||||
|
SQLITE_LIMIT_VARIABLE_NUMBER = 9;
|
||||||
|
SQLITE_LIMIT_TRIGGER_DEPTH = 10;
|
||||||
|
|
||||||
|
function sqlite3_prepare(db: PSQLite3; const zSql: PAnsiChar; nByte: Integer; var ppStmt: PSQLite3Stmt; const pzTail: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_prepare_v2(db: PSQLite3; const zSql: PAnsiChar; nByte: Integer; var ppStmt: PSQLite3Stmt; const pzTail: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_prepare16(db: PSQLite3; const zSql: PWideChar; nByte: Integer; var ppStmt: PSQLite3Stmt; const pzTail: PPWideChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_prepare16_v2(db: PSQLite3; const zSql: PWideChar; nByte: Integer; var ppStmt: PSQLite3Stmt; const pzTail: PPWideChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_sql(pStmt: PSQLite3Stmt): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3Value = ^TSQLite3Value;
|
||||||
|
sqlite3_value = type Pointer;
|
||||||
|
TSQLite3Value = sqlite3_value;
|
||||||
|
|
||||||
|
PPSQLite3ValueArray = ^TPSQLite3ValueArray;
|
||||||
|
TPSQLite3ValueArray = array[0..MaxInt div SizeOf(PSQLite3Value) - 1] of PSQLite3Value;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3Context = type Pointer;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3DestructorType = procedure(p: Pointer); cdecl;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_STATIC = Pointer(0);
|
||||||
|
SQLITE_TRANSIENT = Pointer(-1);
|
||||||
|
|
||||||
|
function sqlite3_bind_blob(pStmt: PSQLite3Stmt; i: Integer; const zData: Pointer; n: Integer; xDel: TSQLite3DestructorType): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_bind_double(pStmt: PSQLite3Stmt; i: Integer; rValue: Double): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_bind_int(p: PSQLite3Stmt; i: Integer; iValue: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_bind_int64(pStmt: PSQLite3Stmt; i: Integer; iValue: Int64): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_bind_null(pStmt: PSQLite3Stmt; i: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_bind_text(pStmt: PSQLite3Stmt; i: Integer; const zData: PAnsiChar; n: Integer; xDel: TSQLite3DestructorType): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_bind_text16(pStmt: PSQLite3Stmt; i: Integer; const zData: PWideChar; nData: Integer; xDel: TSQLite3DestructorType): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_bind_value(pStmt: PSQLite3Stmt; i: Integer; const pValue: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_bind_zeroblob(pStmt: PSQLite3Stmt; i: Integer; n: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_bind_parameter_count(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_bind_parameter_name(pStmt: PSQLite3Stmt; i: Integer): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_bind_parameter_index(pStmt: PSQLite3Stmt; const zName: PAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_clear_bindings(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_column_count(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_column_name(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_name16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_ENABLE_COLUMN_METADATA}
|
||||||
|
function sqlite3_column_database_name(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_database_name16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_table_name(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_table_name16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_origin_name(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_origin_name16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
function sqlite3_column_decltype(pStmt: PSQLite3Stmt; N: Integer): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_decltype16(pStmt: PSQLite3Stmt; N: Integer): PWideChar; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_step(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_data_count(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_INTEGER = 1;
|
||||||
|
SQLITE_FLOAT = 2;
|
||||||
|
SQLITE_BLOB = 4;
|
||||||
|
SQLITE_NULL = 5;
|
||||||
|
SQLITE_TEXT = 3;
|
||||||
|
SQLITE3_TEXT = 3;
|
||||||
|
|
||||||
|
function sqlite3_column_blob(pStmt: PSQLite3Stmt; iCol: Integer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_bytes(pStmt: PSQLite3Stmt; iCol: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_bytes16(pStmt: PSQLite3Stmt; iCol: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_double(pStmt: PSQLite3Stmt; iCol: Integer): Double; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_int(pStmt: PSQLite3Stmt; iCol: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_int64(pStmt: PSQLite3Stmt; iCol: Integer): Int64; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_text(pStmt: PSQLite3Stmt; iCol: Integer): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_text16(pStmt: PSQLite3Stmt; iCol: Integer): PWideChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_type(pStmt: PSQLite3Stmt; iCol: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_column_value(pStmt: PSQLite3Stmt; iCol: Integer): PSQLite3Value; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_finalize(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_reset(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3RegularFunction = procedure(ctx: PSQLite3Context; n: Integer; apVal: PPSQLite3ValueArray); cdecl;
|
||||||
|
TSQLite3AggregateStep = procedure(ctx: PSQLite3Context; n: Integer; apVal: PPSQLite3ValueArray); cdecl;
|
||||||
|
TSQLite3AggregateFinalize = procedure(ctx: PSQLite3Context); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_create_function(db: PSQLite3; const zFunctionName: PAnsiChar; nArg: Integer; eTextRep: Integer; pApp: Pointer; xFunc: TSQLite3RegularFunction; xStep: TSQLite3AggregateStep; xFinal: TSQLite3AggregateFinalize): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_create_function16(db: PSQLite3; const zFunctionName: PWideChar; nArg: Integer; eTextRep: Integer; pApp: Pointer; xFunc: TSQLite3RegularFunction; xStep: TSQLite3AggregateStep; xFinal: TSQLite3AggregateFinalize): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_UTF8 = 1;
|
||||||
|
SQLITE_UTF16LE = 2;
|
||||||
|
SQLITE_UTF16BE = 3;
|
||||||
|
SQLITE_UTF16 = 4;
|
||||||
|
SQLITE_ANY = 5;
|
||||||
|
SQLITE_UTF16_ALIGNED = 8;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_DEPRECATED}
|
||||||
|
type
|
||||||
|
TSQLite3MemoryAlarmCallback = procedure(pArg: Pointer; used: Int64; N: Integer); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_aggregate_count(p: PSQLite3Context): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_expired(pStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_transfer_bindings(pFromStmt: PSQLite3Stmt; pToStmt: PSQLite3Stmt): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_global_recover: Integer; cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_thread_cleanup; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_memory_alarm(xCallback: TSQLite3MemoryAlarmCallback; pArg: Pointer; iThreshold: Int64): Integer; cdecl; external sqlite3_lib;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
function sqlite3_value_blob(pVal: PSQLite3Value): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_bytes(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_bytes16(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_double(pVal: PSQLite3Value): Double; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_int(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_int64(pVal: PSQLite3Value): Int64; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_text(pVal: PSQLite3Value): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_text16(pVal: PSQLite3Value): PWideChar; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_text16le(pVal: PSQLite3Value): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_text16be(pVal: PSQLite3Value): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_type(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_value_numeric_type(pVal: PSQLite3Value): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_aggregate_context(p: PSQLite3Context; nBytes: Integer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_user_data(p: PSQLite3Context): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_context_db_handle(p: PSQLite3Context): PSQLite3; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3AuxDataDestructor = procedure(pAux: Pointer); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_get_auxdata(pCtx: PSQLite3Context; N: Integer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_set_auxdata(pCtx: PSQLite3Context; N: Integer; pAux: Pointer; xDelete: TSQLite3AuxDataDestructor); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
procedure sqlite3_result_blob(pCtx: PSQLite3Context; const z: Pointer; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_double(pCtx: PSQLite3Context; rVal: Double); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_error(pCtx: PSQLite3Context; const z: PAnsiChar; n: Integer); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_error16(pCtx: PSQLite3Context; const z: PWideChar; n: Integer); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_error_toobig(pCtx: PSQLite3Context); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_error_nomem(pCtx: PSQLite3Context); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_error_code(pCtx: PSQLite3Context; errCode: Integer); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_int(pCtx: PSQLite3Context; iVal: Integer); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_int64(pCtx: PSQLite3Context; iVal: Int64); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_null(pCtx: PSQLite3Context); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_text(pCtx: PSQLite3Context; const z: PAnsiChar; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_text16(pCtx: PSQLite3Context; const z: PWideChar; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_text16le(pCtx: PSQLite3Context; const z: Pointer; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_text16be(pCtx: PSQLite3Context; const z: Pointer; n: Integer; xDel: TSQLite3DestructorType); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_value(pCtx: PSQLite3Context; pValue: PSQLite3Value); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_result_zeroblob(pCtx: PSQLite3Context; n: Integer); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3CollationCompare = procedure(pUser: Pointer; n1: Integer; const z1: Pointer; n2: Integer; const z2: Pointer); cdecl;
|
||||||
|
TSQLite3CollationDestructor = procedure(pUser: Pointer); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_create_collation(db: PSQLite3; const zName: PAnsiChar; eTextRep: Integer; pUser: Pointer; xCompare: TSQLite3CollationCompare): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_create_collation_v2(db: PSQLite3; const zName: PAnsiChar; eTextRep: Integer; pUser: Pointer; xCompare: TSQLite3CollationCompare; xDestroy: TSQLite3CollationDestructor): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_create_collation16(db: PSQLite3; const zName: PWideChar; eTextRep: Integer; pUser: Pointer; xCompare: TSQLite3CollationCompare): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3CollationNeededCallback = procedure(pCollNeededArg: Pointer; db: PSQLite3; eTextRep: Integer; const zExternal: PAnsiChar); cdecl;
|
||||||
|
TSQLite3CollationNeededCallback16 = procedure(pCollNeededArg: Pointer; db: PSQLite3; eTextRep: Integer; const zExternal: PWideChar); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_collation_needed(db: PSQLite3; pCollNeededArg: Pointer; xCollNeeded: TSQLite3CollationNeededCallback): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_collation_needed16(db: PSQLite3; pCollNeededArg: Pointer; xCollNeeded16: TSQLite3CollationNeededCallback16): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
//function sqlite3_key(db: PSQLite3; const pKey: Pointer; nKey: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
//function sqlite3_rekey(db: PSQLite3; const pKey: Pointer; nKey: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_sleep(ms: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
//var sqlite3_temp_directory: PAnsiChar;
|
||||||
|
|
||||||
|
function sqlite3_get_autocommit(db: PSQLite3): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_db_handle(pStmt: PSQLite3Stmt): PSQLite3; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_next_stmt(pDb: PSQLite3; pStmt: PSQLite3Stmt): PSQLite3Stmt; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3CommitCallback = function(pCommitArg: Pointer): Integer; cdecl;
|
||||||
|
TSQLite3RollbackCallback = procedure(pRollbackArg: Pointer); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_commit_hook(db: PSQLite3; xCallback: TSQLite3CommitCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_rollback_hook(db: PSQLite3; xCallback: TSQLite3RollbackCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3UpdateCallback = procedure(pUpdateArg: Pointer; op: Integer; const zDb: PAnsiChar; const zTbl: PAnsiChar; iKey: Int64); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_update_hook(db: PSQLite3; xCallback: TSQLite3UpdateCallback; pArg: Pointer): Pointer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_enable_shared_cache(enable: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_release_memory(n: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
procedure sqlite3_soft_heap_limit(n: Integer); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_ENABLE_COLUMN_METADATA}
|
||||||
|
function sqlite3_table_column_metadata(db: PSQLite3; const zDbName: PAnsiChar; const zTableName: PAnsiChar; const zColumnName: PAnsiChar; const pzDataType: PPAnsiChar; const pzCollSeq: PPAnsiChar; pNotNull: PInteger; pPrimaryKey: PInteger; pAutoinc: PInteger): Integer; cdecl; external sqlite3_lib;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
function sqlite3_load_extension(db: PSQLite3; const zFile: PAnsiChar; const zProc: PAnsiChar; pzErrMsg: PPAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_enable_load_extension(db: PSQLite3; onoff: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLiteAutoExtensionEntryPoint = procedure; cdecl;
|
||||||
|
|
||||||
|
function sqlite3_auto_extension(xEntryPoint: TSQLiteAutoExtensionEntryPoint): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
procedure sqlite3_reset_auto_extension; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_EXPERIMENTAL}
|
||||||
|
type
|
||||||
|
TSQLite3FTS3Func = procedure(pContext: PSQLite3Context; argc: Integer; argv: PPSQLite3ValueArray); cdecl;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3VTab = ^TSQLite3VTab;
|
||||||
|
PSQLite3IndexInfo = ^TSQLite3IndexInfo;
|
||||||
|
PSQLite3VTabCursor = ^TSQLite3VTabCursor;
|
||||||
|
PSQLite3Module = ^TSQLite3Module;
|
||||||
|
|
||||||
|
sqlite3_module = record
|
||||||
|
iVersion: Integer;
|
||||||
|
xCreate: function(db: PSQLite3; pAux: Pointer; argc: Integer; const argv: PPAnsiCharArray; var ppVTab: PSQLite3VTab; var pzErr: PAnsiChar): Integer; cdecl;
|
||||||
|
xConnect: function(db: PSQLite3; pAux: Pointer; argc: Integer; const argv: PPAnsiCharArray; var ppVTab: PSQLite3VTab; var pzErr: PAnsiChar): Integer; cdecl;
|
||||||
|
xBestIndex: function(pVTab: PSQLite3VTab; pInfo: PSQLite3IndexInfo): Integer; cdecl;
|
||||||
|
xDisconnect: function(pVTab: PSQLite3VTab): Integer; cdecl;
|
||||||
|
xDestroy: function(pVTab: PSQLite3VTab): Integer; cdecl;
|
||||||
|
xOpen: function(pVTab: PSQLite3VTab; var ppCursor: PSQLite3VTabCursor): Integer; cdecl;
|
||||||
|
xClose: function(pVtabCursor: PSQLite3VTabCursor): Integer; cdecl;
|
||||||
|
xFilter: function(pVtabCursor: PSQLite3VTabCursor; idxNum: Integer; const idxStr: PAnsiChar; argc: Integer; argv: PPSQLite3ValueArray): Integer; cdecl;
|
||||||
|
xNext: function(pVtabCursor: PSQLite3VTabCursor): Integer; cdecl;
|
||||||
|
xEof: function(pVtabCursor: PSQLite3VTabCursor): Integer; cdecl;
|
||||||
|
xColumn: function(pVtabCursor: PSQLite3VTabCursor; sContext: PSQLite3Context; p2: Integer): Integer; cdecl;
|
||||||
|
xRowid: function(pVtabCursor: PSQLite3VTabCursor; var pRowid: Int64): Integer; cdecl;
|
||||||
|
xUpdate: function(pVtab: PSQLite3VTab; nArg: Integer; ppArg: PPSQLite3ValueArray; var pRowid: Int64): Integer; cdecl;
|
||||||
|
xBegin: function(pVTab: PSQLite3VTab): Integer; cdecl;
|
||||||
|
xSync: function(pVTab: PSQLite3VTab): Integer; cdecl;
|
||||||
|
xCommit: function(pVTab: PSQLite3VTab): Integer; cdecl;
|
||||||
|
xRollback: function(pVTab: PSQLite3VTab): Integer; cdecl;
|
||||||
|
xFindFunction: function(pVtab: PSQLite3VTab; nArg: Integer; const zName: PAnsiChar; var pxFunc: TSQLite3FTS3Func; var ppArg: Pointer): Integer; cdecl;
|
||||||
|
xRename: function(pVtab: PSQLite3VTab; const zNew: PAnsiChar): Integer; cdecl;
|
||||||
|
end;
|
||||||
|
TSQLite3Module = sqlite3_module;
|
||||||
|
|
||||||
|
sqlite3_index_constraint = record
|
||||||
|
iColumn: Integer;
|
||||||
|
op: Byte;
|
||||||
|
usable: Byte;
|
||||||
|
iTermOffset: Integer;
|
||||||
|
end;
|
||||||
|
TSQLite3IndexConstraint = sqlite3_index_constraint;
|
||||||
|
|
||||||
|
PSQLite3IndexConstraintArray = ^TSQLite3IndexConstraintArray;
|
||||||
|
TSQLite3IndexConstraintArray = array[0..MaxInt div SizeOf(TSQLite3IndexConstraint) - 1] of TSQLite3IndexConstraint;
|
||||||
|
|
||||||
|
sqlite3_index_orderby = record
|
||||||
|
iColumn: Integer;
|
||||||
|
desc: Byte;
|
||||||
|
end;
|
||||||
|
TSQLite3IndexOrderBy = sqlite3_index_orderby;
|
||||||
|
|
||||||
|
PSQLite3IndexOrderByArray = ^TSQLite3IndexOrderByArray;
|
||||||
|
TSQLite3IndexOrderByArray = array[0..MaxInt div SizeOf(TSQLite3IndexOrderBy) - 1] of TSQLite3IndexOrderBy;
|
||||||
|
|
||||||
|
sqlite3_index_constraint_usage = record
|
||||||
|
argvIndex: Integer;
|
||||||
|
omit: Byte;
|
||||||
|
end;
|
||||||
|
TSQLite3IndexConstraintUsage = sqlite3_index_constraint_usage;
|
||||||
|
|
||||||
|
PSQLite3IndexConstraintUsageArray = ^TSQLite3IndexConstraintUsageArray;
|
||||||
|
TSQLite3IndexConstraintUsageArray = array[0..MaxInt div SizeOf(TSQLite3IndexConstraintUsage) - 1] of TSQLite3IndexConstraintUsage;
|
||||||
|
|
||||||
|
sqlite3_index_info = record
|
||||||
|
nConstraint: Integer;
|
||||||
|
aConstraint: PSQLite3IndexConstraintArray;
|
||||||
|
nOrderBy: Integer;
|
||||||
|
aOrderBy: PSQLite3IndexOrderByArray;
|
||||||
|
aConstraintUsage: PSQLite3IndexConstraintUsageArray;
|
||||||
|
idxNum: Integer;
|
||||||
|
idxStr: PAnsiChar;
|
||||||
|
needToFreeIdxStr: Integer;
|
||||||
|
orderByConsumed: Integer;
|
||||||
|
estimatedCost: Double;
|
||||||
|
end;
|
||||||
|
TSQLite3IndexInfo = sqlite3_index_info;
|
||||||
|
|
||||||
|
sqlite3_vtab = record
|
||||||
|
pModule: PSQLite3Module;
|
||||||
|
nRef: Integer;
|
||||||
|
zErrMsg: PAnsiChar;
|
||||||
|
end;
|
||||||
|
TSQLite3VTab = sqlite3_vtab;
|
||||||
|
|
||||||
|
sqlite3_vtab_cursor = record
|
||||||
|
pVtab: PSQLite3VTab;
|
||||||
|
end;
|
||||||
|
TSQLite3VTabCursor = sqlite3_vtab_cursor;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_INDEX_CONSTRAINT_EQ = 2;
|
||||||
|
SQLITE_INDEX_CONSTRAINT_GT = 4;
|
||||||
|
SQLITE_INDEX_CONSTRAINT_LE = 8;
|
||||||
|
SQLITE_INDEX_CONSTRAINT_LT = 16;
|
||||||
|
SQLITE_INDEX_CONSTRAINT_GE = 32;
|
||||||
|
SQLITE_INDEX_CONSTRAINT_MATCH = 64;
|
||||||
|
|
||||||
|
function sqlite3_create_module(db: PSQLite3; const zName: PAnsiChar; const p: PSQLite3Module; pClientData: Pointer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
type
|
||||||
|
TSQLite3ModuleDestructor = procedure(pAux: Pointer); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_create_module_v2(db: PSQLite3; const zName: PAnsiChar; const p: PSQLite3Module; pClientData: Pointer; xDestroy: TSQLite3ModuleDestructor): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_declare_vtab(db: PSQLite3; const zSQL: PAnsiChar): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_overload_function(db: PSQLite3; const zFuncName: PAnsiChar; nArg: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3Blob = type Pointer;
|
||||||
|
|
||||||
|
function sqlite3_blob_open(db: PSQLite3; const zDb: PAnsiChar; const zTable: PAnsiChar; const zColumn: PAnsiChar; iRow: Int64; flags: Integer; var ppBlob: PSQLite3Blob): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_blob_close(pBlob: PSQLite3Blob): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_blob_bytes(pBlob: PSQLite3Blob): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_blob_read(pBlob: PSQLite3Blob; Z: Pointer; N: Integer; iOffset: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_blob_write(pBlob: PSQLite3Blob; const z: Pointer; n: Integer; iOffset: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_vfs_find(const zVfsName: PAnsiChar): PSQLite3VFS; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_vfs_register(pVfs: PSQLite3VFS; makeDflt: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_vfs_unregister(pVfs: PSQLite3VFS): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_mutex_alloc(id: Integer): PSQLite3Mutex; cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_mutex_free(p: PSQLite3Mutex); cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_mutex_enter(p: PSQLite3Mutex); cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_mutex_try(p: PSQLite3Mutex): Integer; cdecl; external sqlite3_lib;
|
||||||
|
procedure sqlite3_mutex_leave(p: PSQLite3Mutex); cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_EXPERIMENTAL}
|
||||||
|
type
|
||||||
|
sqlite3_mutex_methods = record
|
||||||
|
xMutexInit: function: Integer; cdecl;
|
||||||
|
xMutexEnd: function: Integer; cdecl;
|
||||||
|
xMutexAlloc: function(id: Integer): PSQLite3Mutex; cdecl;
|
||||||
|
xMutexFree: procedure(p: PSQLite3Mutex); cdecl;
|
||||||
|
xMutexEnter: procedure(p: PSQLite3Mutex); cdecl;
|
||||||
|
xMutexTry: function(p: PSQLite3Mutex): Integer; cdecl;
|
||||||
|
xMutexLeave: procedure(p: PSQLite3Mutex); cdecl;
|
||||||
|
xMutexHeld: function(p: PSQLite3Mutex): Integer; cdecl;
|
||||||
|
xMutexNotheld: function(p: PSQLite3Mutex): Integer; cdecl;
|
||||||
|
end;
|
||||||
|
TSQLite3MutexMethods = sqlite3_mutex_methods;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_DEBUG}
|
||||||
|
function sqlite3_mutex_held(p: PSQLite3Mutex): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_mutex_notheld(p: PSQLite3Mutex): Integer; cdecl; external sqlite3_lib;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_MUTEX_FAST = 0;
|
||||||
|
SQLITE_MUTEX_RECURSIVE = 1;
|
||||||
|
SQLITE_MUTEX_STATIC_MASTER = 2;
|
||||||
|
SQLITE_MUTEX_STATIC_MEM = 3;
|
||||||
|
SQLITE_MUTEX_STATIC_MEM2 = 4;
|
||||||
|
SQLITE_MUTEX_STATIC_OPEN = 4;
|
||||||
|
SQLITE_MUTEX_STATIC_PRNG = 5;
|
||||||
|
SQLITE_MUTEX_STATIC_LRU = 6;
|
||||||
|
SQLITE_MUTEX_STATIC_LRU2 = 7;
|
||||||
|
|
||||||
|
function sqlite3_db_mutex(db: PSQLite3): PSQLite3Mutex; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_file_control(db: PSQLite3; const zDbName: PAnsiChar; op: Integer; pArg: Pointer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
function sqlite3_test_control(op: Integer{; ...}): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_TESTCTRL_FIRST = 5;
|
||||||
|
SQLITE_TESTCTRL_PRNG_SAVE = 5;
|
||||||
|
SQLITE_TESTCTRL_PRNG_RESTORE = 6;
|
||||||
|
SQLITE_TESTCTRL_PRNG_RESET = 7;
|
||||||
|
SQLITE_TESTCTRL_BITVEC_TEST = 8;
|
||||||
|
SQLITE_TESTCTRL_FAULT_INSTALL = 9;
|
||||||
|
SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10;
|
||||||
|
SQLITE_TESTCTRL_PENDING_BYTE = 11;
|
||||||
|
SQLITE_TESTCTRL_ASSERT = 12;
|
||||||
|
SQLITE_TESTCTRL_ALWAYS = 13;
|
||||||
|
SQLITE_TESTCTRL_RESERVE = 14;
|
||||||
|
SQLITE_TESTCTRL_OPTIMIZATIONS = 15;
|
||||||
|
SQLITE_TESTCTRL_ISKEYWORD = 16;
|
||||||
|
|
||||||
|
SQLITE_TESTCTRL_LAST = 16;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_EXPERIMENTAL}
|
||||||
|
function sqlite3_status(op: Integer; var pCurrent: Integer; var pHighwater: Integer; resetFlag: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_STATUS_MEMORY_USED = 0;
|
||||||
|
SQLITE_STATUS_PAGECACHE_USED = 1;
|
||||||
|
SQLITE_STATUS_PAGECACHE_OVERFLOW = 2;
|
||||||
|
SQLITE_STATUS_SCRATCH_USED = 3;
|
||||||
|
SQLITE_STATUS_SCRATCH_OVERFLOW = 4;
|
||||||
|
SQLITE_STATUS_MALLOC_SIZE = 5;
|
||||||
|
SQLITE_STATUS_PARSER_STACK = 6;
|
||||||
|
SQLITE_STATUS_PAGECACHE_SIZE = 7;
|
||||||
|
SQLITE_STATUS_SCRATCH_SIZE = 8;
|
||||||
|
|
||||||
|
function sqlite3_db_status(db: PSQLite3; op: Integer; var pCur: Integer; var pHiwtr: Integer; resetFlg: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_DBSTATUS_LOOKASIDE_USED = 0;
|
||||||
|
|
||||||
|
function sqlite3_stmt_status(pStmt: PSQLite3Stmt; op: Integer; resetFlg: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
const
|
||||||
|
SQLITE_STMTSTATUS_FULLSCAN_STEP = 1;
|
||||||
|
SQLITE_STMTSTATUS_SORT = 2;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3PCache = type Pointer;
|
||||||
|
|
||||||
|
type
|
||||||
|
sqlite3_pcache_methods = record
|
||||||
|
pArg: Pointer;
|
||||||
|
xInit: function(pArg: Pointer): Integer; cdecl;
|
||||||
|
xShutdown: procedure(pArg: Pointer); cdecl;
|
||||||
|
xCreate: function(szPage: Integer; bPurgeable: Integer): PSQLite3PCache; cdecl;
|
||||||
|
xCachesize: procedure(pCache: PSQLite3PCache; nCachesize: Integer); cdecl;
|
||||||
|
xPagecount: function(pCache: PSQLite3PCache): Integer; cdecl;
|
||||||
|
xFetch: function(pCache: PSQLite3PCache; key: Cardinal; createFlag: Integer): Pointer; cdecl;
|
||||||
|
xUnpin: procedure(pCache: PSQLite3PCache; pPg: Pointer; discard: Integer); cdecl;
|
||||||
|
xRekey: procedure(pCache: PSQLite3PCache; pPg: Pointer; oldKey: Cardinal; newKey: Cardinal); cdecl;
|
||||||
|
xTruncate: procedure(pCache: PSQLite3PCache; iLimit: Cardinal); cdecl;
|
||||||
|
xDestroy: procedure(pCache: PSQLite3PCache); cdecl;
|
||||||
|
end;
|
||||||
|
TSQLite3PCacheMethods = sqlite3_pcache_methods;
|
||||||
|
|
||||||
|
type
|
||||||
|
PSQLite3Backup = type Pointer;
|
||||||
|
|
||||||
|
function sqlite3_backup_init(pDest: PSQLite3; const zDestName: PAnsiChar; pSource: PSQLite3; const zSourceName: PAnsiChar): PSQLite3Backup; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_backup_step(p: PSQLite3Backup; nPage: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_backup_finish(p: PSQLite3Backup): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_backup_remaining(p: PSQLite3Backup): Integer; cdecl; external sqlite3_lib;
|
||||||
|
function sqlite3_backup_pagecount(p: PSQLite3Backup): Integer; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
{$IFDEF SQLITE_ENABLE_UNLOCK_NOTIFY}
|
||||||
|
type
|
||||||
|
TSQLite3UnlockNotifyCallback = procedure(apArg: PPointerArray; nArg: Integer); cdecl;
|
||||||
|
|
||||||
|
function sqlite3_unlock_notify(pBlocked: PSQLite3; xNotify: TSQLite3UnlockNotifyCallback; pNotifyArg: Pointer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
function sqlite3_strnicmp(const zLeft: PAnsiChar; const zRight: PAnsiChar; N: Integer): Integer; cdecl; external sqlite3_lib;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
//function sqlite3_win32_mbcs_to_utf8(const S: PAnsiChar): PAnsiChar; cdecl; external sqlite3_lib;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
93
Source/SQLite3Utils.pas
Normal file
93
Source/SQLite3Utils.pas
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
{
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
Complete SQLite3 API translation and simple wrapper for Delphi and FreePascal
|
||||||
|
Copyright © 2010 IndaSoftware Inc. and contributors. All rights reserved.
|
||||||
|
http://www.indasoftware.com/fordev/sqlite3/
|
||||||
|
|
||||||
|
SQLite is a software library that implements a self-contained, serverless,
|
||||||
|
zero-configuration, transactional SQL database engine. The source code for
|
||||||
|
SQLite is in the public domain and is thus free for use for any purpose,
|
||||||
|
commercial or private. SQLite is the most widely deployed SQL database engine
|
||||||
|
in the world.
|
||||||
|
|
||||||
|
This package contains complete SQLite3 API translation for Delphi and
|
||||||
|
FreePascal, as well as a simple Unicode-enabled object wrapper to simplify
|
||||||
|
the use of this database engine.
|
||||||
|
|
||||||
|
The contents of this file are used with permission, subject to the Mozilla
|
||||||
|
Public License Version 1.1 (the "License"); you may not use this file except
|
||||||
|
in compliance with the License. You may obtain a copy of the License at
|
||||||
|
http://www.mozilla.org/MPL/MPL-1.1.html
|
||||||
|
|
||||||
|
Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||||
|
the specific language governing rights and limitations under the License.
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Miscellaneous utility functions
|
||||||
|
}
|
||||||
|
unit SQLite3Utils;
|
||||||
|
|
||||||
|
{$WARN SYMBOL_DEPRECATED OFF}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
function StrToUTF8(const S: WideString): AnsiString;
|
||||||
|
function UTF8ToStr(const S: PAnsiChar; const Len: Integer = -1): WideString;
|
||||||
|
function QuotedStr(const S: WideString): WideString;
|
||||||
|
function FloatToSQLStr(Value: Extended): WideString;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses SysUtils;
|
||||||
|
|
||||||
|
function StrToUTF8(const S: WideString): AnsiString;
|
||||||
|
begin
|
||||||
|
Result := UTF8Encode(S);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function UTF8ToStr(const S: PAnsiChar; const Len: Integer): WideString;
|
||||||
|
var
|
||||||
|
UTF8Str: AnsiString;
|
||||||
|
begin
|
||||||
|
if Len < 0 then
|
||||||
|
begin
|
||||||
|
Result := UTF8Decode(S);
|
||||||
|
end
|
||||||
|
else if Len > 0 then
|
||||||
|
begin
|
||||||
|
SetLength(UTF8Str, Len);
|
||||||
|
Move(S^, UTF8Str[1], Len);
|
||||||
|
Result := UTF8Decode(UTF8Str);
|
||||||
|
end
|
||||||
|
else Result := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function QuotedStr(const S: WideString): WideString;
|
||||||
|
const
|
||||||
|
Quote = #39;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
Result := S;
|
||||||
|
for I := Length(Result) downto 1 do
|
||||||
|
if Result[I] = Quote then Insert(Quote, Result, I);
|
||||||
|
Result := Quote + Result + Quote;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function FloatToSQLStr(Value: Extended): WideString;
|
||||||
|
var
|
||||||
|
SaveSeparator: Char;
|
||||||
|
begin
|
||||||
|
SaveSeparator := DecimalSeparator;
|
||||||
|
DecimalSeparator := '.';
|
||||||
|
try
|
||||||
|
Result := FloatToStr(Value);
|
||||||
|
finally
|
||||||
|
DecimalSeparator := SaveSeparator;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
478
Source/SQLite3Wrap.pas
Normal file
478
Source/SQLite3Wrap.pas
Normal file
@@ -0,0 +1,478 @@
|
|||||||
|
{
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
Complete SQLite3 API translation and simple wrapper for Delphi and FreePascal
|
||||||
|
Copyright © 2010 IndaSoftware Inc. and contributors. All rights reserved.
|
||||||
|
http://www.indasoftware.com/fordev/sqlite3/
|
||||||
|
|
||||||
|
SQLite is a software library that implements a self-contained, serverless,
|
||||||
|
zero-configuration, transactional SQL database engine. The source code for
|
||||||
|
SQLite is in the public domain and is thus free for use for any purpose,
|
||||||
|
commercial or private. SQLite is the most widely deployed SQL database engine
|
||||||
|
in the world.
|
||||||
|
|
||||||
|
This package contains complete SQLite3 API translation for Delphi and
|
||||||
|
FreePascal, as well as a simple Unicode-enabled object wrapper to simplify
|
||||||
|
the use of this database engine.
|
||||||
|
|
||||||
|
The contents of this file are used with permission, subject to the Mozilla
|
||||||
|
Public License Version 1.1 (the "License"); you may not use this file except
|
||||||
|
in compliance with the License. You may obtain a copy of the License at
|
||||||
|
http://www.mozilla.org/MPL/MPL-1.1.html
|
||||||
|
|
||||||
|
Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||||
|
the specific language governing rights and limitations under the License.
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Simple object wrapper over SQLite3 API
|
||||||
|
}
|
||||||
|
unit SQLite3Wrap;
|
||||||
|
|
||||||
|
{$IFDEF FPC}
|
||||||
|
{$MODE DELPHI}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, Classes, SQLite3;
|
||||||
|
|
||||||
|
type
|
||||||
|
ESQLite3Error = class(Exception);
|
||||||
|
|
||||||
|
TSQLite3Statement = class;
|
||||||
|
TSQLite3BlobHandler = class;
|
||||||
|
|
||||||
|
{ TSQLite3Database class }
|
||||||
|
|
||||||
|
TSQLite3Database = class(TObject)
|
||||||
|
private
|
||||||
|
FHandle: PSQLite3;
|
||||||
|
FStatementList: TList;
|
||||||
|
FBlobHandlerList: TList;
|
||||||
|
FTransactionOpen: Boolean;
|
||||||
|
procedure Check(const ErrCode: Integer);
|
||||||
|
procedure CheckHandle;
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
procedure Open(const FileName: WideString);
|
||||||
|
procedure Close;
|
||||||
|
|
||||||
|
procedure Execute(const SQL: WideString);
|
||||||
|
function LastInsertRowID: Int64;
|
||||||
|
function Prepare(const SQL: WideString): TSQLite3Statement;
|
||||||
|
function BlobOpen(const Table, Column: WideString; const RowID: Int64; const WriteAccess: Boolean = True): TSQLite3BlobHandler;
|
||||||
|
|
||||||
|
procedure BeginTransaction;
|
||||||
|
procedure Commit;
|
||||||
|
procedure Rollback;
|
||||||
|
|
||||||
|
property Handle: PSQLite3 read FHandle;
|
||||||
|
property TransactionOpen: Boolean read FTransactionOpen;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TSQLite3Statement class }
|
||||||
|
|
||||||
|
TSQLite3Statement = class(TObject)
|
||||||
|
private
|
||||||
|
FHandle: PSQLite3Stmt;
|
||||||
|
FOwnerDatabase: TSQLite3Database;
|
||||||
|
function ParamIndexByName(const ParamName: WideString): Integer;
|
||||||
|
public
|
||||||
|
constructor Create(OwnerDatabase: TSQLite3Database; const SQL: WideString);
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
procedure BindInt(const ParamIndex: Integer; const Value: Integer); overload;
|
||||||
|
procedure BindInt64(const ParamIndex: Integer; const Value: Int64); overload;
|
||||||
|
procedure BindDouble(const ParamIndex: Integer; const Value: Double); overload;
|
||||||
|
procedure BindText(const ParamIndex: Integer; const Value: WideString); overload;
|
||||||
|
procedure BindNull(const ParamIndex: Integer); overload;
|
||||||
|
procedure BindBlob(const ParamIndex: Integer; Data: Pointer; const Size: Integer); overload;
|
||||||
|
procedure BindZeroBlob(const ParamIndex: Integer; const Size: Integer); overload;
|
||||||
|
procedure BindInt(const ParamName: WideString; const Value: Integer); overload;
|
||||||
|
procedure BindInt64(const ParamName: WideString; const Value: Int64); overload;
|
||||||
|
procedure BindDouble(const ParamName: WideString; const Value: Double); overload;
|
||||||
|
procedure BindText(const ParamName: WideString; const Value: WideString); overload;
|
||||||
|
procedure BindNull(const ParamName: WideString); overload;
|
||||||
|
procedure BindBlob(const ParamName: WideString; Data: Pointer; const Size: Integer); overload;
|
||||||
|
procedure BindZeroBlob(const ParamName: WideString; const Size: Integer); overload;
|
||||||
|
procedure ClearBindings;
|
||||||
|
|
||||||
|
function Step: Integer;
|
||||||
|
|
||||||
|
function ColumnCount: Integer;
|
||||||
|
function ColumnName(const ColumnIndex: Integer): WideString;
|
||||||
|
function ColumnType(const ColumnIndex: Integer): Integer;
|
||||||
|
function ColumnInt(const ColumnIndex: Integer): Integer;
|
||||||
|
function ColumnInt64(const ColumnIndex: Integer): Int64;
|
||||||
|
function ColumnDouble(const ColumnIndex: Integer): Double;
|
||||||
|
function ColumnText(const ColumnIndex: Integer): WideString;
|
||||||
|
function ColumnBlob(const ColumnIndex: Integer): Pointer;
|
||||||
|
function ColumnBytes(const ColumnIndex: Integer): Integer;
|
||||||
|
|
||||||
|
procedure Reset;
|
||||||
|
procedure StepAndReset;
|
||||||
|
|
||||||
|
property Handle: PSQLite3Stmt read FHandle;
|
||||||
|
property OwnerDatabase: TSQLite3Database read FOwnerDatabase;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TSQLite3BlobHandler class }
|
||||||
|
|
||||||
|
TSQLite3BlobHandler = class(TObject)
|
||||||
|
private
|
||||||
|
FHandle: PSQLite3Blob;
|
||||||
|
FOwnerDatabase: TSQLite3Database;
|
||||||
|
public
|
||||||
|
constructor Create(OwnerDatabase: TSQLite3Database; const Table, Column: WideString; const RowID: Int64; const WriteAccess: Boolean = True);
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
function Bytes: Integer;
|
||||||
|
procedure Read(Buffer: Pointer; const Size, Offset: Integer);
|
||||||
|
procedure Write(Buffer: Pointer; const Size, Offset: Integer);
|
||||||
|
|
||||||
|
property Handle: PSQLite3Blob read FHandle;
|
||||||
|
property OwnerDatabase: TSQLite3Database read FOwnerDatabase;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses SQLite3Utils;
|
||||||
|
|
||||||
|
resourcestring
|
||||||
|
SErrorMessage = 'SQLite3 error: %s';
|
||||||
|
SDatabaseNotConnected = 'SQLite3 error: database is not connected.';
|
||||||
|
STransactionAlreadyOpen = 'Transaction is already opened.';
|
||||||
|
SNoTransactionOpen = 'No transaction is open';
|
||||||
|
|
||||||
|
{ TSQLite3Database }
|
||||||
|
|
||||||
|
procedure TSQLite3Database.BeginTransaction;
|
||||||
|
begin
|
||||||
|
if not FTransactionOpen then
|
||||||
|
begin
|
||||||
|
Execute('BEGIN TRANSACTION;');
|
||||||
|
FTransactionOpen := True;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise ESQLite3Error.Create(STransactionAlreadyOpen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Database.BlobOpen(const Table, Column: WideString;
|
||||||
|
const RowID: Int64; const WriteAccess: Boolean): TSQLite3BlobHandler;
|
||||||
|
begin
|
||||||
|
Result := TSQLite3BlobHandler.Create(Self, Table, Column, RowID, WriteAccess);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Database.Check(const ErrCode: Integer);
|
||||||
|
begin
|
||||||
|
if ErrCode <> SQLITE_OK then
|
||||||
|
raise ESQLite3Error.CreateFmt(SErrorMessage, [UTF8ToStr(sqlite3_errmsg(FHandle))]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Database.CheckHandle;
|
||||||
|
begin
|
||||||
|
if FHandle = nil then
|
||||||
|
raise ESQLite3Error.Create(SDatabaseNotConnected);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Database.Close;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
if FHandle <> nil then
|
||||||
|
begin
|
||||||
|
if FTransactionOpen then
|
||||||
|
Rollback;
|
||||||
|
// Delete all statements
|
||||||
|
for I := FStatementList.Count - 1 downto 0 do
|
||||||
|
TSQLite3Statement(FStatementList[I]).Free;
|
||||||
|
// Delete all blob handlers
|
||||||
|
for I := FBlobHandlerList.Count - 1 downto 0 do
|
||||||
|
TSQLite3BlobHandler(FBlobHandlerList[I]).Free;
|
||||||
|
sqlite3_close(FHandle);
|
||||||
|
FHandle := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Database.Commit;
|
||||||
|
begin
|
||||||
|
if FTransactionOpen then
|
||||||
|
begin
|
||||||
|
Execute('COMMIT;');
|
||||||
|
FTransactionOpen := False;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise ESQLite3Error.Create(SNoTransactionOpen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TSQLite3Database.Create;
|
||||||
|
begin
|
||||||
|
FHandle := nil;
|
||||||
|
FStatementList := TList.Create;
|
||||||
|
FBlobHandlerList := TList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TSQLite3Database.Destroy;
|
||||||
|
begin
|
||||||
|
Close;
|
||||||
|
FBlobHandlerList.Free;
|
||||||
|
FStatementList.Free;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Database.Execute(const SQL: WideString);
|
||||||
|
begin
|
||||||
|
CheckHandle;
|
||||||
|
Check(sqlite3_exec(FHandle, PAnsiChar(StrToUTF8(SQL)), nil, nil, nil));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Database.LastInsertRowID: Int64;
|
||||||
|
begin
|
||||||
|
CheckHandle;
|
||||||
|
Result := sqlite3_last_insert_rowid(FHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Database.Open(const FileName: WideString);
|
||||||
|
begin
|
||||||
|
Close;
|
||||||
|
Check(sqlite3_open(PAnsiChar(StrToUTF8(FileName)), FHandle));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Database.Prepare(const SQL: WideString): TSQLite3Statement;
|
||||||
|
begin
|
||||||
|
Result := TSQLite3Statement.Create(Self, SQL);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Database.Rollback;
|
||||||
|
begin
|
||||||
|
if FTransactionOpen then
|
||||||
|
begin
|
||||||
|
Execute('ROLLBACK;');
|
||||||
|
FTransactionOpen := False;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise ESQLite3Error.Create(SNoTransactionOpen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TSQLite3Statement }
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindBlob(const ParamIndex: Integer; Data: Pointer;
|
||||||
|
const Size: Integer);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_bind_blob(FHandle, ParamIndex, Data, Size, SQLITE_STATIC));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindDouble(const ParamIndex: Integer;
|
||||||
|
const Value: Double);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_bind_double(FHandle, ParamIndex, Value));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindInt(const ParamIndex, Value: Integer);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_bind_int(FHandle, ParamIndex, Value));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindInt64(const ParamIndex: Integer;
|
||||||
|
const Value: Int64);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_bind_int64(FHandle, ParamIndex, Value));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindNull(const ParamIndex: Integer);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_bind_null(FHandle, ParamIndex));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindText(const ParamIndex: Integer;
|
||||||
|
const Value: WideString);
|
||||||
|
var
|
||||||
|
S: AnsiString; { UTF-8 string }
|
||||||
|
begin
|
||||||
|
S := StrToUTF8(Value);
|
||||||
|
FOwnerDatabase.Check(
|
||||||
|
sqlite3_bind_text(FHandle, ParamIndex, PAnsiChar(S), Length(S), SQLITE_STATIC)
|
||||||
|
);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindZeroBlob(const ParamIndex, Size: Integer);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_bind_zeroblob(FHandle, ParamIndex, Size));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.ClearBindings;
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_clear_bindings(FHandle));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnBlob(const ColumnIndex: Integer): Pointer;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_column_blob(FHandle, ColumnIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnBytes(const ColumnIndex: Integer): Integer;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_column_bytes(FHandle, ColumnIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnCount: Integer;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_column_count(FHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnDouble(const ColumnIndex: Integer): Double;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_column_double(FHandle, ColumnIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnInt(const ColumnIndex: Integer): Integer;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_column_int(FHandle, ColumnIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnInt64(const ColumnIndex: Integer): Int64;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_column_int64(FHandle, ColumnIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnName(const ColumnIndex: Integer): WideString;
|
||||||
|
begin
|
||||||
|
Result := UTF8ToStr(sqlite3_column_name(FHandle, ColumnIndex));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnText(const ColumnIndex: Integer): WideString;
|
||||||
|
var
|
||||||
|
Len: Integer;
|
||||||
|
begin
|
||||||
|
Len := ColumnBytes(ColumnIndex);
|
||||||
|
Result := UTF8ToStr(sqlite3_column_text(FHandle, ColumnIndex), Len);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ColumnType(const ColumnIndex: Integer): Integer;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_column_type(FHandle, ColumnIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TSQLite3Statement.Create(OwnerDatabase: TSQLite3Database;
|
||||||
|
const SQL: WideString);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase := OwnerDatabase;
|
||||||
|
FOwnerDatabase.CheckHandle;
|
||||||
|
FOwnerDatabase.Check(
|
||||||
|
sqlite3_prepare_v2(FOwnerDatabase.Handle, PAnsiChar(StrToUTF8(SQL)), -1, FHandle, nil)
|
||||||
|
);
|
||||||
|
FOwnerDatabase.FStatementList.Add(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TSQLite3Statement.Destroy;
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.FStatementList.Remove(Self);
|
||||||
|
sqlite3_finalize(FHandle);
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.ParamIndexByName(const ParamName: WideString): Integer;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_bind_parameter_index(FHandle, PAnsiChar(StrToUTF8(ParamName)));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.Reset;
|
||||||
|
begin
|
||||||
|
sqlite3_reset(FHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSQLite3Statement.Step: Integer;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_step(FHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.StepAndReset;
|
||||||
|
begin
|
||||||
|
Step;
|
||||||
|
Reset;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindBlob(const ParamName: WideString; Data: Pointer;
|
||||||
|
const Size: Integer);
|
||||||
|
begin
|
||||||
|
BindBlob(ParamIndexByName(ParamName), Data, Size);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindDouble(const ParamName: WideString;
|
||||||
|
const Value: Double);
|
||||||
|
begin
|
||||||
|
BindDouble(ParamIndexByName(ParamName), Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindInt(const ParamName: WideString;
|
||||||
|
const Value: Integer);
|
||||||
|
begin
|
||||||
|
BindInt(ParamIndexByName(ParamName), Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindInt64(const ParamName: WideString;
|
||||||
|
const Value: Int64);
|
||||||
|
begin
|
||||||
|
BindInt64(ParamIndexByName(ParamName), Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindNull(const ParamName: WideString);
|
||||||
|
begin
|
||||||
|
BindNull(ParamIndexByName(ParamName));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindText(const ParamName, Value: WideString);
|
||||||
|
begin
|
||||||
|
BindText(ParamIndexByName(ParamName), Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Statement.BindZeroBlob(const ParamName: WideString;
|
||||||
|
const Size: Integer);
|
||||||
|
begin
|
||||||
|
BindZeroBlob(ParamIndexByName(ParamName), Size);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TSQLite3BlobHandler }
|
||||||
|
|
||||||
|
function TSQLite3BlobHandler.Bytes: Integer;
|
||||||
|
begin
|
||||||
|
Result := sqlite3_blob_bytes(FHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TSQLite3BlobHandler.Create(OwnerDatabase: TSQLite3Database; const Table,
|
||||||
|
Column: WideString; const RowID: Int64; const WriteAccess: Boolean);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase := OwnerDatabase;
|
||||||
|
FOwnerDatabase.CheckHandle;
|
||||||
|
FOwnerDatabase.Check(
|
||||||
|
sqlite3_blob_open(FOwnerDatabase.FHandle, 'main', PAnsiChar(StrToUTF8(Table)),
|
||||||
|
PAnsiChar(StrToUTF8(Column)), RowID, Ord(WriteAccess), FHandle)
|
||||||
|
);
|
||||||
|
FOwnerDatabase.FBlobHandlerList.Add(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TSQLite3BlobHandler.Destroy;
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.FBlobHandlerList.Remove(Self);
|
||||||
|
sqlite3_blob_close(FHandle);
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3BlobHandler.Read(Buffer: Pointer; const Size,
|
||||||
|
Offset: Integer);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_blob_read(FHandle, Buffer, Size, Offset));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3BlobHandler.Write(Buffer: Pointer; const Size,
|
||||||
|
Offset: Integer);
|
||||||
|
begin
|
||||||
|
FOwnerDatabase.Check(sqlite3_blob_write(FHandle, Buffer, Size, Offset));
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
Reference in New Issue
Block a user