~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Brian Aker
  • Date: 2009-06-09 01:59:10 UTC
  • mfrom: (1054.1.11 merge)
  • Revision ID: brian@gaz-20090609015910-0sfsovp2x8wfbr2c
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
8351
8351
  @param tables  list of tables in join
8352
8352
  @query_type    type of the query is being generated
8353
8353
*/
8354
 
static void print_join(Session *session, String *str,
8355
 
                       List<TableList> *tables, enum_query_type)
 
8354
void print_join(Session *session, String *str,
 
8355
                List<TableList> *tables, enum_query_type)
8356
8356
{
8357
8357
  /* List is reversed => we should reverse it before using */
8358
8358
  List_iterator_fast<TableList> ti(*tables);
8386
8386
  print_table_array(session, str, table, table + tables->elements);
8387
8387
}
8388
8388
 
8389
 
/**
8390
 
  Print table as it should be in join list.
8391
 
 
8392
 
  @param str   string where table should be printed
8393
 
*/
8394
 
void TableList::print(Session *session, String *str, enum_query_type query_type)
8395
 
{
8396
 
  if (nested_join)
8397
 
  {
8398
 
    str->append('(');
8399
 
    print_join(session, str, &nested_join->join_list, query_type);
8400
 
    str->append(')');
8401
 
  }
8402
 
  else
8403
 
  {
8404
 
    const char *cmp_name;                         // Name to compare with alias
8405
 
    if (derived)
8406
 
    {
8407
 
      // A derived table
8408
 
      str->append('(');
8409
 
      derived->print(str, query_type);
8410
 
      str->append(')');
8411
 
      cmp_name= "";                               // Force printing of alias
8412
 
    }
8413
 
    else
8414
 
    {
8415
 
      // A normal table
8416
 
      {
8417
 
        str->append_identifier(db, db_length);
8418
 
        str->append('.');
8419
 
      }
8420
 
      if (schema_table)
8421
 
      {
8422
 
        str->append_identifier(schema_table_name, strlen(schema_table_name));
8423
 
        cmp_name= schema_table_name;
8424
 
      }
8425
 
      else
8426
 
      {
8427
 
        str->append_identifier(table_name, table_name_length);
8428
 
        cmp_name= table_name;
8429
 
      }
8430
 
    }
8431
 
    if (my_strcasecmp(table_alias_charset, cmp_name, alias))
8432
 
    {
8433
 
 
8434
 
      if (alias && alias[0])
8435
 
      {
8436
 
        str->append(' ');
8437
 
 
8438
 
        string t_alias(alias);
8439
 
        transform(t_alias.begin(), t_alias.end(),
8440
 
                  t_alias.begin(), ::tolower);
8441
 
 
8442
 
        str->append_identifier(t_alias.c_str(), t_alias.length());
8443
 
      }
8444
 
 
8445
 
    }
8446
 
 
8447
 
    if (index_hints)
8448
 
    {
8449
 
      List_iterator<Index_hint> it(*index_hints);
8450
 
      Index_hint *hint;
8451
 
 
8452
 
      while ((hint= it++))
8453
 
      {
8454
 
        str->append (STRING_WITH_LEN(" "));
8455
 
        hint->print (session, str);
8456
 
      }
8457
 
    }
8458
 
  }
8459
 
}
8460
 
 
8461
8389
void Select_Lex::print(Session *session, String *str, enum_query_type query_type)
8462
8390
{
8463
8391
  /* QQ: session may not be set for sub queries, but this should be fixed */