summaryrefslogtreecommitdiffstats
path: root/ldap/admin
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2007-10-05 02:30:07 +0000
committerRich Megginson <rmeggins@redhat.com>2007-10-05 02:30:07 +0000
commit89157bcf8103ed471fbe0363680009e9a6055a96 (patch)
tree9810970b593c2d6743f00a4d60228eb9545533d9 /ldap/admin
parent12127c38df19c27168ebf677ada16e4552e6b575 (diff)
downloadds-89157bcf8103ed471fbe0363680009e9a6055a96.tar.gz
ds-89157bcf8103ed471fbe0363680009e9a6055a96.tar.xz
ds-89157bcf8103ed471fbe0363680009e9a6055a96.zip
Resolves: bug 249366
Bug Description: rhds71 - search filters returns too many entries on interger attributes value greater than 2 to the 31 Reviewed by: nhosoi, nkinder (Thanks!) Fix Description: This handles the migration part. The first part is when migrating the schema. Look for all integer syntax attributes. This can be tricky if there are SUP attribute types derived from integer syntax attributes. numSubordinates and hasSubordinates are skipped because they are handled specially by the db code. The next step is to scan all of the index files in the new db directory. If any integer indexes are found, they will be removed and recreated. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: Yes. Will need to document that this happens during migration if not cross platform. QA impact: should be covered by regular nightly and manual testing New Tests integrated into TET: Will need to create some integer indexes and do same platform migration to see if this works
Diffstat (limited to 'ldap/admin')
-rw-r--r--ldap/admin/src/scripts/DSMigration.pm.in87
-rw-r--r--ldap/admin/src/scripts/migrate-ds.res3
2 files changed, 90 insertions, 0 deletions
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
index 2be45860..d30cb097 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
@@ -311,6 +311,45 @@ sub migrateNetscapeRoot {
return $tmpldiffile;
}
+sub fixIntegerIndexes {
+ my $mig = shift;
+ my $inst_dir = shift;
+ my $newdbdir = shift;
+
+ if (!$mig->{integerattrs}) {
+ debug(1, "No integer syntax attributes, no indexes fixed\n");
+ return ();
+ }
+
+ # look at each index file in the db dir
+ # if it is on our list of integer attributes,
+ # remove it and re-create it
+ my $dbname = basename($newdbdir);
+ for (glob("$newdbdir/*.db4")) {
+ my $indexname = basename($_, '.db4');
+ if ($mig->{integerattrs}->{lc $indexname}) {
+ $mig->msg($INFO, 'fixing_integer_attr_index', $indexname, $newdbdir);
+ debug(1, "Removing file $_\n");
+ if (! unlink $_) {
+ debug(1, "Error: could not remove file $_: $!\n");
+ return ('error_removing_index_file', $_, $!);
+ }
+ my $cmd = "$inst_dir/db2index -n \"$dbname\" -t \"$indexname\"";
+ debug(1, "Re-creating index file $_: $cmd\n");
+ $? = 0; # clear error condition
+ my $output = `$cmd 2>&1`;
+ if ($?) {
+ return ('error_recreating_index_file', $_, $output);
+ }
+ debug(1, $output);
+ } else {
+ debug(3, "Index $indexname is not for an integer syntax attribute - skipping\n");
+ }
+ }
+
+ return ();
+}
+
# migrate all of the databases in an instance
sub migrateDatabases {
my $mig = shift; # the Migration object
@@ -436,6 +475,15 @@ sub migrateDatabases {
if (@errs = copyDatabaseDirs($srcdir, "$newdbdir")) {
return @errs;
}
+ # fix up the integer indexes
+ if ($mig->{integerattrs}) {
+ debug(3, "The schema has some integer attributes\n");
+ if (@errs = fixIntegerIndexes($mig, $inst_dir, $newdbdir)) {
+ return @errs;
+ }
+ } else {
+ debug(3, "No integer attributes to fix for $newdbdir\n");
+ }
}
}
} while ($ent = $src->nextEntry());
@@ -680,6 +728,12 @@ my %deletedschema = (
'51ns-calendar' => '51ns-calendar.ldif'
);
+# these indexes are handled specially by the db code
+my %intattrstoskip = (
+ 'numsubordinates' => 'numSubordinates',
+ 'hassubordinates' => 'hasSubordinates'
+);
+
sub migrateSchema {
my $mig = shift; # the Migration object
my $inst = shift; # the instance name (e.g. slapd-instance)
@@ -700,6 +754,39 @@ sub migrateSchema {
}
}
+ if (!$mig->{crossplatform}) {
+ # now, for all of the new schema, we need to get the list of attribute
+ # types with INTEGER syntax, including derived types (e.g. SUP 'attr')
+ # not required for cross platform because import of the old ldif file
+ # will automatically recreate all indexes
+ my %intattrs = ();
+ for (glob("$newschemadir/*.ldif")) {
+ # read in schema entry from LDIF
+ open( MYSCHEMA, $_ ) || die "Can't open $_: $!";
+ my $in = new Mozilla::LDAP::LDIF(*MYSCHEMA);
+ while (my $ent = readOneEntry $in) {
+ my @attrs = $ent->getValues('attributeTypes');
+ foreach my $attr (@attrs) {
+ # first see if the attribute definition uses INTEGER syntax
+ # else see if the super uses INTEGER - note this assumes the attributes
+ # are listed in the files in SUP order - that is, an attribute does
+ # not reference a SUP before it is defined
+ if ($attr =~ / NAME (?:\(\s)?[\']?(\w+)[\']?.* SYNTAX 1.3.6.1.4.1.1466.115.121.1.27[\{\s]/) {
+ next if ($intattrstoskip{lc $1});
+ $intattrs{lc $1} = $1;
+ } elsif (($attr =~ / NAME (?:\(\s)?[\']?(\w+)[\']?.*SUP [\']?(\w+)[\']?/) &&
+ $intattrs{lc $2}) {
+ next if ($intattrstoskip{lc $1});
+ $intattrs{lc $1} = $1;
+ }
+ }
+ }
+ close MYSCHEMA;
+ }
+ # %intattrs now contains all of the integer valued attributes
+ $mig->{integerattrs} = \%intattrs; # hashref
+ }
+
return ();
}
diff --git a/ldap/admin/src/scripts/migrate-ds.res b/ldap/admin/src/scripts/migrate-ds.res
index 05d1677d..f739196d 100644
--- a/ldap/admin/src/scripts/migrate-ds.res
+++ b/ldap/admin/src/scripts/migrate-ds.res
@@ -22,3 +22,6 @@ LDIF files are required in order to do cross platform migration. The\
database files are not binary compatible, and the new databases must\
be initialized from an LDIF export of the old databases. Please refer\
to the migration instructions for help with how to do this.\n\n
+fixing_integer_attr_index = The index for the attribute '%s' in the database directory '%s' will be removed and re-created.\n\n
+error_removing_index_file = Could not remove the index file '%s'. Error: %s\n\n
+error_recreating_index_file = Could not re-create the index file '%s'. Error: %s\n\n