[Checkins] SVN: relstorage/trunk/ Updated migration notes and set up the Oracle adapter to
Shane Hathaway
shane at hathawaymix.org
Fri Oct 30 04:33:42 EDT 2009
Log message for revision 105382:
Updated migration notes and set up the Oracle adapter to
auto-install the relstorage_op package.
Changed:
U relstorage/trunk/README.txt
A relstorage/trunk/notes/migrate-to-1.4.txt
U relstorage/trunk/relstorage/adapters/schema.py
-=-
Modified: relstorage/trunk/README.txt
===================================================================
--- relstorage/trunk/README.txt 2009-10-30 07:58:37 UTC (rev 105381)
+++ relstorage/trunk/README.txt 2009-10-30 08:33:42 UTC (rev 105382)
@@ -330,34 +330,17 @@
Sometimes RelStorage needs a schema modification along with a software
upgrade. Hopefully, this will not often be necessary.
-No schema migration is required if you are upgrading from version 1.1.2
-or later.
+No schema migration is required if you are using PostgreSQL or MySQL
+and upgrading from version 1.1.2 or later. See the `notes subdirectory`_
+if you are upgrading from an older version.
-To migrate from version 1.1.1 to version 1.1.2 or 1.1.3, see:
+.. _`notes subdirectory`: http://svn.zope.org/relstorage/trunk/notes/
- migrate-to-1.1.2.txt_
+To migrate Oracle to version 1.4, see `migrate-to-1.4.txt`_.
- .. _migrate-to-1.1.2.txt: http://svn.zope.org/*checkout*/relstorage/trunk/notes/migrate-to-1.1.2.txt
+.. _`migrate-to-1.4.txt`: http://svn.zope.org/*checkout*/relstorage/trunk/notes/migrate-to-1.4.txt
-To migrate from version 1.1 to version 1.1.1, see:
- migrate-to-1.1.1.txt_
-
- .. _migrate-to-1.1.1.txt: http://svn.zope.org/*checkout*/relstorage/trunk/notes/migrate-to-1.1.1.txt
-
-To migrate from version 1.0.1 to version 1.1, see:
-
- migrate-to-1.1.txt_
-
- .. _migrate-to-1.1.txt: http://svn.zope.org/*checkout*/relstorage/trunk/notes/migrate-to-1.1.txt
-
-To migrate from version 1.0 beta to version 1.0c1 through 1.0.1, see:
-
- migrate-to-1.0.txt_
-
- .. _migrate-to-1.0.txt: http://svn.zope.org/*checkout*/relstorage/trunk/notes/migrate-to-1.0.txt
-
-
RelStorage Options
==================
Added: relstorage/trunk/notes/migrate-to-1.4.txt
===================================================================
--- relstorage/trunk/notes/migrate-to-1.4.txt (rev 0)
+++ relstorage/trunk/notes/migrate-to-1.4.txt 2009-10-30 08:33:42 UTC (rev 105382)
@@ -0,0 +1,38 @@
+
+Migrating to RelStorage version 1.4
+-----------------------------------
+
+Before following these directions, first upgrade to the schema of
+RelStorage version 1.1.2 by following the directions in "migrate-to-1.1.2.txt".
+
+Only Oracle needs a change for this release. The Oracle adapter
+now requires the installation of a PL/SQL package with ``SYS`` privileges.
+
+Using Oracle 10g XE, you can start a ``SYS`` session with the following
+shell commands::
+
+ $ su - oracle
+ $ sqlplus / as sysdba
+
+The PL/SQL package below provides limited access to the DBMS_LOCK
+package so that RelStorage can acquire user locks. Using ``sqlplus``
+with ``SYS`` privileges, execute the following::
+
+ CREATE OR REPLACE PACKAGE relstorage_util AS
+ FUNCTION request_lock(id IN NUMBER, timeout IN NUMBER)
+ RETURN NUMBER;
+ END relstorage_util;
+ /
+
+ CREATE OR REPLACE PACKAGE BODY relstorage_util AS
+ FUNCTION request_lock(id IN NUMBER, timeout IN NUMBER)
+ RETURN NUMBER IS
+ BEGIN
+ RETURN DBMS_LOCK.REQUEST(
+ id => id,
+ lockmode => DBMS_LOCK.X_MODE,
+ timeout => timeout,
+ release_on_commit => TRUE);
+ END request_lock;
+ END relstorage_util;
+ /
Modified: relstorage/trunk/relstorage/adapters/schema.py
===================================================================
--- relstorage/trunk/relstorage/adapters/schema.py 2009-10-30 07:58:37 UTC (rev 105381)
+++ relstorage/trunk/relstorage/adapters/schema.py 2009-10-30 08:33:42 UTC (rev 105382)
@@ -769,9 +769,21 @@
database_name = 'oracle'
- def create(self, cursor):
- """Create the database tables and the relstorage_op PL/SQL package."""
- super(OracleSchemaInstaller, self).create(cursor)
+ def prepare(self):
+ """Create the database schema if it does not already exist."""
+ def callback(conn, cursor):
+ tables = self.list_tables(cursor)
+ if not 'object_state' in tables:
+ self.create(cursor)
+ else:
+ self.check_compatibility(cursor, tables)
+ packages = self.list_packages(cursor)
+ if not 'relstorage_op' in packages:
+ self.install_plsql(cursor)
+ self.connmanager.open_and_call(callback)
+
+ def install_plsql(self, cursor):
+ """Install the unprivileged PL/SQL package"""
if self.keep_history:
plsql = oracle_history_preserving_plsql
else:
@@ -793,3 +805,12 @@
def list_sequences(self, cursor):
cursor.execute("SELECT sequence_name FROM user_sequences")
return [name.lower() for (name,) in cursor]
+
+ def list_packages(self, cursor):
+ stmt = """
+ SELECT object_name
+ FROM user_objects
+ WHERE object_type = 'PACKAGE'
+ """
+ cursor.execute(stmt)
+ return [name.lower() for (name,) in cursor]
More information about the checkins
mailing list