Merge lp:~stewart/drizzle/fix-create-schema-for-catalogs into lp:~drizzle-trunk/drizzle/development

Proposed by Stewart Smith
Status: Work in progress
Proposed branch: lp:~stewart/drizzle/fix-create-schema-for-catalogs
Merge into: lp:~drizzle-trunk/drizzle/development
Prerequisite: lp:~stewart/drizzle/schema-identifier-has-catalog
Diff against target: 270 lines (+22/-79)
10 files modified
drizzled/identifier/constants/schema.cc (+1/-1)
drizzled/message/schema.cc (+9/-18)
drizzled/message/schema.h (+1/-2)
drizzled/statement/alter_schema.cc (+1/-1)
drizzled/statement/create_schema.cc (+1/-1)
drizzled/table/instance/base.cc (+0/-24)
plugin/schema_engine/schema.cc (+0/-19)
plugin/transaction_log/tests/t/bug911643-master.opt (+1/-5)
unittests/main.cc (+1/-1)
unittests/table_identifier.cc (+7/-7)
To merge this branch: bzr merge lp:~stewart/drizzle/fix-create-schema-for-catalogs
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+87580@code.launchpad.net

Description of the change

This fixes a bit of code around creating and altering SCHEMAs so that it takes what CATALOG you're connected to into account.

i.e. it allows you to (only with console plugin currently) create schemas in catalogs other than LOCAL.

To post a comment you must log in.
2493. By Stewart Smith

merge trunk

2494. By Stewart Smith

fix up table_identifier unit tests to deal with identifier::Table constructor now also requiring a Catalog identifier

2495. By Stewart Smith

fix up problem with constant schema identifiers for DATA_DICTIONARY and INFORMATION_SCHEMA that came up on certain compilers choosing orders for static constructor execution.

Unmerged revisions

2495. By Stewart Smith

fix up problem with constant schema identifiers for DATA_DICTIONARY and INFORMATION_SCHEMA that came up on certain compilers choosing orders for static constructor execution.

2494. By Stewart Smith

fix up table_identifier unit tests to deal with identifier::Table constructor now also requiring a Catalog identifier

2493. By Stewart Smith

merge trunk

2492. By Stewart Smith

fix initialization of message::schema to be from the Schema identifier, which includes the CATALOG name, so that we can create schemas in catalogs other than LOCAL

2491. By Stewart Smith

force a identifier::Schema to be constructed with a identifier::Catalog. This is close to the final 'big' part for CATALOG support. We also have to modify all around the server that creates identifier::Schema so it does so properly. Since a single Session cannot span schemas, we get off a wee bit easy :) The big limitation in this patch is that INFORMATION_SCHEMA and DATA_DICTIONARY only appear in the LOCAL catalog (and this really needs to be fixed before CATALOGs other than LOCAL are supported).

2490. By Stewart Smith

use the table identifier and catalog in the identifier in constructing the path in build_table_filename instead of the global drizzled::catalog::local_identifier(). Another step towards full CATALOG support

2489. By Stewart Smith

merge table_identifier unittest fix

2488. By Stewart Smith

TableShare use a TableIdentifier instead of db,table strings.

2487. By Stewart Smith

merge print_transaction_message filename/path bug fix (also hit in testing CATALOG)

2486. By Stewart Smith

merge off-by-one error message fix (was hitting this)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/identifier/constants/schema.cc'
2--- drizzled/identifier/constants/schema.cc 2012-01-18 05:02:25 +0000
3+++ drizzled/identifier/constants/schema.cc 2012-01-18 05:02:26 +0000
4@@ -32,7 +32,7 @@
5 public:
6 /* FIXME: use a global identifier for catalog */
7 Schema(const char* name) :
8- identifier::Schema(drizzled::catalog::local_identifier(),
9+ identifier::Schema(drizzled::identifier::Catalog(str_ref("LOCAL")),
10 str_ref(name)),
11 path_(boost::to_lower_copy(getSchemaName()))
12 {
13
14=== modified file 'drizzled/message/schema.cc'
15--- drizzled/message/schema.cc 2011-04-20 22:18:30 +0000
16+++ drizzled/message/schema.cc 2012-01-18 05:02:26 +0000
17@@ -38,24 +38,15 @@
18 {
19 shared_ptr shared(new message::Schema);
20
21- init(*shared, identifier.getSchemaName());
22-
23- return shared;
24-}
25-
26-shared_ptr make_shared(const std::string &name_arg)
27-{
28- shared_ptr shared(new message::Schema);
29-
30- init(*shared, name_arg);
31-
32- return shared;
33-}
34-
35-void init(drizzled::message::Schema &arg, const std::string &name_arg)
36-{
37- arg.set_name(name_arg);
38- arg.set_catalog(drizzled::catalog::local()->name());
39+ init(*shared, identifier);
40+
41+ return shared;
42+}
43+
44+void init(drizzled::message::Schema &arg, const drizzled::identifier::Schema &identifier)
45+{
46+ arg.set_name(identifier.getSchemaName());
47+ arg.set_catalog(identifier.getCatalogName());
48 arg.mutable_engine()->set_name(std::string("filesystem")); // For the moment we have only one.
49 arg.set_creation_timestamp(time(NULL));
50 arg.set_update_timestamp(time(NULL));
51
52=== modified file 'drizzled/message/schema.h'
53--- drizzled/message/schema.h 2011-03-23 23:44:48 +0000
54+++ drizzled/message/schema.h 2012-01-18 05:02:26 +0000
55@@ -35,8 +35,7 @@
56 typedef const message::Schema const_reference;
57
58 shared_ptr make_shared(const identifier::Schema& identifier);
59-shared_ptr make_shared(const std::string &name_arg);
60-void init(drizzled::message::Schema &arg, const std::string &name_arg);
61+void init(drizzled::message::Schema &arg, const drizzled::identifier::Schema &identifier);
62
63
64 } // namespace schema
65
66=== modified file 'drizzled/statement/alter_schema.cc'
67--- drizzled/statement/alter_schema.cc 2012-01-18 05:02:25 +0000
68+++ drizzled/statement/alter_schema.cc 2012-01-18 05:02:26 +0000
69@@ -67,7 +67,7 @@
70 */
71
72 // First initialize the schema message
73- drizzled::message::schema::init(schema_message, old_definition->name());
74+ drizzled::message::schema::init(schema_message, identifier);
75
76 // We set the name from the old version to keep case preference
77 schema_message.set_version(old_definition->version());
78
79=== modified file 'drizzled/statement/create_schema.cc'
80--- drizzled/statement/create_schema.cc 2012-01-18 05:02:25 +0000
81+++ drizzled/statement/create_schema.cc 2012-01-18 05:02:26 +0000
82@@ -53,7 +53,7 @@
83 if (not check(schema_identifier))
84 return false;
85
86- drizzled::message::schema::init(schema_message, lex().name.data());
87+ drizzled::message::schema::init(schema_message, schema_identifier);
88
89 message::set_definer(schema_message, *session().user());
90
91
92=== modified file 'drizzled/table/instance/base.cc'
93--- drizzled/table/instance/base.cc 2012-01-18 05:02:25 +0000
94+++ drizzled/table/instance/base.cc 2012-01-18 05:02:26 +0000
95@@ -340,12 +340,6 @@
96 table_category= TABLE_CATEGORY_TEMPORARY;
97 tmp_table= message::Table::INTERNAL;
98
99-<<<<<<< TREE
100- db= str_ref(private_key_for_cache.vector() + strlen(private_key_for_cache.vector()) + 1);
101-
102- table_name= str_ref(db.data() + strlen(db.data()) + 1);
103-=======
104->>>>>>> MERGE-SOURCE
105 path= str_ref("");
106 normalized_path= str_ref("");
107 }
108@@ -471,15 +465,6 @@
109 table_identifier= new identifier::Table(identifier);
110
111 private_key_for_cache= identifier.getKey();
112-<<<<<<< TREE
113- /*
114- Let us use the fact that the key is "db/0/table_name/0" + optional
115- part for temporary tables.
116- */
117- db= str_ref(private_key_for_cache.vector() + strlen(private_key_for_cache.vector()) + 1);
118- table_name= str_ref(db.data() + db.size() + 1);
119-=======
120->>>>>>> MERGE-SOURCE
121
122 std::string _path;
123 if (path_arg)
124@@ -525,17 +510,8 @@
125 {
126 private_key_for_cache= identifier_arg.getKey();
127
128-<<<<<<< TREE
129- /*
130- Let us use the fact that the key is "db/0/table_name/0" + optional
131- part for temporary tables.
132- */
133- db= str_ref(private_key_for_cache.vector() + strlen(private_key_for_cache.vector()) + 1);
134- table_name= str_ref(db.data() + db.size() + 1);
135-=======
136 delete table_identifier;
137 table_identifier= new identifier::Table(identifier_arg);
138->>>>>>> MERGE-SOURCE
139
140 getTableMessage()->set_name(identifier_arg.getTableName());
141 getTableMessage()->set_schema(identifier_arg.getSchemaName());
142
143=== modified file 'plugin/schema_engine/schema.cc'
144--- plugin/schema_engine/schema.cc 2012-01-18 05:02:25 +0000
145+++ plugin/schema_engine/schema.cc 2012-01-18 05:02:26 +0000
146@@ -26,12 +26,8 @@
147 #include <drizzled/sql_table.h>
148 #include <drizzled/charset.h>
149 #include <drizzled/cursor.h>
150-<<<<<<< TREE
151-#include <drizzled/catalog/local.h>
152-=======
153 #include <drizzled/data_home.h>
154 #include <drizzled/message/catalog.h>
155->>>>>>> MERGE-SOURCE
156
157 #include <drizzled/pthread_globals.h>
158
159@@ -76,15 +72,9 @@
160
161 void Schema::prime_catalog(identifier::Catalog &catalog_identifier)
162 {
163-<<<<<<< TREE
164- CachedDirectory directory(catalog::local_identifier().getPath(),
165- CachedDirectory::DIRECTORY, true);
166-
167-=======
168 CachedDirectory directory(catalog_identifier.getPath(),
169 CachedDirectory::DIRECTORY, true);
170
171->>>>>>> MERGE-SOURCE
172 CachedDirectory::Entries files= directory.getEntries();
173 boost::unique_lock<boost::shared_mutex> scopedLock(mutex);
174
175@@ -93,21 +83,12 @@
176 if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))
177 continue;
178 message::Schema schema_message;
179-<<<<<<< TREE
180-
181- std::string filename= catalog::local_identifier().getPath();
182- filename+= FN_LIBCHAR;
183- filename+= entry->filename;
184-
185- if (readSchemaFile(filename, schema_message))
186-=======
187
188 std::string filename= catalog_identifier.getPath();
189 filename+= FN_LIBCHAR;
190 filename+= entry->filename;
191
192 if (readSchemaFile(filename, schema_message))
193->>>>>>> MERGE-SOURCE
194 {
195
196 identifier::Schema schema_identifier(catalog_identifier,
197
198=== modified file 'plugin/transaction_log/tests/t/bug911643-master.opt'
199--- plugin/transaction_log/tests/t/bug911643-master.opt 2012-01-18 05:02:25 +0000
200+++ plugin/transaction_log/tests/t/bug911643-master.opt 2012-01-18 05:02:26 +0000
201@@ -1,5 +1,1 @@
202-<<<<<<< TREE
203---transaction-log.enable --scheduler=multi_thread --transaction-message-threshold=131072 --allow-all-authentication.allow_anonymous=true --transaction-log.file=../local/transaction.log
204-=======
205---transaction-log.enable --scheduler=multi_thread --transaction-message-threshold=131072 --allow-all-authentication.allow_anonymous=true --transaction-log.file=local/test/transaction.log
206->>>>>>> MERGE-SOURCE
207+--transaction-log.enable --scheduler=multi_thread --transaction-message-threshold=131072 --allow-all-authentication.allow_anonymous=true --transaction-log.file=local/transaction.log
208
209=== modified file 'unittests/main.cc'
210--- unittests/main.cc 2011-12-25 02:34:26 +0000
211+++ unittests/main.cc 2012-01-18 05:02:26 +0000
212@@ -27,7 +27,7 @@
213 {
214 MyConfig()
215 {
216- boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_nothing);
217+ boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_successful_tests);
218 boost::unit_test::unit_test_log.set_format(boost::unit_test::CLF);
219 }
220
221
222=== modified file 'unittests/table_identifier.cc'
223--- unittests/table_identifier.cc 2012-01-04 09:51:04 +0000
224+++ unittests/table_identifier.cc 2012-01-18 05:02:26 +0000
225@@ -30,21 +30,21 @@
226 BOOST_AUTO_TEST_SUITE(TableIdentifierTest)
227 BOOST_AUTO_TEST_CASE(CreateStandard)
228 {
229- identifier::Table identifier("test", "a");
230- BOOST_REQUIRE_EQUAL("test/a", identifier.getPath());
231+ identifier::Table identifier(identifier::Catalog(str_ref("local")), "test", "a");
232+ BOOST_REQUIRE_EQUAL("local/test/a", identifier.getPath());
233 BOOST_REQUIRE_EQUAL("test.a", identifier.getSQLPath());
234 }
235
236 BOOST_AUTO_TEST_CASE(CreateTemporary)
237 {
238- identifier::Table identifier("test", "a", message::Table::TEMPORARY);
239+ identifier::Table identifier(identifier::Catalog(str_ref("local")), "test", "a", message::Table::TEMPORARY);
240 BOOST_REQUIRE_EQUAL("/#sql", identifier.getPath().substr(0, 5));
241 BOOST_REQUIRE_EQUAL("test.#a", identifier.getSQLPath());
242 }
243
244 BOOST_AUTO_TEST_CASE(CreateInternal)
245 {
246- identifier::Table identifier("test", "a", message::Table::TEMPORARY);
247+ identifier::Table identifier(identifier::Catalog(str_ref("local")), "test", "a", message::Table::TEMPORARY);
248 BOOST_REQUIRE_EQUAL("/#sql", identifier.getPath().substr(0, 5));
249 BOOST_REQUIRE_EQUAL("test.#a", identifier.getSQLPath());
250 }
251@@ -59,7 +59,7 @@
252
253 BOOST_AUTO_TEST_CASE(Key)
254 {
255- identifier::Table identifier("test", "a");
256+ identifier::Table identifier(identifier::Catalog(str_ref("LOCAL")), "test", "a");
257
258 const identifier::Table::Key key= identifier.getKey();
259
260@@ -82,8 +82,8 @@
261
262 BOOST_AUTO_TEST_CASE(KeyCompare)
263 {
264- identifier::Table identifier("test", "a");
265- identifier::Table identifier2("test", "a");
266+ identifier::Table identifier(identifier::Catalog(str_ref("foo")), "test", "a");
267+ identifier::Table identifier2(identifier::Catalog(str_ref("foo")), "test", "a");
268
269 BOOST_REQUIRE_EQUAL((identifier.getKey() == identifier.getKey()), true);
270 }