mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ba6e3293b |
No files matched your search
@@ -20,4 +20,3 @@ mono.spec
|
||||
autom4te.cache
|
||||
mint.pc
|
||||
stamp-h1
|
||||
config.h.in
|
||||
@@ -1,249 +1,3 @@
|
||||
|
||||
Mon Jun 14 18:38:34 CEST 2004 Paolo Molaro <[email protected]>
|
||||
|
||||
* configure.in: better explain that --with-nptl is not related to
|
||||
NPTL, but to __thread support. Set sigaltstack support to off by
|
||||
default.
|
||||
|
||||
2004-06-12 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (populate-runtime-subdir): Add _tmpinst directory
|
||||
to the PATH.
|
||||
|
||||
2004-06-11 Jackson Harper <[email protected]>
|
||||
|
||||
* runtime/net_2_0/Makefile.am:
|
||||
* runtime/net_1_1/Makefile.am: Remove signing patches
|
||||
|
||||
2004-06-11 Jackson Harper <[email protected]>
|
||||
|
||||
* man/mono.1: Add documentation for MONO_GAC_PREFIX.
|
||||
* runtime/net_2_0/Makefile.am:
|
||||
* runtime/net_1_1/Makefile.am: Sign assemblies before
|
||||
installing. Do not sign ziplib, npgsql, or nunit assemblies. Sign mscorlib.
|
||||
|
||||
2004-06-11 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (populate-runtime-subdir): New target. Does a
|
||||
controlled "make install" in the 'mcs/' directory to populate the
|
||||
'runtime' directory.
|
||||
(fasterstrap): Use it.
|
||||
|
||||
2004-06-10 Raja R Harinath <[email protected]>
|
||||
|
||||
* runtime/Makefile.am ($(monoone_DATA),$(monotwo_DATA),$(monobins_DATA)):
|
||||
Don't copy from prefix. Use $(LN_S) to point to the mcs/ tree.
|
||||
* runtime/net_1_1/Makefile.am (mscorlib.dll,$(gac_assemblies)):
|
||||
Use $(LN_S) to point to the mcs/ tree, rather than copying.
|
||||
* runtime/net_2_0/Makefile.am (mscorlib.dll,$(gac_assemblies)): Likewise.
|
||||
|
||||
2004-06-10 Raja R Harinath <[email protected]>
|
||||
|
||||
Support the new assembly signing setup in mcs/.
|
||||
* Makefile.am (mcs-do-basic-build): Pass 'USE_BOOT_COMPILE' to sub-makes.
|
||||
($(tmpinst)/etc/mono/machine.config): New target.
|
||||
(tmpinst-dir.stamp): Remove and rewrite into ...
|
||||
($(tmpinst)/bin/mcs): ... this and ...
|
||||
($(tmpinst)/bin/mono): ... this. Update to use the in-tree machine.config.
|
||||
(tmpinst-dir): Rewrite to invoke above $(tmpinst)/... targets directly.
|
||||
* configure.in (AC_PROG_LN_S): New check to define $(LN_S).
|
||||
|
||||
Thu Jun 3 14:39:17 CEST 2004 Paolo Molaro <[email protected]>
|
||||
|
||||
* configure.in: libc setting for NetBSD (patch from [email protected]).
|
||||
|
||||
2004-06-01 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (bootstrap,faststrap,fasterstrap): Refactor.
|
||||
Fix 'faststrap' to be corlib-version-change-safe.
|
||||
(one-stage-strap,two-stage-strap,three-stage-strap): Remove.
|
||||
(monolite-bootstrap): Update.
|
||||
|
||||
2004-05-31 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* configure.in: fixlets for windows.
|
||||
|
||||
2004-05-29 Zoltan Varga <[email protected]>
|
||||
|
||||
* configure.in: export CC instead of passing it to libgc/configure.
|
||||
|
||||
2004-05-28 Duncan Mak <[email protected]>
|
||||
|
||||
* runtime/Makefile.am:
|
||||
* scripts/Makefile.am: Include mono-find-provides and
|
||||
mono-find-requires.
|
||||
|
||||
* scripts/mono-find-provides.in:
|
||||
* scripts/mono-find-requires.in: New wrapper scripts.
|
||||
|
||||
2004-05-27 Zoltan Varga <[email protected]>
|
||||
|
||||
* configure.in: Pass CC to libgc configure.
|
||||
|
||||
2004-05-27 Gert Driesen ([email protected])
|
||||
|
||||
* monowiz.win32.nsi: normalized line-endings to unix (LF)
|
||||
|
||||
2004-05-27 Gert Driesen ([email protected])
|
||||
|
||||
* monowiz.win32.nsi: do not include mono subdirectory in
|
||||
MonoConfigDir registry key, to match batch files
|
||||
|
||||
2004-05-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* data/DefaultWsdlHelpGenerator.aspx: fixed querystring attribute
|
||||
values. Now they are URlEncoded.
|
||||
|
||||
* data/browscap.ini.gz: updated.
|
||||
|
||||
2004-05-26 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (mcs-do-basic-build): No need to set MCS here.
|
||||
* runtime/net_1_1/Makefile.am (gac_assemblies_list): Update to
|
||||
reflect new names for nunit.util and nunit.framework. Add
|
||||
nunit.core.
|
||||
* runtime/net_2_0/Makefile.am (gac_assemblies_list): Likewise.
|
||||
|
||||
2004-05-25 Ben Maurer <[email protected]>
|
||||
|
||||
* config.h.in: remove
|
||||
|
||||
2004-05-25 18:30 CET Patrik Torstensson <[email protected]>
|
||||
|
||||
* configure.in: Check for trunc instead of truncl (HAVE_TRUNC)
|
||||
|
||||
2004-05-21 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* Makefile.am:
|
||||
* monowiz.win32.nsi: improved windows installer script.
|
||||
|
||||
2004-05-21 Raja R Harinath <[email protected]>
|
||||
|
||||
* README: Update to include instructions for the various new
|
||||
bootstrap-like targets.
|
||||
|
||||
2004-05-20 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (get-monolite-latest, monolite-bootstrap):
|
||||
New bootstrap targets to build from monolite.
|
||||
Based on idea from Jaroslaw Kowalski <[email protected]>.
|
||||
|
||||
2004-05-20 Raja R Harinath <[email protected]>
|
||||
|
||||
* configure.in (AC_OUTPUT): Add tools/Makefile and
|
||||
tools/locale-builder/Makefile.
|
||||
* Makefile.am (SUBDIRS): Remove tools.
|
||||
(DIST_SUBDIRS): Add 'tools'.
|
||||
(bootstrap): Rewrite so that we get two new targets.
|
||||
(faststrap): New two-stage build.
|
||||
(fasterstrap): New one-stage build.
|
||||
|
||||
2004-05-19 Jackson Harper <[email protected]>
|
||||
|
||||
* tools/
|
||||
* tools/Makefile.am: Add tools directory
|
||||
* tools/locale-builder: Add the locale-builder tool, this tool is
|
||||
not built by default as it is only needed by people that wish to
|
||||
moidify culture data.
|
||||
* Makefile.am: Add tools to build
|
||||
|
||||
Wed May 19 13:22:19 EDT 2004 Paolo Molaro <[email protected]>
|
||||
|
||||
* configure.in: make MacOSX default to use the included libgc.
|
||||
|
||||
2004-05-18 Zoltan Varga <[email protected]>
|
||||
|
||||
* configure.in: Get rid of -DMONO_USE_EXC_TABLES.
|
||||
|
||||
2004-05-19 Raja R Harinath <[email protected]>
|
||||
|
||||
* configure.in: Use proper autoconf idiom to pass additional
|
||||
arguments to libgc/configure.
|
||||
(PLATFORM_WIN32, NEED_LINK_UNLINK): Use three-argument AC_DEFINE.
|
||||
* acconfig.h: Update to reflect changes.
|
||||
|
||||
2004-05-17 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (tmpinst-dir): Creates _tmpinst tree if
|
||||
necessary. Move body ...
|
||||
(tmpinst-dir.stamp): ... here.
|
||||
(stage3): Don't remove _tmpinst tree.
|
||||
(bootstrap-clean, bootstrap-check): New rules. They run the
|
||||
corresponding rules in the mcs/ tree.
|
||||
|
||||
2004-05-14 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am: Revert unlogged unexplained changes.
|
||||
(stage3): Make 'all-profiles' since the mono source tarball
|
||||
carries all the net_2_0 preview dlls.
|
||||
|
||||
2004-05-11 Jackson Harper <[email protected]>
|
||||
|
||||
* runtime/net_1_1/Makefile.am:
|
||||
* runtime/net_2_0/Makefile.am: cscompmgd.dll is lowercase now.
|
||||
|
||||
2004-05-10 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile.am (tmpinst-dir): Always add $tmpinst/lib to MONO_PATH.
|
||||
Fix quoting of commands.
|
||||
|
||||
2004-05-08 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* monowiz.win32.nsi: some changes i made to build the 0.91 win32 setup
|
||||
file.
|
||||
|
||||
2004-05-07 Bernie Solomon <[email protected]>
|
||||
|
||||
* man/mono.1: mention MONO_EGD_SOCKET
|
||||
|
||||
2004-05-07 Raja R Harinath <[email protected]>
|
||||
|
||||
Goodbye 'fullbuild', hello 'bootstrap'.
|
||||
* Makefile.am (bootstrap): New target for building from CVS. New
|
||||
improved version of 'fullbuild' -- does not install any files.
|
||||
(fullbuild): Obsolete target. Bootstraps and installs tree.
|
||||
(mcs-tree-safe-build,xinstall-runtime,mcs-rest,remove-binaries):
|
||||
Removed.
|
||||
(stage1,stage1-mcs,stage1-mono,stage2,stage3)
|
||||
(tmpinst-dir,tmpinst-runtime): New targets used to implement a
|
||||
two-stage bootstrap.
|
||||
|
||||
2004-05-05 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* configure.in: scandir check is no longer needed.
|
||||
|
||||
2004-05-05 Bernie Solomon <[email protected]>
|
||||
|
||||
* configure.in: set LIBC on HPUX
|
||||
|
||||
2004-05-05 Zoltan Varga <[email protected]>
|
||||
|
||||
* configure.in: Detect JNI headers in GNU classpath sources as well.
|
||||
|
||||
2004-05-05 Raja R Harinath <[email protected]>
|
||||
|
||||
* runtime/net_2_0/Makefile.am (install-data-local, uninstall-local):
|
||||
Only disable this if INSTALL_2_0 is disabled.
|
||||
|
||||
2004-05-05 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* data/DefaultWsdlHelpGenerator.aspx: add any cookie in the request to
|
||||
the request we do for the actual web service.
|
||||
|
||||
2004-05-04 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* configure.in: check for SIGEV_THREAD being defined before checking
|
||||
for AIO support. Fixes compilation under FreeBSD.
|
||||
|
||||
2004-05-04 Raja R Harinath <[email protected]>
|
||||
|
||||
* runtime/net_1_1/Makefile.am (mono_runtime): Use USE_JIT, not
|
||||
JIT_SUPPORTED.
|
||||
(install-data-local, uninstall-data-local): Run runtime with
|
||||
libtool.
|
||||
* runtime/net_2_0/Makefile.am: Likewise.
|
||||
Report from Urs C Muff <[email protected]>.
|
||||
|
||||
2004-05-03 Jackson Harper <[email protected]>
|
||||
|
||||
* man/gacutil.1: Basic man page for gacutil. This doesn't include
|
||||
|
||||
+34
-144
@@ -1,11 +1,11 @@
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I .
|
||||
|
||||
SUBDIRS = @libgc_dir@ mono @ikvm_jni_dir@ docs runtime scripts man data samples support web
|
||||
SUBDIRS = @libgc_dir@ mono @ikvm_jni_dir@ docs runtime scripts man data samples support web
|
||||
|
||||
# Keep in sync with SUBDIRS
|
||||
## 'tools' is not normally built
|
||||
DIST_SUBDIRS = libgc mono ikvm-jni docs runtime scripts man data samples support web tools
|
||||
DIST_SUBDIRS = libgc mono ikvm-jni docs runtime scripts man data samples support web
|
||||
|
||||
# EXTRA_SUBDIRS = libgc
|
||||
|
||||
EXTRA_DIST= mono.pc.in mono.spec.in mint.pc.in
|
||||
|
||||
@@ -18,154 +18,38 @@ endif
|
||||
DISTCLEANFILES= mono.pc mint.pc
|
||||
|
||||
#
|
||||
# The following targets are used to compile and install
|
||||
# The following target is used to compile and install
|
||||
# mono and mcs without running into the out-of-sync
|
||||
# problems by doing the compilation in the right order.
|
||||
#
|
||||
|
||||
mcs_topdir=$(top_srcdir)/../mcs
|
||||
|
||||
.PHONY: bootstrap faststrap fasterstrap bootstrap-clean bootstrap-check get-monolite-latest monolite-bootstrap
|
||||
.PHONY: tmpinst-dir tmpinst-mcs-basic-build tmpinst-mcs-short-build tmpinst-mcs-full-build tmpinst-monolite
|
||||
.PHONY: mono-do-runtime-only mcs-do-basic-build mcs-do-short-build mcs-do-full-build mcs-do-clean-profiles mcs-do-run-test
|
||||
.PHONY: fullbuild remove-binaries mcs-tree-safe-build xinstall-runtime mcs-rest
|
||||
|
||||
if USE_JIT
|
||||
mono_runtime = mono/mini/mono
|
||||
else
|
||||
mono_runtime = mono/interpreter/mint
|
||||
endif
|
||||
|
||||
# Minimal set of directories to build, and files used to run the 'mcs' compiler
|
||||
MCS_BASIC_DIRS = jay mcs class/corlib class/System
|
||||
MCS_BASIC_FILES = \
|
||||
$(mcs_topdir)/mcs/mcs.exe \
|
||||
$(mcs_topdir)/class/lib/default/mscorlib.dll \
|
||||
$(mcs_topdir)/class/lib/default/System.dll
|
||||
|
||||
# Set of directories and files the 'mcs' compiler can use
|
||||
## We build class/System twice to resolve the cyclic dependency of class/System.XML
|
||||
MCS_DIRS = $(MCS_BASIC_DIRS) class/System.XML class/System class/Mono.CSharp.Debugger
|
||||
MCS_FILES = $(MCS_BASIC_FILES) \
|
||||
$(mcs_topdir)/class/lib/default/System.Xml.dll \
|
||||
$(mcs_topdir)/class/lib/default/Mono.CSharp.Debugger.dll
|
||||
|
||||
tmpinst = _tmpinst
|
||||
|
||||
bootstrap: tmpinst-mcs-basic-build mono-do-runtime-only
|
||||
$(MAKE) tmpinst-mcs-short-build
|
||||
$(MAKE) fasterstrap
|
||||
|
||||
faststrap: tmpinst-mcs-short-build
|
||||
$(MAKE) mono-do-runtime-only
|
||||
$(MAKE) fasterstrap
|
||||
|
||||
.PHONY: populate-runtime-subdir
|
||||
## *** warning ***: tested only with GNU make
|
||||
populate-runtime-subdir:
|
||||
srcdir=`cd $(srcdir) && pwd`; tmpinst=`pwd`/$(tmpinst) ; \
|
||||
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
|
||||
cd $(mcs_topdir) \
|
||||
&& $(MAKE) PROGRAM_INSTALL_DIR=$$srcdir/runtime LIBRARY_INSTALL_DIR=$$srcdir/runtime/net_1_1 prefix=$$tmpinst/prefix PROFILE=default install \
|
||||
&& $(MAKE) PROGRAM_INSTALL_DIR=$$srcdir/runtime LIBRARY_INSTALL_DIR=$$srcdir/runtime/net_2_0 prefix=$$tmpinst/prefix PROFILE=net_2_0 install
|
||||
test -z "`find $(tmpinst)/prefix -name '*.dll'`"
|
||||
test -z "`find $(tmpinst)/prefix -name '*.exe'`"
|
||||
set fnord `find $(tmpinst)/prefix -type f | wc -l` ; test "$$2" = 9
|
||||
rm -rf $(tmpinst)/prefix
|
||||
|
||||
fasterstrap: tmpinst-mcs-full-build
|
||||
$(MAKE) populate-runtime-subdir
|
||||
fullbuild: mcs-rest
|
||||
$(MAKE)
|
||||
|
||||
bootstrap-clean: clean mcs-do-clean-profiles
|
||||
bootstrap-check: check mcs-do-run-test
|
||||
|
||||
# building with monolite
|
||||
|
||||
get-monolite-latest:
|
||||
wget -O $(srcdir)/../monolite-latest.tar.gz http://www.go-mono.com/daily/monolite-latest.tar.gz
|
||||
|
||||
monolite-bootstrap: tmpinst-monolite mono-do-runtime-only
|
||||
rm -f $(MCS_FILES)
|
||||
$(MAKE) tmpinst-mcs-short-build
|
||||
$(MAKE) fasterstrap
|
||||
|
||||
# internal targets
|
||||
|
||||
tmpinst-mcs-basic-build: mcs-do-basic-build tmpinst-dir
|
||||
mv -f $(MCS_BASIC_FILES) $(tmpinst)/lib
|
||||
|
||||
tmpinst-mcs-short-build: mcs-do-short-build tmpinst-dir
|
||||
mv -f $(MCS_FILES) $(tmpinst)/lib
|
||||
|
||||
tmpinst-mcs-full-build: mcs-do-full-build tmpinst-dir
|
||||
cp -f $(MCS_FILES) $(tmpinst)/lib
|
||||
|
||||
tmpinst-monolite: tmpinst-dir
|
||||
-rm -f $(tmpinst)/lib/mcs.exe $(tmpinst)/lib/*.dll
|
||||
-rm -fr $(tmpinst)/monolite-*
|
||||
srcdir=`cd $(srcdir) && pwd` && cd $(tmpinst) && ( gzip -d -c $$srcdir/../monolite-latest.tar.gz | tar xf - )
|
||||
mv -f $(tmpinst)/monolite-*/mcs.exe $(tmpinst)/monolite-*/*.dll $(tmpinst)/lib
|
||||
rm -fr $(tmpinst)/monolite-*
|
||||
|
||||
# Build enough of 'mono' to run the stage1 mcs.exe
|
||||
mono-do-runtime-only: $(CONFIG_HEADER)
|
||||
for dir in $(libgc_dir) mono data; do \
|
||||
(cd $$dir && $(MAKE)) || exit 1 ; \
|
||||
done
|
||||
|
||||
mcs-do-basic-build:
|
||||
rm -f $(MCS_FILES)
|
||||
for dir in $(MCS_BASIC_DIRS); do \
|
||||
(cd $(mcs_topdir)/$$dir && $(MAKE) PROFILE=default USE_BOOT_COMPILE=yes BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB") || exit 1 ; \
|
||||
done
|
||||
|
||||
mcs-do-short-build:
|
||||
tmpinst=`cd $(tmpinst) && pwd` ; \
|
||||
PATH=$$tmpinst/bin:$$PATH; export PATH ; \
|
||||
for dir in $(MCS_DIRS); do \
|
||||
(cd $(mcs_topdir)/$$dir && $(MAKE) PROFILE=default) || exit 1 ; \
|
||||
done
|
||||
|
||||
mcs-do-full-build:
|
||||
tmpinst=`cd $(tmpinst) && pwd` ; \
|
||||
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
|
||||
cd $(mcs_topdir) && $(MAKE) all-profiles
|
||||
|
||||
mcs-do-clean-profiles:
|
||||
cd $(mcs_topdir) && $(MAKE) clean-profiles
|
||||
|
||||
mcs-do-run-test: tmpinst-dir
|
||||
tmpinst=`cd $(tmpinst) && pwd` ; \
|
||||
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
|
||||
cd $(mcs_topdir) && $(MAKE) PROFILE=default run-test
|
||||
|
||||
tmpinst-dir:
|
||||
mkdir -p $(tmpinst) $(tmpinst)/bin $(tmpinst)/lib $(tmpinst)/etc/mono
|
||||
$(MAKE) $(tmpinst)/bin/mono $(tmpinst)/bin/mcs $(tmpinst)/etc/mono/machine.config
|
||||
|
||||
$(tmpinst)/bin/mono: $(srcdir)/Makefile.am
|
||||
echo '#! /bin/sh' > $@
|
||||
echo 'builddir="'`pwd`'"; tmpinst=$$builddir/$(tmpinst)' >> $@
|
||||
echo 'if test -z "$$MONO_PATH" ; then MONO_PATH=$$tmpinst/lib; else MONO_PATH=$${MONO_PATH}:$$tmpinst/lib ; fi' >> $@
|
||||
echo 'MONO_CFG_DIR=$$tmpinst/etc' >> $@
|
||||
echo 'export MONO_PATH MONO_CFG_DIR' >> $@
|
||||
echo 'exec "$$builddir/libtool" --mode=execute "$$builddir/$(mono_runtime)" --config "$$builddir/data/config" "$$@"' >> $@
|
||||
chmod +x $@
|
||||
|
||||
$(tmpinst)/bin/mcs: $(srcdir)/Makefile.am
|
||||
(t=`cd $(tmpinst) && pwd`; echo '#! /bin/sh'; echo 'exec "'"$$t/bin/mono"'" "'"$$t/lib/mcs.exe"'" "$$@"') > $@
|
||||
chmod +x $@
|
||||
|
||||
$(tmpinst)/etc/mono/machine.config: $(srcdir)/data/machine.config
|
||||
rm -f $@
|
||||
srcdir=`cd $(srcdir) && pwd`; cd $(tmpinst)/etc/mono && $(LN_S) $$srcdir/data/machine.config machine.config
|
||||
|
||||
# Obsolete target -- don't use.
|
||||
.PHONY: fullbuild
|
||||
fullbuild: bootstrap
|
||||
$(MAKE) install
|
||||
echo "*** 'fullbuild' is an obsolete target. Use 'make bootstrap && make install'."
|
||||
exit 1
|
||||
|
||||
mcs-tree-safe-build: remove-binaries
|
||||
cd $(mcs_topdir)/jay && $(MAKE)
|
||||
cd $(mcs_topdir)/mcs && $(MAKE) MCS=mcs BOOTSTRAP_MCS=mcs PROFILE=default
|
||||
cd $(mcs_topdir)/class/corlib && $(MAKE) MCS=mcs BOOTSTRAP_MCS=mcs PROFILE=default
|
||||
cp $(mcs_topdir)/class/lib/default/mscorlib.dll $(top_srcdir)/runtime/net_1_1
|
||||
cp $(mcs_topdir)/mcs/mcs.exe $(top_srcdir)/runtime
|
||||
|
||||
xinstall-runtime: mcs-tree-safe-build $(CONFIG_HEADER)
|
||||
if test -z "$(libgc_dir)"; then :; else cd libgc && $(MAKE) && $(MAKE) install ; fi
|
||||
cd mono && $(MAKE) && $(MAKE) install
|
||||
cd runtime && $(MAKE) dist_monobins_DATA=mcs.exe install-dist_monobinsDATA
|
||||
cd runtime/net_1_1 && $(MAKE) install-dist_corlibDATA
|
||||
|
||||
mcs-rest: xinstall-runtime
|
||||
cd $(mcs_topdir) && $(MAKE)
|
||||
|
||||
remove-binaries:
|
||||
rm -f $(mcs_topdir)/class/lib/default/mscorlib.dll $(mcs_topdir)/mcs/mcs.exe $(top_srcdir)/runtime/*/*.dll $(top_srcdir)/runtime/*.exe
|
||||
|
||||
|
||||
win32getdeps:
|
||||
wget http://www.go-mono.com/archive/pkgconfig-0.11-20020310.zip
|
||||
@@ -184,4 +68,10 @@ win32getdeps:
|
||||
unzip -n -d / nsis4cygwin.zip
|
||||
|
||||
win32setup:
|
||||
makensis /DMILESTONE=$(VERSION) /DSOURCE_INSTALL_DIR=$(SOURCE_INSTALL_DIR) /DBUILDNUM=$(BUILDNUM) monowiz.win32.nsi
|
||||
cp /usr/lib/libglib-2.0-0.dll @prefix@/lib
|
||||
cp /usr/lib/iconv.dll @prefix@/lib
|
||||
cp /usr/lib/libgmodule-2.0-0.dll @prefix@/lib
|
||||
cp /usr/lib/libgobject-2.0-0.dll @prefix@/lib
|
||||
cp /usr/lib/libgthread-2.0-0.dll @prefix@/lib
|
||||
cp /usr/lib/libintl-1.dll @prefix@/lib
|
||||
makensis /DMILESTONE=@VERSION@ /DSOURCE_INSTALL_DIR=`cygpath -a -w @prefix@`\\* monowiz.win32.nsi
|
||||
@@ -59,31 +59,14 @@ This is Mono.
|
||||
|
||||
tar xzf mcs-XXXX.tar.gz
|
||||
tar xzf mono-XXXX.tar.gz
|
||||
mv mono-XXX mono
|
||||
mv mcs-XXX mcs
|
||||
cd mono
|
||||
cd mono-XXXX
|
||||
./autogen.sh --prefix=/usr/local
|
||||
make bootstrap
|
||||
make fullbuild
|
||||
|
||||
c. Building the software from CVS
|
||||
---------------------------------
|
||||
|
||||
If you are building the software from CVS, make sure that you
|
||||
have up-to-date mcs and mono sources:
|
||||
|
||||
cvs co mono mcs
|
||||
|
||||
Then, go into the mono directory, and configure:
|
||||
|
||||
cd mono
|
||||
./autogen.sh --prefix=/usr/local
|
||||
|
||||
Depending on whether you have an existing Mono installation or
|
||||
not, you can try the following:
|
||||
|
||||
i. If you have an existing Mono installation
|
||||
-----------------------------------------
|
||||
c. Upgrade from CVS
|
||||
-------------------
|
||||
|
||||
If you are upgrading from CVS you will need an existing Mono installation.
|
||||
First verify that you have a working installation:
|
||||
|
||||
echo 'class X { static void Main () { System.Console.Write("OK");}}' > x.cs
|
||||
@@ -96,86 +79,25 @@ This is Mono.
|
||||
|
||||
mono x.exe
|
||||
|
||||
If you get the output `OK' and no errors, and you have mono
|
||||
version 0.31 or later, continue. Otherwise, you can try option
|
||||
(ii) below.
|
||||
If you get the output `OK' and no errors, you are ready to start your CVS upgrade.
|
||||
|
||||
You are ready to start your CVS upgrade. Compile with
|
||||
First, make sure that you have up-to-date mcs and mono sources:
|
||||
|
||||
make bootstrap
|
||||
cvs co mono mcs
|
||||
|
||||
This will automatically go into the mcs/ tree and build the
|
||||
binaries there, and copy them into the appropriate
|
||||
sub-directories of mono/runtime/.
|
||||
Then, go into the mono directory, and configure:
|
||||
|
||||
Now, go to step (iii) below.
|
||||
cd mono
|
||||
./autogen.sh --prefix=/usr/local
|
||||
|
||||
ii. If you don't have a working Mono installation
|
||||
---------------------------------------------
|
||||
Then compile using the special target `fullbuild':
|
||||
|
||||
If you don't have a working Mono installation, an obvious choice
|
||||
is to install the latest released packages of 'mono' for your
|
||||
distribution and go back to step (i).
|
||||
make fullbuild
|
||||
|
||||
You can also try a slightly more risky approach that should work
|
||||
almost all the time.
|
||||
|
||||
This works by first getting the latest version of the 'monolite'
|
||||
distribution, which contains just enough to run the 'mcs'
|
||||
compiler. You do this by
|
||||
|
||||
make get-monolite-latest
|
||||
|
||||
This should place a monolite-latest.tar.gz in the parent
|
||||
directory of the 'mono' source tree. You can then run:
|
||||
|
||||
make monolite-bootstrap
|
||||
|
||||
This will automatically gunzip and untar the tarball, place the
|
||||
files appropriately, and then complete the bootstrap.
|
||||
|
||||
iii. Testing and Installation
|
||||
------------------------
|
||||
|
||||
You can run the mono and mcs testsuites with the command:
|
||||
|
||||
make -k bootstrap-check
|
||||
|
||||
Expect to find several testsuite failures, especially in the
|
||||
mcs/ tree. As a sanity check, you can compare the failures you
|
||||
got with
|
||||
|
||||
http://go-mono.com/tests/displayTestResults.php
|
||||
|
||||
You can now install it:
|
||||
|
||||
make install
|
||||
This step will compile and install at the same time.
|
||||
|
||||
Failure to follow these steps will result in a broken installation.
|
||||
|
||||
iv. Other useful "bootstrap"-like facilities
|
||||
----------------------------------------
|
||||
|
||||
If you have a CVS snapshot that you keep updating periodically,
|
||||
and/or do your development in, you may try using a couple of
|
||||
specialty make targets that may be slightly faster than a
|
||||
"make bootstrap".
|
||||
|
||||
You can try a two-stage bootstrap with:
|
||||
|
||||
make faststrap
|
||||
|
||||
This assumes that you have already run a "make bootstrap" on the
|
||||
tree before.
|
||||
|
||||
If you want to avoid waiting even for that, you can try the
|
||||
riskier one-stage build:
|
||||
|
||||
make fasterstrap
|
||||
|
||||
This should be attempted only if you're sure that the sources of
|
||||
the mcs compiler itself and the sources of the libraries used by
|
||||
it have not been changed.
|
||||
|
||||
2. Using Mono
|
||||
=============
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#undef HAVE_PTHREAD_MUTEX_TIMEDLOCK
|
||||
#undef USE_MONO_MUTEX
|
||||
#undef HAVE_LARGE_FILE_SUPPORT
|
||||
#undef PLATFORM_WIN32
|
||||
#undef HAVE_NEW_ICONV
|
||||
#undef NAME_DEV_RANDOM
|
||||
#undef HAVE_CRYPT_RNG
|
||||
@@ -20,6 +21,7 @@
|
||||
#undef HAVE_TM_GMTOFF
|
||||
#undef MONO_SIZEOF_SUNPATH
|
||||
#undef MONO_ZERO_ARRAY_LENGTH
|
||||
#undef NEED_LINK_UNLINK
|
||||
#undef PTHREAD_POINTER_ID
|
||||
#undef HAVE_GC_H
|
||||
#undef HAVE_GC_GCJ_MALLOC
|
||||
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
#undef HAVE_INET_PTON
|
||||
#undef HAVE_INET_ATON
|
||||
#undef HAVE_MSG_NOSIGNAL
|
||||
#undef HAVE_SOL_IP
|
||||
#undef HAVE_SOL_TCP
|
||||
#undef HAVE_SOL_IPV6
|
||||
#undef HAVE_IP_PKTINFO
|
||||
#undef HAVE_STRUCT_IP_MREQN
|
||||
#undef HAVE_STRUCT_IP_MREQ
|
||||
#undef HAVE_PTHREAD_MUTEX_TIMEDLOCK
|
||||
#undef USE_MONO_MUTEX
|
||||
#undef HAVE_LARGE_FILE_SUPPORT
|
||||
#undef PLATFORM_WIN32
|
||||
#undef HAVE_NEW_ICONV
|
||||
#undef NAME_DEV_RANDOM
|
||||
#undef HAVE_CRYPT_RNG
|
||||
#undef HAVE_BOEHM_GC
|
||||
#undef USE_INCLUDED_LIBGC
|
||||
#undef DISABLE_SHARED_HANDLES
|
||||
#undef HAVE_TIMEZONE
|
||||
#undef HAVE_TM_GMTOFF
|
||||
#undef MONO_SIZEOF_SUNPATH
|
||||
#undef MONO_ZERO_ARRAY_LENGTH
|
||||
#undef NEED_LINK_UNLINK
|
||||
#undef PTHREAD_POINTER_ID
|
||||
#undef HAVE_GC_H
|
||||
#undef HAVE_GC_GCJ_MALLOC
|
||||
#undef HAVE_GC_ENABLE
|
||||
#undef WITH_BUNDLE
|
||||
#undef HAVE_GETHOSTBYNAME2_R
|
||||
#undef HAVE_ICU
|
||||
#undef HAVE_KW_THREAD
|
||||
#undef HAVE_SIGNBIT
|
||||
#undef USE_MACH_SEMA
|
||||
#undef HAVE_SOCKLEN_T
|
||||
#undef HAVE_TRUNCL
|
||||
#undef HAVE_AINTL
|
||||
#undef HAVE_WORKING_SIGALTSTACK
|
||||
|
||||
/* Define to 1 if you have the <aio.h> header file. */
|
||||
#undef HAVE_AIO_H
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <elf.h> header file. */
|
||||
#undef HAVE_ELF_H
|
||||
|
||||
/* Define to 1 if you have the `finite' function. */
|
||||
#undef HAVE_FINITE
|
||||
|
||||
/* Define to 1 if you have the <gc/gc.h> header file. */
|
||||
#undef HAVE_GC_GC_H
|
||||
|
||||
/* Define to 1 if you have the <gc.h> header file. */
|
||||
#undef HAVE_GC_H
|
||||
|
||||
/* Define to 1 if you have the `getgrgid_r' function. */
|
||||
#undef HAVE_GETGRGID_R
|
||||
|
||||
/* Define to 1 if you have the `getgrnam_r' function. */
|
||||
#undef HAVE_GETGRNAM_R
|
||||
|
||||
/* Define to 1 if you have the `getpwnam_r' function. */
|
||||
#undef HAVE_GETPWNAM_R
|
||||
|
||||
/* Define to 1 if you have the `getpwuid_r' function. */
|
||||
#undef HAVE_GETPWUID_R
|
||||
|
||||
/* Define to 1 if you have the `getresuid' function. */
|
||||
#undef HAVE_GETRESUID
|
||||
|
||||
/* Define to 1 if you have the `inet_aton' function. */
|
||||
#undef HAVE_INET_ATON
|
||||
|
||||
/* Define to 1 if you have the `inet_pton' function. */
|
||||
#undef HAVE_INET_PTON
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `isfinite' function. */
|
||||
#undef HAVE_ISFINITE
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the `poll' function. */
|
||||
#undef HAVE_POLL
|
||||
|
||||
/* Define to 1 if you have the `pthread_attr_get_np' function. */
|
||||
#undef HAVE_PTHREAD_ATTR_GET_NP
|
||||
|
||||
/* Define to 1 if you have the `pthread_attr_setstacksize' function. */
|
||||
#undef HAVE_PTHREAD_ATTR_SETSTACKSIZE
|
||||
|
||||
/* Define to 1 if you have the `pthread_getattr_np' function. */
|
||||
#undef HAVE_PTHREAD_GETATTR_NP
|
||||
|
||||
/* Define to 1 if you have the <pthread.h> header file. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
/* Define to 1 if you have the `pthread_mutex_timedlock' function. */
|
||||
#undef HAVE_PTHREAD_MUTEX_TIMEDLOCK
|
||||
|
||||
/* Define to 1 if you have the <semaphore.h> header file. */
|
||||
#undef HAVE_SEMAPHORE_H
|
||||
|
||||
/* Define to 1 if you have the `setresuid' function. */
|
||||
#undef HAVE_SETRESUID
|
||||
|
||||
/* 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/aio.h> header file. */
|
||||
#undef HAVE_SYS_AIO_H
|
||||
|
||||
/* Define to 1 if you have the <sys/filio.h> header file. */
|
||||
#undef HAVE_SYS_FILIO_H
|
||||
|
||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||
#undef HAVE_SYS_SOCKIO_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 <sys/un.h> header file. */
|
||||
#undef HAVE_SYS_UN_H
|
||||
|
||||
/* Define to 1 if you have the `truncl' function. */
|
||||
#undef HAVE_TRUNCL
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the <utime.h> header file. */
|
||||
#undef HAVE_UTIME_H
|
||||
|
||||
/* Define to 1 if you have the <valgrind/memcheck.h> header file. */
|
||||
#undef HAVE_VALGRIND_MEMCHECK_H
|
||||
|
||||
/* Define to 1 if you have the <wchar.h> header file. */
|
||||
#undef HAVE_WCHAR_H
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* 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
|
||||
|
||||
/* Pointer field name in 'union sigval' */
|
||||
#undef SIGVAL_PTR
|
||||
|
||||
/* The size of a `void *', as computed by sizeof. */
|
||||
#undef SIZEOF_VOID_P
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
+46
-86
@@ -1,11 +1,9 @@
|
||||
AC_INIT(README)
|
||||
AC_CANONICAL_SYSTEM
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,0.96)
|
||||
AM_INIT_AUTOMAKE(mono,0.91)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_LN_S
|
||||
|
||||
dnl
|
||||
dnl libgc checks
|
||||
dnl
|
||||
@@ -32,30 +30,21 @@ AC_SUBST(libmono_ldflags)
|
||||
dnl if linker handles the version script
|
||||
no_version_script=no
|
||||
|
||||
# Set to yes if Unix sockets cannot be created in an anonymous namespace
|
||||
need_link_unlink=no
|
||||
|
||||
# Thread configuration inspired by sleepycat's db
|
||||
AC_MSG_CHECKING([host platform characteristics])
|
||||
libgc_threads=no
|
||||
case "$host" in
|
||||
*-*-mingw*|*-*-cygwin*)
|
||||
platform_win32=yes
|
||||
AC_DEFINE(PLATFORM_WIN32,1,[Platform is Win32])
|
||||
AC_DEFINE(PLATFORM_WIN32)
|
||||
CC="gcc -mno-cygwin"
|
||||
HOST_CC="gcc"
|
||||
# So libgc configure gets -mno-cygwin
|
||||
export CC
|
||||
# latest libgc already defines GC_WIN32_THREADS
|
||||
# CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS -DWIN32_THREADS"
|
||||
CPPFLAGS="$CPPFLAGS -DWIN32_THREADS"
|
||||
libdl=
|
||||
libgc_threads=win32
|
||||
gc_default=boehm
|
||||
with_nptl=no
|
||||
with_sigaltstack=no
|
||||
LN_S=cp
|
||||
|
||||
;;
|
||||
*-*-*netbsd*)
|
||||
platform_win32=no
|
||||
@@ -63,25 +52,25 @@ case "$host" in
|
||||
libmono_cflags="-D_REENTRANT"
|
||||
LDFLAGS="$LDFLAGS -pthread"
|
||||
libmono_ldflags="-pthread"
|
||||
need_link_unlink=yes
|
||||
AC_DEFINE(NEED_LINK_UNLINK)
|
||||
libdl=
|
||||
libgc_threads=no
|
||||
libgc_threads=pthreads
|
||||
;;
|
||||
*-*-*freebsd*|*-*-*openbsd*)
|
||||
platform_win32=no
|
||||
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
|
||||
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
|
||||
libmono_cflags="-D_THREAD_SAFE"
|
||||
LDFLAGS="$LDFLAGS -pthread"
|
||||
libmono_ldflags="-pthread"
|
||||
need_link_unlink=yes
|
||||
AC_DEFINE(NEED_LINK_UNLINK)
|
||||
AC_DEFINE(PTHREAD_POINTER_ID)
|
||||
libdl=
|
||||
libgc_threads=pthreads
|
||||
;;
|
||||
*-*-linux*)
|
||||
platform_win32=no
|
||||
CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT"
|
||||
libmono_cflags="-D_REENTRANT"
|
||||
CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -DMONO_USE_EXC_TABLES -D_GNU_SOURCE -D_REENTRANT -fexceptions"
|
||||
libmono_cflags="-DMONO_USE_EXC_TABLES -fexceptions -D_REENTRANT"
|
||||
libmono_ldflags="-lpthread"
|
||||
libdl="-ldl"
|
||||
libgc_threads=pthreads
|
||||
@@ -94,12 +83,12 @@ case "$host" in
|
||||
libmono_cflags="-D_REENTRANT"
|
||||
libmono_ldflags="-lpthread"
|
||||
libgc_threads=pthreads
|
||||
need_link_unlink=yes
|
||||
AC_DEFINE(NEED_LINK_UNLINK)
|
||||
;;
|
||||
*-*-solaris*)
|
||||
platform_win32=no
|
||||
CPPFLAGS="$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT"
|
||||
need_link_unlink=yes
|
||||
AC_DEFINE(NEED_LINK_UNLINK)
|
||||
libmono_cflags="-D_REENTRANT"
|
||||
libgc_threads=pthreads
|
||||
;;
|
||||
@@ -109,12 +98,13 @@ case "$host" in
|
||||
libmono_cflags="-D_THREAD_SAFE"
|
||||
LDFLAGS="$LDFLAGS -pthread"
|
||||
libmono_ldflags="-pthread"
|
||||
need_link_unlink=yes
|
||||
AC_DEFINE(NEED_LINK_UNLINK)
|
||||
AC_DEFINE(PTHREAD_POINTER_ID)
|
||||
AC_DEFINE(USE_MACH_SEMA)
|
||||
no_version_script=yes
|
||||
libdl=
|
||||
libgc_threads=pthreads
|
||||
libgc_threads=no
|
||||
gc_default=none
|
||||
;;
|
||||
*)
|
||||
AC_MSG_WARN([*** Please add $host to configure.in checks!])
|
||||
@@ -123,11 +113,6 @@ case "$host" in
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT(ok)
|
||||
|
||||
if test x$need_link_unlink = xyes; then
|
||||
AC_DEFINE(NEED_LINK_UNLINK, 1, [Define if Unix sockets cannot be created in an anonymous namespace])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
|
||||
|
||||
AC_CHECK_TOOL(CC, gcc, gcc)
|
||||
@@ -246,15 +231,14 @@ AC_SUBST(GMODULE_LIBS)
|
||||
|
||||
AC_ARG_WITH(gc, [ --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
|
||||
|
||||
# Enable support for fast thread-local storage
|
||||
# Some systems have broken support, so we allow to disable it.
|
||||
# This is misnamed: __thread support has no relation to NPTL,
|
||||
# but people already use it...
|
||||
AC_ARG_WITH(nptl, [ --with-nptl=yes,no enable/disable support for __thread support],[],[with_nptl=yes])
|
||||
# Enable support for NPTL only features like fast thread-local storage
|
||||
# We can't reliably detect nptl at compile & run time
|
||||
# so this option will stay until nptl becomes more widespread
|
||||
AC_ARG_WITH(nptl, [ --with-nptl=yes,no enable/disable support for NPTL],[],[with_nptl=yes])
|
||||
|
||||
# Enable support for using sigaltstack for SIGSEGV and stack overflow handling
|
||||
# This does not work on some platforms (bug #55253)
|
||||
AC_ARG_WITH(sigaltstack, [ --with-sigaltstack=yes,no enable/disable support for sigaltstack],[],[with_sigaltstack=no])
|
||||
AC_ARG_WITH(sigaltstack, [ --with-sigaltstack=yes,no enable/disable support for sigaltstack],[],[with_sigaltstack=yes])
|
||||
|
||||
# assembly bundle support, see metadata/make-bundle.pl for more info
|
||||
AC_ARG_WITH(bundle, [ --with-bundle=bundle_template],[
|
||||
@@ -324,9 +308,9 @@ case "x$gc" in
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# tell libgc/configure about what we want
|
||||
ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
|
||||
we_are_embedded_in_mono=yes
|
||||
export we_are_embedded_in_mono
|
||||
export libgc_threads
|
||||
|
||||
AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
|
||||
AC_SUBST(LIBGC_CFLAGS)
|
||||
@@ -365,15 +349,10 @@ if test x$platform_win32 = xno; then
|
||||
else
|
||||
if test -d $with_jdk_dir/include/solaris; then
|
||||
jdk_platform=solaris
|
||||
else
|
||||
if test -f $with_jdk_dir/include/jni_md.h; then
|
||||
# GNU Classpath sources
|
||||
jdk_platform=
|
||||
else
|
||||
jdk_headers_found=no
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
jdk_headers_found=no
|
||||
fi
|
||||
@@ -870,42 +849,30 @@ if test x$platform_win32 = xno; then
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
|
||||
dnl *********************
|
||||
dnl * Check for scandir *
|
||||
dnl *********************
|
||||
AC_CHECK_FUNCS(scandir)
|
||||
|
||||
dnl *********************
|
||||
dnl *** Check for AIO ***
|
||||
dnl *********************
|
||||
AC_MSG_CHECKING([for SIGEV_THREAD definition])
|
||||
dnl Some systems (FreeBSD at least) may have aio_read
|
||||
dnl but don't support/define SIGEV_THREAD.
|
||||
AC_TRY_COMPILE([
|
||||
#include <sys/signal.h>
|
||||
],[
|
||||
int x = SIGEV_THREAD;
|
||||
],[
|
||||
ac_cv_c_sigev_thread=yes
|
||||
AC_MSG_RESULT(yes)
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
|
||||
if test "$ac_cv_c_sigev_thread" = "yes" ; then
|
||||
AC_CHECK_HEADERS(aio.h sys/aio.h)
|
||||
AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
|
||||
SIGVAL_PTR="undefined"
|
||||
if test "$ac_cv_header_aio_h" = "yes" -o "$ac_cv_header_sys_aio_h" = "yes" ; then
|
||||
AC_CHECK_MEMBER(union sigval.sigval_ptr,SIGVAL_PTR="sigval_ptr",, [
|
||||
#include <sys/signal.h>
|
||||
])
|
||||
AC_CHECK_MEMBER(union sigval.sival_ptr,SIGVAL_PTR="sival_ptr",, [
|
||||
#include <sys/signal.h>
|
||||
])
|
||||
if test "$SIGVAL_PTR" = "undefined" ; then
|
||||
AC_MSG_ERROR([Unable to detect field name in 'union sigval'])
|
||||
fi
|
||||
AC_CHECK_HEADERS(aio.h sys/aio.h)
|
||||
AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
|
||||
SIGVAL_PTR="undefined"
|
||||
if test "$ac_cv_header_aio_h" = "yes" -o "$ac_cv_header_sys_aio_h" = "yes" ; then
|
||||
AC_CHECK_MEMBER(union sigval.sigval_ptr,SIGVAL_PTR="sigval_ptr",, [
|
||||
#include <sys/signal.h>
|
||||
])
|
||||
AC_CHECK_MEMBER(union sigval.sival_ptr,SIGVAL_PTR="sival_ptr",, [
|
||||
#include <sys/signal.h>
|
||||
])
|
||||
if test "$SIGVAL_PTR" = "undefined" ; then
|
||||
AC_MSG_ERROR([Unable to detect field name in 'union sigval'])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
|
||||
else
|
||||
jdk_headers_found=no
|
||||
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
|
||||
AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
|
||||
fi
|
||||
@@ -925,13 +892,13 @@ ac_cv_c_socklen_t=yes
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
|
||||
AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
|
||||
AC_CHECK_FUNCS(truncl, , AC_MSG_CHECKING(for truncl in math.h)
|
||||
AC_TRY_LINK([#include <math.h>],
|
||||
[ trunc(0.0); ],
|
||||
[ truncl(0.0); ],
|
||||
[
|
||||
AC_DEFINE(HAVE_TRUNC)
|
||||
AC_DEFINE(HAVE_TRUNCL)
|
||||
AC_MSG_RESULT(yes)
|
||||
ac_cv_trunc=yes
|
||||
ac_cv_truncl=yes
|
||||
],
|
||||
AC_MSG_RESULT(no)))
|
||||
|
||||
@@ -957,7 +924,7 @@ case "{$target}" in
|
||||
dnl Win32 does not have /dev/random, they have their own method...
|
||||
|
||||
*-*-mingw*|*-*-cygwin*)
|
||||
ac_cv_have_dev_random=no
|
||||
ac_cv_have_dev_random = no
|
||||
;;
|
||||
|
||||
dnl Everywhere else, it's /dev/random
|
||||
@@ -1071,7 +1038,6 @@ case "$host" in
|
||||
arch_target=sparc;
|
||||
JIT_SUPPORTED=yes
|
||||
ACCESS_UNALIGNED="no"
|
||||
LIBC="libc.so"
|
||||
jit_wanted=true
|
||||
;;
|
||||
# alpha*-*-linux* | alpha*-*-osf*)
|
||||
@@ -1094,7 +1060,6 @@ case "$host" in
|
||||
hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
|
||||
TARGET=HPPA;
|
||||
arch_target=hppa;
|
||||
LIBC="libc.sl"
|
||||
ACCESS_UNALIGNED="no"
|
||||
;;
|
||||
macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
|
||||
@@ -1103,6 +1068,7 @@ case "$host" in
|
||||
arch_target=ppc;
|
||||
JIT_SUPPORTED=yes
|
||||
jit_wanted=true
|
||||
LIBC="libc.dylib"
|
||||
;;
|
||||
arm-*-linux-* | armv4l-*-linux-*)
|
||||
TARGET=ARM;
|
||||
@@ -1140,10 +1106,6 @@ libsuffix=".so"
|
||||
case "$host" in
|
||||
powerpc-*-darwin*)
|
||||
libsuffix=".dylib"
|
||||
LIBC="libc.dylib"
|
||||
;;
|
||||
*-*-*netbsd*)
|
||||
LIBC="libc.so.12"
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(libsuffix)
|
||||
@@ -1251,15 +1213,13 @@ samples/Makefile
|
||||
support/Makefile
|
||||
data/config
|
||||
mono.spec
|
||||
tools/Makefile
|
||||
tools/locale-builder/Makefile
|
||||
])
|
||||
|
||||
echo "
|
||||
|
||||
GC: $gc
|
||||
ICU: $enable_icu
|
||||
__thread: $with_nptl
|
||||
NPTL: $with_nptl
|
||||
SIGALTSTACK: $with_sigaltstack
|
||||
Engine: $jit_status
|
||||
2.0 Alpha: $PREVIEW
|
||||
|
||||
@@ -316,7 +316,7 @@ string GetTestResult ()
|
||||
{
|
||||
if (fill) {
|
||||
if (qs != "") qs += "&";
|
||||
qs += Request.QueryString.GetKey(n) + "=" + Server.UrlEncode (Request.QueryString [n]);
|
||||
qs += Request.QueryString.GetKey(n) + "=" + Request.QueryString [n];
|
||||
}
|
||||
if (Request.QueryString.GetKey(n) == "ext") fill = true;
|
||||
}
|
||||
@@ -338,17 +338,6 @@ string GetTestResult ()
|
||||
try
|
||||
{
|
||||
WebRequest req = WebRequest.Create (location + "/" + CurrentOperationName + "?" + qs);
|
||||
HttpCookieCollection cookies = Request.Cookies;
|
||||
int last = cookies.Count;
|
||||
if (last > 0) {
|
||||
CookieContainer container = new CookieContainer ();
|
||||
for (int i = 0; i < last; i++) {
|
||||
HttpCookie hcookie = cookies [i];
|
||||
Cookie cookie = new Cookie (hcookie.Name, hcookie.Value, hcookie.Path, hcookie.Domain);
|
||||
container.Add (cookie);
|
||||
}
|
||||
((HttpWebRequest) req).CookieContainer = container;
|
||||
}
|
||||
WebResponse resp = req.GetResponse();
|
||||
StreamReader sr = new StreamReader (resp.GetResponseStream());
|
||||
string s = sr.ReadToEnd ();
|
||||
|
||||
Binary file not shown.
@@ -4,6 +4,17 @@
|
||||
<dllmap dll="libxslt.dll" target="libxslt@libsuffix@" />
|
||||
<dllmap dll="libmySQL.dll" target="libmysqlclient@libsuffix@" />
|
||||
<dllmap dll="odbc32.dll" target="libodbc@libsuffix@" />
|
||||
<dllmap dll="libglib-2.0-0.dll" target="libglib-2.0@libsuffix@" />
|
||||
<dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0@libsuffix@" />
|
||||
<dllmap dll="libgthread-2.0-0.dll" target="libgthread-2.0@libsuffix@" />
|
||||
<dllmap dll="libpango-1.0-0.dll" target="libpango-1.0@libsuffix@" />
|
||||
<dllmap dll="libatk-1.0-0.dll" target="libatk-1.0@libsuffix@" />
|
||||
<dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0@libsuffix@" />
|
||||
<dllmap dll="libgdk_pixbuf-2.0-0.dll" target="libgdk_pixbuf-2.0@libsuffix@" />
|
||||
<dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0@libsuffix@" />
|
||||
<dllmap dll="libglade-2.0-0.dll" target="libglade-2.0@libsuffix@" />
|
||||
<dllmap dll="oci" target="clntsh" />
|
||||
<dllmap dll="gtkhtml-3.0" target="libgtkhtml-3.0@libsuffix@" />
|
||||
<dllmap dll="db2cli" target="libdb2_36@libsuffix@"/>
|
||||
<dllmap dll="gstreamer" target="libgstreamer-0.6@libsuffix@" />
|
||||
</configuration>
|
||||
+2
-16
@@ -35,8 +35,6 @@
|
||||
type="System.Web.Configuration.CustomErrorsConfigHandler, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<section name="pages"
|
||||
type="System.Web.Configuration.PagesConfigurationHandler, System.Web, Version=1.0.5000.0, Culture=neutral" />
|
||||
<section name="clientTarget"
|
||||
type="System.Web.Configuration.ClientTargetSectionHandler, System.Web, Version=1.0.5000.0, Culture=neutral" />
|
||||
</sectionGroup>
|
||||
<sectionGroup name="system.net">
|
||||
<section name="settings"
|
||||
@@ -79,7 +77,8 @@
|
||||
<httpHandlers>
|
||||
<add verb="*" path="Trace.axd" type="System.Web.Handlers.TraceHandler, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<add verb="*" path="*.asmx" validate="false" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<add verb="*" path="*.asmx" validate="false"
|
||||
type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services" />
|
||||
<add verb="*" path="*.ashx" type="System.Web.UI.SimpleHandlerFactory, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<add verb="GET" path="WebResource.axd" type="System.Web.Handlers.AssemblyResourceLoader, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<add verb="*" path="*.asax" type="System.Web.HttpForbiddenHandler, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
@@ -192,19 +191,6 @@
|
||||
</system.diagnostics>
|
||||
<system.drawing>
|
||||
</system.drawing>
|
||||
|
||||
<strongNames>
|
||||
<pubTokenMapping>
|
||||
<!-- ECMA key -->
|
||||
<map Token="b77a5c561934e089" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
|
||||
<!-- Microsoft (final) key -->
|
||||
<map Token="b03f5f7f11d50a3a" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
|
||||
<!-- Microsoft (Web Service Enhancement) key -->
|
||||
<map Token="31bf3856ad364e35" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
|
||||
<!-- IBM (DB2 Data Provider) key -->
|
||||
<map Token="7c307b91aa13d208" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
|
||||
</pubTokenMapping>
|
||||
</strongNames>
|
||||
</configuration>
|
||||
|
||||
|
||||
@@ -1,525 +0,0 @@
|
||||
|
||||
Here "abc" stays for "array bounds check", or "array bound checks", or
|
||||
some combination of the two...
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
USAGE
|
||||
|
||||
Simply use the "abcrem" optimization invoking mono.
|
||||
|
||||
To see if bound checks are actually removed, use "mono -v" and grep for
|
||||
"ARRAY-ACCESS" in the output, there should be a message for each check
|
||||
that has been removed.
|
||||
|
||||
To trace the algorithm execution, use "-v -v -v", and be prepared to be
|
||||
totally submersed by debugging messages...
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
EFFECTIVENESS
|
||||
|
||||
The abc removal code can now always remove bound checks from "clean"
|
||||
array scans in loops, and generally anyway there are clear conditions that
|
||||
already state that the index is "safe".
|
||||
|
||||
To be clearer, and give an idea of what the algorithm can and cannot do
|
||||
without describing it in detail... keep in mind that only "redunant" checks
|
||||
cannot be removed. By "redundant", I mean "already explicitly checked" in
|
||||
the method code.
|
||||
|
||||
Unfortunately, analyzing complex expressions is not so easy (see below for
|
||||
details), so the capabilities of this "abc remover" are limited.
|
||||
|
||||
These are simple guidelines:
|
||||
- Only simple comparisons between variables are understood.
|
||||
- Only increment-decrement operations are handled.
|
||||
- "switch" statements are not yet handled.
|
||||
|
||||
This means that code like this will be handled well:
|
||||
|
||||
for (int i = 0; i < a.Length; i++) {
|
||||
a [i] = .....
|
||||
}
|
||||
|
||||
The "i" variable could be declared out of the "for", the "for" could be a
|
||||
"while", and maybe even implemented with "goto", the array could be scanned
|
||||
in reverse order, and everything would still work.
|
||||
I could have a temporary variable storing the array length, and check on
|
||||
it inside the loop, and the abc removal would still occurr, like this:
|
||||
|
||||
int i = 0;
|
||||
int l = a.Length;
|
||||
while ( i < l ) {
|
||||
a [i] ......
|
||||
}
|
||||
|
||||
or this:
|
||||
|
||||
int l = a.Length;
|
||||
for (int i = l; i > 0; i--) {
|
||||
a [i] = .....
|
||||
}
|
||||
|
||||
|
||||
But just something like this
|
||||
|
||||
for (int i = 0; i < (a.Length -1); i++) .....
|
||||
|
||||
or like this
|
||||
|
||||
for (int i = 0; i < a.Length; i += 2) .....
|
||||
|
||||
would not work, the check would stay there, sorry :-(
|
||||
|
||||
Just to make you understand how things are tricky... this would work!
|
||||
|
||||
int limit = a.Length - 1;
|
||||
for (int i = 0; i < limit; i++) {
|
||||
a [i] = .....
|
||||
}
|
||||
|
||||
|
||||
A detailed explanation of the reason why things are done like this is given
|
||||
below...
|
||||
|
||||
All in all, the compiling phase is generally non so fast, and the abc removed
|
||||
are so few, that there is hardly a performance gain in using the "abcrem"
|
||||
flag in the compiling options for short programs like the ones I tried.
|
||||
|
||||
Anyway, various bound checks *are* removed, and this is good :-)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
THE ALGORITHM
|
||||
|
||||
Unfortunately, this time google has not been my friend, and I did not
|
||||
find an algorithm I could reasonably implement in the time frame I had,
|
||||
so I had to invent one. The two cleasses of algorithms I found were either
|
||||
simply an analisys of variable ranges (which is not very different from
|
||||
what I'm doing), or they were based on type systems richer than the .NET
|
||||
one (particularly, they required integer types to have an explicit range,
|
||||
which could be related to array ranges). By the way, it seems that the
|
||||
gcj people do not have an array bound check removal optimization (they
|
||||
just have a compiler flag that unconditionally removes all the checks,
|
||||
but this is not what we want).
|
||||
|
||||
This array bound check removal (abc removal) algorithm is based on
|
||||
symbolic execution concepts. I handle the removal like an "unreachable
|
||||
code elimination" (and in fact the optimization could be extended to remove
|
||||
also other unreachable sections of code, due to branches that "always go the
|
||||
same way").
|
||||
|
||||
In symbolic execution, variables do not have actual (numeric) values, but
|
||||
instead symbolic expressions (like "a", or "x+y").
|
||||
Also, branch conditions are handled like symbolic conditions (like "i<k"),
|
||||
which state relations between variable values.
|
||||
|
||||
The SSA representation inside mini is somewhat close to a symbolic
|
||||
representation of the execution of the compiled method.
|
||||
Particularly, the representation of variable values is exactly a symbolic
|
||||
one. It is enough to find all CEE_STIND_* instructions which store to a
|
||||
local variable, and their second argument is exactly the variable value.
|
||||
Actually, "cfg->vars [<variable-index>]->def" should contain exactly
|
||||
those store instructions, and the "get_variable_value_from_ssa_store"
|
||||
function extracts the variable value from there.
|
||||
|
||||
On the other hand, the conditions under which each basic block is
|
||||
executed are not made fully explicit.
|
||||
|
||||
However, it is not difficult to make them so.
|
||||
Each BB that has more than one exit BB, in practice must end either with
|
||||
a conditional branch instruction or with a switch instruction.
|
||||
In the first case, the BB has exactly two exit BBs, and their execution
|
||||
conditions are easy to get from the condition of the branch (see the
|
||||
"get_relation_from_branch_instruction" function, and expecially the end of
|
||||
"analyze_block" in abcremoval.c.
|
||||
If there is a switch, the jump condition of every exit BB is the equality
|
||||
of the switch argument with the particular index associated with its case
|
||||
(but the current implementation does not handle switch statements yet).
|
||||
|
||||
These individual conditions are in practice associated to each arc that
|
||||
connects BBs in the CFG (with the simple case that unconditional branches
|
||||
have a "TRUE" condition, because they always happen).
|
||||
|
||||
So, for each BB, its *proper* entry condition is the union of all the
|
||||
conditions associated to arcs that enter the BB. The "union" is like a
|
||||
logical "or", in the sense that either of the condition could be true,
|
||||
they are not necessarily all true. This means that if I can enter a BB
|
||||
in two ways, and in one case I know that "x>0", and in the other that
|
||||
"x==0", actually in the BB I know that "x>=0", which is a weaker
|
||||
condition (the union of the two).
|
||||
|
||||
Also, the *complete* entry condition for a BB is the "intersection" of all
|
||||
the entry conditions of its dominators. This is true because each dominator
|
||||
is the only way to reach the BB, so the entry condition of each dominator
|
||||
must be true if the control flow reached the BB. This translates to the
|
||||
logical "and" of all the "proper" conditions of the BBs met walking up in the
|
||||
dominator tree. So, if one says "x>0", and another "x==1", then I know
|
||||
that "x==1", which is a stronger condition (the intersection of the two).
|
||||
Note that, if the two conditions were "x>0" and "x==0", then the block would
|
||||
be unreachable (the intersection is empty), because some branch is impossible.
|
||||
|
||||
Another observation is that, inside each BB, every variable is subject to the
|
||||
complete entry condition of that very same BB, and not the one in which it is
|
||||
defined (with the "complete entry condition" being the thing I defined before,
|
||||
sorry if these terms "proper" and "complete" are strange, I found nothing
|
||||
better).
|
||||
This happens because the branch conditions are related to the control flow.
|
||||
I can define "i=a", and if I am in a BB where "a>0", then "i>0", but not
|
||||
otherwise.
|
||||
|
||||
So, intuitively, if the available conditions say "i>=0", and i is used as an
|
||||
index in an array access, then the lower bound check can be omitted.
|
||||
If the condition also says "(i>=0)&&(i<array.length)", the abc removal can
|
||||
occur.
|
||||
|
||||
So, a complete solution to the problem of abc removal would be the following:
|
||||
for each array access, build a system of equations containing:
|
||||
[1] all the symbolic variable definitions
|
||||
[2] the complete entry condition of the BB in which the array access occurs
|
||||
[3] the two "goal functions" ("index >=0" and "index < array.length")
|
||||
If the system is valid for *each possible* variable value, then the goal
|
||||
functions are always true, and the abc can be removed.
|
||||
|
||||
All this discussion is useful to give a precise specification to the problem
|
||||
we are trying to solve.
|
||||
The trouble is that, in the general case, the resulting system of equations
|
||||
is like a predicate in first order logic, which is semi-decidable, and its
|
||||
general solution is anyway too complex to be attempted in a JIT compiler
|
||||
(which should not contain a full fledged theorem prover).
|
||||
|
||||
Therefore, we must cut some corner.
|
||||
|
||||
|
||||
By the way, there is also another big problem, which is caused by "recursive"
|
||||
symbolic definitions. These definition can (and generally do) happen every
|
||||
time there is a loop. For instance, in the following piece of code
|
||||
|
||||
for ( int i = 0; i < array.length; i++ ) {
|
||||
Console.WriteLine( "array [i] = " + array [i] );
|
||||
}
|
||||
|
||||
one of the definitions of i is a PHI that can be either 0 or "i + 1".
|
||||
|
||||
Now, we know that mathematically "i = i + 1" does not make sense, and in
|
||||
fact symbolic values are not "equations", they are "symbolic definitions".
|
||||
|
||||
The symbolic value of i is a generic "n", where "n" is the number of
|
||||
iterations of the loop, but this is terrible to handle (and in more complex
|
||||
examples the symbolic definition of i simply cannot be written, because i is
|
||||
calculated in an iterative way).
|
||||
|
||||
However, the definition "i = i + 1" tells us something about i: it tells us
|
||||
that i "grows". So (from the PHI definition) we know that i is either 0, or
|
||||
"grows". This is enough to tell that "i>=0", which is what we want!
|
||||
It is important to note that recursive definitions can only occurr inside
|
||||
PHI definitions, because actually a variable cannot be defined *only* in terms
|
||||
of itself!
|
||||
|
||||
|
||||
At this point, I can explain which corners I want to cut to make the
|
||||
problem solvable. It will not remove all the abc that could theoretically
|
||||
be removed, but at least it will work.
|
||||
|
||||
The easiest way to cut corners is to only handle expressions which are
|
||||
"reasonably simple", and ignore the rest.
|
||||
Keep in mind that ignoring an expression is not harmful in itself.
|
||||
The algorithm will be simply "less powerful", because it will ignore
|
||||
conditions that could have caused to the removal of an abc, but will
|
||||
not remove checks "by mistake" (so the resulting code will be in any case
|
||||
correct).
|
||||
|
||||
In a first attempt, we can consider only conditions that have the simple
|
||||
possible form, which is "(compare simpleExpression simpleExpression)",
|
||||
where "simpleExpression" is either "(ldind.* local[*])" or
|
||||
"(ldlen (ldind.ref local[*]))" (or a constant, of course).
|
||||
|
||||
We can also "summarize" variable definitions, keeping only what is relevant
|
||||
to know: if they are greater or smaller than zero or other variables.
|
||||
|
||||
One particular note on PHI functions: they work (obviously) like the logical
|
||||
"or" of their definitions, and therefore are equivalent to the "logical or"
|
||||
of the summarization of their definitions.
|
||||
|
||||
About recursive definitions (which, believe me, are the worst thing in all
|
||||
this mess), we handle only "monotonic" ones. That is, we try to understand
|
||||
if the recursive definition (which, as we said above, must happen because
|
||||
of a loop) always "grows" or "gets smaller". In all other cases, we decide
|
||||
we cannot handle it.
|
||||
|
||||
So, the algorithm to optimize one method could be something like:
|
||||
|
||||
[1] Build the SSA representation.
|
||||
[2] Analyze each BB. Particularly, do the following:
|
||||
[2a] summarize its exit conditions
|
||||
[2b] summarize all the variable definitions occurring in the BB
|
||||
[2c] check if it contains array accesses (only as optimization, so that
|
||||
step 3 will be performed only when necessary)
|
||||
[3] Perform the removal. For each BB that contains array accesses, do:
|
||||
[3a] build an evaluation area where for each variable we keep track
|
||||
of its relations with zero and with each other variable.
|
||||
[3b] populate the evaluation area with the initial data (the variable
|
||||
definitions and the complete entry condition of the BB)
|
||||
[3c] propagate the relations between variables (so that from "a<b" and
|
||||
"b<c" we know that "a<c") in the evaluation area
|
||||
[3d] for each array access in the BB, use the evaluation area to "match
|
||||
conditions", to see if the goal functions are satisfied
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
LOW LEVEL DESIGN DECISIONS
|
||||
|
||||
One of the problems I had to solve was the representation of the relations
|
||||
between symbolic values.
|
||||
The "canonical" solution would be to have a complex, potentially recursive
|
||||
data structure, somewhat similar to MonoInst, and use it all the time (maybe
|
||||
MonoInst could be used "as is").
|
||||
The problem is that, at this point, the software would have to "play" with
|
||||
these structures, for instance to deduce "b < a-1" from "a > b+1", because we
|
||||
are interested in what value b has, and not a. And maybe the software should
|
||||
be able to do this without modifying the original condition, because it was
|
||||
used elsewhere (or could be reused).
|
||||
Then, the software should also be able to apply logical relations to
|
||||
conditions (like "(a>0)||(c<1)"), and manipulate them, too.
|
||||
|
||||
In my opinion, an optimizer written in this way risks to be too complex, and
|
||||
its performance not acceptable in a JIT compiler.
|
||||
Therefore, I decided to represent values in a "summarized" way.
|
||||
For instance, "x = a + 1" becomes "x > a" (and, by the way, "x = x + 1"
|
||||
would look like "x > x", which means that "x grows").
|
||||
So, each variable value is simply a "relation" of the variable with other
|
||||
variables or constants. Anything more complex is ignored.
|
||||
Relations are represented with flags (EQ, LT and GT), so that it is easy
|
||||
to combine them logically (it is enough to perform the bitwise operations
|
||||
on the flags). The condition (EQ|LT|GT) means we know nothing special, any
|
||||
value is possible. The empty condition would mean an unreachable statement
|
||||
(because no value is acceptable).
|
||||
|
||||
There is still the problem of identifying variables, and where to store all
|
||||
these relations. After some thinking, I decided that a "brute force" approach
|
||||
is the easier, and probably also the fastest. In practice, I keep in memory
|
||||
an array of "variable relations", where for each variable I record its
|
||||
relation with the constants 0 and 1 and an array of its relations with all
|
||||
other variables. The evaluation area, therefore, looks like a square matrix
|
||||
as large as the number of variables. I *know* that the matrix is rather sparse
|
||||
(in the sense that only few of its cells are significant), but I decided that
|
||||
this data structure was the simplest and more efficient anyway. After all,
|
||||
each cell takes just one byte, and any other data structure must be some
|
||||
kind of associative array (like a g_hash_table). Such a data structue is
|
||||
difficult to use with a MonoMemPool, and in the end is slower than a plain
|
||||
array, and has the storage overhead of all the pointers... in the end, maybe
|
||||
the full matrix is not a waste at all.
|
||||
<note>
|
||||
After a few benchmarks, I clearly see that the matrix works well if the
|
||||
variables are not too much, otherwise it gets "too sparse", and much time
|
||||
is wasted in the propagation phase. Maybe the data structure could be changed
|
||||
after a more careful evaluation of the problem...
|
||||
</note>
|
||||
|
||||
With these assumptions, all the memory used to represent values, conditions
|
||||
and the evaluation area can be allocated in advance (from a MonoMemPool), and
|
||||
used for all the analysis of one method. Moreover, the performance of logical
|
||||
operations is high (they are simple bitwise operations on bytes).
|
||||
<note>
|
||||
For the propagation phase, there was a function I could not easily code
|
||||
with bitwise operations. As that phase is a real pain for the performance
|
||||
(the complexity is quadratic, and it must be executed iteratively until
|
||||
nothing changes), I decided to code it in perl, and generate a precomputed
|
||||
table then used by the C code (just 64 bytes). I think this is faster than
|
||||
all those branches... Really, I could think again to phases 3c and 3d (see
|
||||
above), maybe there is a better way to do them.
|
||||
</note>
|
||||
|
||||
Of course not all expressions can be handled by the summarization, so the
|
||||
optimizer is not as effective as a full blown theorem prover...
|
||||
|
||||
Another thing related to design... the implementation is as less intrusive
|
||||
as possible.
|
||||
I "patched" the main files to add an option for abc removal, and handle it
|
||||
just like any other option, and then wrote all the relevant code in two
|
||||
separated files (one header for data structures, and a C file for the code).
|
||||
If the patch turns out to be useful also for other pourposes (like a more
|
||||
generic "unreachable code elimination", that detects branches that will never
|
||||
be taken using the analysis of variable values), it will not be difficult
|
||||
to integrate the branch summarizations into the BasicBlock data structures,
|
||||
and so on.
|
||||
|
||||
One last thing... in some places, I knowingly coded in an inefficient way.
|
||||
For instance, "remove_abc_from_block" does something only if the flag
|
||||
"has_array_access_instructions" is true, but I call it anyway, letting it
|
||||
do nothing (calling it conditionally would be better). There are several
|
||||
things like this in the code, but I was in a hurry, and preferred to make
|
||||
the code more readable (it is already difficult to understand as it is).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
WHEN IS ABC REMOVAL POSSIBLE? WHEN IS IT USEFUL?
|
||||
|
||||
Warning! Random ideas ahead!
|
||||
|
||||
In general, managed code should be safe, so abc removal is possible only if
|
||||
there already is some branch in the method that does the check.
|
||||
So, one check on the index is "mandatory", the abc removal can only avoid a
|
||||
second one (which is useless *because* of the first one).
|
||||
If in the code there is not a conditional branch that "avoids" to access
|
||||
an array out of its bounds, in general the abc removal cannot occur.
|
||||
|
||||
It could happen, however, that one method is called from another one, and
|
||||
the check on the index is performed in the caller.
|
||||
|
||||
For instance:
|
||||
|
||||
void
|
||||
caller( int[] a, int n ) {
|
||||
if ( n <= a.Length ) {
|
||||
for ( int i = 0; i < n; i++ ) {
|
||||
callee( a, i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void callee( int[] a, int i ) {
|
||||
Console.WriteLine( "a [i] = " + a [i] );
|
||||
}
|
||||
|
||||
|
||||
In this case, it should be possible to have two versions of the callee, one
|
||||
without checks, to be called from methods that do the check themselves, and
|
||||
another to be called otherwise.
|
||||
This kind of optimization could be profile driven: if one method is executed
|
||||
several times, wastes CPU time for bound checks, and is mostly called from
|
||||
another one, it could make sense to analyze the situation in detail.
|
||||
|
||||
However, one simple way to perform this optimization would be to inline
|
||||
the callee (so that the abc removal algorithm can see both methods at once).
|
||||
|
||||
The biggest benefits of abc removal can be seen for array accesses that
|
||||
occur "often", like the ones inside inner loops. This is why I tried to
|
||||
handle "recursive" variable definitions, because without them you cannot
|
||||
optimize inside loops, which is also where you need it most.
|
||||
|
||||
Another possible optimization (alwais related to loops) is the following:
|
||||
|
||||
void method( int[] a, int n ) {
|
||||
for ( int i = 0; i < n; i++ ) {
|
||||
Console.WriteLine( "a [i] = " + a [i] );
|
||||
}
|
||||
}
|
||||
|
||||
In this case, the check on n is missing, so the abc could not be removed.
|
||||
However, this would mean that i will be checked twice at each loop iteration,
|
||||
one against n, and the other against a.Length. The code could be transformed
|
||||
like this:
|
||||
|
||||
void method( int[] a, int n ) {
|
||||
if ( n < a.Length ) {
|
||||
for ( int i = 0; i < n; i++ ) {
|
||||
Console.WriteLine( "a [i] = " + a [i] ); // Remove abc
|
||||
}
|
||||
} else {
|
||||
for ( int i = 0; i < n; i++ ) {
|
||||
Console.WriteLine( "a [i] = " + a [i] ); // Leave abc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
This could result in performance improvements (again, probably this
|
||||
optimization should be profile driven).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
OPEN ISSUES
|
||||
|
||||
There are several issues that should still be addressed...
|
||||
|
||||
One is related to aliasing. For now, I decided to operate only on local
|
||||
variables, and ignore aliasing problems (and alias analisys has not yet
|
||||
been implemented anyway).
|
||||
Actually, I identified the local arrays with their length, because I
|
||||
totally ignore the contents of arrays (and objects in general).
|
||||
|
||||
Also, in several places in the code I only handle some cases, and ignore
|
||||
other more complex ones, which could anyway work (there are comments where
|
||||
this happens). Anyway, this is not harmful (the code is not as effective
|
||||
as it could be).
|
||||
|
||||
Another possible improvement is the explicit handling of all constants.
|
||||
For now, code like
|
||||
|
||||
void
|
||||
method () {
|
||||
int[] a = new int [16];
|
||||
for ( int i = 0; i < 16; i++ ) {
|
||||
a [i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
is not handled, because the two constants "16" are lost when variable
|
||||
relations are summarized (actually they are not lost, they are stored in the
|
||||
summarized values, but they are not yet used correctly).
|
||||
|
||||
The worst thing, anyway, is that for now I fail completely in distinguishing
|
||||
between signed and unsigned variables/operations/conditions, and between
|
||||
different integer sizes (in bytes). I did this on pourpose, just for lack of
|
||||
time, but this can turn out to be terribly wrong.
|
||||
The problem is caused by the fact that I handle arithmetical operations and
|
||||
conditions as "ideal" operations, but actually they can overflow and/or
|
||||
underflow, giving "surprising" results.
|
||||
|
||||
For instance, look at the following two methods:
|
||||
|
||||
public static void testSignedOverflow()
|
||||
{
|
||||
Console.WriteLine( "Testing signed overflow..." );
|
||||
int[] ia = new int[70000];
|
||||
int i = 1;
|
||||
while ( i <ia.Length )
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine( " i = " + i );
|
||||
ia[i] = i;
|
||||
}
|
||||
catch ( IndexOutOfRangeException e )
|
||||
{
|
||||
Console.WriteLine( "Yes, we had an overflow (i = " + i + ")" );
|
||||
}
|
||||
i *= 60000;
|
||||
}
|
||||
Console.WriteLine( "Testing signed overflow done." );
|
||||
}
|
||||
|
||||
public static void testUnsignedOverflow()
|
||||
{
|
||||
Console.WriteLine( "Testing unsigned overflow..." );
|
||||
int[] ia = new int[70000];
|
||||
uint i = 1;
|
||||
while ( i <ia.Length )
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine( " i = " + i );
|
||||
ia[i] = (int) i;
|
||||
}
|
||||
catch ( IndexOutOfRangeException e )
|
||||
{
|
||||
Console.WriteLine( "Yes, we had an overflow (i = " + i + ")" );
|
||||
}
|
||||
i *= 60000;
|
||||
}
|
||||
Console.WriteLine( "Testing unsigned overflow done." );
|
||||
}
|
||||
|
||||
In the "testSignedOverflow" method, the exception will be thrown, while
|
||||
in the "testUnsignedOverflow" everything will go on smoothly.
|
||||
The problem is that the test "i <ia.Length" is a signed comparison in the
|
||||
first case, and will not exit from the loop if the index is negative.
|
||||
Therefore, in the first method, the abc should not be removed.
|
||||
|
||||
In practice, the abc removal code should try to predict if any given
|
||||
expression could over/under-flow, and act accordingly.
|
||||
For now, I made so that the only accepted expressions are plain increments
|
||||
and decrements of variables (which cannot over/under-flow without being
|
||||
trapped by the existing conditions). Anyway, this issue should be analyzed
|
||||
better.
|
||||
By the way, in summarizations there is a field that keeps track of the
|
||||
relation with "1", which I planned to use exactly to summarize products and
|
||||
quotients, but it is never used (as I said, only increment and decrement
|
||||
operations are properly summarized).
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
Rules for opening shared files
|
||||
==============================
|
||||
|
||||
File is already open, with share set to none:
|
||||
|
||||
Can not open again
|
||||
|
||||
|
||||
File is already open for reading, with read share:
|
||||
|
||||
Can open for reading only, share must include read (can have write too)
|
||||
|
||||
|
||||
File is already open for reading, with write share:
|
||||
|
||||
Can open for writing only, share must include read (can have write too)
|
||||
|
||||
|
||||
File is already open for reading, with read + write share:
|
||||
|
||||
Can open for read, writing or both, share must include read (can have write too)
|
||||
|
||||
|
||||
File is already open for writing, with read share:
|
||||
|
||||
Can open for reading only, share must include write (can have read too)
|
||||
|
||||
|
||||
File is already open for writing, with write share:
|
||||
|
||||
Can open for writing only, share must include write (can have read too)
|
||||
|
||||
|
||||
File is already open for writing, with read + write share:
|
||||
|
||||
Can open for reading, writing or both, share must include write (can have read too)
|
||||
|
||||
|
||||
File is already open for reading + writing, with read share:
|
||||
|
||||
Can open for reading only, share must be read + write
|
||||
|
||||
|
||||
File is already open for reading + writing, with write share:
|
||||
|
||||
Can open for for writing only, share must be read + write
|
||||
|
||||
|
||||
File is already open for reading + writing, with read + write share:
|
||||
|
||||
Can open for read, writing or both, share must be read + write
|
||||
|
||||
|
||||
|
||||
Executive Summary
|
||||
-----------------
|
||||
|
||||
Second open must have access within first share, must set second share to at least first access
|
||||
|
||||
|
||||
|
||||
|
||||
Documenting code
|
||||
----------------
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
int access[] = {
|
||||
GENERIC_READ,
|
||||
GENERIC_WRITE,
|
||||
GENERIC_READ | GENERIC_WRITE
|
||||
};
|
||||
|
||||
char *access_names[] = {
|
||||
"G_READ",
|
||||
"G_WRITE",
|
||||
"G_READ|G_WRITE"
|
||||
};
|
||||
|
||||
int share[] = {
|
||||
FILE_SHARE_READ,
|
||||
FILE_SHARE_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE
|
||||
};
|
||||
|
||||
char *share_names[] = {
|
||||
"SHARE_READ",
|
||||
"SHARE_WRITE",
|
||||
"SHARE_READ|SHARE_WRITE"
|
||||
};
|
||||
|
||||
void lockfiles(int access1, int share1, int access2, int share2)
|
||||
{
|
||||
HANDLE h1, h2;
|
||||
BOOL ret;
|
||||
|
||||
if (access2 == 0 && share2 == 0) {
|
||||
printf("\n");
|
||||
printf("%22.22s\n%22.22s", access_names[access1], share_names[share1]);
|
||||
}
|
||||
|
||||
h1 = CreateFile("lockedfile",
|
||||
access[access1],
|
||||
share[share1],
|
||||
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h1 == INVALID_HANDLE_VALUE) {
|
||||
printf("Open1 failed: %d\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
h2 = CreateFile("lockedfile",
|
||||
access[access2],
|
||||
share[share2],
|
||||
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h2 == INVALID_HANDLE_VALUE) {
|
||||
printf(" %4.4s", "");
|
||||
} else {
|
||||
printf(" %4.4s", "OK");
|
||||
CloseHandle(h2);
|
||||
}
|
||||
|
||||
CloseHandle(h1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, j, k, l;
|
||||
|
||||
printf("\t\t\t\t\t\t\tSecond Open\n");
|
||||
printf("%22.22s G_RE G_RE G_RE G_WR G_WR G_WR G_RW G_RW G_RW\n", "");
|
||||
printf("%22.22s S_RE S_WR S_RW S_RE S_WR S_RW S_RE S_WR S_RW", "First open --v ");
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
for (k = 0; k < 3; k++) {
|
||||
for (l = 0; l < 3; l++) {
|
||||
lockfiles(i, j, k, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Code output
|
||||
-----------
|
||||
|
||||
Second Open
|
||||
G_RE G_RE G_RE G_WR G_WR G_WR G_RW G_RW G_RW
|
||||
First open --v S_RE S_WR S_RW S_RE S_WR S_RW S_RE S_WR S_RW
|
||||
G_READ
|
||||
SHARE_READ OK OK
|
||||
G_READ
|
||||
SHARE_WRITE OK OK
|
||||
G_READ
|
||||
SHARE_READ|SHARE_WRITE OK OK OK OK OK OK
|
||||
G_WRITE
|
||||
SHARE_READ OK OK
|
||||
G_WRITE
|
||||
SHARE_WRITE OK OK
|
||||
G_WRITE
|
||||
SHARE_READ|SHARE_WRITE OK OK OK OK OK OK
|
||||
G_READ|G_WRITE
|
||||
SHARE_READ OK
|
||||
G_READ|G_WRITE
|
||||
SHARE_WRITE OK
|
||||
G_READ|G_WRITE
|
||||
SHARE_READ|SHARE_WRITE OK OK OK
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<h1>Mono 1.0 Release Notes</h1>
|
||||
|
||||
<h2>What does Mono Include</h2>
|
||||
|
||||
<h2>Missing functionality</h2>
|
||||
|
||||
<p>COM support.
|
||||
|
||||
<p>EnterpriseServices are non-existant.
|
||||
|
||||
<p>Windows.Forms is only available as a preview, it is not
|
||||
completed nor stable.
|
||||
|
||||
<h3>Assembly: System.Drawing</h3>
|
||||
|
||||
<p>System.Drawing.Printing is not supported.
|
||||
@@ -1,7 +1,3 @@
|
||||
2004-05-05 Zoltan Varga <[email protected]>
|
||||
|
||||
* mono-jni.c: Implement some missing JNI functions.
|
||||
|
||||
2004-04-13 Zoltan Varga <[email protected]>
|
||||
|
||||
* mono-jni.c: Use <stdarg.h> instead of <varargs.h>.
|
||||
|
||||
+25
-44
@@ -35,8 +35,7 @@ void mono_jni_jnienv_init (
|
||||
void *invokemethod_func,
|
||||
void *getmethodarglist_func,
|
||||
void *findclass_func,
|
||||
void *getjnienv_func,
|
||||
void *allocobject_func);
|
||||
void *getjnienv_func);
|
||||
|
||||
void* mono_jni_get_func_table (void);
|
||||
|
||||
@@ -75,7 +74,6 @@ typedef struct MonoJniFunctions {
|
||||
void * (*GetMethodArgList) (void *cookie);
|
||||
void * (*FindClass) (void *name);
|
||||
void * (*GetJniEnv) (void);
|
||||
void * (*AllocObject) (void *klass);
|
||||
} MonoJniFunctions;
|
||||
|
||||
static MonoJniFunctions jniFuncs;
|
||||
@@ -97,8 +95,7 @@ mono_jni_jnienv_init (
|
||||
void *invokemethod_func,
|
||||
void *getmethodarglist_func,
|
||||
void *findclass_func,
|
||||
void *getjnienv_func,
|
||||
void *allocobject_func)
|
||||
void *getjnienv_func)
|
||||
{
|
||||
jniFuncs.MakeLocalRef = makelocalref_func;
|
||||
jniFuncs.UnwrapRef = unwrap_func;
|
||||
@@ -116,7 +113,6 @@ mono_jni_jnienv_init (
|
||||
jniFuncs.GetMethodArgList = getmethodarglist_func;
|
||||
jniFuncs.FindClass = findclass_func;
|
||||
jniFuncs.GetJniEnv = getjnienv_func;
|
||||
jniFuncs.AllocObject = allocobject_func;
|
||||
}
|
||||
|
||||
static void *jni_func_table[256];
|
||||
@@ -245,7 +241,7 @@ static jboolean JNICALL IsSameObject (JNIEnv *env, jobject obj1, jobject obj2) {
|
||||
static jobject JNICALL NewLocalRef (JNIEnv *env, jobject ref) { printf ("JNI Function NewLocalRef is not implemented.\n"); g_assert_not_reached (); return 0; }
|
||||
static jint JNICALL EnsureLocalCapacity (JNIEnv *env, jint capacity) { printf ("JNI Function EnsureLocalCapacity is not implemented.\n"); g_assert_not_reached (); return 0; }
|
||||
|
||||
static jobject JNICALL AllocObject (JNIEnv *env, jclass clazz) { printf ("JNI Function EnsureLocalCapacity is not implemented.\n"); g_assert_not_reached (); return 0; }
|
||||
static jobject JNICALL AllocObject (JNIEnv *env, jclass clazz) { printf ("JNI Function AllocObject is not implemented.\n"); g_assert_not_reached (); return 0; }
|
||||
|
||||
static jclass JNICALL GetObjectClass (JNIEnv *env, jobject obj)
|
||||
{
|
||||
@@ -836,18 +832,6 @@ static type* JNICALL Get##Type##ArrayElements(JNIEnv *env, type##Array array, jb
|
||||
static void JNICALL Release##Type##ArrayElements(JNIEnv *env, type##Array array, type *elems, jint mode)\
|
||||
{\
|
||||
return; \
|
||||
} \
|
||||
static void JNICALL Get##Type##ArrayRegion (JNIEnv *env, type##Array array, jsize start, jsize l, type *buf) \
|
||||
{\
|
||||
MonoArray *obj; \
|
||||
obj = jniFuncs.UnwrapRef (env, (void*)array); \
|
||||
memcpy (buf, mono_array_addr (obj, sizeof (type), start), (sizeof (type) * l)); \
|
||||
} \
|
||||
static void JNICALL Set##Type##ArrayRegion (JNIEnv *env, type##Array array, jsize start, jsize l, type *buf) \
|
||||
{ \
|
||||
MonoArray *obj; \
|
||||
obj = jniFuncs.UnwrapRef (env, (void*)array); \
|
||||
memcpy (mono_array_addr (obj, sizeof (type), start), buf, (sizeof (type) * l)); \
|
||||
}
|
||||
|
||||
GET_SET_ARRAY_ELEMENTS(Boolean,jboolean,gboolean)
|
||||
@@ -859,32 +843,23 @@ GET_SET_ARRAY_ELEMENTS(Long,jlong,glong)
|
||||
GET_SET_ARRAY_ELEMENTS(Float,jfloat,float)
|
||||
GET_SET_ARRAY_ELEMENTS(Double,jdouble,double)
|
||||
|
||||
static void * JNICALL GetPrimitiveArrayCritical (JNIEnv *env, jarray array, jboolean *isCopy) {
|
||||
MonoArray *obj;
|
||||
static void JNICALL GetBooleanArrayRegion (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf) { printf ("JNI Function GetBooleanArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL GetByteArrayRegion (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf) { printf ("JNI Function GetByteArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL GetCharArrayRegion (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf) { printf ("JNI Function GetCharArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL GetShortArrayRegion (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf) { printf ("JNI Function GetShortArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL GetIntArrayRegion (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf) { printf ("JNI Function GetIntArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL GetLongArrayRegion (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf) { printf ("JNI Function GetLongArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL GetFloatArrayRegion (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf) { printf ("JNI Function GetFloatArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL GetDoubleArrayRegion (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf) { printf ("JNI Function GetDoubleArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
|
||||
obj = jniFuncs.UnwrapRef (env, (void*)array);
|
||||
if (isCopy)
|
||||
*isCopy = JNI_FALSE;
|
||||
return mono_array_addr (obj, void*, 0);
|
||||
}
|
||||
|
||||
static void JNICALL ReleasePrimitiveArrayCritical (JNIEnv *env, jarray array, void *carray, jint mode) {
|
||||
}
|
||||
|
||||
static const jchar * JNICALL GetStringCritical (JNIEnv *env, jstring string, jboolean *isCopy) {
|
||||
MonoString *obj;
|
||||
|
||||
obj = jniFuncs.UnwrapRef (env, (void*)string);
|
||||
|
||||
if (isCopy)
|
||||
*isCopy = JNI_FALSE;
|
||||
|
||||
return mono_string_chars (obj);
|
||||
}
|
||||
|
||||
static void JNICALL ReleaseStringCritical (JNIEnv *env, jstring string, const jchar *cstring)
|
||||
{
|
||||
}
|
||||
static void JNICALL SetBooleanArrayRegion (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf) { printf ("JNI Function SetBooleanArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL SetByteArrayRegion (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf) { printf ("JNI Function SetByteArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL SetCharArrayRegion (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf) { printf ("JNI Function SetCharArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL SetShortArrayRegion (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf) { printf ("JNI Function SetShortArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL SetIntArrayRegion (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf) { printf ("JNI Function SetIntArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL SetLongArrayRegion (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf) { printf ("JNI Function SetLongArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL SetFloatArrayRegion (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf) { printf ("JNI Function SetFloatArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL SetDoubleArrayRegion (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf) { printf ("JNI Function SetDoubleArrayRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
|
||||
static jobject JNICALL NewObjectA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
|
||||
{
|
||||
@@ -958,6 +933,12 @@ jint JNICALL GetJavaVM (JNIEnv *env, JavaVM **vm)
|
||||
static void JNICALL GetStringRegion (JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf) { printf ("JNI Function GetStringRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
static void JNICALL GetStringUTFRegion (JNIEnv *env, jstring str, jsize start, jsize len, char *buf) { printf ("JNI Function GetStringUTFRegion is not implemented.\n"); g_assert_not_reached (); }
|
||||
|
||||
static void * JNICALL GetPrimitiveArrayCritical (JNIEnv *env, jarray array, jboolean *isCopy) { printf ("JNI Function GetPrimitiveArrayCritical is not implemented.\n"); g_assert_not_reached (); return NULL; }
|
||||
static void JNICALL ReleasePrimitiveArrayCritical (JNIEnv *env, jarray array, void *carray, jint mode) { printf ("JNI Function ReleasePrimitiveArrayCritical is not implemented.\n"); g_assert_not_reached (); }
|
||||
|
||||
static const jchar * JNICALL GetStringCritical (JNIEnv *env, jstring string, jboolean *isCopy) { printf ("JNI Function GetStringCritical is not implemented.\n"); g_assert_not_reached (); return NULL; }
|
||||
static void JNICALL ReleaseStringCritical (JNIEnv *env, jstring string, const jchar *cstring) { printf ("JNI Function ReleaseStringCritical is not implemented.\n"); g_assert_not_reached (); }
|
||||
|
||||
static jweak JNICALL NewWeakGlobalRef (JNIEnv *env, jobject obj) { printf ("JNI Function NewWeakGlobalRef is not implemented.\n"); g_assert_not_reached (); return 0; }
|
||||
static void JNICALL DeleteWeakGlobalRef (JNIEnv *env, jweak ref) { printf ("JNI Function DeleteWeakGlobalRef is not implemented.\n"); g_assert_not_reached (); }
|
||||
|
||||
|
||||
@@ -108,6 +108,10 @@ key containers. The option is equivalent to including [assembly:
|
||||
AssemblyKeyName ("CONTAINER")] in your source code. Compiler option
|
||||
takes precedence over the attributes.
|
||||
.TP
|
||||
.I \-\-stacktrace
|
||||
Generates a stack trace at the time the error is reported, useful for
|
||||
debugging the compiler.
|
||||
.TP
|
||||
.I -lib:PATHLIST
|
||||
Each path specified in the comma-separated list will direct the
|
||||
compiler to look for libraries in that specified path.
|
||||
@@ -138,16 +142,6 @@ Names the output file to be generated.
|
||||
.I \-\-parse
|
||||
Used for benchmarking. The compiler will only parse its input files.
|
||||
.TP
|
||||
.I \-pkg:package1[,packageN]
|
||||
The compiler will invoke pkg-config --libs on the set of packages
|
||||
specified on the command line to obtain libraries and directories to
|
||||
compile the code.
|
||||
.PP
|
||||
This is typically used with third party components, like this:
|
||||
.nf
|
||||
$ mcs -pkg:gtk-sharp demo.cs
|
||||
.fi
|
||||
.TP
|
||||
.I -resource:RESOURCE[,ID]
|
||||
Embeds to the given resource file. The optional ID can be used to
|
||||
give a different name to the resource. If not specified, the resource
|
||||
@@ -171,13 +165,9 @@ Does recursive compilation using the specified pattern. In Unix the
|
||||
shell will perform globbing, so you migth want to use it like this:
|
||||
.PP
|
||||
.nf
|
||||
$ mcs -recurse:'*.cs'
|
||||
bash$ mcs -recurse:'*.cs'
|
||||
.fi
|
||||
.TP
|
||||
.I \-\-stacktrace
|
||||
Generates a stack trace at the time the error is reported, useful for
|
||||
debugging the compiler.
|
||||
.TP
|
||||
.I \-target:KIND, \-t:KIND
|
||||
Used to specify the desired target. The possible values are: exe
|
||||
(plain executable), winexe (Windows.Forms executable), library
|
||||
|
||||
+17
-32
@@ -238,10 +238,10 @@ Finally, namespaces can be specified using the N: prefix:
|
||||
Turns off the garbage collection in Mono. This should be only used
|
||||
for debugging purposes
|
||||
.TP
|
||||
.I "MONO_ASPNET_NODELETE"
|
||||
If set to any value, temporary source files generated by ASP.NET support
|
||||
classes will not be removed. They will be kept in the user's temporary
|
||||
directory.
|
||||
.I "MONO_PATH"
|
||||
Provides a search path to the runtime where to look for library files.
|
||||
Directories are separated by the platform path separator (colons on unix). Example:
|
||||
.B /home/username/lib:/usr/local/mono/lib
|
||||
.TP
|
||||
.I "MONO_CFG_DIR"
|
||||
If set, this variable overrides the default system configuration directory
|
||||
@@ -254,10 +254,8 @@ environment variable.
|
||||
.TP
|
||||
.I "MONO_DEBUG"
|
||||
If set, enables some features of the runtime useful for debugging.
|
||||
It makes the runtime display the stack traces for all the threads
|
||||
running and exit when mono is interrupted (Ctrl-C) and print some
|
||||
additional messages on error conditions. It may not exit cleanly. Use at
|
||||
your own risk.
|
||||
Currently it only makes the runtime display the stack traces for all the
|
||||
threads running and exit. It may not exit cleanly. Use at your own risk.
|
||||
.TP
|
||||
.I "MONO_DISABLE_AIO"
|
||||
If set, tells mono NOT to attempt using native asynchronous I/O services. In
|
||||
@@ -269,41 +267,18 @@ Windows I/O Emulation layer, and handles (files, events, mutexes,
|
||||
pipes) will not be shared across processes. Process creation is also
|
||||
disabled. This option is only available on Unix.
|
||||
.TP
|
||||
.I "MONO_EGD_SOCKET"
|
||||
For platforms that do not otherwise have a way of obtaining random bytes
|
||||
this can be set to the name of a file system socket on which an egd or
|
||||
prngd daemon is listening.
|
||||
.TP
|
||||
.I "MONO_EXTERNAL_ENCODINGS"
|
||||
If set, contains a colon-separated list of text encodings to try when
|
||||
turning externally-generated text (e.g. command-line arguments or
|
||||
filenames) into Unicode. The encoding names come from the list
|
||||
provided by iconv, and the special case "default_locale" which refers
|
||||
to the current locale's default encoding.
|
||||
.IP
|
||||
.TP
|
||||
When reading externally-generated text strings UTF-8 is tried first,
|
||||
and then this list is tried in order with the first successful
|
||||
conversion ending the search. When writing external text (e.g. new
|
||||
filenames or arguments to new processes) the first item in this list
|
||||
is used, or UTF-8 if the environment variable is not set.
|
||||
.TP
|
||||
.I "MONO_MANAGED_WATCHER"
|
||||
If set to any value, System.IO.FileSystemWatcher will use the default
|
||||
managed implementation (slow). If unset, mono will try to use FAM under
|
||||
Unix systems and native API calls on Windows, falling back to the
|
||||
managed implementation on error.
|
||||
.TP
|
||||
.I "MONO_PATH"
|
||||
Provides a search path to the runtime where to look for library files.
|
||||
Directories are separated by the platform path separator (colons on unix). Example:
|
||||
.B /home/username/lib:/usr/local/mono/lib
|
||||
.TP
|
||||
.I "MONO_GAC_PREFIX"
|
||||
Provides a prefix the runtime uses to look for Global Assembly Caches.
|
||||
Directories are separated by the platform path separator (colons on
|
||||
unix). MONO_GAC_PREFIX should point to the top directory of a prefixed
|
||||
install. Or to the directory provided in the gacutil /gacdir command. Example:
|
||||
.B /home/username/.mono:/usr/local/mono/
|
||||
.TP
|
||||
.I "MONO_SHARED_DIR"
|
||||
If set its the directory where the ".wapi" handle state is stored.
|
||||
@@ -319,6 +294,16 @@ new and might have some bugs. Basically we recommend Managed XSLT
|
||||
solution, but if it contains some blocking bugs, then you can also
|
||||
use traditional libxslt. If you want to use msxsl:script, you have
|
||||
to select Managed XSLT.
|
||||
.TP
|
||||
.I "MONO_MANAGED_WATCHER"
|
||||
If set to any value, System.IO.FileSystemWatcher will use the default
|
||||
managed implementation (slow). If unset, mono will try to use FAM under
|
||||
Unix systems and native API calls on Windows, falling back to the
|
||||
managed implementation on error.
|
||||
.TP
|
||||
.I "MONO_CODEDOM_NODELETE"
|
||||
If set to any value, the C# CodeDom compiler will not remove the temporary
|
||||
source files generated.
|
||||
.SH FILES
|
||||
On Unix assemblies are loaded from the installation lib directory. If you set
|
||||
`prefix' to /usr, the assemblies will be located in /usr/lib. On
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
.\"
|
||||
.\" sn manual page.
|
||||
.\" Copyright 2003 Motus Technologies
|
||||
.\" Copyright 2004 Novell
|
||||
.\" Author:
|
||||
.\" Sebastien Pouliot <sebastien@ximian.com>
|
||||
.\" Sebastien Pouliot (spouliot@motus.com)
|
||||
.\"
|
||||
.TH Mono "sn"
|
||||
.SH NAME
|
||||
@@ -14,33 +13,24 @@ sn \- Digitally sign/verify/compare strongname on CLR assemblies.
|
||||
.SH DESCRIPTION
|
||||
Digitally sign, verify or compare, CLR assemblies using strongnames.
|
||||
.SH CONFIGURATION OPTIONS
|
||||
Configuration options are stored in the machine.config configuration file
|
||||
under /configuration/strongNames.
|
||||
.TP
|
||||
.I "-c provider"
|
||||
Change the default CSP (Crypto Service Provider). Currently not supported
|
||||
in Mono.
|
||||
Change the default CSP (Crypto Service Provider).
|
||||
.TP
|
||||
.I "-m [y|n]"
|
||||
Use a machine [y] key container or a user [n] key container. Currently not
|
||||
supported in Mono.
|
||||
Use a machine [y] key container or a user [n] key container.
|
||||
.TP
|
||||
.I "-Vl"
|
||||
List the verification options. The list is kept under /configuration/
|
||||
strongNames/verificationSettings in machine.config.
|
||||
List the verification options.
|
||||
.TP
|
||||
.I "-Vr assembly [userlist]"
|
||||
Exempt the specified assembly from verification for the specified user list.
|
||||
Currently not supported by sn, you must edit machine.config manually if you
|
||||
require this.
|
||||
.TP
|
||||
.I "-Vu assembly"
|
||||
Remove the exemption entry for the specified assembly. Currently not
|
||||
supported by sn, you must edit machine.config manually if you require this.
|
||||
Remove the exemption entry for the specified assembly.
|
||||
.TP
|
||||
.I "-Vx"
|
||||
Remove all exemptions entries. Currently not supported by sn, you must edit
|
||||
machine.config manually if you require this.
|
||||
Remove all exemptions entries.
|
||||
.SH CSP RELATED OPTIONS
|
||||
.TP
|
||||
.I "-d container"
|
||||
@@ -72,14 +62,11 @@ Compare if assembly1 and assembly are the same exception for their signature.
|
||||
This is done by comparing the hash of the metadata of both assembly.
|
||||
.TP
|
||||
.I "-k keypair.snk"
|
||||
Create a new strongname keypair (a 1024 bits RSA keypair) in the specified
|
||||
file.
|
||||
Create a new strongname keypair in the specified file.
|
||||
.TP
|
||||
.I "-R assembly keypair.snk"
|
||||
Resign the specified assembly using the specified strongname keypair file
|
||||
(SNK). You can only sign an assembly with the private key (SNK) that match
|
||||
the public key inside the assembly (unless it's public key token has been
|
||||
remapped in machine.config).
|
||||
(SNK).
|
||||
.TP
|
||||
.I "-Rc assembly container"
|
||||
Resign the specified assembly using the specified strongname container.
|
||||
@@ -96,10 +83,10 @@ Show the public key from the specified assembly.
|
||||
.I "-Tp assembly"
|
||||
Show the public key and the public key token from the specified assembly.
|
||||
.TP
|
||||
.I "-v assembly"
|
||||
.I "-V assembly"
|
||||
Verify the specified assembly signature.
|
||||
.TP
|
||||
.I "-vf assembly"
|
||||
.I "-Vf assembly"
|
||||
Verify the specified assembly signature (even if disabled).
|
||||
.SH HELP OPTIONS
|
||||
.TP
|
||||
@@ -117,35 +104,10 @@ Display convertion related help about this tool.
|
||||
.TP
|
||||
.I "-h sn", "-? sn"
|
||||
Display strongname related help about this tool.
|
||||
.SH CONFIGURATION FILE
|
||||
.TP
|
||||
Strongnames configuration is kept in "machine.config" file. Currently two
|
||||
features can be configured.
|
||||
.TP
|
||||
.I "/configuration/strongNames/pubTokenMapping"
|
||||
This mechanism let Mono remap a public key token, like the ECMA token, to
|
||||
another public key for verification. This is useful in two scenarios. First
|
||||
assemblies signed with the "ECMA key" needs to be verified by the "runtime"
|
||||
key (as the ECMA key isn't a public key). Second, many assemblies are signed
|
||||
with private keys that Mono can't use (e.g. System.Security.dll assembly).
|
||||
A new key cannot be used because it should change thr strongname (a new key
|
||||
pair would have a new public key which would produce a new token). Public
|
||||
key token remapping is the solution for both problems. Each token must be
|
||||
configured in a "map" entry similar to this one: <map Token="b77a5c561934e089"
|
||||
PublicKey="00..." />
|
||||
.TP
|
||||
.I "/configuration/strongNames/verificationSettings"
|
||||
It is often useful during development to use delay signed assemblies.
|
||||
Normally* the runtime wouldn't allow delay-signed assemblies to be loaded.
|
||||
This feature allows some delay-signed assemblies (based on their public key
|
||||
token, optionally assembly name and user name) to be used like they were
|
||||
fully signed assemblies. [*] Note that Mono 1.0 "runtime" doesn't validate
|
||||
strongname signatures so this option shouldn't be required in most scenarios.
|
||||
.SH AUTHOR
|
||||
Written by Sebastien Pouliot
|
||||
.SH COPYRIGHT
|
||||
Copyright (C) 2003 Motus Technologies.
|
||||
Copyright (C) 2004 Novell.
|
||||
Released under BSD license.
|
||||
.SH MAILING LISTS
|
||||
Visit http://mail.ximian.com/mailman/mono-list for details.
|
||||
|
||||
@@ -49,9 +49,6 @@ Specifies the namespace of the XML schema element for which a class or a dataset
|
||||
.I "/language:name" "/l:name"
|
||||
Specifies the programming language to use for the generated code. The only supported languages are CS (C#) and VB (Visual Basic.NET).
|
||||
.TP
|
||||
.I "/generator:type,assembly" "/g:type,assembly"
|
||||
Indicates xsd.exe to use custom CodeDomProvider to generate code. The type name must be full name. Assembly name is a local file name that is going to be loaded. The specified Type must have the default constructor.
|
||||
.TP
|
||||
.I "/outputdir:path" "/o:path"
|
||||
Specifies the directory where to generate the code or schemas.
|
||||
.TP
|
||||
|
||||
+33
-78
@@ -1,48 +1,3 @@
|
||||
2004-06-14 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (all-profiles, clean-profiles): Simplify slightly.
|
||||
|
||||
2004-06-05 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* Makefile: added target run-test-ondotnet.
|
||||
|
||||
2004-05-26 Raja R Harinath <[email protected]>
|
||||
|
||||
* nunit20/util/Makefile (EXTRA_DISTFILES): Remove
|
||||
Transform.resources.
|
||||
($(the_lib)): Make Transform.resources using internal resgen.
|
||||
* nunit20/util/Transform.resources: Rebuild.
|
||||
|
||||
2004-05-25 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* nunit.key: New. NUnit private key. Due to build issues the key
|
||||
must be present in this directory.
|
||||
|
||||
2004-05-20 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (SUBDIRS): Move 'monoresgen' ahead of 'class'.
|
||||
|
||||
2004-05-17 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (all, clean): Remove indirection.
|
||||
(clean-profiles): New.
|
||||
|
||||
2004-05-13 Jackson Harper <[email protected]>
|
||||
|
||||
* Makefile: default build is no longer the multi profile build. Do
|
||||
build both 1.1 and 2.0 profiles use the all-profiles target.
|
||||
|
||||
2004-05-12 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* Makefile: disable net_2_0 on windows. It doesn't build. Don't
|
||||
try to build net_1_0 and net_2_0 if we provide a PROFILE=xxx in the
|
||||
command line.
|
||||
|
||||
2004-05-10 Raja R Harinath <[email protected]>
|
||||
|
||||
* INSTALL.txt: Don't mention 'fullbuild'. Mention 'bootstrap'
|
||||
instead. Update instructions for 'monocharge'.
|
||||
|
||||
2004-04-30 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (SUBDIRS): Remove 'gmcs' for now.
|
||||
@@ -192,41 +147,41 @@
|
||||
which includes a MySQL ADO.NET Provider.
|
||||
Contributed by Reggie Burnett <[email protected]>
|
||||
from ByteFX, Inc.
|
||||
ByteFX.Data 0.6.5 is Copyright 2002-2003, ByteFX, Inc.
|
||||
|
||||
Added the following files and directories:
|
||||
ByteFX.Data 0.6.5 is Copyright 2002-2003, ByteFX, Inc.
|
||||
|
||||
Added the following files and directories:
|
||||
|
||||
class/ByteFX.Data/AssemblyInfo.cs
|
||||
class/ByteFX.Data/list
|
||||
class/ByteFX.Data/ByteFX.Data.build
|
||||
class/ByteFX.Data/makefile.gnu
|
||||
class/ByteFX.Data/ChangeLog.txt
|
||||
class/ByteFX.Data/readme.txt
|
||||
class/ByteFX.Data/lgpl.txt: new files
|
||||
|
||||
BitStream.cs
|
||||
Connection.cs
|
||||
Field.cs
|
||||
Inflater.cs
|
||||
ConnectionString.cs
|
||||
HuffmanTree.cs
|
||||
NamedPipeStream.cs
|
||||
class/ByteFX.Data/Common: added files to new directory
|
||||
|
||||
Driver.cs
|
||||
command.resx
|
||||
todo.txt
|
||||
CommandBuilder.cs
|
||||
Exception.cs
|
||||
dataadapter.cs
|
||||
transcaction.cs
|
||||
Connection.cs
|
||||
Field.cs
|
||||
datareader.cs
|
||||
Connection.resx
|
||||
MysqlDefs.cs
|
||||
class/ByteFX.Data/AssemblyInfo.cs
|
||||
class/ByteFX.Data/list
|
||||
class/ByteFX.Data/ByteFX.Data.build
|
||||
class/ByteFX.Data/makefile.gnu
|
||||
class/ByteFX.Data/ChangeLog.txt
|
||||
class/ByteFX.Data/readme.txt
|
||||
class/ByteFX.Data/lgpl.txt: new files
|
||||
|
||||
BitStream.cs
|
||||
Connection.cs
|
||||
Field.cs
|
||||
Inflater.cs
|
||||
ConnectionString.cs
|
||||
HuffmanTree.cs
|
||||
NamedPipeStream.cs
|
||||
class/ByteFX.Data/Common: added files to new directory
|
||||
|
||||
Driver.cs
|
||||
command.resx
|
||||
todo.txt
|
||||
CommandBuilder.cs
|
||||
Exception.cs
|
||||
dataadapter.cs
|
||||
transcaction.cs
|
||||
Connection.cs
|
||||
Field.cs
|
||||
datareader.cs
|
||||
Connection.resx
|
||||
MysqlDefs.cs
|
||||
parameter.cs
|
||||
class/ByteFX.Data/mysqlclient: added files to new directory
|
||||
class/ByteFX.Data/mysqlclient: added files to new directory
|
||||
|
||||
command.cs
|
||||
parameter_collection.cs
|
||||
|
||||
+15
-17
@@ -25,15 +25,15 @@ compilers and tools.
|
||||
|
||||
If you only want to build a snapshot or a fresh CVS checkout of the
|
||||
sources, you should go into the `mono' sibling directory and issue the
|
||||
make bootstrap command, like this:
|
||||
make fullbuild command, like this:
|
||||
|
||||
cd ../mono
|
||||
./autogen.sh --prefix=/usr/local
|
||||
make bootstrap
|
||||
make install
|
||||
make fullbuild
|
||||
|
||||
The compilation is bundled with the build due to dependencies on the
|
||||
class libraries on the runtime.
|
||||
That will build and install the code in a single pass. The
|
||||
compilation is bundled with the build due to dependencies on the class
|
||||
libraries on the runtime.
|
||||
|
||||
Build Features for Developers of Mono.
|
||||
======================================
|
||||
@@ -73,19 +73,17 @@ The difference between the two modes is explained farther down.
|
||||
Troubleshooting
|
||||
===============
|
||||
|
||||
We try to maintain the CVS tree such that it is bootstrapable from the
|
||||
latest released version of mono and mcs. Occasionally, something in the
|
||||
compiler or runtime changes enough that an existing installation cannot
|
||||
complete a bootstrap from cvs. In this case, go to
|
||||
http://go-mono.com/daily and download a monocharge or monolite tarball.
|
||||
Unpack and copy the .dlls to $prefix/lib and .exes to $prefix/bin/.
|
||||
Then you should be able to complete the build normally (i.e. using make
|
||||
bootstrap).
|
||||
Occasionally, something in the compiler or runtime changes enough that
|
||||
an existing installation cannot complete a full build from cvs. In this case,
|
||||
go to http://go-mono.com/daily and download a monocharge or monolite tarball.
|
||||
Unpack and copy the .dlls to $prefix/lib and .exes to $prefix/bin/. Then
|
||||
you should be able to complete the build normally (i.e. using make fullbuild).
|
||||
|
||||
wget http://go-mono.com/daily/monolite-20040505.tar.gz
|
||||
tar -zxvf monolite-20040505.tar.gz
|
||||
cd monolite-20040505
|
||||
env prefix=/usr/local sh recharge.sh
|
||||
wget http://go-mono.com/daily/monolite-20031028.tar.gz
|
||||
tar -zxvf monolite-20031028.tar.gz
|
||||
cd monolite-20031028
|
||||
cp *.exe /usr/local/bin/.
|
||||
cp *.dll /usr/local/lib/.
|
||||
|
||||
Monocharges
|
||||
===========
|
||||
|
||||
+10
-14
@@ -1,5 +1,5 @@
|
||||
thisdir := .
|
||||
SUBDIRS := build jay mcs monoresgen class mbas nunit20 ilasm tools tests errors docs
|
||||
SUBDIRS := build jay mcs class mbas nunit20 monoresgen ilasm tools tests errors docs
|
||||
OVERRIDE_BARE_TARGETS = hells yeah
|
||||
include build/rules.make
|
||||
|
||||
@@ -7,9 +7,15 @@ include build/rules.make
|
||||
|
||||
#all: platform-check profile-check all-recursive #all-local
|
||||
|
||||
.PHONY: all clean all-profiles clean-profiles install uninstall test run-test testcorlib
|
||||
all:
|
||||
$(MAKE) PROFILE=default all-profile
|
||||
$(MAKE) PROFILE=net_2_0 all-profile
|
||||
|
||||
all: platform-check profile-check all-recursive
|
||||
clean:
|
||||
$(MAKE) PROFILE=default clean-profile
|
||||
$(MAKE) PROFILE=net_2_0 clean-profile
|
||||
|
||||
all-profile: platform-check profile-check all-recursive
|
||||
|
||||
install: platform-check profile-check install-recursive #install-local
|
||||
|
||||
@@ -19,20 +25,10 @@ test: platform-check profile-check test-recursive #test-local
|
||||
|
||||
run-test: run-test-recursive #run-test-local
|
||||
|
||||
run-test-ondotnet: run-test-ondotnet-recursive # run-test-ondotnet-local
|
||||
|
||||
clean: clean-recursive #clean-local
|
||||
clean-profile: clean-recursive #clean-local
|
||||
|
||||
# fun specialty targets
|
||||
|
||||
all-profiles:
|
||||
$(MAKE) PROFILE=default all
|
||||
$(MAKE) PROFILE=net_2_0 all
|
||||
|
||||
clean-profiles:
|
||||
$(MAKE) PROFILE=default clean
|
||||
$(MAKE) PROFILE=net_2_0 clean
|
||||
|
||||
testcorlib:
|
||||
@cd class/corlib && $(MAKE) test run-test
|
||||
|
||||
|
||||
+4
-12
@@ -1,12 +1,4 @@
|
||||
2004-06-11 Anirban Bhattacharjee <banirban@novell.com>
|
||||
* Makefile: Removed inclusion of rules.make from Makefile for two reasons :
|
||||
- This Makefile as of now has no dependency on rules.make what so ever
|
||||
- Because of inclusion of INTENAL_MBAS in rules.make it was causing confliction with existing INTERNAL_MBAS in this makefile and causing lots of tests to fail
|
||||
|
||||
2004-05-15 Rafael Teixeira ([email protected])
|
||||
* Makefile: corrected /libpath: compiler flag (parameter) to point to ../class/lib/default/ the new location of libraries
|
||||
|
||||
2004-03-16 Rafael Teixeira ([email protected])
|
||||
* Test1.vb: corrected mispelling in keyword
|
||||
* Test.Sources: no misc1.vb or CharacterLiteralsA.vb sources
|
||||
* ConditionalCompilationC.vb: added some tests with #Const
|
||||
2004-03-16 Rafael Teixeira (rafaelteixeira@hotmail.com)
|
||||
* Test1.vb: corrected mispelling in keyword
|
||||
* Test.Sources: no misc1.vb or CharacterLiteralsA.vb sources
|
||||
* ConditionalCompilationC.vb: added some tests with #Const
|
||||
+4
-12
@@ -1,12 +1,4 @@
|
||||
2004-06-11 Anirban Bhattacharjee <banirban@novell.com>
|
||||
* Makefile: Removed inclusion of rules.make from Makefile for two reasons :
|
||||
- This Makefile as of now has no dependency on rules.make what so ever
|
||||
- Because of inclusion of INTENAL_MBAS in rules.make it was causing confliction with existing INTERNAL_MBAS in this makefile and causing lots of tests to fail
|
||||
|
||||
2004-05-15 Rafael Teixeira ([email protected])
|
||||
* Makefile: corrected /libpath: compiler flag (parameter) to point to ../class/lib/default/ the new location of libraries
|
||||
|
||||
2004-03-16 Rafael Teixeira ([email protected])
|
||||
* Test1.vb: corrected mispelling in keyword
|
||||
* Test.Sources: no misc1.vb or CharacterLiteralsA.vb sources
|
||||
* ConditionalCompilationC.vb: added some tests with #Const
|
||||
2004-03-16 Rafael Teixeira (rafaelteixeira@hotmail.com)
|
||||
* Test1.vb: corrected mispelling in keyword
|
||||
* Test.Sources: no misc1.vb or CharacterLiteralsA.vb sources
|
||||
* ConditionalCompilationC.vb: added some tests with #Const
|
||||
@@ -1,34 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Module M
|
||||
Delegate Sub SD()
|
||||
sub f()
|
||||
End sub
|
||||
|
||||
Public Delegate Function SF(a as integer) as Integer
|
||||
Public Function f1(a as integer) as Integer
|
||||
return a
|
||||
End Function
|
||||
|
||||
Sub Main()
|
||||
dim d1 as SD
|
||||
d1 = new SD(AddressOf f)
|
||||
d1.Invoke()
|
||||
|
||||
dim d2 as SD
|
||||
d2 = AddressOf f
|
||||
d2.Invoke()
|
||||
|
||||
dim d3 as new SD(AddressOf f)
|
||||
d3.Invoke()
|
||||
|
||||
dim d4 as SF
|
||||
d4 = new SF(AddressOf f1)
|
||||
Dim i as Integer = d4.Invoke(10)
|
||||
if i <> 10 then
|
||||
Throw new System.Exception ("#A1, Unexpected result")
|
||||
end if
|
||||
|
||||
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,14 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Module M
|
||||
Delegate Sub SD()
|
||||
sub f(i as integer)
|
||||
End sub
|
||||
|
||||
|
||||
Sub Main()
|
||||
dim d1 as SD
|
||||
d1= new SD(AddressOf f)
|
||||
d1.Invoke()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,18 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Module M
|
||||
Delegate Sub SD()
|
||||
sub f()
|
||||
End sub
|
||||
|
||||
Public Delegate Function SF(a as integer) as Integer
|
||||
Public Function f1(a as integer) as Integer
|
||||
return a
|
||||
End Function
|
||||
|
||||
Sub Main()
|
||||
dim d1 as SD
|
||||
d1= new SD(AddressOf f1)
|
||||
d1.Invoke()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,27 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Public Event E
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
dim WithEvents x as C = new C()
|
||||
Sub call_S()
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH() Handles x.E
|
||||
Console.WriteLine("event called")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,28 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Delegate Sub EH()
|
||||
Public Event E as EH
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
dim WithEvents x as C = new C()
|
||||
Sub call_S()
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH() Handles x.E
|
||||
Console.WriteLine("event called")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,30 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Public Event E (ByVal i as integer)
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E(10)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
dim WithEvents x as C = new C()
|
||||
|
||||
Sub call_S()
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH(i as Integer) Handles x.E
|
||||
Console.WriteLine("event called : " + i)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
End Module
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Delegate Sub EH(ByVal i as integer)
|
||||
Public Event E as EH
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E(10)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
dim WithEvents x as C = new C()
|
||||
|
||||
Sub call_S()
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH(i as Integer) Handles x.E
|
||||
Console.WriteLine("event called : " + i)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
End Module
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Public Class C
|
||||
Public Event E()
|
||||
|
||||
Sub S()
|
||||
RaiseEvent E()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Module M
|
||||
Sub S1()
|
||||
Dim x As New C()
|
||||
AddHandler x.E, AddressOf EH
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub EH()
|
||||
Console.WriteLine("Event fired")
|
||||
End Sub
|
||||
|
||||
Sub Main()
|
||||
S1()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
Imports System
|
||||
|
||||
Class C
|
||||
Delegate Sub EH()
|
||||
Public Event E as EH
|
||||
|
||||
Public Sub S()
|
||||
RaiseEvent E
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Class C1
|
||||
Sub call_S()
|
||||
dim x as C = new C()
|
||||
AddHandler x.E, AddressOf xh
|
||||
x.S()
|
||||
End Sub
|
||||
|
||||
Sub xh()
|
||||
Console.WriteLine("event called")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
dim y as new C1
|
||||
y.call_S()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
+2
-5
@@ -1,15 +1,12 @@
|
||||
thisdir = btests
|
||||
SUBDIRS =
|
||||
TEST_RUNTIME = mono
|
||||
COMPILER_FLAGS = /libpath:../class/lib/default/ /imports:System
|
||||
COMPILER_FLAGS = /libpath:../class/lib /imports:System
|
||||
INTERNAL_MBAS = $(TEST_RUNTIME) --debug ../mbas/mbas.exe --stacktrace $(COMPILER_FLAGS)
|
||||
#INTERNAL_MBAS = vbc $(COMPILER_FLAGS)
|
||||
all: test-compiler-jit
|
||||
|
||||
# removed this cause INTERNAL_MBAS now getting set in
|
||||
# rules.make which is conflicting with this instance of
|
||||
# INTERNAL_MBAS
|
||||
#include ../build/rules.make
|
||||
include ../build/rules.make
|
||||
|
||||
DISTFILES = README.tests $(wildcard *.vb)
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
p = 10
|
||||
System.Console.WriteLine(p)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,21 +0,0 @@
|
||||
IMPORTS SYSTEM
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET
|
||||
i = Value
|
||||
End SET
|
||||
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
p = 10
|
||||
Console.WriteLine(p)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,22 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public Property p(ByVal x as Integer) as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
p(5) = 10
|
||||
'Console.WriteLine(p)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,22 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (ByRef val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
p = 10
|
||||
Console.WriteLine(p)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,21 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
protected Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
|
||||
End Property
|
||||
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,17 +0,0 @@
|
||||
Class C1
|
||||
'property that do not override any other
|
||||
'property should not be declared 'notoverridable'
|
||||
|
||||
Public NotOverridable Property p() as Integer
|
||||
GET
|
||||
END GET
|
||||
|
||||
SET (val as Integer)
|
||||
End SET
|
||||
End Property
|
||||
|
||||
End Class
|
||||
Module OverrideC2
|
||||
Sub Main()
|
||||
End Sub
|
||||
End Module
|
||||
@@ -1,18 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public Property p() as Integer
|
||||
GET
|
||||
END GET
|
||||
|
||||
SET (ByVal val as string)
|
||||
End SET
|
||||
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,17 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public Property p() as Integer
|
||||
Get
|
||||
return i
|
||||
END Get
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
p = 10
|
||||
Console.WriteLine(p)
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,19 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public Property p() as Integer
|
||||
'GET
|
||||
' return i
|
||||
'END GET
|
||||
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,19 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public WriteOnly Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,19 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public ReadOnly Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
End Property
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,11 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public MustOverride Property p() as Integer
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,15 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Public Struct s
|
||||
public MustOverride Property p() as Integer
|
||||
End Struct
|
||||
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,22 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Structure S
|
||||
private i as integer
|
||||
|
||||
protected Property p() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
|
||||
SET (val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
|
||||
End Property
|
||||
End Structure
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,22 +0,0 @@
|
||||
Imports system
|
||||
|
||||
Module M
|
||||
private i as integer
|
||||
|
||||
public WriteOnly Property p() as Integer
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
End Property
|
||||
|
||||
public ReadOnly Property p1() as Integer
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
End Property
|
||||
|
||||
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
@@ -1,29 +0,0 @@
|
||||
Imports system
|
||||
|
||||
MustInherit Class C1
|
||||
public MustOverride Property p() as Integer
|
||||
End Class
|
||||
|
||||
|
||||
Class C2
|
||||
Inherits C1
|
||||
|
||||
private i as integer
|
||||
|
||||
public shadows Property p() as Integer
|
||||
SET (ByVal val as Integer)
|
||||
i = val
|
||||
End SET
|
||||
|
||||
GET
|
||||
return i
|
||||
END GET
|
||||
End Property
|
||||
End Class
|
||||
|
||||
|
||||
Module M
|
||||
Sub Main()
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
+3
-27
@@ -127,19 +127,8 @@ ArrayA \
|
||||
ArrayB \
|
||||
ArrayC \
|
||||
ArrayD \
|
||||
EnumA \
|
||||
PropertyA \
|
||||
PropertyB \
|
||||
PropertyC \
|
||||
PropertyD \
|
||||
PropertyE \
|
||||
DelegateA \
|
||||
EventA \
|
||||
EventB \
|
||||
EventC \
|
||||
EventD \
|
||||
EventE \
|
||||
EventF
|
||||
EnumA
|
||||
|
||||
|
||||
# All negetive test cases which should
|
||||
# fail during compilation goes here
|
||||
@@ -284,20 +273,7 @@ EnumC3 \
|
||||
EnumC4 \
|
||||
EnumC5 \
|
||||
EnumC6 \
|
||||
EnumC7 \
|
||||
PropertyC1 \
|
||||
PropertyC2 \
|
||||
PropertyC3 \
|
||||
PropertyC4 \
|
||||
PropertyC5 \
|
||||
PropertyC6 \
|
||||
PropertyC7 \
|
||||
PropertyC8 \
|
||||
PropertyC9 \
|
||||
PropertyC10 \
|
||||
PropertyC11 \
|
||||
DelegateC1 \
|
||||
DelegateC2
|
||||
EnumC7
|
||||
|
||||
# All negetive test cases which should fail at
|
||||
# runtime goes here
|
||||
|
||||
@@ -1,168 +1,3 @@
|
||||
2004-06-14 Raja R Harinath <[email protected]>
|
||||
|
||||
* platforms/linux.make (PLATFORM_CHANGE_SEPARATOR_CMD): Define to 'cat'.
|
||||
(PLATFORM_TWEAK_CORLIB_SOURCES): Remove.
|
||||
(platform-check): Avoid bash-ism.
|
||||
* library.make: Simplify uses of $(patsubst x,y,$(foo)) to $(foo:x=y).
|
||||
(core_sourcefile): Rename back to ...
|
||||
(sourcefile): ... this. Remove creation of redundant intermediate file.
|
||||
(response): Change test for optimization, now that
|
||||
PLATFORM_CHANGE_SEPARATOR_CMD is unconditional. Combine with
|
||||
platform-exclude handling.
|
||||
(library_CLEAN_FILES): New variable to specify clean:-able files
|
||||
close to where they're defined.
|
||||
(test_response, btest_response): Simplify.
|
||||
* executable.make (response): Change test for optimization.
|
||||
(executable_CLEAN_FILES): New define.
|
||||
|
||||
2004-06-14 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (uninstall-local): Fix typo.
|
||||
|
||||
2004-06-11 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* library.make : HAVE_CS_TESTS fixie.
|
||||
|
||||
2004-06-11 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (HAVE_CS_TESTS, HAVE_VB_TESTS): Allow to be
|
||||
overriden. Useful if the tests sourcefile is generated.
|
||||
(TEST_COMPILE, BTEST_COMPILE): Allow these to be customized too.
|
||||
|
||||
* platforms/win32.make (PLATFORM_TWEAK_CORLIB_SOURCES): Remove.
|
||||
|
||||
Support enough features to build mscorlib.dll.
|
||||
* library.make (core_sourcefile): New renamed from $(sourcefile).
|
||||
(PLATFORM_excludes): Auto-detecting define that sees if
|
||||
$(LIBRARY).$(PLATFORM)-excludes file exists.
|
||||
(sourcefile): New. Possibly-built file that removes
|
||||
PLATFORM_excluded files from core_sourcefile.
|
||||
(test_against, test_dep): New. Allow the test assembly to be
|
||||
built against a different library.
|
||||
(test_lib): Allow makefile to override the name of the test
|
||||
assembly.
|
||||
(LIBRARY_INSTALL_DIR): If defined, switch to using $(INSTALL_LIB)
|
||||
rather than $(gacutil).
|
||||
(DISTFILES, dist-local): Use core_sourcefile.
|
||||
(clean-local): Remove sourcefile if it was generated.
|
||||
(test_lib, btest_lib): Depend on $(test_dep).
|
||||
|
||||
2004-06-10 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* library.make: fixed PLATFORM_CHANGE_SEPARATOR_CHAR on windows.
|
||||
|
||||
2004-06-09 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* library.make: Added support to fully sign assemblies when doing a
|
||||
"make install" (thanks to Jackson :-).
|
||||
|
||||
2004-06-09 Raja R Harinath <[email protected]>
|
||||
|
||||
Do away with stampfiles.
|
||||
Introduce support for VB test cases.
|
||||
* library.make (HAVE_CS_TESTS, HAVE_VB_TESTS): New auto-detecting
|
||||
defines.
|
||||
(stampfile, test_stampfile): Remove.
|
||||
(clean-local): Don't mention them.
|
||||
(test-local, run-test-local, run-test-ondotnet-local):
|
||||
Make unconditional.
|
||||
($(makefrag), $(test_makefrag)): Simplify.
|
||||
($(btest_lib)): New. Support for VB testcases.
|
||||
|
||||
2004-06-09 Raja R Harinath <[email protected]>
|
||||
|
||||
Partial support for writing Visual Basic source files.
|
||||
* rules.make (USE_MBAS_FLAGS,BASCOMPILE,INTERNAL_MBAS): New.
|
||||
* config-default.make (MBAS_FLAGS, DEFAULT_MBAS_FLAGS): New.
|
||||
* profiles/default.make (MBAS): New.
|
||||
|
||||
2004-06-09 Raja R Harinath <[email protected]>
|
||||
|
||||
Do away with stampfiles.
|
||||
* executable.make (stampfile): Remove.
|
||||
(clean-local): Remove mention of $(stampfile).
|
||||
(test-local, run-test-local, run-test-ondotnet-local):
|
||||
Make unconditional. Add dummy rule to prevent other makefiles
|
||||
from defining rules on these.
|
||||
($(PROGRAM)): Depend directly on $(BUILT_SOURCES).
|
||||
($(makefrag)): Simplify.
|
||||
|
||||
2004-06-03 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* README.makefiles : added description for run-test-ondotnet.
|
||||
|
||||
2004-06-03 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* Makefile, executable.make, library.make, rules.make :
|
||||
Added new target "run-test-ondotnet" that works what "run-test"
|
||||
used to be on windows (i.e. tests our libs under MS.NET).
|
||||
|
||||
2004-06-01 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* platforms/win32.make : TEST_RUNTIME should be always mono we can't
|
||||
test our libs against MS.NET runtime. Think about internal call).
|
||||
|
||||
2004-05-30 Jackson Harper <[email protected]>
|
||||
|
||||
* library.make: Install to 2.0 package if building with the
|
||||
net_2_0 profile.
|
||||
|
||||
2004-05-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* library.make: reference nunti.core.dll and nunit.util.dll when
|
||||
building tests.
|
||||
|
||||
2004-05-26 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (clean-local): Add $(CLEAN_FILES) too.
|
||||
|
||||
2004-05-25 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* library.make: changed case on nunit.framework.dll (lowercase)
|
||||
|
||||
2004-05-24 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (LIBRARY_COMPILE): New define.
|
||||
($(the_lib)): Use $(LIBRARY_COMPILE) to compile $(the_lib).
|
||||
|
||||
* executable.make (PROGRAM_INSTALL_DIR): Allow makefile to specify
|
||||
a different directory for installation.
|
||||
(install-local, uninstall-local): Use it.
|
||||
|
||||
2004-05-20 Raja R Harinath <[email protected]>
|
||||
|
||||
* profiles/default.make (TEST_RUNTIME): Look in class/lib/default
|
||||
for library to be tested.
|
||||
* rules.make (INTERNAL_RESGEN): New Define.
|
||||
* library.make (run-test-local): Move commands to run-test-lib.
|
||||
Preparartion for allowing creation of addition test dll with .vb
|
||||
testcases.
|
||||
* executable.make (PROGRAM_COMPILE): New define.
|
||||
($(PROGRAM)): Use PROGRAM_COMPILE to compile PROGRAM.
|
||||
|
||||
2004-05-14 Jackson Harper <[email protected]>
|
||||
|
||||
* library.make: Install package files. Get params in magical
|
||||
correct order.
|
||||
|
||||
2004-05-11 Jackson Harper <[email protected]>
|
||||
|
||||
* platforms/linux.make:
|
||||
* platforms/win32.make: Define a PLATFORM_PATH_SEPARATOR used for
|
||||
separating paths in env vars. (ie MONO_PATH).
|
||||
* profiles/net_2_0.make: Always use gmcs for building the 2.0
|
||||
libraries. corlib is the first lib built and it will build gmcs.
|
||||
|
||||
2004-05-11 Jackson Harper <[email protected]>
|
||||
|
||||
* library.make: Allow assembly names to be different then their
|
||||
.sources file names.
|
||||
|
||||
2004-05-08 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* library.make: build NUnit if we try to run 'make test' and the dll
|
||||
is not found.
|
||||
|
||||
2004-04-29 Jackson Harper <[email protected]>
|
||||
|
||||
* library.make: Fix uninstall
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ thisdir = build
|
||||
SUBDIRS =
|
||||
include ../build/rules.make
|
||||
|
||||
all-local install-local test-local run-test-local run-test-ondotnet-local clean-local uninstall-local:
|
||||
all-local install-local test-local run-test-local clean-local uninstall-local:
|
||||
|
||||
DISTFILES = \
|
||||
README.makefiles \
|
||||
|
||||
@@ -40,9 +40,6 @@ test-local: my_test_program.exe
|
||||
run-test-local:
|
||||
$(RUNTIME) my_test_program.exe
|
||||
|
||||
run-test-ondotnet-local:
|
||||
$(RUNTIME) my_test_program.exe
|
||||
|
||||
DISTFILES = myfile.txt my_test_source.cs
|
||||
|
||||
dist-local: dist-default
|
||||
@@ -52,7 +49,7 @@ my_test_program.exe: my_test_source.cs
|
||||
========================================
|
||||
|
||||
Each makefile follows the same pattern: it does some setup, includes
|
||||
the standard make rules, and provides rules for seven standard targets:
|
||||
the standard make rules, and provides rules for six standard targets:
|
||||
all, install, test, run-test, clean, and dist.
|
||||
|
||||
"Some setup" is defining two variables: $(thisdir) and
|
||||
@@ -60,7 +57,7 @@ $(SUBDIRS). $(thisdir) is the directory that the makefile lives in,
|
||||
relative to the top directory (ie, class/corlib) and $(SUBDIRS)
|
||||
defines the subdirectories that should be built in.
|
||||
|
||||
The seven targets do the following:
|
||||
The six targets do the following:
|
||||
|
||||
* all-local builds whatever someone would expect to be built
|
||||
when they just type 'make'. Most likely Foo.dll or Foo.exe
|
||||
@@ -78,8 +75,6 @@ target. The idea is that 'make run-test' from the toplevel should be
|
||||
able to proceed unsupervised and test everything that can be tested in
|
||||
such a manner.
|
||||
|
||||
* run-test-ondotnet-local is a variant of run-test-local. It is used only to validate if our tests themselves works fine under Microsoft runtime (on Windows). Basically, in this target, we should not use $(TEST_RUNTIME) to test our libraries.
|
||||
|
||||
* clean-local removes built files; 'make clean' should leave
|
||||
only files that go into a distribution tarball. (But it is not necessarily
|
||||
true that all files that go into a tarball need to be left after a make clean.)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
RUNTIME_FLAGS =
|
||||
TEST_HARNESS = $(topdir)/class/lib/nunit-console.exe
|
||||
MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)
|
||||
MBAS_FLAGS = $(PLATFORM_DEBUG_FLAGS)
|
||||
LIBRARY_FLAGS = /noconfig
|
||||
CFLAGS = -g -O2
|
||||
INSTALL = /usr/bin/install
|
||||
@@ -21,7 +20,6 @@ prefix = /usr/local
|
||||
# keep track of the default value
|
||||
|
||||
DEFAULT_MCS_FLAGS := $(MCS_FLAGS)
|
||||
DEFAULT_MBAS_FLAGS := $(MBAS_FLAGS)
|
||||
|
||||
# You shouldn't need to set these but might on a
|
||||
# weird platform.
|
||||
|
||||
+33
-27
@@ -8,40 +8,35 @@
|
||||
|
||||
base_prog = $(shell basename $(PROGRAM))
|
||||
sourcefile = $(base_prog).sources
|
||||
|
||||
ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
|
||||
response = $(sourcefile)
|
||||
else
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
response = $(depsdir)/$(base_prog).response
|
||||
executable_CLEAN_FILES += $(response)
|
||||
else
|
||||
response = $(sourcefile)
|
||||
endif
|
||||
|
||||
stampfile = $(depsdir)/$(base_prog).stamp
|
||||
makefrag = $(depsdir)/$(base_prog).makefrag
|
||||
pdb = $(patsubst %.exe,%.pdb,$(PROGRAM))
|
||||
executable_CLEAN_FILES += $(makefrag) $(pdb)
|
||||
|
||||
ifndef PROGRAM_INSTALL_DIR
|
||||
PROGRAM_INSTALL_DIR = $(prefix)/bin
|
||||
endif
|
||||
|
||||
all-local: $(PROGRAM)
|
||||
|
||||
install-local: $(PROGRAM)
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
|
||||
$(INSTALL_BIN) $(PROGRAM) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(prefix)/bin
|
||||
$(INSTALL_BIN) $(PROGRAM) $(DESTDIR)$(prefix)/bin
|
||||
|
||||
uninstall-local:
|
||||
-rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog)
|
||||
-rm -f $(DESTDIR)$(prefix)/bin/$(base_prog)
|
||||
|
||||
clean-local:
|
||||
-rm -f *.exe $(BUILT_SOURCES) $(executable_CLEAN_FILES) $(CLEAN_FILES)
|
||||
-rm -f *.exe $(BUILT_SOURCES) $(CLEAN_FILES) $(pdb) $(stampfile) $(makefrag)
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
-rm -f $(response)
|
||||
endif
|
||||
|
||||
ifndef HAS_TEST
|
||||
test-local: $(PROGRAM)
|
||||
@:
|
||||
|
||||
run-test-local:
|
||||
@:
|
||||
run-test-ondotnet-local:
|
||||
@:
|
||||
endif
|
||||
|
||||
DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
|
||||
|
||||
@@ -51,21 +46,32 @@ dist-local: dist-default
|
||||
$(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
|
||||
done
|
||||
|
||||
ifndef PROGRAM_COMPILE
|
||||
PROGRAM_COMPILE = $(CSCOMPILE)
|
||||
endif
|
||||
# Changing makefile probably means changing the
|
||||
# sources, so let's be safe and add a Makefile dep
|
||||
|
||||
$(PROGRAM): $(makefrag) $(BUILT_SOURCES) $(response)
|
||||
$(PROGRAM_COMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
|
||||
$(PROGRAM): $(makefrag) $(response) $(stampfile)
|
||||
$(CSCOMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
|
||||
|
||||
# warning: embedded tab in the 'echo touch' line
|
||||
$(makefrag): $(sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(PROGRAM): ,' $< > $@
|
||||
@echo "HAVE_MAKEFRAG = yes" >$@.new
|
||||
@echo "$(stampfile): $(BUILT_SOURCES) \\" >>[email protected]
|
||||
@cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>[email protected]
|
||||
@cat [email protected] |sed -e '$$s, \\$$,,' >$@
|
||||
@echo " touch \$$@" >>$@
|
||||
@rm -rf [email protected]
|
||||
|
||||
ifneq ($(response),$(sourcefile))
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
$(response): $(sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@( $(PLATFORM_CHANGE_SEPARATOR_CMD) ) <$< >$@
|
||||
@cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
endif
|
||||
|
||||
-include $(makefrag)
|
||||
|
||||
ifndef HAVE_MAKEFRAG
|
||||
$(stampfile):
|
||||
touch $@
|
||||
endif
|
||||
|
||||
+66
-172
@@ -9,169 +9,67 @@
|
||||
# munge in the library name to keep the files from clashing.
|
||||
|
||||
sourcefile = $(LIBRARY).sources
|
||||
PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
|
||||
|
||||
ifndef PLATFORM_excludes
|
||||
ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
|
||||
else
|
||||
response = $(sourcefile)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef response
|
||||
response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
|
||||
library_CLEAN_FILES += $(response)
|
||||
endif
|
||||
|
||||
ifndef LIBRARY_NAME
|
||||
LIBRARY_NAME = $(LIBRARY)
|
||||
endif
|
||||
|
||||
makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
|
||||
the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
|
||||
the_pdb = $(the_lib:.dll=.pdb)
|
||||
library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb)
|
||||
stampfile = $(depsdir)/$(PROFILE)_$(LIBRARY).stamp
|
||||
the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY)
|
||||
the_pdb = $(patsubst %.dll,%.pdb,$(the_lib))
|
||||
|
||||
ifndef NO_TEST
|
||||
test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
|
||||
test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
|
||||
test_nunit_ref = $(test_nunit_dep:%=-r:%)
|
||||
library_CLEAN_FILES += TestResult.xml
|
||||
|
||||
ifndef test_against
|
||||
test_against = $(the_lib)
|
||||
test_dep = $(the_lib)
|
||||
endif
|
||||
|
||||
ifndef test_lib
|
||||
test_lib = $(LIBRARY:.dll=_test.dll)
|
||||
endif
|
||||
test_pdb = $(test_lib:.dll=.pdb)
|
||||
test_lib = $(patsubst %.dll,%_test.dll,$(LIBRARY))
|
||||
test_pdb = $(patsubst %.dll,%.pdb,$(test_lib))
|
||||
test_sourcefile = $(test_lib).sources
|
||||
test_response = $(depsdir)/$(PROFILE)_$(test_lib).response
|
||||
test_makefrag = $(depsdir)/$(PROFILE)_$(test_lib).makefrag
|
||||
test_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
|
||||
library_CLEAN_FILES += $(test_lib) $(test_pdb) $(test_response) $(test_makefrag)
|
||||
|
||||
ifndef btest_lib
|
||||
btest_lib = $(LIBRARY:.dll=_btest.dll)
|
||||
endif
|
||||
btest_pdb = $(btest_lib:.dll=.pdb)
|
||||
btest_sourcefile = $(btest_lib).sources
|
||||
btest_response = $(depsdir)/$(btest_lib).response
|
||||
btest_makefrag = $(depsdir)/$(btest_lib).makefrag
|
||||
btest_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
|
||||
library_CLEAN_FILES += $(btest_lib) $(btest_pdb) $(btest_response) $(btest_makefrag)
|
||||
|
||||
ifndef HAVE_CS_TESTS
|
||||
HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
|
||||
endif
|
||||
ifndef HAVE_VB_TESTS
|
||||
HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
|
||||
endif
|
||||
|
||||
test_stampfile = $(depsdir)/$(PROFILE)_$(test_lib).stamp
|
||||
test_flags = /r:$(the_lib) /r:$(topdir)/class/lib/$(PROFILE)/NUnit.Framework.dll $(TEST_MCS_FLAGS)
|
||||
endif
|
||||
|
||||
gacutil = $(topdir)/tools/gacutil/gacutil.exe
|
||||
sn = $(topdir)/tools/security/sn.exe
|
||||
|
||||
PACKAGE = 1.0
|
||||
|
||||
ifeq ($(PROFILE), net_2_0)
|
||||
PACKAGE = 2.0
|
||||
endif
|
||||
|
||||
all-local: $(the_lib)
|
||||
|
||||
install-local: $(the_lib) maybe-sign-lib
|
||||
|
||||
ifdef LIBRARY_INSTALL_DIR
|
||||
install-local:
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
|
||||
$(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
|
||||
|
||||
uninstall-local:
|
||||
-rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
|
||||
|
||||
else
|
||||
|
||||
install-local: $(gacutil)
|
||||
$(RUNTIME) $(gacutil) /i $(the_lib) /f /root $(DESTDIR)$(prefix)/lib /package $(PACKAGE)
|
||||
install-local: $(the_lib) $(gacutil)
|
||||
$(RUNTIME) $(gacutil) -i $(the_lib) -f /root $(DESTDIR)$(prefix)/lib || exit 1 ; \
|
||||
|
||||
uninstall-local: $(gacutil)
|
||||
$(RUNTIME) $(gacutil) /u $(LIBRARY_NAME:.dll=)
|
||||
$(RUNTIME) $(gacutil) /u $$(basename $(the_lib) .dll) ; \
|
||||
|
||||
$(gacutil):
|
||||
cd $(topdir)/tools/gacutil && $(MAKE)
|
||||
|
||||
endif
|
||||
|
||||
maybe-sign-lib:
|
||||
ifndef NO_SIGN_ASSEMBLY
|
||||
maybe-sign-lib: $(sn)
|
||||
$(RUNTIME) $(sn) -q -R $(the_lib) $(topdir)/class/mono.snk
|
||||
endif
|
||||
|
||||
$(sn):
|
||||
cd $(topdir)/tools/security && $(MAKE) sn.exe
|
||||
cd $(topdir)/tools/gacutil && $(MAKE) || exit 1 ;
|
||||
|
||||
clean-local:
|
||||
-rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
|
||||
|
||||
test-local: $(the_lib)
|
||||
@:
|
||||
run-test-local:
|
||||
@:
|
||||
run-test-ondotnet-local:
|
||||
@:
|
||||
-rm -f $(the_lib) $(makefrag) $(test_lib) \
|
||||
$(test_makefrag) $(test_response) \
|
||||
$(stampfile) $(test_stampfile) \
|
||||
$(the_pdb) $(test_pdb) \
|
||||
TestResult.xml
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
-rm -rf $(response)
|
||||
endif
|
||||
|
||||
ifndef NO_TEST
|
||||
$(test_nunit_dep): $(topdir)/build/deps/nunit.stamp
|
||||
@if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
|
||||
$(topdir)/build/deps/nunit.stamp:
|
||||
cd ${topdir}/nunit20 && $(MAKE)
|
||||
echo "stamp" >$@
|
||||
endif
|
||||
test-local: $(the_lib) $(test_lib)
|
||||
|
||||
ifdef HAVE_CS_TESTS
|
||||
|
||||
test-local: $(test_lib)
|
||||
|
||||
run-test-local: run-test-lib
|
||||
|
||||
run-test-lib: test-local
|
||||
run-test-local:
|
||||
$(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
|
||||
|
||||
run-test-ondotnet-local: run-test-ondotnet-lib
|
||||
|
||||
run-test-ondotnet-lib: test-local
|
||||
$(TEST_HARNESS) $(test_lib)
|
||||
endif
|
||||
|
||||
ifdef HAVE_VB_TESTS
|
||||
|
||||
test-local: $(btest_lib)
|
||||
|
||||
run-test-local: run-btest-lib
|
||||
|
||||
run-btest-lib: test-local
|
||||
$(TEST_RUNTIME) $(TEST_HARNESS) $(btest_lib)
|
||||
|
||||
run-test-ondotnet-local: run-btest-ondotnet-lib
|
||||
|
||||
run-btest-ondotnet-lib: test-local
|
||||
$(TEST_HARNESS) $(btest_lib)
|
||||
else
|
||||
test-local: $(the_lib)
|
||||
|
||||
run-test-local:
|
||||
endif
|
||||
|
||||
DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
|
||||
|
||||
ifdef NO_TEST
|
||||
TEST_FILES =
|
||||
|
||||
ifdef HAVE_CS_TESTS
|
||||
TEST_FILES += `sed 's,^,Test/,' $(test_sourcefile)`
|
||||
endif
|
||||
ifdef HAVE_VB_TESTS
|
||||
TEST_FILES += `sed 's,^,Test/,' $(btest_sourcefile)`
|
||||
else
|
||||
TEST_FILES = `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'`
|
||||
endif
|
||||
|
||||
dist-local: dist-default
|
||||
@@ -180,68 +78,64 @@ dist-local: dist-default
|
||||
$(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
|
||||
done
|
||||
|
||||
ifndef LIBRARY_COMPILE
|
||||
LIBRARY_COMPILE = $(CSCOMPILE)
|
||||
endif
|
||||
|
||||
ifndef TEST_COMPILE
|
||||
TEST_COMPILE = $(CSCOMPILE)
|
||||
endif
|
||||
|
||||
ifndef BTEST_COMPILE
|
||||
BTEST_COMPILE = $(BASCOMPILE)
|
||||
endif
|
||||
|
||||
# Fun with dependency tracking
|
||||
|
||||
$(the_lib): $(makefrag) $(response)
|
||||
$(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
|
||||
$(the_lib): $(makefrag) $(stampfile) $(response)
|
||||
$(CSCOMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
|
||||
|
||||
# warning: embedded tab in the 'echo touch' line
|
||||
$(makefrag): $(sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(the_lib): ,' $< >$@
|
||||
@echo "HAVE_MAKEFRAG = yes" >[email protected]
|
||||
@echo "$(stampfile): \\" >>[email protected]
|
||||
@cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>[email protected]
|
||||
@cat [email protected] |sed -e '$$s, \\$$,,' >$@
|
||||
@echo " touch \$$@" >>$@
|
||||
@rm -rf [email protected]
|
||||
|
||||
ifneq ($(response),$(sourcefile))
|
||||
$(response): $(sourcefile) $(PLATFORM_excludes)
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
$(response): $(sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
@cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
endif
|
||||
|
||||
-include $(makefrag)
|
||||
|
||||
ifndef HAVE_MAKEFRAG
|
||||
$(stampfile):
|
||||
touch $@
|
||||
endif
|
||||
|
||||
# for now, don't give any /lib flags or set MONO_PATH, since we
|
||||
# give a full path to the assembly.
|
||||
|
||||
ifdef HAVE_CS_TESTS
|
||||
|
||||
$(test_lib): $(test_makefrag) $(test_dep) $(test_response) $(test_nunit_dep)
|
||||
$(TEST_COMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
|
||||
ifndef NO_TEST
|
||||
$(test_lib): $(test_makefrag) $(the_lib) $(test_response) $(test_stampfile)
|
||||
$(CSCOMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
|
||||
|
||||
$(test_response): $(test_sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
ifdef PLATFORM_CHANGE_SEPARATOR_CMD
|
||||
@cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
else
|
||||
@cat $< |sed -e 's,^\(.\),Test/\1,' >$@
|
||||
endif
|
||||
|
||||
# warning: embedded tab in the 'echo touch' line
|
||||
$(test_makefrag): $(test_response)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(test_lib): ,' $< >$@
|
||||
@echo "HAVE_TEST_MAKEFRAG = yes" >[email protected]
|
||||
@echo "$(test_stampfile): \\" >>[email protected]
|
||||
@cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>[email protected]
|
||||
@cat [email protected] |sed -e '$$s, \\$$,,' >$@
|
||||
@echo " touch \$$@" >>$@
|
||||
@rm -rf [email protected]
|
||||
|
||||
-include $(test_makefrag)
|
||||
|
||||
endif
|
||||
|
||||
ifdef HAVE_VB_TESTS
|
||||
|
||||
$(btest_lib): $(btest_makefrag) $(test_dep) $(btest_response) $(test_nunit_dep)
|
||||
$(BTEST_COMPILE) /target:library /out:$@ $(btest_flags) @$(btest_response)
|
||||
|
||||
$(btest_response): $(btest_sourcefile)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
|
||||
$(btest_makefrag): $(btest_response)
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(btest_lib): ,' $< >$@
|
||||
|
||||
-include $(btest_makefrag)
|
||||
|
||||
ifndef HAVE_TEST_MAKEFRAG
|
||||
$(test_stampfile):
|
||||
touch $@
|
||||
endif
|
||||
|
||||
@@ -11,25 +11,31 @@ PLATFORM_CORLIB = mscorlib.dll
|
||||
BOOTSTRAP_MCS = mcs
|
||||
RESGEN = monoresgen
|
||||
|
||||
PLATFORM_PATH_SEPARATOR = :
|
||||
|
||||
# Define this if this ever will work on Linux
|
||||
# PLATFORM_MAKE_CORLIB_CMP = yes
|
||||
|
||||
# This is for the security permission attribute problem
|
||||
# on windows
|
||||
PLATFORM_TWEAK_CORLIB_SOURCES = cat
|
||||
|
||||
# This is for changing / to \ on windows
|
||||
PLATFORM_CHANGE_SEPARATOR_CMD = cat
|
||||
# Don't define it so we don't needlessly copy the sources
|
||||
# file. This command is handy for testing:
|
||||
#
|
||||
# PLATFORM_CHANGE_SEPARATOR_CMD=sed -e 's,/,/./,g'
|
||||
|
||||
hidden_prefix = .
|
||||
hidden_suffix =
|
||||
|
||||
platform-check:
|
||||
@set fnord $(BOOTSTRAP_MCS) ; if type $$2 >/dev/null 2>&1 ; then :; else \
|
||||
echo "*** You need a C# compiler installed to build MCS. (make sure mcs works from the command line)" ; \
|
||||
@if ! type $(BOOTSTRAP_MCS) >/dev/null 2>&1 ; then \
|
||||
echo "*** You need a C# compiler installed to build MCS." ; \
|
||||
echo "*** Read INSTALL.txt for information on how to bootstrap" ; \
|
||||
echo "*** a Mono installation." ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
|
||||
# I tried this but apparently Make's version strings aren't that
|
||||
# ... consistent between releases. Whatever.
|
||||
#
|
||||
|
||||
@@ -13,10 +13,8 @@ MCS = $(BOOTSTRAP_MCS)
|
||||
RESGEN = resgen.exe
|
||||
|
||||
PLATFORM_MAKE_CORLIB_CMP = yes
|
||||
PLATFORM_TWEAK_CORLIB_SOURCES=cat - corlib.dll.win32-excludes |sort |uniq -u
|
||||
PLATFORM_CHANGE_SEPARATOR_CMD=tr '/' '\\\\'
|
||||
PLATFORM_PATH_SEPARATOR = ;
|
||||
|
||||
TEST_RUNTIME = mono
|
||||
|
||||
hidden_prefix =
|
||||
hidden_suffix = .tmp
|
||||
|
||||
@@ -16,11 +16,9 @@
|
||||
|
||||
ifdef PLATFORM_MONO_NATIVE
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(INTERNAL_MCS)
|
||||
MBAS = MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(INTERNAL_MBAS)
|
||||
TEST_RUNTIME = MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(RUNTIME) --debug
|
||||
TEST_RUNTIME = MONO_PATH=".:$$MONO_PATH" $(RUNTIME) --debug
|
||||
else
|
||||
MCS = $(PLATFORM_RUNTIME) $(BOOTSTRAP_MCS) /lib:$(topdir)/class/lib/$(PROFILE)
|
||||
MBAS = $(PLATFORM_RUNTIME) $(BOOTSTRAP_MBAS) /lib:$(topdir)/class/lib/$(PROFILE)
|
||||
endif
|
||||
|
||||
# nuttzing!
|
||||
@@ -28,4 +26,3 @@ endif
|
||||
profile-check:
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:ONLY_1_1
|
||||
PROFILE_MBAS_FLAGS = -d:NET_1_1 -d:ONLY_1_1
|
||||
@@ -14,9 +14,11 @@
|
||||
# run the compiler; /r: flags are by default loaded from whatever's
|
||||
# in the MONO_PATH too).
|
||||
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
ifdef PLATFORM_MONO_NATIVE
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
TEST_RUNTIME = MONO_PATH=".:$$MONO_PATH" $(RUNTIME) --debug
|
||||
else
|
||||
MCS = $(PLATFORM_RUNTIME) $(BOOTSTRAP_MCS) /lib:$(topdir)/class/lib/$(PROFILE)
|
||||
endif
|
||||
|
||||
# nuttzing!
|
||||
|
||||
@@ -13,13 +13,11 @@
|
||||
dots := $(shell echo $(thisdir) |sed -e 's,[^./][^/]*,..,g')
|
||||
topdir := $(dots)
|
||||
|
||||
VERSION = 0.93
|
||||
VERSION = 0.30.99
|
||||
|
||||
USE_MCS_FLAGS = $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
|
||||
USE_MBAS_FLAGS = $(LOCAL_MBAS_FLAGS) $(PLATFORM_MBAS_FLAGS) $(PROFILE_MBAS_FLAGS) $(MBAS_FLAGS)
|
||||
USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
|
||||
CSCOMPILE = $(MCS) $(USE_MCS_FLAGS)
|
||||
BASCOMPILE = $(MBAS) $(USE_MBAS_FLAGS)
|
||||
CCOMPILE = $(CC) $(USE_CFLAGS)
|
||||
BOOT_COMPILE = $(BOOTSTRAP_MCS) $(USE_MCS_FLAGS)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
@@ -27,10 +25,8 @@ INSTALL_BIN = $(INSTALL) -m 755
|
||||
INSTALL_LIB = $(INSTALL_BIN)
|
||||
MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
|
||||
INTERNAL_MCS = $(RUNTIME) $(topdir)/mcs/mcs.exe
|
||||
INTERNAL_MBAS = $(RUNTIME) $(topdir)/mbas/mbas.exe
|
||||
INTERNAL_GMCS = $(RUNTIME) $(topdir)/gmcs/gmcs.exe
|
||||
INTERNAL_ILASM = $(RUNTIME) $(topdir)/ilasm/ilasm.exe
|
||||
INTERNAL_RESGEN = $(RUNTIME) $(topdir)/monoresgen/monoresgen.exe
|
||||
corlib = mscorlib.dll
|
||||
|
||||
depsdir = $(topdir)/build/deps
|
||||
@@ -127,8 +123,6 @@ test: test-recursive test-local
|
||||
|
||||
run-test: run-test-recursive test-local run-test-local
|
||||
|
||||
run-test-ondotnet: run-test-ondotnet-recursive test-local run-test-ondotnet-local
|
||||
|
||||
clean: clean-recursive clean-local
|
||||
|
||||
uninstall: uninstall-recursive uninstall-local
|
||||
|
||||
@@ -27,11 +27,11 @@ using System.Runtime.CompilerServices;
|
||||
// by using the '*' as shown below:
|
||||
|
||||
#if (NET_2_0)
|
||||
[assembly: AssemblyVersion ("0.7.6.2")]
|
||||
[assembly: AssemblyVersion ("0.7.4.2")]
|
||||
#elif (NET_1_1)
|
||||
[assembly: AssemblyVersion ("0.7.6.1")]
|
||||
[assembly: AssemblyVersion ("0.7.4.1")]
|
||||
#else
|
||||
[assembly: AssemblyVersion ("0.7.6.0")]
|
||||
[assembly: AssemblyVersion ("0.7.4.0")]
|
||||
#endif
|
||||
|
||||
[assembly: AssemblyDelaySign (true)]
|
||||
|
||||
@@ -1,43 +1,35 @@
|
||||
./AssemblyInfo.cs
|
||||
./Common/BitStream.cs
|
||||
./Common/Connection.cs
|
||||
./Common/ConnectionString.cs
|
||||
./Common/DBConnectionString.cs
|
||||
./Common/DBParametersEditor.cs
|
||||
./Common/Field.cs
|
||||
./Common/HuffmanTree.cs
|
||||
./Common/Inflater.cs
|
||||
./Common/MultiHostStream.cs
|
||||
./Common/NamedPipeStream.cs
|
||||
./Common/Platform.cs
|
||||
./Common/Security.cs
|
||||
./Common/SqlCommandEditorDlg.cs
|
||||
./Common/SqlCommandTextEditor.cs
|
||||
./Common/StreamCreator.cs
|
||||
./Common/StringUtility.cs
|
||||
./Common/Version.cs
|
||||
./Common/MultiHostStream.cs
|
||||
./mysqlclient/CharSetMap.cs
|
||||
./mysqlclient/CommandBuilder.cs
|
||||
./mysqlclient/CommandResult.cs
|
||||
./mysqlclient/CompressedStream.cs
|
||||
./mysqlclient/command.cs
|
||||
./mysqlclient/Connection.cs
|
||||
./mysqlclient/ConnectionInternal.cs
|
||||
./mysqlclient/ConnectionString.cs
|
||||
./mysqlclient/Designers/EditConnectionString.cs
|
||||
./mysqlclient/Designers/MySqlConnectionDesign.cs
|
||||
./mysqlclient/dataadapter.cs
|
||||
./mysqlclient/datareader.cs
|
||||
./mysqlclient/Driver.cs
|
||||
./mysqlclient/Exception.cs
|
||||
./mysqlclient/Field.cs
|
||||
./mysqlclient/MySqlError.cs
|
||||
./mysqlclient/MysqlDefs.cs
|
||||
./mysqlclient/MySqlHelper.cs
|
||||
./mysqlclient/MySqlPool.cs
|
||||
./mysqlclient/MySqlPoolManager.cs
|
||||
./mysqlclient/MySqlStream.cs
|
||||
./mysqlclient/MysqlDefs.cs
|
||||
./mysqlclient/Packet.cs
|
||||
./mysqlclient/command.cs
|
||||
./mysqlclient/dataadapter.cs
|
||||
./mysqlclient/datareader.cs
|
||||
./mysqlclient/parameter.cs
|
||||
./mysqlclient/parameter_collection.cs
|
||||
./mysqlclient/transaction.cs
|
||||
./mysqlclient/transcaction.cs
|
||||
./mysqlclient/Designers/EditConnectionString.cs
|
||||
./mysqlclient/Designers/MySqlConnectionDesign.cs
|
||||
@@ -1,40 +1,3 @@
|
||||
2004-05-18 Duncan Mak <[email protected]>
|
||||
|
||||
* AssemblyInfo.cs: Gonzalo reminded me that I need to update the
|
||||
version number as well. We're at 0.7.6 now.
|
||||
|
||||
* Common/StreamCreator.cs (CreateUnixSocketStream): Instead of
|
||||
hostList [0], which is a char, use hostList directly. This fixes
|
||||
the build.
|
||||
|
||||
2004-05-18 Duncan Mak <[email protected]>
|
||||
|
||||
* Makefile: Add reference to Mono.Posix.dll.
|
||||
|
||||
* ByteFX.Data.dll.sources: Update to latest listing of source
|
||||
files.
|
||||
|
||||
* AssemblyInfo.cs: Revert back to the previous version, because we
|
||||
don't have bytefx.snk.
|
||||
|
||||
* mysqlclient/transcaction.cs: Removed, replaced by the new
|
||||
transaction.cs.
|
||||
|
||||
2004-05-18 Duncan Mak <[email protected]>
|
||||
|
||||
* Update to the latest version:
|
||||
http://www.bytefx.com/releases/ByteFX.MySqlClient.76.src.zip
|
||||
|
||||
* Common/Connection.cs:
|
||||
* Common/ConnectionString.cs:
|
||||
* Common/Inflater.cs:
|
||||
* Common/Platform.cs:
|
||||
* Common/StreamCreater.cs:
|
||||
* Common/CommandResult.cs:
|
||||
* Common/CompressedStream.cs:
|
||||
* mysqlclient/MySqlError.cs:
|
||||
* mysqlclient/transaction.cs: New source files.
|
||||
|
||||
2003-10-06 Nick Drochak <[email protected]>
|
||||
|
||||
* AssemblyInfo.cs: Fix the build by ignoring assembly signing for now.
|
||||
|
||||
+288
-386
@@ -1,386 +1,288 @@
|
||||
3/11/2004
|
||||
MySql - Changed command editor to point to MySqlClient.Design
|
||||
|
||||
3/4/2004
|
||||
Common - Fixed bug in Version.isAtLeast
|
||||
Common - Changed DBConnectionString to support changes done to MySqlConnectionString
|
||||
Common - Removed SqlCommandEditor and DataAdapterPreviewDialog
|
||||
|
||||
3/3/2004
|
||||
MySql - Using new long return values in many places
|
||||
MySql - Integrated new CompressedStream class
|
||||
|
||||
3/2/2004
|
||||
MySql - Changed ConnectionString and added attributes to allow it to be used in MySqlClient.Design
|
||||
MySql - Changed packet.cs to support newer lengths in ReadLenInteger
|
||||
MySql - changed other classes to use new properties and fields of MySqlConnectionString
|
||||
MySql - ConnectionInternal is now using PING to see if the server is alive
|
||||
|
||||
3/1/2004
|
||||
MySql - Moved toolbox bitmaps into resource/
|
||||
MySql - Changed field.cs to allow values to come directly from row buffer
|
||||
|
||||
2/25/2004
|
||||
MySql - Changed to use the new driver.Send syntax
|
||||
MySql - Using a new packet queueing system
|
||||
MySql - started work handling the "broken" compression packet handling
|
||||
|
||||
2/20/2004
|
||||
Common - Fixed bug in StreamCreator where failure to connect to a host would continue
|
||||
to loop infinitly (thanks Kevin Casella)
|
||||
|
||||
2/8/2004
|
||||
MySql - Improved connectstring handling
|
||||
MySql - Moved designers into Pro product
|
||||
|
||||
2/4/2004
|
||||
MySql - Removed some old commented out code from command.cs
|
||||
MySql - Fixed a problem with compression
|
||||
|
||||
2/2/2004
|
||||
MySql - Fixed connection object where an exception throw prior to the connection opening would not leave
|
||||
the connection in the connecting state (thanks Chris Cline )
|
||||
|
||||
1/31/2004
|
||||
MySql - Added GUID support
|
||||
MySql - Fixed sequence out of order bug (thanks Mark Reay)
|
||||
|
||||
1/26/2004
|
||||
MySql - Enum values now supported as parameter values (thanks Philipp Sumi)
|
||||
1/22/2004
|
||||
MySql - Year datatype now supported
|
||||
|
||||
1/21/2004
|
||||
MySql - fixed compression
|
||||
|
||||
1/20/2004
|
||||
MySql - Fixed bug where a parameter with a TimeSpan as the value would not serialize properly
|
||||
MySql,Common - Fixed bug where default ctor would not set default connection string values
|
||||
MySql - Added some XML comments to some members
|
||||
MySql - Work to fix/improve compression handling
|
||||
|
||||
1/13/2004
|
||||
MySql,Common - Improved ConnectionString handling so that it better matches the standard set by SqlClient.
|
||||
MySql - A MySqlException is now thrown if a username is not included in the connection string
|
||||
MySql- Localhost is now used as the default if not specified on the connection string
|
||||
MySql - An exception is now thrown if an attempt is made to set the connection string while the connection is open
|
||||
MySql - Small changes to ConnectionString docs
|
||||
MySql,common - Removed MultiHostStream and MySqlStream. Replaced it with Common/StreamCreator
|
||||
MySql - Added support for Use Pipe connection string value
|
||||
MySql - Added Platform class for easier access to platform utility functions
|
||||
MySql - Fixed small pooling bug where new connection was not getting created after IsAlive fails
|
||||
Common - Added Platform.cs and StreamCreator.cs
|
||||
|
||||
12/30/2003
|
||||
MySql - Fixed Field.cs to properly handle 4.1 style timestamps
|
||||
MySql - Changed Common.Version to Common.DBVersion to avoid name conflict
|
||||
|
||||
|
||||
12/29/2003
|
||||
MySql - Fixed field.cs so that text columns return the right field type (thanks [email protected]et)
|
||||
|
||||
12/22/2003
|
||||
MySql - Added MySqlError class to provide some reference for error codes (thanks Geert Veenstra)
|
||||
|
||||
------------0.74 ------------------------
|
||||
|
||||
12/6/2003
|
||||
MySql - Added Unix socket support (thanks Mohammad DAMT [[email protected]])
|
||||
|
||||
12/4/2003
|
||||
MySql - only calling Thread.Sleep when no data is available
|
||||
MySql - improved escaping of quote characters in parameter data
|
||||
MySql - removed misleading comments from parameter.cs
|
||||
|
||||
12/1/2003
|
||||
Mysql -fixed pooling bug
|
||||
MySql - same pooling bug fixed again!! ;-)
|
||||
|
||||
11/30/2003
|
||||
MySql - Fixed ConnectionSTring editor dialog (thanks marco p (pomarc))
|
||||
Common - UserId now supported in connection strings (thanks Jeff Neeley)
|
||||
MySql - Attempting to create a parameter that is not input throws an exception (thanks Ryan Gregg)
|
||||
|
||||
11/29/2003
|
||||
MySql - Added much documentation
|
||||
|
||||
11/26/2003
|
||||
MySql - checked in new MultiHostStream capability. Big thanks to Dan Guisinger for this. he originally submitted the code and idea of supporting multiple machines on the connect string.
|
||||
|
||||
11/25/2003
|
||||
MySql - Added alot of documentation. Still alot to do.
|
||||
|
||||
11/24/2003
|
||||
MySql - Fixed speed issue with 0.73
|
||||
|
||||
11/14/2003
|
||||
MySql - changed to Thread.Sleep(0) in MySqlDataStream to help optimize the case where it doesn't need to wait (thanks Todd German)
|
||||
11/1/2003
|
||||
MySql - Prepopulating the idlepools to MinPoolSize
|
||||
|
||||
10/31/2003
|
||||
MySql - Fixed MySqlPool deadlock condition as well as stupid bug where CreateNewPooledConnection
|
||||
was not ever adding new connections to the pool.
|
||||
Also fixed MySqlStream.ReadBytes and ReadByte to not use TicksPerSecond which does not appear
|
||||
to always be right.
|
||||
(thanks Matthew J. Peddlesden)
|
||||
MySql - Fix for precision and scale (thanks Matthew J. Peddlesden)
|
||||
|
||||
10/28/2003
|
||||
MySql - Added Thread.Sleep(1) to stream reading methods to be more cpu friendly (thanks Sean McGinnis)
|
||||
|
||||
10/24/2003
|
||||
MySql - Fixed problem where ExecuteReader would sometime return null (thanks Lloyd Dupont )
|
||||
|
||||
10/17/2003
|
||||
MySql - Fixed major bug with null field handling (thanks Naucki)
|
||||
|
||||
10/15/2003
|
||||
MySql - enclosed queries for max_allowed_packet and characterset inside try catch (and set defaults)
|
||||
MySql - fixed problem where socket was not getting closed properly (thanks Steve!)
|
||||
|
||||
10/14/2003
|
||||
MySql - Fixed problem where ExecuteNonQuery was not always returning the right value
|
||||
|
||||
10/13/2003
|
||||
MySql - Fixed InternalConnection to not use @@session.max_allowed_packet but use @@max_allowed_packet. (Thanks Miguel)
|
||||
|
||||
10/12/2003
|
||||
MySql - Added many new XML doc lines
|
||||
|
||||
10/10/2003
|
||||
MySql - Fixed sql parsing to not send empty queries (thanks Rory)
|
||||
MySql - Fixed problem where the reader was not unpeeking the packet on close
|
||||
MySql - Fixed problem where user variables were not being handled (thanks Sami Vaaraniemi)
|
||||
MySql - Fixed loop checking in the MySqlPool (thanks Steve M. Brown)
|
||||
|
||||
10/7/2003
|
||||
MySql - Fixed ParameterCollection.Add method to match SqlClient (thanks Joshua Mouch)
|
||||
Common & MySql - Fixed ConnectionSTring parsing to handle no and yes for boolean and not lowercase values (thanks Naucki)
|
||||
|
||||
10/3/2003
|
||||
MySql - Added InternalConnection class, changes to pooling
|
||||
Common - Implemented Persist Security Info
|
||||
|
||||
9/26/2003
|
||||
Common - Added security.cs and version.cs to project
|
||||
|
||||
9/25/2003
|
||||
MySql - Fixed DateTime handling in Parameter.cs (thanks Burkhard Perkens-Golomb)
|
||||
MySql - Fixed parameter serialization where some types would throw a cast exception
|
||||
MySql - Fixed DataReader to convert all returned values to prevent casting errors (thanks Keith Murray)
|
||||
MySql - Added code to Command.ExecuteReader to return null if the initial SQL command throws an exception (thanks Burkhard Perkens-Golomb)
|
||||
|
||||
9/24/2003
|
||||
MySql - Fixed ExecuteScalar bug introduced with restructure
|
||||
|
||||
9/23/2003
|
||||
MySql - Restructure to allow for LOCAL DATA INFILE and better sequencing of packets
|
||||
MySql - Fixed several bugs related to restructure.
|
||||
|
||||
9/10/2003
|
||||
MySql - Early work done to support more secure passwords in Mysql 4.1. Old passwords in 4.1 not supported yet
|
||||
|
||||
8/22/2003
|
||||
MySql- Parameters appearing after system parameters are now handled correctly (Adam M. (adammil))
|
||||
MySql - strings can now be assigned directly to blob fields (Adam M.)
|
||||
|
||||
8/20/2003
|
||||
MySql - Fixed float parameters (thanks Pent)
|
||||
|
||||
8/7/2003
|
||||
MySql - Improved Parameter ctor and ParameterCollection.Add methods to better match SqlClient (thx Joshua Mouch )
|
||||
MySql - Corrected Connection.CreateCommand to return a MySqlCommand type
|
||||
MySql - Fixed connection string designer dialog box problem (thanks Abraham Guyt)
|
||||
|
||||
7/24/2003
|
||||
MySql - Fixed problem with sending commands not always reading the response packet (thanks Joshua Mouch )
|
||||
MySql - Fixed parameter serialization where some blobs types were not being handled (thanks Sean McGinnis )
|
||||
|
||||
7/22/2003
|
||||
MySql - Removed spurious MessageBox.show from DataReader code (thanks Joshua Mouch )
|
||||
|
||||
7/17/2003
|
||||
MySql - Fixed a nasty bug in the split sql code (thanks everyone! :-) )
|
||||
|
||||
*************Released 0.71***********************
|
||||
7/15/2003
|
||||
MySql - Fixed bug in MySqlStream where too much data could attempt to be read (thanks Peter Belbin)
|
||||
|
||||
7/11/2003
|
||||
MySql - Implemented HasRows (thanks Nash Pherson)
|
||||
MySql - Fixed bug where tables with more than 252 columns cause an exception ( thanks Joshua Kessler )
|
||||
MySql - Fixed bug where SQL statements ending in ; would cause a problem ( thanks Shane Krueger )
|
||||
MySql - Fixed bug in driver where error messsages were getting truncated by 1 character (thanks Shane Krueger)
|
||||
|
||||
7/6/2003
|
||||
========MySql===============
|
||||
* Made MySqlException serializable (thanks Mathias Hasselmann)
|
||||
|
||||
========PgSql===============
|
||||
* Made PgSqlException serializable (thanks Mathias Hasselmann)
|
||||
|
||||
***********Released 0.70*********************
|
||||
|
||||
6/25/2003
|
||||
========MySql===============
|
||||
* Updated some of the character code pages to be more accurate
|
||||
* Fixed problem where readers could be opened on connections that had readers open
|
||||
* Release of 0.70
|
||||
|
||||
6/20/2003
|
||||
========MySql===============
|
||||
* Moved test to separate assembly MySqlClientTests
|
||||
|
||||
6/19/2003
|
||||
========MySql===============
|
||||
* Fixed stupid problem in driver with sequence out of order (Thanks Peter Belbin)
|
||||
|
||||
6/18/2003
|
||||
========MySql===============
|
||||
* Added some pipe tests
|
||||
* Increased default max pool size to 50
|
||||
* Compiles with Mono 0-24
|
||||
|
||||
6/17/2003
|
||||
========MySql===============
|
||||
* Fixed connection and data reader dispose problems
|
||||
* Added String datatype handling to parameter serialization
|
||||
|
||||
6/13/2003
|
||||
========MySql===============
|
||||
* Fixed sequence problem in driver that occured after thrown exception
|
||||
(thanks Burkhard Perkens-Golomb)
|
||||
|
||||
6/10/2003
|
||||
========MySql===============
|
||||
* Added support for CommandBehavior.SingleRow to DataReader
|
||||
* Fixed command sql processing so quotes are better handled (thanks Theo Spears)
|
||||
|
||||
6/9/2003
|
||||
========MySQL===============
|
||||
* Fixed parsing of double, single, and decimal values to account for non-English separators.
|
||||
You still have to use the right syntax if you using hard coded sql, but if you use parameters
|
||||
the code will convert floating point types to use '.' appropriately internal both into the server
|
||||
and out.
|
||||
[ Thanks anonymous ]
|
||||
* Added MySqlStream class to simplify timeOuts and driver coding.
|
||||
* Fixed DataReader so that it is closed properly when the associated connection is closed.
|
||||
[thanks smishra]
|
||||
* Made client more SqlClient compliant so that DataReaders have to be closed before the connection
|
||||
can be used to run another command
|
||||
* Improved DBNull.Value handling in the fields
|
||||
* Added several unit tests
|
||||
* Fixed MySqlException so that the base class is actually called :-o
|
||||
* Improved driver coding
|
||||
|
||||
=============PgSql=================
|
||||
* Too many changes to document. Still basic structuring of driver. Driver not really usable yet.
|
||||
|
||||
|
||||
|
||||
5/28/2003
|
||||
* Fixed bug where NextResult was returning false on the last resultset
|
||||
* Added more tests for MySQL
|
||||
* Improved casting problems by equating unsigned 32bit values to Int64 and usigned 16bit values to Int32, etc
|
||||
|
||||
5/6/2003
|
||||
* Added new ctor for MySqlParameter for (name, type, size, srccol)
|
||||
* Fixed bug in MySqlDataReader where it didn't check for null fieldlist before returning field count
|
||||
|
||||
4/23/2003
|
||||
* Started adding MySqlClient unit tests (added MySqlClient/Tests folder and some test cases)
|
||||
* Fixed some things in Connection String handling
|
||||
|
||||
4/7/2003
|
||||
* Moved INIT_DB to MySqlPool. I may move it again, this is in preparation of the conference.
|
||||
|
||||
4/6/2003
|
||||
* Fixed bug inside CommandBuilder that prevented inserts from happening properly
|
||||
* Reworked some of the internals so that all three execute methods of Command worked properly
|
||||
* FIxed many small bugs found during benchmarking
|
||||
|
||||
4/5/2003
|
||||
* The first cut of CoonectionPooling is working. "min pool size" and "max pool size" are respected.
|
||||
|
||||
4/3/2003
|
||||
* Work to enable multiple resultsets to be returned
|
||||
* Character sets are handled much more intelligently now. The driver queries MySQL at startup for the default character set.
|
||||
That character set is then used for conversions if that code page can be loaded. If not, then the default code
|
||||
page for the current OS is used.
|
||||
|
||||
3/31/2003
|
||||
* Added code to save the inferred type in the name,value ctor of Parameter
|
||||
* Also, inferred type if value of null parameter is changed using Value property
|
||||
* Converted all files to use proper Camel case. MySQL is now MySql in all files. PgSQL is now PgSql
|
||||
* Added attribute to PgSql code to prevent designer from trying to show
|
||||
|
||||
3/17/2003
|
||||
* Added MySQLDbType property to Parameter object and added proper conversion code to convert from DbType to MySQLDbType)
|
||||
* Removed unused ObjectToString method from MySQLParameter.cs
|
||||
* Fixed Add(..) method in ParameterCollection so that it doesn't use Add(name, value) instead.
|
||||
* Fixed IndexOf and Contains in ParameterCollection to be aware that parameter names are now stored without @
|
||||
* Fixed Command.ConvertSQLToBytes so it only allows characters that can be in MySQL variable names
|
||||
* Fixed DataReader and Field so that blob fields read their data from Field.cs and GetBytes works right
|
||||
* Added simple query builder editor to CommandText property of MySQLCommand
|
||||
* Fixed CommandBuilder and Parameter serialization to account for Parameters not storing @ in their names
|
||||
* Removed MySQLFieldType enum from Field.cs. Now using MySQLDbType enum
|
||||
|
||||
3/15/2003
|
||||
* Added Designer attribute to several classes to prevent designer view when using VS.Net
|
||||
|
||||
3/13/2003
|
||||
* Fixed Initial catalog typo in ConnectionString designer
|
||||
* Removed 3 parameter ctor for MySQLParameter that conflicted with (name, type, value)
|
||||
* changed MySQLParameter so paramName is now stored without leading @ (this fixed null inserts when using designer)
|
||||
* Changed TypeConverter for MySQLParameter to use the ctor with all properties
|
||||
|
||||
0.68
|
||||
========================================================================
|
||||
Note that this build has not been checked out with Mono.
|
||||
|
||||
3/10/2003
|
||||
* Fixed sequence issue in driver
|
||||
|
||||
3/9/2003
|
||||
* Added DbParametersEditor to make parameter editing more like SqlClient
|
||||
* Fixed Command class so that parameters can be edited using the designer
|
||||
|
||||
3/7/2003
|
||||
* Update connection string designer to support Use Compression flag
|
||||
|
||||
2/15/2003
|
||||
* Fixed string encoding so that European characters like ä will work correctly
|
||||
|
||||
2/9/2003
|
||||
* Creating base classes to aid in building new data providers
|
||||
* Added support for UID key in connection string
|
||||
|
||||
2/10/2003
|
||||
* Field, parameter, command now using DBNull.Value instead of null
|
||||
* CommandBuilder using DBNull.Value
|
||||
* CommandBuilder now builds insert command correctly when an auto_insert field is not present
|
||||
* Field now uses typeof keyword to return System.Types (performance)
|
||||
|
||||
0.65
|
||||
====================
|
||||
* MySQLCommandBuilder now implemented
|
||||
* Transaction support now implemented (not all table types support this)
|
||||
* GetSchemaTable fixed to not use xsd (for Mono)
|
||||
* Driver is now Mono-compatible!!
|
||||
* TIME data type now supported
|
||||
* More work to improve Timestamp data type handling
|
||||
* Changed signatures of all classes to match corresponding SqlClient classes
|
||||
|
||||
0.60
|
||||
======================
|
||||
* Protocol compression using SharpZipLib (www.icsharpcode.net)
|
||||
* Named pipes on Windows now working properly
|
||||
* Work done to improve Timestamp data type handling
|
||||
* Implemented IEnumerable on DataReader so DataGrid would work
|
||||
|
||||
0.50
|
||||
======================
|
||||
* Speed increased dramatically by removing bugging network sync code
|
||||
* Driver no longer buffers rows of data (more ADO.Net compliant)
|
||||
* Conversion bugs related to TIMESTAMP and DATETIME fields fixed
|
||||
11/30/2003
|
||||
MySql - Fixed ConnectionSTring editor dialog (thanks marco p (pomarc))
|
||||
Common - UserId now supported in connection strings (thanks Jeff Neeley)
|
||||
MySql - Attempting to create a parameter that is not input throws an exception (thanks Ryan Gregg)
|
||||
|
||||
11/29/2003
|
||||
MySql - Added much documentation
|
||||
|
||||
11/26/2003
|
||||
MySql - checked in new MultiHostStream capability. Big thanks to Dan Guisinger for this. he originally submitted the code and idea of supporting multiple machines on the connect string.
|
||||
|
||||
11/25/2003
|
||||
MySql - Added alot of documentation. Still alot to do.
|
||||
|
||||
11/24/2003
|
||||
MySql - Fixed speed issue with 0.73
|
||||
|
||||
11/14/2003
|
||||
MySql - changed to Thread.Sleep(0) in MySqlDataStream to help optimize the case where it doesn't need to wait (thanks Todd German)
|
||||
11/1/2003
|
||||
MySql - Prepopulating the idlepools to MinPoolSize
|
||||
|
||||
10/31/2003
|
||||
MySql - Fixed MySqlPool deadlock condition as well as stupid bug where CreateNewPooledConnection
|
||||
was not ever adding new connections to the pool.
|
||||
Also fixed MySqlStream.ReadBytes and ReadByte to not use TicksPerSecond which does not appear
|
||||
to always be right.
|
||||
(thanks Matthew J. Peddlesden)
|
||||
MySql - Fix for precision and scale (thanks Matthew J. Peddlesden)
|
||||
|
||||
10/28/2003
|
||||
MySql - Added Thread.Sleep(1) to stream reading methods to be more cpu friendly (thanks Sean McGinnis)
|
||||
|
||||
10/24/2003
|
||||
MySql - Fixed problem where ExecuteReader would sometime return null (thanks Lloyd Dupont )
|
||||
|
||||
10/17/2003
|
||||
MySql - Fixed major bug with null field handling (thanks Naucki)
|
||||
|
||||
10/15/2003
|
||||
MySql - enclosed queries for max_allowed_packet and characterset inside try catch (and set defaults)
|
||||
MySql - fixed problem where socket was not getting closed properly (thanks Steve!)
|
||||
|
||||
10/14/2003
|
||||
MySql - Fixed problem where ExecuteNonQuery was not always returning the right value
|
||||
|
||||
10/13/2003
|
||||
MySql - Fixed InternalConnection to not use @@session.max_allowed_packet but use @@max_allowed_packet. (Thanks Miguel)
|
||||
|
||||
10/12/2003
|
||||
MySql - Added many new XML doc lines
|
||||
|
||||
10/10/2003
|
||||
MySql - Fixed sql parsing to not send empty queries (thanks Rory)
|
||||
MySql - Fixed problem where the reader was not unpeeking the packet on close
|
||||
MySql - Fixed problem where user variables were not being handled (thanks Sami Vaaraniemi)
|
||||
MySql - Fixed loop checking in the MySqlPool (thanks Steve M. Brown)
|
||||
|
||||
10/7/2003
|
||||
MySql - Fixed ParameterCollection.Add method to match SqlClient (thanks Joshua Mouch)
|
||||
Common & MySql - Fixed ConnectionSTring parsing to handle no and yes for boolean and not lowercase values (thanks Naucki)
|
||||
|
||||
10/3/2003
|
||||
MySql - Added InternalConnection class, changes to pooling
|
||||
Common - Implemented Persist Security Info
|
||||
|
||||
9/26/2003
|
||||
Common - Added security.cs and version.cs to project
|
||||
|
||||
9/25/2003
|
||||
MySql - Fixed DateTime handling in Parameter.cs (thanks Burkhard Perkens-Golomb)
|
||||
MySql - Fixed parameter serialization where some types would throw a cast exception
|
||||
MySql - Fixed DataReader to convert all returned values to prevent casting errors (thanks Keith Murray)
|
||||
MySql - Added code to Command.ExecuteReader to return null if the initial SQL command throws an exception (thanks Burkhard Perkens-Golomb)
|
||||
|
||||
9/24/2003
|
||||
MySql - Fixed ExecuteScalar bug introduced with restructure
|
||||
|
||||
9/23/2003
|
||||
MySql - Restructure to allow for LOCAL DATA INFILE and better sequencing of packets
|
||||
MySql - Fixed several bugs related to restructure.
|
||||
|
||||
9/10/2003
|
||||
MySql - Early work done to support more secure passwords in Mysql 4.1. Old passwords in 4.1 not supported yet
|
||||
|
||||
8/22/2003
|
||||
MySql- Parameters appearing after system parameters are now handled correctly (Adam M. (adammil))
|
||||
MySql - strings can now be assigned directly to blob fields (Adam M.)
|
||||
|
||||
8/20/2003
|
||||
MySql - Fixed float parameters (thanks Pent)
|
||||
|
||||
8/7/2003
|
||||
MySql - Improved Parameter ctor and ParameterCollection.Add methods to better match SqlClient (thx Joshua Mouch )
|
||||
MySql - Corrected Connection.CreateCommand to return a MySqlCommand type
|
||||
MySql - Fixed connection string designer dialog box problem (thanks Abraham Guyt)
|
||||
|
||||
7/24/2003
|
||||
MySql - Fixed problem with sending commands not always reading the response packet (thanks Joshua Mouch )
|
||||
MySql - Fixed parameter serialization where some blobs types were not being handled (thanks Sean McGinnis )
|
||||
|
||||
7/22/2003
|
||||
MySql - Removed spurious MessageBox.show from DataReader code (thanks Joshua Mouch )
|
||||
|
||||
7/17/2003
|
||||
MySql - Fixed a nasty bug in the split sql code (thanks everyone! :-) )
|
||||
|
||||
*************Released 0.71***********************
|
||||
7/15/2003
|
||||
MySql - Fixed bug in MySqlStream where too much data could attempt to be read (thanks Peter Belbin)
|
||||
|
||||
7/11/2003
|
||||
MySql - Implemented HasRows (thanks Nash Pherson)
|
||||
MySql - Fixed bug where tables with more than 252 columns cause an exception ( thanks Joshua Kessler )
|
||||
MySql - Fixed bug where SQL statements ending in ; would cause a problem ( thanks Shane Krueger )
|
||||
MySql - Fixed bug in driver where error messsages were getting truncated by 1 character (thanks Shane Krueger)
|
||||
|
||||
7/6/2003
|
||||
========MySql===============
|
||||
* Made MySqlException serializable (thanks Mathias Hasselmann)
|
||||
|
||||
========PgSql===============
|
||||
* Made PgSqlException serializable (thanks Mathias Hasselmann)
|
||||
|
||||
***********Released 0.70*********************
|
||||
|
||||
6/25/2003
|
||||
========MySql===============
|
||||
* Updated some of the character code pages to be more accurate
|
||||
* Fixed problem where readers could be opened on connections that had readers open
|
||||
* Release of 0.70
|
||||
|
||||
6/20/2003
|
||||
========MySql===============
|
||||
* Moved test to separate assembly MySqlClientTests
|
||||
|
||||
6/19/2003
|
||||
========MySql===============
|
||||
* Fixed stupid problem in driver with sequence out of order (Thanks Peter Belbin)
|
||||
|
||||
6/18/2003
|
||||
========MySql===============
|
||||
* Added some pipe tests
|
||||
* Increased default max pool size to 50
|
||||
* Compiles with Mono 0-24
|
||||
|
||||
6/17/2003
|
||||
========MySql===============
|
||||
* Fixed connection and data reader dispose problems
|
||||
* Added String datatype handling to parameter serialization
|
||||
|
||||
6/13/2003
|
||||
========MySql===============
|
||||
* Fixed sequence problem in driver that occured after thrown exception
|
||||
(thanks Burkhard Perkens-Golomb)
|
||||
|
||||
6/10/2003
|
||||
========MySql===============
|
||||
* Added support for CommandBehavior.SingleRow to DataReader
|
||||
* Fixed command sql processing so quotes are better handled (thanks Theo Spears)
|
||||
|
||||
6/9/2003
|
||||
========MySQL===============
|
||||
* Fixed parsing of double, single, and decimal values to account for non-English separators.
|
||||
You still have to use the right syntax if you using hard coded sql, but if you use parameters
|
||||
the code will convert floating point types to use '.' appropriately internal both into the server
|
||||
and out.
|
||||
[ Thanks anonymous ]
|
||||
* Added MySqlStream class to simplify timeOuts and driver coding.
|
||||
* Fixed DataReader so that it is closed properly when the associated connection is closed.
|
||||
[thanks smishra]
|
||||
* Made client more SqlClient compliant so that DataReaders have to be closed before the connection
|
||||
can be used to run another command
|
||||
* Improved DBNull.Value handling in the fields
|
||||
* Added several unit tests
|
||||
* Fixed MySqlException so that the base class is actually called :-o
|
||||
* Improved driver coding
|
||||
|
||||
=============PgSql=================
|
||||
* Too many changes to document. Still basic structuring of driver. Driver not really usable yet.
|
||||
|
||||
|
||||
|
||||
5/28/2003
|
||||
* Fixed bug where NextResult was returning false on the last resultset
|
||||
* Added more tests for MySQL
|
||||
* Improved casting problems by equating unsigned 32bit values to Int64 and usigned 16bit values to Int32, etc
|
||||
|
||||
5/6/2003
|
||||
* Added new ctor for MySqlParameter for (name, type, size, srccol)
|
||||
* Fixed bug in MySqlDataReader where it didn't check for null fieldlist before returning field count
|
||||
|
||||
4/23/2003
|
||||
* Started adding MySqlClient unit tests (added MySqlClient/Tests folder and some test cases)
|
||||
* Fixed some things in Connection String handling
|
||||
|
||||
4/7/2003
|
||||
* Moved INIT_DB to MySqlPool. I may move it again, this is in preparation of the conference.
|
||||
|
||||
4/6/2003
|
||||
* Fixed bug inside CommandBuilder that prevented inserts from happening properly
|
||||
* Reworked some of the internals so that all three execute methods of Command worked properly
|
||||
* FIxed many small bugs found during benchmarking
|
||||
|
||||
4/5/2003
|
||||
* The first cut of CoonectionPooling is working. "min pool size" and "max pool size" are respected.
|
||||
|
||||
4/3/2003
|
||||
* Work to enable multiple resultsets to be returned
|
||||
* Character sets are handled much more intelligently now. The driver queries MySQL at startup for the default character set.
|
||||
That character set is then used for conversions if that code page can be loaded. If not, then the default code
|
||||
page for the current OS is used.
|
||||
|
||||
3/31/2003
|
||||
* Added code to save the inferred type in the name,value ctor of Parameter
|
||||
* Also, inferred type if value of null parameter is changed using Value property
|
||||
* Converted all files to use proper Camel case. MySQL is now MySql in all files. PgSQL is now PgSql
|
||||
* Added attribute to PgSql code to prevent designer from trying to show
|
||||
|
||||
3/17/2003
|
||||
* Added MySQLDbType property to Parameter object and added proper conversion code to convert from DbType to MySQLDbType)
|
||||
* Removed unused ObjectToString method from MySQLParameter.cs
|
||||
* Fixed Add(..) method in ParameterCollection so that it doesn't use Add(name, value) instead.
|
||||
* Fixed IndexOf and Contains in ParameterCollection to be aware that parameter names are now stored without @
|
||||
* Fixed Command.ConvertSQLToBytes so it only allows characters that can be in MySQL variable names
|
||||
* Fixed DataReader and Field so that blob fields read their data from Field.cs and GetBytes works right
|
||||
* Added simple query builder editor to CommandText property of MySQLCommand
|
||||
* Fixed CommandBuilder and Parameter serialization to account for Parameters not storing @ in their names
|
||||
* Removed MySQLFieldType enum from Field.cs. Now using MySQLDbType enum
|
||||
|
||||
3/15/2003
|
||||
* Added Designer attribute to several classes to prevent designer view when using VS.Net
|
||||
|
||||
3/13/2003
|
||||
* Fixed Initial catalog typo in ConnectionString designer
|
||||
* Removed 3 parameter ctor for MySQLParameter that conflicted with (name, type, value)
|
||||
* changed MySQLParameter so paramName is now stored without leading @ (this fixed null inserts when using designer)
|
||||
* Changed TypeConverter for MySQLParameter to use the ctor with all properties
|
||||
|
||||
0.68
|
||||
========================================================================
|
||||
Note that this build has not been checked out with Mono.
|
||||
|
||||
3/10/2003
|
||||
* Fixed sequence issue in driver
|
||||
|
||||
3/9/2003
|
||||
* Added DbParametersEditor to make parameter editing more like SqlClient
|
||||
* Fixed Command class so that parameters can be edited using the designer
|
||||
|
||||
3/7/2003
|
||||
* Update connection string designer to support Use Compression flag
|
||||
|
||||
2/15/2003
|
||||
* Fixed string encoding so that European characters like ä will work correctly
|
||||
|
||||
2/9/2003
|
||||
* Creating base classes to aid in building new data providers
|
||||
* Added support for UID key in connection string
|
||||
|
||||
2/10/2003
|
||||
* Field, parameter, command now using DBNull.Value instead of null
|
||||
* CommandBuilder using DBNull.Value
|
||||
* CommandBuilder now builds insert command correctly when an auto_insert field is not present
|
||||
* Field now uses typeof keyword to return System.Types (performance)
|
||||
|
||||
0.65
|
||||
====================
|
||||
* MySQLCommandBuilder now implemented
|
||||
* Transaction support now implemented (not all table types support this)
|
||||
* GetSchemaTable fixed to not use xsd (for Mono)
|
||||
* Driver is now Mono-compatible!!
|
||||
* TIME data type now supported
|
||||
* More work to improve Timestamp data type handling
|
||||
* Changed signatures of all classes to match corresponding SqlClient classes
|
||||
|
||||
0.60
|
||||
======================
|
||||
* Protocol compression using SharpZipLib (www.icsharpcode.net)
|
||||
* Named pipes on Windows now working properly
|
||||
* Work done to improve Timestamp data type handling
|
||||
* Implemented IEnumerable on DataReader so DataGrid would work
|
||||
|
||||
0.50
|
||||
======================
|
||||
* Speed increased dramatically by removing bugging network sync code
|
||||
* Driver no longer buffers rows of data (more ADO.Net compliant)
|
||||
* Conversion bugs related to TIMESTAMP and DATETIME fields fixed
|
||||
@@ -1,53 +1,53 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for BitStream.
|
||||
/// </summary>
|
||||
public class BitStream : MemoryStream
|
||||
{
|
||||
private byte[] _input;
|
||||
private int _start;
|
||||
private int _end;
|
||||
private int _bitindex;
|
||||
private uint _bitbuffer;
|
||||
private int _bits_in_buffer;
|
||||
|
||||
public BitStream(byte[] input, int index, int len)
|
||||
{
|
||||
_bitindex = 0;
|
||||
_bitbuffer = 0;
|
||||
_bits_in_buffer = 0;
|
||||
_input = input;
|
||||
_start = index;
|
||||
_end = _start + len;
|
||||
}
|
||||
|
||||
public int GetBits(int numbits)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int PeekBits(int numbits)
|
||||
{
|
||||
int val=0;
|
||||
|
||||
int index=_start;
|
||||
while (numbits > 0)
|
||||
{
|
||||
val = (val << 8) | _input[index++];
|
||||
numbits -= 8;
|
||||
}
|
||||
|
||||
while (_bits_in_buffer < numbits)
|
||||
{
|
||||
if (_start == _end)
|
||||
throw new Exception("Out of bits");
|
||||
byte b = _input[_start++];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for BitStream.
|
||||
/// </summary>
|
||||
public class BitStream : MemoryStream
|
||||
{
|
||||
private byte[] _input;
|
||||
private int _start;
|
||||
private int _end;
|
||||
private int _bitindex;
|
||||
private uint _bitbuffer;
|
||||
private int _bits_in_buffer;
|
||||
|
||||
public BitStream(byte[] input, int index, int len)
|
||||
{
|
||||
_bitindex = 0;
|
||||
_bitbuffer = 0;
|
||||
_bits_in_buffer = 0;
|
||||
_input = input;
|
||||
_start = index;
|
||||
_end = _start + len;
|
||||
}
|
||||
|
||||
public int GetBits(int numbits)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int PeekBits(int numbits)
|
||||
{
|
||||
int val=0;
|
||||
|
||||
int index=_start;
|
||||
while (numbits > 0)
|
||||
{
|
||||
val = (val << 8) | _input[index++];
|
||||
numbits -= 8;
|
||||
}
|
||||
|
||||
while (_bits_in_buffer < numbits)
|
||||
{
|
||||
if (_start == _end)
|
||||
throw new Exception("Out of bits");
|
||||
byte b = _input[_start++];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +1,129 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Data;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Connection.
|
||||
/// </summary>
|
||||
[ToolboxItem(false)]
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
public class Connection : Component
|
||||
{
|
||||
internal ConnectionString connString;
|
||||
internal ConnectionState state;
|
||||
internal IDataReader reader = null;
|
||||
|
||||
|
||||
public Connection(System.ComponentModel.IContainer container)
|
||||
{
|
||||
/// <summary>
|
||||
/// Required for Windows.Forms Class Composition Designer support
|
||||
/// </summary>
|
||||
container.Add(this);
|
||||
Init();
|
||||
}
|
||||
|
||||
public Connection()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
protected void Init()
|
||||
{
|
||||
state = ConnectionState.Closed;
|
||||
}
|
||||
|
||||
|
||||
[Browsable(true)]
|
||||
public string DataSource
|
||||
{
|
||||
get
|
||||
{
|
||||
String s = connString["data source"];
|
||||
if (s == null || s.Length == 0)
|
||||
return "localhost";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public string User
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = connString["user id"];
|
||||
if (s == null)
|
||||
s = "";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
string pwd = connString["password"];
|
||||
if (pwd == null)
|
||||
pwd = "";
|
||||
return pwd;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
public int ConnectionTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns the connection time-out value set in the connection
|
||||
// string. Zero indicates an indefinite time-out period.
|
||||
if (connString == null)
|
||||
return 30;
|
||||
return connString.GetIntOption("connection timeout", 30);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
public string Database
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns an initial database as set in the connection string.
|
||||
// An empty string indicates not set - do not return a null reference.
|
||||
return connString["database"];
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public ConnectionState State
|
||||
{
|
||||
get { return state; }
|
||||
}
|
||||
|
||||
internal IDataReader Reader
|
||||
{
|
||||
get { return reader; }
|
||||
set { reader = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Data;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Connection.
|
||||
/// </summary>
|
||||
[ToolboxItem(false)]
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
public class Connection : Component
|
||||
{
|
||||
internal ConnectionString connString;
|
||||
internal ConnectionState state;
|
||||
internal IDataReader reader = null;
|
||||
|
||||
|
||||
public Connection(System.ComponentModel.IContainer container)
|
||||
{
|
||||
/// <summary>
|
||||
/// Required for Windows.Forms Class Composition Designer support
|
||||
/// </summary>
|
||||
container.Add(this);
|
||||
Init();
|
||||
}
|
||||
|
||||
public Connection()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
protected void Init()
|
||||
{
|
||||
state = ConnectionState.Closed;
|
||||
}
|
||||
|
||||
|
||||
[Browsable(true)]
|
||||
public string DataSource
|
||||
{
|
||||
get
|
||||
{
|
||||
String s = connString["data source"];
|
||||
if (s == null || s.Length == 0)
|
||||
return "localhost";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public string User
|
||||
{
|
||||
get
|
||||
{
|
||||
string s = connString["user id"];
|
||||
if (s == null)
|
||||
s = "";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
string pwd = connString["password"];
|
||||
if (pwd == null)
|
||||
pwd = "";
|
||||
return pwd;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
public int ConnectionTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns the connection time-out value set in the connection
|
||||
// string. Zero indicates an indefinite time-out period.
|
||||
if (connString == null)
|
||||
return 30;
|
||||
return connString.GetIntOption("connection timeout", 30);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
public string Database
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns an initial database as set in the connection string.
|
||||
// An empty string indicates not set - do not return a null reference.
|
||||
return connString["database"];
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public ConnectionState State
|
||||
{
|
||||
get { return state; }
|
||||
}
|
||||
|
||||
internal IDataReader Reader
|
||||
{
|
||||
get { return reader; }
|
||||
set { reader = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,185 +1,185 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Utility.
|
||||
/// </summary>
|
||||
internal class ConnectionString
|
||||
{
|
||||
private StringDictionary elements;
|
||||
private string connString;
|
||||
|
||||
public ConnectionString(string connString)
|
||||
{
|
||||
this.connString = connString;
|
||||
elements = new StringDictionary();
|
||||
Parse( connString );
|
||||
}
|
||||
|
||||
public string Value
|
||||
{
|
||||
get { return connString; }
|
||||
}
|
||||
|
||||
public string this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
string val = elements[key];
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetIntOption( string key, int defaultvalue )
|
||||
{
|
||||
string val = this[ key ];
|
||||
if (null == val) return defaultvalue;
|
||||
return Convert.ToInt32( val );
|
||||
}
|
||||
|
||||
public bool GetBoolOption( string key, bool defaultvalue )
|
||||
{
|
||||
string val = this[ key ];
|
||||
if (null == val) return defaultvalue;
|
||||
val = val.ToLower();
|
||||
if (val == "true" || val == "yes") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Contains( string key )
|
||||
{
|
||||
return elements.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool Equals( ConnectionString obj )
|
||||
{
|
||||
foreach (string key in elements.Keys)
|
||||
{
|
||||
if (! obj.Contains(key)) return false;
|
||||
if ( ! this[key].Equals( obj[key] )) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public bool PoolingEquals( ConnectionString obj )
|
||||
{
|
||||
foreach (string key in elements.Keys)
|
||||
{
|
||||
// these connection string elements only affect pooling
|
||||
// so we don't check them when making sure connection strings
|
||||
// are alike
|
||||
if (key.Equals("connection lifetime")) continue;
|
||||
if (key.Equals("connection reset")) continue;
|
||||
if (key.Equals("enlist")) continue;
|
||||
if (key.Equals("max pool size")) continue;
|
||||
if (key.Equals("min pool size")) continue;
|
||||
if (key.Equals("pooling")) continue;
|
||||
|
||||
if (! obj.Contains(key)) return false;
|
||||
if ( ! this[key].Equals( obj[key] )) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void Parse( String s )
|
||||
{
|
||||
String[] keyvalues = s.Split( ';' );
|
||||
String[] newkeyvalues = new String[keyvalues.Length];
|
||||
int x = 0;
|
||||
|
||||
elements.Clear();
|
||||
|
||||
// first run through the array and check for any keys that
|
||||
// have ; in their value
|
||||
foreach (String keyvalue in keyvalues)
|
||||
{
|
||||
// check for trailing ; at the end of the connection string
|
||||
if (keyvalue.Length == 0) continue;
|
||||
|
||||
// this value has an '=' sign so we are ok
|
||||
if (keyvalue.IndexOf('=') >= 0)
|
||||
{
|
||||
newkeyvalues[x++] = keyvalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
newkeyvalues[x-1] += ";";
|
||||
newkeyvalues[x-1] += keyvalue;
|
||||
}
|
||||
}
|
||||
|
||||
// now we run through our normalized key-values, splitting on equals
|
||||
for (int y=0; y < x; y++)
|
||||
{
|
||||
String[] parts = newkeyvalues[y].Split( '=' );
|
||||
|
||||
// first trim off any space and lowercase the key
|
||||
parts[0] = parts[0].Trim().ToLower();
|
||||
parts[1] = parts[1].Trim();
|
||||
|
||||
// normalize the keys going in. We want to support the same synonyms that
|
||||
// SqlClient supports
|
||||
switch (parts[0])
|
||||
{
|
||||
case "uid": parts[0] = "user id"; break;
|
||||
case "pwd": parts[0] = "password"; break;
|
||||
case "user": parts[0] = "user id"; break;
|
||||
case "initial catalog": parts[0] = "database"; break;
|
||||
case "server": parts[0] = "data source"; break;
|
||||
}
|
||||
|
||||
// we also want to clear off any quotes
|
||||
String newvalue = parts[1].Trim( '\'' );
|
||||
if (newvalue.Length == parts[1].Length)
|
||||
{
|
||||
newvalue = parts[1].Trim('"');
|
||||
}
|
||||
parts[1] = newvalue;
|
||||
|
||||
// make sure we don't get dupliate keys
|
||||
if (elements.ContainsKey(parts[0]))
|
||||
{
|
||||
throw new ArgumentException("Duplicate key in connection string", parts[0]);
|
||||
}
|
||||
|
||||
elements.Add( parts[0], parts[1] );
|
||||
|
||||
// now put the correct parsed string into the connection string !! (AG 4/8/2003)
|
||||
connString="";
|
||||
foreach(string key in elements.Keys)
|
||||
{
|
||||
connString=connString+key+"="+elements[key]+"; ";
|
||||
}
|
||||
connString=connString.Substring(0,connString.Length-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Utility.
|
||||
/// </summary>
|
||||
internal class ConnectionString
|
||||
{
|
||||
private StringDictionary elements;
|
||||
private string connString;
|
||||
|
||||
public ConnectionString(string connString)
|
||||
{
|
||||
this.connString = connString;
|
||||
elements = new StringDictionary();
|
||||
Parse( connString );
|
||||
}
|
||||
|
||||
public string Value
|
||||
{
|
||||
get { return connString; }
|
||||
}
|
||||
|
||||
public string this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
string val = elements[key];
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetIntOption( string key, int defaultvalue )
|
||||
{
|
||||
string val = this[ key ];
|
||||
if (null == val) return defaultvalue;
|
||||
return Convert.ToInt32( val );
|
||||
}
|
||||
|
||||
public bool GetBoolOption( string key, bool defaultvalue )
|
||||
{
|
||||
string val = this[ key ];
|
||||
if (null == val) return defaultvalue;
|
||||
val = val.ToLower();
|
||||
if (val == "true" || val == "yes") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Contains( string key )
|
||||
{
|
||||
return elements.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool Equals( ConnectionString obj )
|
||||
{
|
||||
foreach (string key in elements.Keys)
|
||||
{
|
||||
if (! obj.Contains(key)) return false;
|
||||
if ( ! this[key].Equals( obj[key] )) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public bool PoolingEquals( ConnectionString obj )
|
||||
{
|
||||
foreach (string key in elements.Keys)
|
||||
{
|
||||
// these connection string elements only affect pooling
|
||||
// so we don't check them when making sure connection strings
|
||||
// are alike
|
||||
if (key.Equals("connection lifetime")) continue;
|
||||
if (key.Equals("connection reset")) continue;
|
||||
if (key.Equals("enlist")) continue;
|
||||
if (key.Equals("max pool size")) continue;
|
||||
if (key.Equals("min pool size")) continue;
|
||||
if (key.Equals("pooling")) continue;
|
||||
|
||||
if (! obj.Contains(key)) return false;
|
||||
if ( ! this[key].Equals( obj[key] )) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void Parse( String s )
|
||||
{
|
||||
String[] keyvalues = s.Split( ';' );
|
||||
String[] newkeyvalues = new String[keyvalues.Length];
|
||||
int x = 0;
|
||||
|
||||
elements.Clear();
|
||||
|
||||
// first run through the array and check for any keys that
|
||||
// have ; in their value
|
||||
foreach (String keyvalue in keyvalues)
|
||||
{
|
||||
// check for trailing ; at the end of the connection string
|
||||
if (keyvalue.Length == 0) continue;
|
||||
|
||||
// this value has an '=' sign so we are ok
|
||||
if (keyvalue.IndexOf('=') >= 0)
|
||||
{
|
||||
newkeyvalues[x++] = keyvalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
newkeyvalues[x-1] += ";";
|
||||
newkeyvalues[x-1] += keyvalue;
|
||||
}
|
||||
}
|
||||
|
||||
// now we run through our normalized key-values, splitting on equals
|
||||
for (int y=0; y < x; y++)
|
||||
{
|
||||
String[] parts = newkeyvalues[y].Split( '=' );
|
||||
|
||||
// first trim off any space and lowercase the key
|
||||
parts[0] = parts[0].Trim().ToLower();
|
||||
parts[1] = parts[1].Trim();
|
||||
|
||||
// normalize the keys going in. We want to support the same synonyms that
|
||||
// SqlClient supports
|
||||
switch (parts[0])
|
||||
{
|
||||
case "uid": parts[0] = "user id"; break;
|
||||
case "pwd": parts[0] = "password"; break;
|
||||
case "user": parts[0] = "user id"; break;
|
||||
case "initial catalog": parts[0] = "database"; break;
|
||||
case "server": parts[0] = "data source"; break;
|
||||
}
|
||||
|
||||
// we also want to clear off any quotes
|
||||
String newvalue = parts[1].Trim( '\'' );
|
||||
if (newvalue.Length == parts[1].Length)
|
||||
{
|
||||
newvalue = parts[1].Trim('"');
|
||||
}
|
||||
parts[1] = newvalue;
|
||||
|
||||
// make sure we don't get dupliate keys
|
||||
if (elements.ContainsKey(parts[0]))
|
||||
{
|
||||
throw new ArgumentException("Duplicate key in connection string", parts[0]);
|
||||
}
|
||||
|
||||
elements.Add( parts[0], parts[1] );
|
||||
|
||||
// now put the correct parsed string into the connection string !! (AG 4/8/2003)
|
||||
connString="";
|
||||
foreach(string key in elements.Keys)
|
||||
{
|
||||
connString=connString+key+"="+elements[key]+"; ";
|
||||
}
|
||||
connString=connString.Substring(0,connString.Length-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,189 +1,245 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Utility.
|
||||
/// </summary>
|
||||
internal abstract class DBConnectionString
|
||||
{
|
||||
protected Hashtable keyValues = new Hashtable();
|
||||
protected string connectionName = String.Empty;
|
||||
protected string connectString;
|
||||
|
||||
public DBConnectionString()
|
||||
{
|
||||
keyValues = GetDefaultValues();
|
||||
}
|
||||
|
||||
public void SetConnectionString(string value)
|
||||
{
|
||||
Hashtable ht = Parse( value );
|
||||
connectString = value;
|
||||
keyValues = ht;
|
||||
}
|
||||
|
||||
protected string GetString(string name)
|
||||
{
|
||||
if (! keyValues.ContainsKey(name)) return String.Empty;
|
||||
return (keyValues[name] as string);
|
||||
}
|
||||
|
||||
protected int GetInt( string name )
|
||||
{
|
||||
return Convert.ToInt32(keyValues[name]);
|
||||
}
|
||||
|
||||
protected bool GetBool( string name )
|
||||
{
|
||||
return Convert.ToBoolean(keyValues[name]);
|
||||
}
|
||||
|
||||
protected virtual bool ConnectionParameterParsed(Hashtable hash, string key, string value)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case "persist security info":
|
||||
hash["persist security info"] =
|
||||
value.ToLower() == "yes" || value.ToLower() == "true";
|
||||
return true;
|
||||
|
||||
case "uid":
|
||||
case "username":
|
||||
case "user id":
|
||||
case "user name":
|
||||
case "userid":
|
||||
hash["user id"] = value;
|
||||
return true;
|
||||
|
||||
case "password":
|
||||
case "pwd":
|
||||
hash["password"] = value;
|
||||
return true;
|
||||
|
||||
case "host":
|
||||
case "server":
|
||||
case "data source":
|
||||
case "datasource":
|
||||
case "address":
|
||||
case "addr":
|
||||
case "network address":
|
||||
hash["host"] = value;
|
||||
return true;
|
||||
|
||||
case "initial catalog":
|
||||
case "database":
|
||||
hash["database"] = value;
|
||||
return true;
|
||||
|
||||
case "connection timeout":
|
||||
case "connect timeout":
|
||||
hash["connect timeout"] = Int32.Parse( value );
|
||||
return true;
|
||||
|
||||
case "port":
|
||||
hash["port"] = Int32.Parse( value );
|
||||
return true;
|
||||
|
||||
case "pooling":
|
||||
hash["pooling"] =
|
||||
value.ToLower() == "yes" || value.ToLower() == "true";
|
||||
return true;
|
||||
|
||||
case "min pool size":
|
||||
hash["min pool size"] = Int32.Parse(value);
|
||||
return true;
|
||||
|
||||
case "max pool size":
|
||||
hash["max pool size"] = Int32.Parse(value);
|
||||
return true;
|
||||
|
||||
case "connection lifetime":
|
||||
hash["connect lifetime"] = Int32.Parse(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual Hashtable GetDefaultValues()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Hashtable ParseKeyValuePairs( string src )
|
||||
{
|
||||
String[] keyvalues = src.Split( ';' );
|
||||
String[] newkeyvalues = new String[keyvalues.Length];
|
||||
int x = 0;
|
||||
|
||||
// first run through the array and check for any keys that
|
||||
// have ; in their value
|
||||
foreach (String keyvalue in keyvalues)
|
||||
{
|
||||
// check for trailing ; at the end of the connection string
|
||||
if (keyvalue.Length == 0) continue;
|
||||
|
||||
// this value has an '=' sign so we are ok
|
||||
if (keyvalue.IndexOf('=') >= 0)
|
||||
{
|
||||
newkeyvalues[x++] = keyvalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
newkeyvalues[x-1] += ";";
|
||||
newkeyvalues[x-1] += keyvalue;
|
||||
}
|
||||
}
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
|
||||
// now we run through our normalized key-values, splitting on equals
|
||||
for (int y=0; y < x; y++)
|
||||
{
|
||||
String[] parts = newkeyvalues[y].Split( '=' );
|
||||
|
||||
// first trim off any space and lowercase the key
|
||||
parts[0] = parts[0].Trim().ToLower();
|
||||
parts[1] = parts[1].Trim();
|
||||
|
||||
// we also want to clear off any quotes
|
||||
parts[0] = parts[0].Trim('\'', '"');
|
||||
parts[1] = parts[1].Trim('\'', '"');
|
||||
|
||||
hash.Add( parts[0], parts[1] );
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
protected virtual Hashtable Parse(string newConnectString)
|
||||
{
|
||||
Hashtable hash = ParseKeyValuePairs( newConnectString );
|
||||
Hashtable newHash = GetDefaultValues();
|
||||
|
||||
foreach (object key in hash.Keys)
|
||||
ConnectionParameterParsed( newHash, (string)key, (string)hash[key] );
|
||||
return newHash;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Utility.
|
||||
/// </summary>
|
||||
internal class DBConnectionString
|
||||
{
|
||||
protected Hashtable keyValues = new Hashtable();
|
||||
protected string connectString;
|
||||
protected string host;
|
||||
protected string username;
|
||||
protected string password;
|
||||
protected string database;
|
||||
protected int connectTimeout;
|
||||
protected int port;
|
||||
protected int maxPoolSize;
|
||||
protected int minPoolSize;
|
||||
protected int connectLifetime;
|
||||
protected bool pooling;
|
||||
protected bool persistSecurityInfo;
|
||||
|
||||
public DBConnectionString()
|
||||
{
|
||||
persistSecurityInfo = false;
|
||||
}
|
||||
|
||||
public DBConnectionString(string connectString) : this()
|
||||
{
|
||||
this.connectString = connectString;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public string Host
|
||||
{
|
||||
get { return host; }
|
||||
}
|
||||
|
||||
public string Username
|
||||
{
|
||||
get { return username; }
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get { return password; }
|
||||
}
|
||||
|
||||
public int ConnectTimeout
|
||||
{
|
||||
get { return connectTimeout; }
|
||||
}
|
||||
|
||||
public string Database
|
||||
{
|
||||
get { return database; }
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
get { return port; }
|
||||
}
|
||||
|
||||
public int MaxPoolSize
|
||||
{
|
||||
get { return maxPoolSize; }
|
||||
}
|
||||
|
||||
public int MinPoolSize
|
||||
{
|
||||
get { return minPoolSize; }
|
||||
}
|
||||
|
||||
public bool Pooling
|
||||
{
|
||||
get { return pooling; }
|
||||
}
|
||||
|
||||
public int ConnectionLifetime
|
||||
{
|
||||
get { return connectLifetime; }
|
||||
}
|
||||
|
||||
public string ConnectString
|
||||
{
|
||||
get { return GetConnectionString(); }
|
||||
set { connectString = value; Parse(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private string GetConnectionString()
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
foreach ( string key in keyValues.Keys)
|
||||
{
|
||||
if ((key.ToLower() == "pwd" || key.ToLower() == "password") &&
|
||||
!persistSecurityInfo) continue;
|
||||
str.AppendFormat("{0}={1};", key, keyValues[key]);
|
||||
}
|
||||
|
||||
if (str.Length > 0)
|
||||
str.Remove( str.Length-1, 1 );
|
||||
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
protected virtual void ConnectionParameterParsed(string key, string value)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case "persist security info":
|
||||
if (value.ToLower() == "no" || value.ToLower() == "false")
|
||||
persistSecurityInfo = false;
|
||||
else
|
||||
persistSecurityInfo = true;
|
||||
break;
|
||||
|
||||
case "uid":
|
||||
case "username":
|
||||
case "user id":
|
||||
case "user name":
|
||||
case "userid":
|
||||
username = value;
|
||||
break;
|
||||
|
||||
case "password":
|
||||
case "pwd":
|
||||
password = value;
|
||||
break;
|
||||
|
||||
case "host":
|
||||
case "server":
|
||||
case "data source":
|
||||
case "datasource":
|
||||
case "address":
|
||||
case "addr":
|
||||
case "network address":
|
||||
host = value;
|
||||
break;
|
||||
|
||||
case "initial catalog":
|
||||
case "database":
|
||||
database = value;
|
||||
break;
|
||||
|
||||
case "connection timeout":
|
||||
case "connect timeout":
|
||||
connectTimeout = Int32.Parse( value );
|
||||
break;
|
||||
|
||||
case "port":
|
||||
port = Int32.Parse( value );
|
||||
break;
|
||||
|
||||
case "pooling":
|
||||
if (value.ToLower() == "no" || value.ToLower() == "false")
|
||||
pooling = false;
|
||||
else
|
||||
pooling = true;
|
||||
break;
|
||||
|
||||
case "min pool size":
|
||||
minPoolSize = Int32.Parse(value);
|
||||
break;
|
||||
|
||||
case "max pool size":
|
||||
maxPoolSize = Int32.Parse(value);
|
||||
break;
|
||||
|
||||
case "connection lifetime":
|
||||
connectLifetime = Int32.Parse(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Parse()
|
||||
{
|
||||
String[] keyvalues = connectString.Split( ';' );
|
||||
String[] newkeyvalues = new String[keyvalues.Length];
|
||||
int x = 0;
|
||||
|
||||
// first run through the array and check for any keys that
|
||||
// have ; in their value
|
||||
foreach (String keyvalue in keyvalues)
|
||||
{
|
||||
// check for trailing ; at the end of the connection string
|
||||
if (keyvalue.Length == 0) continue;
|
||||
|
||||
// this value has an '=' sign so we are ok
|
||||
if (keyvalue.IndexOf('=') >= 0)
|
||||
{
|
||||
newkeyvalues[x++] = keyvalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
newkeyvalues[x-1] += ";";
|
||||
newkeyvalues[x-1] += keyvalue;
|
||||
}
|
||||
}
|
||||
|
||||
keyValues.Clear();
|
||||
|
||||
// now we run through our normalized key-values, splitting on equals
|
||||
for (int y=0; y < x; y++)
|
||||
{
|
||||
String[] parts = newkeyvalues[y].Split( '=' );
|
||||
|
||||
// first trim off any space and lowercase the key
|
||||
parts[0] = parts[0].Trim().ToLower();
|
||||
parts[1] = parts[1].Trim();
|
||||
|
||||
// we also want to clear off any quotes
|
||||
parts[0] = parts[0].Trim('\'', '"');
|
||||
parts[1] = parts[1].Trim('\'', '"');
|
||||
|
||||
ConnectionParameterParsed( parts[0], parts[1] );
|
||||
keyValues.Add( parts[0], parts[1] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,59 +1,59 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
using ByteFX.Data.MySqlClient;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for DBParametersEditor.
|
||||
/// </summary>
|
||||
internal class DBParametersEditor : CollectionEditor
|
||||
{
|
||||
public DBParametersEditor(Type t) : base(t)
|
||||
{
|
||||
}
|
||||
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object[] items = base.GetItems(null);
|
||||
|
||||
int i = 1;
|
||||
while (true)
|
||||
{
|
||||
bool found = false;
|
||||
foreach (object obj in items)
|
||||
{
|
||||
MySqlParameter p = (MySqlParameter)obj;
|
||||
if (p.ParameterName.Equals( "parameter" + i ))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! found) break;
|
||||
i ++;
|
||||
}
|
||||
|
||||
MySqlParameter parm = new MySqlParameter("parameter"+i, MySqlDbType.VarChar);
|
||||
return parm;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
using ByteFX.Data.MySqlClient;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for DBParametersEditor.
|
||||
/// </summary>
|
||||
internal class DBParametersEditor : CollectionEditor
|
||||
{
|
||||
public DBParametersEditor(Type t) : base(t)
|
||||
{
|
||||
}
|
||||
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object[] items = base.GetItems(null);
|
||||
|
||||
int i = 1;
|
||||
while (true)
|
||||
{
|
||||
bool found = false;
|
||||
foreach (object obj in items)
|
||||
{
|
||||
MySqlParameter p = (MySqlParameter)obj;
|
||||
if (p.ParameterName.Equals( "parameter" + i ))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! found) break;
|
||||
i ++;
|
||||
}
|
||||
|
||||
MySqlParameter parm = new MySqlParameter("parameter"+i, MySqlDbType.VarChar);
|
||||
return parm;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,51 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlTypes;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Field.
|
||||
/// </summary>
|
||||
internal class Field
|
||||
{
|
||||
/* protected SqlByte byteValue;
|
||||
protected SqlDateTime dateValue;
|
||||
protected SqlString stringValue;
|
||||
protected SqlInt32 int32Value;
|
||||
protected SqlInt64 int64Value;
|
||||
protected SqlDouble doubleValue;
|
||||
protected SqlSingle singleValue;
|
||||
protected SqlMoney moneyValue;
|
||||
protected SqlDecimal decimalValue;
|
||||
protected SqlBinary binaryValue;*/
|
||||
protected object value;
|
||||
|
||||
protected string tableName;
|
||||
protected string colName;
|
||||
protected int colLen;
|
||||
protected string catalogName;
|
||||
protected DbType dbType;
|
||||
protected bool hasValue;
|
||||
|
||||
public Field()
|
||||
{
|
||||
hasValue = false;
|
||||
}
|
||||
|
||||
public string ColumnName
|
||||
{
|
||||
get { return colName; }
|
||||
set { colName = value; }
|
||||
}
|
||||
|
||||
public int ColumnLength
|
||||
{
|
||||
get { return colLen; }
|
||||
set { colLen = value; }
|
||||
}
|
||||
|
||||
public string TableName
|
||||
{
|
||||
get { return tableName; }
|
||||
set { tableName = value; }
|
||||
}
|
||||
|
||||
public string CatalogName
|
||||
{
|
||||
get { return catalogName; }
|
||||
set { catalogName = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlTypes;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Field.
|
||||
/// </summary>
|
||||
internal class Field
|
||||
{
|
||||
/* protected SqlByte byteValue;
|
||||
protected SqlDateTime dateValue;
|
||||
protected SqlString stringValue;
|
||||
protected SqlInt32 int32Value;
|
||||
protected SqlInt64 int64Value;
|
||||
protected SqlDouble doubleValue;
|
||||
protected SqlSingle singleValue;
|
||||
protected SqlMoney moneyValue;
|
||||
protected SqlDecimal decimalValue;
|
||||
protected SqlBinary binaryValue;*/
|
||||
protected object value;
|
||||
|
||||
protected string tableName;
|
||||
protected string colName;
|
||||
protected int colLen;
|
||||
protected DbType dbType;
|
||||
protected bool hasValue;
|
||||
|
||||
public Field()
|
||||
{
|
||||
hasValue = false;
|
||||
}
|
||||
|
||||
public string ColumnName
|
||||
{
|
||||
get { return colName; }
|
||||
}
|
||||
|
||||
public int ColumnLength
|
||||
{
|
||||
get { return colLen; }
|
||||
}
|
||||
|
||||
public string TableName
|
||||
{
|
||||
get { return tableName; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,76 +1,76 @@
|
||||
using System;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for HuffmanTree.
|
||||
/// </summary>
|
||||
public class HuffmanTree
|
||||
{
|
||||
const int MAX_BITS = 15;
|
||||
int[] codes;
|
||||
|
||||
public HuffmanTree(bool lit)
|
||||
{
|
||||
if (lit)
|
||||
BuildLitTree();
|
||||
else
|
||||
BuildLenTree();
|
||||
}
|
||||
|
||||
private void BuildLitTree()
|
||||
{
|
||||
codes = new int[288];
|
||||
|
||||
// fill the code slots with code lengths first
|
||||
for (int x=0; x < 144; x++)
|
||||
codes[x] = 8;
|
||||
for (int x=144; x < 256; x++)
|
||||
codes[x] = 9;
|
||||
for (int x=256; x < 280; x++)
|
||||
codes[x] = 7;
|
||||
for (int x=280; x < 288; x++)
|
||||
codes[x] = 8;
|
||||
|
||||
BuildTreeCommon();
|
||||
}
|
||||
|
||||
|
||||
private void BuildLenTree()
|
||||
{
|
||||
BuildTreeCommon();
|
||||
}
|
||||
|
||||
private void BuildTreeCommon()
|
||||
{
|
||||
int[] codecounts = new int[MAX_BITS];
|
||||
int[] codebase = new int[MAX_BITS];
|
||||
|
||||
for (int i = 0; i < codes.Length; i++)
|
||||
{
|
||||
int bit_len = codes[i];
|
||||
if (bit_len > 0)
|
||||
codecounts[bit_len]++;
|
||||
}
|
||||
|
||||
// now we compute the intial value for each code length
|
||||
int code = 0;
|
||||
codecounts[0] = 0;
|
||||
for (int bits = 1; bits <= MAX_BITS; bits++)
|
||||
{
|
||||
code = (code + codecounts[bits-1]) << 1;
|
||||
codebase[bits] = code;
|
||||
}
|
||||
|
||||
// next we assign numerical values to each code
|
||||
for (int x=0; x <= codes.Length; x++)
|
||||
{
|
||||
if (codes[x] == 0) continue;
|
||||
int blen = codes[x];
|
||||
codes[x] = codebase[ blen ];
|
||||
codebase[ blen ] ++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for HuffmanTree.
|
||||
/// </summary>
|
||||
public class HuffmanTree
|
||||
{
|
||||
const int MAX_BITS = 15;
|
||||
int[] codes;
|
||||
|
||||
public HuffmanTree(bool lit)
|
||||
{
|
||||
if (lit)
|
||||
BuildLitTree();
|
||||
else
|
||||
BuildLenTree();
|
||||
}
|
||||
|
||||
private void BuildLitTree()
|
||||
{
|
||||
codes = new int[288];
|
||||
|
||||
// fill the code slots with code lengths first
|
||||
for (int x=0; x < 144; x++)
|
||||
codes[x] = 8;
|
||||
for (int x=144; x < 256; x++)
|
||||
codes[x] = 9;
|
||||
for (int x=256; x < 280; x++)
|
||||
codes[x] = 7;
|
||||
for (int x=280; x < 288; x++)
|
||||
codes[x] = 8;
|
||||
|
||||
BuildTreeCommon();
|
||||
}
|
||||
|
||||
|
||||
private void BuildLenTree()
|
||||
{
|
||||
BuildTreeCommon();
|
||||
}
|
||||
|
||||
private void BuildTreeCommon()
|
||||
{
|
||||
int[] codecounts = new int[MAX_BITS];
|
||||
int[] codebase = new int[MAX_BITS];
|
||||
|
||||
for (int i = 0; i < codes.Length; i++)
|
||||
{
|
||||
int bit_len = codes[i];
|
||||
if (bit_len > 0)
|
||||
codecounts[bit_len]++;
|
||||
}
|
||||
|
||||
// now we compute the intial value for each code length
|
||||
int code = 0;
|
||||
codecounts[0] = 0;
|
||||
for (int bits = 1; bits <= MAX_BITS; bits++)
|
||||
{
|
||||
code = (code + codecounts[bits-1]) << 1;
|
||||
codebase[bits] = code;
|
||||
}
|
||||
|
||||
// next we assign numerical values to each code
|
||||
for (int x=0; x <= codes.Length; x++)
|
||||
{
|
||||
if (codes[x] == 0) continue;
|
||||
int blen = codes[x];
|
||||
codes[x] = codebase[ blen ];
|
||||
codebase[ blen ] ++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,37 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Inflater.
|
||||
/// </summary>
|
||||
public class Inflater
|
||||
{
|
||||
private BitStream _input;
|
||||
|
||||
public Inflater()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetInput(byte[] input, int offset, int len)
|
||||
{
|
||||
_input = new BitStream(input, offset, len);
|
||||
}
|
||||
|
||||
public void Inflate(byte[] output, int offset, int size)
|
||||
{
|
||||
byte cmf = (byte)_input.GetBits(8);
|
||||
byte flag = (byte)_input.GetBits(8);
|
||||
|
||||
if ((cmf & 0x0f) != 8)
|
||||
throw new Exception("Only deflate format data is supported");
|
||||
|
||||
if (((cmf*256+flag) % 31) != 0)
|
||||
throw new Exception("Data is not in proper deflate format");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Inflater.
|
||||
/// </summary>
|
||||
public class Inflater
|
||||
{
|
||||
private BitStream _input;
|
||||
|
||||
public Inflater()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetInput(byte[] input, int offset, int len)
|
||||
{
|
||||
_input = new BitStream(input, offset, len);
|
||||
}
|
||||
|
||||
public void Inflate(byte[] output, int offset, int size)
|
||||
{
|
||||
byte cmf = (byte)_input.GetBits(8);
|
||||
byte flag = (byte)_input.GetBits(8);
|
||||
|
||||
if ((cmf & 0x0f) != 8)
|
||||
throw new Exception("Only deflate format data is supported");
|
||||
|
||||
if (((cmf*256+flag) % 31) != 0)
|
||||
throw new Exception("Data is not in proper deflate format");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,212 +1,194 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
internal enum MultiHostStreamErrorType
|
||||
{
|
||||
Connecting,
|
||||
Reading,
|
||||
Writing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for MultiHostStream.
|
||||
/// </summary>
|
||||
internal abstract class MultiHostStream : Stream
|
||||
{
|
||||
protected Stream stream;
|
||||
protected int readTimeOut;
|
||||
protected Exception baseException;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new MultiHostStream object with the given parameters
|
||||
/// </summary>
|
||||
/// <param name="hostList"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="readTimeOut"></param>
|
||||
/// <param name="connectTimeOut"></param>
|
||||
public MultiHostStream(string hostList, int port, int readTimeOut, int connectTimeOut)
|
||||
{
|
||||
this.readTimeOut = readTimeOut;
|
||||
ProcessHosts( hostList, port, connectTimeOut );
|
||||
}
|
||||
|
||||
// abstract members
|
||||
protected abstract void TimeOut(MultiHostStreamErrorType error);
|
||||
protected abstract void Error(string msg);
|
||||
protected abstract bool CreateStream( IPAddress ip, string host, int port );
|
||||
protected abstract bool CreateStream (string fileName);
|
||||
protected abstract bool DataAvailable
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
private void ProcessHosts( string hostList, int port, int connectTimeOut )
|
||||
{
|
||||
int startTime = Environment.TickCount;
|
||||
|
||||
int toTicks = connectTimeOut * 1000;
|
||||
|
||||
// support Unix sockets
|
||||
if (hostList.StartsWith ("/"))
|
||||
{
|
||||
CreateStream (hostList);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Host name can contain multiple hosts, seperated by &.
|
||||
string [] dnsHosts = hostList.Split('&');
|
||||
Hashtable ips = new Hashtable();
|
||||
|
||||
//
|
||||
// Each host name specified may contain multiple IP addresses
|
||||
// Lets look at the DNS entries for each host name
|
||||
foreach(string h in dnsHosts)
|
||||
{
|
||||
IPHostEntry hostAddress = Dns.GetHostByName(h);
|
||||
foreach (IPAddress addr in hostAddress.AddressList)
|
||||
ips.Add( addr, hostAddress.HostName );
|
||||
}
|
||||
IPAddress[] keys = new IPAddress[ ips.Count ];
|
||||
ips.Keys.CopyTo( keys, 0 );
|
||||
|
||||
if ((Environment.TickCount - startTime) > toTicks)
|
||||
{
|
||||
TimeOut(MultiHostStreamErrorType.Connecting);
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure they gave us at least one host
|
||||
if (ips.Count == 0)
|
||||
{
|
||||
Error("You must specify at least one host");
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
// now choose a random server if there are more than one
|
||||
if (ips.Count > 1)
|
||||
{
|
||||
System.Random random = new Random((int)DateTime.Now.Ticks);
|
||||
index = random.Next(ips.Count-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Lets step through our hosts until we get a connection
|
||||
for (int i=0; i < ips.Count; i++)
|
||||
{
|
||||
if ((Environment.TickCount - startTime) > toTicks)
|
||||
{
|
||||
TimeOut(MultiHostStreamErrorType.Connecting);
|
||||
return;
|
||||
}
|
||||
if (CreateStream( (IPAddress)keys[i], (string)ips[keys[i]], port ))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
int start = Environment.TickCount;
|
||||
int ticks = readTimeOut * 1000;
|
||||
|
||||
while ((Environment.TickCount - start) < ticks)
|
||||
{
|
||||
if (DataAvailable)
|
||||
{
|
||||
int b = stream.ReadByte();
|
||||
return b;
|
||||
}
|
||||
else
|
||||
Thread.Sleep(0);
|
||||
}
|
||||
|
||||
TimeOut(MultiHostStreamErrorType.Reading);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
int numToRead = count;
|
||||
int start = Environment.TickCount;
|
||||
int ticks = readTimeOut * 1000;
|
||||
|
||||
try
|
||||
{
|
||||
while (numToRead > 0 && (Environment.TickCount - start) < ticks)
|
||||
{
|
||||
if (DataAvailable)
|
||||
{
|
||||
int bytes_read = stream.Read( buffer, offset, numToRead);
|
||||
if (bytes_read == 0)
|
||||
return (count - numToRead);
|
||||
offset += bytes_read;
|
||||
numToRead -= bytes_read;
|
||||
}
|
||||
else
|
||||
Thread.Sleep(0);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
if (numToRead > 0)
|
||||
TimeOut(MultiHostStreamErrorType.Reading);
|
||||
return count;
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return stream.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return stream.CanWrite; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return stream.CanSeek; }
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { return stream.Length; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return stream.Position; }
|
||||
set { stream.Position = value; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
stream.Flush();
|
||||
}
|
||||
|
||||
public override void SetLength(long length)
|
||||
{
|
||||
stream.SetLength( length );
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
stream.Write( buffer, offset, count );
|
||||
}
|
||||
|
||||
public override long Seek( long offset, SeekOrigin origin )
|
||||
{
|
||||
return stream.Seek( offset, origin );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
internal enum MultiHostStreamErrorType
|
||||
{
|
||||
Connecting,
|
||||
Reading,
|
||||
Writing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for MultiHostStream.
|
||||
/// </summary>
|
||||
internal abstract class MultiHostStream : Stream
|
||||
{
|
||||
protected Stream stream;
|
||||
protected int readTimeOut;
|
||||
protected Exception baseException;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new MultiHostStream object with the given parameters
|
||||
/// </summary>
|
||||
/// <param name="hostList"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="readTimeOut"></param>
|
||||
/// <param name="connectTimeOut"></param>
|
||||
public MultiHostStream(string hostList, int port, int readTimeOut, int connectTimeOut)
|
||||
{
|
||||
this.readTimeOut = readTimeOut;
|
||||
ProcessHosts( hostList, port, connectTimeOut );
|
||||
}
|
||||
|
||||
protected abstract void TimeOut(MultiHostStreamErrorType error);
|
||||
protected abstract void Error(string msg);
|
||||
protected abstract bool CreateStream( IPAddress ip, string host, int port );
|
||||
protected abstract bool DataAvailable
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
private void ProcessHosts( string hostList, int port, int connectTimeOut )
|
||||
{
|
||||
int startTime = Environment.TickCount;
|
||||
|
||||
int toTicks = connectTimeOut * 1000;
|
||||
//
|
||||
// Host name can contain multiple hosts, seperated by &.
|
||||
string [] dnsHosts = hostList.Split('&');
|
||||
Hashtable ips = new Hashtable();
|
||||
|
||||
//
|
||||
// Each host name specified may contain multiple IP addresses
|
||||
// Lets look at the DNS entries for each host name
|
||||
foreach(string h in dnsHosts)
|
||||
{
|
||||
IPHostEntry hostAddress = Dns.GetHostByName(h);
|
||||
foreach (IPAddress addr in hostAddress.AddressList)
|
||||
ips.Add( addr, hostAddress.HostName );
|
||||
}
|
||||
IPAddress[] keys = new IPAddress[ ips.Count ];
|
||||
ips.Keys.CopyTo( keys, 0 );
|
||||
|
||||
if ((Environment.TickCount - startTime) > toTicks)
|
||||
{
|
||||
TimeOut(MultiHostStreamErrorType.Connecting);
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure they gave us at least one host
|
||||
if (ips.Count == 0)
|
||||
{
|
||||
Error("You must specify at least one host");
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
// now choose a random server if there are more than one
|
||||
if (ips.Count > 1)
|
||||
{
|
||||
System.Random random = new Random((int)DateTime.Now.Ticks);
|
||||
index = random.Next(ips.Count-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Lets step through our hosts until we get a connection
|
||||
for (int i=0; i < ips.Count; i++)
|
||||
{
|
||||
if ((Environment.TickCount - startTime) > toTicks)
|
||||
{
|
||||
TimeOut(MultiHostStreamErrorType.Connecting);
|
||||
return;
|
||||
}
|
||||
if (CreateStream( (IPAddress)keys[i], (string)ips[keys[i]], port ))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
int start = Environment.TickCount;
|
||||
int ticks = readTimeOut * 1000;
|
||||
|
||||
while ((Environment.TickCount - start) < ticks)
|
||||
{
|
||||
if (DataAvailable)
|
||||
{
|
||||
int b = stream.ReadByte();
|
||||
return b;
|
||||
}
|
||||
else
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
TimeOut(MultiHostStreamErrorType.Reading);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
int numToRead = count;
|
||||
int start = Environment.TickCount;
|
||||
int ticks = readTimeOut * 1000;
|
||||
|
||||
while (numToRead > 0 && (Environment.TickCount - start) < ticks)
|
||||
{
|
||||
if (DataAvailable)
|
||||
{
|
||||
int bytes_read = stream.Read( buffer, offset, numToRead);
|
||||
if (bytes_read == 0)
|
||||
return (count - numToRead);
|
||||
offset += bytes_read;
|
||||
numToRead -= bytes_read;
|
||||
}
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
if (numToRead > 0)
|
||||
TimeOut(MultiHostStreamErrorType.Reading);
|
||||
return count;
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return stream.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return stream.CanWrite; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return stream.CanSeek; }
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { return stream.Length; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return stream.Position; }
|
||||
set { stream.Position = value; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
stream.Flush();
|
||||
}
|
||||
|
||||
public override void SetLength(long length)
|
||||
{
|
||||
stream.SetLength( length );
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
stream.Write( buffer, offset, count );
|
||||
}
|
||||
|
||||
public override long Seek( long offset, SeekOrigin origin )
|
||||
{
|
||||
return stream.Seek( offset, origin );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,208 +1,208 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for API.
|
||||
/// </summary>
|
||||
internal class NamedPipeStream : Stream
|
||||
{
|
||||
[DllImport("kernel32.dll", EntryPoint="CreateFile", SetLastError=true)]
|
||||
private static extern IntPtr CreateFile(String lpFileName,
|
||||
UInt32 dwDesiredAccess, UInt32 dwShareMode,
|
||||
IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition,
|
||||
UInt32 dwFlagsAndAttributes,
|
||||
IntPtr hTemplateFile);
|
||||
[DllImport("kernel32.dll", EntryPoint="PeekNamedPipe", SetLastError=true)]
|
||||
private static extern bool PeekNamedPipe( IntPtr handle,
|
||||
byte[] buffer, uint nBufferSize, ref uint bytesRead,
|
||||
ref uint bytesAvail, ref uint BytesLeftThisMessage);
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool ReadFile( IntPtr handle,
|
||||
byte[] buffer, uint toRead, ref uint read, IntPtr lpOverLapped);
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool WriteFile( IntPtr handle,
|
||||
byte[] buffer, uint count, ref uint written, IntPtr lpOverlapped );
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool CloseHandle( IntPtr handle );
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool FlushFileBuffers( IntPtr handle );
|
||||
|
||||
//Constants for dwDesiredAccess:
|
||||
private const UInt32 GENERIC_READ = 0x80000000;
|
||||
private const UInt32 GENERIC_WRITE = 0x40000000;
|
||||
|
||||
//Constants for return value:
|
||||
private const Int32 INVALID_HANDLE_VALUE = -1;
|
||||
|
||||
//Constants for dwFlagsAndAttributes:
|
||||
private const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000;
|
||||
private const UInt32 FILE_FLAG_NO_BUFFERING = 0x20000000;
|
||||
|
||||
//Constants for dwCreationDisposition:
|
||||
private const UInt32 OPEN_EXISTING = 3;
|
||||
|
||||
IntPtr _handle;
|
||||
FileAccess _mode;
|
||||
|
||||
public NamedPipeStream(string host, FileAccess mode)
|
||||
{
|
||||
_handle = IntPtr.Zero;
|
||||
Open(host, mode);
|
||||
}
|
||||
|
||||
public void Open( string host, FileAccess mode )
|
||||
{
|
||||
_mode = mode;
|
||||
uint pipemode = 0;
|
||||
|
||||
if ((mode & FileAccess.Read) > 0)
|
||||
pipemode |= GENERIC_READ;
|
||||
if ((mode & FileAccess.Write) > 0)
|
||||
pipemode |= GENERIC_WRITE;
|
||||
_handle = CreateFile( host, pipemode,
|
||||
0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero );
|
||||
}
|
||||
|
||||
public bool DataAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
uint bytesRead=0, avail=0, thismsg=0;
|
||||
|
||||
bool result = PeekNamedPipe( _handle,
|
||||
null, 0, ref bytesRead, ref avail, ref thismsg );
|
||||
return (result == true && avail > 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return (_mode & FileAccess.Read) > 0; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return (_mode & FileAccess.Write) > 0; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
|
||||
set { }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
if (_handle == IntPtr.Zero)
|
||||
throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
|
||||
FlushFileBuffers(_handle);
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer", "The buffer to read into cannot be null");
|
||||
if (buffer.Length < (offset + count))
|
||||
throw new ArgumentException("Buffer is not large enough to hold requested data", "buffer");
|
||||
if (offset < 0)
|
||||
throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");
|
||||
if (! CanRead)
|
||||
throw new NotSupportedException("The stream does not support reading");
|
||||
if (_handle == IntPtr.Zero)
|
||||
throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
|
||||
|
||||
// first read the data into an internal buffer since ReadFile cannot read into a buf at
|
||||
// a specified offset
|
||||
uint read=0;
|
||||
byte[] buf = new Byte[count];
|
||||
ReadFile( _handle, buf, (uint)count, ref read, IntPtr.Zero );
|
||||
|
||||
for (int x=0; x < read; x++)
|
||||
{
|
||||
buffer[offset+x] = buf[x];
|
||||
}
|
||||
return (int)read;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
CloseHandle(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
}
|
||||
|
||||
public override void SetLength(long length)
|
||||
{
|
||||
throw new NotSupportedException("NamedPipeStream doesn't support SetLength");
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer", "The buffer to write into cannot be null");
|
||||
if (buffer.Length < (offset + count))
|
||||
throw new ArgumentException("Buffer does not contain amount of requested data", "buffer");
|
||||
if (offset < 0)
|
||||
throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");
|
||||
if (! CanWrite)
|
||||
throw new NotSupportedException("The stream does not support writing");
|
||||
if (_handle == IntPtr.Zero)
|
||||
throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
|
||||
|
||||
// copy data to internal buffer to allow writing from a specified offset
|
||||
byte[] buf = new Byte[count];
|
||||
for (int x=0; x < count; x++)
|
||||
{
|
||||
buf[x] = buffer[offset+x];
|
||||
}
|
||||
uint written=0;
|
||||
bool result = WriteFile( _handle, buf, (uint)count, ref written, IntPtr.Zero );
|
||||
|
||||
if (! result)
|
||||
throw new IOException("Writing to the stream failed");
|
||||
if (written < count)
|
||||
throw new IOException("Unable to write entire buffer to stream");
|
||||
}
|
||||
|
||||
public override long Seek( long offset, SeekOrigin origin )
|
||||
{
|
||||
throw new NotSupportedException("NamedPipeStream doesn't support seeking");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for API.
|
||||
/// </summary>
|
||||
internal class NamedPipeStream : Stream
|
||||
{
|
||||
[DllImport("kernel32.dll", EntryPoint="CreateFile", SetLastError=true)]
|
||||
private static extern IntPtr CreateFile(String lpFileName,
|
||||
UInt32 dwDesiredAccess, UInt32 dwShareMode,
|
||||
IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition,
|
||||
UInt32 dwFlagsAndAttributes,
|
||||
IntPtr hTemplateFile);
|
||||
[DllImport("kernel32.dll", EntryPoint="PeekNamedPipe", SetLastError=true)]
|
||||
private static extern bool PeekNamedPipe( IntPtr handle,
|
||||
byte[] buffer, uint nBufferSize, ref uint bytesRead,
|
||||
ref uint bytesAvail, ref uint BytesLeftThisMessage);
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool ReadFile( IntPtr handle,
|
||||
byte[] buffer, uint toRead, ref uint read, IntPtr lpOverLapped);
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool WriteFile( IntPtr handle,
|
||||
byte[] buffer, uint count, ref uint written, IntPtr lpOverlapped );
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool CloseHandle( IntPtr handle );
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool FlushFileBuffers( IntPtr handle );
|
||||
|
||||
//Constants for dwDesiredAccess:
|
||||
private const UInt32 GENERIC_READ = 0x80000000;
|
||||
private const UInt32 GENERIC_WRITE = 0x40000000;
|
||||
|
||||
//Constants for return value:
|
||||
private const Int32 INVALID_HANDLE_VALUE = -1;
|
||||
|
||||
//Constants for dwFlagsAndAttributes:
|
||||
private const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000;
|
||||
private const UInt32 FILE_FLAG_NO_BUFFERING = 0x20000000;
|
||||
|
||||
//Constants for dwCreationDisposition:
|
||||
private const UInt32 OPEN_EXISTING = 3;
|
||||
|
||||
IntPtr _handle;
|
||||
FileAccess _mode;
|
||||
|
||||
public NamedPipeStream(string host, FileAccess mode)
|
||||
{
|
||||
_handle = IntPtr.Zero;
|
||||
Open(host, mode);
|
||||
}
|
||||
|
||||
public void Open( string host, FileAccess mode )
|
||||
{
|
||||
_mode = mode;
|
||||
uint pipemode = 0;
|
||||
|
||||
if ((mode & FileAccess.Read) > 0)
|
||||
pipemode |= GENERIC_READ;
|
||||
if ((mode & FileAccess.Write) > 0)
|
||||
pipemode |= GENERIC_WRITE;
|
||||
_handle = CreateFile( host, pipemode,
|
||||
0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero );
|
||||
}
|
||||
|
||||
public bool DataAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
uint bytesRead=0, avail=0, thismsg=0;
|
||||
|
||||
bool result = PeekNamedPipe( _handle,
|
||||
null, 0, ref bytesRead, ref avail, ref thismsg );
|
||||
return (result == true && avail > 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return (_mode & FileAccess.Read) > 0; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return (_mode & FileAccess.Write) > 0; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
|
||||
set { }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
if (_handle == IntPtr.Zero)
|
||||
throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
|
||||
FlushFileBuffers(_handle);
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer", "The buffer to read into cannot be null");
|
||||
if (buffer.Length < (offset + count))
|
||||
throw new ArgumentException("Buffer is not large enough to hold requested data", "buffer");
|
||||
if (offset < 0)
|
||||
throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");
|
||||
if (! CanRead)
|
||||
throw new NotSupportedException("The stream does not support reading");
|
||||
if (_handle == IntPtr.Zero)
|
||||
throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
|
||||
|
||||
// first read the data into an internal buffer since ReadFile cannot read into a buf at
|
||||
// a specified offset
|
||||
uint read=0;
|
||||
byte[] buf = new Byte[count];
|
||||
ReadFile( _handle, buf, (uint)count, ref read, IntPtr.Zero );
|
||||
|
||||
for (int x=0; x < read; x++)
|
||||
{
|
||||
buffer[offset+x] = buf[x];
|
||||
}
|
||||
return (int)read;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
CloseHandle(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
}
|
||||
|
||||
public override void SetLength(long length)
|
||||
{
|
||||
throw new NotSupportedException("NamedPipeStream doesn't support SetLength");
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer", "The buffer to write into cannot be null");
|
||||
if (buffer.Length < (offset + count))
|
||||
throw new ArgumentException("Buffer does not contain amount of requested data", "buffer");
|
||||
if (offset < 0)
|
||||
throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");
|
||||
if (! CanWrite)
|
||||
throw new NotSupportedException("The stream does not support writing");
|
||||
if (_handle == IntPtr.Zero)
|
||||
throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
|
||||
|
||||
// copy data to internal buffer to allow writing from a specified offset
|
||||
byte[] buf = new Byte[count];
|
||||
for (int x=0; x < count; x++)
|
||||
{
|
||||
buf[x] = buffer[offset+x];
|
||||
}
|
||||
uint written=0;
|
||||
bool result = WriteFile( _handle, buf, (uint)count, ref written, IntPtr.Zero );
|
||||
|
||||
if (! result)
|
||||
throw new IOException("Writing to the stream failed");
|
||||
if (written < count)
|
||||
throw new IOException("Unable to write entire buffer to stream");
|
||||
}
|
||||
|
||||
public override long Seek( long offset, SeekOrigin origin )
|
||||
{
|
||||
throw new NotSupportedException("NamedPipeStream doesn't support seeking");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2004 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Platform.
|
||||
/// </summary>
|
||||
internal class Platform
|
||||
{
|
||||
public static bool IsWindows()
|
||||
{
|
||||
OperatingSystem os = Environment.OSVersion;
|
||||
switch (os.Platform)
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
case PlatformID.Win32S:
|
||||
case PlatformID.Win32Windows:
|
||||
case PlatformID.WinCE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Security.
|
||||
/// </summary>
|
||||
internal class Security
|
||||
{
|
||||
public Security()
|
||||
{
|
||||
}
|
||||
|
||||
public static void ArrayCrypt( byte[] src, int srcoff, byte[] dst, int dstoff, byte[] key, int length )
|
||||
{
|
||||
int idx = 0;
|
||||
|
||||
while ( (idx+srcoff) < src.Length && idx < length )
|
||||
{
|
||||
dst[idx+dstoff] = (byte)(src[idx+srcoff] ^ key[idx]);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Security.
|
||||
/// </summary>
|
||||
internal class Security
|
||||
{
|
||||
public Security()
|
||||
{
|
||||
}
|
||||
|
||||
public static void ArrayCrypt( byte[] src, int srcoff, byte[] dst, int dstoff, byte[] key, int length )
|
||||
{
|
||||
int idx = 0;
|
||||
|
||||
while ( (idx+srcoff) < src.Length && idx < length )
|
||||
{
|
||||
dst[idx+dstoff] = (byte)(src[idx+srcoff] ^ key[idx]);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2004 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Collections;
|
||||
#if __MonoCS__
|
||||
using Mono.Posix;
|
||||
#endif
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for StreamCreator.
|
||||
/// </summary>
|
||||
internal class StreamCreator
|
||||
{
|
||||
string hostList;
|
||||
int port;
|
||||
string pipeName;
|
||||
int timeOut;
|
||||
|
||||
public StreamCreator( string hosts, int port, string pipeName)
|
||||
{
|
||||
hostList = hosts;
|
||||
this.port = port;
|
||||
this.pipeName = pipeName;
|
||||
}
|
||||
|
||||
public Stream GetStream(int timeOut)
|
||||
{
|
||||
this.timeOut = timeOut;
|
||||
|
||||
if (hostList.StartsWith("/"))
|
||||
return CreateUnixSocketStream();
|
||||
|
||||
string [] dnsHosts = hostList.Split('&');
|
||||
ArrayList ipAddresses = new ArrayList();
|
||||
ArrayList hostNames = new ArrayList();
|
||||
|
||||
//
|
||||
// Each host name specified may contain multiple IP addresses
|
||||
// Lets look at the DNS entries for each host name
|
||||
foreach (string h in dnsHosts)
|
||||
{
|
||||
IPHostEntry hostAddress = Dns.GetHostByName(h);
|
||||
foreach (IPAddress addr in hostAddress.AddressList)
|
||||
{
|
||||
ipAddresses.Add( addr );
|
||||
hostNames.Add( hostAddress.HostName );
|
||||
}
|
||||
}
|
||||
|
||||
System.Random random = new Random((int)DateTime.Now.Ticks);
|
||||
int index = random.Next(ipAddresses.Count-1);
|
||||
|
||||
bool usePipe = pipeName != String.Empty;
|
||||
Stream stream = null;
|
||||
for (int i=0; i < ipAddresses.Count; i++)
|
||||
{
|
||||
if (usePipe)
|
||||
stream = CreateNamedPipeStream( (string)hostNames[index] );
|
||||
else
|
||||
stream = CreateSocketStream( (IPAddress)ipAddresses[index], port );
|
||||
if (stream != null) return stream;
|
||||
|
||||
index++;
|
||||
if (index == ipAddresses.Count) index = 0;
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
private Stream CreateUnixSocketStream()
|
||||
{
|
||||
#if __MonoCS__ && !WINDOWS
|
||||
|
||||
Socket socket = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);
|
||||
|
||||
try
|
||||
{
|
||||
UnixEndPoint endPoint = new UnixEndPoint (hostList);
|
||||
socket.Connect (endPoint);
|
||||
return new NetworkStream (socket, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
#else
|
||||
throw new PlatformNotSupportedException ("Unix sockets are only supported on this platform");
|
||||
#endif
|
||||
}
|
||||
|
||||
private Stream CreateNamedPipeStream( string hostname )
|
||||
{
|
||||
string pipePath;
|
||||
if (hostname.ToLower().Equals("localhost"))
|
||||
pipePath = @"\\.\pipe\" + pipeName;
|
||||
else
|
||||
pipePath = String.Format(@"\\{0}\pipe\{1}", hostname.ToString(), pipeName);
|
||||
return new NamedPipeStream(pipePath, FileAccess.ReadWrite);
|
||||
}
|
||||
|
||||
private void ConnectSocketCallback( IAsyncResult iar )
|
||||
{
|
||||
}
|
||||
|
||||
private Stream CreateSocketStream( IPAddress ip, int port )
|
||||
{
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork,
|
||||
SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
try
|
||||
{
|
||||
//
|
||||
// Lets try to connect
|
||||
IPEndPoint endPoint = new IPEndPoint( ip, port);
|
||||
// IAsyncResult iar = socket.BeginConnect( endPoint,
|
||||
// new AsyncCallback(ConnectSocketCallback), socket );
|
||||
|
||||
socket.Connect(endPoint);
|
||||
socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 );
|
||||
return new NetworkStream( socket, true );
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for StringUtility.
|
||||
/// </summary>
|
||||
public class StringUtility
|
||||
{
|
||||
public StringUtility()
|
||||
{
|
||||
}
|
||||
|
||||
public static string[] Split( string src, char delimiter, params char[] quotedelims )
|
||||
{
|
||||
ArrayList strings = new ArrayList();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ArrayList ar = new ArrayList(quotedelims);
|
||||
char quote_open = Char.MinValue;
|
||||
|
||||
foreach (char c in src)
|
||||
{
|
||||
if (c == delimiter && quote_open == Char.MinValue)
|
||||
{
|
||||
strings.Add( sb.ToString() );
|
||||
sb.Remove( 0, sb.Length );
|
||||
}
|
||||
|
||||
else if (ar.Contains(c))
|
||||
{
|
||||
if (quote_open == Char.MinValue)
|
||||
quote_open = c;
|
||||
else if (quote_open == c)
|
||||
quote_open = Char.MinValue;
|
||||
sb.Append(c);
|
||||
}
|
||||
else
|
||||
sb.Append( c );
|
||||
}
|
||||
|
||||
if (sb.Length > 0)
|
||||
strings.Add( sb.ToString());
|
||||
|
||||
return (string[])strings.ToArray(typeof(string));
|
||||
}
|
||||
}
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for StringUtility.
|
||||
/// </summary>
|
||||
public class StringUtility
|
||||
{
|
||||
public StringUtility()
|
||||
{
|
||||
}
|
||||
|
||||
public static string[] Split( string src, char delimiter, params char[] quotedelims )
|
||||
{
|
||||
ArrayList strings = new ArrayList();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ArrayList ar = new ArrayList(quotedelims);
|
||||
char quote_open = Char.MinValue;
|
||||
|
||||
foreach (char c in src)
|
||||
{
|
||||
if (c == delimiter && quote_open == Char.MinValue)
|
||||
{
|
||||
strings.Add( sb.ToString() );
|
||||
sb.Remove( 0, sb.Length );
|
||||
}
|
||||
|
||||
else if (ar.Contains(c))
|
||||
{
|
||||
if (quote_open == Char.MinValue)
|
||||
quote_open = c;
|
||||
else if (quote_open == c)
|
||||
quote_open = Char.MinValue;
|
||||
sb.Append(c);
|
||||
}
|
||||
else
|
||||
sb.Append( c );
|
||||
}
|
||||
|
||||
if (sb.Length > 0)
|
||||
strings.Add( sb.ToString());
|
||||
|
||||
return (string[])strings.ToArray(typeof(string));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +1,51 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2004 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Version.
|
||||
/// </summary>
|
||||
internal struct DBVersion
|
||||
{
|
||||
private int major;
|
||||
private int minor;
|
||||
private int build;
|
||||
|
||||
public DBVersion( int major, int minor, int build)
|
||||
{
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
public static DBVersion Parse( string versionString )
|
||||
{
|
||||
int start = 0;
|
||||
int index = versionString.IndexOf('.', start);
|
||||
if (index == -1) throw new Exception("Version string not in acceptable format");
|
||||
int major = Convert.ToInt32( versionString.Substring(start, index-start).Trim());
|
||||
|
||||
start = index+1;
|
||||
index = versionString.IndexOf('.', start);
|
||||
if (index == -1) throw new Exception("Version string not in acceptable format");
|
||||
int minor = Convert.ToInt32( versionString.Substring(start, index-start).Trim());
|
||||
|
||||
start = index+1;
|
||||
int i = start;
|
||||
while (i < versionString.Length && Char.IsDigit( versionString, i ))
|
||||
i++;
|
||||
int build = Convert.ToInt32( versionString.Substring(start, i-start).Trim());
|
||||
|
||||
return new DBVersion( major, minor, build );
|
||||
}
|
||||
|
||||
public bool isAtLeast(int major, int minor, int build)
|
||||
{
|
||||
if (this.major > major) return true;
|
||||
if (this.major == major && this.minor > minor) return true;
|
||||
if (this.major == major && this.minor == minor && this.build >= build) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
|
||||
namespace ByteFX.Data.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Version.
|
||||
/// </summary>
|
||||
internal struct Version
|
||||
{
|
||||
private int major;
|
||||
private int minor;
|
||||
private int build;
|
||||
|
||||
public Version( int major, int minor, int build)
|
||||
{
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
public static Version Parse( string versionString )
|
||||
{
|
||||
int start = 0;
|
||||
int index = versionString.IndexOf('.', start);
|
||||
if (index == -1) throw new Exception("Version string not in acceptable format");
|
||||
int major = Convert.ToInt32( versionString.Substring(start, index-start).Trim());
|
||||
|
||||
start = index+1;
|
||||
index = versionString.IndexOf('.', start);
|
||||
if (index == -1) throw new Exception("Version string not in acceptable format");
|
||||
int minor = Convert.ToInt32( versionString.Substring(start, index-start).Trim());
|
||||
|
||||
start = index+1;
|
||||
int i = start;
|
||||
while (i < versionString.Length && Char.IsDigit( versionString, i ))
|
||||
i++;
|
||||
int build = Convert.ToInt32( versionString.Substring(start, i-start).Trim());
|
||||
|
||||
return new Version( major, minor, build );
|
||||
}
|
||||
|
||||
public bool isAtLeast(int major, int minor, int build)
|
||||
{
|
||||
if (major > this.major) return false;
|
||||
if (minor > this.minor) return false;
|
||||
if (build > this.build) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ LIBRARY = ByteFX.Data.dll
|
||||
LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:System.Xml.dll \
|
||||
/r:System.Data.dll /r:ICSharpCode.SharpZipLib.dll \
|
||||
/r:System.Design.dll /r:System.Drawing.dll /r:System.Windows.Forms.dll \
|
||||
/r:Mono.Posix.dll \
|
||||
/res:mysqlclient/Designers/command.bmp \
|
||||
/res:mysqlclient/Designers/connection.bmp \
|
||||
/res:mysqlclient/Designers/dataadapter.bmp
|
||||
|
||||
@@ -1,339 +0,0 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{5EAEFBC4-8389-4120-BAB3-9B27174F6F6F}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "ByteFX.MySqlClient"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "Library"
|
||||
PreBuildEvent = ""
|
||||
PostBuildEvent = ""
|
||||
RootNamespace = "ByteFX.Data.MySqlClient"
|
||||
RunPostBuildEvent = "OnBuildSuccess"
|
||||
StartupObject = ""
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "DEBUG;TRACE;WINDOWS"
|
||||
DocumentationFile = "doc.xml"
|
||||
DebugSymbols = "true"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "true"
|
||||
NoStdLib = "false"
|
||||
NoWarn = "1591"
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\Debug\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "TRACE;WINDOWS"
|
||||
DocumentationFile = "doc.xml"
|
||||
DebugSymbols = "false"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = "1591"
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\Release\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Design"
|
||||
AssemblyName = "System.Design"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Design.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Drawing"
|
||||
AssemblyName = "System.Drawing"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Windows.Forms"
|
||||
AssemblyName = "System.Windows.Forms"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "ICSharpCode.SharpZipLib"
|
||||
AssemblyName = "ICSharpCode.SharpZipLib"
|
||||
HintPath = "ICSharpCode.SharpZipLib.dll"
|
||||
/>
|
||||
</References>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "ChangeLog.txt"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "internals.html"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common\DBConnectionString.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common\DBParametersEditor.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common\Field.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common\NamedPipeStream.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common\Platform.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common\Security.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common\StreamCreator.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common\Version.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\CharSetMap.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\command.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\command.resx"
|
||||
DependentUpon = "command.cs"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\CommandBuilder.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\CommandResult.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\CompressedStream.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\Connection.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\Connection.resx"
|
||||
DependentUpon = "Connection.cs"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\ConnectionInternal.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\ConnectionString.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\dataadapter.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\datareader.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\Driver.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\Exception.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\Field.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\MysqlDefs.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\MySqlError.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\MySqlHelper.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\MySqlPool.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\MySqlPoolManager.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\Packet.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\parameter.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\parameter_collection.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\todo.txt"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\transaction.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlCommand.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlCommandBuilder.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlConnection.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlDataAdapter.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlDataReader.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlException.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlHelper.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlParameter.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlParameterCollection.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\docs\MySqlTransaction.xml"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\resources\command.bmp"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\resources\connection.bmp"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "MySqlClient\resources\dataadapter.bmp"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
+504
-504
File diff suppressed because it is too large.
Load diff
@@ -1,88 +1,88 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for CharSetMap.
|
||||
/// </summary>
|
||||
internal class CharSetMap
|
||||
{
|
||||
private static Hashtable mapping;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="MySqlCharSetName"></param>
|
||||
/// <returns></returns>
|
||||
public static Encoding GetEncoding( string MySqlCharSetName )
|
||||
{
|
||||
if (mapping == null )
|
||||
InitializeMapping();
|
||||
try
|
||||
{
|
||||
int cpid = (int)mapping[ MySqlCharSetName ];
|
||||
return Encoding.GetEncoding( cpid );
|
||||
}
|
||||
catch (System.NotSupportedException)
|
||||
{
|
||||
return Encoding.GetEncoding(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private static void InitializeMapping()
|
||||
{
|
||||
mapping = new Hashtable();
|
||||
|
||||
// relatively sure about
|
||||
mapping.Add( "default", 0 );
|
||||
mapping.Add( "big5", 950 ); // Traditional Chinese
|
||||
mapping.Add( "latin1", 28591 ); // Latin alphabet #1
|
||||
mapping.Add( "utf8", 65001 );
|
||||
mapping.Add( "ucs2", 1200 );
|
||||
mapping.Add( "latin2", 28592 );
|
||||
mapping.Add( "latin4", 28594 );
|
||||
mapping.Add( "latin3", 28593 );
|
||||
mapping.Add( "latin5", 1254 );
|
||||
mapping.Add( "cp1251", 1251 ); // Russian
|
||||
mapping.Add( "win1251", 1251 );
|
||||
mapping.Add( "hebrew", 1255 ); // Hebrew
|
||||
mapping.Add( "greek", 1253 ); // Greek
|
||||
mapping.Add( "sjis", 932 ); // Shift-JIS
|
||||
mapping.Add( "gbk", 936 ); // Simplified Chinese
|
||||
mapping.Add( "cp866", 866 );
|
||||
mapping.Add( "euc_kr", 949 );
|
||||
|
||||
// maybe, maybe not...
|
||||
mapping.Add( "win1250", 1250 ); // Central Eurpoe
|
||||
mapping.Add( "win1251ukr", 1251 );
|
||||
mapping.Add( "latin1_de", 1252 ); // Latin1 German
|
||||
mapping.Add( "german1", 1252 ); // German
|
||||
mapping.Add( "danish", 1252 ); // Danish
|
||||
mapping.Add( "dos", 437 ); // Dos
|
||||
mapping.Add( "pclatin2", 852 );
|
||||
mapping.Add( "win1250ch", 1250 );
|
||||
mapping.Add( "cp1257", 1257 );
|
||||
mapping.Add( "usa7", 646 );
|
||||
mapping.Add( "czech", 912 );
|
||||
mapping.Add( "hungarian", 912 );
|
||||
mapping.Add( "croat", 912 );
|
||||
|
||||
/* ("gb2312", "EUC_CN");
|
||||
("ujis", "EUC_JP");
|
||||
("latvian", "ISO8859_13");
|
||||
("latvian1", "ISO8859_13");
|
||||
("estonia", "ISO8859_13");
|
||||
("koi8_ru", "KOI8_R");
|
||||
("tis620", "TIS620");
|
||||
("macroman", "MacRoman");
|
||||
("macce", "MacCentralEurope");
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for CharSetMap.
|
||||
/// </summary>
|
||||
internal class CharSetMap
|
||||
{
|
||||
private static Hashtable mapping;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="MySqlCharSetName"></param>
|
||||
/// <returns></returns>
|
||||
public static Encoding GetEncoding( string MySqlCharSetName )
|
||||
{
|
||||
if (mapping == null )
|
||||
InitializeMapping();
|
||||
try
|
||||
{
|
||||
int cpid = (int)mapping[ MySqlCharSetName ];
|
||||
return Encoding.GetEncoding( cpid );
|
||||
}
|
||||
catch (System.NotSupportedException)
|
||||
{
|
||||
return Encoding.GetEncoding(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private static void InitializeMapping()
|
||||
{
|
||||
mapping = new Hashtable();
|
||||
|
||||
// relatively sure about
|
||||
mapping.Add( "default", 0 );
|
||||
mapping.Add( "big5", 950 ); // Traditional Chinese
|
||||
mapping.Add( "latin1", 28591 ); // Latin alphabet #1
|
||||
mapping.Add( "utf8", 65001 );
|
||||
mapping.Add( "ucs2", 1200 );
|
||||
mapping.Add( "latin2", 28592 );
|
||||
mapping.Add( "latin4", 28594 );
|
||||
mapping.Add( "latin3", 28593 );
|
||||
mapping.Add( "latin5", 1254 );
|
||||
mapping.Add( "cp1251", 1251 ); // Russian
|
||||
mapping.Add( "win1251", 1251 );
|
||||
mapping.Add( "hebrew", 1255 ); // Hebrew
|
||||
mapping.Add( "greek", 1253 ); // Greek
|
||||
mapping.Add( "sjis", 932 ); // Shift-JIS
|
||||
mapping.Add( "gbk", 936 ); // Simplified Chinese
|
||||
mapping.Add( "cp866", 866 );
|
||||
mapping.Add( "euc_kr", 949 );
|
||||
|
||||
// maybe, maybe not...
|
||||
mapping.Add( "win1250", 1250 ); // Central Eurpoe
|
||||
mapping.Add( "win1251ukr", 1251 );
|
||||
mapping.Add( "latin1_de", 1252 ); // Latin1 German
|
||||
mapping.Add( "german1", 1252 ); // German
|
||||
mapping.Add( "danish", 1252 ); // Danish
|
||||
mapping.Add( "dos", 437 ); // Dos
|
||||
mapping.Add( "pclatin2", 852 );
|
||||
mapping.Add( "win1250ch", 1250 );
|
||||
mapping.Add( "cp1257", 1257 );
|
||||
mapping.Add( "usa7", 646 );
|
||||
mapping.Add( "czech", 912 );
|
||||
mapping.Add( "hungarian", 912 );
|
||||
mapping.Add( "croat", 912 );
|
||||
|
||||
/* ("gb2312", "EUC_CN");
|
||||
("ujis", "EUC_JP");
|
||||
("latvian", "ISO8859_13");
|
||||
("latvian1", "ISO8859_13");
|
||||
("estonia", "ISO8859_13");
|
||||
("koi8_ru", "KOI8_R");
|
||||
("tis620", "TIS620");
|
||||
("macroman", "MacRoman");
|
||||
("macce", "MacCentralEurope");
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,420 +1,420 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlCommandBuilder.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[ToolboxItem(false)]
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
public sealed class MySqlCommandBuilder : Component
|
||||
{
|
||||
private MySqlDataAdapter _adapter;
|
||||
private string _QuotePrefix;
|
||||
private string _QuoteSuffix;
|
||||
private DataTable _schema;
|
||||
private string _tableName;
|
||||
|
||||
private MySqlCommand _updateCmd;
|
||||
private MySqlCommand _insertCmd;
|
||||
private MySqlCommand _deleteCmd;
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
|
||||
/// </summary>
|
||||
public MySqlCommandBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
|
||||
/// </summary>
|
||||
public MySqlCommandBuilder( MySqlDataAdapter adapter )
|
||||
{
|
||||
_adapter = adapter;
|
||||
_adapter.RowUpdating += new MySqlRowUpdatingEventHandler( OnRowUpdating );
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a MySqlDataAdapter object for which SQL statements are automatically generated.
|
||||
/// </summary>
|
||||
public MySqlDataAdapter DataAdapter
|
||||
{
|
||||
get { return _adapter; }
|
||||
set
|
||||
{
|
||||
if (_adapter != null)
|
||||
{
|
||||
_adapter.RowUpdating -= new MySqlRowUpdatingEventHandler( OnRowUpdating );
|
||||
}
|
||||
_adapter = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the beginning character or characters to use when specifying MySql database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.
|
||||
/// </summary>
|
||||
public string QuotePrefix
|
||||
{
|
||||
get { return _QuotePrefix; }
|
||||
set { _QuotePrefix = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ending character or characters to use when specifying MySql database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.
|
||||
/// </summary>
|
||||
public string QuoteSuffix
|
||||
{
|
||||
get { return _QuoteSuffix; }
|
||||
set { _QuoteSuffix = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Retrieves parameter information from the stored procedure specified in the MySqlCommand and populates the Parameters collection of the specified MySqlCommand object.
|
||||
/// This method is not currently supported since stored procedures are not available in MySql.
|
||||
/// </summary>
|
||||
/// <param name="command">The MySqlCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the MySqlCommand.</param>
|
||||
/// <exception cref="InvalidOperationException">The command text is not a valid stored procedure name.</exception>
|
||||
public static void DeriveParameters(MySqlCommand command)
|
||||
{
|
||||
throw new MySqlException("DeriveParameters is not supported (due to MySql not supporting SP)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the automatically generated MySqlCommand object required to perform deletions on the database.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlCommand GetDeleteCommand()
|
||||
{
|
||||
if (_schema == null)
|
||||
GenerateSchema();
|
||||
return CreateDeleteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the automatically generated MySqlCommand object required to perform insertions on the database.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlCommand GetInsertCommand()
|
||||
{
|
||||
if (_schema == null)
|
||||
GenerateSchema();
|
||||
return CreateInsertCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the automatically generated MySqlCommand object required to perform updates on the database.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlCommand GetUpdateCommand()
|
||||
{
|
||||
if (_schema == null)
|
||||
GenerateSchema();
|
||||
return CreateUpdateCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the database schema information used to generate INSERT, UPDATE, or DELETE statements.
|
||||
/// </summary>
|
||||
public void RefreshSchema()
|
||||
{
|
||||
_schema = null;
|
||||
_insertCmd = null;
|
||||
_deleteCmd = null;
|
||||
_updateCmd = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void GenerateSchema()
|
||||
{
|
||||
if (_adapter == null)
|
||||
throw new MySqlException("Improper MySqlCommandBuilder state: adapter is null");
|
||||
if (_adapter.SelectCommand == null)
|
||||
throw new MySqlException("Improper MySqlCommandBuilder state: adapter's SelectCommand is null");
|
||||
|
||||
MySqlDataReader dr = _adapter.SelectCommand.ExecuteReader(CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
|
||||
_schema = dr.GetSchemaTable();
|
||||
dr.Close();
|
||||
|
||||
// make sure we got at least one unique or key field and count base table names
|
||||
bool hasKeyOrUnique=false;
|
||||
|
||||
foreach (DataRow row in _schema.Rows)
|
||||
{
|
||||
if (true == (bool)row["IsKey"] || true == (bool)row["IsUnique"])
|
||||
hasKeyOrUnique=true;
|
||||
if (_tableName == null)
|
||||
_tableName = (string)row["BaseTableName"];
|
||||
else if (_tableName != (string)row["BaseTableName"])
|
||||
throw new InvalidOperationException("MySqlCommandBuilder does not support multi-table statements");
|
||||
}
|
||||
if (! hasKeyOrUnique)
|
||||
throw new InvalidOperationException("MySqlCommandBuilder cannot operate on tables with no unique or key columns");
|
||||
}
|
||||
|
||||
private string Quote(string table_or_column)
|
||||
{
|
||||
if (_QuotePrefix == null || _QuoteSuffix == null)
|
||||
return table_or_column;
|
||||
return _QuotePrefix + table_or_column + _QuoteSuffix;
|
||||
}
|
||||
|
||||
private MySqlParameter CreateParameter(DataRow row, bool Original)
|
||||
{
|
||||
MySqlParameter p;
|
||||
if (Original)
|
||||
p = new MySqlParameter( "@Original_" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],
|
||||
ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Original, DBNull.Value );
|
||||
else
|
||||
p = new MySqlParameter( "@" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],
|
||||
ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Current, DBNull.Value );
|
||||
return p;
|
||||
}
|
||||
|
||||
private MySqlCommand CreateBaseCommand()
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = _adapter.SelectCommand.Connection;
|
||||
cmd.CommandTimeout = _adapter.SelectCommand.CommandTimeout;
|
||||
cmd.Transaction = _adapter.SelectCommand.Transaction;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private MySqlCommand CreateDeleteCommand()
|
||||
{
|
||||
if (_deleteCmd != null) return _deleteCmd;
|
||||
|
||||
MySqlCommand cmd = CreateBaseCommand();
|
||||
|
||||
cmd.CommandText = "DELETE FROM " + Quote(_tableName) +
|
||||
" WHERE " + CreateOriginalWhere(cmd);
|
||||
|
||||
_deleteCmd = cmd;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private string CreateFinalSelect(bool forinsert)
|
||||
{
|
||||
StringBuilder sel = new StringBuilder();
|
||||
StringBuilder where = new StringBuilder();
|
||||
|
||||
foreach (DataRow row in _schema.Rows)
|
||||
{
|
||||
string colname = (string)row["ColumnName"];
|
||||
if (sel.Length > 0)
|
||||
sel.Append(", ");
|
||||
sel.Append( colname );
|
||||
if ((bool)row["IsKey"] == false) continue;
|
||||
if (where.Length > 0)
|
||||
where.Append(" AND ");
|
||||
where.Append( "(" + colname + "=" );
|
||||
if (forinsert)
|
||||
{
|
||||
if ((bool)row["IsAutoIncrement"])
|
||||
where.Append("last_insert_id()");
|
||||
else if ((bool)row["IsKey"])
|
||||
where.Append("@" + colname);
|
||||
}
|
||||
else
|
||||
{
|
||||
where.Append("@Original_" + colname);
|
||||
}
|
||||
where.Append(")");
|
||||
}
|
||||
return "SELECT " + sel.ToString() + " FROM " + Quote(_tableName) +
|
||||
" WHERE " + where.ToString();
|
||||
}
|
||||
|
||||
private string CreateOriginalWhere(MySqlCommand cmd)
|
||||
{
|
||||
StringBuilder wherestr = new StringBuilder();
|
||||
|
||||
foreach (DataRow row in _schema.Rows)
|
||||
{
|
||||
if (! IncludedInWhereClause(row)) continue;
|
||||
|
||||
// first update the where clause since it will contain all parameters
|
||||
if (wherestr.Length > 0)
|
||||
wherestr.Append(" AND ");
|
||||
string colname = Quote((string)row["ColumnName"]);
|
||||
|
||||
MySqlParameter op = CreateParameter(row, true);
|
||||
cmd.Parameters.Add(op);
|
||||
|
||||
wherestr.Append( "(" + colname + "=@" + op.ParameterName);
|
||||
if ((bool)row["AllowDBNull"] == true)
|
||||
wherestr.Append( " or (" + colname + " IS NULL and @" + op.ParameterName + " IS NULL)");
|
||||
wherestr.Append(")");
|
||||
}
|
||||
return wherestr.ToString();
|
||||
}
|
||||
|
||||
private MySqlCommand CreateUpdateCommand()
|
||||
{
|
||||
if (_updateCmd != null) return _updateCmd;
|
||||
|
||||
MySqlCommand cmd = CreateBaseCommand();
|
||||
|
||||
StringBuilder setstr = new StringBuilder();
|
||||
|
||||
foreach (DataRow schemaRow in _schema.Rows)
|
||||
{
|
||||
string colname = Quote((string)schemaRow["ColumnName"]);
|
||||
|
||||
if (! IncludedInUpdate(schemaRow)) continue;
|
||||
|
||||
if (setstr.Length > 0)
|
||||
setstr.Append(", ");
|
||||
|
||||
MySqlParameter p = CreateParameter(schemaRow, false);
|
||||
cmd.Parameters.Add(p);
|
||||
|
||||
setstr.Append( colname + "=@" + p.ParameterName );
|
||||
}
|
||||
|
||||
cmd.CommandText = "UPDATE " + Quote(_tableName) + " SET " + setstr.ToString() +
|
||||
" WHERE " + CreateOriginalWhere(cmd);
|
||||
cmd.CommandText += "; " + CreateFinalSelect(false);
|
||||
|
||||
_updateCmd = cmd;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private MySqlCommand CreateInsertCommand()
|
||||
{
|
||||
if (_insertCmd != null) return _insertCmd;
|
||||
|
||||
MySqlCommand cmd = CreateBaseCommand();
|
||||
|
||||
StringBuilder setstr = new StringBuilder();
|
||||
StringBuilder valstr = new StringBuilder();
|
||||
foreach (DataRow schemaRow in _schema.Rows)
|
||||
{
|
||||
string colname = Quote((string)schemaRow["ColumnName"]);
|
||||
|
||||
if (!IncludedInInsert(schemaRow)) continue;
|
||||
|
||||
if (setstr.Length > 0)
|
||||
{
|
||||
setstr.Append(", ");
|
||||
valstr.Append(", ");
|
||||
}
|
||||
|
||||
MySqlParameter p = CreateParameter(schemaRow, false);
|
||||
cmd.Parameters.Add(p);
|
||||
|
||||
setstr.Append( colname );
|
||||
valstr.Append( "@" + p.ParameterName );
|
||||
}
|
||||
|
||||
cmd.CommandText = "INSERT INTO " + Quote(_tableName) + " (" + setstr.ToString() + ") " +
|
||||
" VALUES (" + valstr.ToString() + ")";
|
||||
cmd.CommandText += "; " + CreateFinalSelect(true);
|
||||
|
||||
_insertCmd = cmd;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private bool IncludedInInsert (DataRow schemaRow)
|
||||
{
|
||||
// If the parameter has one of these properties, then we don't include it in the insert:
|
||||
// AutoIncrement, Hidden, Expression, RowVersion, ReadOnly
|
||||
|
||||
if ((bool) schemaRow ["IsAutoIncrement"])
|
||||
return false;
|
||||
/* if ((bool) schemaRow ["IsHidden"])
|
||||
return false;
|
||||
if ((bool) schemaRow ["IsExpression"])
|
||||
return false;*/
|
||||
if ((bool) schemaRow ["IsRowVersion"])
|
||||
return false;
|
||||
if ((bool) schemaRow ["IsReadOnly"])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IncludedInUpdate (DataRow schemaRow)
|
||||
{
|
||||
// If the parameter has one of these properties, then we don't include it in the insert:
|
||||
// AutoIncrement, Hidden, RowVersion
|
||||
|
||||
if ((bool) schemaRow ["IsAutoIncrement"])
|
||||
return false;
|
||||
// if ((bool) schemaRow ["IsHidden"])
|
||||
// return false;
|
||||
if ((bool) schemaRow ["IsRowVersion"])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IncludedInWhereClause (DataRow schemaRow)
|
||||
{
|
||||
// if ((bool) schemaRow ["IsLong"])
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SetParameterValues(MySqlCommand cmd, DataRow dataRow)
|
||||
{
|
||||
foreach (MySqlParameter p in cmd.Parameters)
|
||||
{
|
||||
if (p.ParameterName.Length >= 8 && p.ParameterName.Substring(0, 8).Equals("Original"))
|
||||
p.Value = dataRow[ p.SourceColumn, DataRowVersion.Original ];
|
||||
else
|
||||
p.Value = dataRow[ p.SourceColumn, DataRowVersion.Current ];
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRowUpdating(object sender, MySqlRowUpdatingEventArgs args)
|
||||
{
|
||||
// make sure we are still to proceed
|
||||
if (args.Status != UpdateStatus.Continue) return;
|
||||
|
||||
if (_schema == null)
|
||||
GenerateSchema();
|
||||
|
||||
if (StatementType.Delete == args.StatementType)
|
||||
args.Command = CreateDeleteCommand();
|
||||
else if (StatementType.Update == args.StatementType)
|
||||
args.Command = CreateUpdateCommand();
|
||||
else if (StatementType.Insert == args.StatementType)
|
||||
args.Command = CreateInsertCommand();
|
||||
else if (StatementType.Select == args.StatementType)
|
||||
return;
|
||||
|
||||
SetParameterValues(args.Command, args.Row);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlCommandBuilder.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[ToolboxItem(false)]
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
public sealed class MySqlCommandBuilder : Component
|
||||
{
|
||||
private MySqlDataAdapter _adapter;
|
||||
private string _QuotePrefix;
|
||||
private string _QuoteSuffix;
|
||||
private DataTable _schema;
|
||||
private string _tableName;
|
||||
|
||||
private MySqlCommand _updateCmd;
|
||||
private MySqlCommand _insertCmd;
|
||||
private MySqlCommand _deleteCmd;
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
|
||||
/// </summary>
|
||||
public MySqlCommandBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
|
||||
/// </summary>
|
||||
public MySqlCommandBuilder( MySqlDataAdapter adapter )
|
||||
{
|
||||
_adapter = adapter;
|
||||
_adapter.RowUpdating += new MySqlRowUpdatingEventHandler( OnRowUpdating );
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a MySqlDataAdapter object for which SQL statements are automatically generated.
|
||||
/// </summary>
|
||||
public MySqlDataAdapter DataAdapter
|
||||
{
|
||||
get { return _adapter; }
|
||||
set
|
||||
{
|
||||
if (_adapter != null)
|
||||
{
|
||||
_adapter.RowUpdating -= new MySqlRowUpdatingEventHandler( OnRowUpdating );
|
||||
}
|
||||
_adapter = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the beginning character or characters to use when specifying MySql database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.
|
||||
/// </summary>
|
||||
public string QuotePrefix
|
||||
{
|
||||
get { return _QuotePrefix; }
|
||||
set { _QuotePrefix = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ending character or characters to use when specifying MySql database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.
|
||||
/// </summary>
|
||||
public string QuoteSuffix
|
||||
{
|
||||
get { return _QuoteSuffix; }
|
||||
set { _QuoteSuffix = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Retrieves parameter information from the stored procedure specified in the MySqlCommand and populates the Parameters collection of the specified MySqlCommand object.
|
||||
/// This method is not currently supported since stored procedures are not available in MySql.
|
||||
/// </summary>
|
||||
/// <param name="command">The MySqlCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the MySqlCommand.</param>
|
||||
/// <exception cref="InvalidOperationException">The command text is not a valid stored procedure name.</exception>
|
||||
public static void DeriveParameters(MySqlCommand command)
|
||||
{
|
||||
throw new MySqlException("DeriveParameters is not supported (due to MySql not supporting SP)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the automatically generated MySqlCommand object required to perform deletions on the database.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlCommand GetDeleteCommand()
|
||||
{
|
||||
if (_schema == null)
|
||||
GenerateSchema();
|
||||
return CreateDeleteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the automatically generated MySqlCommand object required to perform insertions on the database.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlCommand GetInsertCommand()
|
||||
{
|
||||
if (_schema == null)
|
||||
GenerateSchema();
|
||||
return CreateInsertCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the automatically generated MySqlCommand object required to perform updates on the database.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlCommand GetUpdateCommand()
|
||||
{
|
||||
if (_schema == null)
|
||||
GenerateSchema();
|
||||
return CreateUpdateCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the database schema information used to generate INSERT, UPDATE, or DELETE statements.
|
||||
/// </summary>
|
||||
public void RefreshSchema()
|
||||
{
|
||||
_schema = null;
|
||||
_insertCmd = null;
|
||||
_deleteCmd = null;
|
||||
_updateCmd = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void GenerateSchema()
|
||||
{
|
||||
if (_adapter == null)
|
||||
throw new MySqlException("Improper MySqlCommandBuilder state: adapter is null");
|
||||
if (_adapter.SelectCommand == null)
|
||||
throw new MySqlException("Improper MySqlCommandBuilder state: adapter's SelectCommand is null");
|
||||
|
||||
MySqlDataReader dr = _adapter.SelectCommand.ExecuteReader(CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
|
||||
_schema = dr.GetSchemaTable();
|
||||
dr.Close();
|
||||
|
||||
// make sure we got at least one unique or key field and count base table names
|
||||
bool hasKeyOrUnique=false;
|
||||
|
||||
foreach (DataRow row in _schema.Rows)
|
||||
{
|
||||
if (true == (bool)row["IsKey"] || true == (bool)row["IsUnique"])
|
||||
hasKeyOrUnique=true;
|
||||
if (_tableName == null)
|
||||
_tableName = (string)row["BaseTableName"];
|
||||
else if (_tableName != (string)row["BaseTableName"])
|
||||
throw new InvalidOperationException("MySqlCommandBuilder does not support multi-table statements");
|
||||
}
|
||||
if (! hasKeyOrUnique)
|
||||
throw new InvalidOperationException("MySqlCommandBuilder cannot operate on tables with no unique or key columns");
|
||||
}
|
||||
|
||||
private string Quote(string table_or_column)
|
||||
{
|
||||
if (_QuotePrefix == null || _QuoteSuffix == null)
|
||||
return table_or_column;
|
||||
return _QuotePrefix + table_or_column + _QuoteSuffix;
|
||||
}
|
||||
|
||||
private MySqlParameter CreateParameter(DataRow row, bool Original)
|
||||
{
|
||||
MySqlParameter p;
|
||||
if (Original)
|
||||
p = new MySqlParameter( "@Original_" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],
|
||||
ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Original, DBNull.Value );
|
||||
else
|
||||
p = new MySqlParameter( "@" + (string)row["ColumnName"], (MySqlDbType)row["ProviderType"],
|
||||
ParameterDirection.Input, (string)row["ColumnName"], DataRowVersion.Current, DBNull.Value );
|
||||
return p;
|
||||
}
|
||||
|
||||
private MySqlCommand CreateBaseCommand()
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = _adapter.SelectCommand.Connection;
|
||||
cmd.CommandTimeout = _adapter.SelectCommand.CommandTimeout;
|
||||
cmd.Transaction = _adapter.SelectCommand.Transaction;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private MySqlCommand CreateDeleteCommand()
|
||||
{
|
||||
if (_deleteCmd != null) return _deleteCmd;
|
||||
|
||||
MySqlCommand cmd = CreateBaseCommand();
|
||||
|
||||
cmd.CommandText = "DELETE FROM " + Quote(_tableName) +
|
||||
" WHERE " + CreateOriginalWhere(cmd);
|
||||
|
||||
_deleteCmd = cmd;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private string CreateFinalSelect(bool forinsert)
|
||||
{
|
||||
StringBuilder sel = new StringBuilder();
|
||||
StringBuilder where = new StringBuilder();
|
||||
|
||||
foreach (DataRow row in _schema.Rows)
|
||||
{
|
||||
string colname = (string)row["ColumnName"];
|
||||
if (sel.Length > 0)
|
||||
sel.Append(", ");
|
||||
sel.Append( colname );
|
||||
if ((bool)row["IsKey"] == false) continue;
|
||||
if (where.Length > 0)
|
||||
where.Append(" AND ");
|
||||
where.Append( "(" + colname + "=" );
|
||||
if (forinsert)
|
||||
{
|
||||
if ((bool)row["IsAutoIncrement"])
|
||||
where.Append("last_insert_id()");
|
||||
else if ((bool)row["IsKey"])
|
||||
where.Append("@" + colname);
|
||||
}
|
||||
else
|
||||
{
|
||||
where.Append("@Original_" + colname);
|
||||
}
|
||||
where.Append(")");
|
||||
}
|
||||
return "SELECT " + sel.ToString() + " FROM " + Quote(_tableName) +
|
||||
" WHERE " + where.ToString();
|
||||
}
|
||||
|
||||
private string CreateOriginalWhere(MySqlCommand cmd)
|
||||
{
|
||||
StringBuilder wherestr = new StringBuilder();
|
||||
|
||||
foreach (DataRow row in _schema.Rows)
|
||||
{
|
||||
if (! IncludedInWhereClause(row)) continue;
|
||||
|
||||
// first update the where clause since it will contain all parameters
|
||||
if (wherestr.Length > 0)
|
||||
wherestr.Append(" AND ");
|
||||
string colname = Quote((string)row["ColumnName"]);
|
||||
|
||||
MySqlParameter op = CreateParameter(row, true);
|
||||
cmd.Parameters.Add(op);
|
||||
|
||||
wherestr.Append( "(" + colname + "=@" + op.ParameterName);
|
||||
if ((bool)row["AllowDBNull"] == true)
|
||||
wherestr.Append( " or (" + colname + " IS NULL and @" + op.ParameterName + " IS NULL)");
|
||||
wherestr.Append(")");
|
||||
}
|
||||
return wherestr.ToString();
|
||||
}
|
||||
|
||||
private MySqlCommand CreateUpdateCommand()
|
||||
{
|
||||
if (_updateCmd != null) return _updateCmd;
|
||||
|
||||
MySqlCommand cmd = CreateBaseCommand();
|
||||
|
||||
StringBuilder setstr = new StringBuilder();
|
||||
|
||||
foreach (DataRow schemaRow in _schema.Rows)
|
||||
{
|
||||
string colname = Quote((string)schemaRow["ColumnName"]);
|
||||
|
||||
if (! IncludedInUpdate(schemaRow)) continue;
|
||||
|
||||
if (setstr.Length > 0)
|
||||
setstr.Append(", ");
|
||||
|
||||
MySqlParameter p = CreateParameter(schemaRow, false);
|
||||
cmd.Parameters.Add(p);
|
||||
|
||||
setstr.Append( colname + "=@" + p.ParameterName );
|
||||
}
|
||||
|
||||
cmd.CommandText = "UPDATE " + Quote(_tableName) + " SET " + setstr.ToString() +
|
||||
" WHERE " + CreateOriginalWhere(cmd);
|
||||
cmd.CommandText += "; " + CreateFinalSelect(false);
|
||||
|
||||
_updateCmd = cmd;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private MySqlCommand CreateInsertCommand()
|
||||
{
|
||||
if (_insertCmd != null) return _insertCmd;
|
||||
|
||||
MySqlCommand cmd = CreateBaseCommand();
|
||||
|
||||
StringBuilder setstr = new StringBuilder();
|
||||
StringBuilder valstr = new StringBuilder();
|
||||
foreach (DataRow schemaRow in _schema.Rows)
|
||||
{
|
||||
string colname = Quote((string)schemaRow["ColumnName"]);
|
||||
|
||||
if (!IncludedInInsert(schemaRow)) continue;
|
||||
|
||||
if (setstr.Length > 0)
|
||||
{
|
||||
setstr.Append(", ");
|
||||
valstr.Append(", ");
|
||||
}
|
||||
|
||||
MySqlParameter p = CreateParameter(schemaRow, false);
|
||||
cmd.Parameters.Add(p);
|
||||
|
||||
setstr.Append( colname );
|
||||
valstr.Append( "@" + p.ParameterName );
|
||||
}
|
||||
|
||||
cmd.CommandText = "INSERT INTO " + Quote(_tableName) + " (" + setstr.ToString() + ") " +
|
||||
" VALUES (" + valstr.ToString() + ")";
|
||||
cmd.CommandText += "; " + CreateFinalSelect(true);
|
||||
|
||||
_insertCmd = cmd;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private bool IncludedInInsert (DataRow schemaRow)
|
||||
{
|
||||
// If the parameter has one of these properties, then we don't include it in the insert:
|
||||
// AutoIncrement, Hidden, Expression, RowVersion, ReadOnly
|
||||
|
||||
if ((bool) schemaRow ["IsAutoIncrement"])
|
||||
return false;
|
||||
/* if ((bool) schemaRow ["IsHidden"])
|
||||
return false;
|
||||
if ((bool) schemaRow ["IsExpression"])
|
||||
return false;*/
|
||||
if ((bool) schemaRow ["IsRowVersion"])
|
||||
return false;
|
||||
if ((bool) schemaRow ["IsReadOnly"])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IncludedInUpdate (DataRow schemaRow)
|
||||
{
|
||||
// If the parameter has one of these properties, then we don't include it in the insert:
|
||||
// AutoIncrement, Hidden, RowVersion
|
||||
|
||||
if ((bool) schemaRow ["IsAutoIncrement"])
|
||||
return false;
|
||||
// if ((bool) schemaRow ["IsHidden"])
|
||||
// return false;
|
||||
if ((bool) schemaRow ["IsRowVersion"])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IncludedInWhereClause (DataRow schemaRow)
|
||||
{
|
||||
// if ((bool) schemaRow ["IsLong"])
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SetParameterValues(MySqlCommand cmd, DataRow dataRow)
|
||||
{
|
||||
foreach (MySqlParameter p in cmd.Parameters)
|
||||
{
|
||||
if (p.ParameterName.Length >= 8 && p.ParameterName.Substring(0, 8).Equals("Original"))
|
||||
p.Value = dataRow[ p.SourceColumn, DataRowVersion.Original ];
|
||||
else
|
||||
p.Value = dataRow[ p.SourceColumn, DataRowVersion.Current ];
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRowUpdating(object sender, MySqlRowUpdatingEventArgs args)
|
||||
{
|
||||
// make sure we are still to proceed
|
||||
if (args.Status != UpdateStatus.Continue) return;
|
||||
|
||||
if (_schema == null)
|
||||
GenerateSchema();
|
||||
|
||||
if (StatementType.Delete == args.StatementType)
|
||||
args.Command = CreateDeleteCommand();
|
||||
else if (StatementType.Update == args.StatementType)
|
||||
args.Command = CreateUpdateCommand();
|
||||
else if (StatementType.Insert == args.StatementType)
|
||||
args.Command = CreateInsertCommand();
|
||||
else if (StatementType.Select == args.StatementType)
|
||||
return;
|
||||
|
||||
SetParameterValues(args.Command, args.Row);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for CommandResult.
|
||||
/// </summary>
|
||||
internal class CommandResult
|
||||
{
|
||||
private Driver driver;
|
||||
private Packet packet;
|
||||
private int affectedRows = -1;
|
||||
private int fieldCount = -1;
|
||||
private int fieldsRead = 0;
|
||||
private long fieldLength = 0;
|
||||
private bool readSchema = false;
|
||||
private bool readRows = false;
|
||||
|
||||
public CommandResult(Packet p, Driver d)
|
||||
{
|
||||
driver = d;
|
||||
packet = p;
|
||||
fieldCount = (int)p.ReadLenInteger();
|
||||
if (fieldCount == 0)
|
||||
affectedRows =(int)p.ReadLenInteger();
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public bool IsResultSet
|
||||
{
|
||||
get { return fieldCount > 0; }
|
||||
}
|
||||
|
||||
public int ColumnCount
|
||||
{
|
||||
get { return fieldCount; }
|
||||
}
|
||||
|
||||
public int RowsAffected
|
||||
{
|
||||
get { return affectedRows; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public MySqlField GetField()
|
||||
{
|
||||
MySqlField f = new MySqlField( driver.Encoding );
|
||||
packet = driver.ReadPacket();
|
||||
|
||||
f.TableName = packet.ReadLenString();
|
||||
f.ColumnName = packet.ReadLenString();
|
||||
f.ColumnLength = (int)packet.ReadNBytes();
|
||||
f.Type = (MySqlDbType)packet.ReadNBytes();
|
||||
packet.ReadByte(); // this is apparently 2 -- not sure what it is for
|
||||
f.Flags = (ColumnFlags)packet.ReadInteger(2); //(short)(d.ReadByte() & 0xff);
|
||||
f.NumericScale = packet.ReadByte();
|
||||
fieldsRead++;
|
||||
return f;
|
||||
}
|
||||
|
||||
public byte[] GetFieldBuffer()
|
||||
{
|
||||
return packet.GetBuffer();
|
||||
}
|
||||
|
||||
public int GetFieldIndex()
|
||||
{
|
||||
return (int)packet.Position;
|
||||
}
|
||||
|
||||
public long GetFieldLength()
|
||||
{
|
||||
return fieldLength;
|
||||
}
|
||||
|
||||
public bool NextField()
|
||||
{
|
||||
if (fieldLength >= 0)
|
||||
packet.Position += fieldLength;
|
||||
if (! packet.HasMoreData) return false;
|
||||
fieldLength = packet.ReadLenInteger();
|
||||
fieldsRead++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if there are any row packets coming
|
||||
/// </summary>
|
||||
/// <returns>True if there are row packets available, false if not</returns>
|
||||
public bool CheckForRows()
|
||||
{
|
||||
// first read off any unread field defs
|
||||
while (fieldsRead < fieldCount)
|
||||
GetField();
|
||||
|
||||
// read off the end of schema packet
|
||||
packet = driver.ReadPacket();
|
||||
if ( ! packet.IsLastPacket())
|
||||
throw new MySqlException("Expected end of schema packet");
|
||||
readSchema = true;
|
||||
|
||||
packet = driver.PeekPacket();
|
||||
return ! packet.IsLastPacket();
|
||||
}
|
||||
|
||||
public bool ReadDataRow()
|
||||
{
|
||||
packet = driver.ReadPacket();
|
||||
if (packet.IsLastPacket())
|
||||
{
|
||||
readRows = true;
|
||||
return false;
|
||||
}
|
||||
fieldsRead = 0;
|
||||
fieldLength = 0;
|
||||
NextField();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Packet p;
|
||||
|
||||
if (! readSchema)
|
||||
{
|
||||
do
|
||||
{
|
||||
p = driver.ReadPacket();
|
||||
} while (! p.IsLastPacket());
|
||||
}
|
||||
|
||||
if (! readRows)
|
||||
do
|
||||
{
|
||||
p = driver.ReadPacket();
|
||||
} while (! p.IsLastPacket());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for CompressedStream.
|
||||
/// </summary>
|
||||
internal class CompressedStream : Stream
|
||||
{
|
||||
private Stream srcStream;
|
||||
private byte[] buffer;
|
||||
private int index;
|
||||
|
||||
public CompressedStream( Stream src )
|
||||
{
|
||||
srcStream = src;
|
||||
index = 0;
|
||||
buffer = new byte[0];
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return srcStream.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return srcStream.CanWrite; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return srcStream.CanSeek; }
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { return srcStream.Length; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return srcStream.Position; }
|
||||
set { srcStream.Position = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
srcStream.Close();
|
||||
base.Close ();
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
srcStream.Flush();
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
srcStream.SetLength( value );
|
||||
}
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
EnsureData(1);
|
||||
|
||||
return (int)buffer[index++];
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException( "buffer", "Buffer must not be null" );
|
||||
if (offset < 0 || offset >= buffer.Length)
|
||||
throw new ArgumentOutOfRangeException( "Offset must be a valid position in buffer" );
|
||||
if ((offset + count) > buffer.Length)
|
||||
throw new ArgumentException( "Buffer is not large enough to complete operation" );
|
||||
|
||||
EnsureData( count );
|
||||
|
||||
for (int i=0; i < count; i++)
|
||||
buffer[offset+i] = this.buffer[index++];
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
srcStream.Write( buffer, offset, count );
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return srcStream.Seek( offset, origin );
|
||||
}
|
||||
|
||||
private void ReadBuffer( Stream s, byte[] buf, int offset, int length )
|
||||
{
|
||||
while (length > 0)
|
||||
{
|
||||
int amountRead = s.Read( buf, offset, length );
|
||||
if (amountRead == 0)
|
||||
throw new MySqlException("Unexpected end of data encountered");
|
||||
length -= amountRead;
|
||||
offset += amountRead;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadNextPacket()
|
||||
{
|
||||
// read off the uncompressed and compressed lengths
|
||||
int compressedLen = srcStream.ReadByte() + (srcStream.ReadByte() << 8) +
|
||||
(srcStream.ReadByte() << 16);
|
||||
byte seq = (byte)srcStream.ReadByte();
|
||||
int unCompressedLen = srcStream.ReadByte() + (srcStream.ReadByte() << 8) +
|
||||
(srcStream.ReadByte() << 16);
|
||||
|
||||
// if the data is in fact compressed, then uncompress it
|
||||
byte[] unCompressedBuffer = null;
|
||||
if (unCompressedLen > 0)
|
||||
{
|
||||
unCompressedBuffer = new byte[ unCompressedLen ];
|
||||
InflaterInputStream iis = new InflaterInputStream( srcStream );
|
||||
ReadBuffer( iis, unCompressedBuffer, 0, unCompressedLen );
|
||||
}
|
||||
else
|
||||
{
|
||||
unCompressedBuffer = new byte[ compressedLen ];
|
||||
ReadBuffer( srcStream, unCompressedBuffer, 0, compressedLen );
|
||||
}
|
||||
|
||||
// now join this buffer to our existing one
|
||||
int left = buffer.Length - index;
|
||||
byte[] newBuffer = new byte[ left + unCompressedBuffer.Length ];
|
||||
|
||||
int newIndex = 0;
|
||||
// first copy in the rest of the original
|
||||
for (int i=index; i < buffer.Length; i++)
|
||||
newBuffer[newIndex++] = buffer[i];
|
||||
unCompressedBuffer.CopyTo( newBuffer, newIndex );
|
||||
buffer = newBuffer;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
private void EnsureData( int size )
|
||||
{
|
||||
while ((buffer.Length - index) < size)
|
||||
ReadNextPacket();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,386 +1,372 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using ByteFX.Data.Common;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an open connection to a MySQL Server database. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[System.Drawing.ToolboxBitmap( typeof(MySqlConnection), "MySqlClient.resources.connection.bmp")]
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
[ToolboxItem(true)]
|
||||
public sealed class MySqlConnection : Component, IDbConnection, ICloneable
|
||||
{
|
||||
internal ConnectionState state;
|
||||
private MySqlInternalConnection internalConnection;
|
||||
private MySqlDataReader dataReader;
|
||||
private NumberFormatInfo numberFormat;
|
||||
private MySqlConnectionString settings;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the state of the connection changes.
|
||||
/// </summary>
|
||||
public event StateChangeEventHandler StateChange;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new connection
|
||||
/// </summary>
|
||||
public MySqlConnection()
|
||||
{
|
||||
settings = new MySqlConnectionString("server=localhost");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new connection
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
public MySqlConnection(System.ComponentModel.IContainer container)
|
||||
{
|
||||
settings = new MySqlConnectionString();
|
||||
}
|
||||
|
||||
|
||||
// Have a constructor that takes a connection string.
|
||||
/// <summary>
|
||||
/// Creates a new connection using the specified connection string.
|
||||
/// </summary>
|
||||
/// <param name="connectString"></param>
|
||||
public MySqlConnection(string connectString)
|
||||
{
|
||||
settings = new MySqlConnectionString(connectString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the MySQL server to which to connect.
|
||||
/// </summary>
|
||||
#region Properties
|
||||
[Browsable(true)]
|
||||
public string DataSource
|
||||
{
|
||||
get { return settings.Server; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionTimeout"]/*'/>
|
||||
[Browsable(true)]
|
||||
public int ConnectionTimeout
|
||||
{
|
||||
get { return settings.ConnectionTimeout; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the current database or the database to be used after a connection is opened.
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
public string Database
|
||||
{
|
||||
get { return settings.Database; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this connection should use compression when communicating with the server.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool UseCompression
|
||||
{
|
||||
get { return settings.UseCompression; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current state of the connection.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public ConnectionState State
|
||||
{
|
||||
get { return state; }
|
||||
}
|
||||
|
||||
internal MySqlDataReader Reader
|
||||
{
|
||||
get { return dataReader; }
|
||||
set { dataReader = value; }
|
||||
}
|
||||
|
||||
internal MySqlInternalConnection InternalConnection
|
||||
{
|
||||
get { return internalConnection; }
|
||||
}
|
||||
|
||||
internal NumberFormatInfo NumberFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
if (numberFormat == null)
|
||||
{
|
||||
numberFormat = new NumberFormatInfo();
|
||||
numberFormat = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone();
|
||||
numberFormat.NumberDecimalSeparator = ".";
|
||||
}
|
||||
return numberFormat;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string containing the version of the MySQL server to which the client is connected.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string ServerVersion
|
||||
{
|
||||
get { return internalConnection.Driver.VersionString; }
|
||||
}
|
||||
|
||||
internal Encoding Encoding
|
||||
{
|
||||
get
|
||||
{
|
||||
if (internalConnection == null)
|
||||
return System.Text.Encoding.Default;
|
||||
else
|
||||
return internalConnection.Driver.Encoding;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the string used to connect to a MySQL Server database.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionString"]/*'/>
|
||||
#if WINDOWS
|
||||
[Editor("ByteFX.Data.MySqlClient.Design.ConnectionStringTypeEditor,MySqlClient.Design", typeof(System.Drawing.Design.UITypeEditor))]
|
||||
#endif
|
||||
[Browsable(true)]
|
||||
[Category("Data")]
|
||||
[Description("Information used to connect to a DataSource, such as 'Server=xxx;UserId=yyy;Password=zzz;Database=dbdb'.")]
|
||||
public string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
// Always return exactly what the user set.
|
||||
// Security-sensitive information may be removed.
|
||||
return settings.GetConnectionString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.State != ConnectionState.Closed)
|
||||
throw new MySqlException("Not allowed to change the 'ConnectionString' property while the connection (state=" + State + ").");
|
||||
|
||||
settings.SetConnectionString(value);
|
||||
if (internalConnection != null)
|
||||
internalConnection.Settings = settings;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Transactions
|
||||
/// <summary>
|
||||
/// Begins a database transaction.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlTransaction BeginTransaction()
|
||||
{
|
||||
if (state != ConnectionState.Open)
|
||||
throw new MySqlException("Invalid operation: The connection is closed");
|
||||
|
||||
MySqlTransaction t = new MySqlTransaction();
|
||||
t.Connection = this;
|
||||
InternalConnection.Driver.Send( DBCmd.QUERY, "BEGIN");
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
IDbTransaction IDbConnection.BeginTransaction()
|
||||
{
|
||||
return BeginTransaction();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
/// <returns></returns>
|
||||
public MySqlTransaction BeginTransaction(IsolationLevel level)
|
||||
{
|
||||
if (state != ConnectionState.Open)
|
||||
throw new MySqlException("Invalid operation: The connection is closed");
|
||||
|
||||
MySqlTransaction t = new MySqlTransaction();
|
||||
t.Connection = this;
|
||||
t.IsolationLevel = level;
|
||||
string cmd = "SET SESSION TRANSACTION ISOLATION LEVEL ";
|
||||
switch (level)
|
||||
{
|
||||
case IsolationLevel.ReadCommitted:
|
||||
cmd += "READ COMMITTED"; break;
|
||||
case IsolationLevel.ReadUncommitted:
|
||||
cmd += "READ UNCOMMITTED"; break;
|
||||
case IsolationLevel.RepeatableRead:
|
||||
cmd += "REPEATABLE READ"; break;
|
||||
case IsolationLevel.Serializable:
|
||||
cmd += "SERIALIZABLE"; break;
|
||||
case IsolationLevel.Chaos:
|
||||
throw new NotSupportedException("Chaos isolation level is not supported");
|
||||
}
|
||||
InternalConnection.Driver.Send( DBCmd.QUERY, cmd );
|
||||
InternalConnection.Driver.Send( DBCmd.QUERY, "BEGIN");
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
/// <returns></returns>
|
||||
IDbTransaction IDbConnection.BeginTransaction(IsolationLevel level)
|
||||
{
|
||||
return BeginTransaction(level);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Changes the current database for an open MySqlConnection.
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
public void ChangeDatabase(string dbName)
|
||||
{
|
||||
if (state != ConnectionState.Open)
|
||||
throw new MySqlException("Invalid operation: The connection is closed");
|
||||
|
||||
//TODOinternalConnection.ChangeDatabase( dbName );
|
||||
InternalConnection.Driver.Send( DBCmd.INIT_DB, dbName );
|
||||
}
|
||||
|
||||
internal void SetState( ConnectionState newState )
|
||||
{
|
||||
ConnectionState oldState = state;
|
||||
state = newState;
|
||||
if (this.StateChange != null)
|
||||
StateChange(this, new StateChangeEventArgs( oldState, newState ));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a database connection with the property settings specified by the ConnectionString.
|
||||
/// </summary>
|
||||
public void Open()
|
||||
{
|
||||
if (state == ConnectionState.Open)
|
||||
throw new MySqlException("error connecting: The connection is already Open (state=Open).");
|
||||
|
||||
SetState( ConnectionState.Connecting );
|
||||
|
||||
try
|
||||
{
|
||||
if (settings.Pooling)
|
||||
{
|
||||
internalConnection = MySqlPoolManager.GetConnection( settings );
|
||||
}
|
||||
else
|
||||
{
|
||||
internalConnection = new MySqlInternalConnection( settings );
|
||||
internalConnection.Open();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SetState( ConnectionState.Closed );
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
||||
SetState( ConnectionState.Open );
|
||||
internalConnection.SetServerVariables(this);
|
||||
if (settings.Database != null && settings.Database != String.Empty)
|
||||
ChangeDatabase( settings.Database );
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Closes the connection to the database. This is the preferred method of closing any open connection.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
if (state == ConnectionState.Closed) return;
|
||||
|
||||
if (dataReader != null)
|
||||
dataReader.Close();
|
||||
|
||||
if (settings.Pooling)
|
||||
MySqlPoolManager.ReleaseConnection( internalConnection );
|
||||
else
|
||||
internalConnection.Close();
|
||||
|
||||
SetState( ConnectionState.Closed );
|
||||
}
|
||||
|
||||
IDbCommand IDbConnection.CreateCommand()
|
||||
{
|
||||
return CreateCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and returns a MySqlCommand object associated with the MySqlConnection.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlCommand CreateCommand()
|
||||
{
|
||||
// Return a new instance of a command object.
|
||||
MySqlCommand c = new MySqlCommand();
|
||||
c.Connection = this;
|
||||
return c;
|
||||
}
|
||||
|
||||
#region ICloneable
|
||||
/// <summary>
|
||||
/// Creates a new MySqlConnection object with the exact same ConnectionString value
|
||||
/// </summary>
|
||||
/// <returns>A cloned MySqlConnection object</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
MySqlConnection clone = new MySqlConnection();
|
||||
clone.ConnectionString = this.ConnectionString;
|
||||
//TODO: how deep should this go?
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposeable
|
||||
/// <summary>
|
||||
/// Releases the resources used by the MySqlConnection.
|
||||
/// </summary>
|
||||
public new void Dispose()
|
||||
{
|
||||
if (State == ConnectionState.Open)
|
||||
Close();
|
||||
base.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using ByteFX.Data.Common;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an open connection to a MySQL Server database. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[System.Drawing.ToolboxBitmap( typeof(MySqlConnection), "Designers.connection.bmp")]
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
[ToolboxItem(true)]
|
||||
public sealed class MySqlConnection : Component, IDbConnection, ICloneable
|
||||
{
|
||||
internal ConnectionState state;
|
||||
private MySqlInternalConnection internalConnection;
|
||||
private MySqlDataReader dataReader;
|
||||
private NumberFormatInfo numberFormat;
|
||||
private MySqlConnectionString settings;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the state of the connection changes.
|
||||
/// </summary>
|
||||
public event StateChangeEventHandler StateChange;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new connection
|
||||
/// </summary>
|
||||
public MySqlConnection()
|
||||
{
|
||||
settings = new MySqlConnectionString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new connection
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
public MySqlConnection(System.ComponentModel.IContainer container)
|
||||
{
|
||||
settings = new MySqlConnectionString();
|
||||
}
|
||||
|
||||
|
||||
// Have a constructor that takes a connection string.
|
||||
/// <summary>
|
||||
/// Creates a new connection using the specified connection string.
|
||||
/// </summary>
|
||||
/// <param name="connectString"></param>
|
||||
public MySqlConnection(string connectString)
|
||||
{
|
||||
settings = new MySqlConnectionString(connectString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the MySQL server to which to connect.
|
||||
/// </summary>
|
||||
#region Properties
|
||||
[Browsable(true)]
|
||||
public string DataSource
|
||||
{
|
||||
get { return settings.Host; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionTimeout"]/*'/>
|
||||
[Browsable(true)]
|
||||
public int ConnectionTimeout
|
||||
{
|
||||
get { return settings.ConnectTimeout; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the current database or the database to be used after a connection is opened.
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
public string Database
|
||||
{
|
||||
get { return settings.Database; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this connection should use compression when communicating with the server.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool UseCompression
|
||||
{
|
||||
get { return settings.UseCompression; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current state of the connection.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public ConnectionState State
|
||||
{
|
||||
get { return state; }
|
||||
}
|
||||
|
||||
internal MySqlDataReader Reader
|
||||
{
|
||||
get { return dataReader; }
|
||||
set { dataReader = value; }
|
||||
}
|
||||
|
||||
internal MySqlInternalConnection InternalConnection
|
||||
{
|
||||
get { return internalConnection; }
|
||||
}
|
||||
|
||||
internal NumberFormatInfo NumberFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
if (numberFormat == null)
|
||||
{
|
||||
numberFormat = new NumberFormatInfo();
|
||||
numberFormat = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone();
|
||||
numberFormat.NumberDecimalSeparator = ".";
|
||||
}
|
||||
return numberFormat;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string containing the version of the MySQL server to which the client is connected.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string ServerVersion
|
||||
{
|
||||
get { return internalConnection.Driver.Version; }
|
||||
}
|
||||
|
||||
internal Encoding Encoding
|
||||
{
|
||||
get
|
||||
{
|
||||
if (internalConnection == null)
|
||||
return System.Text.Encoding.Default;
|
||||
else
|
||||
return internalConnection.Driver.Encoding;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the string used to connect to a MySQL Server database.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionString"]/*'/>
|
||||
#if WINDOWS
|
||||
[Editor(typeof(Designers.ConnectionStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
|
||||
#endif
|
||||
[Browsable(true)]
|
||||
[Category("Data")]
|
||||
public string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
// Always return exactly what the user set.
|
||||
// Security-sensitive information may be removed.
|
||||
return settings.ConnectString;
|
||||
}
|
||||
set
|
||||
{
|
||||
settings.ConnectString = value;
|
||||
if (internalConnection != null)
|
||||
internalConnection.Settings = settings;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Transactions
|
||||
/// <summary>
|
||||
/// Begins a database transaction.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlTransaction BeginTransaction()
|
||||
{
|
||||
if (state != ConnectionState.Open)
|
||||
throw new MySqlException("Invalid operation: The connection is closed");
|
||||
|
||||
MySqlTransaction t = new MySqlTransaction();
|
||||
t.Connection = this;
|
||||
InternalConnection.Driver.SendCommand( DBCmd.QUERY, "BEGIN");
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
IDbTransaction IDbConnection.BeginTransaction()
|
||||
{
|
||||
return BeginTransaction();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
/// <returns></returns>
|
||||
public MySqlTransaction BeginTransaction(IsolationLevel level)
|
||||
{
|
||||
if (state != ConnectionState.Open)
|
||||
throw new MySqlException("Invalid operation: The connection is closed");
|
||||
|
||||
MySqlTransaction t = new MySqlTransaction();
|
||||
t.Connection = this;
|
||||
t.IsolationLevel = level;
|
||||
string cmd = "SET SESSION TRANSACTION ISOLATION LEVEL ";
|
||||
switch (level)
|
||||
{
|
||||
case IsolationLevel.ReadCommitted:
|
||||
cmd += "READ COMMITTED"; break;
|
||||
case IsolationLevel.ReadUncommitted:
|
||||
cmd += "READ UNCOMMITTED"; break;
|
||||
case IsolationLevel.RepeatableRead:
|
||||
cmd += "REPEATABLE READ"; break;
|
||||
case IsolationLevel.Serializable:
|
||||
cmd += "SERIALIZABLE"; break;
|
||||
case IsolationLevel.Chaos:
|
||||
throw new NotSupportedException("Chaos isolation level is not supported");
|
||||
}
|
||||
InternalConnection.Driver.SendCommand( DBCmd.QUERY, cmd );
|
||||
InternalConnection.Driver.SendCommand( DBCmd.QUERY, "BEGIN");
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
/// <returns></returns>
|
||||
IDbTransaction IDbConnection.BeginTransaction(IsolationLevel level)
|
||||
{
|
||||
return BeginTransaction(level);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Changes the current database for an open MySqlConnection.
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
public void ChangeDatabase(string dbName)
|
||||
{
|
||||
if (state != ConnectionState.Open)
|
||||
throw new MySqlException("Invalid operation: The connection is closed");
|
||||
|
||||
//TODOinternalConnection.ChangeDatabase( dbName );
|
||||
InternalConnection.Driver.SendCommand( DBCmd.INIT_DB, dbName );
|
||||
}
|
||||
|
||||
internal void SetState( ConnectionState newState )
|
||||
{
|
||||
ConnectionState oldState = state;
|
||||
state = newState;
|
||||
if (this.StateChange != null)
|
||||
StateChange(this, new StateChangeEventArgs( oldState, newState ));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a database connection with the property settings specified by the ConnectionString.
|
||||
/// </summary>
|
||||
public void Open()
|
||||
{
|
||||
if (state == ConnectionState.Open)
|
||||
throw new MySqlException("error connecting: The connection is already Open (state=Open).");
|
||||
|
||||
SetState( ConnectionState.Connecting );
|
||||
|
||||
if (settings.Pooling)
|
||||
{
|
||||
internalConnection = MySqlPoolManager.GetConnection( settings );
|
||||
}
|
||||
else
|
||||
{
|
||||
internalConnection = new MySqlInternalConnection( settings );
|
||||
internalConnection.Open();
|
||||
}
|
||||
|
||||
SetState( ConnectionState.Open );
|
||||
internalConnection.SetServerVariables(this);
|
||||
ChangeDatabase( settings.Database );
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Closes the connection to the database. This is the preferred method of closing any open connection.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
if (state == ConnectionState.Closed) return;
|
||||
|
||||
if (dataReader != null)
|
||||
dataReader.Close();
|
||||
|
||||
if (settings.Pooling)
|
||||
MySqlPoolManager.ReleaseConnection( internalConnection );
|
||||
else
|
||||
internalConnection.Close();
|
||||
|
||||
SetState( ConnectionState.Closed );
|
||||
}
|
||||
|
||||
IDbCommand IDbConnection.CreateCommand()
|
||||
{
|
||||
return CreateCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and returns a MySqlCommand object associated with the MySqlConnection.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlCommand CreateCommand()
|
||||
{
|
||||
// Return a new instance of a command object.
|
||||
MySqlCommand c = new MySqlCommand();
|
||||
c.Connection = this;
|
||||
return c;
|
||||
}
|
||||
|
||||
#region ICloneable
|
||||
/// <summary>
|
||||
/// Creates a new MySqlConnection object with the exact same ConnectionString value
|
||||
/// </summary>
|
||||
/// <returns>A cloned MySqlConnection object</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
MySqlConnection clone = new MySqlConnection();
|
||||
clone.ConnectionString = this.ConnectionString;
|
||||
//TODO: how deep should this go?
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposeable
|
||||
/// <summary>
|
||||
/// Releases the resources used by the MySqlConnection.
|
||||
/// </summary>
|
||||
public new void Dispose()
|
||||
{
|
||||
if (State == ConnectionState.Open)
|
||||
Close();
|
||||
base.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="ResMimeType">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="Version">
|
||||
<value>1.0.0.0</value>
|
||||
</resheader>
|
||||
<resheader name="Reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="Writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="ResMimeType">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="Version">
|
||||
<value>1.0.0.0</value>
|
||||
</resheader>
|
||||
<resheader name="Reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="Writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,117 +1,129 @@
|
||||
using System;
|
||||
using ByteFX.Data.Common;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
internal sealed class MySqlInternalConnection
|
||||
{
|
||||
MySqlConnectionString settings;
|
||||
Driver driver;
|
||||
DateTime createTime;
|
||||
bool serverVariablesSet;
|
||||
|
||||
public MySqlInternalConnection( MySqlConnectionString connectString )
|
||||
{
|
||||
settings = connectString;
|
||||
serverVariablesSet = false;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public MySqlConnectionString Settings
|
||||
{
|
||||
get { return settings; }
|
||||
set { settings = value; }
|
||||
}
|
||||
|
||||
internal Driver Driver
|
||||
{
|
||||
get { return driver; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public bool IsAlive()
|
||||
{
|
||||
try
|
||||
{
|
||||
CommandResult result = driver.Send( DBCmd.PING, (byte[])null );
|
||||
// we don't care about the result. The fact that it responded is enough
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsTooOld()
|
||||
{
|
||||
TimeSpan ts = DateTime.Now.Subtract( createTime );
|
||||
if (ts.Seconds > settings.ConnectionLifetime)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I don't like this setup but can't think of a better way of doing
|
||||
/// right now.
|
||||
/// </summary>
|
||||
/// <param name="connection"></param>
|
||||
public void SetServerVariables(MySqlConnection connection)
|
||||
{
|
||||
if (serverVariablesSet) return;
|
||||
|
||||
// retrieve the encoding that should be used for character data
|
||||
MySqlCommand cmd = new MySqlCommand("show variables like 'max_allowed_packet'", connection);
|
||||
try
|
||||
{
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
reader.Read();
|
||||
driver.MaxPacketSize = reader.GetInt64( 1 );
|
||||
reader.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
driver.MaxPacketSize = 1047552;
|
||||
}
|
||||
|
||||
cmd.CommandText = "show variables like 'character_set'";
|
||||
driver.Encoding = System.Text.Encoding.Default;
|
||||
|
||||
try
|
||||
{
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
driver.Encoding = CharSetMap.GetEncoding( reader.GetString(1) );
|
||||
reader.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new MySqlException("Failure to initialize connection");
|
||||
}
|
||||
|
||||
serverVariablesSet = true;
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
driver = new Driver();
|
||||
driver.Open( settings );
|
||||
|
||||
createTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
driver.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using ByteFX.Data.Common;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
internal sealed class MySqlInternalConnection
|
||||
{
|
||||
MySqlConnectionString settings;
|
||||
Driver driver;
|
||||
DateTime createTime;
|
||||
bool serverVariablesSet;
|
||||
|
||||
public MySqlInternalConnection( MySqlConnectionString connectString )
|
||||
{
|
||||
settings = connectString;
|
||||
serverVariablesSet = false;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public MySqlConnectionString Settings
|
||||
{
|
||||
get { return settings; }
|
||||
set { settings = value; }
|
||||
}
|
||||
|
||||
internal Driver Driver
|
||||
{
|
||||
get { return driver; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public bool IsAlive()
|
||||
{
|
||||
Packet packet;
|
||||
try
|
||||
{
|
||||
byte[] bytes = driver.Encoding.GetBytes("select connection_id();");
|
||||
packet = driver.SendSql( bytes );
|
||||
// we have to read for two last packets since MySql sends
|
||||
// us a last packet after schema and again after rows
|
||||
// I will likely change this later to have the driver just
|
||||
// return schema in one very large packet.
|
||||
while (! packet.IsLastPacket())
|
||||
packet = driver.ReadPacket();
|
||||
|
||||
// now read off the resultset
|
||||
packet = driver.ReadPacket();
|
||||
while (! packet.IsLastPacket())
|
||||
packet = driver.ReadPacket();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsTooOld()
|
||||
{
|
||||
TimeSpan ts = DateTime.Now.Subtract( createTime );
|
||||
if (ts.Seconds > settings.ConnectionLifetime)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I don't like this setup but can't think of a better way of doing
|
||||
/// right now.
|
||||
/// </summary>
|
||||
/// <param name="connection"></param>
|
||||
public void SetServerVariables(MySqlConnection connection)
|
||||
{
|
||||
if (serverVariablesSet) return;
|
||||
|
||||
// retrieve the encoding that should be used for character data
|
||||
MySqlCommand cmd = new MySqlCommand("show variables like 'max_allowed_packet'", connection);
|
||||
try
|
||||
{
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
reader.Read();
|
||||
driver.MaxPacketSize = reader.GetInt64( 1 );
|
||||
reader.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
driver.MaxPacketSize = 1047552;
|
||||
}
|
||||
|
||||
cmd.CommandText = "show variables like 'character_set'";
|
||||
driver.Encoding = System.Text.Encoding.Default;
|
||||
|
||||
try
|
||||
{
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
driver.Encoding = CharSetMap.GetEncoding( reader.GetString(1) );
|
||||
reader.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new MySqlException("Failure to initialize connection");
|
||||
}
|
||||
|
||||
serverVariablesSet = true;
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
driver = new Driver();
|
||||
driver.Open( settings );
|
||||
|
||||
createTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
driver.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,286 +1,58 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using ByteFX.Data.Common;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
internal enum ConnectionProtocol
|
||||
{
|
||||
Sockets, NamedPipe, UnixSocket
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for MySqlConnectionString.
|
||||
/// </summary>
|
||||
internal sealed class MySqlConnectionString : DBConnectionString
|
||||
{
|
||||
private Hashtable defaults;
|
||||
|
||||
public MySqlConnectionString() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public MySqlConnectionString(string connectString) : this()
|
||||
{
|
||||
SetConnectionString( connectString );
|
||||
}
|
||||
|
||||
#region Server Properties
|
||||
[Browsable(false)]
|
||||
public string Name
|
||||
{
|
||||
get { return connectionName; }
|
||||
set { connectionName = value; }
|
||||
}
|
||||
|
||||
|
||||
[Category("Connection")]
|
||||
[Description("The name or IP address of the server to use")]
|
||||
public string Server
|
||||
{
|
||||
get { return GetString("host"); }
|
||||
set { keyValues["host"] = value; }
|
||||
}
|
||||
|
||||
[Category("Connection")]
|
||||
[Description("Port to use when connecting with sockets")]
|
||||
[DefaultValue(3306)]
|
||||
public int Port
|
||||
{
|
||||
get { return GetInt("port"); }
|
||||
set { keyValues["port"] = value; }
|
||||
}
|
||||
|
||||
[Category("Connection")]
|
||||
[Description("Protocol to use for connection to MySQL")]
|
||||
[DefaultValue(ConnectionProtocol.Sockets)]
|
||||
public ConnectionProtocol Protocol
|
||||
{
|
||||
get { return (ConnectionProtocol)keyValues["protocol"]; }
|
||||
set { keyValues["protocol"] = value; }
|
||||
}
|
||||
|
||||
[Category("Connection")]
|
||||
[Description("Name of pipe to use when connecting with named pipes (Win32 only)")]
|
||||
public string PipeName
|
||||
{
|
||||
get { return GetString("use pipe"); }
|
||||
set { keyValues["use pipe"] = value; }
|
||||
}
|
||||
|
||||
[Category("Connection")]
|
||||
[Description("Should the connection ues compression")]
|
||||
[DefaultValue(false)]
|
||||
public bool UseCompression
|
||||
{
|
||||
get { return GetBool("compress"); }
|
||||
set { keyValues["compress"] = value; }
|
||||
}
|
||||
|
||||
[Category("Connection")]
|
||||
[Description("Database to use initially")]
|
||||
[Editor("ByteFX.Data.MySqlClient.Design.DatabaseTypeEditor,MySqlClient.Design", typeof(System.Drawing.Design.UITypeEditor))]
|
||||
public string Database
|
||||
{
|
||||
get { return GetString("database"); }
|
||||
set { keyValues["database"] = value; }
|
||||
}
|
||||
|
||||
[Category("Connection")]
|
||||
[Description("Number of seconds to wait for the connection to succeed")]
|
||||
[DefaultValue(15)]
|
||||
public int ConnectionTimeout
|
||||
{
|
||||
get { return GetInt("connect timeout"); }
|
||||
set { keyValues["connect timeout"] = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Authentication Properties
|
||||
|
||||
[Category("Authentication")]
|
||||
[Description("The username to connect as")]
|
||||
public string UserId
|
||||
{
|
||||
get { return GetString("user id"); }
|
||||
set { keyValues["user id"] = value; }
|
||||
}
|
||||
|
||||
[Category("Authentication")]
|
||||
[Description("The password to use for authentication")]
|
||||
public string Password
|
||||
{
|
||||
get { return GetString("password"); }
|
||||
set { keyValues["password"] = value; }
|
||||
}
|
||||
|
||||
[Category("Authentication")]
|
||||
[Description("Should the connection use SSL. This currently has no effect.")]
|
||||
[DefaultValue(false)]
|
||||
public bool UseSSL
|
||||
{
|
||||
get { return GetBool("use ssl"); }
|
||||
set { keyValues["use ssl"] = value; }
|
||||
}
|
||||
|
||||
[Category("Authentication")]
|
||||
[Description("Show user password in connection string")]
|
||||
[DefaultValue(false)]
|
||||
public bool PersistSecurityInfo
|
||||
{
|
||||
get { return GetBool("persist security info"); }
|
||||
set { keyValues["persist security info"] = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Pooling Properties
|
||||
|
||||
[Category("Pooling")]
|
||||
[Description("Should the connection support pooling")]
|
||||
[DefaultValue(true)]
|
||||
public bool Pooling
|
||||
{
|
||||
get { return GetBool("pooling"); }
|
||||
set { keyValues["pooling"] = value; }
|
||||
}
|
||||
|
||||
[Category("Pooling")]
|
||||
[Description("Minimum number of connections to have in this pool")]
|
||||
[DefaultValue(0)]
|
||||
public int MinPoolSize
|
||||
{
|
||||
get { return GetInt("min pool size"); }
|
||||
set { keyValues["min pool size"] = value; }
|
||||
}
|
||||
|
||||
[Category("Pooling")]
|
||||
[Description("Maximum number of connections to have in this pool")]
|
||||
[DefaultValue(100)]
|
||||
public int MaxPoolSize
|
||||
{
|
||||
get { return GetInt("max pool size"); }
|
||||
set { keyValues["max pool size"] = value; }
|
||||
}
|
||||
|
||||
[Category("Pooling")]
|
||||
[Description("Maximum number of seconds a connection should live. This is checked when a connection is returned to the pool.")]
|
||||
[DefaultValue(0)]
|
||||
public int ConnectionLifetime
|
||||
{
|
||||
get { return GetInt("connection lifetime"); }
|
||||
set { keyValues["connection lifetime"] = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Takes a given connection string and returns it, possible
|
||||
/// stripping out the password info
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetConnectionString()
|
||||
{
|
||||
if (connectString == null) return CreateConnectionString();
|
||||
|
||||
StringBuilder str = new StringBuilder();
|
||||
Hashtable ht = ParseKeyValuePairs( connectString );
|
||||
|
||||
if (! PersistSecurityInfo)
|
||||
ht.Remove("password");
|
||||
|
||||
foreach( string key in ht.Keys)
|
||||
str.AppendFormat("{0}={1};", key, ht[key]);
|
||||
|
||||
if (str.Length > 0)
|
||||
str.Remove( str.Length-1, 1 );
|
||||
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the values in the keyValues hash to create a
|
||||
/// connection string
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string CreateConnectionString()
|
||||
{
|
||||
string cStr = String.Empty;
|
||||
|
||||
Hashtable values = (Hashtable)keyValues.Clone();
|
||||
Hashtable defaultValues = GetDefaultValues();
|
||||
|
||||
if (!PersistSecurityInfo && values.Contains("password") )
|
||||
values.Remove( "password" );
|
||||
|
||||
// we always return the server key. It's not needed but
|
||||
// seems weird for it not to be there.
|
||||
cStr = "server=" + values["host"] + ";";
|
||||
values.Remove("server");
|
||||
|
||||
foreach (string key in values.Keys)
|
||||
{
|
||||
if (!values[key].Equals( defaultValues[key]))
|
||||
cStr += key + "=" + values[key] + ";";
|
||||
}
|
||||
|
||||
return cStr;
|
||||
}
|
||||
|
||||
protected override Hashtable GetDefaultValues()
|
||||
{
|
||||
defaults = base.GetDefaultValues();
|
||||
if (defaults == null)
|
||||
{
|
||||
defaults = new Hashtable();
|
||||
defaults["host"] = "localhost";
|
||||
defaults["connect lifetime"] = 0;
|
||||
defaults["user id"] = String.Empty;
|
||||
defaults["password"] = String.Empty;
|
||||
defaults["pooling"] = true;
|
||||
defaults["min pool size"] = 0;
|
||||
defaults["protocol"] = ConnectionProtocol.Sockets;
|
||||
defaults["max pool size"] = 100;
|
||||
defaults["connect timeout"] = 15;
|
||||
defaults["port"] = 3306;
|
||||
defaults["useSSL"] = false;
|
||||
defaults["compress"] = false;
|
||||
defaults["persist Security Info"] = false;
|
||||
}
|
||||
return (Hashtable)defaults.Clone();
|
||||
}
|
||||
|
||||
protected override bool ConnectionParameterParsed(Hashtable hash, string key, string value)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case "use compression":
|
||||
case "compress":
|
||||
hash["compress"] =
|
||||
value.ToLower() == "yes" || value.ToLower() == "true";
|
||||
return true;
|
||||
|
||||
case "protocol":
|
||||
if (value == "socket" || value == "tcp")
|
||||
hash["protocol"] = ConnectionProtocol.Sockets;
|
||||
else if (value == "pipe")
|
||||
hash["protocol"] = ConnectionProtocol.NamedPipe;
|
||||
else if (value == "unix")
|
||||
hash["protocol"] = ConnectionProtocol.UnixSocket;
|
||||
return true;
|
||||
|
||||
case "use pipe":
|
||||
case "pipe":
|
||||
hash["use pipe"] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (! base.ConnectionParameterParsed(hash, key, value))
|
||||
throw new ArgumentException("Keyword not supported: '" + key + "'");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using ByteFX.Data.Common;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MySqlConnectionString.
|
||||
/// </summary>
|
||||
internal sealed class MySqlConnectionString : DBConnectionString
|
||||
{
|
||||
private bool useCompression = false;
|
||||
|
||||
public MySqlConnectionString()
|
||||
{
|
||||
connectLifetime = 0;
|
||||
pooling = true;
|
||||
minPoolSize = 0;
|
||||
maxPoolSize = 100;
|
||||
connectTimeout = 15;
|
||||
port = 3306;
|
||||
}
|
||||
|
||||
public MySqlConnectionString(string connectString) : base(connectString)
|
||||
{
|
||||
connectLifetime = 0;
|
||||
pooling = true;
|
||||
minPoolSize = 0;
|
||||
maxPoolSize = 100;
|
||||
connectTimeout = 15;
|
||||
port = 3306;
|
||||
Parse();
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public bool UseCompression
|
||||
{
|
||||
get { return useCompression; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void ConnectionParameterParsed(string key, string value)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case "use compression":
|
||||
case "compress":
|
||||
if (value.ToLower() == "no" || value.ToLower() == "false")
|
||||
useCompression = false;
|
||||
else
|
||||
useCompression = true;
|
||||
break;
|
||||
}
|
||||
|
||||
base.ConnectionParameterParsed(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,63 +1,53 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when MySQL returns an error. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlException.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[Serializable]
|
||||
public sealed class MySqlException : SystemException
|
||||
{
|
||||
private int errorCode;
|
||||
|
||||
internal MySqlException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException( string msg, Exception ex ) : base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException()
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException(string msg, int errno) : base(msg)
|
||||
{
|
||||
errorCode = errno;
|
||||
}
|
||||
|
||||
internal MySqlException(SerializationInfo info,
|
||||
StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a number that identifies the type of error.
|
||||
/// </summary>
|
||||
public int Number
|
||||
{
|
||||
get { return errorCode; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when MySQL returns an error. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlException.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[Serializable]
|
||||
public sealed class MySqlException : SystemException
|
||||
{
|
||||
internal MySqlException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException( string msg, Exception ex ) : base(msg, ex)
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException()
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException(string msg, int errno) : base(msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal MySqlException(SerializationInfo info,
|
||||
StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,463 +1,397 @@
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using ByteFX.Data.Common;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
internal enum ColumnFlags : int
|
||||
{
|
||||
NOT_NULL = 1,
|
||||
PRIMARY_KEY = 2,
|
||||
UNIQUE_KEY = 4,
|
||||
MULTIPLE_KEY = 8,
|
||||
BLOB = 16,
|
||||
UNSIGNED = 32,
|
||||
ZERO_FILL = 64,
|
||||
BINARY = 128,
|
||||
ENUM = 256,
|
||||
AUTO_INCREMENT = 512,
|
||||
TIMESTAMP = 1024,
|
||||
SET = 2048,
|
||||
NUMBER = 32768
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Field.
|
||||
/// </summary>
|
||||
internal class MySqlField : Common.Field
|
||||
{
|
||||
protected MySqlDbType colType;
|
||||
protected ColumnFlags colFlags;
|
||||
protected int colDecimals;
|
||||
protected Encoding encoding;
|
||||
private static NumberFormatInfo numberFormat = null;
|
||||
|
||||
protected byte[] buffer;
|
||||
protected long bufIndex;
|
||||
protected long bufLength;
|
||||
|
||||
public MySqlField(Encoding encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
if (numberFormat == null)
|
||||
{
|
||||
numberFormat = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone();
|
||||
numberFormat.NumberDecimalSeparator = ".";
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Buffer
|
||||
{
|
||||
get { return buffer; }
|
||||
}
|
||||
|
||||
public long BufferIndex
|
||||
{
|
||||
get { return bufIndex; }
|
||||
}
|
||||
|
||||
public long BufferLength
|
||||
{
|
||||
get { return bufLength; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CopyBuffer makes a copy of the byte buffer given to us while
|
||||
/// the rowset was being read
|
||||
/// </summary>
|
||||
private void CopyBuffer()
|
||||
{
|
||||
byte[] newbuf = new byte[ bufLength ];
|
||||
long oldIndex = bufIndex;
|
||||
for (long i=0; i < bufLength; i++)
|
||||
newbuf[i] = buffer[ oldIndex++ ];
|
||||
bufIndex = 0;
|
||||
buffer = newbuf;
|
||||
value = newbuf;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetValue returns an object that represents the value of this field.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public object GetValue()
|
||||
{
|
||||
// if our value is a byte buffer and we are using only
|
||||
// a part of that buffer, then we need to make a copy
|
||||
if (value is byte[] && (bufIndex > 0 || bufLength < buffer.Length))
|
||||
CopyBuffer();
|
||||
return value;
|
||||
}
|
||||
|
||||
public MySqlDbType Type
|
||||
{
|
||||
get { return colType; }
|
||||
set { colType = value; }
|
||||
}
|
||||
|
||||
public int NumericPrecision
|
||||
{
|
||||
get
|
||||
{
|
||||
if (colType == MySqlDbType.Decimal)
|
||||
return colLen;
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int NumericScale
|
||||
{
|
||||
get
|
||||
{
|
||||
if (colType == MySqlDbType.Decimal)
|
||||
return colDecimals;
|
||||
return -1;
|
||||
}
|
||||
set
|
||||
{
|
||||
colDecimals = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ColumnFlags Flags
|
||||
{
|
||||
get { return colFlags; }
|
||||
set { colFlags = value; }
|
||||
}
|
||||
|
||||
public bool IsAutoIncrement()
|
||||
{
|
||||
return (colFlags & ColumnFlags.AUTO_INCREMENT) > 0;
|
||||
}
|
||||
|
||||
public bool IsNumeric()
|
||||
{
|
||||
return (colFlags & ColumnFlags.NUMBER) > 0;
|
||||
}
|
||||
|
||||
public bool AllowsNull()
|
||||
{
|
||||
return (colFlags & ColumnFlags.NOT_NULL) == 0;
|
||||
}
|
||||
|
||||
public bool IsUnique()
|
||||
{
|
||||
return (colFlags & ColumnFlags.UNIQUE_KEY) > 0;
|
||||
}
|
||||
|
||||
public bool IsPrimaryKey()
|
||||
{
|
||||
return (colFlags & ColumnFlags.PRIMARY_KEY) > 0;
|
||||
}
|
||||
|
||||
public bool IsBlob()
|
||||
{
|
||||
return (colFlags & ColumnFlags.BLOB) > 0;
|
||||
}
|
||||
|
||||
public bool IsBinary()
|
||||
{
|
||||
return (colFlags & ColumnFlags.BINARY) > 0;
|
||||
}
|
||||
|
||||
public bool IsUnsigned()
|
||||
{
|
||||
return (colFlags & ColumnFlags.UNSIGNED) > 0;
|
||||
}
|
||||
|
||||
public void SetValueData( byte[] buf, long index, long len, DBVersion version )
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
value = DBNull.Value;
|
||||
buffer = null;
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = buf;
|
||||
bufIndex = index;
|
||||
bufLength = len;
|
||||
|
||||
// if it is a blob and binary, then GetBytes is the way to go
|
||||
if ( IsBlob() && IsBinary() )
|
||||
{
|
||||
dbType = DbType.Binary;
|
||||
value = buffer;
|
||||
return;
|
||||
}
|
||||
|
||||
string sValue = encoding.GetString( buf, (int)index, (int)len );
|
||||
|
||||
switch(colType)
|
||||
{
|
||||
case MySqlDbType.Byte:
|
||||
if (IsUnsigned())
|
||||
value = Byte.Parse( sValue );
|
||||
else
|
||||
value = SByte.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Short:
|
||||
if (IsUnsigned())
|
||||
value = UInt16.Parse( sValue );
|
||||
else
|
||||
value = Int16.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Int :
|
||||
case MySqlDbType.Int24:
|
||||
if (IsUnsigned())
|
||||
value = UInt32.Parse( sValue );
|
||||
else
|
||||
value = Int32.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.BigInt:
|
||||
if (IsUnsigned())
|
||||
value = UInt64.Parse( sValue );
|
||||
else
|
||||
value = Int64.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Decimal:
|
||||
value = Decimal.Parse( sValue , numberFormat );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Float:
|
||||
value = Convert.ToSingle( sValue, numberFormat );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Double:
|
||||
value = Convert.ToDouble( sValue, numberFormat );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Year:
|
||||
value = Int32.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Date:
|
||||
ParseDateValue( "0000-00-00", "yyyy-MM-dd", sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Datetime:
|
||||
ParseDateValue( "0000-00-00 00:00:00", "yyyy-MM-dd HH:mm:ss", sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Time:
|
||||
if (sValue.Equals("00:00:00"))
|
||||
value = DBNull.Value;
|
||||
else
|
||||
value = TimeSpan.Parse(sValue);
|
||||
break;
|
||||
|
||||
case MySqlDbType.Timestamp:
|
||||
// MySql 4.1.0 and later use DateTime format for timestamp
|
||||
if (version.isAtLeast(4,1,0))
|
||||
{
|
||||
ParseDateValue( "0000-00-00 00:00:00", "yyyy-MM-dd HH:mm:ss", sValue );
|
||||
return;
|
||||
}
|
||||
|
||||
string pattern;
|
||||
string null_value = "00000000000000";
|
||||
switch (ColumnLength)
|
||||
{
|
||||
case 2: pattern = "yy"; break;
|
||||
case 4: pattern = "yyMM"; break;
|
||||
case 6: pattern = "yyMMdd"; break;
|
||||
case 8: pattern = "yyyyMMdd"; break;
|
||||
case 10: pattern = "yyMMddHHmm"; break;
|
||||
case 12: pattern = "yyMMddHHmmss"; break;
|
||||
case 14:
|
||||
default: pattern = "yyyyMMddHHmmss"; break;
|
||||
}
|
||||
|
||||
if (ColumnLength > 2 && sValue.Equals( null_value.Substring(0, ColumnLength)))
|
||||
value = DBNull.Value;
|
||||
else
|
||||
value = DateTime.ParseExact( sValue, pattern, new System.Globalization.DateTimeFormatInfo());
|
||||
break;
|
||||
|
||||
case MySqlDbType.String:
|
||||
case MySqlDbType.VarChar:
|
||||
case MySqlDbType.Blob:
|
||||
case MySqlDbType.TinyBlob:
|
||||
case MySqlDbType.LongBlob:
|
||||
case MySqlDbType.MediumBlob:
|
||||
value = sValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ParseDateValue( string nullpattern, string pattern, string data )
|
||||
{
|
||||
if ( data.Equals (nullpattern) )
|
||||
value = DBNull.Value;
|
||||
else
|
||||
value = DateTime.ParseExact( data, pattern, new System.Globalization.DateTimeFormatInfo());
|
||||
}
|
||||
|
||||
public string GetFieldTypeName()
|
||||
{
|
||||
switch (colType)
|
||||
{
|
||||
case MySqlDbType.Decimal: return "DECIMAL";
|
||||
case MySqlDbType.Byte: return "TINY";
|
||||
case MySqlDbType.Short: return "SHORT";
|
||||
case MySqlDbType.Int: return "INTEGER";
|
||||
case MySqlDbType.Float: return "FLOAT";
|
||||
case MySqlDbType.Double: return "DOUBLE";
|
||||
case MySqlDbType.Null: return "NULL";
|
||||
case MySqlDbType.Timestamp: return "TIMESTAMP";
|
||||
case MySqlDbType.BigInt: return "BIGINT";
|
||||
case MySqlDbType.Int24: return "INT24";
|
||||
case MySqlDbType.Date: return "DATE";
|
||||
case MySqlDbType.Time: return "TIME";
|
||||
case MySqlDbType.Datetime: return "DATETIME";
|
||||
case MySqlDbType.Year: return "YEAR";
|
||||
case MySqlDbType.Newdate: return "NEWDATE";
|
||||
case MySqlDbType.Enum: return "ENUM";
|
||||
case MySqlDbType.Set: return "SET";
|
||||
case MySqlDbType.TinyBlob: return "TINY_BLOB";
|
||||
case MySqlDbType.MediumBlob: return "MEDIUM_BLOB";
|
||||
case MySqlDbType.LongBlob: return "LONG_BLOB";
|
||||
case MySqlDbType.Blob: return "BLOB";
|
||||
case MySqlDbType.VarChar: return "VAR_STRING";
|
||||
case MySqlDbType.String: return "STRING";
|
||||
}
|
||||
return "Unknown typeid";
|
||||
}
|
||||
|
||||
|
||||
public Type GetFieldType()
|
||||
{
|
||||
switch (colType)
|
||||
{
|
||||
case MySqlDbType.Byte: return IsUnsigned() ? typeof(System.Byte) : typeof(System.SByte);
|
||||
|
||||
case MySqlDbType.Short: return IsUnsigned() ? typeof(System.UInt16) : typeof(System.Int16);
|
||||
|
||||
case MySqlDbType.Int:
|
||||
case MySqlDbType.Int24: return IsUnsigned() ? typeof(System.UInt32) : typeof(System.Int32);
|
||||
|
||||
case MySqlDbType.BigInt: return IsUnsigned() ? typeof(System.UInt64) : typeof(System.Int64);
|
||||
|
||||
case MySqlDbType.Float: return typeof(System.Single);
|
||||
case MySqlDbType.Double: return typeof(System.Double);
|
||||
|
||||
case MySqlDbType.Time: return typeof(System.TimeSpan);
|
||||
|
||||
case MySqlDbType.Date:
|
||||
case MySqlDbType.Datetime:
|
||||
case MySqlDbType.Timestamp: return typeof(System.DateTime);
|
||||
|
||||
case MySqlDbType.Decimal: return typeof(System.Decimal);
|
||||
|
||||
case MySqlDbType.VarChar:
|
||||
case MySqlDbType.String: return typeof(System.String);
|
||||
|
||||
case MySqlDbType.TinyBlob:
|
||||
case MySqlDbType.MediumBlob:
|
||||
case MySqlDbType.LongBlob:
|
||||
case MySqlDbType.Blob:
|
||||
if ((colFlags & ColumnFlags.BINARY) != 0)
|
||||
return typeof(System.Array);
|
||||
else
|
||||
return typeof(System.String);
|
||||
|
||||
case MySqlDbType.Year:
|
||||
return typeof(System.Int32);
|
||||
|
||||
default:
|
||||
case MySqlDbType.Null: return typeof(System.DBNull);
|
||||
}
|
||||
}
|
||||
|
||||
public DbType GetDbType()
|
||||
{
|
||||
switch (colType)
|
||||
{
|
||||
case MySqlDbType.Decimal: return DbType.Decimal;
|
||||
case MySqlDbType.Byte: return DbType.Byte;
|
||||
case MySqlDbType.Short:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt16;
|
||||
else
|
||||
return DbType.Int16;
|
||||
|
||||
case MySqlDbType.Int:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt32;
|
||||
else
|
||||
return DbType.Int32;
|
||||
|
||||
case MySqlDbType.Float: return DbType.Single;
|
||||
case MySqlDbType.Double: return DbType.Double;
|
||||
case MySqlDbType.Null: return DbType.Object;
|
||||
|
||||
case MySqlDbType.BigInt:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt64;
|
||||
else
|
||||
return DbType.Int64;
|
||||
|
||||
case MySqlDbType.Int24:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt32;
|
||||
else
|
||||
return DbType.Int32;
|
||||
case MySqlDbType.Date:
|
||||
case MySqlDbType.Year:
|
||||
case MySqlDbType.Newdate:
|
||||
return DbType.Date;
|
||||
|
||||
case MySqlDbType.Time:
|
||||
return DbType.Time;
|
||||
case MySqlDbType.Datetime:
|
||||
case MySqlDbType.Timestamp:
|
||||
return DbType.DateTime;
|
||||
|
||||
case MySqlDbType.Enum: return DbType.UInt32;
|
||||
case MySqlDbType.Set: return DbType.Object;
|
||||
|
||||
case MySqlDbType.TinyBlob:
|
||||
case MySqlDbType.MediumBlob:
|
||||
case MySqlDbType.LongBlob:
|
||||
case MySqlDbType.Blob:
|
||||
if (IsBinary()) return DbType.Binary;
|
||||
return DbType.String;
|
||||
case MySqlDbType.VarChar:
|
||||
return DbType.String;
|
||||
case MySqlDbType.String:
|
||||
return DbType.StringFixedLength;
|
||||
}
|
||||
throw new Exception("unknown MySqlDbType");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// ByteFX.Data data access components for .Net
|
||||
// Copyright (C) 2002-2003 ByteFX, Inc.
|
||||
//
|
||||
// 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.1 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
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
internal enum ColFlags : int
|
||||
{
|
||||
NOT_NULL = 1,
|
||||
PRIMARY_KEY = 2,
|
||||
UNIQUE_KEY = 4,
|
||||
MULTIPLE_KEY = 8,
|
||||
BLOB = 16,
|
||||
UNSIGNED = 32,
|
||||
ZERO_FILL = 64,
|
||||
BINARY = 128,
|
||||
ENUM = 256,
|
||||
AUTO_INCREMENT = 512,
|
||||
TIMESTAMP = 1024,
|
||||
SET = 2048,
|
||||
NUMBER = 32768
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Field.
|
||||
/// </summary>
|
||||
internal class MySqlField : Common.Field
|
||||
{
|
||||
MySqlDbType colType;
|
||||
public ColFlags colFlags;
|
||||
public int colDecimals;
|
||||
// System.Text.Encoding encoding;
|
||||
private static NumberFormatInfo numberFormat = null;
|
||||
|
||||
|
||||
public MySqlField()
|
||||
{
|
||||
// this.encoding = encoding;
|
||||
if (numberFormat == null)
|
||||
{
|
||||
numberFormat = (NumberFormatInfo)NumberFormatInfo.InvariantInfo.Clone();
|
||||
numberFormat.NumberDecimalSeparator = ".";
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadSchemaInfo( Packet packet )
|
||||
{
|
||||
tableName = packet.ReadLenString();
|
||||
colName = packet.ReadLenString();
|
||||
colLen = (int)packet.ReadNBytes();
|
||||
colType = (MySqlDbType)packet.ReadNBytes();
|
||||
packet.ReadByte(); // this is apparently 2 -- not sure what it is for
|
||||
colFlags = (ColFlags)packet.ReadInteger(2); //(short)(d.ReadByte() & 0xff);
|
||||
colDecimals = packet.ReadByte();
|
||||
}
|
||||
|
||||
public object GetValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public int NumericPrecision()
|
||||
{
|
||||
if (colType == MySqlDbType.Decimal)
|
||||
return colLen;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int NumericScale()
|
||||
{
|
||||
if (colType == MySqlDbType.Decimal)
|
||||
return colDecimals;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool IsAutoIncrement()
|
||||
{
|
||||
return (colFlags & ColFlags.AUTO_INCREMENT) > 0;
|
||||
}
|
||||
|
||||
public bool IsNumeric()
|
||||
{
|
||||
return (colFlags & ColFlags.NUMBER) > 0;
|
||||
}
|
||||
|
||||
public bool AllowsNull()
|
||||
{
|
||||
return (colFlags & ColFlags.NOT_NULL) == 0;
|
||||
}
|
||||
|
||||
public bool IsUnique()
|
||||
{
|
||||
return (colFlags & ColFlags.UNIQUE_KEY) > 0;
|
||||
}
|
||||
|
||||
public bool IsPrimaryKey()
|
||||
{
|
||||
return (colFlags & ColFlags.PRIMARY_KEY) > 0;
|
||||
}
|
||||
|
||||
public bool IsBlob()
|
||||
{
|
||||
return (colFlags & ColFlags.BLOB) > 0;
|
||||
}
|
||||
|
||||
public bool IsBinary()
|
||||
{
|
||||
return (colFlags & ColFlags.BINARY) > 0;
|
||||
}
|
||||
|
||||
public bool IsUnsigned()
|
||||
{
|
||||
return (colFlags & ColFlags.UNSIGNED) > 0;
|
||||
}
|
||||
|
||||
public void SetValueData( Packet p, Encoding encoding )
|
||||
{
|
||||
int len = p.ReadLenInteger();
|
||||
if (len == -1)
|
||||
{
|
||||
value = DBNull.Value;
|
||||
return;
|
||||
}
|
||||
|
||||
// read in the data
|
||||
byte[] data = new byte[ len ];
|
||||
p.Read( data, 0, len );
|
||||
|
||||
// if it is a blob and binary, then GetBytes is the way to go
|
||||
if ( IsBlob() && IsBinary() )
|
||||
{
|
||||
dbType = DbType.Binary;
|
||||
value = data;
|
||||
return;
|
||||
}
|
||||
|
||||
string sValue = encoding.GetString( data );//Chars(data, offset, count );
|
||||
//string sValue = new string(_Chars);
|
||||
|
||||
switch(colType)
|
||||
{
|
||||
case MySqlDbType.Byte:
|
||||
if (IsUnsigned())
|
||||
value = Byte.Parse( sValue );
|
||||
else
|
||||
value = SByte.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Short:
|
||||
if (IsUnsigned())
|
||||
value = UInt16.Parse( sValue );
|
||||
else
|
||||
value = Int16.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Int :
|
||||
case MySqlDbType.Int24:
|
||||
if (IsUnsigned())
|
||||
value = UInt32.Parse( sValue );
|
||||
else
|
||||
value = Int32.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.BigInt:
|
||||
if (IsUnsigned())
|
||||
value = UInt64.Parse( sValue );
|
||||
else
|
||||
value = Int64.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Decimal:
|
||||
value = Decimal.Parse( sValue , numberFormat );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Float:
|
||||
value = Convert.ToSingle( sValue, numberFormat );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Double:
|
||||
value = Convert.ToDouble( sValue, numberFormat );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Date:
|
||||
ParseDateValue( "0000-00-00", "yyyy-MM-dd", sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Datetime:
|
||||
ParseDateValue( "0000-00-00 00:00:00", "yyyy-MM-dd HH:mm:ss", sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Time:
|
||||
if (sValue.Equals("00:00:00"))
|
||||
value = DBNull.Value;
|
||||
else
|
||||
value = TimeSpan.Parse(sValue);
|
||||
break;
|
||||
|
||||
case MySqlDbType.Timestamp:
|
||||
string pattern;
|
||||
string null_value = "00000000000000";
|
||||
switch (ColumnLength)
|
||||
{
|
||||
case 2: pattern = "yy"; break;
|
||||
case 4: pattern = "yyMM"; break;
|
||||
case 6: pattern = "yyMMdd"; break;
|
||||
case 8: pattern = "yyyyMMdd"; break;
|
||||
case 10: pattern = "yyMMddHHmm"; break;
|
||||
case 12: pattern = "yyMMddHHmmss"; break;
|
||||
case 14:
|
||||
default: pattern = "yyyyMMddHHmmss"; break;
|
||||
}
|
||||
|
||||
if (ColumnLength > 2 && sValue.Equals( null_value.Substring(0, ColumnLength)))
|
||||
value = DBNull.Value;
|
||||
else
|
||||
value = DateTime.ParseExact( sValue, pattern, new System.Globalization.DateTimeFormatInfo());
|
||||
break;
|
||||
|
||||
case MySqlDbType.String:
|
||||
case MySqlDbType.VarChar:
|
||||
case MySqlDbType.Blob:
|
||||
case MySqlDbType.TinyBlob:
|
||||
case MySqlDbType.LongBlob:
|
||||
case MySqlDbType.MediumBlob:
|
||||
value = sValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ParseDateValue( string nullpattern, string pattern, string data )
|
||||
{
|
||||
if ( data.Equals (nullpattern) )
|
||||
value = DBNull.Value;
|
||||
else
|
||||
value = DateTime.ParseExact( data, pattern, new System.Globalization.DateTimeFormatInfo());
|
||||
}
|
||||
|
||||
public string GetFieldTypeName()
|
||||
{
|
||||
switch (colType)
|
||||
{
|
||||
case MySqlDbType.Decimal: return "DECIMAL";
|
||||
case MySqlDbType.Byte: return "TINY";
|
||||
case MySqlDbType.Short: return "SHORT";
|
||||
case MySqlDbType.Int: return "INTEGER";
|
||||
case MySqlDbType.Float: return "FLOAT";
|
||||
case MySqlDbType.Double: return "DOUBLE";
|
||||
case MySqlDbType.Null: return "NULL";
|
||||
case MySqlDbType.Timestamp: return "TIMESTAMP";
|
||||
case MySqlDbType.BigInt: return "BIGINT";
|
||||
case MySqlDbType.Int24: return "INT24";
|
||||
case MySqlDbType.Date: return "DATE";
|
||||
case MySqlDbType.Time: return "TIME";
|
||||
case MySqlDbType.Datetime: return "DATETIME";
|
||||
case MySqlDbType.Year: return "YEAR";
|
||||
case MySqlDbType.Newdate: return "NEWDATE";
|
||||
case MySqlDbType.Enum: return "ENUM";
|
||||
case MySqlDbType.Set: return "SET";
|
||||
case MySqlDbType.TinyBlob: return "TINY_BLOB";
|
||||
case MySqlDbType.MediumBlob: return "MEDIUM_BLOB";
|
||||
case MySqlDbType.LongBlob: return "LONG_BLOB";
|
||||
case MySqlDbType.Blob: return "BLOB";
|
||||
case MySqlDbType.VarChar: return "VAR_STRING";
|
||||
case MySqlDbType.String: return "STRING";
|
||||
}
|
||||
return "Unknown typeid";
|
||||
}
|
||||
|
||||
|
||||
public Type GetFieldType()
|
||||
{
|
||||
switch (colType)
|
||||
{
|
||||
case MySqlDbType.Byte: return IsUnsigned() ? typeof(System.Byte) : typeof(System.SByte);
|
||||
|
||||
case MySqlDbType.Short: return IsUnsigned() ? typeof(System.UInt16) : typeof(System.Int16);
|
||||
|
||||
case MySqlDbType.Int:
|
||||
case MySqlDbType.Int24: return IsUnsigned() ? typeof(System.UInt32) : typeof(System.Int32);
|
||||
|
||||
case MySqlDbType.BigInt: return IsUnsigned() ? typeof(System.UInt64) : typeof(System.Int64);
|
||||
|
||||
case MySqlDbType.Float: return typeof(System.Single);
|
||||
case MySqlDbType.Double: return typeof(System.Double);
|
||||
|
||||
case MySqlDbType.Time: return typeof(System.TimeSpan);
|
||||
|
||||
case MySqlDbType.Date:
|
||||
case MySqlDbType.Datetime:
|
||||
case MySqlDbType.Timestamp: return typeof(System.DateTime);
|
||||
|
||||
case MySqlDbType.Decimal: return typeof(System.Decimal);
|
||||
|
||||
case MySqlDbType.VarChar:
|
||||
case MySqlDbType.String: return typeof(System.String);
|
||||
|
||||
case MySqlDbType.TinyBlob:
|
||||
case MySqlDbType.MediumBlob:
|
||||
case MySqlDbType.LongBlob:
|
||||
case MySqlDbType.Blob: return typeof(System.Array);
|
||||
|
||||
default:
|
||||
case MySqlDbType.Null: return typeof(System.DBNull);
|
||||
}
|
||||
}
|
||||
|
||||
public MySqlDbType GetMySqlDbType()
|
||||
{
|
||||
return colType;
|
||||
}
|
||||
|
||||
public DbType GetDbType()
|
||||
{
|
||||
switch (colType)
|
||||
{
|
||||
case MySqlDbType.Decimal: return DbType.Decimal;
|
||||
case MySqlDbType.Byte: return DbType.Byte;
|
||||
case MySqlDbType.Short:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt16;
|
||||
else
|
||||
return DbType.Int16;
|
||||
|
||||
case MySqlDbType.Int:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt32;
|
||||
else
|
||||
return DbType.Int32;
|
||||
|
||||
case MySqlDbType.Float: return DbType.Single;
|
||||
case MySqlDbType.Double: return DbType.Double;
|
||||
case MySqlDbType.Null: return DbType.Object;
|
||||
|
||||
case MySqlDbType.BigInt:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt64;
|
||||
else
|
||||
return DbType.Int64;
|
||||
|
||||
case MySqlDbType.Int24:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt32;
|
||||
else
|
||||
return DbType.Int32;
|
||||
case MySqlDbType.Date:
|
||||
case MySqlDbType.Year:
|
||||
case MySqlDbType.Newdate:
|
||||
return DbType.Date;
|
||||
|
||||
case MySqlDbType.Time:
|
||||
return DbType.Time;
|
||||
case MySqlDbType.Datetime:
|
||||
case MySqlDbType.Timestamp:
|
||||
return DbType.DateTime;
|
||||
|
||||
case MySqlDbType.Enum: return DbType.UInt32;
|
||||
case MySqlDbType.Set: return DbType.Object;
|
||||
|
||||
case MySqlDbType.TinyBlob:
|
||||
case MySqlDbType.MediumBlob:
|
||||
case MySqlDbType.LongBlob:
|
||||
case MySqlDbType.Blob:
|
||||
if (IsBinary()) return DbType.Binary;
|
||||
return DbType.String;
|
||||
case MySqlDbType.VarChar:
|
||||
return DbType.String;
|
||||
case MySqlDbType.String:
|
||||
return DbType.StringFixedLength;
|
||||
}
|
||||
throw new Exception("unknown MySqlDbType");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
public class MySqlError
|
||||
{
|
||||
/* ER_HASHCHK=1000,
|
||||
ER_NISAMCHK=1001,
|
||||
ER_NO=1002,
|
||||
ER_YES 1003
|
||||
ER_CANT_CREATE_FILE 1004
|
||||
ER_CANT_CREATE_TABLE 1005
|
||||
ER_CANT_CREATE_DB 1006
|
||||
ER_DB_CREATE_EXISTS 1007
|
||||
ER_DB_DROP_EXISTS 1008
|
||||
ER_DB_DROP_DELETE 1009
|
||||
ER_DB_DROP_RMDIR 1010
|
||||
ER_CANT_DELETE_FILE 1011
|
||||
ER_CANT_FIND_SYSTEM_REC 1012
|
||||
ER_CANT_GET_STAT 1013
|
||||
ER_CANT_GET_WD 1014
|
||||
ER_CANT_LOCK 1015
|
||||
ER_CANT_OPEN_FILE 1016
|
||||
ER_FILE_NOT_FOUND 1017
|
||||
ER_CANT_READ_DIR 1018
|
||||
ER_CANT_SET_WD 1019
|
||||
ER_CHECKREAD 1020
|
||||
ER_DISK_FULL 1021
|
||||
*/
|
||||
public static int DuplicateKey = 1022;
|
||||
/* ER_ERROR_ON_CLOSE 1023
|
||||
ER_ERROR_ON_READ 1024
|
||||
ER_ERROR_ON_RENAME 1025
|
||||
ER_ERROR_ON_WRITE 1026
|
||||
ER_FILE_USED 1027
|
||||
ER_FILSORT_ABORT 1028
|
||||
ER_FORM_NOT_FOUND 1029
|
||||
ER_GET_ERRNO 1030
|
||||
ER_ILLEGAL_HA 1031*/
|
||||
public static int KeyNotFound = 1032;
|
||||
/* ER_NOT_FORM_FILE 1033
|
||||
ER_NOT_KEYFILE 1034
|
||||
ER_OLD_KEYFILE 1035
|
||||
ER_OPEN_AS_READONLY 1036
|
||||
ER_OUTOFMEMORY 1037
|
||||
ER_OUT_OF_SORTMEMORY 1038
|
||||
ER_UNEXPECTED_EOF 1039
|
||||
ER_CON_COUNT_ERROR 1040
|
||||
ER_OUT_OF_RESOURCES 1041
|
||||
ER_BAD_HOST_ERROR 1042
|
||||
ER_HANDSHAKE_ERROR 1043
|
||||
ER_DBACCESS_DENIED_ERROR 1044
|
||||
ER_ACCESS_DENIED_ERROR 1045
|
||||
ER_NO_DB_ERROR 1046
|
||||
ER_UNKNOWN_COM_ERROR 1047
|
||||
ER_BAD_NULL_ERROR 1048
|
||||
ER_BAD_DB_ERROR 1049
|
||||
ER_TABLE_EXISTS_ERROR 1050
|
||||
ER_BAD_TABLE_ERROR 1051
|
||||
ER_NON_UNIQ_ERROR 1052
|
||||
ER_SERVER_SHUTDOWN 1053
|
||||
ER_BAD_FIELD_ERROR 1054
|
||||
ER_WRONG_FIELD_WITH_GROUP 1055
|
||||
ER_WRONG_GROUP_FIELD 1056
|
||||
ER_WRONG_SUM_SELECT 1057
|
||||
ER_WRONG_VALUE_COUNT 1058
|
||||
ER_TOO_LONG_IDENT 1059
|
||||
ER_DUP_FIELDNAME 1060*/
|
||||
public static int DuplicateKeyName = 1061;
|
||||
public static int DuplicateKeyEntry = 1062;
|
||||
/* ER_WRONG_FIELD_SPEC 1063
|
||||
ER_PARSE_ERROR 1064
|
||||
ER_EMPTY_QUERY 1065
|
||||
ER_NONUNIQ_TABLE 1066
|
||||
ER_INVALID_DEFAULT 1067
|
||||
ER_MULTIPLE_PRI_KEY 1068
|
||||
ER_TOO_MANY_KEYS 1069
|
||||
ER_TOO_MANY_KEY_PARTS 1070
|
||||
ER_TOO_LONG_KEY 1071
|
||||
ER_KEY_COLUMN_DOES_NOT_EXITS 1072
|
||||
ER_BLOB_USED_AS_KEY 1073
|
||||
ER_TOO_BIG_FIELDLENGTH 1074
|
||||
ER_WRONG_AUTO_KEY 1075
|
||||
ER_READY 1076
|
||||
ER_NORMAL_SHUTDOWN 1077
|
||||
ER_GOT_SIGNAL 1078
|
||||
ER_SHUTDOWN_COMPLETE 1079
|
||||
ER_FORCING_CLOSE 1080
|
||||
ER_IPSOCK_ERROR 1081
|
||||
ER_NO_SUCH_INDEX 1082
|
||||
ER_WRONG_FIELD_TERMINATORS 1083
|
||||
ER_BLOBS_AND_NO_TERMINATED 1084
|
||||
ER_TEXTFILE_NOT_READABLE 1085
|
||||
ER_FILE_EXISTS_ERROR 1086
|
||||
ER_LOAD_INFO 1087
|
||||
ER_ALTER_INFO 1088
|
||||
ER_WRONG_SUB_KEY 1089
|
||||
ER_CANT_REMOVE_ALL_FIELDS 1090
|
||||
ER_CANT_DROP_FIELD_OR_KEY 1091
|
||||
ER_INSERT_INFO 1092
|
||||
ER_INSERT_TABLE_USED 1093
|
||||
ER_NO_SUCH_THREAD 1094
|
||||
ER_KILL_DENIED_ERROR 1095
|
||||
ER_NO_TABLES_USED 1096
|
||||
ER_TOO_BIG_SET 1097
|
||||
ER_NO_UNIQUE_LOGFILE 1098
|
||||
ER_TABLE_NOT_LOCKED_FOR_WRITE 1099
|
||||
ER_TABLE_NOT_LOCKED 1100
|
||||
ER_BLOB_CANT_HAVE_DEFAULT 1101
|
||||
ER_WRONG_DB_NAME 1102
|
||||
ER_WRONG_TABLE_NAME 1103
|
||||
ER_TOO_BIG_SELECT 1104
|
||||
ER_UNKNOWN_ERROR 1105
|
||||
ER_UNKNOWN_PROCEDURE 1106
|
||||
ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107
|
||||
ER_WRONG_PARAMETERS_TO_PROCEDURE 1108
|
||||
ER_UNKNOWN_TABLE 1109
|
||||
ER_FIELD_SPECIFIED_TWICE 1110
|
||||
ER_INVALID_GROUP_FUNC_USE 1111
|
||||
ER_UNSUPPORTED_EXTENSION 1112
|
||||
ER_TABLE_MUST_HAVE_COLUMNS 1113
|
||||
ER_RECORD_FILE_FULL 1114
|
||||
ER_UNKNOWN_CHARACTER_SET 1115
|
||||
ER_TOO_MANY_TABLES 1116
|
||||
ER_TOO_MANY_FIELDS 1117
|
||||
ER_TOO_BIG_ROWSIZE 1118
|
||||
ER_STACK_OVERRUN 1119
|
||||
ER_WRONG_OUTER_JOIN 1120
|
||||
ER_NULL_COLUMN_IN_INDEX 1121
|
||||
ER_CANT_FIND_UDF 1122
|
||||
ER_CANT_INITIALIZE_UDF 1123
|
||||
ER_UDF_NO_PATHS 1124
|
||||
ER_UDF_EXISTS 1125
|
||||
ER_CANT_OPEN_LIBRARY 1126
|
||||
ER_CANT_FIND_DL_ENTRY 1127
|
||||
ER_FUNCTION_NOT_DEFINED 1128
|
||||
ER_HOST_IS_BLOCKED 1129
|
||||
*/
|
||||
public static int HostNotPrivileged = 1130;
|
||||
public static int AnonymousUser = 1131;
|
||||
public static int PasswordNotAllowed = 1132;
|
||||
public static int PasswordNoMatch = 1133;
|
||||
/* ER_UPDATE_INFO 1134
|
||||
ER_CANT_CREATE_THREAD 1135
|
||||
ER_WRONG_VALUE_COUNT_ON_ROW 1136
|
||||
ER_CANT_REOPEN_TABLE 1137
|
||||
ER_INVALID_USE_OF_NULL 1138
|
||||
ER_REGEXP_ERROR 1139
|
||||
ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140
|
||||
ER_NONEXISTING_GRANT 1141
|
||||
ER_TABLEACCESS_DENIED_ERROR 1142
|
||||
ER_COLUMNACCESS_DENIED_ERROR 1143
|
||||
ER_ILLEGAL_GRANT_FOR_TABLE 1144
|
||||
ER_GRANT_WRONG_HOST_OR_USER 1145
|
||||
ER_NO_SUCH_TABLE 1146
|
||||
ER_NONEXISTING_TABLE_GRANT 1147
|
||||
ER_NOT_ALLOWED_COMMAND 1148
|
||||
ER_SYNTAX_ERROR 1149
|
||||
ER_DELAYED_CANT_CHANGE_LOCK 1150
|
||||
ER_TOO_MANY_DELAYED_THREADS 1151
|
||||
ER_ABORTING_CONNECTION 1152
|
||||
ER_NET_PACKET_TOO_LARGE 1153
|
||||
ER_NET_READ_ERROR_FROM_PIPE 1154
|
||||
ER_NET_FCNTL_ERROR 1155
|
||||
ER_NET_PACKETS_OUT_OF_ORDER 1156
|
||||
ER_NET_UNCOMPRESS_ERROR 1157
|
||||
ER_NET_READ_ERROR 1158
|
||||
ER_NET_READ_INTERRUPTED 1159
|
||||
ER_NET_ERROR_ON_WRITE 1160
|
||||
ER_NET_WRITE_INTERRUPTED 1161
|
||||
ER_TOO_LONG_STRING 1162
|
||||
ER_TABLE_CANT_HANDLE_BLOB 1163
|
||||
ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164
|
||||
ER_DELAYED_INSERT_TABLE_LOCKED 1165
|
||||
ER_WRONG_COLUMN_NAME 1166
|
||||
ER_WRONG_KEY_COLUMN 1167
|
||||
ER_WRONG_MRG_TABLE 1168
|
||||
ER_DUP_UNIQUE 1169
|
||||
ER_BLOB_KEY_WITHOUT_LENGTH 1170
|
||||
ER_PRIMARY_CANT_HAVE_NULL 1171
|
||||
ER_TOO_MANY_ROWS 1172
|
||||
ER_REQUIRES_PRIMARY_KEY 1173
|
||||
ER_NO_RAID_COMPILED 1174
|
||||
ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175
|
||||
ER_KEY_DOES_NOT_EXITS 1176
|
||||
ER_CHECK_NO_SUCH_TABLE 1177
|
||||
ER_CHECK_NOT_IMPLEMENTED 1178
|
||||
ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179
|
||||
ER_ERROR_DURING_COMMIT 1180
|
||||
ER_ERROR_DURING_ROLLBACK 1181
|
||||
ER_ERROR_DURING_FLUSH_LOGS 1182
|
||||
ER_ERROR_DURING_CHECKPOINT 1183
|
||||
ER_NEW_ABORTING_CONNECTION 1184
|
||||
ER_DUMP_NOT_IMPLEMENTED 1185
|
||||
ER_FLUSH_MASTER_BINLOG_CLOSED 1186
|
||||
ER_INDEX_REBUILD 1187
|
||||
ER_MASTER 1188
|
||||
ER_MASTER_NET_READ 1189
|
||||
ER_MASTER_NET_WRITE 1190
|
||||
ER_FT_MATCHING_KEY_NOT_FOUND 1191
|
||||
ER_LOCK_OR_ACTIVE_TRANSACTION 1192
|
||||
ER_UNKNOWN_SYSTEM_VARIABLE 1193
|
||||
ER_CRASHED_ON_USAGE 1194
|
||||
ER_CRASHED_ON_REPAIR 1195
|
||||
ER_WARNING_NOT_COMPLETE_ROLLBACK 1196
|
||||
ER_TRANS_CACHE_FULL 1197
|
||||
ER_SLAVE_MUST_STOP 1198
|
||||
ER_SLAVE_NOT_RUNNING 1199
|
||||
ER_BAD_SLAVE 1200
|
||||
ER_MASTER_INFO 1201
|
||||
ER_SLAVE_THREAD 1202
|
||||
ER_TOO_MANY_USER_CONNECTIONS 1203
|
||||
ER_SET_CONSTANTS_ONLY 1204
|
||||
ER_LOCK_WAIT_TIMEOUT 1205
|
||||
ER_LOCK_TABLE_FULL 1206
|
||||
ER_READ_ONLY_TRANSACTION 1207
|
||||
ER_DROP_DB_WITH_READ_LOCK 1208
|
||||
ER_CREATE_DB_WITH_READ_LOCK 1209
|
||||
ER_WRONG_ARGUMENTS 1210
|
||||
ER_NO_PERMISSION_TO_CREATE_USER 1211
|
||||
ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
|
||||
ER_LOCK_DEADLOCK 1213
|
||||
ER_TABLE_CANT_HANDLE_FULLTEXT 1214
|
||||
ER_CANNOT_ADD_FOREIGN 1215
|
||||
ER_NO_REFERENCED_ROW 1216
|
||||
ER_ROW_IS_REFERENCED 1217
|
||||
ER_CONNECT_TO_MASTER 1218
|
||||
ER_QUERY_ON_MASTER 1219
|
||||
ER_ERROR_WHEN_EXECUTING_COMMAND 1220
|
||||
ER_WRONG_USAGE 1221
|
||||
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222
|
||||
ER_CANT_UPDATE_WITH_READLOCK 1223
|
||||
ER_MIXING_NOT_ALLOWED 1224
|
||||
ER_DUP_ARGUMENT 1225
|
||||
ER_USER_LIMIT_REACHED 1226
|
||||
ER_SPECIFIC_ACCESS_DENIED_ERROR 1227
|
||||
ER_LOCAL_VARIABLE 1228
|
||||
ER_GLOBAL_VARIABLE 1229
|
||||
ER_NO_DEFAULT 1230
|
||||
ER_WRONG_VALUE_FOR_VAR 1231
|
||||
ER_WRONG_TYPE_FOR_VAR 1232
|
||||
ER_VAR_CANT_BE_READ 1233
|
||||
ER_CANT_USE_OPTION_HERE 1234
|
||||
ER_NOT_SUPPORTED_YET 1235
|
||||
ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
|
||||
ER_SLAVE_IGNORED_TABLE 1237 // only the slave SQL thread can be sent this
|
||||
ER_ERROR_MESSAGES 238*/
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,343 +1,343 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using ByteFX.Data.MySqlClient;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class that makes it easier to work with the provider.
|
||||
/// </summary>
|
||||
public sealed class MySqlHelper
|
||||
{
|
||||
// this class provides only static methods
|
||||
private MySqlHelper()
|
||||
{
|
||||
}
|
||||
|
||||
#region ExecuteNonQuery
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database. The <see cref="MySqlConnection"/> is assumed to be
|
||||
/// open when the method is called and remains open after the method completes.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">SQL command to be executed</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
|
||||
/// <returns></returns>
|
||||
public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters )
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = connection;
|
||||
cmd.CommandText = commandText;
|
||||
cmd.CommandType = CommandType.Text;
|
||||
|
||||
if (commandParameters != null)
|
||||
foreach (MySqlParameter p in commandParameters)
|
||||
cmd.Parameters.Add( p );
|
||||
|
||||
int result = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database. A new <see cref="MySqlConnection"/> is created
|
||||
/// using the <see cref="MySqlConnection.ConnectionString"/> given.
|
||||
/// </summary>
|
||||
/// <param name="connectionString"><see cref="MySqlConnection.ConnectionString"/> to use</param>
|
||||
/// <param name="commandText">SQL command to be executed</param>
|
||||
/// <param name="parms">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
|
||||
/// <returns></returns>
|
||||
public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms )
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
using (MySqlConnection cn = new MySqlConnection(connectionString))
|
||||
{
|
||||
cn.Open();
|
||||
|
||||
//call the overload that takes a connection in place of the connection string
|
||||
return ExecuteNonQuery(cn, commandText, parms );
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataSet
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object
|
||||
/// is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="parms">Parameters to use for the command</param>
|
||||
/// <returns>DataRow containing the first row of the resultset</returns>
|
||||
public static DataRow ExecuteDatarow( string connectionString, string commandText, params MySqlParameter[] parms )
|
||||
{
|
||||
DataSet ds = ExecuteDataset( connectionString, commandText, parms );
|
||||
if (ds == null) return null;
|
||||
if (ds.Tables.Count == 0) return null;
|
||||
if (ds.Tables[0].Rows.Count == 0) return null;
|
||||
return ds.Tables[0].Rows[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// A new MySqlConnection object is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// A new MySqlConnection object is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
using (MySqlConnection cn = new MySqlConnection(connectionString))
|
||||
{
|
||||
cn.Open();
|
||||
|
||||
//call the overload that takes a connection in place of the connection string
|
||||
return ExecuteDataset(cn, commandText, commandParameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
|
||||
/// of this method.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteDataset(connection, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
|
||||
/// of this method.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = connection;
|
||||
cmd.CommandText = commandText;
|
||||
cmd.CommandType = CommandType.Text;
|
||||
|
||||
if (commandParameters != null)
|
||||
foreach (MySqlParameter p in commandParameters)
|
||||
cmd.Parameters.Add( p );
|
||||
|
||||
//create the DataAdapter & DataSet
|
||||
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
|
||||
DataSet ds = new DataSet();
|
||||
|
||||
//fill the DataSet using default values for DataTable names, etc.
|
||||
da.Fill(ds);
|
||||
|
||||
// detach the MySqlParameters from the command object, so they can be used again.
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
//return the dataset
|
||||
return ds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the given table with data from the given <see cref="DataSet"/>
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the update</param>
|
||||
/// <param name="commandText">Command text to use for the update</param>
|
||||
/// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>
|
||||
/// <param name="tablename">Tablename in the dataset to update</param>
|
||||
public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )
|
||||
{
|
||||
MySqlConnection cn = new MySqlConnection( connectionString );
|
||||
cn.Open();
|
||||
MySqlDataAdapter da = new MySqlDataAdapter( commandText, cn );
|
||||
MySqlCommandBuilder cb = new MySqlCommandBuilder( da );
|
||||
da.Update( ds, tablename );
|
||||
cn.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataReader
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database, possibly inside an existing transaction.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use for the command</param>
|
||||
/// <param name="transaction"><see cref="MySqlTransaction"/> object to use for the command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
|
||||
/// <param name="ExternalConn">True if the connection should be preserved, false if not</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn )
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = connection;
|
||||
cmd.Transaction = transaction;
|
||||
cmd.CommandText = commandText;
|
||||
cmd.CommandType = CommandType.Text;
|
||||
|
||||
if (commandParameters != null)
|
||||
foreach (MySqlParameter p in commandParameters)
|
||||
cmd.Parameters.Add( p );
|
||||
|
||||
//create a reader
|
||||
MySqlDataReader dr;
|
||||
|
||||
// call ExecuteReader with the appropriate CommandBehavior
|
||||
if (ExternalConn)
|
||||
{
|
||||
dr = cmd.ExecuteReader();
|
||||
}
|
||||
else
|
||||
{
|
||||
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
|
||||
}
|
||||
|
||||
// detach the SqlParameters from the command object, so they can be used again.
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
return dr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for this command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
public static MySqlDataReader ExecuteReader(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteReader(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for this command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection
|
||||
MySqlConnection cn = new MySqlConnection(connectionString);
|
||||
cn.Open();
|
||||
|
||||
try
|
||||
{
|
||||
//call the private overload that takes an internally owned connection in place of the connection string
|
||||
return ExecuteReader(cn, null, commandText, commandParameters, false );
|
||||
}
|
||||
catch
|
||||
{
|
||||
//if we fail to return the SqlDatReader, we need to close the connection ourselves
|
||||
cn.Close();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteScalar
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the update</param>
|
||||
/// <param name="commandText">Command text to use for the update</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of MySqlParameters
|
||||
return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the command</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
using (MySqlConnection cn = new MySqlConnection(connectionString))
|
||||
{
|
||||
cn.Open();
|
||||
|
||||
//call the overload that takes a connection in place of the connection string
|
||||
return ExecuteScalar(cn, commandText, commandParameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(MySqlConnection connection, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of MySqlParameters
|
||||
return ExecuteScalar(connection, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = connection;
|
||||
cmd.CommandText = commandText;
|
||||
cmd.CommandType = CommandType.Text;
|
||||
|
||||
if (commandParameters != null)
|
||||
foreach (MySqlParameter p in commandParameters)
|
||||
cmd.Parameters.Add( p );
|
||||
|
||||
//execute the command & return the results
|
||||
object retval = cmd.ExecuteScalar();
|
||||
|
||||
// detach the SqlParameters from the command object, so they can be used again.
|
||||
cmd.Parameters.Clear();
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Data;
|
||||
using ByteFX.Data.MySqlClient;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class that makes it easier to work with the provider.
|
||||
/// </summary>
|
||||
public sealed class MySqlHelper
|
||||
{
|
||||
// this class provides only static methods
|
||||
private MySqlHelper()
|
||||
{
|
||||
}
|
||||
|
||||
#region ExecuteNonQuery
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database. The <see cref="MySqlConnection"/> is assumed to be
|
||||
/// open when the method is called and remains open after the method completes.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">SQL command to be executed</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
|
||||
/// <returns></returns>
|
||||
public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters )
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = connection;
|
||||
cmd.CommandText = commandText;
|
||||
cmd.CommandType = CommandType.Text;
|
||||
|
||||
if (commandParameters != null)
|
||||
foreach (MySqlParameter p in commandParameters)
|
||||
cmd.Parameters.Add( p );
|
||||
|
||||
int result = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database. A new <see cref="MySqlConnection"/> is created
|
||||
/// using the <see cref="MySqlConnection.ConnectionString"/> given.
|
||||
/// </summary>
|
||||
/// <param name="connectionString"><see cref="MySqlConnection.ConnectionString"/> to use</param>
|
||||
/// <param name="commandText">SQL command to be executed</param>
|
||||
/// <param name="parms">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
|
||||
/// <returns></returns>
|
||||
public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms )
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
using (MySqlConnection cn = new MySqlConnection(connectionString))
|
||||
{
|
||||
cn.Open();
|
||||
|
||||
//call the overload that takes a connection in place of the connection string
|
||||
return ExecuteNonQuery(cn, commandText, parms );
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataSet
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object
|
||||
/// is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="parms">Parameters to use for the command</param>
|
||||
/// <returns>DataRow containing the first row of the resultset</returns>
|
||||
public static DataRow ExecuteDatarow( string connectionString, string commandText, params MySqlParameter[] parms )
|
||||
{
|
||||
DataSet ds = ExecuteDataset( connectionString, commandText, parms );
|
||||
if (ds == null) return null;
|
||||
if (ds.Tables.Count == 0) return null;
|
||||
if (ds.Tables[0].Rows.Count == 0) return null;
|
||||
return ds.Tables[0].Rows[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// A new MySqlConnection object is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// A new MySqlConnection object is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
using (MySqlConnection cn = new MySqlConnection(connectionString))
|
||||
{
|
||||
cn.Open();
|
||||
|
||||
//call the overload that takes a connection in place of the connection string
|
||||
return ExecuteDataset(cn, commandText, commandParameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
|
||||
/// of this method.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteDataset(connection, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
|
||||
/// of this method.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = connection;
|
||||
cmd.CommandText = commandText;
|
||||
cmd.CommandType = CommandType.Text;
|
||||
|
||||
if (commandParameters != null)
|
||||
foreach (MySqlParameter p in commandParameters)
|
||||
cmd.Parameters.Add( p );
|
||||
|
||||
//create the DataAdapter & DataSet
|
||||
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
|
||||
DataSet ds = new DataSet();
|
||||
|
||||
//fill the DataSet using default values for DataTable names, etc.
|
||||
da.Fill(ds);
|
||||
|
||||
// detach the MySqlParameters from the command object, so they can be used again.
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
//return the dataset
|
||||
return ds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the given table with data from the given <see cref="DataSet"/>
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the update</param>
|
||||
/// <param name="commandText">Command text to use for the update</param>
|
||||
/// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>
|
||||
/// <param name="tablename">Tablename in the dataset to update</param>
|
||||
public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )
|
||||
{
|
||||
MySqlConnection cn = new MySqlConnection( connectionString );
|
||||
cn.Open();
|
||||
MySqlDataAdapter da = new MySqlDataAdapter( commandText, cn );
|
||||
MySqlCommandBuilder cb = new MySqlCommandBuilder( da );
|
||||
da.Update( ds, tablename );
|
||||
cn.Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataReader
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database, possibly inside an existing transaction.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use for the command</param>
|
||||
/// <param name="transaction"><see cref="MySqlTransaction"/> object to use for the command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
|
||||
/// <param name="ExternalConn">True if the connection should be preserved, false if not</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn )
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = connection;
|
||||
cmd.Transaction = transaction;
|
||||
cmd.CommandText = commandText;
|
||||
cmd.CommandType = CommandType.Text;
|
||||
|
||||
if (commandParameters != null)
|
||||
foreach (MySqlParameter p in commandParameters)
|
||||
cmd.Parameters.Add( p );
|
||||
|
||||
//create a reader
|
||||
MySqlDataReader dr;
|
||||
|
||||
// call ExecuteReader with the appropriate CommandBehavior
|
||||
if (ExternalConn)
|
||||
{
|
||||
dr = cmd.ExecuteReader();
|
||||
}
|
||||
else
|
||||
{
|
||||
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
|
||||
}
|
||||
|
||||
// detach the SqlParameters from the command object, so they can be used again.
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
return dr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for this command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
public static MySqlDataReader ExecuteReader(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteReader(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for this command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection
|
||||
MySqlConnection cn = new MySqlConnection(connectionString);
|
||||
cn.Open();
|
||||
|
||||
try
|
||||
{
|
||||
//call the private overload that takes an internally owned connection in place of the connection string
|
||||
return ExecuteReader(cn, null, commandText, commandParameters, false );
|
||||
}
|
||||
catch
|
||||
{
|
||||
//if we fail to return the SqlDatReader, we need to close the connection ourselves
|
||||
cn.Close();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteScalar
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the update</param>
|
||||
/// <param name="commandText">Command text to use for the update</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of MySqlParameters
|
||||
return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the command</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
using (MySqlConnection cn = new MySqlConnection(connectionString))
|
||||
{
|
||||
cn.Open();
|
||||
|
||||
//call the overload that takes a connection in place of the connection string
|
||||
return ExecuteScalar(cn, commandText, commandParameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(MySqlConnection connection, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of MySqlParameters
|
||||
return ExecuteScalar(connection, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = connection;
|
||||
cmd.CommandText = commandText;
|
||||
cmd.CommandType = CommandType.Text;
|
||||
|
||||
if (commandParameters != null)
|
||||
foreach (MySqlParameter p in commandParameters)
|
||||
cmd.Parameters.Add( p );
|
||||
|
||||
//execute the command & return the results
|
||||
object retval = cmd.ExecuteScalar();
|
||||
|
||||
// detach the SqlParameters from the command object, so they can be used again.
|
||||
cmd.Parameters.Clear();
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,135 +1,134 @@
|
||||
using System;
|
||||
using ByteFX.Data.Common;
|
||||
using System.Collections;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MySqlPool.
|
||||
/// </summary>
|
||||
internal sealed class MySqlPool
|
||||
{
|
||||
private ArrayList inUsePool;
|
||||
private ArrayList idlePool;
|
||||
private MySqlConnectionString settings;
|
||||
private int minSize;
|
||||
private int maxSize;
|
||||
|
||||
public MySqlPool(MySqlConnectionString settings)
|
||||
{
|
||||
minSize = settings.MinPoolSize;
|
||||
maxSize = settings.MaxPoolSize;
|
||||
this.settings = settings;
|
||||
inUsePool =new ArrayList();
|
||||
idlePool = new ArrayList( settings.MinPoolSize );
|
||||
|
||||
// prepopulate the idle pool to minSize
|
||||
for (int i=0; i < minSize; i++)
|
||||
CreateNewPooledConnection();
|
||||
}
|
||||
|
||||
private void CheckOutConnection(MySqlInternalConnection conn)
|
||||
{
|
||||
}
|
||||
|
||||
private MySqlInternalConnection GetPooledConnection()
|
||||
{
|
||||
MySqlInternalConnection conn = null;
|
||||
|
||||
// if there are no idle connections and the in use pool is full
|
||||
// then return null to indicate that we cannot provide a connection
|
||||
// at this time.
|
||||
if (idlePool.Count == 0 && inUsePool.Count == maxSize) return null;
|
||||
|
||||
lock (idlePool.SyncRoot)
|
||||
{
|
||||
for (int i=idlePool.Count-1; i >=0; i--)
|
||||
{
|
||||
conn = (idlePool[i] as MySqlInternalConnection);
|
||||
if (conn.IsAlive())
|
||||
{
|
||||
lock (inUsePool)
|
||||
{
|
||||
inUsePool.Add( conn );
|
||||
}
|
||||
idlePool.RemoveAt( i );
|
||||
return conn;
|
||||
}
|
||||
else
|
||||
{
|
||||
conn.Close();
|
||||
idlePool.RemoveAt(i);
|
||||
conn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we couldn't get a pooled connection and there is still room
|
||||
// make a new one
|
||||
if (conn == null && (idlePool.Count+inUsePool.Count) < maxSize)
|
||||
{
|
||||
conn = CreateNewPooledConnection();
|
||||
if (conn == null) return null;
|
||||
|
||||
lock (idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
{
|
||||
idlePool.Remove( conn );
|
||||
inUsePool.Add( conn );
|
||||
}
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
private MySqlInternalConnection CreateNewPooledConnection()
|
||||
{
|
||||
lock(idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
{
|
||||
// first we check if we are allowed to create another
|
||||
if ((inUsePool.Count + idlePool.Count) == maxSize) return null;
|
||||
|
||||
MySqlInternalConnection conn = new MySqlInternalConnection( settings );
|
||||
conn.Open();
|
||||
idlePool.Add( conn );
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleaseConnection( MySqlInternalConnection connection )
|
||||
{
|
||||
lock (idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
{
|
||||
inUsePool.Remove( connection );
|
||||
if (connection.Settings.ConnectionLifetime != 0 && connection.IsTooOld())
|
||||
connection.Close();
|
||||
else
|
||||
idlePool.Add( connection );
|
||||
}
|
||||
}
|
||||
|
||||
public MySqlInternalConnection GetConnection()
|
||||
{
|
||||
MySqlInternalConnection conn = null;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
int ticks = settings.ConnectionTimeout * 1000;
|
||||
|
||||
// wait timeOut seconds at most to get a connection
|
||||
while (conn == null && (Environment.TickCount - start) < ticks)
|
||||
conn = GetPooledConnection();
|
||||
|
||||
// if pool size is at maximum, then we must have reached our timeout so we simply
|
||||
// throw our exception
|
||||
if (conn == null)
|
||||
throw new MySqlException("error connecting: Timeout expired. The timeout period elapsed " +
|
||||
"prior to obtaining a connection from the pool. This may have occurred because all " +
|
||||
"pooled connections were in use and max pool size was reached.");
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using ByteFX.Data.Common;
|
||||
using System.Collections;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MySqlPool.
|
||||
/// </summary>
|
||||
internal sealed class MySqlPool
|
||||
{
|
||||
private ArrayList inUsePool;
|
||||
private ArrayList idlePool;
|
||||
private MySqlConnectionString settings;
|
||||
private int minSize;
|
||||
private int maxSize;
|
||||
|
||||
public MySqlPool(MySqlConnectionString settings)
|
||||
{
|
||||
minSize = settings.MinPoolSize;
|
||||
maxSize = settings.MaxPoolSize;
|
||||
this.settings = settings;
|
||||
inUsePool =new ArrayList();
|
||||
idlePool = new ArrayList( settings.MinPoolSize );
|
||||
|
||||
// prepopulate the idle pool to minSize
|
||||
for (int i=0; i < minSize; i++)
|
||||
CreateNewPooledConnection();
|
||||
}
|
||||
|
||||
private void CheckOutConnection(MySqlInternalConnection conn)
|
||||
{
|
||||
}
|
||||
|
||||
private MySqlInternalConnection GetPooledConnection()
|
||||
{
|
||||
MySqlInternalConnection conn = null;
|
||||
|
||||
// if there are no idle connections and the in use pool is full
|
||||
// then return null to indicate that we cannot provide a connection
|
||||
// at this time.
|
||||
if (idlePool.Count == 0 && inUsePool.Count == maxSize) return null;
|
||||
|
||||
lock (idlePool.SyncRoot)
|
||||
{
|
||||
for (int i=idlePool.Count-1; i >=0; i--)
|
||||
{
|
||||
conn = (idlePool[i] as MySqlInternalConnection);
|
||||
if (conn.IsAlive())
|
||||
{
|
||||
lock (inUsePool)
|
||||
{
|
||||
inUsePool.Add( conn );
|
||||
}
|
||||
idlePool.RemoveAt( i );
|
||||
return conn;
|
||||
}
|
||||
else
|
||||
{
|
||||
conn.Close();
|
||||
idlePool.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we couldn't get a pooled connection and there is still room
|
||||
// make a new one
|
||||
if (conn == null && (idlePool.Count+inUsePool.Count) < maxSize)
|
||||
{
|
||||
conn = CreateNewPooledConnection();
|
||||
if (conn == null) return null;
|
||||
|
||||
lock (idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
{
|
||||
idlePool.Remove( conn );
|
||||
inUsePool.Add( conn );
|
||||
}
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
private MySqlInternalConnection CreateNewPooledConnection()
|
||||
{
|
||||
lock(idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
{
|
||||
// first we check if we are allowed to create another
|
||||
if ((inUsePool.Count + idlePool.Count) == maxSize) return null;
|
||||
|
||||
MySqlInternalConnection conn = new MySqlInternalConnection( settings );
|
||||
conn.Open();
|
||||
idlePool.Add( conn );
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleaseConnection( MySqlInternalConnection connection )
|
||||
{
|
||||
lock (idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
{
|
||||
inUsePool.Remove( connection );
|
||||
if (connection.Settings.ConnectionLifetime != 0 && connection.IsTooOld())
|
||||
connection.Close();
|
||||
else
|
||||
idlePool.Add( connection );
|
||||
}
|
||||
}
|
||||
|
||||
public MySqlInternalConnection GetConnection()
|
||||
{
|
||||
MySqlInternalConnection conn = null;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
int ticks = settings.ConnectTimeout * 1000;
|
||||
|
||||
// wait timeOut seconds at most to get a connection
|
||||
while (conn == null && (Environment.TickCount - start) < ticks)
|
||||
conn = GetPooledConnection();
|
||||
|
||||
// if pool size is at maximum, then we must have reached our timeout so we simply
|
||||
// throw our exception
|
||||
if (conn == null)
|
||||
throw new MySqlException("error connecting: Timeout expired. The timeout period elapsed " +
|
||||
"prior to obtaining a connection from the pool. This may have occurred because all " +
|
||||
"pooled connections were in use and max pool size was reached.");
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,63 +1,63 @@
|
||||
using System;
|
||||
using ByteFX.Data.Common;
|
||||
using System.Collections;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MySqlPoolManager.
|
||||
/// </summary>
|
||||
internal sealed class MySqlPoolManager
|
||||
{
|
||||
private static Hashtable pools;
|
||||
|
||||
public MySqlPoolManager()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private static void Initialize()
|
||||
{
|
||||
pools = new Hashtable();
|
||||
}
|
||||
|
||||
public static MySqlInternalConnection GetConnection( MySqlConnectionString settings )
|
||||
{
|
||||
// make sure the manager is initialized
|
||||
if (MySqlPoolManager.pools == null)
|
||||
MySqlPoolManager.Initialize();
|
||||
|
||||
string text = settings.GetConnectionString();
|
||||
|
||||
lock( pools.SyncRoot )
|
||||
{
|
||||
MySqlPool pool;
|
||||
if (!pools.Contains( text ))
|
||||
{
|
||||
pool = new MySqlPool( settings );
|
||||
pools.Add( text, pool );
|
||||
}
|
||||
else
|
||||
{
|
||||
pool = (pools[text] as MySqlPool);
|
||||
}
|
||||
|
||||
return pool.GetConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReleaseConnection( MySqlInternalConnection connection )
|
||||
{
|
||||
lock (pools.SyncRoot)
|
||||
{
|
||||
string key = connection.Settings.GetConnectionString();
|
||||
MySqlPool pool = (MySqlPool)pools[ key ];
|
||||
if (pool == null)
|
||||
throw new MySqlException("Pooling exception: Unable to find original pool for connection");
|
||||
pool.ReleaseConnection(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using ByteFX.Data.Common;
|
||||
using System.Collections;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MySqlPoolManager.
|
||||
/// </summary>
|
||||
internal sealed class MySqlPoolManager
|
||||
{
|
||||
private static Hashtable pools;
|
||||
|
||||
public MySqlPoolManager()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private static void Initialize()
|
||||
{
|
||||
pools = new Hashtable();
|
||||
}
|
||||
|
||||
public static MySqlInternalConnection GetConnection( MySqlConnectionString settings )
|
||||
{
|
||||
// make sure the manager is initialized
|
||||
if (MySqlPoolManager.pools == null)
|
||||
MySqlPoolManager.Initialize();
|
||||
|
||||
string text = settings.ConnectString;
|
||||
|
||||
lock( pools.SyncRoot )
|
||||
{
|
||||
MySqlPool pool;
|
||||
if (!pools.Contains( text ))
|
||||
{
|
||||
pool = new MySqlPool( settings );
|
||||
pools.Add( text, pool );
|
||||
}
|
||||
else
|
||||
{
|
||||
pool = (pools[text] as MySqlPool);
|
||||
}
|
||||
|
||||
return pool.GetConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReleaseConnection( MySqlInternalConnection connection )
|
||||
{
|
||||
lock (pools.SyncRoot)
|
||||
{
|
||||
string key = connection.Settings.ConnectString;
|
||||
MySqlPool pool = (MySqlPool)pools[ key ];
|
||||
if (pool == null)
|
||||
throw new MySqlException("Pooling exception: Unable to find original pool for connection");
|
||||
pool.ReleaseConnection(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 3315 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user