summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2005-11-18 16:38:01 +0100
committerunknown <guilhem@mysql.com>2005-11-18 16:38:01 +0100
commit41de6f9a7cfcb39e8461835dfe67dbc24f457bb4 (patch)
tree07e22cfddd8927526e3bb2ef581822106278886f /sql/sql_table.cc
parent081cc1558734f2ee7a674ddacaa2436b2a46d039 (diff)
parent14637f97cdd7ff4a7d60c09052e2e280ee57c957 (diff)
downloadmariadb-git-41de6f9a7cfcb39e8461835dfe67dbc24f457bb4.tar.gz
Merge mysql.com:/home/mysql_src/mysql-5.0
into mysql.com:/home/mysql_src/mysql-5.1-merge-of-5.0 (not all files are good, I'll fix; I'll ask some devs to check their part) BitKeeper/etc/ignore: auto-union include/my_global.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/information_schema.result: Auto merged mysql-test/t/view.test: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged sql/field.cc: Auto merged sql/item.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/set_var.h: Auto merged sql/sp.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_table.cc: Auto merged sql/table.h: Auto merged storage/myisam/mi_key.c: Auto merged storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged storage/ndb/src/ndbapi/NdbImpl.hpp: Auto merged storage/ndb/src/ndbapi/ndb_cluster_connection.cpp: Auto merged support-files/mysql.spec.sh: Auto merged configure.in: merge mysql-test/r/ps_1general.result: merge ("ul", will fix) sql/examples/ha_tina.cc: merge sql/ha_innodb.cc: merge sql/handler.h: merge sql/log.cc: merge sql/set_var.cc: merge sql/share/errmsg.txt: merge (bad, will fix) sql/sql_show.cc: merge (bad, will fix) sql/sql_yacc.yy: merge storage/ndb/src/ndbapi/NdbRecAttr.cpp: merge
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc43
1 files changed, 32 insertions, 11 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 94590f6faf2..4c06d4646fb 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -896,6 +896,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
else
{
/* Field redefined */
+ sql_field->def= dup_field->def;
sql_field->sql_type= dup_field->sql_type;
sql_field->charset= (dup_field->charset ?
dup_field->charset :
@@ -905,8 +906,15 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->key_length= dup_field->key_length;
sql_field->create_length_to_internal_length();
sql_field->decimals= dup_field->decimals;
- sql_field->flags= dup_field->flags;
sql_field->unireg_check= dup_field->unireg_check;
+ /*
+ We're making one field from two, the result field will have
+ dup_field->flags as flags. If we've incremented null_fields
+ because of sql_field->flags, decrement it back.
+ */
+ if (!(sql_field->flags & NOT_NULL_FLAG))
+ null_fields--;
+ sql_field->flags= dup_field->flags;
it2.remove(); // Remove first (create) definition
select_field_pos--;
break;
@@ -2338,7 +2346,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* if view are unsupported */
if (table->view && view_operator_func == NULL)
{
- result_code= HA_ADMIN_NOT_IMPLEMENTED;
+ result_code= HA_ADMIN_NOT_BASE_TABLE;
goto send_result;
}
thd->open_options&= ~extra_open_options;
@@ -2473,6 +2481,16 @@ send_result_message:
}
break;
+ case HA_ADMIN_NOT_BASE_TABLE:
+ {
+ char buf[ERRMSGSIZE+20];
+ uint length= my_snprintf(buf, ERRMSGSIZE,
+ ER(ER_BAD_TABLE_ERROR), table_name);
+ protocol->store("note", 4, system_charset_info);
+ protocol->store(buf, length, system_charset_info);
+ }
+ break;
+
case HA_ADMIN_OK:
protocol->store("status", 6, system_charset_info);
protocol->store("OK",2, system_charset_info);
@@ -2573,16 +2591,19 @@ send_result_message:
break;
}
}
- if (fatal_error)
- table->table->s->version=0; // Force close of table
- else if (open_for_modify)
+ if (table->table)
{
- pthread_mutex_lock(&LOCK_open);
- remove_table_from_cache(thd, table->table->s->db,
- table->table->s->table_name, RTFC_NO_FLAG);
- pthread_mutex_unlock(&LOCK_open);
- /* May be something modified consequently we have to invalidate cache */
- query_cache_invalidate3(thd, table->table, 0);
+ if (fatal_error)
+ table->table->s->version=0; // Force close of table
+ else if (open_for_modify)
+ {
+ pthread_mutex_lock(&LOCK_open);
+ remove_table_from_cache(thd, table->table->s->db,
+ table->table->s->table_name, RTFC_NO_FLAG);
+ pthread_mutex_unlock(&LOCK_open);
+ /* Something may be modified, that's why we have to invalidate cache */
+ query_cache_invalidate3(thd, table->table, 0);
+ }
}
close_thread_tables(thd);
table->table=0; // For query cache