diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e12a28 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +/tntdb/INSTALL +/tntdb/pkgconfig/*.pc +/tntdb/aclocal.m4 +/tntdb/autom4te.cache/ +/tntdb/config.guess +/tntdb/config.sub +/tntdb/configure +/tntdb/compile +/tntdb/depcomp +/tntdb/install-sh +/tntdb/ltmain.sh +/tntdb/m4/ +/tntdb/missing +/tntdb/src/config.h.in +/tntdb/src/config.h +/tntdb/config.log +/tntdb/config.status +/tntdb/libtool +/tntdb/demo/categories +/tntdb/demo/person +/tntdb/demo/pooldemo +/tntdb/demo/prodbench +/tntdb/demo/serial +/tntdb/demo/sqlcmd +/tntdb/doc/tntdb.doxygen +/tntdb/include/tntdb/config.h +/tntdb/test/tntdb-test +/tntdb/.git +/tntdb/packaging +/tntdb/obs +Makefile.in +Makefile +.deps +stamp-h1 +*.l[ao] +*.o +.libs diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e1c0471 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,346 @@ +@Library('etn-ipm2-jenkins') _ + +pipeline { + agent { + docker { + label 'docker-dev-1' + image infra.getDockerAgentImage() + args '--oom-score-adj=100 -v /etc/ssh/id_rsa_git-proxy-cache:/etc/ssh/id_rsa_git-proxy-cache:ro -v /etc/ssh/ssh_config:/etc/ssh/ssh_config:ro -v /etc/gitconfig:/etc/gitconfig:ro --security-opt seccomp=unconfined' + } + } + parameters { + // Use DEFAULT_DEPLOY_BRANCH_PATTERN and DEFAULT_DEPLOY_JOB_NAME if + // defined in this jenkins setup -- in Jenkins Management Web-GUI + // see Configure System / Global properties / Environment variables + // Default (if unset) is empty => no deployment attempt after good test + // See zproject Jenkinsfile-deploy.example for an example deploy job. + // TODO: Try to marry MultiBranchPipeline support with pre-set defaults + // directly in MultiBranchPipeline plugin, or mechanism like Credentials, + // or a config file uploaded to master for all jobs or this job, see + // https://jenkins.io/doc/pipeline/examples/#configfile-provider-plugin + string ( + defaultValue: '${DEFAULT_DEPLOY_BRANCH_PATTERN}', + description: 'Regular expression of branch names for which a deploy action would be attempted after a successful build and test; leave empty to not deploy. Reasonable value is ^(master|release/.*|feature/*)$', + name : 'DEPLOY_BRANCH_PATTERN') + string ( + defaultValue: '${DEFAULT_DEPLOY_JOB_NAME}', + description: 'Name of your job that handles deployments and should accept arguments: DEPLOY_GIT_URL DEPLOY_GIT_BRANCH DEPLOY_GIT_COMMIT -- and it is up to that job what to do with this knowledge (e.g. git archive + push to packaging); leave empty to not deploy', + name : 'DEPLOY_JOB_NAME') + booleanParam ( + defaultValue: true, + description: 'If the deployment is done, should THIS job wait for it to complete and include its success or failure as the build result (true), or should it schedule the job and exit quickly to free up the executor (false)', + name: 'DEPLOY_REPORT_RESULT') + booleanParam ( + defaultValue: true, + description: 'Attempt "make check" in this run?', + name: 'DO_TEST_CHECK') + booleanParam ( + defaultValue: false, + description: 'Attempt "make memcheck" in this run?', + name: 'DO_TEST_MEMCHECK') + booleanParam ( + defaultValue: false, + description: 'Attempt "make distcheck" in this run? (note: needs passing of config opts)', + name: 'DO_TEST_DISTCHECK') + booleanParam ( + defaultValue: false, + description: 'Attempt a "make install" check in this run? (note: hiccups on libname.so.x.y.zT)', + name: 'DO_TEST_INSTALL') + string ( + defaultValue: "`pwd`/tmp/_inst", + description: 'If attempting a "make install" check in this run, what DESTDIR to specify? (absolute path, defaults to "BUILD_DIR/tmp/_inst")', + name: 'USE_TEST_INSTALL_DESTDIR') + booleanParam ( + defaultValue: true, + description: 'Attempt "cppcheck" analysis before this run? (Note: corresponding tools are required in the build environment)', + name: 'DO_CPPCHECK') + booleanParam ( + defaultValue: true, + description: 'Require that there are no files not discovered changed/untracked via .gitignore after builds and tests?', + name: 'CI_REQUIRE_GOOD_GITIGNORE') + string ( + defaultValue: "30", + description: 'When running tests, use this timeout (in minutes; be sure to leave enough for double-job of a distcheck too)', + name: 'USE_TEST_TIMEOUT') + booleanParam ( + defaultValue: true, + description: 'When using temporary subdirs in build/test workspaces, wipe them after successful builds?', + name: 'DO_CLEANUP_AFTER_BUILD') + booleanParam ( + defaultValue: true, + description: 'When using temporary subdirs in build/test workspaces, wipe them after the whole job is done successfully?', + name: 'DO_CLEANUP_AFTER_JOB') + booleanParam ( + defaultValue: true, + description: 'When using temporary subdirs in build/test workspaces, wipe them after the whole job is done unsuccessfully (failed)? Note this would not allow postmortems on CI server, but would conserve its disk space.', + name: 'DO_CLEANUP_AFTER_FAILED_JOB') + } + triggers { + pollSCM 'H/5 * * * *' + } + + // Jenkins tends to reschedule jobs that have not yet completed if they took + // too long, maybe this happens in combination with polling. Either way, if + // the server gets into this situation, the snowball of same builds grows as + // the build system lags more and more. Let the devs avoid it in a few ways. + options { + disableConcurrentBuilds() + // Jenkins community suggested that instead of a default checkout, we can do + // an explicit step for that. It is expected that either way Jenkins "should" + // record that a particular commit is being processed, but the explicit ways + // might work better. In either case it honors SCM settings like refrepo if + // set up in the Pipeline or MultiBranchPipeline job. + skipDefaultCheckout() + } +// Note: your Jenkins setup may benefit from similar setup on side of agents: +// PATH="/usr/lib64/ccache:/usr/lib/ccache:/usr/bin:/bin:${PATH}" + stages { + stage ('pre-clean') { + steps { + milestone ordinal: 20, label: "${env.JOB_NAME}@${env.BRANCH_NAME}" + dir("tmp") { + sh 'if [ -s Makefile ]; then make -k distclean || true ; fi' + sh 'chmod -R u+w .' + deleteDir() + } + sh 'rm -f ccache.log cppcheck.xml' + } + } + stage ('git') { + steps { + retry(3) { + checkout scm + } + milestone ordinal: 30, label: "${env.JOB_NAME}@${env.BRANCH_NAME}" + script { + buildenv.setExtraEnvVariables() + buildenv.listInstalledPackage() + buildenv.checkDebianBuildDependencies() + } + } + } + stage ('prepare') { + steps { + sh 'cd tntdb && ./autogen.sh' + stash (name: 'prepped', includes: '**/*', excludes: '**/cppcheck.xml') + milestone ordinal: 40, label: "${env.JOB_NAME}@${env.BRANCH_NAME}" + } + } + stage ('configure') { + steps { + sh 'cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; ./configure --with-driverdir=/usr/lib/tntdb --with-doxygen=no --without-postgresql --without-sqlite --with-mysql )' + } + } + stage ('compile') { + steps { + sh 'cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make -k -j4 all || make all )' + sh 'echo "Are GitIgnores good after make? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + script { + if ( (params.DO_TEST_CHECK && params.DO_TEST_MEMCHECK) || (params.DO_TEST_CHECK && params.DO_TEST_DISTCHECK) || (params.DO_TEST_MEMCHECK && params.DO_TEST_DISTCHECK) || + (params.DO_TEST_INSTALL && params.DO_TEST_MEMCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_DISTCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_CHECK) + ) { + stash (name: 'built', includes: '**/*') + } + } + } + } + stage ('check') { + parallel { + stage ('cppcheck') { + when { expression { return ( params.DO_CPPCHECK ) } } + steps { + dir("tmp/test-cppcheck") { + deleteDir() + unstash 'prepped' + sh 'cppcheck --std=c++11 --enable=all --inconclusive --xml --xml-version=2 . 2>cppcheck.xml' + archiveArtifacts artifacts: '**/cppcheck.xml' + sh 'rm -f cppcheck.xml' + script { + if ( params.DO_CLEANUP_AFTER_BUILD ) { + deleteDir() + } + } + } + } + } + stage ('make check') { + when { expression { return ( params.DO_TEST_CHECK ) } } + steps { + script { + if ( (params.DO_TEST_CHECK && params.DO_TEST_MEMCHECK) || (params.DO_TEST_CHECK && params.DO_TEST_DISTCHECK) || (params.DO_TEST_MEMCHECK && params.DO_TEST_DISTCHECK) || + (params.DO_TEST_INSTALL && params.DO_TEST_MEMCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_DISTCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_CHECK) + ) { + dir("tmp/test-check") { + deleteDir() + unstash 'built' + timeout (time: "${params.USE_TEST_TIMEOUT}".toInteger(), unit: 'MINUTES') { + sh 'cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make check )' + } + sh 'echo "Are GitIgnores good after make check? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + script { + if ( params.DO_CLEANUP_AFTER_BUILD ) { + deleteDir() + } + } + } + } else { + timeout (time: "${params.USE_TEST_TIMEOUT}".toInteger(), unit: 'MINUTES') { + sh 'cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make check )' + } + sh 'echo "Are GitIgnores good after make check? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + } + } + } + } + stage ('make memcheck') { + when { expression { return ( params.DO_TEST_MEMCHECK ) } } + steps { + script { + if ( (params.DO_TEST_CHECK && params.DO_TEST_MEMCHECK) || (params.DO_TEST_CHECK && params.DO_TEST_DISTCHECK) || (params.DO_TEST_MEMCHECK && params.DO_TEST_DISTCHECK) || + (params.DO_TEST_INSTALL && params.DO_TEST_MEMCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_DISTCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_CHECK) + ) { + dir("tmp/test-memcheck") { + deleteDir() + unstash 'built' + timeout (time: "${params.USE_TEST_TIMEOUT}".toInteger(), unit: 'MINUTES') { + sh 'cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make memcheck && exit 0 ; echo "Re-running failed ($?) memcheck with greater verbosity" >&2 ; make VERBOSE=1 memcheck-verbose )' + } + sh 'echo "Are GitIgnores good after make memcheck? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + script { + if ( params.DO_CLEANUP_AFTER_BUILD ) { + deleteDir() + } + } + } + } else { + timeout (time: "${params.USE_TEST_TIMEOUT}".toInteger(), unit: 'MINUTES') { + sh 'cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make memcheck && exit 0 ; echo "Re-running failed ($?) memcheck with greater verbosity" >&2 ; make VERBOSE=1 memcheck-verbose )' + } + sh 'echo "Are GitIgnores good after make memcheck? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + } + } + } + } + stage ('make distcheck') { + when { expression { return ( params.DO_TEST_DISTCHECK ) } } + steps { + script { + if ( (params.DO_TEST_CHECK && params.DO_TEST_MEMCHECK) || (params.DO_TEST_CHECK && params.DO_TEST_DISTCHECK) || (params.DO_TEST_MEMCHECK && params.DO_TEST_DISTCHECK) || + (params.DO_TEST_INSTALL && params.DO_TEST_MEMCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_DISTCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_CHECK) + ) { + dir("tmp/test-distcheck") { + deleteDir() + unstash 'built' + timeout (time: "${params.USE_TEST_TIMEOUT}".toInteger(), unit: 'MINUTES') { + sh 'cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make DISTCHECK_CONFIGURE_FLAGS="--with-driverdir=/usr/lib/tntdb --with-doxygen=no --without-postgresql --without-sqlite --with-mysql" distcheck )' + } + sh 'echo "Are GitIgnores good after make distcheck? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + script { + if ( params.DO_CLEANUP_AFTER_BUILD ) { + deleteDir() + } + } + } + } else { + timeout (time: "${params.USE_TEST_TIMEOUT}".toInteger(), unit: 'MINUTES') { + sh 'cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make DISTCHECK_CONFIGURE_FLAGS="--with-driverdir=/usr/lib/tntdb --with-doxygen=no --without-postgresql --without-sqlite --with-mysql" distcheck )' + } + sh 'echo "Are GitIgnores good after make distcheck? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + } + } + } + } + stage ('make install check') { + when { expression { return ( params.DO_TEST_INSTALL ) } } + steps { + script { + if ( (params.DO_TEST_CHECK && params.DO_TEST_MEMCHECK) || (params.DO_TEST_CHECK && params.DO_TEST_DISTCHECK) || (params.DO_TEST_MEMCHECK && params.DO_TEST_DISTCHECK) || + (params.DO_TEST_INSTALL && params.DO_TEST_MEMCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_DISTCHECK) || (params.DO_TEST_INSTALL && params.DO_TEST_CHECK) + ) { + dir("tmp/test-install-check") { + deleteDir() + unstash 'built' + timeout (time: "${params.USE_TEST_TIMEOUT}".toInteger(), unit: 'MINUTES') { + sh """cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make DESTDIR="${params.USE_TEST_INSTALL_DESTDIR}" install )""" + } + sh 'echo "Are GitIgnores good after make install? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + script { + if ( params.DO_CLEANUP_AFTER_BUILD ) { + deleteDir() + } + } + } + } else { + timeout (time: "${params.USE_TEST_TIMEOUT}".toInteger(), unit: 'MINUTES') { + sh """cd tntdb && ( CCACHE_BASEDIR="`pwd`" ; export CCACHE_BASEDIR; make DESTDIR="${params.USE_TEST_INSTALL_DESTDIR}" install )""" + } + sh 'echo "Are GitIgnores good after make install? (should have no output below)"; git status -s || if [ "${params.CI_REQUIRE_GOOD_GITIGNORE}" = false ]; then echo "WARNING GitIgnore tests found newly changed or untracked files" >&2 ; exit 0 ; else echo "FAILED GitIgnore tests" >&2 ; exit 1; fi' + } + } + } + } + } + } + stage ('Deploy') { + parallel { + stage ("Push to OBS") { + when { + anyOf { + branch 'master' + branch "release/*" + branch "featureimage/*" + branch 'FTY' + branch '*-FTY-master' + branch '*-FTY' + } + } + steps { + script { + deploy.pushToOBS() + } + } + } + } + } + stage ('cleanup') { + when { expression { return ( params.DO_CLEANUP_AFTER_BUILD ) } } + steps { + deleteDir() + } + } + } + post { + success { + script { + if (currentBuild.getPreviousBuild()?.result != 'SUCCESS') { + // Uncomment desired notification + + //slackSend (color: "#008800", message: "Build ${env.JOB_NAME} is back to normal.") + //emailext (to: "qa@example.com", subject: "Build ${env.JOB_NAME} is back to normal.", body: "Build ${env.JOB_NAME} is back to normal.") + } + if ( params.DO_CLEANUP_AFTER_JOB ) { + dir("tmp") { + deleteDir() + } + } + } + } + failure { + // Uncomment desired notification + // Section must not be empty, you can delete the sleep once you set notification + sleep 1 + //slackSend (color: "#AA0000", message: "Build ${env.BUILD_NUMBER} of ${env.JOB_NAME} ${currentBuild.result} (<${env.BUILD_URL}|Open>)") + //emailext (to: "qa@example.com", subject: "Build ${env.JOB_NAME} failed!", body: "Build ${env.BUILD_NUMBER} of ${env.JOB_NAME} ${currentBuild.result}\nSee ${env.BUILD_URL}") + + dir("tmp") { + script { + if ( params.DO_CLEANUP_AFTER_FAILED_JOB ) { + deleteDir() + } else { + sh """ echo "NOTE: BUILD AREA OF WORKSPACE `pwd` REMAINS FOR POST-MORTEMS ON `hostname` AND CONSUMES `du -hs . | awk '{print \$1}'` !" """ + } + } + } + } + } +} diff --git a/obs/debian.changelog b/obs/debian.changelog new file mode 100644 index 0000000..d1ff5b1 --- /dev/null +++ b/obs/debian.changelog @@ -0,0 +1,131 @@ +tntdb (1.3-2etn2) unstable; urgency=high + + * Enable debug symbol debian packages + + -- Jim Klimov Thu, 9 Nov 2017 15:09:45 +0200 + +tntdb (1.3-2etn1) unstable; urgency=low + + * Fix connections leakage in MySQL driver + + -- Michal Hrusecky Tue, 9 Jun 2015 9:35:32 +0200 + +tntdb (1.3-2) unstable; urgency=low + + * Build-Conflicts: libtntdb3, libtntdb-dev (Closes: #716749) + + -- Kari Pahula Fri, 12 Jul 2013 19:35:32 +0300 + +tntdb (1.3-1) unstable; urgency=low + + * New upstream release (SONAME 4) + * Standards-Version 3.9.4 and debhelper compat 9. + + -- Kari Pahula Sat, 25 May 2013 12:00:54 +0300 + +tntdb (1.2-2) unstable; urgency=low + + * Removed CXX=g++-4.7 from configure's parameters, fix FTBFS. + (Closes: #671051) + * This version won't FTBFS with g++-4.7 (assuming b-d or g++ (>= 4.7)) + (Closes: #667393) + + -- Kari Pahula Wed, 02 May 2012 17:23:48 +0300 + +tntdb (1.2-1) unstable; urgency=low + + * New upstream release (SONAME 3) + * Standards-Version 3.9.3 (no changes necessary). + * Use dh-autoreconf + * Run test suite at build time. + + -- Kari Pahula Sat, 28 Apr 2012 11:26:54 +0300 + +tntdb (1.1-1) unstable; urgency=low + + * New upstream release (SONAME 2) + * Standards-Version 3.9.2 (no changes necessary). + * Don't install .la files. (Closes: #633210) + * debian/source/format "quilt (3.0)" and drop quilt as a build + dependency. + * Parse and use the parallel= DEB_BUILD_OPTION. + + -- Kari Pahula Mon, 08 Aug 2011 21:57:30 +0300 + +tntdb (1.0.1-3) unstable; urgency=low + + * Add -I m4/ aclocal's parameters, to make sure ACX_PTHREAD is + recognized. + + -- Kari Pahula Sun, 28 Jun 2009 15:17:03 +0300 + +tntdb (1.0.1-2) unstable; urgency=low + + * Bumped Standards-Version to 3.8.2 (no changes). + * Copy config.{sub,guess} from autotools-dev. (Closes: #533961) + * Patch to add a few #include statements to make g++ 4.4 + happy. (Closes: #504975) + * Add quilt as a build dependency. + * Omit .a files from -dev package. + * Add automake1.9 and autoconf as build deps and regenerate build + scripts. + + -- Kari Pahula Sat, 27 Jun 2009 23:33:58 +0300 + +tntdb (1.0.1-1) unstable; urgency=low + + * New upstream release + * Bumped Standards-Version to 3.8.0 (no changes). + + -- Kari Pahula Mon, 16 Jun 2008 12:12:24 +0300 + +tntdb (1.0.0-1) unstable; urgency=low + + * New upstream release (Closes: #455639) + * SONAME 0 -> 1. + * Bumped Standards-Version to 3.7.3 and set the Homepage field. + * Install driver backends in /usr/lib/tntdb, not tntdb$(SONAME) + + -- Kari Pahula Thu, 27 Mar 2008 20:13:27 +0200 + +tntdb (0.9.2-1) unstable; urgency=low + + * New upstream release (Closes: #417728) + + -- Kari Pahula Fri, 18 May 2007 19:45:32 +0300 + +tntdb (0.9.0-3) unstable; urgency=low + + * Changed dependency to the tntdb-* packages to a recommends in + libtntdb0 (Closes: #391973) + + -- Kari Pahula Sun, 22 Oct 2006 18:41:01 +0300 + +tntdb (0.9.0-2) unstable; urgency=low + + * Added missing build-dep doxygen. + * Install html and pdf documentation to libtntdb-dev. + + -- Kari Pahula Sun, 8 Oct 2006 01:46:27 +0300 + +tntdb (0.9.0-1) unstable; urgency=low + + * New upstream release + + -- Kari Pahula Sat, 7 Oct 2006 18:34:14 +0300 + +tntdb (0.6.3-2) unstable; urgency=low + + * Moved database access backends to tntdb0-mysql, tntdb0-postgresql and + tntdb0-sqlite. + * Added missing build-dep on libtool (Closes: #385777) + * Added dependency to libtntdb0 from libtntdb-dev + + -- Kari Pahula Tue, 5 Sep 2006 00:07:31 +0300 + +tntdb (0.6.3-1) unstable; urgency=low + + * Initial release (Closes: #374132) + + -- Kari Pahula Fri, 25 Aug 2006 00:32:44 +0300 + diff --git a/obs/debian.compat b/obs/debian.compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/obs/debian.compat @@ -0,0 +1 @@ +10 diff --git a/obs/debian.control b/obs/debian.control new file mode 100644 index 0000000..c87cf94 --- /dev/null +++ b/obs/debian.control @@ -0,0 +1,83 @@ +Source: tntdb +Section: libs +Priority: optional +Maintainer: Kari Pahula +Build-Depends: cdbs, debhelper (>= 9), libcxxtools-dev (>= 2.2), libsqlite3-dev, libmariadbclient-dev (<= 10.5.8) | libmariadbclient-dev-compat, libpq-dev, libltdl-dev, doxygen, dh-autoreconf, sqlite3 +Build-Conflicts: libtntdb-dev, libtntdb3 +Standards-Version: 3.9.4 +Homepage: http://www.tntnet.org/tntdb.html + +Package: libtntdb4 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: tntdb-mysql4|tntdb-postgresql4|tntdb-sqlite4 +Suggests: tntdb-mysql4, tntdb-postgresql4, tntdb-sqlite4, libtntdb-dev +Description: C++ class library for easy database access + This library provides a thin, database independent layer over an SQL + database. It lacks complex features like schema queries or wrapper + classes like active result sets or data bound controls. Instead you + get to access the database directly with SQL queries. The library is + suited for application programming, not for writing generic database + handling tools. + . + Currently has support for MySQL, PostgreSQL and SQLite. + +Package: tntdb-mysql4 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: MySQL backend for tntdb database access library + This library provides a thin, database independent layer over an SQL + database. It lacks complex features like schema queries or wrapper + classes like active result sets or data bound controls. Instead you + get to access the database directly with SQL queries. The library is + suited for application programming, not for writing generic database + handling tools. + . + This file has the necessary files for MySQL support. + +Package: tntdb-postgresql4 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: PostgreSQL backend for tntdb database access library + This library provides a thin, database independent layer over an SQL + database. It lacks complex features like schema queries or wrapper + classes like active result sets or data bound controls. Instead you + get to access the database directly with SQL queries. The library is + suited for application programming, not for writing generic database + handling tools. + . + This file has the necessary files for PostgreSQL support. + +Package: tntdb-sqlite4 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: SQLite backend for tntdb database access library + This library provides a thin, database independent layer over an SQL + database. It lacks complex features like schema queries or wrapper + classes like active result sets or data bound controls. Instead you + get to access the database directly with SQL queries. The library is + suited for application programming, not for writing generic database + handling tools. + . + This file has the necessary files for SQLite support. + +Package: libtntdb-dev +Architecture: any +Section: libdevel +Depends: libtntdb4 (= ${binary:Version}), libcxxtools-dev, ${shlibs:Depends}, ${misc:Depends}, libjs-jquery +Description: Development headers for tntdb + This library provides a thin, database independent layer over an SQL + database. It lacks complex features like schema queries or wrapper + classes like active result sets or data bound controls. Instead you + get to access the database directly with SQL queries. The library is + suited for application programming, not for writing generic database + handling tools. + . + Currently has support for MySQL, PostgreSQL and SQLite. + +Package: libtntdb-dbg +Architecture: any +Section: debug +Priority: optional +Depends: libtntdb4 (= ${binary:Version}), ${misc:Depends} +Description: tntdb debugging symbols diff --git a/obs/debian.copyright b/obs/debian.copyright new file mode 100644 index 0000000..61d8118 --- /dev/null +++ b/obs/debian.copyright @@ -0,0 +1,45 @@ +nThis package was debianized by Kari Pahula on +Sat, 29 Jul 2006 17:56:27 +0300. + +It was downloaded from http://tntnet.de/tntdb.html + +Upstream Author: Tommi Mäkitalo + +Copyright: + 2005-2008,2010-2012 Tommi Mäkitalo + 2007-2008 Marc Boris Dürner + 2007 Mark Wright + +License: + + This package 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. + + As a special exception, you may use this file as part of a free + software library without restriction. Specifically, if other files + instantiate templates or use macros or inline functions from this + file, or you compile this file and link it with other files to + produce an executable, this file does not by itself cause the + resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU Library + General Public License. + + This package 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 package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU Lesser General +Public License can be found in `/usr/share/common-licenses/LGPL'. + + +The Debian packaging is (C) 2006-2008, 2011-2012 Kari Pahula + and is licensed under the GPLv2 or later, see +`/usr/share/common-licenses/GPL'. diff --git a/obs/debian.docs b/obs/debian.docs new file mode 100644 index 0000000..50bd824 --- /dev/null +++ b/obs/debian.docs @@ -0,0 +1,2 @@ +NEWS +README diff --git a/obs/debian.libtntdb-dev.install b/obs/debian.libtntdb-dev.install new file mode 100644 index 0000000..ba7d281 --- /dev/null +++ b/obs/debian.libtntdb-dev.install @@ -0,0 +1,8 @@ +debian/tmp/usr/lib/lib*.so usr/lib +debian/tmp/usr/include/ usr +debian/tmp/usr/lib/pkgconfig/*.pc +doc/tntdb.odt usr/share/doc/libtntdb-dev +doc/tntdb.pdf usr/share/doc/libtntdb-dev +doc/html/ usr/share/doc/libtntdb-dev +demo/*.cpp usr/share/doc/libtntdb-dev/examples +demo/*.h usr/share/doc/libtntdb-dev/examples diff --git a/obs/debian.libtntdb4.install b/obs/debian.libtntdb4.install new file mode 100644 index 0000000..c55dfff --- /dev/null +++ b/obs/debian.libtntdb4.install @@ -0,0 +1,2 @@ +debian/tmp/usr/lib/lib*.so.* usr/lib +debian/tmp/usr/lib/tntdb/tntdb*-replicate.so* diff --git a/obs/debian.rules b/obs/debian.rules new file mode 100644 index 0000000..23abf45 --- /dev/null +++ b/obs/debian.rules @@ -0,0 +1,29 @@ +#!/usr/bin/make -f + +DEB_BUILD_PARALLEL=yes + +include /usr/share/cdbs/1/rules/autoreconf.mk +include /usr/share/cdbs/1/class/autotools.mk +include /usr/share/cdbs/1/rules/debhelper.mk + +DEB_CONFIGURE_EXTRA_FLAGS := --with-driverdir=/usr/lib/tntdb --with-doxygen +DEB_DH_MAKESHLIBS_ARGS := -Xusr/lib/tntdb + +pre-build:: debian/compat + if [ "`find tntdb/ | wc -l`" -gt 1 ] ; then mv -f tntdb/* ./ ; fi + +clean:: + rm -fr doc/html/ doc/latex/ + rm -f config.guess config.sub config.log + rm -f src/config.h.in + rm -f test/test.db + +binary-post-install/libtntdb-dev:: + rm -f debian/libtntdb-dev/usr/share/doc/libtntdb-dev/html/jquery.js + cd debian/libtntdb-dev/usr/share/doc/libtntdb-dev/html/; ln -s ../../../javascript/jquery/jquery.js jquery.js +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + cd test; sqlite3 test.db < sqlite-test.sql; ./tntdb-test || /bin/true +endif + +override_dh_strip: + dh_strip --dbg-package=libtntdb-dbg diff --git a/obs/debian.series b/obs/debian.series new file mode 100644 index 0000000..ad911c2 --- /dev/null +++ b/obs/debian.series @@ -0,0 +1,3 @@ +# This source tarball is taken from a dedicated Git branch head, so +# no further patches are to be applied (change the repo if needed). + diff --git a/obs/debian.tntdb-mysql4.install b/obs/debian.tntdb-mysql4.install new file mode 100644 index 0000000..496cfb4 --- /dev/null +++ b/obs/debian.tntdb-mysql4.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/tntdb/tntdb*-mysql.so* diff --git a/obs/debian.tntdb-postgresql4.install b/obs/debian.tntdb-postgresql4.install new file mode 100644 index 0000000..2f39bf8 --- /dev/null +++ b/obs/debian.tntdb-postgresql4.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/tntdb/tntdb*-postgresql.so* diff --git a/obs/debian.tntdb-sqlite4.install b/obs/debian.tntdb-sqlite4.install new file mode 100644 index 0000000..592900d --- /dev/null +++ b/obs/debian.tntdb-sqlite4.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/tntdb/tntdb*-sqlite.so* diff --git a/obs/tntdb-1.3-avoid-version.patch b/obs/tntdb-1.3-avoid-version.patch new file mode 100644 index 0000000..7262808 --- /dev/null +++ b/obs/tntdb-1.3-avoid-version.patch @@ -0,0 +1,68 @@ +This patch is applied to 42ITy build of tntdb-1.3 fork on RPM systems only. + +Index: src/mysql/Makefile.am +=================================================================== +--- src/mysql/Makefile.am.orig ++++ src/mysql/Makefile.am +@@ -9,7 +9,7 @@ if MAKE_MYSQL + driver_LTLIBRARIES = tntdb@abi_current@-mysql.la + + tntdb@abi_current@_mysql_la_SOURCES = $(sources) +-tntdb@abi_current@_mysql_la_LDFLAGS = -module -version-info @sonumber@ @MYSQL_LDFLAGS@ @SHARED_LIB_FLAG@ ++tntdb@abi_current@_mysql_la_LDFLAGS = -module -avoid-version -version-info @sonumber@ @MYSQL_LDFLAGS@ @SHARED_LIB_FLAG@ + tntdb@abi_current@_mysql_la_LIBADD = $(top_builddir)/src/libtntdb.la + + endif +Index: src/oracle/Makefile.am +=================================================================== +--- src/oracle/Makefile.am.orig ++++ src/oracle/Makefile.am +@@ -22,7 +22,7 @@ if MAKE_ORACLE + driver_LTLIBRARIES = tntdb@abi_current@-oracle.la + + tntdb@abi_current@_oracle_la_SOURCES = $(sources) +-tntdb@abi_current@_oracle_la_LDFLAGS = -module -version-info @sonumber@ @SHARED_LIB_FLAG@ ++tntdb@abi_current@_oracle_la_LDFLAGS = -module -avoid-version -version-info @sonumber@ @SHARED_LIB_FLAG@ + tntdb@abi_current@_oracle_la_LIBADD = $(top_builddir)/src/libtntdb.la -lclntsh + + endif +Index: src/postgresql/Makefile.am +=================================================================== +--- src/postgresql/Makefile.am.orig ++++ src/postgresql/Makefile.am +@@ -9,7 +9,7 @@ if MAKE_POSTGRESQL + driver_LTLIBRARIES = tntdb@abi_current@-postgresql.la + + tntdb@abi_current@_postgresql_la_SOURCES = $(sources) +-tntdb@abi_current@_postgresql_la_LDFLAGS = -module -version-info @sonumber@ @PG_LDFLAGS@ @SHARED_LIB_FLAG@ ++tntdb@abi_current@_postgresql_la_LDFLAGS = -module -avoid-version -version-info @sonumber@ @PG_LDFLAGS@ @SHARED_LIB_FLAG@ + tntdb@abi_current@_postgresql_la_LIBADD = $(top_builddir)/src/libtntdb.la + + endif +Index: src/replicate/Makefile.am +=================================================================== +--- src/replicate/Makefile.am.orig ++++ src/replicate/Makefile.am +@@ -7,7 +7,7 @@ if MAKE_REPLICATE + driver_LTLIBRARIES = tntdb@abi_current@-replicate.la + + tntdb@abi_current@_replicate_la_SOURCES = $(sources) +-tntdb@abi_current@_replicate_la_LDFLAGS = -module -version-info @sonumber@ @SHARED_LIB_FLAG@ ++tntdb@abi_current@_replicate_la_LDFLAGS = -module -avoid-version -version-info @sonumber@ @SHARED_LIB_FLAG@ + tntdb@abi_current@_replicate_la_LIBADD = $(top_builddir)/src/libtntdb.la + + endif +Index: src/sqlite/Makefile.am +=================================================================== +--- src/sqlite/Makefile.am.orig ++++ src/sqlite/Makefile.am +@@ -7,7 +7,7 @@ if MAKE_SQLITE + driver_LTLIBRARIES = tntdb@abi_current@-sqlite.la + + tntdb@abi_current@_sqlite_la_SOURCES = $(sources) +-tntdb@abi_current@_sqlite_la_LDFLAGS = -module -version-info @sonumber@ -lsqlite3 @SHARED_LIB_FLAG@ ++tntdb@abi_current@_sqlite_la_LDFLAGS = -module -avoid-version -version-info @sonumber@ -lsqlite3 @SHARED_LIB_FLAG@ + tntdb@abi_current@_sqlite_la_LIBADD = $(top_builddir)/src/libtntdb.la + + endif + diff --git a/obs/tntdb.changes b/obs/tntdb.changes new file mode 100644 index 0000000..e7e1615 --- /dev/null +++ b/obs/tntdb.changes @@ -0,0 +1,31 @@ +------------------------------------------------------------------- +Thu Nov 10 13:09:45 UTC 2017 - EvgenyKlimov@eaton.com + +- enable debug-symbol debian packages + +------------------------------------------------------------------- +Wed Jun 10 12:42:16 UTC 2015 - michal.hrusecky@opensuse.org + +- Fix connection leaking bug + http://sourceforge.net/p/tntnet/mailman/message/31875108/ + +------------------------------------------------------------------- +Mon Sep 8 13:15:03 UTC 2014 - michal.hrusecky@opensuse.org + +- better package structure + +------------------------------------------------------------------- +Wed Oct 23 09:09:43 UTC 2013 - mhrusecky@suse.com + +- Updated to version 1.3 of the package + +------------------------------------------------------------------- +Sat Feb 23 16:52:05 UTC 2013 - mhrusecky@suse.com + +- Updated to version 1.2 of the package + +------------------------------------------------------------------- +Tue Jan 17 11:18:37 CET 2012 - mhrusecky@suse.cz + +- Packaged version 1.1 of the package + diff --git a/obs/tntdb.dsc b/obs/tntdb.dsc new file mode 100644 index 0000000..940934a --- /dev/null +++ b/obs/tntdb.dsc @@ -0,0 +1,18 @@ +Format: 1.0 +Source: tntdb +Binary: libtntdb4, tntdb-mysql4, tntdb-postgresql4, tntdb-sqlite4, libtntdb-dev, libtntdb-dbg +Architecture: any +Version: 1.3-2etn2 +Maintainer: Kari Pahula +Homepage: http://www.tntnet.org/tntdb.html +Standards-Version: 3.9.4 +Build-Depends: cdbs, debhelper (>= 9), libcxxtools-dev (>= 2.2), libsqlite3-dev, libmariadbclient-dev (<= 10.5.8) | libmariadbclient-dev-compat, libpq-dev, libltdl-dev, doxygen, dh-autoreconf, sqlite3 +Build-Conflicts: libtntdb-dev, libtntdb3 +Package-List: + libtntdb-dev deb libdevel optional + libtntdb4 deb libs optional + tntdb-mysql4 deb libs optional + tntdb-postgresql4 deb libs optional + tntdb-sqlite4 deb libs optional + libtntdb-dbg deb debug extra +DEBTRANSFORM-TAR: tntdb-1.3.tar.gz diff --git a/obs/tntdb.spec b/obs/tntdb.spec new file mode 100644 index 0000000..c126566 --- /dev/null +++ b/obs/tntdb.spec @@ -0,0 +1,167 @@ +# +# spec file for package tntdb +# +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# Note: for 42ity, maybe this should require (or optionalize) mariadb-devel +# if defined on target distro at all + +Name: tntdb +Version: 1.3 +Release: 1 +Summary: Library for simple database access +License: GPL-2.0+ +Group: Development/Libraries/C and C++ +Url: http://www.tntnet.org/index.html +Source0: tntdb-%{version}.tar.gz +Patch0: tntdb-1.3-avoid-version.patch +#Patch1: connection.patch +#Patch2: 0002-add-pkgconfig-support.patch +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: findutils +BuildRequires: gcc-c++ +BuildRequires: glibc-devel +BuildRequires: gnutls-devel +BuildRequires: libcxxtools-devel +BuildRequires: libtool +BuildRequires: lzo +BuildRequires: lzo-devel +BuildRequires: mysql-devel +BuildRequires: openssl-devel +BuildRequires: pkg-config +%if 0%{?suse_version} > 1315 +### 42ity-OBS offers several implementation and bugs out +BuildRequires: postgresql96-devel +BuildRequires: postgresql96 +%else +BuildRequires: postgresql-devel +%endif +BuildRequires: sqlite-devel +BuildRequires: zip +BuildRequires: zlib-devel +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description +Tntdb is a library for simple database access. + +The database independent layer offers easy to use methods for working with the database and also greatly simplifies resource-management. The classes hold reference-counted pointers to the actual implementation. They are copyable and assignable. The user can use the classes just like simple values. The resources they reference are freed, when the last reference is deleted. This happens normally just by leaving the scope. There is normally no reason to instantiate them dynamically on the heap. + +The driver-layer contains the actual implementation, which does the work. These classes are database-dependent. The user normally doesn't need to deal with this. + +%package -n libtntdb4 +Summary: Library for simple database access +Group: Development/Libraries/C and C++ +Provides: tntdb + +%description -n libtntdb4 +Tntdb is a library for simple database access. + +The database independent layer offers easy to use methods for working with the database and also greatly simplifies resource-management. The classes hold reference-counted pointers to the actual implementation. They are copyable and assignable. The user can use the classes just like simple values. The resources they reference are freed, when the last reference is deleted. This happens normally just by leaving the scope. There is normally no reason to instantiate them dynamically on the heap. + +The driver-layer contains the actual implementation, which does the work. These classes are database-dependent. The user normally doesn't need to deal with this. + +%package -n libtntdb-devel +Summary: Development files for tntdb +Group: Development/Libraries/C and C++ +Provides: tntdb-devel +Requires: cxxtools-devel +Requires: libtntdb4 = %{version} + +%description -n libtntdb-devel +Headers and so links for tntdb library. + +%package -n tntdb-mysql +Summary: MySQL plugin for tntdb +Group: Development/Libraries/C and C++ + +%description -n tntdb-mysql +MySQL plugin for tntdb abstraction library. + +%package -n tntdb-postgresql +Summary: PostgreSQL plugin for tntdb +Group: Development/Libraries/C and C++ + +%description -n tntdb-postgresql +PostgreSQL plugin for tntdb abstraction library. + +%package -n tntdb-sqlite +Summary: SQLite plugin for tntdb +Group: Development/Libraries/C and C++ + +%description -n tntdb-sqlite +SQLite plugin for tntdb abstraction library. + +%package -n tntdb-replicate +Summary: SQLite plugin for tntdb +Group: Development/Libraries/C and C++ + +%description -n tntdb-replicate +Replication plugin for tntdb abstraction library. + +%prep +%setup -q -n tntdb-%{version} +if [ "`find tntdb/ | wc -l`" -gt 1 ] ; then mv -f tntdb/* ./ ; fi +%patch0 +#%patch1 -p1 +#%patch2 -p1 + +%build +autoreconf -vi +%configure --with-doxygen=no +make %{?_smp_mflags} + +%install +make DESTDIR=%{buildroot} install %{?_smp_mflags} +find %{buildroot} -type f -name "*.la" -delete -print +find %{buildroot} -name '*.a' -delete + +%post -n libtntdb4 -p /sbin/ldconfig + +%postun -n libtntdb4 -p /sbin/ldconfig + +%files -n libtntdb4 +%defattr (-, root, root) +%{_libdir}/libtntdb.so.* + +%files -n libtntdb-devel +%defattr (-, root, root) +%doc AUTHORS ChangeLog README +%{_includedir}/tntdb +%{_includedir}/tntdb.h +%{_libdir}/libtntdb.so +%{_libdir}/pkgconfig/*.pc + +%files -n tntdb-mysql +%defattr (-, root, root) +%dir %{_libdir}/tntdb +%{_libdir}/tntdb/tntdb*mysql.so + +%files -n tntdb-postgresql +%defattr (-, root, root) +%dir %{_libdir}/tntdb +%{_libdir}/tntdb/tntdb*postgresql.so + +%files -n tntdb-sqlite +%defattr (-, root, root) +%dir %{_libdir}/tntdb +%{_libdir}/tntdb/tntdb*sqlite.so + +%files -n tntdb-replicate +%defattr (-, root, root) +%dir %{_libdir}/tntdb +%{_libdir}/tntdb/tntdb*replicate.so + +%changelog diff --git a/tntdb/Makefile.am b/tntdb/Makefile.am index d92b8ba..6858a4c 100644 --- a/tntdb/Makefile.am +++ b/tntdb/Makefile.am @@ -14,3 +14,7 @@ SUBDIRS = \ EXTRA_DIST = \ COPYING + +pkgconfigdir = $(libdir)/pkgconfig/ + +pkgconfig_DATA = pkgconfig/tntdb.pc diff --git a/tntdb/configure.in b/tntdb/configure.ac similarity index 94% rename from tntdb/configure.in rename to tntdb/configure.ac index cd3de00..414c903 100644 --- a/tntdb/configure.in +++ b/tntdb/configure.ac @@ -1,4 +1,7 @@ -AC_INIT(tntdb, 1.3rc3, [Tommi Maekitalo ]) +# This is upstream tntdb-1.3rc3 with tweaks for 42ity project +# The original version string drove the pkgconfig parser mad +# (it is not ">= 1.3.0" that we require in configre scripts) +AC_INIT([tntdb], [1.3.0], [Tommi Maekitalo ]) AM_INIT_AUTOMAKE abi_current=4 @@ -173,9 +176,9 @@ AC_ARG_WITH( if test "$with_mysql" = yes then - AC_PATH_PROGS(MYSQL_CONFIG, mysql_config) + AC_PATH_PROGS(MYSQL_CONFIG, mysql_config mariadb_config) if ! test -x "$MYSQL_CONFIG"; then - AC_MSG_ERROR([mysql configuration script was not found]) + AC_MSG_ERROR([mysql (or mariadb) configuration script was not found]) fi MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags` @@ -281,6 +284,7 @@ AC_SUBST(SHARED_LIB_FLAG) AC_CONFIG_FILES([ Makefile + pkgconfig/tntdb.pc src/Makefile src/mysql/Makefile src/postgresql/Makefile diff --git a/tntdb/include/tntdb/mysql/impl/connection.h b/tntdb/include/tntdb/mysql/impl/connection.h index 84fd709..f0d0422 100644 --- a/tntdb/include/tntdb/mysql/impl/connection.h +++ b/tntdb/include/tntdb/mysql/impl/connection.h @@ -38,7 +38,7 @@ namespace tntdb { class Connection : public IStmtCacheConnection { - MYSQL mysql; + MYSQL* mysql; bool initialized; unsigned transactionActive; std::string lockTablesQuery; @@ -56,7 +56,7 @@ namespace tntdb const char* unix_socket = 0, unsigned long client_flag = 0); ~Connection(); - MYSQL* getHandle() { return &mysql; } + MYSQL* getHandle() { return mysql; } void beginTransaction(); void commitTransaction(); diff --git a/tntdb/include/tntdb/mysql/impl/statement.h b/tntdb/include/tntdb/mysql/impl/statement.h index ddc8524..47e5d23 100644 --- a/tntdb/include/tntdb/mysql/impl/statement.h +++ b/tntdb/include/tntdb/mysql/impl/statement.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include namespace tntdb @@ -44,7 +44,7 @@ namespace tntdb { typedef std::multimap hostvarMapType; - tntdb::Connection conn; + Connection* conn; std::string query; BindValues inVars; hostvarMapType hostvarMap; @@ -58,7 +58,7 @@ namespace tntdb cxxtools::SmartPtr fetchRow(); public: - Statement(const tntdb::Connection& conn, MYSQL* mysql, + Statement(Connection* conn, MYSQL* mysql, const std::string& query); ~Statement(); diff --git a/tntdb/pkgconfig/tntdb.pc.in b/tntdb/pkgconfig/tntdb.pc.in new file mode 100644 index 0000000..6fc8c00 --- /dev/null +++ b/tntdb/pkgconfig/tntdb.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: tntdb +Description: C++ class library for easy database access +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -ltntdb +Cflags: -I${includedir} +Requires.private: cxxtools diff --git a/tntdb/src/mysql/connection.cpp b/tntdb/src/mysql/connection.cpp index 6206778..6a478b3 100644 --- a/tntdb/src/mysql/connection.cpp +++ b/tntdb/src/mysql/connection.cpp @@ -50,7 +50,7 @@ namespace tntdb : std::string("null"); } const char* zstr(const char* s) - { return s && s[0] ? s : 0; } + { return s && s[0] ? s : NULL; } } void Connection::open(const char* app, const char* host, const char* user, @@ -66,30 +66,47 @@ namespace tntdb << port << ", " << str(unix_socket) << ", " << client_flag << ')'); - - if (::mysql_init(&mysql) == 0) + + //We already open the connection + if(mysql) + { + ::mysql_init(mysql); + } + else + { + mysql = ::mysql_init(NULL); + } + + if (!mysql) throw std::runtime_error("cannot initalize mysql"); + initialized = true; - if (::mysql_options(&mysql, MYSQL_READ_DEFAULT_GROUP, app && app[0] ? app : "tntdb") != 0) - throw MysqlError("mysql_options", &mysql); + unsigned int timeout = 300; + mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, &timeout); + + if (::mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, app && app[0] ? app : "tntdb") != 0) + throw MysqlError("mysql_options", mysql); - if (!::mysql_real_connect(&mysql, zstr(host), zstr(user), zstr(passwd), + if (!::mysql_real_connect(mysql, zstr(host), zstr(user), zstr(passwd), zstr(db), port, zstr(unix_socket), client_flag)) - throw MysqlError("mysql_real_connect", &mysql); + throw MysqlError("mysql_real_connect", mysql); } Connection::Connection(const char* app, const char* host, const char* user, const char* passwd, const char* db, unsigned int port, const char* unix_socket, unsigned long client_flag) - : initialized(false), - transactionActive(0) + : mysql(NULL) + , initialized(false) + , transactionActive(0) { open(app, host, user, passwd, db, port, unix_socket, client_flag); } Connection::Connection(const char* conn) - : initialized(false) + : mysql(NULL) + , initialized(false) + , transactionActive(0) { log_debug("Connection::Connection(\"" << conn << "\")"); std::string app; @@ -245,12 +262,13 @@ namespace tntdb if (!lockTablesQuery.empty()) { log_debug("mysql_query(\"UNLOCK TABLES\")"); - if (::mysql_query(&mysql, "UNLOCK TABLES") != 0) - log_warn(MysqlError("mysql_query", &mysql).what()); + if (::mysql_query(mysql, "UNLOCK TABLES") != 0) + log_warn(MysqlError("mysql_query", mysql).what()); } - log_debug("mysql_close(" << &mysql << ')'); - ::mysql_close(&mysql); + log_debug("mysql_close(" << mysql << ')'); + ::mysql_close(mysql); + mysql = NULL; } } @@ -258,9 +276,9 @@ namespace tntdb { if (transactionActive == 0) { - log_debug("mysql_autocomit(" << &mysql << ", " << 0 << ')'); - if (::mysql_autocommit(&mysql, 0) != 0) - throw MysqlError("mysql_autocommit", &mysql); + log_debug("mysql_autocomit(" << mysql << ", " << 0 << ')'); + if (::mysql_autocommit(mysql, 0) != 0) + throw MysqlError("mysql_autocommit", mysql); } ++transactionActive; @@ -270,21 +288,21 @@ namespace tntdb { if (transactionActive == 0 || --transactionActive == 0) { - log_debug("mysql_commit(" << &mysql << ')'); - if (::mysql_commit(&mysql) != 0) - throw MysqlError("mysql_commit", &mysql); + log_debug("mysql_commit(" << mysql << ')'); + if (::mysql_commit(mysql) != 0) + throw MysqlError("mysql_commit", mysql); if (!lockTablesQuery.empty()) { log_debug("mysql_query(\"UNLOCK TABLES\")"); - if (::mysql_query(&mysql, "UNLOCK TABLES") != 0) - throw MysqlError("mysql_query", &mysql); + if (::mysql_query(mysql, "UNLOCK TABLES") != 0) + throw MysqlError("mysql_query", mysql); lockTablesQuery.clear(); } - log_debug("mysql_autocomit(" << &mysql << ", " << 1 << ')'); - if (::mysql_autocommit(&mysql, 1) != 0) - throw MysqlError("mysql_autocommit", &mysql); + log_debug("mysql_autocomit(" << mysql << ", " << 1 << ')'); + if (::mysql_autocommit(mysql, 1) != 0) + throw MysqlError("mysql_autocommit", mysql); } } @@ -293,21 +311,21 @@ namespace tntdb { if (transactionActive == 0 || --transactionActive == 0) { - log_debug("mysql_rollback(" << &mysql << ')'); - if (::mysql_rollback(&mysql) != 0) - throw MysqlError("mysql_rollback", &mysql); + log_debug("mysql_rollback(" << mysql << ')'); + if (::mysql_rollback(mysql) != 0) + throw MysqlError("mysql_rollback", mysql); if (!lockTablesQuery.empty()) { log_debug("mysql_query(\"UNLOCK TABLES\")"); - if (::mysql_query(&mysql, "UNLOCK TABLES") != 0) - throw MysqlError("mysql_query", &mysql); + if (::mysql_query(mysql, "UNLOCK TABLES") != 0) + throw MysqlError("mysql_query", mysql); lockTablesQuery.clear(); } - log_debug("mysql_autocommit(" << &mysql << ", " << 1 << ')'); - if (::mysql_autocommit(&mysql, 1) != 0) - throw MysqlError("mysql_autocommit", &mysql); + log_debug("mysql_autocommit(" << mysql << ", " << 1 << ')'); + if (::mysql_autocommit(mysql, 1) != 0) + throw MysqlError("mysql_autocommit", mysql); } } @@ -315,23 +333,23 @@ namespace tntdb Connection::size_type Connection::execute(const std::string& query) { log_debug("mysql_query(\"" << query << "\")"); - if (::mysql_query(&mysql, query.c_str()) != 0) - throw MysqlError("mysql_query", &mysql); + if (::mysql_real_query(mysql, query.c_str(), query.size()) != 0) + throw MysqlError("mysql_query", mysql); - log_debug("mysql_affected_rows(" << &mysql << ')'); - return ::mysql_affected_rows(&mysql); + log_debug("mysql_affected_rows(" << mysql << ')'); + return ::mysql_affected_rows(mysql); } tntdb::Result Connection::select(const std::string& query) { execute(query); - log_debug("mysql_store_result(" << &mysql << ')'); - MYSQL_RES* res = ::mysql_store_result(&mysql); + log_debug("mysql_store_result(" << mysql << ')'); + MYSQL_RES* res = ::mysql_store_result(mysql); if (res == 0) - throw MysqlError("mysql_store_result", &mysql); + throw MysqlError("mysql_store_result", mysql); - return tntdb::Result(new Result(tntdb::Connection(this), &mysql, res)); + return tntdb::Result(new Result(tntdb::Connection(this), mysql, res)); } Row Connection::selectRow(const std::string& query) @@ -354,19 +372,19 @@ namespace tntdb tntdb::Statement Connection::prepare(const std::string& query) { - return tntdb::Statement(new Statement(tntdb::Connection(this), &mysql, query)); + return tntdb::Statement(new Statement(this, mysql, query)); } bool Connection::ping() { - int ret = ::mysql_ping(&mysql); + int ret = ::mysql_ping(mysql); log_debug("mysql_ping() => " << ret); return ret == 0; } long Connection::lastInsertId(const std::string& name) { - return static_cast(::mysql_insert_id(&mysql)); + return static_cast(::mysql_insert_id(mysql)); } void Connection::lockTable(const std::string& tablename, bool exclusive) @@ -380,8 +398,8 @@ namespace tntdb lockTablesQuery += exclusive ? " WRITE" : " READ"; log_debug("mysql_query(\"" << lockTablesQuery << "\")"); - if (::mysql_query(&mysql, lockTablesQuery.c_str()) != 0) - throw MysqlError("mysql_query", &mysql); + if (::mysql_query(mysql, lockTablesQuery.c_str()) != 0) + throw MysqlError("mysql_query", mysql); } } diff --git a/tntdb/src/mysql/statement.cpp b/tntdb/src/mysql/statement.cpp index 1a703e3..9aaa0c0 100644 --- a/tntdb/src/mysql/statement.cpp +++ b/tntdb/src/mysql/statement.cpp @@ -137,7 +137,7 @@ namespace tntdb return ptr.getPointer(); } - Statement::Statement(const tntdb::Connection& conn_, MYSQL* mysql_, + Statement::Statement(Connection* conn_, MYSQL* mysql_, const std::string& query_) : conn(conn_), mysql(mysql_), @@ -517,7 +517,7 @@ namespace tntdb log_debug("execute statement " << stmt); if (hostvarMap.empty()) { - return conn.execute(query); + return conn->execute(query); } else { @@ -533,7 +533,7 @@ namespace tntdb log_debug("select"); if (hostvarMap.empty()) - return conn.select(query); + return conn->select(query); if (fields) getRow(); @@ -559,7 +559,7 @@ namespace tntdb log_debug("selectRow"); if (hostvarMap.empty()) - return conn.selectRow(query); + return conn->selectRow(query); if (fields) getRow();