mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-04-21 13:21:03 +00:00
Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
|
462c40e3fd | ||
|
7b4ad1e204 | ||
|
5a44e5811a | ||
|
9e2c50014c | ||
|
86c13364fb |
29 changed files with 9924 additions and 18452 deletions
620
COPYING.LIB
620
COPYING.LIB
|
@ -1,166 +1,504 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
Preamble
|
||||
|
||||
0. Additional Definitions.
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
4. Combined Works.
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
|
|
320
ECPG.pgm
320
ECPG.pgm
|
@ -9,16 +9,16 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
|
@ -40,9 +40,6 @@
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
|
||||
@interface SQLClientECPG : SQLClient
|
||||
|
@ -111,18 +108,18 @@ void SQLErrorHandler()
|
|||
const char *e1 = "Error in transaction processing";
|
||||
|
||||
sqlca.sqlcode = 0; // Reset error code
|
||||
NSLog (@"Raising an exception, %d, %s", code, sqlca.sqlerrm.sqlerrmc);
|
||||
NSLog (@"Raising an exception, %ld, %s", code, sqlca.sqlerrm.sqlerrmc);
|
||||
|
||||
if (strncmp(ptr, e0, strlen(e0)) == 0
|
||||
|| strncmp(ptr, e1, strlen(e1)) == 0)
|
||||
{
|
||||
[NSException raise: SQLConnectionException
|
||||
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
|
||||
format: @"SQL Error: SQLCODE=(%ld): %s", code, ptr];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"SQL Error: SQLCODE=(%d): %s", code, ptr];
|
||||
format: @"SQL Error: SQLCODE=(%ld): %s", code, ptr];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +134,7 @@ static NSDate *future = nil;
|
|||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
[future retain];
|
||||
RETAIN(future);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,20 +245,20 @@ static NSDate *future = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char *statement;
|
||||
char *handle;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
unsigned int length;
|
||||
NSString *stmt = [info objectAtIndex: 0];
|
||||
|
||||
length = [stmt length];
|
||||
if (length == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -279,9 +276,9 @@ static NSDate *future = nil;
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
[self name], stmt];
|
||||
|
@ -299,7 +296,7 @@ static NSDate *future = nil;
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
/*
|
||||
* remove line number information from database exception message
|
||||
|
@ -325,14 +322,13 @@ static NSDate *future = nil;
|
|||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return -1;
|
||||
DESTROY(arp);
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -360,8 +356,6 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
recordType: (id)rtype
|
||||
listType: (id)ltype
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
bool aBool;
|
||||
|
@ -383,7 +377,7 @@ static unsigned int trim(char *str)
|
|||
char *query;
|
||||
char *handle;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSMutableArray *records;
|
||||
BOOL isOpen = NO;
|
||||
BOOL localTransaction = NO;
|
||||
|
@ -391,21 +385,21 @@ static unsigned int trim(char *str)
|
|||
length = [stmt length];
|
||||
if (length == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
||||
query = (char*)[hackForPrepare(stmt) UTF8String];
|
||||
handle = (char*)[[self clientName] UTF8String];
|
||||
records = [[ltype alloc] initWithCapacity: 32];
|
||||
records = [[NSMutableArray alloc] initWithCapacity: 32];
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
[self name], stmt];
|
||||
|
@ -557,10 +551,7 @@ static unsigned int trim(char *str)
|
|||
case SQL3_CHARACTER_VARYING:
|
||||
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
|
||||
:aString = DATA;
|
||||
if (_shouldTrim)
|
||||
{
|
||||
trim(aString);
|
||||
}
|
||||
trim(aString);
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
break;
|
||||
|
@ -589,10 +580,7 @@ static unsigned int trim(char *str)
|
|||
default:
|
||||
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
|
||||
:aString = DATA;
|
||||
if (_shouldTrim)
|
||||
{
|
||||
trim(aString);
|
||||
}
|
||||
trim(aString);
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
if ([self debugging] > 0)
|
||||
|
@ -609,11 +597,11 @@ static unsigned int trim(char *str)
|
|||
keys[index-1] = [NSString stringWithUTF8String:
|
||||
fieldName];
|
||||
}
|
||||
record = [rtype newWithValues: values
|
||||
keys: keys
|
||||
count: count];
|
||||
record = [SQLRecord newWithValues: values
|
||||
keys: keys
|
||||
count: count];
|
||||
[records addObject: record];
|
||||
[record release];
|
||||
RELEASE(record);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -631,8 +619,7 @@ static unsigned int trim(char *str)
|
|||
NSString *n = [localException name];
|
||||
NSString *msg = [localException reason];
|
||||
|
||||
[records release];
|
||||
records = nil;
|
||||
DESTROY(records);
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
|
@ -651,14 +638,14 @@ static unsigned int trim(char *str)
|
|||
|
||||
if ([e isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -680,15 +667,15 @@ static unsigned int trim(char *str)
|
|||
userInfo: nil];
|
||||
}
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN(localException);
|
||||
RELEASE(arp);
|
||||
AUTORELEASE(localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
DESTROY(arp);
|
||||
|
||||
return [records autorelease];
|
||||
return AUTORELEASE(records);
|
||||
}
|
||||
|
||||
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
|
||||
|
@ -946,13 +933,9 @@ static unsigned int trim(char *str)
|
|||
|
||||
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l
|
||||
{
|
||||
char buf[l+32]; /* Allow space to expand buffer. */
|
||||
NSCalendarDate *d;
|
||||
BOOL milliseconds = NO;
|
||||
BOOL timezone = NO;
|
||||
NSString *s;
|
||||
int i;
|
||||
int e;
|
||||
char buf[l+32]; /* Allow space to expend buffer. */
|
||||
NSString *s;
|
||||
int i;
|
||||
|
||||
memcpy(buf, b, l);
|
||||
b = buf;
|
||||
|
@ -975,153 +958,98 @@ static unsigned int trim(char *str)
|
|||
|
||||
if (l == 10)
|
||||
{
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d"
|
||||
locale: nil];
|
||||
}
|
||||
|
||||
i = l;
|
||||
|
||||
/* Convert +/-HH:SS timezone to +/-HHSS
|
||||
*/
|
||||
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
|
||||
{
|
||||
b[i-3] = b[i-2];
|
||||
b[i-2] = b[i-1];
|
||||
b[--i] = '\0';
|
||||
}
|
||||
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
e = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
timezone = YES;
|
||||
e = i;
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
i = l;
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
int e = i;
|
||||
|
||||
/*
|
||||
* Ensure we have a four digit timezone value.
|
||||
*/
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone ... append zero minutes
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes ... remove it
|
||||
b[i+3] = b[i+4];
|
||||
b[i+4] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
|
||||
/* kludge for timestamps with fractional second information.
|
||||
* Force it to 3 digit millisecond */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
milliseconds = YES;
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+3], &b[i], e-i);
|
||||
l += 3;
|
||||
memcpy(&b[i], "000", 3);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+2], &b[i], e-i);
|
||||
l += 2;
|
||||
memcpy(&b[i], "00", 2);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+1], &b[i], e-i);
|
||||
l += 1;
|
||||
memcpy(&b[i], "0", 1);
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0 && i < e)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
}
|
||||
b[l] = '\0';
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes
|
||||
b[i+3] = b[i+4];
|
||||
b[i+5] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (YES == timezone)
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
/* FIXME ... horrible kludge for postgres returning timestamps with
|
||||
fractional second information. */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
b[l] = '\0';
|
||||
}
|
||||
}
|
||||
else if (l == 19)
|
||||
{
|
||||
/* A date and time without a timezone ... assume gmt */
|
||||
strcat(b, " +0000");
|
||||
l += 6;
|
||||
}
|
||||
|
||||
|
||||
/* If it's a simple date (YYYY-MM-DD) append time for start of day. */
|
||||
if (l == 10)
|
||||
{
|
||||
strcat(b, " 00:00:00 +0000");
|
||||
l += 15;
|
||||
}
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
}
|
||||
}
|
||||
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
return d;
|
||||
}
|
||||
|
||||
- (NSString*) dbToStringFromBuffer: (char*)b length: (int)l
|
||||
|
@ -1139,8 +1067,8 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
d = [[NSData alloc] initWithBytes: b length: l];
|
||||
s = [[NSString alloc] initWithData: d encoding: NSUTF8StringEncoding];
|
||||
[d release];
|
||||
return [s autorelease];
|
||||
RELEASE(d);
|
||||
return AUTORELEASE(s);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
83
GNUmakefile
83
GNUmakefile
|
@ -1,50 +1,23 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(error You need to set GNUSTEP_MAKEFILES before compiling!)
|
||||
endif
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
# Force sequential build to prevent different versions of the same
|
||||
# bundle overwriting each other's temporary files during building.
|
||||
GNUSTEP_MAKE_PARALLEL_BUILDING=no
|
||||
|
||||
-include config.make
|
||||
|
||||
PACKAGE_NAME = SQLClient
|
||||
PACKAGE_VERSION = 1.9.0
|
||||
PACKAGE_VERSION = 1.2.0
|
||||
CVS_MODULE_NAME = gnustep/dev-libs/SQLClient
|
||||
CVS_TAG_NAME = SQLClient
|
||||
SVN_BASE_URL=svn+ssh://svn.gna.org/svn/gnustep/libs
|
||||
SVN_MODULE_NAME=sqlclient
|
||||
|
||||
NEEDS_GUI = NO
|
||||
|
||||
TEST_TOOL_NAME=
|
||||
|
||||
LIBRARY_NAME=SQLClient
|
||||
DOCUMENT_NAME=SQLClient
|
||||
|
||||
SQLClient_INTERFACE_VERSION=1.9
|
||||
SQLClient_INTERFACE_VERSION=1.2
|
||||
|
||||
SQLClient_OBJC_FILES = SQLClient.m SQLClientPool.m
|
||||
SQLClient_LIBRARIES_DEPEND_UPON = -lPerformance $(FND_LIBS) $(OBJC_LIBS)
|
||||
SQLClient_OBJC_FILES = SQLClient.m
|
||||
SQLClient_LIBRARIES_DEPEND_UPON = -lPerformance
|
||||
SQLClient_HEADER_FILES = SQLClient.h
|
||||
SQLClient_AGSDOC_FILES = SQLClient.h
|
||||
SQLClient_AGSDOC_FLAGS = -WordMap '{SQLCLIENT_PRIVATE="";}'
|
||||
|
||||
# Optional Java wrappers for the library
|
||||
JAVA_WRAPPER_NAME = SQLClient
|
||||
|
@ -53,7 +26,7 @@ SQLClient_HEADER_FILES_INSTALL_DIR = SQLClient
|
|||
|
||||
BUNDLE_NAME=
|
||||
|
||||
BUNDLE_INSTALL_DIR=$(GNUSTEP_BUNDLES)/SQLClient$(SQLClient_INTERFACE_VERSION)
|
||||
BUNDLE_INSTALL_DIR=$(GNUSTEP_INSTALLATION_DIR)/Library/Bundles/SQLClient
|
||||
|
||||
# In some systems and situations the dynamic linker needs to haved the
|
||||
# SQLClient, gnustep-base, and objc libraries explicityly linked into
|
||||
|
@ -63,7 +36,7 @@ BUNDLE_INSTALL_DIR=$(GNUSTEP_BUNDLES)/SQLClient$(SQLClient_INTERFACE_VERSION)
|
|||
|
||||
ifeq ($(LINKSQLCLIENT),)
|
||||
LINKSQLCLIENT=0
|
||||
ifeq ($(findstring darwin, $(GNUSTEP_TARGET_OS)), darwin)
|
||||
ifeq ($(APPLE),1)
|
||||
LINKSQLCLIENT=1
|
||||
endif
|
||||
endif
|
||||
|
@ -85,13 +58,13 @@ BUNDLE_NAME += ECPG_libs
|
|||
ECPG_libs_OBJC_FILES = ECPG.m
|
||||
ECPG_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
ECPG_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lecpg
|
||||
-lgnustep-base -lobjc -lecpg
|
||||
ECPG_libs_PRINCIPAL_CLASS = SQLClientECPG_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testECPG
|
||||
testECPG_OBJC_FILES = testECPG.m
|
||||
testECPG_TOOL_LIBS += -lSQLClient
|
||||
testECPG_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testECPG_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
endif
|
||||
|
||||
ifneq ($(POSTGRES),)
|
||||
|
@ -111,39 +84,13 @@ BUNDLE_NAME += Postgres_libs
|
|||
Postgres_libs_OBJC_FILES = Postgres.m
|
||||
Postgres_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
Postgres_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lpq
|
||||
-lgnustep-base -lobjc -lpq
|
||||
Postgres_libs_PRINCIPAL_CLASS = SQLClientPostgres_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testPostgres
|
||||
testPostgres_OBJC_FILES = testPostgres.m
|
||||
testPostgres_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testPostgres_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
endif
|
||||
|
||||
ifneq ($(JDBC),)
|
||||
ifeq ($(LINKSQLCLIENT),1)
|
||||
BUNDLE_NAME += JDBC
|
||||
JDBC_OBJC_FILES = JDBC.m
|
||||
JDBC_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR) $(JDBC_VM_LIBDIRS)
|
||||
JDBC_BUNDLE_LIBS += -lSQLClient $(JDBC_VM_LIBS)
|
||||
JDBC_PRINCIPAL_CLASS = SQLClientJDBC
|
||||
else
|
||||
BUNDLE_NAME += JDBC
|
||||
JDBC_OBJC_FILES = JDBC.m
|
||||
JDBC_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR) $(JDBC_VM_LIBDIRS)
|
||||
JDBC_BUNDLE_LIBS += $(JDBC_VM_LIBS)
|
||||
JDBC_PRINCIPAL_CLASS = SQLClientJDBC
|
||||
BUNDLE_NAME += JDBC_libs
|
||||
JDBC_libs_OBJC_FILES = JDBC.m
|
||||
JDBC_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR) $(JDBC_VM_LIBDIRS)
|
||||
JDBC_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) $(JDBC_VM_LIBS)
|
||||
JDBC_libs_PRINCIPAL_CLASS = SQLClientJDBC_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testJDBC
|
||||
testJDBC_OBJC_FILES = testJDBC.m
|
||||
testJDBC_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testJDBC_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
testPostgres_TOOL_LIBS += -lSQLClient
|
||||
endif
|
||||
|
||||
ifneq ($(MYSQL),)
|
||||
|
@ -163,13 +110,13 @@ BUNDLE_NAME += MySQL_libs
|
|||
MySQL_libs_OBJC_FILES = MySQL.m
|
||||
MySQL_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
MySQL_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lmysqlclient
|
||||
-lgnustep-base -lobjc -lmysqlclient
|
||||
MySQL_libs_PRINCIPAL_CLASS = SQLClientMySQL_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testMySQL
|
||||
testMySQL_OBJC_FILES = testMySQL.m
|
||||
testMySQL_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testMySQL_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
testMySQL_TOOL_LIBS += -lSQLClient
|
||||
endif
|
||||
|
||||
ifneq ($(SQLITE),)
|
||||
|
@ -189,13 +136,13 @@ BUNDLE_NAME += SQLite_libs
|
|||
SQLite_libs_OBJC_FILES = SQLite.m
|
||||
SQLite_libs_LIB_DIRS = -L./$(GNUSTEP_OBJ_DIR)
|
||||
SQLite_libs_BUNDLE_LIBS += -lSQLClient -lPerformance \
|
||||
$(FND_LIBS) $(OBJC_LIBS) -lsqlite3
|
||||
-lgnustep-base -lobjc -lsqlite3
|
||||
SQLite_libs_PRINCIPAL_CLASS = SQLClientSQLite_libs
|
||||
endif
|
||||
TEST_TOOL_NAME += testSQLite
|
||||
testSQLite_OBJC_FILES = testSQLite.m
|
||||
testSQLite_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||
testSQLite_TOOL_LIBS += -lSQLClient -lPerformance
|
||||
testSQLite_TOOL_LIBS += -lSQLClient
|
||||
endif
|
||||
|
||||
ifneq ($(ORACLE_HOME),)
|
||||
|
@ -212,7 +159,7 @@ Oracle_libs_OBJC_FILES = Oracle.m
|
|||
Oracle_libs_LIB_DIRS = -L$(ORACLE_HOME)/lib -L./$(GNUSTEP_OBJ_DIR) \
|
||||
$(shell cat $(ORACLE_HOME)/lib/ldflags)
|
||||
Oracle_libs_BUNDLE_LIBS += -lclntsh \
|
||||
-lSQLClient -lPerformance $(FND_LIBS) $(OBJC_LIBS) \
|
||||
-lSQLClient -lPerformance -lgnustep-base -lobjc \
|
||||
$(shell cat $(ORACLE_HOME)/lib/sysliblist) \
|
||||
-ldl -lm
|
||||
Oracle_libs_PRINCIPAL_CLASS = SQLClientOracle_libs
|
||||
|
|
|
@ -13,7 +13,9 @@ ifneq ($(ECPG),)
|
|||
%.m: %.pgm
|
||||
ecpg -o $@ $< $(ADDITIONAL_INCLUDE_DIRS)
|
||||
|
||||
.PRECIOUS: %.m
|
||||
# if you need to see the .m files for debugging, uncomment
|
||||
# the following line
|
||||
#.PRECIOUS: %.m
|
||||
|
||||
endif
|
||||
|
||||
|
@ -23,7 +25,9 @@ ifneq ($(ORACLE_HOME),)
|
|||
%.m: %.pm
|
||||
proc iname=$< oname=$@ mode=ansi parse=none
|
||||
|
||||
.PRECIOUS: %.m
|
||||
# if you need to see the .m files for debugging, uncomment
|
||||
# the following line
|
||||
#.PRECIOUS: %.m
|
||||
|
||||
endif
|
||||
|
||||
|
@ -66,10 +70,6 @@ after-distclean::
|
|||
# Things to do after checking
|
||||
# after-check::
|
||||
|
||||
config.make: config.status
|
||||
if [ -x config.status ]; then \
|
||||
./config.status --recheck; \
|
||||
else \
|
||||
./configure; \
|
||||
fi
|
||||
config.make: config.make.in
|
||||
./configure
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS += -DSOVERSION=\"$(SQLClient_INTERFACE_VERSION)\"
|
||||
# ADDITIONAL_CPPFLAGS +=
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
# ADDITIONAL_OBJCFLAGS +=
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
LIBRARIES_DEPEND_UPON += -lPerformance.A
|
||||
ADDITIONAL_LIB_DIRS = -L../../$(GNUSTEP_OBJ_DIR)
|
||||
|
|
261
MySQL.m
261
MySQL.m
|
@ -9,40 +9,36 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSTimeZone.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSCalendarDate.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSNull.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
|
||||
#include <mysql/mysql.h>
|
||||
|
@ -62,12 +58,12 @@ static NSNull *null = nil;
|
|||
{
|
||||
if (future == nil)
|
||||
{
|
||||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
future = [NSCalendarDate dateWithString: @"9999-01-01 00:00:00 +0000"
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
[future retain];
|
||||
RETAIN(future);
|
||||
null = [NSNull null];
|
||||
[null retain];
|
||||
RETAIN(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,11 +97,9 @@ static NSNull *null = nil;
|
|||
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Connect to '%@' as %@",
|
||||
[self database], [self name]];
|
||||
[self debug: @"Connect to '%@' as %@", [self database], [self name]];
|
||||
}
|
||||
extra = mysql_init(0);
|
||||
mysql_options(connection, MYSQL_SET_CHARSET_NAME, "utf8");
|
||||
if (mysql_real_connect(connection,
|
||||
[host UTF8String],
|
||||
[[self user] UTF8String],
|
||||
|
@ -113,13 +107,23 @@ static NSNull *null = nil;
|
|||
[dbase UTF8String],
|
||||
[port intValue],
|
||||
NULL,
|
||||
CLIENT_MULTI_STATEMENTS) == 0)
|
||||
0
|
||||
) == 0)
|
||||
{
|
||||
[self debug: @"Error connecting to '%@' (%@) - %s",
|
||||
[self name], [self database], mysql_error(connection)];
|
||||
mysql_close(connection);
|
||||
extra = 0;
|
||||
}
|
||||
#if 0
|
||||
else if (mysql_query(connection, "SET CHARACTER SET utf8") != 0)
|
||||
{
|
||||
[self debug: @"Error setting utf8 support for '%@' (%@) - %s",
|
||||
[self name], [self database], mysql_error(connection)];
|
||||
mysql_close(connection);
|
||||
extra = 0;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
connected = YES;
|
||||
|
@ -173,30 +177,28 @@ static NSNull *null = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
NSString *stmt;
|
||||
NSInteger rowCount = 0;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *stmt;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
|
||||
stmt = [info objectAtIndex: 0];
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
const char *statement;
|
||||
unsigned length;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
|
@ -208,38 +210,14 @@ static NSNull *null = nil;
|
|||
statement = [self insertBLOBs: info
|
||||
intoStatement: statement
|
||||
length: length
|
||||
withMarker: "'?'''?'"
|
||||
length: 7
|
||||
withMarker: "'''"
|
||||
length: 3
|
||||
giving: &length];
|
||||
|
||||
if (mysql_real_query(connection, statement, length) != 0)
|
||||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"%s", mysql_error(connection)];
|
||||
if (mysql_ping(connection) == 0)
|
||||
{
|
||||
[NSException raise: SQLException format: @"%@", s];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLConnectionException format: @"%@", s];
|
||||
}
|
||||
}
|
||||
/* See how many rows were modified.
|
||||
*/
|
||||
rowCount = mysql_affected_rows(connection);
|
||||
/* discard any results.
|
||||
*/
|
||||
result = mysql_store_result(connection);
|
||||
if (result != 0) mysql_free_result(result);
|
||||
while (mysql_more_results(connection))
|
||||
{
|
||||
if (mysql_next_result(connection) == 0)
|
||||
{
|
||||
result = mysql_store_result(connection);
|
||||
if (result != 0) mysql_free_result(result);
|
||||
}
|
||||
[NSException raise: SQLException format: @"%s",
|
||||
mysql_error(connection)];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
|
@ -248,21 +226,20 @@ static NSNull *null = nil;
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return rowCount;
|
||||
DESTROY(arp);
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -290,16 +267,14 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
recordType: (id)rtype
|
||||
listType: (id)ltype
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSMutableArray *records = nil;
|
||||
MYSQL_RES *result = 0;
|
||||
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -311,7 +286,7 @@ static unsigned int trim(char *str)
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
|
@ -333,7 +308,7 @@ static unsigned int trim(char *str)
|
|||
keys[i] = [NSString stringWithUTF8String: (char*)fields[i].name];
|
||||
}
|
||||
|
||||
records = [[ltype alloc] initWithCapacity: recordCount];
|
||||
records = [[NSMutableArray alloc] initWithCapacity: recordCount];
|
||||
for (i = 0; i < recordCount; i++)
|
||||
{
|
||||
SQLRecord *record;
|
||||
|
@ -361,55 +336,60 @@ static unsigned int trim(char *str)
|
|||
{
|
||||
case FIELD_TYPE_TIMESTAMP:
|
||||
{
|
||||
char b[32];
|
||||
NSString *f;
|
||||
NSString *s;
|
||||
|
||||
s = [[NSString alloc] initWithBytes: p
|
||||
length: size encoding: NSASCIIStringEncoding];
|
||||
if (size > 14)
|
||||
{
|
||||
size = 19;
|
||||
f = @"%Y-%m-%d %H:%M:%S %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 14)
|
||||
{
|
||||
f = @"%Y%m%d%H%M%S %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y%m%d%H%M%S"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 12)
|
||||
{
|
||||
f = @"%y%m%d%H%M%S %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H%M%S"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 10)
|
||||
{
|
||||
f = @"%y%m%d%H%M %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H%M"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 8)
|
||||
{
|
||||
f = @"%y%m%d%H %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d%H"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 6)
|
||||
{
|
||||
f = @"%y%m%d %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m%d"
|
||||
locale: nil];
|
||||
}
|
||||
else if (size == 4)
|
||||
{
|
||||
f = @"%y%m %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y%m"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
f = @"%y %z";
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%y"
|
||||
locale: nil];
|
||||
}
|
||||
strncpy(b, (char*)p, size);
|
||||
strncpy(b + size, (char*)" +0000", 6);
|
||||
s = [[NSString alloc] initWithBytes: b
|
||||
length: size + 6
|
||||
encoding: NSASCIIStringEncoding];
|
||||
v = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: f
|
||||
locale: nil];
|
||||
RELEASE(s);
|
||||
[v setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
if ([self debugging] > 1)
|
||||
[self debug: @"Parsed '%@' as '%@'\n", s, v];
|
||||
[s release];
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -421,49 +401,28 @@ static unsigned int trim(char *str)
|
|||
case FIELD_TYPE_TINY_BLOB:
|
||||
case FIELD_TYPE_MEDIUM_BLOB:
|
||||
case FIELD_TYPE_LONG_BLOB:
|
||||
if (63 == fields[j].charsetnr)
|
||||
{
|
||||
v = [NSData dataWithBytes: p length: size];
|
||||
}
|
||||
else
|
||||
{
|
||||
v = [[[NSString alloc] initWithBytes: p
|
||||
length: size
|
||||
encoding: NSUTF8StringEncoding] autorelease];
|
||||
}
|
||||
v = [NSData dataWithBytes: p length: size];
|
||||
break;
|
||||
|
||||
default:
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim((char*)p);
|
||||
}
|
||||
trim((char*)p);
|
||||
v = [NSString stringWithUTF8String: (char*)p];
|
||||
break;
|
||||
}
|
||||
}
|
||||
values[j] = v;
|
||||
}
|
||||
record = [rtype newWithValues: values
|
||||
keys: keys
|
||||
count: fieldCount];
|
||||
record = [SQLRecord newWithValues: values
|
||||
keys: keys
|
||||
count: fieldCount];
|
||||
[records addObject: record];
|
||||
[record release];
|
||||
RELEASE(record);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"%s", mysql_error(connection)];
|
||||
if (mysql_ping(connection) == 0)
|
||||
{
|
||||
[NSException raise: SQLException format: @"%@", s];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: SQLConnectionException format: @"%@", s];
|
||||
}
|
||||
[NSException raise: SQLException format: @"%s",
|
||||
mysql_error(connection)];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
|
@ -472,7 +431,7 @@ static unsigned int trim(char *str)
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
|
@ -483,20 +442,19 @@ static unsigned int trim(char *str)
|
|||
{
|
||||
mysql_free_result(result);
|
||||
}
|
||||
[records release];
|
||||
records = nil;
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
DESTROY(records);
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
DESTROY(arp);
|
||||
if (result != 0)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
}
|
||||
return [records autorelease];
|
||||
return AUTORELEASE(records);
|
||||
}
|
||||
|
||||
- (unsigned) copyEscapedBLOB: (NSData*)blob into: (void*)buf
|
||||
|
@ -549,38 +507,5 @@ static unsigned int trim(char *str)
|
|||
return length;
|
||||
}
|
||||
|
||||
- (NSString*) quote: (id)obj
|
||||
{
|
||||
/* MySQL doesn't support timezones ... convert dates to simple GMT.
|
||||
*/
|
||||
if ([obj isKindOfClass: [NSDate class]] == YES)
|
||||
{
|
||||
NSString *fmt = nil;
|
||||
static NSTimeZone *gmt = nil;
|
||||
|
||||
if (nil == gmt)
|
||||
{
|
||||
gmt = [[NSTimeZone timeZoneForSecondsFromGMT: 0] retain];
|
||||
}
|
||||
if ([obj isKindOfClass: [NSCalendarDate class]] == YES)
|
||||
{
|
||||
fmt = [obj calendarFormat];
|
||||
if ([fmt length] > 17)
|
||||
{
|
||||
fmt = nil; // bad format ... had timezone
|
||||
}
|
||||
}
|
||||
if (nil == fmt)
|
||||
{
|
||||
fmt = @"%Y-%m-%d %H:%M:%S";
|
||||
}
|
||||
fmt = [NSString stringWithFormat: @"'%@'", fmt];
|
||||
return [obj descriptionWithCalendarFormat: fmt
|
||||
timeZone: gmt
|
||||
locale: nil];
|
||||
}
|
||||
return [super quote: obj];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
271
Oracle.pm
271
Oracle.pm
|
@ -10,16 +10,16 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
|
@ -216,7 +216,7 @@ void SQLClientOracleErrorHandler()
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char *statement;
|
||||
|
@ -240,7 +240,7 @@ void SQLClientOracleErrorHandler()
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"(Oracle) Unable to connect to database"];
|
||||
|
@ -273,7 +273,7 @@ void SQLClientOracleErrorHandler()
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
/*
|
||||
* remove line number information from database exception message
|
||||
|
@ -300,7 +300,6 @@ void SQLClientOracleErrorHandler()
|
|||
}
|
||||
NS_ENDHANDLER
|
||||
DESTROY(arp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static unsigned int trim(char *str)
|
||||
|
@ -327,7 +326,7 @@ static unsigned int trim(char *str)
|
|||
return (str - start);
|
||||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt recordClass: (Class)rClass
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
int count;
|
||||
|
@ -369,7 +368,7 @@ static unsigned int trim(char *str)
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"(Oracle) Unable to connect to database"];
|
||||
|
@ -554,10 +553,7 @@ static unsigned int trim(char *str)
|
|||
|
||||
/* \0-pad the string. */
|
||||
aString[octetLength] = '\0';
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim (aString);
|
||||
}
|
||||
trim (aString);
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free(aString);
|
||||
break;
|
||||
|
@ -588,10 +584,7 @@ static unsigned int trim(char *str)
|
|||
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
|
||||
:aString = DATA;
|
||||
aString[octetLength] = '\0';
|
||||
if (YES == _shouldTrim)
|
||||
{
|
||||
trim (aString);
|
||||
}
|
||||
trim (aString);
|
||||
v = [NSString stringWithUTF8String: aString];
|
||||
free (aString);
|
||||
NSLog(@"(Oracle) Unknown data type (%d) for '%s': '%@'",
|
||||
|
@ -604,9 +597,9 @@ static unsigned int trim(char *str)
|
|||
keys[index - 1] = [NSString stringWithUTF8String:
|
||||
fieldName];
|
||||
}
|
||||
record = [rClass newWithValues: values
|
||||
keys: keys
|
||||
count: count];
|
||||
record = [SQLRecord newWithValues: values
|
||||
keys: keys
|
||||
count: count];
|
||||
[records addObject: record];
|
||||
RELEASE(record);
|
||||
}
|
||||
|
@ -651,7 +644,7 @@ static unsigned int trim(char *str)
|
|||
}
|
||||
if ([e isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
@ -674,7 +667,7 @@ static unsigned int trim(char *str)
|
|||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
_inTransaction = NO;
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -899,15 +892,14 @@ static unsigned int trim(char *str)
|
|||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from a database character buffer to an NSDate.
|
||||
*/
|
||||
- (NSDate*) dbToDateFromBuffer: (char*)b length: (int)l
|
||||
{
|
||||
char buf[l+32]; /* Allow space to expand buffer. */
|
||||
NSCalendarDate *d;
|
||||
BOOL milliseconds = NO;
|
||||
BOOL timezone = NO;
|
||||
NSString *s;
|
||||
int i;
|
||||
int e;
|
||||
char buf[l+32]; /* Allow space to expend buffer. */
|
||||
NSString *s;
|
||||
int i;
|
||||
|
||||
memcpy(buf, b, l);
|
||||
b = buf;
|
||||
|
@ -930,153 +922,98 @@ static unsigned int trim(char *str)
|
|||
|
||||
if (l == 10)
|
||||
{
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d"
|
||||
locale: nil];
|
||||
}
|
||||
|
||||
i = l;
|
||||
|
||||
/* Convert +/-HH:SS timezone to +/-HHSS
|
||||
*/
|
||||
if (i > 5 && b[i-3] == ':' && (b[i-6] == '+' || b[i-6] == '-'))
|
||||
{
|
||||
b[i-3] = b[i-2];
|
||||
b[i-2] = b[i-1];
|
||||
b[--i] = '\0';
|
||||
}
|
||||
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
e = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
timezone = YES;
|
||||
e = i;
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
i = l;
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '+' || b[i] == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (b[i] == ':' || b[i] == ' ')
|
||||
{
|
||||
i = 0;
|
||||
break; /* No time zone found */
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
int e = i;
|
||||
|
||||
/*
|
||||
* Ensure we have a four digit timezone value.
|
||||
*/
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone ... append zero minutes
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes ... remove it
|
||||
b[i+3] = b[i+4];
|
||||
b[i+4] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isdigit(b[i-1]))
|
||||
{
|
||||
/*
|
||||
* Make space between seconds and timezone.
|
||||
*/
|
||||
memmove(&b[i+1], &b[i], l - i);
|
||||
b[i++] = ' ';
|
||||
b[++l] = '\0';
|
||||
}
|
||||
|
||||
/* kludge for timestamps with fractional second information.
|
||||
* Force it to 3 digit millisecond */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
milliseconds = YES;
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+3], &b[i], e-i);
|
||||
l += 3;
|
||||
memcpy(&b[i], "000", 3);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+2], &b[i], e-i);
|
||||
l += 2;
|
||||
memcpy(&b[i], "00", 2);
|
||||
}
|
||||
i++;
|
||||
if (!isdigit(b[i]))
|
||||
{
|
||||
memmove(&b[i+1], &b[i], e-i);
|
||||
l += 1;
|
||||
memcpy(&b[i], "0", 1);
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0 && i < e)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
}
|
||||
b[l] = '\0';
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [NSString stringWithUTF8String: b];
|
||||
if (isdigit(b[i+1]) && isdigit(b[i+2]))
|
||||
{
|
||||
if (b[i+3] == '\0')
|
||||
{
|
||||
// Two digit time zone
|
||||
b[l++] = '0';
|
||||
b[l++] = '0';
|
||||
b[l] = '\0';
|
||||
}
|
||||
else if (b[i+3] == ':')
|
||||
{
|
||||
// Zone with colon before minutes
|
||||
b[i+3] = b[i+4];
|
||||
b[i+5] = b[i+5];
|
||||
b[--l] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (YES == timezone)
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
/* FIXME ... horrible kludge for postgres returning timestamps with
|
||||
fractional second information. */
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (b[i] == '.')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
memmove(&b[i], &b[e], l - e);
|
||||
l -= (e - i);
|
||||
b[l] = '\0';
|
||||
}
|
||||
}
|
||||
else if (l == 19)
|
||||
{
|
||||
/* A date and time without a timezone ... assume gmt */
|
||||
strcat(b, " +0000");
|
||||
l += 6;
|
||||
}
|
||||
|
||||
|
||||
/* If it's a simple date (YYYY-MM-DD) append time for start of day. */
|
||||
if (l == 10)
|
||||
{
|
||||
strcat(b, " 00:00:00 +0000");
|
||||
l += 15;
|
||||
}
|
||||
if (l == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
s = [self dbToStringFromBuffer: b length: l];
|
||||
return [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (milliseconds == YES)
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S.%F"
|
||||
locale: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [NSCalendarDate dateWithString: s
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S"
|
||||
locale: nil];
|
||||
}
|
||||
}
|
||||
[d setCalendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
1830
Postgres.m
1830
Postgres.m
File diff suppressed because it is too large
Load diff
84
RELEASE_NOTES
Normal file
84
RELEASE_NOTES
Normal file
|
@ -0,0 +1,84 @@
|
|||
|
||||
This is the 1.2 release of the 'sqlclient' library (version 1.2.0)
|
||||
|
||||
|
||||
Scope
|
||||
====
|
||||
This library is a lightweight database abstraction layer designed to make
|
||||
it simple to write high performance applications using SQL databases from
|
||||
Objective-C.
|
||||
The library consists of a semi-abstract superclass doing much of the work
|
||||
and allowing extremely simple database specific bundles to be written to
|
||||
talk to particular database servers. It comes with backend bundles for
|
||||
Postgres, MySQL, and SQLite (plus an untested Oracle bundle).
|
||||
|
||||
|
||||
Platforms
|
||||
=========
|
||||
GNUstep gnu/linux
|
||||
GNUstep windows/mingw32 (only tested for SQLite)
|
||||
Cocoa ... reported to work.
|
||||
|
||||
|
||||
New in this release
|
||||
===================
|
||||
Removed WebServe rinto its own library
|
||||
Supports in-memory caching using GSCache from performance library
|
||||
SQLite support
|
||||
Can quote arrays and sets of database values.
|
||||
Minor fixes.
|
||||
Windows/Mingw32 support ... NB you have to build with ...
|
||||
LINKSQLCLIENT=1 make
|
||||
or
|
||||
LINKSQLCLIENT=1 make debug=yes
|
||||
depending on whether you build with debug or not.
|
||||
|
||||
|
||||
Contents
|
||||
========
|
||||
SQLClient
|
||||
Provides managements of connections to (multiple) database backends.
|
||||
Each instance represents a database connection.
|
||||
|
||||
SQLClient(Caching)
|
||||
Category providing methods for handling locally cached query results.
|
||||
|
||||
SQLRecord
|
||||
Represents a record in the database
|
||||
|
||||
SQLTransaction
|
||||
Represents a sequence of operations to be performed as a single transaction.
|
||||
Statements may be added to transactions and transactions may be merged.
|
||||
|
||||
SQLClientECPG
|
||||
Backend bundle using embedded SQL for Postgres.
|
||||
|
||||
SQLClientMySQL
|
||||
Backend bundle handling MySQL database.
|
||||
|
||||
SQLClientOracle
|
||||
Backend bundle using embedded SQL for Oracle.
|
||||
|
||||
SQLClientPostgres
|
||||
Backend bundle handling Postgres database.
|
||||
|
||||
SQLClientSQLite
|
||||
Backend bundle handling SQLite database.
|
||||
|
||||
|
||||
Location
|
||||
========
|
||||
Available from the gnustep subversion repository.
|
||||
|
||||
Browse at http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/tags/1.2.0
|
||||
|
||||
Download with:
|
||||
svn co svn://svn.gna.org/svn/gnustep/libs/sqlclient/tags/1.2.0 sqlclient
|
||||
|
||||
|
||||
Bugs
|
||||
====
|
||||
Please report bugs to https://savannah.gnu.org/bugs/?group=gnustep selecting
|
||||
'Libraries' as the catagory. NB. please check to see if a bug has already
|
||||
been reported before submitting a new one.
|
||||
|
1591
SQLClient.h
1591
SQLClient.h
File diff suppressed because it is too large
Load diff
|
@ -72,7 +72,7 @@
|
|||
"add:with:",
|
||||
"append:",
|
||||
"count",
|
||||
"owner",
|
||||
"db",
|
||||
"execute",
|
||||
"reset"
|
||||
);
|
||||
|
|
5952
SQLClient.m
5952
SQLClient.m
File diff suppressed because it is too large
Load diff
1526
SQLClientPool.m
1526
SQLClientPool.m
File diff suppressed because it is too large
Load diff
96
SQLite.m
96
SQLite.m
|
@ -1,6 +1,6 @@
|
|||
/* -*-objc-*- */
|
||||
|
||||
/** Implementation of SQLClientSQLite for GNUStep
|
||||
/** Implementation of SQLClientPostgres for GNUStep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
@ -9,43 +9,38 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSCalendarDate.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSNull.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define SQLCLIENT_PRIVATE @public
|
||||
|
||||
#include "SQLClient.h"
|
||||
#include <string.h>
|
||||
#include <sqlite3.h>
|
||||
|
||||
@interface SQLClientSQLite : SQLClient
|
||||
|
@ -132,15 +127,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (NSInteger) backendExecute: (NSArray*)info
|
||||
- (void) backendExecute: (NSArray*)info
|
||||
{
|
||||
NSString *stmt;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *stmt;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
|
||||
stmt = [info objectAtIndex: 0];
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -155,7 +150,7 @@
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute statement %@",
|
||||
|
@ -167,8 +162,8 @@
|
|||
statement = [self insertBLOBs: info
|
||||
intoStatement: statement
|
||||
length: length
|
||||
withMarker: "'?'''?'"
|
||||
length: 7
|
||||
withMarker: "'''"
|
||||
length: 3
|
||||
giving: &length];
|
||||
|
||||
result = sqlite3_exec((sqlite3 *)extra, statement, 0, 0, &err);
|
||||
|
@ -183,33 +178,30 @@
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return -1;
|
||||
DESTROY(arp);
|
||||
}
|
||||
|
||||
- (NSMutableArray*) backendQuery: (NSString*)stmt
|
||||
recordType: (id)rtype
|
||||
listType: (id)ltype
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSMutableArray *records = [[ltype alloc] initWithCapacity: 2];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSMutableArray *records = [[NSMutableArray alloc] init];
|
||||
|
||||
if ([stmt length] == 0)
|
||||
{
|
||||
[arp release];
|
||||
RELEASE (arp);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Statement produced null string"];
|
||||
}
|
||||
|
@ -224,7 +216,7 @@
|
|||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([self connect] == NO)
|
||||
if ([self backendConnect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to run query %@",
|
||||
|
@ -289,11 +281,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
record = [rtype newWithValues: values
|
||||
keys: keys
|
||||
count: columns];
|
||||
record = [SQLRecord newWithValues: values
|
||||
keys: keys
|
||||
count: columns];
|
||||
[records addObject: record];
|
||||
[record release];
|
||||
RELEASE(record);
|
||||
}
|
||||
while ((result = sqlite3_step(prepared)) == SQLITE_ROW);
|
||||
}
|
||||
|
@ -310,21 +302,21 @@
|
|||
|
||||
if ([n isEqual: SQLConnectionException] == YES)
|
||||
{
|
||||
[self disconnect];
|
||||
[self backendDisconnect];
|
||||
}
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
[self debug: @"Error executing statement:\n%@\n%@",
|
||||
stmt, localException];
|
||||
}
|
||||
[localException retain];
|
||||
[arp release];
|
||||
[localException autorelease];
|
||||
RETAIN (localException);
|
||||
RELEASE (arp);
|
||||
AUTORELEASE (localException);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[arp release];
|
||||
return [records autorelease];
|
||||
DESTROY(arp);
|
||||
return AUTORELEASE(records);
|
||||
}
|
||||
|
||||
static char hex[16] = "0123456789ABCDEF";
|
||||
|
|
1326
config.guess
vendored
Executable file
1326
config.guess
vendored
Executable file
File diff suppressed because it is too large
Load diff
106
config.h.in
106
config.h.in
|
@ -1,117 +1,13 @@
|
|||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <ecpglib.h> header file. */
|
||||
#undef HAVE_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <jni.h> header file. */
|
||||
#undef HAVE_JNI_H
|
||||
|
||||
/* Define to 1 if you have the `ecpg' library (-lecpg). */
|
||||
#undef HAVE_LIBECPG
|
||||
|
||||
/* Define to 1 if you have the `jvm' library (-ljvm). */
|
||||
#undef HAVE_LIBJVM
|
||||
|
||||
/* Define to 1 if you have the `mysqlclient' library (-lmysqlclient). */
|
||||
#undef HAVE_LIBMYSQLCLIENT
|
||||
|
||||
/* Define to 1 if you have the `pq' library (-lpq). */
|
||||
#undef HAVE_LIBPQ
|
||||
|
||||
/* Define to 1 if you have the <libpq-fe.h> header file. */
|
||||
#undef HAVE_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the `sqlite3' library (-lsqlite3). */
|
||||
#undef HAVE_LIBSQLITE3
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <mysql/mysql.h> header file. */
|
||||
#undef HAVE_MYSQL_MYSQL_H
|
||||
|
||||
/* Define to 1 if you have the `PQescapeStringConn' function. */
|
||||
#undef HAVE_PQESCAPESTRINGCONN
|
||||
|
||||
/* Define to 1 if you have the <sqlite3.h> header file. */
|
||||
#undef HAVE_SQLITE3_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the </usr/include/pgsql/ecpglib.h> header file. */
|
||||
#undef HAVE__USR_INCLUDE_PGSQL_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/pgsql/libpq-fe.h> header file. */
|
||||
#undef HAVE__USR_INCLUDE_PGSQL_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/postgresql/8.0/ecpglib.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_INCLUDE_POSTGRESQL_8_0_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/postgresql/8.0/libpq-fe.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_INCLUDE_POSTGRESQL_8_0_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/postgresql/ecpglib.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_INCLUDE_POSTGRESQL_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/include/postgresql/libpq-fe.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_INCLUDE_POSTGRESQL_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the </usr/local/include/pgsql/ecpglib.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_LOCAL_INCLUDE_PGSQL_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/local/include/pgsql/libpq-fe.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_LOCAL_INCLUDE_PGSQL_LIBPQ_FE_H
|
||||
|
||||
/* Define to 1 if you have the </usr/local/pgsql/include/ecpglib.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_LOCAL_PGSQL_INCLUDE_ECPGLIB_H
|
||||
|
||||
/* Define to 1 if you have the </usr/local/pgsql/include/libpq-fe.h> header
|
||||
file. */
|
||||
#undef HAVE__USR_LOCAL_PGSQL_INCLUDE_LIBPQ_FE_H
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
ECPG=@ECPG@
|
||||
JDBC=@JDBC@
|
||||
JDBC_VM_LIBS=@JDBC_VM_LIBS@
|
||||
JDBC_VM_LIBDIRS=@JDBC_VM_LIBDIRS@
|
||||
MYSQL=@MYSQL@
|
||||
SQLITE=@SQLITE@
|
||||
ORACLE_HOME=@ORACLE_HOME@
|
||||
|
|
1451
config.sub
vendored
Executable file
1451
config.sub
vendored
Executable file
File diff suppressed because it is too large
Load diff
594
configure.ac
594
configure.ac
|
@ -3,31 +3,25 @@ dnl Process this file with autoconf to produce configure.
|
|||
AC_INIT(SQLClient.h)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
if test -z "$GNUSTEP_MAKEFILES"; then
|
||||
GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
|
||||
export GNUSTEP_MAKEFILES
|
||||
fi
|
||||
|
||||
if test -z "$GNUSTEP_MAKEFILES"; then
|
||||
AC_MSG_ERROR([You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!])
|
||||
else
|
||||
. $GNUSTEP_MAKEFILES/GNUstep.sh
|
||||
fi
|
||||
|
||||
if test "x$GNUSTEP_HOST_OS" = "x"; then
|
||||
GNUSTEP_HOST_OS=`gnustep-config --variable=GNUSTEP_HOST_OS`
|
||||
GNUSTEP_HOST_CPU=`gnustep-config --variable=GNUSTEP_HOST_CPU`
|
||||
# Fetch basic path information from config file.
|
||||
GNUSTEP_CONFIG_FILE=`grep '^GNUSTEP_CONFIG_FILE *=' $GNUSTEP_MAKEFILES/config.make | sed -e 's/GNUSTEP_CONFIG_FILE *= *\(.*\)/\1/'`
|
||||
|
||||
# This is for backwards compatibility with older gnustep releases,
|
||||
# which have no GNUSTEP_CONFIG_FILE -- but it can be dropped in a year
|
||||
# or so ;-) -- NB: We could do better here, like checking the
|
||||
# GNUSTEP_MAKE_VERSION or emitting a warning if no config file is
|
||||
# found etc.
|
||||
if test -n "$GNUSTEP_CONFIG_FILE"; then
|
||||
. "$GNUSTEP_CONFIG_FILE"
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
AC_ARG_WITH(additional-include, [
|
||||
--with-additional-include=flags
|
||||
Specifies additional include compiler flags to use.
|
||||
If configure can not find your database library headers,
|
||||
you may want to use this flag to help it find them. For
|
||||
example:
|
||||
--with-additional-include=-I/usr/local/include
|
||||
],
|
||||
AC_ARG_WITH(additional-include,
|
||||
[ --with-additional-include=flags specify additional include dirs to use],
|
||||
additional_include="$withval", additional_include="no")
|
||||
|
||||
if test "$additional_include" != "no"; then
|
||||
|
@ -35,14 +29,8 @@ if test "$additional_include" != "no"; then
|
|||
INCD="$INCD $additional_include"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(additional-lib, [
|
||||
--with-additional-lib=flags
|
||||
Specifies additional library compiler flags to use.
|
||||
If configure can not find your database libraries,
|
||||
you may want to use this flag to help it find them. For
|
||||
example:
|
||||
--with-additional-lib=-L/usr/local/lib/mysql
|
||||
],
|
||||
AC_ARG_WITH(additional-lib,
|
||||
[ --with-additional-lib=flags specify additional lib dirs to use],
|
||||
additional_lib="$withval", additional_lib="no")
|
||||
|
||||
if test "$additional_lib" != "no"; then
|
||||
|
@ -50,452 +38,187 @@ if test "$additional_lib" != "no"; then
|
|||
LIBD="$LIBD $additional_lib"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(postgres-dir, [
|
||||
--with-postgres-dir=PATH
|
||||
Specifies the postgres installation dir; configure
|
||||
will add the appropriate additional include and lib
|
||||
flags. Useful when you installed postgres in some
|
||||
unusual place and want to help configure find it. For
|
||||
example:
|
||||
--with-postgres-dir=/usr/local/pgsql
|
||||
(which is equivalent to
|
||||
--with-additional-include=-L/usr/local/pgsql/include
|
||||
--with-additional-lib=-L/usr/local/pgsql/lib)
|
||||
],
|
||||
echo "Postgres development support"
|
||||
AC_ARG_WITH(postgres-dir,
|
||||
[ --with-postgres-dir=PATH specify postgres installation dir],
|
||||
postgres_topdir="$withval", postgres_topdir="no")
|
||||
|
||||
if test "$postgres_topdir" != "no"; then
|
||||
CPPFLAGS="$CPPFLAGS -I$postgres_topdir/include -L$postgres_topdir/lib"
|
||||
INCD="$INCD -I$postgres_topdir/include"
|
||||
LIBD="$LIBD -L$postgres_topdir/lib"
|
||||
else
|
||||
PGINC=`pg_config --includedir`
|
||||
if test "$PGINC" != ""; then
|
||||
CPPFLAGS="$CPPFLAGS -I$PGINC"
|
||||
INCD="$INCD -I$PGINC"
|
||||
fi
|
||||
PGLIB=`pg_config --libdir`
|
||||
if test "$PGLIB" != ""; then
|
||||
CPPFLAGS="$CPPFLAGS -L$PGLIB"
|
||||
LIBD="$LIBD -I$PGLIB"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Call AC_CHECK_HEADERS here as a workaround for a configure bug/feature
|
||||
# which messes up all subsequent tests if the first occurrence in the
|
||||
# file does not get called ... as would otherwise be the case if jdbc
|
||||
# support is disabled.
|
||||
AC_CHECK_HEADERS(stdio.h)
|
||||
|
||||
AC_MSG_CHECKING([if Jdbc support was manually disabled])
|
||||
AC_ARG_ENABLE(jdbc-bundle, [
|
||||
--disable-jdbc-bundle
|
||||
Disable creating the Jdbc bundle.
|
||||
Use this option to force the Jdbc bundle not to be built
|
||||
even if the Jdbc libraries look like being present.
|
||||
],
|
||||
ac_cv_jdbc_bundle=$enableval,
|
||||
ac_cv_jdbc_bundle="yes")
|
||||
|
||||
if test "$ac_cv_jdbc_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
AC_CHECK_HEADERS(mysql/mysql.h)
|
||||
if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
|
||||
MYSQL=yes
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
# Get likely subdirectory for system specific java include
|
||||
case "$GNUSTEP_HOST_OS" in
|
||||
bsdi*) _JNI_SUBDIR="bsdos";;
|
||||
linux*) _JNI_SUBDIR="linux";;
|
||||
osf*) _JNI_SUBDIR="alpha";;
|
||||
solaris*) _JNI_SUBDIR="solaris";;
|
||||
mingw*) _JNI_SUBDIR="win32";;
|
||||
cygwin*) _JNI_SUBDIR="win32";;
|
||||
*) _JNI_SUBDIR="genunix";;
|
||||
esac
|
||||
|
||||
AC_ARG_WITH(jre-architecture, [
|
||||
--with-jre-architecture=value
|
||||
Specifies the CPU architecture to use for the JRE
|
||||
(only used when building the JDBC module). Example
|
||||
values are i386, amd64 and sparc.
|
||||
],
|
||||
jre_architecture="$withval", jre_architecture="")
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/include -I$JAVA_HOME/include/$_JNI_SUBDIR"
|
||||
AC_CHECK_HEADERS(jni.h)
|
||||
if test "$ac_cv_header_jni_h" = "yes"; then
|
||||
JDBC_VM_LIBS="-ljvm"
|
||||
jre_lib="$JAVA_HOME/jre/lib"
|
||||
|
||||
if test "$jre_architecture" = ""; then
|
||||
|
||||
# If on a 32/64bit system and compiling for the 64bit model
|
||||
# adjust the cpu type to be the 64bit version
|
||||
case "$CFLAGS" in
|
||||
*-m64*)
|
||||
if test "$GNUSTEP_HOST_CPU" = "ix86"; then
|
||||
_CPU="x86_64"
|
||||
else
|
||||
_CPU="$GNUSTEP_HOST_CPU"
|
||||
fi;;
|
||||
*) _CPU="$GNUSTEP_HOST_CPU";;
|
||||
esac
|
||||
case "$_CPU" in
|
||||
ix86) JAVA_CPU=i386;;
|
||||
x86_64) JAVA_CPU=amd64;;
|
||||
sparc) JAVA_CPU=sparc;;
|
||||
*) JAVA_CPU=i386;;
|
||||
esac
|
||||
else
|
||||
JAVA_CPU="$jre_architecture"
|
||||
fi
|
||||
|
||||
jre_cpu="$jre_lib/$JAVA_CPU"
|
||||
JDBC_VM_LIBDIRS="-L$jre_cpu/server"
|
||||
CFLAGS="$CFLAGS $JDBC_VM_LIBDIRS"
|
||||
AC_CHECK_LIB(jvm,JNI_CreateJavaVM)
|
||||
if test "$ac_cv_lib_jvm_JNI_CreateJavaVM" = "yes"; then
|
||||
INCD="$INCD -I$JAVA_HOME/include -I$JAVA_HOME/include/$_JNI_SUBDIR"
|
||||
JDBC=yes
|
||||
else
|
||||
JDBC=
|
||||
JDBC_VM_LIBS=
|
||||
JDBC_VM_LIBDIRS=
|
||||
echo "**********************************************"
|
||||
echo "Unable to locate jvm library (is it installed)"
|
||||
echo "**********************************************"
|
||||
fi
|
||||
else
|
||||
JDBC=
|
||||
JDBC_VM_LIBS=
|
||||
JDBC_VM_LIBDIRS=
|
||||
echo "*********************************************"
|
||||
echo "Unable to locate jni header (is it installed)"
|
||||
echo "*********************************************"
|
||||
fi
|
||||
AC_SUBST(JDBC)
|
||||
AC_SUBST(JDBC_VM_LIBS)
|
||||
AC_SUBST(JDBC_VM_LIBDIRS)
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
AC_MSG_CHECKING([if Mysql support was manually disabled])
|
||||
AC_ARG_ENABLE(mysql-bundle, [
|
||||
--disable-mysql-bundle
|
||||
Disable creating the Mysql bundle.
|
||||
Use this option to force the Mysql bundle not to be built
|
||||
even if the Mysql libraries look like being present.
|
||||
],
|
||||
ac_cv_mysql_bundle=$enableval,
|
||||
ac_cv_mysql_bundle="yes")
|
||||
|
||||
if test "$ac_cv_mysql_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
MYSQL=
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
AC_CHECK_HEADERS(mysql/mysql.h)
|
||||
if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
|
||||
MYSQL=yes
|
||||
else
|
||||
echo "*********************************************************"
|
||||
echo "Unable to locate mysqlclient headers (are they installed)"
|
||||
echo "*********************************************************"
|
||||
fi
|
||||
if test "$MYSQL" = "yes"; then
|
||||
AC_CHECK_LIB(mysqlclient,mysql_init)
|
||||
if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
|
||||
MYSQL=
|
||||
echo "*********************************************************"
|
||||
echo "Unable to locate mysqlclient headers (are they installed)"
|
||||
echo "*********************************************************"
|
||||
fi
|
||||
if test "$MYSQL" = "yes"; then
|
||||
if test -d /usr/lib/mysql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/mysql"
|
||||
LIBD="$LIBD -L/usr/lib/mysql"
|
||||
else
|
||||
if test -d /usr/local/lib/mysql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/mysql"
|
||||
LIBD="$LIBD -L/usr/local/lib/mysql"
|
||||
else
|
||||
if test -d /usr/local/mysql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/mysql/lib"
|
||||
LIBD="$LIBD -L/usr/local/mysql/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_CHECK_LIB(mysqlclient,mysql_init)
|
||||
if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
|
||||
MYSQL=
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate mysqlclient library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate mysqlclient library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(MYSQL)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([if Sqllite support was manually disabled])
|
||||
AC_ARG_ENABLE(sqllite-bundle, [
|
||||
--disable-sqllite-bundle
|
||||
Disable creating the Sqllite bundle.
|
||||
Use this option to force the Sqllite bundle not to be built
|
||||
even if the Sqllite libraries look like being present.
|
||||
],
|
||||
ac_cv_sqllite_bundle=$enableval,
|
||||
ac_cv_sqllite_bundle="yes")
|
||||
|
||||
if test "$ac_cv_sqllite_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
SQLLITE=
|
||||
AC_CHECK_HEADERS(sqlite3.h)
|
||||
if test "$ac_cv_header_sqlite3_h" = "yes"; then
|
||||
SQLITE=yes
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
AC_CHECK_HEADERS(sqlite3.h)
|
||||
if test "$ac_cv_header_sqlite3_h" = "yes"; then
|
||||
SQLITE=yes
|
||||
else
|
||||
SQLITE=
|
||||
echo "*****************************************************"
|
||||
echo "Unable to locate sqlite3 headers (are they installed)"
|
||||
echo "*****************************************************"
|
||||
fi
|
||||
if test "$SQLITE" = "yes"; then
|
||||
AC_CHECK_LIB(sqlite3,sqlite3_open)
|
||||
if test "$ac_cv_lib_sqlite3_sqlite3_open" != "yes"; then
|
||||
SQLITE=
|
||||
echo "*****************************************************"
|
||||
echo "Unable to locate sqlite3 headers (are they installed)"
|
||||
echo "*****************************************************"
|
||||
fi
|
||||
if test "$SQLITE" = "yes"; then
|
||||
AC_CHECK_LIB(sqlite3,sqlite3_open)
|
||||
if test "$ac_cv_lib_sqlite3_sqlite3_open" != "yes"; then
|
||||
SQLITE=
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate sqlite3 library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
echo "******************************************************"
|
||||
echo "Unable to locate sqlite3 library (is it installed)"
|
||||
echo "******************************************************"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(SQLITE)
|
||||
|
||||
AC_MSG_CHECKING([if Postgres support was manually disabled])
|
||||
AC_ARG_ENABLE(postgres-bundle, [
|
||||
--disable-postgres-bundle
|
||||
Disable creating the Postgres bundle.
|
||||
Use this option to force the Postgres bundle not to be built
|
||||
even if the Postgres libraries look like being present.
|
||||
],
|
||||
ac_cv_postgres_bundle=$enableval,
|
||||
ac_cv_postgres_bundle="yes")
|
||||
POSTGRES=
|
||||
|
||||
if test "$ac_cv_postgres_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
POSTGRES=
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(libpq-fe.h)
|
||||
if test "$ac_cv_header_libpq_fe_h" = "yes"; then
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(ecpglib.h)
|
||||
if test "$ac_cv_header_ecpglib_h" = "yes"; then
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start POSTGRES checks
|
||||
POSTGRES=
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(libpq-fe.h)
|
||||
if test "$ac_cv_header_libpq_fe_h" = "yes"; then
|
||||
POSTGRES=yes
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
echo "**************************************************************"
|
||||
echo "Unable to locate libpq (postgres) headers (are they installed)"
|
||||
echo "**************************************************************"
|
||||
fi
|
||||
if test "$ECPG" = ""; then
|
||||
echo "*************************************************************"
|
||||
echo "Unable to locate ecpg (postgres) headers (are they installed)"
|
||||
echo "*************************************************************"
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/pgsql/include/libpq-fe.h)
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/pgsql/include"
|
||||
POSTGRES=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = ""; then
|
||||
echo "**************************************************************"
|
||||
echo "Unable to locate libpq (postgres) headers (are they installed)"
|
||||
echo "**************************************************************"
|
||||
fi
|
||||
|
||||
if test "$POSTGRES" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/pgsql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
|
||||
LIBD="$LIBD -L/usr/local/pgsql/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
|
||||
POSTGRES=
|
||||
AC_CHECK_LIB(pq,PQclear)
|
||||
echo "******************************************************"
|
||||
if test "$ac_cv_lib_pq_PQclear" != "yes"; then
|
||||
echo "Unable to locate postgres pq library (is it installed)"
|
||||
echo "Unable to locate postgres pq library (is it installed)"
|
||||
else
|
||||
echo "Located postgres pq library, but it is too old to use!"
|
||||
echo "Located postgres pq library, but it is too old to use!"
|
||||
fi
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "******************************************************"
|
||||
else
|
||||
AC_CHECK_FUNCS(PQescapeStringConn)
|
||||
fi
|
||||
fi
|
||||
# End POSTGRES checks
|
||||
AC_CHECK_LIB(ecpg,ECPGconnect)
|
||||
if test "$ac_cv_lib_ecpg_ECPGconnect" != "yes"; then
|
||||
ECPG=
|
||||
echo "********************************************************"
|
||||
echo "Unable to locate postgres ecpg library (is it installed)"
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "********************************************************"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(POSTGRES)
|
||||
|
||||
AC_MSG_CHECKING([if ECPG (Old Postgres) support was manually disabled])
|
||||
AC_ARG_ENABLE(ecpg-bundle, [
|
||||
--disable-ecpg-bundle
|
||||
Disable creating the ECPG bundle.
|
||||
Use this option to force the ECPG bundle not to be built
|
||||
even if the Postgres libraries look like being present.
|
||||
],
|
||||
ac_cv_ecpg_bundle=$enableval,
|
||||
ac_cv_ecpg_bundle="yes")
|
||||
|
||||
if test "$ac_cv_ecpg_bundle" = "no"; then
|
||||
AC_MSG_RESULT([yes: disabled from the command-line])
|
||||
ECPG=
|
||||
else
|
||||
AC_MSG_RESULT([no: build if possible])
|
||||
|
||||
# Start ECPG checks
|
||||
ECPG=
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(ecpglib.h)
|
||||
if test "$ac_cv_header_ecpglib_h" = "yes"; then
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/postgresql/8.0/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/postgresql/8.0"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/include/pgsql/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/include/pgsql"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
AC_CHECK_HEADERS(/usr/local/pgsql/include/ecpglib.h)
|
||||
if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
|
||||
INCD="$INCD -I/usr/local/pgsql/include"
|
||||
ECPG=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ECPG" = ""; then
|
||||
echo "*************************************************************"
|
||||
echo "Unable to locate ecpg (postgres) headers (are they installed)"
|
||||
echo "*************************************************************"
|
||||
fi
|
||||
|
||||
if test "$ECPG" = "yes"; then
|
||||
# NICOLA - hack
|
||||
if test -d /usr/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/lib/pgsql ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
|
||||
LIBD="$LIBD -L/usr/local/lib/pgsql"
|
||||
else
|
||||
if test -d /usr/local/pgsql/lib ; then
|
||||
CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
|
||||
LIBD="$LIBD -L/usr/local/pgsql/lib"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(pq,PQfformat)
|
||||
AC_CHECK_LIB(ecpg,ECPGconnect)
|
||||
if test "$ac_cv_lib_ecpg_ECPGconnect" != "yes"; then
|
||||
ECPG=
|
||||
echo "********************************************************"
|
||||
echo "Unable to locate postgres ecpg library (is it installed)"
|
||||
echo "Perhaps you can try 'configure --with-postgres=dir=path'"
|
||||
echo "to point to the postgres version you wish to use."
|
||||
echo "********************************************************"
|
||||
fi
|
||||
fi
|
||||
# End ECPG checks
|
||||
fi
|
||||
AC_SUBST(ECPG)
|
||||
|
||||
|
||||
|
||||
ORACLE_HOME=
|
||||
AC_SUBST(ORACLE_HOME)
|
||||
|
||||
|
@ -503,13 +226,6 @@ AC_SUBST(INCD)
|
|||
AC_SUBST(LIBD)
|
||||
AC_SUBST(LIBS)
|
||||
|
||||
if test "$JDBC" = "yes"; then
|
||||
BUNDLE="The JDBC backend bundle will be built"
|
||||
else
|
||||
BUNDLE="The JDBC backend bundle will NOT be built"
|
||||
fi
|
||||
AC_MSG_RESULT(${BUNDLE})
|
||||
|
||||
if test "$MYSQL" = "yes"; then
|
||||
BUNDLE="The MySQL backend bundle will be built"
|
||||
else
|
||||
|
|
250
install-sh
Executable file
250
install-sh
Executable file
|
@ -0,0 +1,250 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
18
testECPG.m
18
testECPG.m
|
@ -7,29 +7,29 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SQLClient.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -109,7 +109,7 @@ main()
|
|||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ main()
|
|||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
338
testJDBC.m
338
testJDBC.m
|
@ -1,338 +0,0 @@
|
|||
/**
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: August 2006
|
||||
|
||||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date: 2006-05-25 12:34:03 +0100 (Thu, 25 May 2006) $ $Revision: 22982 $
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Performance/GSCache.h>
|
||||
#import "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
SQLRecord *record;
|
||||
unsigned char dbuf[256];
|
||||
unsigned int i;
|
||||
NSData *data;
|
||||
NSString *name;
|
||||
|
||||
defs = [NSUserDefaults standardUserDefaults];
|
||||
[defs registerDefaults:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"org.postgresql.Driver:jdbc:postgresql://localhost/template1",
|
||||
@"Database",
|
||||
@"postgres", @"User",
|
||||
@"postgres", @"Password",
|
||||
@"JDBC", @"ServerType",
|
||||
nil],
|
||||
@"test",
|
||||
nil],
|
||||
@"SQLClientReferences",
|
||||
nil]
|
||||
];
|
||||
|
||||
db = [SQLClient clientWithConfiguration: nil name: @"test"];
|
||||
[db connect];
|
||||
|
||||
if ((name = [defs stringForKey: @"Producer"]) != nil)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
[db execute: @"CREATE TABLE Queue ( "
|
||||
@"ID SERIAL, "
|
||||
@"Consumer CHAR(40) NOT NULL, "
|
||||
@"ServiceID INT NOT NULL, "
|
||||
@"Status CHAR(1) DEFAULT 'Q' NOT NULL, "
|
||||
@"Delivery TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, "
|
||||
@"Reference CHAR(128), "
|
||||
@"Destination CHAR(15) NOT NULL, "
|
||||
@"Payload CHAR(250) DEFAULT '' NOT NULL"
|
||||
@")",
|
||||
nil];
|
||||
[db execute:
|
||||
@"CREATE UNIQUE INDEX QueueIDX ON Queue (ID)",
|
||||
nil];
|
||||
[db execute:
|
||||
@"CREATE INDEX ServiceIDX ON Queue (ServiceID)",
|
||||
nil];
|
||||
[db execute:
|
||||
@"CREATE INDEX ConsumerIDX ON Queue (Consumer,Status,Delivery)",
|
||||
nil];
|
||||
[db execute:
|
||||
@"CREATE INDEX ReferenceIDX ON Queue (Reference,Consumer)",
|
||||
nil];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"%@", localException);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
NSLog(@"Start producing");
|
||||
for (i = 0; i < 100000; i++)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *destination = [NSString stringWithFormat: @"%d", i];
|
||||
NSString *sid = [NSString stringWithFormat: @"%d", i%100];
|
||||
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination, ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ", [db quote: destination], @", ", sid, @", ",
|
||||
@"'helo there'", @")", nil];
|
||||
[arp release];
|
||||
}
|
||||
NSLog(@"End producing");
|
||||
}
|
||||
else if ((name = [defs stringForKey: @"Consumer"]) != nil)
|
||||
{
|
||||
NSLog(@"Start consuming");
|
||||
for (i = 0; i < 100000;)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
unsigned count;
|
||||
int j;
|
||||
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
@" AND Status = 'Q' AND Delivery < CURRENT_TIMESTAMP",
|
||||
@" ORDER BY Delivery LIMIT 1000 FOR UPDATE" , nil];
|
||||
count = [records count];
|
||||
if (count == 0)
|
||||
{
|
||||
[db commit];
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
@" AND Status = 'Q' AND Delivery < CURRENT_TIMESTAMP",
|
||||
@" ORDER BY Delivery LIMIT 50 FOR UPDATE" , nil];
|
||||
count = [records count];
|
||||
if (count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
SQLRecord *record = [records objectAtIndex: j];
|
||||
NSString *reference = [record objectForKey: @"ID"];
|
||||
|
||||
[db execute: @"UPDATE Queue SET Status = 'S', Reference = ",
|
||||
[db quote: reference], @" WHERE ID = ",
|
||||
[record objectForKey: @"ID"], nil];
|
||||
|
||||
[db execute: @"UPDATE Queue SET Status = 'D'",
|
||||
@" WHERE Consumer = ", [db quote: name],
|
||||
@" AND Reference = ", [db quote: reference],
|
||||
nil];
|
||||
}
|
||||
[db commit];
|
||||
i += count;
|
||||
[arp release];
|
||||
}
|
||||
NSLog(@"End consuming (%d records)", i);
|
||||
/*
|
||||
[db execute: @"DROP INDEX ReferenceIDX", nil];
|
||||
[db execute: @"DROP INDEX ServiceIDX", nil];
|
||||
[db execute: @"DROP INDEX ConsumerIDX", nil];
|
||||
[db execute: @"DROP INDEX QueueIDX", nil];
|
||||
[db execute: @"DROP TABLE Queue", nil];
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
SQLTransaction *t;
|
||||
NSString *oddChars;
|
||||
NSString *nonLatin;
|
||||
id r0;
|
||||
id r1;
|
||||
|
||||
oddChars = @"'a\\b'c\r\nd'\\ed\\";
|
||||
nonLatin = [[NSString stringWithCString: "\"\\U2A11\""] propertyList];
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
dbuf[i] = i;
|
||||
}
|
||||
data = [NSData dataWithBytes: dbuf length: i];
|
||||
|
||||
NS_DURING
|
||||
[db execute: @"drop table xxx", nil];
|
||||
NS_HANDLER
|
||||
NS_ENDHANDLER
|
||||
|
||||
[db setDurationLogging: 0];
|
||||
|
||||
[db begin];
|
||||
[db execute: @"create table xxx ( "
|
||||
@"k char(40), "
|
||||
@"char1 char(1), "
|
||||
@"boolval BOOL, "
|
||||
@"intval int, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp, "
|
||||
@"b bytea"
|
||||
@")",
|
||||
nil];
|
||||
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
@"1, "
|
||||
@"CURRENT_TIMESTAMP, "
|
||||
@"CURRENT_TIMESTAMP, ",
|
||||
data,
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
@"1, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[NSData dataWithBytes: "" length: 0],
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"1, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[NSData dataWithBytes: "" length: 0],
|
||||
@")",
|
||||
nil];
|
||||
[db commit];
|
||||
|
||||
r0 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed");
|
||||
[NSThread sleepForTimeInterval: 2.0];
|
||||
records = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
|
||||
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
||||
if ([records count] != 3)
|
||||
{
|
||||
NSLog(@"Expected 3 records but got %"PRIuPTR, [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
record = [records objectAtIndex: 0];
|
||||
if ([[record objectForKey: @"b"] isEqual: data] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved data does not match saved data %@ %@",
|
||||
data, [record objectForKey: @"b"]);
|
||||
}
|
||||
record = [records objectAtIndex: 1];
|
||||
if ([[record objectForKey: @"b"] isEqual: [NSData data]] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved empty data does not match saved data");
|
||||
}
|
||||
record = [records objectAtIndex: 2];
|
||||
if ([[record objectForKey: @"char1"] isEqual: nonLatin] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved non-latin does not match saved string");
|
||||
}
|
||||
if ([[record objectForKey: @"k"] isEqual: oddChars] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved odd chars does not match saved string");
|
||||
}
|
||||
}
|
||||
|
||||
[db execute: @"create table xxx ( "
|
||||
@"k char(40), "
|
||||
@"char1 char(1), "
|
||||
@"boolval BOOL, "
|
||||
@"intval int, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp, "
|
||||
@"b bytea"
|
||||
@")",
|
||||
nil];
|
||||
t = [db transaction];
|
||||
[t add: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"0, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[db quote: nil],
|
||||
@")",
|
||||
nil];
|
||||
[t add: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"1, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[db quote: nil],
|
||||
@")",
|
||||
nil];
|
||||
[t add: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
@",TRUE, "
|
||||
@"2, ",
|
||||
[NSDate date], @", ",
|
||||
[NSDate date], @", ",
|
||||
[db quote: nil],
|
||||
@")",
|
||||
nil];
|
||||
[t execute];
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
||||
NSLog(@"Records - %@", [GSCache class]);
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
18
testMySQL.m
18
testMySQL.m
|
@ -7,29 +7,29 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SQLClient.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -109,7 +109,7 @@ main()
|
|||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ main()
|
|||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
330
testPostgres.m
330
testPostgres.m
|
@ -7,42 +7,30 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Performance/GSCache.h>
|
||||
#import "SQLClient.h"
|
||||
|
||||
@interface Logger : NSObject
|
||||
- (void) notified: (NSNotification*)n;
|
||||
@end
|
||||
|
||||
@implementation Logger
|
||||
- (void) notified: (NSNotification*)n
|
||||
{
|
||||
NSLog(@"Received %@", n);
|
||||
}
|
||||
@end
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <Performance/GSCache.h>
|
||||
#include "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
SQLClientPool *sp;
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -51,7 +39,6 @@ main()
|
|||
unsigned int i;
|
||||
NSData *data;
|
||||
NSString *name;
|
||||
Logger *l;
|
||||
|
||||
defs = [NSUserDefaults standardUserDefaults];
|
||||
[defs registerDefaults:
|
||||
|
@ -69,84 +56,7 @@ main()
|
|||
nil]
|
||||
];
|
||||
|
||||
sp = [[[SQLClientPool alloc] initWithConfiguration: nil
|
||||
name: @"test"
|
||||
max: 2
|
||||
min: 1] autorelease];
|
||||
#if 0
|
||||
{
|
||||
NSAutoreleasePool *p;
|
||||
NSAutoreleasePool *q;
|
||||
SQLClient *c0;
|
||||
SQLClient *c1;
|
||||
|
||||
[sp setDebugging: 4];
|
||||
p = [NSAutoreleasePool new];
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Got two clients from pool");
|
||||
[c0 connect];
|
||||
[c1 connect];
|
||||
NSLog(@"Now putting clients back in pool again");
|
||||
[sp swallowClient: c0];
|
||||
[sp swallowClient: c1];
|
||||
NSLog(@"And emptying autorelease pool");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
[sp setPurgeAll: 60 min: 1];
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
NSLog(@"Expecting purge to disconnect one client");
|
||||
[sp purge];
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Expecting connected: %@", [c0 connected] ? @"YES" : @"NO");
|
||||
NSLog(@"Expecting not connected: %@", [c1 connected] ? @"NO" : @"YES");
|
||||
|
||||
NSLog(@"Pool has provided both it's clients ... now try for another with a 15 second timeout");
|
||||
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 15.0]
|
||||
exclusive: YES];
|
||||
NSLog(@"Emptying autorelease pool ... clients should be put back in pool");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
NSLog(@"Getting two clients again");
|
||||
c0 = [sp provideClientExclusive];
|
||||
c1 = [sp provideClientExclusive];
|
||||
NSLog(@"Pool has provided both it's clients ... now try for another with a 15 second timeout");
|
||||
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 15.0]
|
||||
exclusive: YES];
|
||||
NSLog(@"Emptying autorelease pool again");
|
||||
[p release];
|
||||
p = [NSAutoreleasePool new];
|
||||
c0 = [sp provideClient];
|
||||
q = [NSAutoreleasePool new];
|
||||
c1 = [sp provideClient];
|
||||
if (c0 != c1)
|
||||
{
|
||||
NSLog(@"ERROR was expecting provideClient to give the same object");
|
||||
exit(1);
|
||||
}
|
||||
[q release];
|
||||
[c0 connect];
|
||||
[p release];
|
||||
|
||||
NSLog(@"Expect to get client immediately");
|
||||
}
|
||||
#endif
|
||||
db = [sp provideClientExclusive];
|
||||
[sp swallowClient: db];
|
||||
|
||||
[sp queryString: @"SELECT CURRENT_TIMESTAMP", nil];
|
||||
db = [sp provideClientExclusive];
|
||||
|
||||
l = [Logger new];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: SQLClientDidConnectNotification
|
||||
object: db];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: SQLClientDidDisconnectNotification
|
||||
object: db];
|
||||
db = [SQLClient clientWithConfiguration: nil name: @"test"];
|
||||
|
||||
if ((name = [defs stringForKey: @"Producer"]) != nil)
|
||||
{
|
||||
|
@ -160,7 +70,7 @@ main()
|
|||
@"Delivery TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, "
|
||||
@"Reference CHAR(128), "
|
||||
@"Destination CHAR(15) NOT NULL, "
|
||||
@"Payload CHAR(250) DEFAULT '' NOT NULL,"
|
||||
@"Payload CHAR(250) DEFAULT '' NOT NULL"
|
||||
@")",
|
||||
nil];
|
||||
[db execute:
|
||||
|
@ -184,35 +94,23 @@ main()
|
|||
NSLog(@"Start producing");
|
||||
for (i = 0; i < 100000; i++)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSString *destination = [NSString stringWithFormat: @"%d", i];
|
||||
NSString *sid = [NSString stringWithFormat: @"%d", i%100];
|
||||
|
||||
if (i % 1000 == 999)
|
||||
{
|
||||
[db postNotificationName: @"Producing"
|
||||
payload: [NSString stringWithFormat: @"%d", i]];
|
||||
}
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination,"
|
||||
@" ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ",
|
||||
[db quote: destination], @", ",
|
||||
sid, @", ",
|
||||
@"'helo there'",
|
||||
@")", nil];
|
||||
[arp release];
|
||||
[db execute: @"INSERT INTO Queue (Consumer, Destination, ServiceID, Payload) VALUES (",
|
||||
[db quote: name], @", ", [db quote: destination], @", ", sid, @", ",
|
||||
@"'helo there'", @")", nil];
|
||||
RELEASE(arp);
|
||||
}
|
||||
NSLog(@"End producing");
|
||||
}
|
||||
else if ((name = [defs stringForKey: @"Consumer"]) != nil)
|
||||
{
|
||||
[db addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: @"Producing"];
|
||||
NSLog(@"Start consuming");
|
||||
for (i = 0; i < 100000;)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
unsigned count;
|
||||
int j;
|
||||
|
||||
|
@ -225,7 +123,7 @@ main()
|
|||
if (count == 0)
|
||||
{
|
||||
[db commit];
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
sleep(1);
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
|
@ -254,7 +152,7 @@ main()
|
|||
}
|
||||
[db commit];
|
||||
i += count;
|
||||
[arp release];
|
||||
RELEASE(arp);
|
||||
}
|
||||
NSLog(@"End consuming (%d records)", i);
|
||||
/*
|
||||
|
@ -267,20 +165,9 @@ main()
|
|||
}
|
||||
else
|
||||
{
|
||||
NSString *oddChars;
|
||||
NSString *oddNoNul;
|
||||
NSString *nonLatin;
|
||||
id e1, e2, e3, e4, e5;
|
||||
id d;
|
||||
id d0;
|
||||
id d1;
|
||||
id d2;
|
||||
id r0;
|
||||
id r1;
|
||||
|
||||
oddChars = @"'a\\b'c\0\r\nd'\\ed\\";
|
||||
oddNoNul = @"'a\\b'c\r\nd'\\ed\\";
|
||||
nonLatin = [[NSString stringWithCString: "\"\\U2A11\""] propertyList];
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
dbuf[i] = i;
|
||||
|
@ -296,64 +183,31 @@ main()
|
|||
|
||||
[db begin];
|
||||
[db execute: @"create table xxx ( "
|
||||
@"id int, "
|
||||
@"k char(40), "
|
||||
@"char1 char(1), "
|
||||
@"boolval BOOL, "
|
||||
@"intval int, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp, "
|
||||
@"b bytea,"
|
||||
@"extra1 int[],"
|
||||
@"extra2 varchar[],"
|
||||
@"extra3 bytea[],"
|
||||
@"extra4 boolean[],"
|
||||
@"extra5 timestamp with time zone[]"
|
||||
@"b bytea"
|
||||
@")",
|
||||
nil];
|
||||
|
||||
if (1 != [db execute: @"INSERT into xxx (id, k, char1, boolval, intval,"
|
||||
@" when1, when2, b, extra1, extra2, extra3, extra4, extra5) "
|
||||
@"values (1,"
|
||||
@"'{hello', "
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
@"1, "
|
||||
@"CURRENT_TIMESTAMP, "
|
||||
@"CURRENT_TIMESTAMP, ",
|
||||
data, @", ",
|
||||
[db quoteArray:
|
||||
(e1 = [NSArray arrayWithObjects: @"1", @"2", [NSNull null], nil])
|
||||
toString: nil
|
||||
quotingStrings: NO], @", ",
|
||||
[db quoteArray:
|
||||
(e2 = [NSArray arrayWithObjects: @"on,e", @"t'wo", @"many", nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @", ",
|
||||
[db quoteArray:
|
||||
(e3 = [NSArray arrayWithObjects: data, nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @", ",
|
||||
[db quoteArray:
|
||||
(e4 =[NSArray arrayWithObjects: @"TRUE", @"FALSE", nil])
|
||||
toString: nil
|
||||
quotingStrings: NO], @", ",
|
||||
[db quoteArray:
|
||||
(e5 = [NSArray arrayWithObjects: [NSDate date], nil])
|
||||
toString: nil
|
||||
quotingStrings: YES], @")",
|
||||
nil])
|
||||
{
|
||||
NSLog(@"Insert failed to return row count");
|
||||
}
|
||||
|
||||
[db setDebugging: 0];
|
||||
[db query: @"select * from xxx", nil];
|
||||
[db setDebugging: 0];
|
||||
|
||||
[db execute: @"INSERT into xxx "
|
||||
@"(id, k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (2,"
|
||||
data,
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"TRUE, "
|
||||
|
@ -363,12 +217,11 @@ main()
|
|||
[NSData dataWithBytes: "" length: 0],
|
||||
@")",
|
||||
nil];
|
||||
[db execute: @"INSERT into xxx "
|
||||
@"(id, k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values (3,",
|
||||
[db quote: oddChars],
|
||||
@", ",
|
||||
[db quote: nonLatin],
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, boolval, intval, when1, when2, b) "
|
||||
@"values ("
|
||||
@"'hello', ",
|
||||
[db quote: [[NSString stringWithCString: "\"\\U2A11\""] propertyList]],
|
||||
@",TRUE, "
|
||||
@"1, ",
|
||||
[NSDate date], @", ",
|
||||
|
@ -378,31 +231,21 @@ main()
|
|||
nil];
|
||||
[db commit];
|
||||
|
||||
r0 = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
r0 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed");
|
||||
[NSThread sleepForTimeInterval: 2.0];
|
||||
records = [db cache: 1 query: @"select * from xxx order by id", nil];
|
||||
sleep(2);
|
||||
records = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
|
||||
|
||||
db = [[[SQLClient alloc] initWithConfiguration: nil
|
||||
name: @"test"] autorelease];
|
||||
[db addObserver: l
|
||||
selector: @selector(notified:)
|
||||
name: @"foo"];
|
||||
|
||||
[db postNotificationName: @"foo" payload: @"hello"];
|
||||
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
||||
if ([records count] != 3)
|
||||
{
|
||||
NSLog(@"Expected 3 records but got %lu", [records count]);
|
||||
NSLog(@"Expected 3 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
record = [records objectAtIndex: 0];
|
||||
if ([[record objectForKey: @"b"] isEqual: data] == NO)
|
||||
{
|
||||
|
@ -414,105 +257,12 @@ main()
|
|||
{
|
||||
NSLog(@"Retrieved empty data does not match saved data");
|
||||
}
|
||||
record = [records objectAtIndex: 2];
|
||||
if ([[record objectForKey: @"char1"] isEqual: nonLatin] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved non-latin does not match saved string");
|
||||
}
|
||||
id o = [[record objectForKey: @"k"] stringByTrimmingSpaces];
|
||||
if ([o isEqual: oddNoNul] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved odd chars (%@) does not match oddNoNul (%@)",
|
||||
o, oddNoNul);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Embedded nul correctly removed");
|
||||
}
|
||||
record = [records objectAtIndex: 0];
|
||||
o = [record objectForKey: @"extra1"];
|
||||
if ([o isEqual: e1] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra1 (%@) does not match saved (%@)", o, e1);
|
||||
}
|
||||
o = [record objectForKey: @"extra2"];
|
||||
if ([o isEqual: e2] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra2 (%@) does not match saved (%@)", o, e2);
|
||||
}
|
||||
o = [record objectForKey: @"extra3"];
|
||||
if ([o isEqual: e3] == NO)
|
||||
{
|
||||
NSLog(@"Retrieved extra3 (%@) does not match saved (%@)", o, e3);
|
||||
}
|
||||
o = [record objectForKey: @"extra4"];
|
||||
if ([o count] != [e4 count])
|
||||
{
|
||||
NSLog(@"Retrieved extra4 (%@) does not match saved (%@)", o, e4);
|
||||
}
|
||||
for (i = 0; i < [o count]; i++)
|
||||
{
|
||||
if ([[o objectAtIndex: i] boolValue]
|
||||
!= [[e4 objectAtIndex: i] boolValue])
|
||||
{
|
||||
NSLog(@"Retrieved extra4 (%@) does not match saved (%@)",
|
||||
o, e4);
|
||||
}
|
||||
}
|
||||
o = [record objectForKey: @"extra5"];
|
||||
if ([o count] != [e5 count])
|
||||
{
|
||||
NSLog(@"Retrieved extra5 (%@) does not match saved (%@)", o, e5);
|
||||
}
|
||||
for (i = 0; i < [o count]; i++)
|
||||
{
|
||||
if (floor([[o objectAtIndex: i] timeIntervalSinceReferenceDate])
|
||||
!= floor([[e5 objectAtIndex: i] timeIntervalSinceReferenceDate]))
|
||||
{
|
||||
NSLog(@"Retrieved extra5 (%@) does not match saved (%@)",
|
||||
o, e5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"Records - %@", [GSCache class]);
|
||||
|
||||
d = [NSCalendarDate date];
|
||||
[d setTimeZone: [NSTimeZone timeZoneForSecondsFromGMT: 240]];
|
||||
[db begin];
|
||||
[db execute: @"create table xxx ( "
|
||||
@"id int, "
|
||||
@"when0 timestamp with time zone, "
|
||||
@"when1 timestamp with time zone, "
|
||||
@"when2 timestamp)",
|
||||
nil];
|
||||
[db execute: @"INSERT into xxx (id, when0, when1, when2) "
|
||||
@"values (99,",
|
||||
d, @", ",
|
||||
[NSDate distantPast], @", ",
|
||||
[NSDate distantFuture], @")",
|
||||
nil];
|
||||
r0 = [[db query: @"select * from xxx where id=99", nil] lastObject];
|
||||
[db execute: @"drop table xxx", nil];
|
||||
[db commit];
|
||||
|
||||
d0 = [r0 objectForKey:@"when0"];
|
||||
NSCAssert(floor([d0 timeIntervalSinceReferenceDate])
|
||||
== floor([d timeIntervalSinceReferenceDate]),
|
||||
NSInternalInconsistencyException);
|
||||
d1 = [r0 objectForKey:@"when1"];
|
||||
NSCAssert([d1 timeIntervalSinceReferenceDate]
|
||||
== [[NSDate distantPast] timeIntervalSinceReferenceDate],
|
||||
NSInternalInconsistencyException);
|
||||
d2 = [r0 objectForKey:@"when2"];
|
||||
NSCAssert([d2 timeIntervalSinceReferenceDate]
|
||||
== [[NSDate distantFuture] timeIntervalSinceReferenceDate],
|
||||
NSInternalInconsistencyException);
|
||||
}
|
||||
|
||||
NSLog(@"Pool stats:\n%@", [sp statistics]);
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
22
testSQLite.m
22
testSQLite.m
|
@ -7,29 +7,29 @@
|
|||
This file is part of the SQLClient Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SQLClient.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include "SQLClient.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
SQLClient *db;
|
||||
NSUserDefaults *defs;
|
||||
NSMutableArray *records;
|
||||
|
@ -91,8 +91,8 @@ main()
|
|||
|
||||
[db execute: @"insert into xxx "
|
||||
@"(k, char1, intval, realval, b) "
|
||||
@"values (",
|
||||
[db quoteString: @"hello"], @", "
|
||||
@"values ("
|
||||
@"'hello', "
|
||||
@"'X', "
|
||||
@"1, ",
|
||||
@"12345.6789, ",
|
||||
|
@ -104,7 +104,7 @@ main()
|
|||
|
||||
if ([records count] != 2)
|
||||
{
|
||||
NSLog(@"Expected 2 records but got %" PRIuPTR "", [records count]);
|
||||
NSLog(@"Expected 2 records but got %u", [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ main()
|
|||
|
||||
NSLog(@"Records - %@", records);
|
||||
|
||||
[pool release];
|
||||
RELEASE(pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue