Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 315962 Details for
Bug 461403
Index tables after loading data
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Index tables after loading data
0001-Index-tables-after-loading-data.patch (text/plain), 12.63 KB, created by
Ville Skyttä
on 2008-09-07 10:51:47 UTC
(
hide
)
Description:
Index tables after loading data
Filename:
MIME Type:
Creator:
Ville Skyttä
Created:
2008-09-07 10:51:47 UTC
Size:
12.63 KB
patch
obsolete
>From af98b98d442b4d2213e639754972ef9d3e5b4039 Mon Sep 17 00:00:00 2001 >From: =?utf-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi> >Date: Sun, 7 Sep 2008 11:18:27 +0300 >Subject: [PATCH] Index tables after loading data. > >--- > db.c | 173 +++++++++++++++++++++++++++++++++------------------------ > db.h | 3 + > sqlitecache.c | 10 +++ > 3 files changed, 113 insertions(+), 73 deletions(-) > >diff --git a/db.c b/db.c >index d2b51d6..59fad0e 100644 >--- a/db.c >+++ b/db.c >@@ -349,24 +349,6 @@ yum_db_create_primary_tables (sqlite3 *db, GError **err) > return; > } > >- sql = "CREATE INDEX packagename ON packages (name)"; >- rc = sqlite3_exec (db, sql, NULL, NULL, NULL); >- if (rc != SQLITE_OK) { >- g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create packagename index: %s", >- sqlite3_errmsg (db)); >- return; >- } >- >- sql = "CREATE INDEX packageId ON packages (pkgId)"; >- rc = sqlite3_exec (db, sql, NULL, NULL, NULL); >- if (rc != SQLITE_OK) { >- g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create packageId index: %s", >- sqlite3_errmsg (db)); >- return; >- } >- > sql = > "CREATE TABLE files (" > " name TEXT," >@@ -380,15 +362,6 @@ yum_db_create_primary_tables (sqlite3 *db, GError **err) > return; > } > >- sql = "CREATE INDEX filenames ON files (name)"; >- rc = sqlite3_exec (db, sql, NULL, NULL, NULL); >- if (rc != SQLITE_OK) { >- g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create filenames index: %s", >- sqlite3_errmsg (db)); >- return; >- } >- > sql = > "CREATE TABLE %s (" > " name TEXT," >@@ -401,9 +374,6 @@ yum_db_create_primary_tables (sqlite3 *db, GError **err) > const char *deps[] = { "requires", "provides", "conflicts", "obsoletes", NULL }; > int i; > >- const char *pkgindexsql = "CREATE INDEX pkg%s on %s (pkgKey)"; >- const char *nameindexsql = "CREATE INDEX %sname ON %s (name)"; >- > for (i = 0; deps[i]; i++) { > const char *prereq; > char *query; >@@ -423,6 +393,68 @@ yum_db_create_primary_tables (sqlite3 *db, GError **err) > deps[i], sqlite3_errmsg (db)); > return; > } >+ } >+ >+ sql = >+ "CREATE TRIGGER removals AFTER DELETE ON packages" >+ " BEGIN" >+ " DELETE FROM files WHERE pkgKey = old.pkgKey;" >+ " DELETE FROM requires WHERE pkgKey = old.pkgKey;" >+ " DELETE FROM provides WHERE pkgKey = old.pkgKey;" >+ " DELETE FROM conflicts WHERE pkgKey = old.pkgKey;" >+ " DELETE FROM obsoletes WHERE pkgKey = old.pkgKey;" >+ " END;"; >+ >+ rc = sqlite3_exec (db, sql, NULL, NULL, NULL); >+ if (rc != SQLITE_OK) { >+ g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >+ "Can not create removals trigger: %s", >+ sqlite3_errmsg (db)); >+ return; >+ } >+} >+ >+void >+yum_db_index_primary_tables (sqlite3 *db, GError **err) >+{ >+ int rc; >+ const char *sql; >+ >+ sql = "CREATE INDEX packagename ON packages (name)"; >+ rc = sqlite3_exec (db, sql, NULL, NULL, NULL); >+ if (rc != SQLITE_OK) { >+ g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >+ "Can not create packagename index: %s", >+ sqlite3_errmsg (db)); >+ return; >+ } >+ >+ sql = "CREATE INDEX packageId ON packages (pkgId)"; >+ rc = sqlite3_exec (db, sql, NULL, NULL, NULL); >+ if (rc != SQLITE_OK) { >+ g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >+ "Can not create packageId index: %s", >+ sqlite3_errmsg (db)); >+ return; >+ } >+ >+ sql = "CREATE INDEX filenames ON files (name)"; >+ rc = sqlite3_exec (db, sql, NULL, NULL, NULL); >+ if (rc != SQLITE_OK) { >+ g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >+ "Can not create filenames index: %s", >+ sqlite3_errmsg (db)); >+ return; >+ } >+ >+ const char *deps[] = { "requires", "provides", "conflicts", "obsoletes", NULL }; >+ int i; >+ >+ const char *pkgindexsql = "CREATE INDEX pkg%s on %s (pkgKey)"; >+ const char *nameindexsql = "CREATE INDEX %sname ON %s (name)"; >+ >+ for (i = 0; deps[i]; i++) { >+ char *query; > > query = g_strdup_printf(pkgindexsql, deps[i], deps[i]); > rc = sqlite3_exec (db, query, NULL, NULL, NULL); >@@ -445,25 +477,6 @@ yum_db_create_primary_tables (sqlite3 *db, GError **err) > return; > } > } >- >- } >- >- sql = >- "CREATE TRIGGER removals AFTER DELETE ON packages" >- " BEGIN" >- " DELETE FROM files WHERE pkgKey = old.pkgKey;" >- " DELETE FROM requires WHERE pkgKey = old.pkgKey;" >- " DELETE FROM provides WHERE pkgKey = old.pkgKey;" >- " DELETE FROM conflicts WHERE pkgKey = old.pkgKey;" >- " DELETE FROM obsoletes WHERE pkgKey = old.pkgKey;" >- " END;"; >- >- rc = sqlite3_exec (db, sql, NULL, NULL, NULL); >- if (rc != SQLITE_OK) { >- g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create removals trigger: %s", >- sqlite3_errmsg (db)); >- return; > } > } > >@@ -677,43 +690,50 @@ yum_db_create_filelist_tables (sqlite3 *db, GError **err) > return; > } > >- sql = "CREATE INDEX keyfile ON filelist (pkgKey)"; >+ sql = >+ "CREATE TRIGGER remove_filelist AFTER DELETE ON packages" >+ " BEGIN" >+ " DELETE FROM filelist WHERE pkgKey = old.pkgKey;" >+ " END;"; >+ > rc = sqlite3_exec (db, sql, NULL, NULL, NULL); > if (rc != SQLITE_OK) { > g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create keyfile index: %s", >+ "Can not create remove_filelist trigger: %s", > sqlite3_errmsg (db)); > return; > } >+} > >- sql = "CREATE INDEX pkgId ON packages (pkgId)"; >+void >+yum_db_index_filelist_tables (sqlite3 *db, GError **err) >+{ >+ int rc; >+ const char *sql; >+ >+ sql = "CREATE INDEX keyfile ON filelist (pkgKey)"; > rc = sqlite3_exec (db, sql, NULL, NULL, NULL); > if (rc != SQLITE_OK) { > g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create pkgId index: %s", >+ "Can not create keyfile index: %s", > sqlite3_errmsg (db)); > return; > } > >- sql = "CREATE INDEX dirnames ON filelist (dirname)"; >+ sql = "CREATE INDEX pkgId ON packages (pkgId)"; > rc = sqlite3_exec (db, sql, NULL, NULL, NULL); > if (rc != SQLITE_OK) { > g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create dirnames index: %s", >+ "Can not create pkgId index: %s", > sqlite3_errmsg (db)); > return; > } > >- sql = >- "CREATE TRIGGER remove_filelist AFTER DELETE ON packages" >- " BEGIN" >- " DELETE FROM filelist WHERE pkgKey = old.pkgKey;" >- " END;"; >- >+ sql = "CREATE INDEX dirnames ON filelist (dirname)"; > rc = sqlite3_exec (db, sql, NULL, NULL, NULL); > if (rc != SQLITE_OK) { > g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create remove_filelist trigger: %s", >+ "Can not create dirnames index: %s", > sqlite3_errmsg (db)); > return; > } >@@ -852,34 +872,41 @@ yum_db_create_other_tables (sqlite3 *db, GError **err) > return; > } > >- sql = "CREATE INDEX keychange ON changelog (pkgKey)"; >+ sql = >+ "CREATE TRIGGER remove_changelogs AFTER DELETE ON packages" >+ " BEGIN" >+ " DELETE FROM changelog WHERE pkgKey = old.pkgKey;" >+ " END;"; >+ > rc = sqlite3_exec (db, sql, NULL, NULL, NULL); > if (rc != SQLITE_OK) { > g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create keychange index: %s", >+ "Can not create remove_changelogs trigger: %s", > sqlite3_errmsg (db)); > return; > } >+} > >- sql = "CREATE INDEX pkgId ON packages (pkgId)"; >+void >+yum_db_index_other_tables (sqlite3 *db, GError **err) >+{ >+ int rc; >+ const char *sql; >+ >+ sql = "CREATE INDEX keychange ON changelog (pkgKey)"; > rc = sqlite3_exec (db, sql, NULL, NULL, NULL); > if (rc != SQLITE_OK) { > g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create pkgId index: %s", >+ "Can not create keychange index: %s", > sqlite3_errmsg (db)); > return; > } > >- sql = >- "CREATE TRIGGER remove_changelogs AFTER DELETE ON packages" >- " BEGIN" >- " DELETE FROM changelog WHERE pkgKey = old.pkgKey;" >- " END;"; >- >+ sql = "CREATE INDEX pkgId ON packages (pkgId)"; > rc = sqlite3_exec (db, sql, NULL, NULL, NULL); > if (rc != SQLITE_OK) { > g_set_error (err, YUM_DB_ERROR, YUM_DB_ERROR, >- "Can not create remove_changelogs trigger: %s", >+ "Can not create pkgId index: %s", > sqlite3_errmsg (db)); > return; > } >diff --git a/db.h b/db.h >index a91d329..fce455d 100644 >--- a/db.h >+++ b/db.h >@@ -44,6 +44,7 @@ GHashTable *yum_db_read_package_ids (sqlite3 *db, GError **err); > /* Primary */ > > void yum_db_create_primary_tables (sqlite3 *db, GError **err); >+void yum_db_index_primary_tables (sqlite3 *db, GError **err); > sqlite3_stmt *yum_db_package_prepare (sqlite3 *db, GError **err); > void yum_db_package_write (sqlite3 *db, > sqlite3_stmt *handle, >@@ -67,6 +68,7 @@ void yum_db_file_write (sqlite3 *db, > /* Filelists */ > > void yum_db_create_filelist_tables (sqlite3 *db, GError **err); >+void yum_db_index_filelist_tables (sqlite3 *db, GError **err); > sqlite3_stmt *yum_db_package_ids_prepare (sqlite3 *db, GError **err); > void yum_db_package_ids_write (sqlite3 *db, > sqlite3_stmt *handle, >@@ -79,6 +81,7 @@ void yum_db_filelists_write (sqlite3 *db, > > /* Other */ > void yum_db_create_other_tables (sqlite3 *db, GError **err); >+void yum_db_index_other_tables (sqlite3 *db, GError **err); > sqlite3_stmt *yum_db_changelog_prepare (sqlite3 *db, GError **err); > void yum_db_changelog_write (sqlite3 *db, > sqlite3_stmt *handle, >diff --git a/sqlitecache.c b/sqlitecache.c >index bc20b56..5625dac 100644 >--- a/sqlitecache.c >+++ b/sqlitecache.c >@@ -37,6 +37,8 @@ typedef void (*XmlParseFn) (const char *filename, > > typedef void (*WriteDbPackageFn) (UpdateInfo *update_info, Package *package); > >+typedef void (*IndexTablesFn) (sqlite3 *db, GError **err); >+ > struct _UpdateInfo { > sqlite3 *db; > sqlite3_stmt *remove_handle; >@@ -55,6 +57,7 @@ struct _UpdateInfo { > CreateTablesFn create_tables; > WriteDbPackageFn write_package; > XmlParseFn xml_parse; >+ IndexTablesFn index_tables; > > gpointer user_data; > }; >@@ -423,6 +426,10 @@ update_packages (UpdateInfo *update_info, > goto cleanup; > sqlite3_exec (update_info->db, "COMMIT", NULL, NULL, NULL); > >+ update_info->index_tables (update_info->db, err); >+ if (*err) >+ goto cleanup; >+ > update_info_remove_old_entries (update_info); > yum_db_dbinfo_update (update_info->db, checksum, err); > >@@ -566,6 +573,7 @@ py_update_primary (PyObject *self, PyObject *args) > info.update_info.create_tables = yum_db_create_primary_tables; > info.update_info.write_package = write_package_to_db; > info.update_info.xml_parse = yum_xml_parse_primary; >+ info.update_info.index_tables = yum_db_index_primary_tables; > > return py_update (self, args, (UpdateInfo *) &info); > } >@@ -581,6 +589,7 @@ py_update_filelist (PyObject *self, PyObject *args) > info.update_info.create_tables = yum_db_create_filelist_tables; > info.update_info.write_package = write_filelist_package_to_db; > info.update_info.xml_parse = yum_xml_parse_filelists; >+ info.update_info.index_tables = yum_db_index_filelist_tables; > > return py_update (self, args, (UpdateInfo *) &info); > } >@@ -596,6 +605,7 @@ py_update_other (PyObject *self, PyObject *args) > info.update_info.create_tables = yum_db_create_other_tables; > info.update_info.write_package = write_other_package_to_db; > info.update_info.xml_parse = yum_xml_parse_other; >+ info.update_info.index_tables = yum_db_index_other_tables; > > return py_update (self, args, (UpdateInfo *) &info); > } >-- >1.5.5.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 461403
: 315962 |
315963