1056
1060
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1058
Session *session= YYSession;
1059
LEX *lex= session->lex;
1060
lex->sql_command= SQLCOM_CREATE_TABLE;
1061
statement::CreateTable *statement= new(std::nothrow) statement::CreateTable(YYSession);
1062
lex->statement= statement;
1063
if (lex->statement == NULL)
1065
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1069
lex->col_list.empty();
1070
statement->change=NULL;
1071
statement->is_if_not_exists= $4;
1072
statement->create_info.db_type= NULL;
1073
statement->create_info.default_table_charset= NULL;
1076
message::Table &proto= statement->create_table_message;
1078
proto.set_name($5->table.str);
1062
Lex->sql_command= SQLCOM_CREATE_TABLE;
1063
Lex->statement= new statement::CreateTable(YYSession);
1065
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
1069
Lex->col_list.empty();
1071
Lex->table()->set_name($5->table.str);
1080
proto.set_type(message::Table::TEMPORARY);
1073
Lex->table()->set_type(message::Table::TEMPORARY);
1082
proto.set_type(message::Table::STANDARD);
1075
Lex->table()->set_type(message::Table::STANDARD);
1077
create_table_definition
1086
LEX *lex= YYSession->lex;
1087
lex->current_select= &lex->select_lex;
1079
Lex->current_select= &Lex->select_lex;
1089
1081
| CREATE build_method
1092
lex->sql_command= SQLCOM_CREATE_INDEX;
1093
statement::CreateIndex *statement= new(std::nothrow) statement::CreateIndex(YYSession);
1094
lex->statement= statement;
1095
if (lex->statement == NULL)
1083
Lex->sql_command= SQLCOM_CREATE_INDEX;
1084
statement::CreateIndex *statement= new statement::CreateIndex(YYSession);
1085
Lex->statement= statement;
1097
1087
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1098
1088
statement->alter_info.build_method= $2;
1099
lex->col_list.empty();
1089
Lex->col_list.empty();
1100
1090
statement->change=NULL;
1102
1092
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
1105
1094
statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
1107
if (!lex->current_select->add_table_to_list(lex->session, $9,
1109
TL_OPTION_UPDATING))
1096
if (not Lex->current_select->add_table_to_list(Lex->session, $9,
1098
TL_OPTION_UPDATING))
1110
1099
DRIZZLE_YYABORT;
1112
key= new Key($4, $6, &statement->key_create_info, 0, lex->col_list);
1101
key= new Key($4, $6, &statement->key_create_info, 0, Lex->col_list);
1113
1102
statement->alter_info.key_list.push_back(key);
1114
lex->col_list.empty();
1103
Lex->col_list.empty();
1116
| CREATE DATABASE opt_if_not_exists ident
1105
| CREATE DATABASE opt_if_not_exists schema_name
1120
lex->sql_command=SQLCOM_CREATE_DB;
1121
statement::CreateSchema *statement= new(std::nothrow) statement::CreateSchema(YYSession);
1122
lex->statement= statement;
1123
if (lex->statement == NULL)
1125
statement->is_if_not_exists= $3;
1107
Lex->sql_command=SQLCOM_CREATE_DB;
1108
Lex->statement= new statement::CreateSchema(YYSession);
1127
1110
opt_create_database_options
1135
| opt_create_table_options
1137
| LIKE table_ident opt_create_table_options
1139
Session *session= YYSession;
1140
LEX *lex= session->lex;
1141
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1143
statement->is_create_table_like= true;
1144
if (!lex->select_lex.add_table_to_list(session, $2, NULL, 0, TL_READ))
1147
| '(' LIKE table_ident ')'
1149
Session *session= YYSession;
1150
LEX *lex= session->lex;
1151
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1153
statement->is_create_table_like= true;
1154
if (!lex->select_lex.add_table_to_list(session, $3, NULL, 0, TL_READ))
1160
field_list ')' opt_create_table_options
1163
{ Lex->current_select->set_braces(1);}
1116
create_table_definition:
1117
'(' field_list ')' opt_create_table_options create_select_as
1119
| '(' create_select ')'
1121
Lex->current_select->set_braces(1);
1124
| '(' create_like ')' opt_create_table_options
1126
| create_like opt_create_table_options
1128
| opt_create_table_options create_select_as
1169
| opt_duplicate opt_as create_select
1170
{ Lex->current_select->set_braces(0);}
1134
| opt_duplicate_as create_select
1136
Lex->current_select->set_braces(0);
1171
1138
union_clause {}
1172
| opt_duplicate opt_as '(' create_select ')'
1173
{ Lex->current_select->set_braces(1);}
1139
| opt_duplicate_as '(' create_select ')'
1141
Lex->current_select->set_braces(1);
1149
((statement::CreateTable *)(YYSession->getLex()->statement))->is_create_table_like= true;
1151
if (not YYSession->getLex()->select_lex.add_table_to_list(YYSession, $2, NULL, 0, TL_READ))
1163
This rule is used for both CREATE TABLE .. SELECT, AND INSERT ... SELECT
1181
lex->lock_option= TL_READ;
1182
if (lex->sql_command == SQLCOM_INSERT)
1168
Lex->lock_option= TL_READ;
1169
if (Lex->sql_command == SQLCOM_INSERT)
1184
lex->sql_command= SQLCOM_INSERT_SELECT;
1185
delete lex->statement;
1187
new(std::nothrow) statement::InsertSelect(YYSession);
1188
if (lex->statement == NULL)
1171
Lex->sql_command= SQLCOM_INSERT_SELECT;
1172
delete Lex->statement;
1173
Lex->statement= new statement::InsertSelect(YYSession);
1191
else if (lex->sql_command == SQLCOM_REPLACE)
1175
else if (Lex->sql_command == SQLCOM_REPLACE)
1193
lex->sql_command= SQLCOM_REPLACE_SELECT;
1194
delete lex->statement;
1196
new(std::nothrow) statement::ReplaceSelect(YYSession);
1197
if (lex->statement == NULL)
1177
Lex->sql_command= SQLCOM_REPLACE_SELECT;
1178
delete Lex->statement;
1179
Lex->statement= new statement::ReplaceSelect(YYSession);
1201
1182
The following work only with the local list, the global list
1202
1183
is created correctly in this case
1204
lex->current_select->table_list.save_and_clear(&lex->save_list);
1206
lex->current_select->parsing_place= SELECT_LIST;
1185
Lex->current_select->table_list.save_and_clear(&Lex->save_list);
1187
Lex->current_select->parsing_place= SELECT_LIST;
1208
1189
select_options select_item_list
1296
1272
custom_engine_option:
1297
1273
ENGINE_SYM equal ident_or_text
1299
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1301
statement->is_engine_set= true;
1303
((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->set_name($3.str);
1275
Lex->table()->mutable_engine()->set_name($3.str);
1305
1277
| COMMENT_SYM opt_equal TEXT_STRING_sys
1307
message::Table::TableOptions *tableopts;
1308
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1310
tableopts->set_comment($3.str);
1279
Lex->table()->mutable_options()->set_comment($3.str);
1312
1281
| AUTO_INC opt_equal ulonglong_num
1314
message::Table::TableOptions *tableopts;
1315
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1317
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1319
statement->create_info.auto_increment_value=$3;
1320
statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1321
tableopts->set_auto_increment_value($3);
1323
| ident_or_text equal ident_or_text
1325
drizzled::message::Engine::Option *opt= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->add_options();
1283
Lex->table()->mutable_options()->set_auto_increment_value($3);
1285
| ROW_FORMAT_SYM equal row_format_or_text
1287
drizzled::message::Engine::Option *opt= Lex->table()->mutable_engine()->add_options();
1289
opt->set_name("ROW_FORMAT");
1290
opt->set_state($3.str);
1292
| FILE_SYM equal TEXT_STRING_sys
1294
drizzled::message::Engine::Option *opt= Lex->table()->mutable_engine()->add_options();
1296
opt->set_name("FILE");
1297
opt->set_state($3.str);
1299
| ident_or_text equal engine_option_value
1301
drizzled::message::Engine::Option *opt= Lex->table()->mutable_engine()->add_options();
1327
1303
opt->set_name($1.str);
1328
1304
opt->set_state($3.str);
1401
1394
key_type opt_ident key_alg '(' key_list ')' key_options
1404
1396
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1405
1397
Key *key= new Key($1, $2, &statement->key_create_info, 0,
1407
1399
statement->alter_info.key_list.push_back(key);
1408
lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1400
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1410
1402
| opt_constraint constraint_key_type opt_ident key_alg
1411
1403
'(' key_list ')' key_options
1414
1405
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1415
1406
Key *key= new Key($2, $3.str ? $3 : $1, &statement->key_create_info, 0,
1417
1408
statement->alter_info.key_list.push_back(key);
1418
lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1409
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1420
1411
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1423
1413
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1424
Key *key= new Foreign_key($1.str ? $1 : $4, lex->col_list,
1414
Key *key= new Foreign_key($1.str ? $1 : $4, Lex->col_list,
1427
1417
statement->fk_delete_opt,
1428
1418
statement->fk_update_opt,
1429
1419
statement->fk_match_option);
1472
1461
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1473
lex->length=lex->dec=0;
1462
Lex->length= Lex->dec=0;
1475
1464
statement->default_value= statement->on_update_value= 0;
1476
1465
statement->comment= null_lex_str;
1478
1467
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1480
message::AlterTable &alter_proto=
1481
((statement::CreateTable *)Lex->statement)->alter_info.alter_proto;
1482
statement->current_proto_field= alter_proto.add_added_field();
1469
message::AlterTable &alter_proto= ((statement::CreateTable *)Lex->statement)->alter_info.alter_proto;
1470
Lex->setField(alter_proto.add_added_field());
1487
1474
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1489
if (statement->current_proto_field)
1490
statement->current_proto_field->set_name($1.str);
1478
Lex->field()->set_name($1.str);
1492
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1493
lex->length,lex->dec,lex->type,
1481
if (add_field_to_list(Lex->session, &$1, (enum enum_field_types) $3,
1482
Lex->length, Lex->dec, Lex->type,
1494
1483
statement->column_format,
1495
1484
statement->default_value, statement->on_update_value,
1496
1485
&statement->comment,
1497
statement->change, &lex->interval_list, lex->charset))
1486
statement->change, &Lex->interval_list, Lex->charset))
1498
1487
DRIZZLE_YYABORT;
1500
statement->current_proto_field= NULL;
1489
Lex->setField(NULL);
1504
type opt_attribute {}
1493
field_definition opt_attribute {}
1508
1497
int_type ignored_field_number_length opt_field_number_signed opt_zerofill
1511
1500
Lex->length=(char*) 0; /* use default length */
1512
statement::CreateTable *statement=
1513
(statement::CreateTable *)Lex->statement;
1517
1504
$1= DRIZZLE_TYPE_LONGLONG;
1520
if (statement->current_proto_field)
1522
1509
assert ($1 == DRIZZLE_TYPE_LONG or $1 == DRIZZLE_TYPE_LONGLONG);
1523
1510
// We update the type for unsigned types
1526
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1527
statement->current_proto_field->mutable_constraints()->set_is_unsigned(true);
1513
Lex->field()->set_type(message::Table::Field::BIGINT);
1514
Lex->field()->mutable_constraints()->set_is_unsigned(true);
1529
1516
if ($1 == DRIZZLE_TYPE_LONG)
1531
statement->current_proto_field->set_type(message::Table::Field::INTEGER);
1518
Lex->field()->set_type(message::Table::Field::INTEGER);
1533
1520
else if ($1 == DRIZZLE_TYPE_LONGLONG)
1535
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1522
Lex->field()->set_type(message::Table::Field::BIGINT);
1572
1553
Lex->length=(char*) "1";
1573
1554
$$=DRIZZLE_TYPE_VARCHAR;
1575
statement::CreateTable *statement=
1576
(statement::CreateTable *)Lex->statement;
1578
if (statement->current_proto_field)
1579
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1557
Lex->field()->set_type(message::Table::Field::VARCHAR);
1581
1559
| varchar '(' NUM ')'
1583
1561
Lex->length=$3.str;
1584
1562
$$= DRIZZLE_TYPE_VARCHAR;
1586
statement::CreateTable *statement=
1587
(statement::CreateTable *)Lex->statement;
1589
if (statement->current_proto_field)
1591
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1566
Lex->field()->set_type(message::Table::Field::VARCHAR);
1593
1568
message::Table::Field::StringFieldOptions *string_field_options;
1595
string_field_options= statement->current_proto_field->mutable_string_options();
1570
string_field_options= Lex->field()->mutable_string_options();
1597
1572
string_field_options->set_length(atoi($3.str));
1623
1595
$$=DRIZZLE_TYPE_DATE;
1625
statement::CreateTable *statement=
1626
(statement::CreateTable *)Lex->statement;
1628
if (statement->current_proto_field)
1629
statement->current_proto_field->set_type(message::Table::Field::DATE);
1598
Lex->field()->set_type(message::Table::Field::DATE);
1633
1602
$$=DRIZZLE_TYPE_TIME;
1635
statement::CreateTable *statement=
1636
(statement::CreateTable *)Lex->statement;
1638
if (statement->current_proto_field)
1639
statement->current_proto_field->set_type(message::Table::Field::TIME);
1605
Lex->field()->set_type(message::Table::Field::TIME);
1641
1607
| TIMESTAMP_SYM
1643
1609
$$=DRIZZLE_TYPE_TIMESTAMP;
1645
statement::CreateTable *statement=
1646
(statement::CreateTable *)Lex->statement;
1648
if (statement->current_proto_field)
1649
statement->current_proto_field->set_type(message::Table::Field::EPOCH);
1651
| LONG_SYM TIMESTAMP_SYM
1653
$$=DRIZZLE_TYPE_TIMESTAMP;
1655
statement::CreateTable *statement=
1656
(statement::CreateTable *)Lex->statement;
1658
if (statement->current_proto_field)
1660
statement->current_proto_field->set_type(message::Table::Field::EPOCH);
1661
statement->current_proto_field->mutable_time_options()->set_microseconds(true);
1612
Lex->field()->set_type(message::Table::Field::EPOCH);
1666
1616
$$=DRIZZLE_TYPE_DATETIME;
1668
statement::CreateTable *statement=
1669
(statement::CreateTable *)Lex->statement;
1671
if (statement->current_proto_field)
1672
statement->current_proto_field->set_type(message::Table::Field::DATETIME);
1619
Lex->field()->set_type(message::Table::Field::DATETIME);
1695
1639
$$=DRIZZLE_TYPE_BLOB;
1696
1640
Lex->length=(char*) 0; /* use default length */
1698
statement::CreateTable *statement=
1699
(statement::CreateTable *)Lex->statement;
1701
if (statement->current_proto_field)
1702
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1643
Lex->field()->set_type(message::Table::Field::BLOB);
1704
1645
| DECIMAL_SYM float_options
1706
1647
$$=DRIZZLE_TYPE_DECIMAL;
1708
statement::CreateTable *statement=
1709
(statement::CreateTable *)Lex->statement;
1711
if (statement->current_proto_field)
1712
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1650
Lex->field()->set_type(message::Table::Field::DECIMAL);
1714
1652
| NUMERIC_SYM float_options
1716
1654
$$=DRIZZLE_TYPE_DECIMAL;
1718
statement::CreateTable *statement=
1719
(statement::CreateTable *)Lex->statement;
1721
if (statement->current_proto_field)
1722
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1657
Lex->field()->set_type(message::Table::Field::DECIMAL);
1724
1659
| FIXED_SYM float_options
1726
1661
$$=DRIZZLE_TYPE_DECIMAL;
1728
statement::CreateTable *statement=
1729
(statement::CreateTable *)Lex->statement;
1731
if (statement->current_proto_field)
1732
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1664
Lex->field()->set_type(message::Table::Field::DECIMAL);
1735
1667
{Lex->interval_list.empty();}
1738
1670
$$=DRIZZLE_TYPE_ENUM;
1740
statement::CreateTable *statement=
1741
(statement::CreateTable *)Lex->statement;
1743
if (statement->current_proto_field)
1744
statement->current_proto_field->set_type(message::Table::Field::ENUM);
1673
Lex->field()->set_type(message::Table::Field::ENUM);
1748
1677
$$=DRIZZLE_TYPE_UUID;
1750
statement::CreateTable *statement=
1751
(statement::CreateTable *)Lex->statement;
1753
if (statement->current_proto_field)
1754
statement->current_proto_field->set_type(message::Table::Field::UUID);
1680
Lex->field()->set_type(message::Table::Field::UUID);
1758
$$=DRIZZLE_TYPE_BOOLEAN;
1760
statement::CreateTable *statement=
1761
(statement::CreateTable *)Lex->statement;
1763
if (statement->current_proto_field)
1764
statement->current_proto_field->set_type(message::Table::Field::BOOLEAN);
1768
$$=DRIZZLE_TYPE_BOOLEAN;
1770
statement::CreateTable *statement=
1771
(statement::CreateTable *)Lex->statement;
1773
if (statement->current_proto_field)
1774
statement->current_proto_field->set_type(message::Table::Field::BOOLEAN);
1684
$$=DRIZZLE_TYPE_BOOLEAN;
1687
Lex->field()->set_type(message::Table::Field::BOOLEAN);
1778
1691
$$=DRIZZLE_TYPE_LONGLONG;
1779
1692
Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
1781
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1782
if (statement->current_proto_field)
1784
1696
message::Table::Field::FieldConstraints *constraints;
1785
constraints= statement->current_proto_field->mutable_constraints();
1697
constraints= Lex->field()->mutable_constraints();
1786
1698
constraints->set_is_nullable(false);
1788
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1700
Lex->field()->set_type(message::Table::Field::BIGINT);
1915
1824
Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
1917
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1918
if (statement->current_proto_field)
1920
1828
message::Table::Field::FieldConstraints *constraints;
1922
constraints= statement->current_proto_field->mutable_constraints();
1830
constraints= Lex->field()->mutable_constraints();
1923
1831
constraints->set_is_nullable(false);
1926
1834
| SERIAL_SYM DEFAULT VALUE_SYM
1929
1836
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1931
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1838
Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1932
1839
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1934
if (statement->current_proto_field)
1936
1843
message::Table::Field::FieldConstraints *constraints;
1937
constraints= statement->current_proto_field->mutable_constraints();
1844
constraints= Lex->field()->mutable_constraints();
1938
1845
constraints->set_is_nullable(false);
1941
1848
| opt_primary KEY_SYM
1944
1850
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1946
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1852
Lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1947
1853
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1949
if (statement->current_proto_field)
1951
1857
message::Table::Field::FieldConstraints *constraints;
1952
constraints= statement->current_proto_field->mutable_constraints();
1858
constraints= Lex->field()->mutable_constraints();
1953
1859
constraints->set_is_nullable(false);
1959
1864
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1961
lex->type|= UNIQUE_FLAG;
1866
Lex->type|= UNIQUE_FLAG;
1962
1867
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1964
1869
| UNIQUE_SYM KEY_SYM
1967
1871
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1969
lex->type|= UNIQUE_KEY_FLAG;
1873
Lex->type|= UNIQUE_KEY_FLAG;
1970
1874
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1972
1876
| COMMENT_SYM TEXT_STRING_sys
2217
2120
ALTER_SYM build_method opt_ignore TABLE_SYM table_ident
2219
Session *session= YYSession;
2220
LEX *lex= session->lex;
2222
lex->name.length= 0;
2223
lex->sql_command= SQLCOM_ALTER_TABLE;
2224
statement::AlterTable *statement= new(std::nothrow) statement::AlterTable(YYSession);
2225
lex->statement= statement;
2226
if (lex->statement == NULL)
2228
lex->duplicates= DUP_ERROR;
2229
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2230
TL_OPTION_UPDATING))
2232
lex->col_list.empty();
2233
lex->select_lex.init_order();
2234
lex->select_lex.db= const_cast<char *>(((TableList*) lex->select_lex.table_list.first)->getSchemaName());
2122
Lex->sql_command= SQLCOM_ALTER_TABLE;
2123
statement::AlterTable *statement= new statement::AlterTable(YYSession);
2124
Lex->statement= statement;
2125
Lex->duplicates= DUP_ERROR;
2126
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
2127
TL_OPTION_UPDATING))
2130
Lex->col_list.empty();
2131
Lex->select_lex.init_order();
2132
Lex->select_lex.db= const_cast<char *>(((TableList*) Lex->select_lex.table_list.first)->getSchemaName());
2235
2133
statement->alter_info.build_method= $2;
2239
| ALTER_SYM DATABASE ident_or_empty
2137
| ALTER_SYM DATABASE schema_name
2242
lex->sql_command=SQLCOM_ALTER_DB;
2243
lex->statement= new(std::nothrow) statement::AlterSchema(YYSession);
2244
if (lex->statement == NULL)
2139
Lex->sql_command=SQLCOM_ALTER_DB;
2140
Lex->statement= new statement::AlterSchema(YYSession);
2247
2142
default_collation_schema
2251
if (lex->name.str == NULL &&
2252
lex->copy_db_to(&lex->name.str, &lex->name.length))
2145
if (Lex->name.str == NULL && Lex->copy_db_to(&Lex->name.str, &Lex->name.length))
2253
2146
DRIZZLE_YYABORT;
2258
/* empty */ { $$.str= 0; $$.length= 0; }
2262
2150
alter_commands:
2264
2152
| DISCARD TABLESPACE
2328
2216
field_spec opt_place
2329
2217
| MODIFY_SYM opt_column field_ident
2332
2219
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2333
lex->length=lex->dec=0; lex->type=0;
2220
Lex->length= Lex->dec=0;
2334
2222
statement->default_value= statement->on_update_value= 0;
2335
2223
statement->comment= null_lex_str;
2337
2225
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2338
2226
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2340
statement->current_proto_field= NULL;
2228
Lex->setField(NULL);
2345
2232
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2347
if (add_field_to_list(lex->session,&$3,
2234
if (add_field_to_list(Lex->session,&$3,
2348
2235
(enum enum_field_types) $5,
2349
lex->length, lex->dec, lex->type,
2236
Lex->length, Lex->dec, Lex->type,
2350
2237
statement->column_format,
2351
2238
statement->default_value,
2352
2239
statement->on_update_value,
2353
2240
&statement->comment,
2354
$3.str, &lex->interval_list, lex->charset))
2241
$3.str, &Lex->interval_list, Lex->charset))
2355
2242
DRIZZLE_YYABORT;
2567
2441
table_to_table:
2568
2442
table_ident TO_SYM table_ident
2571
Select_Lex *sl= lex->current_select;
2572
if (!sl->add_table_to_list(lex->session, $1,NULL,TL_OPTION_UPDATING,
2444
Select_Lex *sl= Lex->current_select;
2445
if (!sl->add_table_to_list(Lex->session, $1,NULL,TL_OPTION_UPDATING,
2574
!sl->add_table_to_list(lex->session, $3,NULL,TL_OPTION_UPDATING,
2447
!sl->add_table_to_list(Lex->session, $3,NULL,TL_OPTION_UPDATING,
2576
2449
DRIZZLE_YYABORT;
2734
Session *session= YYSession;
2735
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
2600
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
2737
2602
NULL, NULL, "*")))
2738
2603
DRIZZLE_YYABORT;
2739
(session->lex->current_select->with_wild)++;
2604
(YYSession->lex->current_select->with_wild)++;
2744
2609
remember_name table_wild remember_end
2746
Session *session= YYSession;
2748
if (session->add_item_to_list($2))
2611
if (YYSession->add_item_to_list($2))
2749
2612
DRIZZLE_YYABORT;
2751
2614
| remember_name expr remember_end select_alias
2753
Session *session= YYSession;
2754
2616
assert($1 < $3);
2756
if (session->add_item_to_list($2))
2618
if (YYSession->add_item_to_list($2))
2757
2619
DRIZZLE_YYABORT;
2760
2623
$2->is_autogenerated_name= false;
3155
3013
{ $$= new (YYSession->mem_root) Item_func_insert(*YYSession, $3, $5, $7, $9); }
3156
3014
| INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM
3158
Session *session= YYSession;
3159
List<Item> *list= new (session->mem_root) List<Item>;
3016
List<Item> *list= new (YYSession->mem_root) List<Item>;
3160
3017
list->push_front($5);
3161
3018
list->push_front($3);
3162
Item_row *item= new (session->mem_root) Item_row(*list);
3163
$$= new (session->mem_root) Item_func_interval(item);
3019
Item_row *item= new (YYSession->mem_root) Item_row(*list);
3020
$$= new (YYSession->mem_root) Item_func_interval(item);
3165
3022
| INTERVAL_SYM '(' expr ',' expr ',' expr_list ')' %prec INTERVAL_SYM
3167
Session *session= YYSession;
3168
3024
$7->push_front($5);
3169
3025
$7->push_front($3);
3170
Item_row *item= new (session->mem_root) Item_row(*$7);
3171
$$= new (session->mem_root) Item_func_interval(item);
3026
Item_row *item= new (YYSession->mem_root) Item_row(*$7);
3027
$$= new (YYSession->mem_root) Item_func_interval(item);
3173
3029
| LEFT '(' expr ',' expr ')'
3174
3030
{ $$= new (YYSession->mem_root) Item_func_left($3,$5); }
3394
3249
{ $$= new (YYSession->mem_root) Item_func_repeat(*YYSession, $3, $5); }
3395
3250
| REPLACE '(' expr ',' expr ',' expr ')'
3396
3251
{ $$= new (YYSession->mem_root) Item_func_replace(*YYSession, $3, $5, $7); }
3397
| REVERSE_SYM '(' expr ')'
3399
std::string reverse_str("reverse");
3400
List<Item> *args= new (YYSession->mem_root) List<Item>;
3401
args->push_back($3);
3402
if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
3407
3252
| TRUNCATE_SYM '(' expr ',' expr ')'
3408
3253
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
3409
3254
| WAIT_SYM '(' expr ')'
3998
3836
/* Handle case of derived table, alias may be NULL if there
3999
3837
are no outer parentheses, add_table_to_list() will throw
4000
3838
error in this case */
4002
Select_Lex *sel= lex->current_select;
3839
Select_Lex *sel= Lex->current_select;
4003
3840
Select_Lex_Unit *unit= sel->master_unit();
4004
lex->current_select= sel= unit->outer_select();
4005
if (!($$= sel->add_table_to_list(lex->session,
3841
Lex->current_select= sel= unit->outer_select();
3842
if (!($$= sel->add_table_to_list(Lex->session,
4006
3843
new Table_ident(unit), $5, 0,
4009
3846
DRIZZLE_YYABORT;
4010
3847
sel->add_joined_table($$);
4013
3850
else if (($3->select_lex && $3->select_lex->master_unit()->is_union()) || $5)
4583
4409
into_destination:
4584
4410
OUTFILE TEXT_STRING_filesystem
4587
lex->setCacheable(false);
4588
if (!(lex->exchange= new file_exchange($2.str, 0)) ||
4589
!(lex->result= new select_export(lex->exchange)))
4412
Lex->setCacheable(false);
4413
if (!(Lex->exchange= new file_exchange($2.str, 0)) ||
4414
!(Lex->result= new select_export(Lex->exchange)))
4590
4415
DRIZZLE_YYABORT;
4592
4417
opt_field_term opt_line_term
4593
4418
| DUMPFILE TEXT_STRING_filesystem
4420
if (not Lex->describe)
4598
lex->setCacheable(false);
4599
if (!(lex->exchange= new file_exchange($2.str,1)))
4422
Lex->setCacheable(false);
4423
if (not (Lex->exchange= new file_exchange($2.str,1)))
4600
4424
DRIZZLE_YYABORT;
4601
if (!(lex->result= new select_dump(lex->exchange)))
4425
if (not (Lex->result= new select_dump(Lex->exchange)))
4602
4426
DRIZZLE_YYABORT;
4614
4438
DROP opt_temporary table_or_tables if_exists table_list
4617
lex->sql_command = SQLCOM_DROP_TABLE;
4618
statement::DropTable *statement= new(std::nothrow) statement::DropTable(YYSession);
4619
lex->statement= statement;
4620
if (lex->statement == NULL)
4440
Lex->sql_command = SQLCOM_DROP_TABLE;
4441
statement::DropTable *statement= new statement::DropTable(YYSession);
4442
Lex->statement= statement;
4622
4443
statement->drop_temporary= $2;
4623
4444
statement->drop_if_exists= $4;
4625
4446
| DROP build_method INDEX_SYM ident ON table_ident {}
4628
lex->sql_command= SQLCOM_DROP_INDEX;
4629
statement::DropIndex *statement= new(std::nothrow) statement::DropIndex(YYSession);
4630
lex->statement= statement;
4631
if (lex->statement == NULL)
4448
Lex->sql_command= SQLCOM_DROP_INDEX;
4449
statement::DropIndex *statement= new statement::DropIndex(YYSession);
4450
Lex->statement= statement;
4633
4451
statement->alter_info.flags.set(ALTER_DROP_INDEX);
4634
4452
statement->alter_info.build_method= $2;
4635
4453
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY, $4.str));
4636
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4637
TL_OPTION_UPDATING))
4454
if (not Lex->current_select->add_table_to_list(Lex->session, $6, NULL,
4455
TL_OPTION_UPDATING))
4638
4456
DRIZZLE_YYABORT;
4640
| DROP DATABASE if_exists ident
4458
| DROP DATABASE if_exists schema_name
4643
lex->sql_command= SQLCOM_DROP_DB;
4644
statement::DropSchema *statement= new(std::nothrow) statement::DropSchema(YYSession);
4645
lex->statement= statement;
4646
if (lex->statement == NULL)
4460
Lex->sql_command= SQLCOM_DROP_DB;
4461
statement::DropSchema *statement= new statement::DropSchema(YYSession);
4462
Lex->statement= statement;
4648
4463
statement->drop_if_exists=$3;
4653
4470
| table_list ',' table_name
4665
/* empty */ { $$= 0; }
4666
| IF EXISTS { $$= 1; }
4482
/* empty */ { $$= false; }
4483
| IF EXISTS { $$= true; }
4670
/* empty */ { $$= 0; }
4671
| TEMPORARY_SYM { $$= 1; }
4487
/* empty */ { $$= false; }
4488
| TEMPORARY_SYM { $$= true; }
4675
4492
Execute a string as dynamic SQL.
4679
4496
EXECUTE_SYM execute_var_or_string opt_status opt_concurrent opt_wait
4682
statement::Execute *statement= new(std::nothrow) statement::Execute(YYSession, $2, $3, $4, $5);
4683
lex->statement= statement;
4684
if (lex->statement == NULL)
4498
Lex->statement= new statement::Execute(YYSession, $2, $3, $4, $5);
4689
4502
execute_var_or_string:
4507
| '@' user_variable_ident
4696
4509
$$.set($2, true);
4700
/* empty */ { $$= 0; }
4701
| WITH NO_SYM RETURN_SYM { $$= 1; }
4513
/* empty */ { $$= false; }
4514
| WITH NO_SYM RETURN_SYM { $$= true; }
4704
4517
opt_concurrent:
4705
/* empty */ { $$= 0; }
4706
| CONCURRENT { $$= 1; }
4518
/* empty */ { $$= false; }
4519
| CONCURRENT { $$= true; }
4710
/* empty */ { $$= 0; }
4711
| WAIT_SYM { $$= 1; }
4523
/* empty */ { $$= false; }
4524
| WAIT_SYM { $$= true; }
4880
4687
UPDATE_SYM opt_ignore table_ident
4884
lex->sql_command= SQLCOM_UPDATE;
4885
lex->statement= new(std::nothrow) statement::Update(YYSession);
4886
if (lex->statement == NULL)
4888
lex->lock_option= TL_UNLOCK; /* Will be set later */
4889
lex->duplicates= DUP_ERROR;
4890
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4690
Lex->sql_command= SQLCOM_UPDATE;
4691
Lex->statement= new statement::Update(YYSession);
4692
Lex->lock_option= TL_UNLOCK; /* Will be set later */
4693
Lex->duplicates= DUP_ERROR;
4694
if (not Lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4891
4695
DRIZZLE_YYABORT;
4893
4697
SET_SYM update_list
4896
if (lex->select_lex.get_table_list()->derived)
4699
if (Lex->select_lex.get_table_list()->derived)
4898
4701
/* it is single table update and it is update of derived table */
4899
4702
my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
4900
lex->select_lex.get_table_list()->alias, "UPDATE");
4703
Lex->select_lex.get_table_list()->alias, "UPDATE");
4901
4704
DRIZZLE_YYABORT;
5033
4822
if (Lex->current_select->where)
5035
if (prepare_new_schema_table(session, lex, "SCHEMAS"))
4824
if (prepare_new_schema_table(YYSession, Lex, "SCHEMAS"))
5036
4825
DRIZZLE_YYABORT;
5040
if (prepare_new_schema_table(session, lex, "SHOW_SCHEMAS"))
4829
if (prepare_new_schema_table(YYSession, Lex, "SHOW_SCHEMAS"))
5041
4830
DRIZZLE_YYABORT;
5044
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
4833
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
5045
4834
my_field->is_autogenerated_name= false;
5046
4835
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
5048
if (session->add_item_to_list(my_field))
4837
if (YYSession->add_item_to_list(my_field))
5049
4838
DRIZZLE_YYABORT;
5051
if (session->add_order_to_list(my_field, true))
4840
if (YYSession->add_order_to_list(my_field, true))
5052
4841
DRIZZLE_YYABORT;
5054
4843
/* SHOW TABLES */
5055
4844
| TABLES opt_db show_wild
5058
Session *session= YYSession;
5060
lex->sql_command= SQLCOM_SELECT;
5062
statement::Show *select=
5063
new(std::nothrow) statement::Show(YYSession);
5065
lex->statement= select;
5067
if (lex->statement == NULL)
4846
Lex->sql_command= SQLCOM_SELECT;
4848
drizzled::statement::Show *select= new statement::Show(YYSession);
4849
Lex->statement= select;
5071
4851
std::string column_name= "Tables_in_";
5073
util::string::const_shared_ptr schema(session->schema());
4853
util::string::const_shared_ptr schema(YYSession->schema());
5076
4856
SchemaIdentifier identifier($2);
5077
4857
column_name.append($2);
5078
lex->select_lex.db= $2;
4858
Lex->select_lex.db= $2;
5079
4859
if (not plugin::StorageEngine::doesSchemaExist(identifier))
5081
4861
my_error(ER_BAD_DB_ERROR, MYF(0), $2);
5101
4881
column_name.append(")");
5104
if (prepare_new_schema_table(YYSession, lex, "SHOW_TABLES"))
4884
if (prepare_new_schema_table(YYSession, Lex, "SHOW_TABLES"))
5105
4885
DRIZZLE_YYABORT;
5107
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
4887
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5108
4888
my_field->is_autogenerated_name= false;
5109
4889
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
5111
if (session->add_item_to_list(my_field))
4891
if (YYSession->add_item_to_list(my_field))
5112
4892
DRIZZLE_YYABORT;
5114
if (session->add_order_to_list(my_field, true))
4894
if (YYSession->add_order_to_list(my_field, true))
5115
4895
DRIZZLE_YYABORT;
5117
4897
/* SHOW TEMPORARY TABLES */
5118
4898
| TEMPORARY_SYM TABLES show_wild
5121
Session *session= YYSession;
5123
lex->sql_command= SQLCOM_SELECT;
5125
statement::Show *select=
5126
new(std::nothrow) statement::Show(YYSession);
5128
lex->statement= select;
5130
if (lex->statement == NULL)
5134
if (prepare_new_schema_table(YYSession, lex, "SHOW_TEMPORARY_TABLES"))
5137
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4900
Lex->sql_command= SQLCOM_SELECT;
4902
Lex->statement= new statement::Show(YYSession);
4905
if (prepare_new_schema_table(YYSession, Lex, "SHOW_TEMPORARY_TABLES"))
4908
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5139
4910
NULL, NULL, "*")))
5140
4911
DRIZZLE_YYABORT;
5141
(session->lex->current_select->with_wild)++;
4912
(YYSession->lex->current_select->with_wild)++;
5144
4915
/* SHOW TABLE STATUS */
5145
4916
| TABLE_SYM STATUS_SYM opt_db show_wild
5148
lex->sql_command= SQLCOM_SELECT;
5149
statement::Show *select=
5150
new(std::nothrow) statement::Show(YYSession);
5152
lex->statement= select;
5154
if (lex->statement == NULL)
5157
Session *session= YYSession;
4918
Lex->sql_command= SQLCOM_SELECT;
4919
drizzled::statement::Show *select= new statement::Show(YYSession);
4920
Lex->statement= select;
5159
4922
std::string column_name= "Tables_in_";
5161
util::string::const_shared_ptr schema(session->schema());
4924
util::string::const_shared_ptr schema(YYSession->schema());
5164
lex->select_lex.db= $3;
4927
Lex->select_lex.db= $3;
5166
4929
SchemaIdentifier identifier($3);
5167
4930
if (not plugin::StorageEngine::doesSchemaExist(identifier))
5181
4944
DRIZZLE_YYABORT;
5184
if (prepare_new_schema_table(session, lex, "SHOW_TABLE_STATUS"))
4947
if (prepare_new_schema_table(YYSession, Lex, "SHOW_TABLE_STATUS"))
5185
4948
DRIZZLE_YYABORT;
5187
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4950
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5189
4952
NULL, NULL, "*")))
5190
4953
DRIZZLE_YYABORT;
5191
(session->lex->current_select->with_wild)++;
4954
(YYSession->lex->current_select->with_wild)++;
5193
4956
/* SHOW COLUMNS FROM table_name */
5194
4957
| COLUMNS from_or_in table_ident opt_db show_wild
5197
Session *session= YYSession;
5198
statement::Show *select;
5200
lex->sql_command= SQLCOM_SELECT;
5202
select= new(std::nothrow) statement::Show(session);
5204
lex->statement= select;
5206
if (lex->statement == NULL)
5209
util::string::const_shared_ptr schema(session->schema());
4959
Lex->sql_command= SQLCOM_SELECT;
4961
drizzled::statement::Show *select= new statement::Show(YYSession);
4962
Lex->statement= select;
4964
util::string::const_shared_ptr schema(YYSession->schema());
5212
4967
select->setShowPredicate($4, $3->table.str);
5238
if (prepare_new_schema_table(session, lex, "SHOW_COLUMNS"))
4993
if (prepare_new_schema_table(YYSession, Lex, "SHOW_COLUMNS"))
5239
4994
DRIZZLE_YYABORT;
5241
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4996
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5243
4998
NULL, NULL, "*")))
5244
4999
DRIZZLE_YYABORT;
5245
(session->lex->current_select->with_wild)++;
5000
(YYSession->lex->current_select->with_wild)++;
5248
5003
/* SHOW INDEXES from table */
5249
5004
| keys_or_index from_or_in table_ident opt_db where_clause
5252
Session *session= YYSession;
5253
statement::Show *select;
5255
lex->sql_command= SQLCOM_SELECT;
5257
select= new(std::nothrow) statement::Show(session);
5259
lex->statement= select;
5261
if (lex->statement == NULL)
5264
util::string::const_shared_ptr schema(session->schema());
5006
Lex->sql_command= SQLCOM_SELECT;
5007
drizzled::statement::Show *select= new statement::Show(YYSession);
5008
Lex->statement= select;
5010
util::string::const_shared_ptr schema(YYSession->schema());
5267
5013
select->setShowPredicate($4, $3->table.str);
5293
if (prepare_new_schema_table(session, lex, "SHOW_INDEXES"))
5039
if (prepare_new_schema_table(YYSession, Lex, "SHOW_INDEXES"))
5294
5040
DRIZZLE_YYABORT;
5296
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
5042
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5298
5044
NULL, NULL, "*")))
5299
5045
DRIZZLE_YYABORT;
5300
(session->lex->current_select->with_wild)++;
5046
(YYSession->lex->current_select->with_wild)++;
5302
5048
| COUNT_SYM '(' '*' ')' WARNINGS
5304
5050
(void) create_select_for_variable("warning_count");
5306
lex->statement= new(std::nothrow) statement::Show(YYSession);
5307
if (lex->statement == NULL)
5051
Lex->statement= new statement::Show(YYSession);
5310
5053
| COUNT_SYM '(' '*' ')' ERRORS
5312
5055
(void) create_select_for_variable("error_count");
5314
lex->statement= new(std::nothrow) statement::Show(YYSession);
5315
if (lex->statement == NULL)
5056
Lex->statement= new statement::Show(YYSession);
5318
5058
| WARNINGS opt_limit_clause_init
5320
5060
Lex->sql_command = SQLCOM_SHOW_WARNS;
5321
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
5322
if (Lex->statement == NULL)
5061
Lex->statement= new statement::ShowWarnings(YYSession);
5325
5063
| ERRORS opt_limit_clause_init
5327
5065
Lex->sql_command = SQLCOM_SHOW_ERRORS;
5328
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
5329
if (Lex->statement == NULL)
5066
Lex->statement= new statement::ShowErrors(YYSession);
5332
5068
| opt_var_type STATUS_SYM show_wild
5335
lex->sql_command= SQLCOM_SELECT;
5337
new(std::nothrow) statement::Show(YYSession);
5338
if (lex->statement == NULL)
5341
Session *session= YYSession;
5070
Lex->sql_command= SQLCOM_SELECT;
5071
Lex->statement= new statement::Show(YYSession);
5343
5073
if ($1 == OPT_GLOBAL)
5345
if (prepare_new_schema_table(session, lex, "GLOBAL_STATUS"))
5075
if (prepare_new_schema_table(YYSession, Lex, "GLOBAL_STATUS"))
5346
5076
DRIZZLE_YYABORT;
5350
if (prepare_new_schema_table(session, lex, "SESSION_STATUS"))
5080
if (prepare_new_schema_table(YYSession, Lex, "SESSION_STATUS"))
5351
5081
DRIZZLE_YYABORT;
5354
5084
std::string key("Variable_name");
5355
5085
std::string value("Value");
5357
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5087
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5358
5088
my_field->is_autogenerated_name= false;
5359
5089
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5361
if (session->add_item_to_list(my_field))
5091
if (YYSession->add_item_to_list(my_field))
5362
5092
DRIZZLE_YYABORT;
5364
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5094
my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5365
5095
my_field->is_autogenerated_name= false;
5366
5096
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5368
if (session->add_item_to_list(my_field))
5098
if (YYSession->add_item_to_list(my_field))
5369
5099
DRIZZLE_YYABORT;
5371
5101
| CREATE TABLE_SYM table_ident
5374
lex->sql_command= SQLCOM_SELECT;
5375
statement::Show *select=
5376
new(std::nothrow) statement::Show(YYSession);
5378
lex->statement= select;
5380
if (lex->statement == NULL)
5383
Session *session= YYSession;
5385
if (prepare_new_schema_table(session, lex, "TABLE_SQL_DEFINITION"))
5388
util::string::const_shared_ptr schema(session->schema());
5103
Lex->sql_command= SQLCOM_SELECT;
5104
statement::Show *select= new statement::Show(YYSession);
5105
Lex->statement= select;
5107
if (Lex->statement == NULL)
5110
if (prepare_new_schema_table(YYSession, Lex, "TABLE_SQL_DEFINITION"))
5113
util::string::const_shared_ptr schema(YYSession->schema());
5389
5114
if ($3->db.str)
5391
5116
select->setShowPredicate($3->db.str, $3->table.str);
5403
5128
std::string key("Table");
5404
5129
std::string value("Create Table");
5406
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5131
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5407
5132
my_field->is_autogenerated_name= false;
5408
5133
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5410
if (session->add_item_to_list(my_field))
5135
if (YYSession->add_item_to_list(my_field))
5411
5136
DRIZZLE_YYABORT;
5413
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
5138
my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
5414
5139
my_field->is_autogenerated_name= false;
5415
5140
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5417
if (session->add_item_to_list(my_field))
5142
if (YYSession->add_item_to_list(my_field))
5418
5143
DRIZZLE_YYABORT;
5420
5145
| PROCESSLIST_SYM
5424
lex->sql_command= SQLCOM_SELECT;
5426
new(std::nothrow) statement::Show(YYSession);
5427
if (lex->statement == NULL)
5430
Session *session= YYSession;
5432
if (prepare_new_schema_table(session, lex, "PROCESSLIST"))
5435
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
5148
Lex->sql_command= SQLCOM_SELECT;
5149
Lex->statement= new statement::Show(YYSession);
5151
if (prepare_new_schema_table(YYSession, Lex, "PROCESSLIST"))
5154
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5437
5156
NULL, NULL, "*")))
5438
5157
DRIZZLE_YYABORT;
5439
(session->lex->current_select->with_wild)++;
5158
(YYSession->lex->current_select->with_wild)++;
5442
5161
| opt_var_type VARIABLES show_wild
5445
lex->sql_command= SQLCOM_SELECT;
5447
new(std::nothrow) statement::Show(YYSession);
5448
if (lex->statement == NULL)
5451
Session *session= YYSession;
5163
Lex->sql_command= SQLCOM_SELECT;
5164
Lex->statement= new statement::Show(YYSession);
5453
5166
if ($1 == OPT_GLOBAL)
5455
if (prepare_new_schema_table(session, lex, "GLOBAL_VARIABLES"))
5168
if (prepare_new_schema_table(YYSession, Lex, "GLOBAL_VARIABLES"))
5456
5169
DRIZZLE_YYABORT;
5460
if (prepare_new_schema_table(session, lex, "SESSION_VARIABLES"))
5173
if (prepare_new_schema_table(YYSession, Lex, "SESSION_VARIABLES"))
5461
5174
DRIZZLE_YYABORT;
5464
5177
std::string key("Variable_name");
5465
5178
std::string value("Value");
5467
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5180
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5468
5181
my_field->is_autogenerated_name= false;
5469
5182
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5471
if (session->add_item_to_list(my_field))
5184
if (YYSession->add_item_to_list(my_field))
5472
5185
DRIZZLE_YYABORT;
5474
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5187
my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5475
5188
my_field->is_autogenerated_name= false;
5476
5189
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5478
if (session->add_item_to_list(my_field))
5191
if (YYSession->add_item_to_list(my_field))
5479
5192
DRIZZLE_YYABORT;
5481
5194
| CREATE DATABASE opt_if_not_exists ident
5484
lex->sql_command= SQLCOM_SELECT;
5485
statement::Show *select=
5486
new(std::nothrow) statement::Show(YYSession);
5488
lex->statement= select;
5490
if (lex->statement == NULL)
5493
Session *session= YYSession;
5495
if (prepare_new_schema_table(session, lex, "SCHEMA_SQL_DEFINITION"))
5498
util::string::const_shared_ptr schema(session->schema());
5196
Lex->sql_command= SQLCOM_SELECT;
5197
drizzled::statement::Show *select= new statement::Show(YYSession);
5198
Lex->statement= select;
5200
if (prepare_new_schema_table(YYSession, Lex, "SCHEMA_SQL_DEFINITION"))
5203
util::string::const_shared_ptr schema(YYSession->schema());
5501
5206
select->setShowPredicate($4.str);
5513
5218
std::string key("Database");
5514
5219
std::string value("Create Database");
5516
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
5221
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
5517
5222
my_field->is_autogenerated_name= false;
5518
5223
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5520
if (session->add_item_to_list(my_field))
5225
if (YYSession->add_item_to_list(my_field))
5521
5226
DRIZZLE_YYABORT;
5523
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_SQL_DEFINITION");
5228
my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "SCHEMA_SQL_DEFINITION");
5524
5229
my_field->is_autogenerated_name= false;
5525
5230
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5527
if (session->add_item_to_list(my_field))
5232
if (YYSession->add_item_to_list(my_field))
5528
5233
DRIZZLE_YYABORT;
5560
5265
describe_command table_ident
5562
Session *session= YYSession;
5563
statement::Show *select;
5565
lex->lock_option= TL_READ;
5567
lex->current_select->parsing_place= SELECT_LIST;
5568
lex->sql_command= SQLCOM_SELECT;
5569
select= new(std::nothrow) statement::Show(session);
5570
lex->statement= select;
5571
if (lex->statement == NULL)
5573
lex->select_lex.db= 0;
5267
Lex->lock_option= TL_READ;
5269
Lex->current_select->parsing_place= SELECT_LIST;
5270
Lex->sql_command= SQLCOM_SELECT;
5271
drizzled::statement::Show *select= new statement::Show(YYSession);
5272
Lex->statement= select;
5273
Lex->select_lex.db= 0;
5575
util::string::const_shared_ptr schema(session->schema());
5275
util::string::const_shared_ptr schema(YYSession->schema());
5576
5276
if ($2->db.str)
5578
5278
select->setShowPredicate($2->db.str, $2->table.str);
5702
5398
KILL_SYM kill_option expr
5708
5402
Lex->type= ONLY_KILL_QUERY;
5715
lex->value_list.empty();
5716
lex->value_list.push_front($3);
5717
lex->sql_command= SQLCOM_KILL;
5718
lex->statement= new(std::nothrow) statement::Kill(YYSession);
5719
if (lex->statement == NULL)
5405
Lex->value_list.empty();
5406
Lex->value_list.push_front($3);
5407
Lex->sql_command= SQLCOM_KILL;
5408
Lex->statement= new statement::Kill(YYSession);
5725
/* empty */ { $$= 0; }
5726
| CONNECTION_SYM { $$= 0; }
5727
| QUERY_SYM { $$= 1; }
5413
/* empty */ { $$= false; }
5414
| CONNECTION_SYM { $$= false; }
5415
| QUERY_SYM { $$= true; }
5730
5418
/* change database */
5736
lex->sql_command=SQLCOM_CHANGE_DB;
5737
lex->statement= new(std::nothrow) statement::ChangeSchema(YYSession);
5738
if (lex->statement == NULL)
5740
lex->select_lex.db= $2.str;
5423
Lex->sql_command=SQLCOM_CHANGE_DB;
5424
Lex->statement= new statement::ChangeSchema(YYSession);
5425
Lex->select_lex.db= $2.str;
5749
Session *session= YYSession;
5750
LEX *lex= session->lex;
5752
lex->sql_command= SQLCOM_LOAD;
5753
statement::Load *statement= new(std::nothrow) statement::Load(YYSession);
5754
lex->statement= statement;
5755
if (lex->statement == NULL)
5758
Lex_input_stream *lip= session->m_lip;
5434
Lex->sql_command= SQLCOM_LOAD;
5435
statement::Load *statement= new statement::Load(YYSession);
5436
Lex->statement= statement;
5438
Lex_input_stream *lip= YYSession->m_lip;
5759
5439
statement->fname_start= lip->get_ptr();
5761
5441
load_data_lock INFILE TEXT_STRING_filesystem
5764
lex->lock_option= $4;
5765
lex->duplicates= DUP_ERROR;
5767
if (!(lex->exchange= new file_exchange($6.str, 0, $2)))
5443
Lex->lock_option= $4;
5444
Lex->duplicates= DUP_ERROR;
5446
if (not (Lex->exchange= new file_exchange($6.str, 0, $2)))
5768
5447
DRIZZLE_YYABORT;
5770
5449
opt_duplicate INTO
5772
Session *session= YYSession;
5773
Lex_input_stream *lip= session->m_lip;
5451
Lex_input_stream *lip= YYSession->m_lip;
5774
5452
((statement::Load *)Lex->statement)->fname_end= lip->get_ptr();
5776
5454
TABLE_SYM table_ident
5779
5456
if (!Lex->current_select->add_table_to_list(YYSession,
5780
5457
$12, NULL, TL_OPTION_UPDATING,
5782
5459
DRIZZLE_YYABORT;
5783
lex->field_list.empty();
5784
lex->update_list.empty();
5785
lex->value_list.empty();
5460
Lex->field_list.empty();
5461
Lex->update_list.empty();
5462
Lex->value_list.empty();
5787
5464
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
5788
5465
opt_load_data_set_spec
6458
6133
sys_option_value:
6459
6134
option_type internal_variable_name equal set_expr_or_default
6464
6137
{ /* System variable */
6466
lex->option_type= $1;
6467
lex->var_list.push_back(SetVarPtr(new set_var(lex->option_type, $2.var,
6468
&$2.base_name, $4)));
6140
Lex->option_type= $1;
6142
Lex->var_list.push_back(SetVarPtr(new set_var(Lex->option_type, $2.var, &$2.base_name, $4)));
6471
6145
| option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
6474
lex->option_type= $1;
6475
lex->var_list.push_back(SetVarPtr(new set_var(lex->option_type,
6476
find_sys_var("tx_isolation"),
6478
new Item_int((int32_t)
6147
Lex->option_type= $1;
6148
Lex->var_list.push_back(SetVarPtr(new set_var(Lex->option_type,
6149
find_sys_var("tx_isolation"),
6151
new Item_int((int32_t)
6484
'@' ident_or_text equal expr
6157
'@' user_variable_ident equal expr
6486
Lex->var_list.push_back(SetVarPtr(new set_var_user(new
6487
Item_func_set_user_var($2,$4))));
6159
Lex->var_list.push_back(SetVarPtr(new set_var_user(new Item_func_set_user_var($2,$4))));
6489
6161
| '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
6492
lex->var_list.push_back(SetVarPtr(new set_var($3, $4.var,
6493
&$4.base_name, $6)));
6163
Lex->var_list.push_back(SetVarPtr(new set_var($3, $4.var, &$4.base_name, $6)));
6167
user_variable_ident:
6168
internal_variable_ident { $$=$1;}
6169
| TEXT_STRING_sys { $$=$1;}
6170
| LEX_HOSTNAME { $$=$1;}
6173
internal_variable_ident:
6174
keyword_exception_for_variable
6176
$$.str= YYSession->strmake($1.str, $1.length);
6177
$$.length= $1.length;
6179
| IDENT_sys { $$=$1; }
6497
6182
internal_variable_name:
6183
internal_variable_ident
6500
6185
/* We have to lookup here since local vars can shadow sysvars */
6502
6187
/* Not an SP local variable */
6503
sys_var *tmp=find_sys_var($1.str);
6188
sys_var *tmp= find_sys_var(std::string($1.str, $1.length));
6505
6190
DRIZZLE_YYABORT;
6596
6272
ROLLBACK_SYM opt_work opt_chain opt_release
6599
lex->sql_command= SQLCOM_ROLLBACK;
6600
statement::Rollback *statement= new(std::nothrow) statement::Rollback(YYSession);
6601
lex->statement= statement;
6602
if (lex->statement == NULL)
6274
Lex->sql_command= SQLCOM_ROLLBACK;
6275
statement::Rollback *statement= new statement::Rollback(YYSession);
6276
Lex->statement= statement;
6604
6277
statement->tx_chain= $3;
6605
6278
statement->tx_release= $4;
6607
| ROLLBACK_SYM opt_work
6608
TO_SYM opt_savepoint ident
6280
| ROLLBACK_SYM opt_work TO_SYM opt_savepoint savepoint_ident
6611
lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
6612
lex->statement= new(std::nothrow) statement::RollbackToSavepoint(YYSession);
6613
if (lex->statement == NULL)
6282
Lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
6283
Lex->statement= new statement::RollbackToSavepoint(YYSession);
6289
SAVEPOINT_SYM savepoint_ident
6623
lex->sql_command= SQLCOM_SAVEPOINT;
6624
lex->statement= new(std::nothrow) statement::Savepoint(YYSession);
6625
if (lex->statement == NULL)
6291
Lex->sql_command= SQLCOM_SAVEPOINT;
6292
Lex->statement= new statement::Savepoint(YYSession);
6632
RELEASE_SYM SAVEPOINT_SYM ident
6298
RELEASE_SYM SAVEPOINT_SYM savepoint_ident
6635
lex->sql_command= SQLCOM_RELEASE_SAVEPOINT;
6636
lex->statement= new(std::nothrow) statement::ReleaseSavepoint(YYSession);
6637
if (lex->statement == NULL)
6300
Lex->sql_command= SQLCOM_RELEASE_SAVEPOINT;
6301
Lex->statement= new statement::ReleaseSavepoint(YYSession);
6644
6311
UNIONS : glue selects together
6675
6342
union_order_or_limit:
6677
Session *session= YYSession;
6678
LEX *lex= session->lex;
6679
assert(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
6680
Select_Lex *sel= lex->current_select;
6344
assert(Lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
6345
Select_Lex *sel= Lex->current_select;
6681
6346
Select_Lex_Unit *unit= sel->master_unit();
6682
6347
Select_Lex *fake= unit->fake_select_lex;
6685
6350
unit->global_parameters= fake;
6686
6351
fake->no_table_names_allowed= 1;
6687
lex->current_select= fake;
6352
Lex->current_select= fake;
6689
session->where= "global ORDER clause";
6354
YYSession->where= "global ORDER clause";
6693
Session *session= YYSession;
6694
session->lex->current_select->no_table_names_allowed= 0;
6358
YYSession->lex->current_select->no_table_names_allowed= 0;
6359
YYSession->where= "";