00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022 #include <plugin/information_schema_dictionary/dictionary.h>
00023
00024 using namespace std;
00025 using namespace drizzled;
00026
00027 TableConstraints::TableConstraints() :
00028 InformationSchema("TABLE_CONSTRAINTS")
00029 {
00030 add_field("CONSTRAINT_CATALOG");
00031 add_field("CONSTRAINT_SCHEMA");
00032 add_field("CONSTRAINT_NAME");
00033 add_field("TABLE_CATALOG");
00034 add_field("TABLE_SCHEMA");
00035 add_field("TABLE_NAME");
00036 add_field("CONSTRAINT_TYPE");
00037 add_field("IS_DEFERRABLE", plugin::TableFunction::BOOLEAN, 0, false);
00038 add_field("INITIALLY_DEFERRED", plugin::TableFunction::BOOLEAN, 0, false);
00039 }
00040
00041 TableConstraints::Generator::Generator(drizzled::Field **arg) :
00042 InformationSchema::Generator(arg),
00043 generator(getSession()),
00044 index_iterator(0)
00045 {
00046 while (not (table_message= generator))
00047 { };
00048 }
00049
00050 bool TableConstraints::Generator::populate()
00051 {
00052 if (not table_message)
00053 return false;
00054
00055 do
00056 {
00057 if (index_iterator != table_message->indexes_size())
00058 {
00059 drizzled::message::Table::Index index= table_message->indexes(index_iterator);
00060
00061 index_iterator++;
00062
00063 if (index.is_primary() || index.is_unique())
00064 {
00065
00066
00067 push(table_message->catalog());
00068
00069
00070 push(table_message->schema());
00071
00072
00073 push(index.name());
00074
00075
00076 push(table_message->catalog());
00077
00078
00079 push(table_message->schema());
00080
00081
00082 push(table_message->name());
00083
00084
00085 if (index.is_primary())
00086 {
00087 push("PRIMARY KEY");
00088 }
00089 else if (index.is_unique())
00090 {
00091 push("UNIQUE");
00092 }
00093 else
00094 {
00095 assert(0);
00096 push("UNIQUE");
00097 }
00098
00099
00100 push(false);
00101
00102
00103 push(false);
00104
00105 return true;
00106 }
00107 }
00108
00109 index_iterator= 0;
00110
00111 } while ((table_message= generator));
00112
00113 return false;
00114 }