~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2010-12-07 18:30:53 UTC
  • mto: This revision was merged to the branch mainline in revision 1983.
  • Revision ID: brian@tangent.org-20101207183053-eg32l3701i5qvkh7
This resolves the issue where one thread may be looking at schema while
another thread could be updating it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4908
4908
 
4909
4909
              std::string column_name= "Tables_in_";
4910
4910
 
 
4911
              util::string::const_shared_ptr schema(session->schema());
4911
4912
              if ($2)
4912
4913
              {
4913
4914
                SchemaIdentifier identifier($2);
4919
4920
                }
4920
4921
                select->setShowPredicate($2, "");
4921
4922
              }
4922
 
              else if (not session->db.empty())
 
4923
              else if (schema and not schema->empty())
4923
4924
              {
4924
 
                column_name.append(session->db);
4925
 
                select->setShowPredicate(session->db, "");
 
4925
                column_name.append(*schema);
 
4926
                select->setShowPredicate(*schema, "");
4926
4927
              }
4927
4928
              else
4928
4929
              {
4929
 
                 my_error(ER_NO_DB_ERROR, MYF(0));
 
4930
                my_error(ER_NO_DB_ERROR, MYF(0));
 
4931
                DRIZZLE_YYABORT;
4930
4932
              }
4931
4933
 
4932
4934
 
4994
4996
 
4995
4997
             std::string column_name= "Tables_in_";
4996
4998
 
 
4999
             util::string::const_shared_ptr schema(session->schema());
4997
5000
             if ($3)
4998
5001
             {
4999
5002
               lex->select_lex.db= $3;
5006
5009
 
5007
5010
               select->setShowPredicate($3, "");
5008
5011
             }
 
5012
             else if (schema)
 
5013
             {
 
5014
               select->setShowPredicate(*schema, "");
 
5015
             }
5009
5016
             else
5010
5017
             {
5011
 
               select->setShowPredicate(session->db, "");
 
5018
               my_error(ER_NO_DB_ERROR, MYF(0));
 
5019
               DRIZZLE_YYABORT;
5012
5020
             }
5013
5021
 
5014
5022
             if (prepare_new_schema_table(session, lex, "SHOW_TABLE_STATUS"))
5036
5044
             if (lex->statement == NULL)
5037
5045
               DRIZZLE_YYABORT;
5038
5046
 
 
5047
             util::string::const_shared_ptr schema(session->schema());
5039
5048
             if ($4)
 
5049
             {
5040
5050
              select->setShowPredicate($4, $3->table.str);
 
5051
             }
5041
5052
             else if ($3->db.str)
 
5053
             {
5042
5054
              select->setShowPredicate($3->db.str, $3->table.str);
 
5055
             }
 
5056
             else if (schema)
 
5057
             {
 
5058
               select->setShowPredicate(*schema, $3->table.str);
 
5059
             }
5043
5060
             else
5044
 
              select->setShowPredicate(session->db, $3->table.str);
 
5061
             {
 
5062
               my_error(ER_NO_DB_ERROR, MYF(0));
 
5063
               DRIZZLE_YYABORT;
 
5064
             }
5045
5065
 
5046
5066
             {
5047
5067
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
5079
5099
             if (lex->statement == NULL)
5080
5100
               DRIZZLE_YYABORT;
5081
5101
 
 
5102
             util::string::const_shared_ptr schema(session->schema());
5082
5103
             if ($4)
 
5104
             {
5083
5105
              select->setShowPredicate($4, $3->table.str);
 
5106
             }
5084
5107
             else if ($3->db.str)
 
5108
             {
5085
5109
              select->setShowPredicate($3->db.str, $3->table.str);
 
5110
             }
 
5111
             else if (schema)
 
5112
             {
 
5113
               select->setShowPredicate(*schema, $3->table.str);
 
5114
             }
5086
5115
             else
5087
 
              select->setShowPredicate(session->db, $3->table.str);
 
5116
             {
 
5117
               my_error(ER_NO_DB_ERROR, MYF(0));
 
5118
               DRIZZLE_YYABORT;
 
5119
             }
5088
5120
 
5089
5121
             {
5090
5122
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
5191
5223
             if (prepare_new_schema_table(session, lex, "TABLE_SQL_DEFINITION"))
5192
5224
               DRIZZLE_YYABORT;
5193
5225
 
 
5226
             util::string::const_shared_ptr schema(session->schema());
5194
5227
             if ($3->db.str)
5195
 
              select->setShowPredicate($3->db.str, $3->table.str);
 
5228
             {
 
5229
               select->setShowPredicate($3->db.str, $3->table.str);
 
5230
             }
 
5231
             else if (schema)
 
5232
             {
 
5233
               select->setShowPredicate(*schema, $3->table.str);
 
5234
             }
5196
5235
             else
5197
 
              select->setShowPredicate(session->db, $3->table.str);
 
5236
             {
 
5237
               my_error(ER_NO_DB_ERROR, MYF(0));
 
5238
               DRIZZLE_YYABORT;
 
5239
             }
5198
5240
 
5199
5241
             std::string key("Table");
5200
5242
             std::string value("Create Table");
5291
5333
             if (prepare_new_schema_table(session, lex, "SCHEMA_SQL_DEFINITION"))
5292
5334
               DRIZZLE_YYABORT;
5293
5335
 
 
5336
             util::string::const_shared_ptr schema(session->schema());
5294
5337
             if ($4.str)
 
5338
             {
5295
5339
              select->setShowPredicate($4.str);
 
5340
             }
 
5341
             else if (schema)
 
5342
             {
 
5343
               select->setShowPredicate(*schema);
 
5344
             }
5296
5345
             else
5297
 
              select->setShowPredicate(session->db);
 
5346
             {
 
5347
               my_error(ER_NO_DB_ERROR, MYF(0));
 
5348
               DRIZZLE_YYABORT;
 
5349
             }
5298
5350
 
5299
5351
             std::string key("Database");
5300
5352
             std::string value("Create Database");
5358
5410
              DRIZZLE_YYABORT;
5359
5411
            lex->select_lex.db= 0;
5360
5412
 
 
5413
             util::string::const_shared_ptr schema(session->schema());
5361
5414
             if ($2->db.str)
5362
 
              select->setShowPredicate($2->db.str, $2->table.str);
 
5415
             {
 
5416
               select->setShowPredicate($2->db.str, $2->table.str);
 
5417
             }
 
5418
             else if (schema)
 
5419
             {
 
5420
               select->setShowPredicate(*schema, $2->table.str);
 
5421
             }
5363
5422
             else
5364
 
              select->setShowPredicate(session->db, $2->table.str);
 
5423
             {
 
5424
               my_error(ER_NO_DB_ERROR, MYF(0));
 
5425
               DRIZZLE_YYABORT;
 
5426
             }
5365
5427
 
5366
5428
             {
5367
5429
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $2->table.str);
5379
5441
             if (session->add_item_to_list( new Item_field(&session->lex->current_select->
5380
5442
                                                           context,
5381
5443
                                                           NULL, NULL, "*")))
 
5444
             {
5382
5445
               DRIZZLE_YYABORT;
 
5446
             }
5383
5447
             (session->lex->current_select->with_wild)++;
5384
5448
 
5385
5449
          }