Name | Status | Last Modified | Last Commit | |
---|---|---|---|---|
lp:~ashish- |
1 Development | 2011-04-08 16:58:22 UTC |
2248.
/* Copyright (C) 2000-2006 MySQL AB
...
Author:
ashish.turbobit
/* Copyright (C) 2000-2006 MySQL AB This program is free software; you can redistribute it and/or modify This program is distributed in the hope that it will be useful, You should have received a copy of the GNU General Public License /* Basic functions needed by many modules */ #include <signal.h> #if TIME_WITH_SYS_TIME #include <drizzled/ using namespace std; namespace drizzled { extern bool volatile shutdown_ bool table_cache_ uint32_t cached_ void table_cache_ table: /* SYNOPSIS NOTES session- If closing a MERGE child, the calling function has to take care for void close_handle_ /* table- /****** void Table:: /* Free resources allocated by filesort() and read_record() */ void Table:: /* @param session Thread context (may be NULL) @remark Session can be NULL, but then wait_for_refresh must be false bool Session: { if (tables == NULL) table: if (wait_for_refresh) If they wait for the locks in thr_multi_lock(), their lock The problem is that the other threads passed all checks in The fix for this problem is to set some_tables_deleted for all Setting some_tables_deleted is done by table:: In other words (reviewer suggestion): You need this setting of if (wait_for_refresh) session- bool found= true; conn1-> lock table t1 write; It also does not make sense to wait for those of placeholders that /* Set version for table */ if (wait_for_refresh) return result; /** bool Session: (void)scopedLock; table::Concurrent *table= static_ safe_ open_tables= table->getNext(); if (table- /* Free memory and reset for next loop */ table: return found_old_table; /** @param session Thread context. @remark It should not ordinarily be called directly. void Session: safe_ boost_ while (open_tables) if (found_old_table) /* SYNOPSIS NOTES: RETURN VALUES TableList *find_table_ /* SYNOPSIS NOTE: to exclude derived tables from check we use following mechanism: We also skip tables with TableList: TODO: when we will have table/view change detection we can do this check RETURN TableList* unique_ /* If this function called for CREATE command that we have not opened table for (;;) void Open_tables_ void Open_tables_ void Open_tables_ void Open_tables_ bool Open_tables_ return false; int Open_tables_ return EEXIST; return ENOENT; Table *Open_tables_ return NULL; // Not a temporary table /** Try to locate the table in the list of session- This function is used to drop user temporary tables, as well as @retval 0 the table was found and dropped successfully. int Open_tables_ if (not (table= find_temporary_ /* Table might be in use by some outer statement. */ close_ return 0; /** @param session Thread context @note because we risk the chance of deleting the share, we can't assume that it will exist past, this should be modified once we can use a TableShare: void Session: /* if (list-> /* Close table. */ // Notify any 'refresh' threads /** @param session Thread handle @note This routine assumes that table to be closed is open only void Session: /* SYNOPSIS void Session: One by effect of this that one can only use wait_for_condition with /** @param session Thread context @return Pointer to Table object used for name locking or 0 in table::Placeholder *Session: /* if (not table:: return NULL; return table; /** @param session Thread context @note This function takes into account all records for table in table @retval true Error occured (OOM) boost_ if (find_ptr( if (not (*table= table_cache_ return false; /* SYNOPSIS IMPLEMENTATION If table list element for the table to be opened has "create" flag RETURN Table *Session: /* Parsing of partitioning information from .frm needs session->lex set up. */ /* find a unused table in the open table cache */ /* an open table operation needs a lot of the stack space */ if (getKilled()) identifier::Table identifier( /* if (not reset) /* Note-> refresh_version is currently changed only during FLUSH TABLES. return NULL; /* { /* table= NULL; if (not table->in_use) /* Avoid self-deadlocks by detecting self-dependencies. */ /* /* /* return NULL; if (table) if (table_ if (not plugin: return table ; /* make a new table */ error= new_table- if (refresh) } /* Fix alias if table name changes */ /* These variables are also set in reopen_table() */ return table; /** @param session Thread context @note This function assumes that if we are not under LOCK TABLES, @note Must not use TableShare: void Session: if (lock) /* /** @param session Thread context @note Since this function can't properly handle prelocking and @note One should have lock on table:: @return false in case of success, true - otherwise. bool Session: if (open_tables == NULL) safe_ for (table= open_tables; table ; table=table- tables_ptr =tables; prev= &open_tables; my_ if (tables != tables_ptr) // Should we get back old locks if ((local_lock= lockTables(tables, (uint32_t) (tables_ptr - tables), flags))) delete [] tables; locking: return error; /** @param session Thread context void Session: Table *table= open_tables; for (; table ; table= table->getNext()) Note "***": We must not enter this branch if the placeholder /* SYNOPSIS INFORMATION The Table object for the dropped table is unlocked but still kept around RETURN Table *drop_locked_ /* if (!found) if (found) return found; /* void abort_locked_ /* SYNOPSIS NOTE If query for which we are opening tables is already marked as requiring RETURN int Session: current_tablenr= 0; /* /* /* /* if (tables->table == NULL) Instead of implementing complex/non-robust logic mentioned In order to prepare for recalculation of set of prelocked tables if (safe_to_ result= -1; // Fatal error set_proc_info(0); if (result && tables) return(result); /* SYNOPSIS NOTE RETURN VALUES If ok, the following are also set: Table *Session: set_proc_ if (table) assert(lock == 0); // You must lock everything at once set_proc_info(0); return table; /* SYNOPSIS NOTES If query for which we are calling this function marked as requring RETURN VALUES int Session: /* if (tables == NULL) assert( if (!(ptr= for (table= tables; table; table= table->next_global) if (not (session->lock= session- return 0; /* SYNPOSIS NOTES: RETURN Table *Open_tables_ table::Temporary *new_tmp_table= new table:: /* return 0; new_tmp_ if (link_in_list) return new_tmp_table; /****** /* Special Field pointers as return values of find_field_in_XXX functions. */ static void update_ /* table- if (session- //if (current_ /* SYNOPSIS DESCRIPTION RETURN static Field * assert( for (nj_col= NULL, curr_nj_col= field_it++; curr_nj_col; *actual_table= nj_col->table_ref; return( /* SYNOPSIS RETURN Field * /* We assume here that table->field < NO_CACHED_ if (field_ptr && *field_ptr) update_ return field; /* SYNOPSIS DESCRIPTION RETURN Field * assert( /* Exclude from the test below nested joins because the columns in a We include explicitly table references with a 'field_translation' table, TODO-> Ensure that table_name, db_name and tables->db always points to something ! *actual_table= NULL; if (!table_ If the field name we search for is qualified, then search for the field if (fld) /* SYNOPSIS RETURN VALUES Field * if (!table_name || !table_name[0]) allow_rowid= table_name || (cur_table && !cur_table- if (item-> if (db) if (last_table) for (; cur_table != last_table ; assert( if (found) if (found) /* /* TODO SYNOPSIS RETURN VALUES /* Special Item pointer to serve as a return value from find_item_ Item ** *resolution= NOT_RESOLVED; is_ref_by_name= (find->type() == Item::FIELD_ITEM || for (uint32_t i= 0; (item=li++); i++) /* if (table_name) Since we should NOT prefer fields from the select list over We use strcmp for table names and database names as these may be /* SYNOPSIS DESCRIPTION RETURN static bool /* SYNOPSIS DESCRIPTION RETURN static bool /* SYNOPSIS DESCRIPTION IMPLEMENTATION RETURN static bool *found_ for (it_1.set( /* Note that for the second loop, it_2.set() will iterate over /* /* if (!item_1 || !item_2) /* /* if (!(eq_cond= new Item_func_ /* nj_ if (field_1) if (using_fields != NULL) /* return(result); /* SYNOPSIS DESCRIPTION IMPLEMENTATION RETURN static bool assert( if (!(non_ /* Append the columns of the first join operand. */ /* for (;;) /* Append the non-equi-join columns of the second join operand. */ if (non_join_ result= false; return(result); /* SYNOPSIS DESCRIPTION IMPLEMENTATION RETURN static bool /* Call the procedure recursively for each nested table reference. */ while (same_level_ /* if (cur_table_ /* /* /* /* /* Add a true condition to outer joins that have no common columns. */ /* Change this table reference to become a leaf for name resolution. */ return(result); /* SYNOPSIS DESCRIPTION IMPLEMENTATION RETURN List< /* Note that tables in the list are in reversed order */ /* return false; /****** int setup_wild(Session *session, List<Item> &fields, Item *item; session- Item_int do not need fix_fields() because it is basic constant. return 0; /****** bool setup_fields( session- /* There is other way to solve problem: fill array with pointers to list, TODO-> remove it when (if) we made one list for allfields and ref_pointer_array Item **ref= ref_pointer_array; session- /* SYNOPSIS RETURN pointer on pointer to next_leaf of last element static TableList **make_ /* SYNOPSIS NOTE This has to be called for all tables that are used by items, as otherwise RETURN bool setup_tables( assert ((select_insert && !tables- if (!(*leaves)) TableList *table_list; /* Precompute and store the row types of NATURAL/USING joins. */ return 0; /* SYNOPSIS NOTE RETURN if (setup_ if (leaves) return false; /* SYNOPSIS bool if (db_name) found= false; /* assert( if ((table_name && my_strcasecmp( /* /* for (; !field_ if (!(item= field_iterator. if (!found) if ((field= field_iterator. session- /* return true; /* SYNOPSIS DESCRIPTION RETURN int Session: session- session- /* } session- err_no_arena: return 1; /****** /* SYNOPSIS NOTE RETURN bool /* while ((field= static_ Field *rfield= field->field; if (rfield == table-> return true; return session- /* SYNOPSIS NOTE RETURN bool fill_record(Session *session, Field **ptr, List<Item> &values, bool) /* while ((field = *ptr++) && ! session- if (field == table-> if (value- return true; return( bool drizzle_ assert( if (not session) plugin: return false; /****** /** void kill_drizzle(void) } /* namespace drizzled */ |
1 → 1 of 1 result | First • Previous • Next • Last |