[CalendarServer-changes] [15735] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Jul 5 12:37:44 PDT 2016


Revision: 15735
          http://trac.calendarserver.org//changeset/15735
Author:   cdaboo at apple.com
Date:     2016-07-05 12:37:44 -0700 (Tue, 05 Jul 2016)
Log Message:
-----------
Wrap database parameters into a single class that also supports optional features. Allow SKIP LOCKED optional feature with postgres. postgres 9.5.3 is now the default. Updated pip and virtualenv packages.

Modified Paths:
--------------
    CalendarServer/trunk/bin/_build.sh
    CalendarServer/trunk/calendarserver/tap/caldav.py
    CalendarServer/trunk/calendarserver/tap/util.py
    CalendarServer/trunk/conf/caldavd-apple.plist
    CalendarServer/trunk/conf/caldavd-stdconfig.plist
    CalendarServer/trunk/requirements-cs.txt
    CalendarServer/trunk/twistedcaldav/dumpconfig.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py
    CalendarServer/trunk/txdav/common/datastore/sql.py
    CalendarServer/trunk/txdav/common/datastore/sql_dump.py
    CalendarServer/trunk/txdav/common/datastore/sql_tables.py
    CalendarServer/trunk/txdav/common/datastore/test/test_sql_dump.py
    CalendarServer/trunk/txdav/common/datastore/test/test_trash.py
    CalendarServer/trunk/txdav/common/datastore/test/util.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrade.py

Modified: CalendarServer/trunk/bin/_build.sh
===================================================================
--- CalendarServer/trunk/bin/_build.sh	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/bin/_build.sh	2016-07-05 19:37:44 UTC (rev 15735)
@@ -602,7 +602,7 @@
   if command -v postgres > /dev/null; then
     using_system "Postgres";
   else
-    local v="9.3.10";
+    local v="9.5.3";
     local n="postgresql";
     local p="${n}-${v}";
 
@@ -612,7 +612,7 @@
       local enable_dtrace="";
     fi;
 
-    c_dependency -m "ec2365548d08f69c8023eddd4f2d1a28" \
+    c_dependency -m "3f0c388566c688c82b01a0edf1e6b7a0" \
       "PostgreSQL" "${p}" \
       "http://ftp.postgresql.org/pub/source/v${v}/${p}.tar.bz2" \
       --with-python ${enable_dtrace};
@@ -740,8 +740,8 @@
 
   for pkg in             \
       setuptools-18.5    \
-      pip-7.1.2          \
-      virtualenv-13.1.2  \
+      pip-8.1.2          \
+      virtualenv-15.0.2  \
   ; do
       local    name="${pkg%-*}";
       local version="${pkg#*-}";

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -66,8 +66,7 @@
 from twext.internet.ssl import ChainingOpenSSLContextFactory
 from twext.internet.tcp import MaxAcceptTCPServer, MaxAcceptSSLServer
 from twext.enterprise.adbapi2 import ConnectionPool
-from twext.enterprise.ienterprise import ORACLE_DIALECT
-from twext.enterprise.ienterprise import POSTGRES_DIALECT
+from twext.enterprise.ienterprise import POSTGRES_DIALECT, ORACLE_DIALECT, DatabaseType
 from twext.enterprise.jobs.queue import NonPerformingQueuer
 from twext.enterprise.jobs.queue import ControllerQueue
 from twext.enterprise.jobs.queue import WorkerFactory as QueueWorkerFactory
@@ -1565,7 +1564,7 @@
         @rtype: L{IService}
         """
 
-        def createSubServiceFactory(dbtype):
+        def createSubServiceFactory(dbtype, dbfeatures=()):
             if dbtype == "":
                 dialect = POSTGRES_DIALECT
                 paramstyle = "pyformat"
@@ -1579,8 +1578,8 @@
             def subServiceFactory(connectionFactory, storageService):
                 ms = MultiService()
                 cp = ConnectionPool(
-                    connectionFactory, dialect=dialect,
-                    paramstyle=paramstyle,
+                    connectionFactory,
+                    dbtype=DatabaseType(dialect, paramstyle, dbfeatures),
                     maxConnections=config.MaxDBConnectionsPerPool
                 )
                 cp.setServiceParent(ms)
@@ -1680,13 +1679,13 @@
                 # to it.
                 pgserv = pgServiceFromConfig(
                     config,
-                    createSubServiceFactory(""),
+                    createSubServiceFactory("", config.DBFeatures),
                     uid=overrideUID, gid=overrideGID
                 )
                 return pgserv
             else:
                 # Connect to a database that is already running.
-                return createSubServiceFactory(config.DBType)(
+                return createSubServiceFactory(config.DBType, config.DBFeatures)(
                     DBAPIConnector.connectorFor(config.DBType, **config.DatabaseConnection).connect, None
                 )
         else:

Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -44,8 +44,7 @@
 
 from twext.enterprise.adbapi2 import ConnectionPool, ConnectionPoolConnection
 from twext.enterprise.adbapi2 import ConnectionPoolClient
-from twext.enterprise.ienterprise import ORACLE_DIALECT
-from twext.enterprise.ienterprise import POSTGRES_DIALECT
+from twext.enterprise.ienterprise import POSTGRES_DIALECT, ORACLE_DIALECT, DatabaseType
 from twext.internet.ssl import ChainingOpenSSLContextFactory
 from twext.python.filepath import CachingFilePath
 from twext.python.filepath import CachingFilePath as FilePath
@@ -179,14 +178,14 @@
 
 
 
-def transactionFactoryFromFD(dbampfd, dialect, paramstyle):
+def transactionFactoryFromFD(dbampfd, dbtype):
     """
     Create a transaction factory from an inherited file descriptor, such as one
     created by L{ConnectionDispenser}.
     """
     skt = fromfd(dbampfd, AF_UNIX, SOCK_STREAM)
     os.close(dbampfd)
-    protocol = ConnectionPoolClient(dialect=dialect, paramstyle=paramstyle)
+    protocol = ConnectionPoolClient(dbtype=dbtype)
     transport = ConnectionWithPeer(skt, protocol)
     protocol.makeConnection(transport)
     transport.startReading()
@@ -830,7 +829,7 @@
     pool = None
     if config.DBAMPFD:
         txnFactory = transactionFactoryFromFD(
-            int(config.DBAMPFD), dialect, paramstyle
+            int(config.DBAMPFD), DatabaseType(dialect, paramstyle, config.DBFeatures)
         )
     elif not config.UseDatabase:
         txnFactory = None
@@ -843,8 +842,7 @@
         else:
             connectionFactory = DBAPIConnector.connectorFor(config.DBType, **config.DatabaseConnection).connect
 
-        pool = ConnectionPool(connectionFactory, dialect=dialect,
-                              paramstyle=paramstyle,
+        pool = ConnectionPool(connectionFactory, dbtype=DatabaseType(dialect, paramstyle, config.DBFeatures),
                               maxConnections=config.MaxDBConnectionsPerPool)
         txnFactory = pool.connection
     else:

Modified: CalendarServer/trunk/conf/caldavd-apple.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-apple.plist	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/conf/caldavd-apple.plist	2016-07-05 19:37:44 UTC (rev 15735)
@@ -108,6 +108,11 @@
     <!-- Database connection -->
     <key>DBType</key>
     <string></string>
+    
+    <!-- No features - when macOS supports postgres 9.5 and up change
+    	 this to include 'skip-locked'. -->
+	<key>DBFeatures</key>
+	<array></array>
 
     <key>Postgres</key>
     <dict>

Modified: CalendarServer/trunk/conf/caldavd-stdconfig.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-stdconfig.plist	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/conf/caldavd-stdconfig.plist	2016-07-05 19:37:44 UTC (rev 15735)
@@ -118,35 +118,43 @@
 	<array>
 	</array>
 
+	<!-- Use a 'meta' FD, i.e. an FD to transmit other FDs to slave processes. -->
+	<key>UseMetaFD</key>
+	<true/>
+
 	<!-- Inherited file descriptor to call recvmsg() on to receive sockets (none =
 	     don't inherit) -->
 	<key>MetaFD</key>
 	<integer>0</integer>
 
-	<!-- Use a 'meta' FD, i.e. an FD to transmit other FDs to slave processes. -->
-	<key>UseMetaFD</key>
-	<true/>
+	<!-- Database configuration information.
 
-	<!-- True: database; False: files -->
+	     Defines what kind of database to use: file (deprecated) or SQL. File-based
+	     DB is only supported for migration purposes - it cannot be used for a real
+	     service.
+
+	     For an SQL-based DB, configuration of connection parameters and various
+	     timeouts is provided. -->
+
+	<!-- True: database; False: files (deprecated) -->
 	<key>UseDatabase</key>
 	<true/>
 
-	<!-- Timeout transactions that take longer than the specified number of
-	     seconds. Zero means no timeouts. 5 minute default. -->
-	<key>TransactionTimeoutSeconds</key>
-	<integer>300</integer>
-
-	<!-- When a transactions times out tell HTTP clients clients to retry after
-	     this amount of time -->
-	<key>TransactionHTTPRetrySeconds</key>
-	<integer>300</integer>
-
-	<!-- 2 possible values: empty, meaning 'spawn postgres yourself', or
-	     'postgres', meaning 'connect to a postgres database as specified by the
-	     'DSN' configuration key.  Will support more values in the future. -->
+	<!-- Possible values: empty, meaning 'spawn postgres yourself', or 'postgres'
+	     or 'oracle', meaning 'connect to a postgres or Oracle database as
+	     specified by the 'DSN' configuration key. -->
 	<key>DBType</key>
 	<string></string>
 
+	<!-- Features supported by the database
+
+	     'skip-locked': SKIP LOCKED available with SELECT (remove if using postgres
+	     &lt; v9.5) -->
+	<key>DBFeatures</key>
+	<array>
+		<string>skip-locked</string>
+	</array>
+
 	<!-- The username to use when DBType is empty -->
 	<key>SpawnedDBUser</key>
 	<string>caldav</string>
@@ -175,17 +183,17 @@
 		<false/>
 	</dict>
 
+	<!-- Use a shared database connection pool in the master process, rather than
+	     having each client make its connections directly. -->
+	<key>SharedConnectionPool</key>
+	<false/>
+
 	<!-- Internally used by database to tell slave processes to inherit a file
 	     descriptor and use it as an AMP connection over a UNIX socket; see
 	     twext.enterprise.adbapi2.ConnectionPoolConnection -->
 	<key>DBAMPFD</key>
 	<integer>0</integer>
 
-	<!-- Use a shared database connection pool in the master process, rather than
-	     having each client make its connections directly. -->
-	<key>SharedConnectionPool</key>
-	<false/>
-
 	<!-- Set to True to prevent the server or utility tools from running if the
 	     database needs a schema upgrade. -->
 	<key>FailIfUpgradeNeeded</key>
@@ -203,6 +211,16 @@
 	<key>UpgradeHomePrefix</key>
 	<string></string>
 
+	<!-- Timeout transactions that take longer than the specified number of
+	     seconds. Zero means no timeouts. 5 minute default. -->
+	<key>TransactionTimeoutSeconds</key>
+	<integer>300</integer>
+
+	<!-- When a transactions times out tell HTTP clients clients to retry after
+	     this amount of time -->
+	<key>TransactionHTTPRetrySeconds</key>
+	<integer>300</integer>
+
 	<!-- Work queue configuration information -->
 
 	<key>WorkQueue</key>

Modified: CalendarServer/trunk/requirements-cs.txt
===================================================================
--- CalendarServer/trunk/requirements-cs.txt	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/requirements-cs.txt	2016-07-05 19:37:44 UTC (rev 15735)
@@ -7,7 +7,7 @@
     zope.interface==4.1.3
 	    setuptools==18.5
 
-    --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@15700#egg=twextpy
+    --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@15734#egg=twextpy
         cffi==1.3.0
             pycparser==2.14
         #twisted

Modified: CalendarServer/trunk/twistedcaldav/dumpconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/dumpconfig.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/twistedcaldav/dumpconfig.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -23,6 +23,8 @@
 import re
 import textwrap
 
+DEBUG = False
+
 COPYRIGHT = """
 <!--
     Copyright (c) 2006-2016 Apple Inc. All rights reserved.
@@ -313,12 +315,14 @@
     }
 
     for item in maps.keys():
+        if DEBUG:
+            print(item)
         lines = parseConfigItem(item)
-        maps[item] = processConfig(lines, with_comments=True, verbose=False)
+        maps[item] = processConfig(lines, with_comments=True, verbose=DEBUG)
 
     # Generate the plist for the default config, substituting for the *_PARAMS items
     lines = parseConfigItem("DEFAULT_CONFIG")
-    j = processConfig(lines, with_comments=True, verbose=False, substitutions=maps)
+    j = processConfig(lines, with_comments=True, verbose=DEBUG, substitutions=maps)
     return writeOrderedPlistToString(j)
 
 

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -195,24 +195,36 @@
     "BindSSLPorts": [], # List of port numbers to bind to for SSL [empty = same as "SSLPort"]
     "InheritFDs": [], # File descriptors to inherit for HTTP requests [empty = don't inherit]
     "InheritSSLFDs": [], # File descriptors to inherit for HTTPS requests [empty = don't inherit]
-    "MetaFD": 0, # Inherited file descriptor to call recvmsg() on to receive sockets (none = don't inherit)
 
     "UseMetaFD": True, # Use a 'meta' FD, i.e. an FD to transmit other FDs to slave processes.
+    "MetaFD": 0, # Inherited file descriptor to call recvmsg() on to receive sockets (none = don't inherit)
 
-    "UseDatabase": True, # True: database; False: files
+    #
+    # Database configuration information.
+    #
+    #    Defines what kind of database to use: file (deprecated) or SQL.
+    #    File-based DB is only supported for migration purposes - it
+    #    cannot be used for a real service.
+    #
+    #    For an SQL-based DB, configuration of connection parameters and various
+    #    timeouts is provided.
+    #
 
-    "TransactionTimeoutSeconds": 300,   # Timeout transactions that take longer than
-                                        # the specified number of seconds. Zero means
-                                        # no timeouts. 5 minute default.
-    "TransactionHTTPRetrySeconds": 300, # When a transactions times out tell HTTP clients
-                                        # clients to retry after this amount of time
+    "UseDatabase": True, # True: database; False: files (deprecated)
 
-    "DBType": "", # 2 possible values: empty, meaning 'spawn postgres
-                  # yourself', or 'postgres', meaning 'connect to a
-                  # postgres database as specified by the 'DSN'
-                  # configuration key.  Will support more values in
-                  # the future.
+    "DBType": "", # Possible values: empty, meaning 'spawn postgres
+                  # yourself', or 'postgres' or 'oracle', meaning
+                  # 'connect to a postgres or Oracle database as
+                  # specified by the 'DSN' configuration key.
 
+
+    "DBFeatures": [ # Features supported by the database
+                    #
+                    # 'skip-locked': SKIP LOCKED available with SELECT (remove if using postgres < v9.5)
+                    #
+        "skip-locked",
+    ],
+
     "SpawnedDBUser": "caldav", # The username to use when DBType is empty
 
     "DatabaseConnection": { # Used to connect to an external database if DBType is non-empty
@@ -223,16 +235,16 @@
         "ssl": False,       # Set to True to require SSL (pg8000 only).
     },
 
+    "SharedConnectionPool": False, # Use a shared database connection pool in
+                                   # the master process, rather than having
+                                   # each client make its connections directly.
+
     "DBAMPFD": 0, # Internally used by database to tell slave
                   # processes to inherit a file descriptor and use it
                   # as an AMP connection over a UNIX socket; see
                   # twext.enterprise.adbapi2.ConnectionPoolConnection
 
-    "SharedConnectionPool": False, # Use a shared database connection pool in
-                                   # the master process, rather than having
-                                   # each client make its connections directly.
-
-    "FailIfUpgradeNeeded": True, # Set to True to prevent the server or utility
+    "FailIfUpgradeNeeded": True,   # Set to True to prevent the server or utility
                                    # tools from running if the database needs a schema
                                    # upgrade.
 
@@ -246,6 +258,12 @@
                                 # need to be run again without this prefix set to complete the overall
                                 # upgrade.
 
+    "TransactionTimeoutSeconds": 300,   # Timeout transactions that take longer than
+                                        # the specified number of seconds. Zero means
+                                        # no timeouts. 5 minute default.
+    "TransactionHTTPRetrySeconds": 300, # When a transactions times out tell HTTP clients
+                                        # clients to retry after this amount of time
+
     #
     # Work queue configuration information
     #

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -643,8 +643,7 @@
         directlyProvides(self, *extraInterfaces)
 
         self._sqlTxn = sqlTxn
-        self.paramstyle = sqlTxn.paramstyle
-        self.dialect = sqlTxn.dialect
+        self.dbtype = sqlTxn.dbtype
 
         self._stats = (
             TransactionStatsCollector(self._label, self._store.logStatsLogFile)

Modified: CalendarServer/trunk/txdav/common/datastore/sql_dump.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_dump.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/txdav/common/datastore/sql_dump.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -54,9 +54,9 @@
     Generate the L{Schema}.
     """
 
-    if txn.dialect == POSTGRES_DIALECT:
+    if txn.dbtype.dialect == POSTGRES_DIALECT:
         return dumpSchema_postgres(txn, title, schemaname)
-    elif txn.dialect == ORACLE_DIALECT:
+    elif txn.dbtype.dialect == ORACLE_DIALECT:
         return dumpSchema_oracle(txn, title, schemaname)
 
 

Modified: CalendarServer/trunk/txdav/common/datastore/sql_tables.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_tables.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/txdav/common/datastore/sql_tables.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -25,7 +25,8 @@
 from twext.enterprise.dal.model import Sequence, ProcedureCall
 from twext.enterprise.dal.parseschema import schemaFromPath
 from twext.enterprise.dal.syntax import FixedPlaceholder
-from twext.enterprise.ienterprise import ORACLE_DIALECT, POSTGRES_DIALECT
+from twext.enterprise.ienterprise import ORACLE_DIALECT, POSTGRES_DIALECT, \
+    DatabaseType
 from twext.enterprise.dal.syntax import Insert
 from twext.enterprise.ienterprise import ORACLE_TABLE_NAME_MAX
 import hashlib
@@ -314,7 +315,7 @@
     @return: the generated SQL string.
     @rtype: C{str}
     """
-    qgen = QueryGenerator(ORACLE_DIALECT, FixedPlaceholder('%s'))
+    qgen = QueryGenerator(DatabaseType(ORACLE_DIALECT, "pyformat"), FixedPlaceholder('%s'))
     if doquote:
         qgen.shouldQuote = lambda name: True
     if hasattr(sql, 'subSQL'):

Modified: CalendarServer/trunk/txdav/common/datastore/test/test_sql_dump.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/test_sql_dump.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_sql_dump.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -53,7 +53,7 @@
     @inlineCallbacks
     def cleanUp(self):
         startTxn = self.store.newTransaction("test_dbUpgrades")
-        if startTxn.dialect == POSTGRES_DIALECT:
+        if startTxn.dbtype.dialect == POSTGRES_DIALECT:
             yield startTxn.execSQL("set search_path to public")
             yield startTxn.execSQL("drop schema test_dbUpgrades cascade")
         else:
@@ -69,7 +69,7 @@
         in postgres that we can quickly wipe clean afterwards.
         """
         startTxn = self.store.newTransaction("test_dbUpgrades")
-        if startTxn.dialect == POSTGRES_DIALECT:
+        if startTxn.dbtype.dialect == POSTGRES_DIALECT:
             yield startTxn.execSQL("create schema test_dbUpgrades")
             yield startTxn.execSQL("set search_path to test_dbUpgrades")
         yield startTxn.execSQLBlock(schema)

Modified: CalendarServer/trunk/txdav/common/datastore/test/test_trash.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/test_trash.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_trash.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -1814,6 +1814,7 @@
 
         yield txn.commit()
 
+
     @inlineCallbacks
     def test_trashCalendarRestoreWithFailures(self):
 

Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/util.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/txdav/common/datastore/test/util.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -36,7 +36,7 @@
 from twext.python.filepath import CachingFilePath as FilePath
 from twext.enterprise.adbapi2 import ConnectionPool
 from twext.enterprise.ienterprise import AlreadyFinishedError, POSTGRES_DIALECT, \
-    ORACLE_DIALECT
+    ORACLE_DIALECT, DatabaseType
 from twext.enterprise.jobs.jobitem import JobItem
 from twext.enterprise.jobs.queue import ControllerQueue
 from twext.who.directory import DirectoryRecord
@@ -162,8 +162,7 @@
         cp = ConnectionPool(
             stubsvc.produceConnection,
             maxConnections=1,
-            dialect=DB_TYPE[0],
-            paramstyle=DB_TYPE[1],
+            dbtype=DatabaseType(DB_TYPE[0], DB_TYPE[1]),
         )
         # Attach the service to the running reactor.
         cp.startService()
@@ -251,8 +250,7 @@
         cp = ConnectionPool(
             self.sharedService.produceConnection,
             maxConnections=4,
-            dialect=DB_TYPE[0],
-            paramstyle=DB_TYPE[1],
+            dbtype=DatabaseType(DB_TYPE[0], DB_TYPE[1]),
         )
         quota = deriveQuota(testCase)
         store = CommonDataStore(
@@ -340,10 +338,10 @@
         # Change the starting values of sequences to random values
         for sequence in schema.model.sequences: #@UndefinedVariable
             try:
-                if cleanupTxn.dialect == POSTGRES_DIALECT:
+                if cleanupTxn.dbtype.dialect == POSTGRES_DIALECT:
                     curval = (yield cleanupTxn.execSQL("select nextval('{}')".format(sequence.name), []))[0][0]
                     yield cleanupTxn.execSQL("select setval('{}', {})".format(sequence.name, curval + randint(1, 10000)), [])
-                elif cleanupTxn.dialect == ORACLE_DIALECT:
+                elif cleanupTxn.dbtype.dialect == ORACLE_DIALECT:
                     yield cleanupTxn.execSQL("alter sequence {} increment by {}".format(sequence.name, randint(1, 10000)), [])
                     yield cleanupTxn.execSQL("select {}.nextval from dual".format(sequence.name), [])
                     yield cleanupTxn.execSQL("alter sequence {} increment by {}".format(sequence.name, 1), [])

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -171,7 +171,7 @@
             in postgres that we can quickly wipe clean afterwards.
             """
             startTxn = store.newTransaction("test_dbUpgrades")
-            if startTxn.dialect == POSTGRES_DIALECT:
+            if startTxn.dbtype.dialect == POSTGRES_DIALECT:
                 yield startTxn.execSQL("create schema test_dbUpgrades")
                 yield startTxn.execSQL("set search_path to test_dbUpgrades")
             yield startTxn.execSQLBlock(path.getContent())
@@ -194,20 +194,20 @@
         @inlineCallbacks
         def _unloadOldSchema():
             startTxn = store.newTransaction("test_dbUpgrades")
-            if startTxn.dialect == POSTGRES_DIALECT:
+            if startTxn.dbtype.dialect == POSTGRES_DIALECT:
                 yield startTxn.execSQL("set search_path to public")
                 yield startTxn.execSQL("drop schema test_dbUpgrades cascade")
-            elif startTxn.dialect == ORACLE_DIALECT:
+            elif startTxn.dbtype.dialect == ORACLE_DIALECT:
                 yield cleanDatabase(startTxn)
             yield startTxn.commit()
 
         @inlineCallbacks
         def _cleanupOldSchema():
             startTxn = store.newTransaction("test_dbUpgrades")
-            if startTxn.dialect == POSTGRES_DIALECT:
+            if startTxn.dbtype.dialect == POSTGRES_DIALECT:
                 yield startTxn.execSQL("set search_path to public")
                 yield startTxn.execSQL("drop schema if exists test_dbUpgrades cascade")
-            elif startTxn.dialect == ORACLE_DIALECT:
+            elif startTxn.dbtype.dialect == ORACLE_DIALECT:
                 yield cleanDatabase(startTxn)
             yield startTxn.commit()
 
@@ -286,7 +286,7 @@
             in postgres that we can quickly wipe clean afterwards.
             """
             startTxn = store.newTransaction("test_dbUpgrades")
-            if startTxn.dialect == POSTGRES_DIALECT:
+            if startTxn.dbtype.dialect == POSTGRES_DIALECT:
                 yield startTxn.execSQL("create schema test_dbUpgrades")
                 yield startTxn.execSQL("set search_path to test_dbUpgrades")
             yield startTxn.execSQLBlock(path.getContent())
@@ -303,20 +303,20 @@
         @inlineCallbacks
         def _unloadOldData():
             startTxn = store.newTransaction("test_dbUpgrades")
-            if startTxn.dialect == POSTGRES_DIALECT:
+            if startTxn.dbtype.dialect == POSTGRES_DIALECT:
                 yield startTxn.execSQL("set search_path to public")
                 yield startTxn.execSQL("drop schema test_dbUpgrades cascade")
-            elif startTxn.dialect == ORACLE_DIALECT:
+            elif startTxn.dbtype.dialect == ORACLE_DIALECT:
                 yield cleanDatabase(startTxn)
             yield startTxn.commit()
 
         @inlineCallbacks
         def _cleanupOldData():
             startTxn = store.newTransaction("test_dbUpgrades")
-            if startTxn.dialect == POSTGRES_DIALECT:
+            if startTxn.dbtype.dialect == POSTGRES_DIALECT:
                 yield startTxn.execSQL("set search_path to public")
                 yield startTxn.execSQL("drop schema if exists test_dbUpgrades cascade")
-            elif startTxn.dialect == ORACLE_DIALECT:
+            elif startTxn.dbtype.dialect == ORACLE_DIALECT:
                 yield cleanDatabase(startTxn)
             yield startTxn.commit()
 

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrade.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrade.py	2016-07-05 19:32:22 UTC (rev 15734)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrade.py	2016-07-05 19:37:44 UTC (rev 15735)
@@ -190,7 +190,7 @@
 
         # Get the schema version in the current database
         sqlTxn = self.sqlStore.newTransaction(label="UpgradeDatabaseCoreStep.getVersions")
-        dialect = sqlTxn.dialect
+        dialect = sqlTxn.dbtype.dialect
         try:
             actual_version = yield sqlTxn.calendarserverValue(self.versionKey)
             actual_version = int(actual_version)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160705/94ec7d74/attachment-0001.html>


More information about the calendarserver-changes mailing list