Forum OpenACS Q&A: Re: How to upgrade Oracle from 8.1.7.0 to 8.1.7.4 ?

Collapse
Posted by Janine Ohmer on
This is how I've done it:

perl -pi.bak -0777 -e 's/TABLESPACE \"<OLDNAME>\"/TABLESPACE
\"<NEWNAME>\"/gism' <your dumpfile>

(I originally got this from the guys at S&R)

This will create a backup copy of your dump file and then will go through and do the substitution.  It's very important that the new tablespace name be in captial letters - it won't work otherwise.

Good luck!

Collapse
Posted by Bruno Mattarollo on

Oh! Thanks Janine!!!

I wrote a small python program to do the same because I thought that I might contribute something as well :)

Here is the code:

#!/usr/bin/python
#
#
# Author: Bruno Mattarollo bruno.mattarollo@diala.greenpeace.org
# Creation Date: 05th Feb 2003
# License: Free, do what you want with this!
# DISCLAIMER! This might corrupt your dump file
#     I AM NOT RESPONSIBLE FOR THE USE OF THIS! Don't blame me for any
#     problem that might occur. DON'T USE THIS IN PRODUCTION!

import re

DUMP_FILE="arsdigita-export-file-20021218-2.dmp"
OUTPUT_FILE="dump-cleaned.dmp"
FROM_TABLESPACE="ARSDIGITA"
TO_TABLESPACE="DEVELOPMENT"

compiled_re = re.compile("(TABLESPACE)\s+(\"" + FROM_TABLESPACE + "\")")

def main():
    print "About to start this miserable task ... :("
    fh = open(DUMP_FILE, 'rb')
    oh = open(OUTPUT_FILE, 'wb')
    # Maybe reading bigger chunks of the file would be better!
    # My file is 3.3GB!!!! :((((((
    chunk = fh.read(1024*1024)
    while (chunk):
       if ( compiled_re.search(chunk) ):
           # We have a match!
           print "We have a match!"
           # We need to replace the FROM_TABLESPACE with the TO_TABLESPACE
           chunk = re.sub(r'(TABLESPACE)(\s+)(\"' + FROM_TABLESPACE + '\")',
                  r'\1\2"' + TO_TABLESPACE + '"',
                  chunk)
       oh.write(chunk)
       # If you change the chunk size above, change it here as well!
       chunk = fh.read(1024*1024)

    # We are done
    fh.close()
    oh.close()
    print "Ouch! Finally!"

if __name__ == '__main__':
    main()

I coded this in 4 minutes and ran it on our export (as it says in the code it's 3.3GB) and I am importing it right now without problems so far... 😊... crossing my fingers...

Collapse
Posted by Bruno Mattarollo on
Sorry for this additional post but I am sure that your solution will be MUCH faster than my python program :)

Thanks again!!!

Collapse
Posted by Bruno Mattarollo on
Just for the record, I processed my dump file with my python script and imported the file into Oracle. This dump contains more than 2GB of JPGs (binary) and PDF's and everything looks fine using our OpenACS service to look at the data.
Collapse
Posted by Guan Yang on
Bruno,

I used your Python script because the Perl one-liner printed a lot of error messages like this:

Malformed UTF-8 character (overflow at 0xca0c1314, byte 0x45, after start byte 0xff) in substitution (s///), <> chunk 1.

However, one thing occured to me. You're using 1 MB chunks. What if the string TABLESPACE <OLDNAME> lies exactly on a chunk boundary?

Guan

Collapse
Posted by Bruno Mattarollo on
Hello Guan,

I would say you are having a tough luck (sorry). You will get an error when trying the import and then you can try with a different chunksize. But that's a good question indeed ... :)

A modification to the script could be to look for a match at the end of a chunk for any match for any substring of "TABLESPACE " and if that happens, read the following chunk, check that at the beginning you can actually match the whole string you are looking for (concatenating both the previous chunk and this one) and do the replacement there ... :-?

Just my 2 cents,

/B