~mdcallag/+junk/5.1-map

« back to all changes in this revision

Viewing changes to sql/sql_show.cc

  • Committer: Mark Callaghan
  • Date: 2008-10-25 15:34:00 UTC
  • mfrom: (2736.1.36 mysql-5.1)
  • Revision ID: mdcallag@gmail.com-20081025153400-uigkz0tk1nxwb13b
mergeĀ fromĀ 5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
707
707
 
708
708
  if ((table_list->view ?
709
709
       view_store_create_info(thd, table_list, &buffer) :
710
 
       store_create_info(thd, table_list, &buffer, NULL)))
 
710
       store_create_info(thd, table_list, &buffer, NULL,
 
711
                         FALSE /* show_database */)))
711
712
    DBUG_RETURN(TRUE);
712
713
 
713
714
  List<Item> field_list;
898
899
  DBUG_PRINT("enter",("table: %s",table_list->table->s->table_name.str));
899
900
 
900
901
  protocol->prepare_for_resend();
901
 
  if (store_create_info(thd, table_list, packet, NULL))
 
902
  if (store_create_info(thd, table_list, packet, NULL,
 
903
                        FALSE /* show_database */))
902
904
    DBUG_RETURN(-1);
903
905
 
904
906
  if (fd < 0)
1150
1152
 */
1151
1153
 
1152
1154
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
1153
 
                      HA_CREATE_INFO *create_info_arg)
 
1155
                      HA_CREATE_INFO *create_info_arg, bool show_database)
1154
1156
{
1155
1157
  List<Item> field_list;
1156
1158
  char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], def_value_buf[MAX_FIELD_WIDTH];
1198
1200
      alias= share->table_name.str;
1199
1201
    }
1200
1202
  }
 
1203
 
 
1204
  /*
 
1205
    Print the database before the table name if told to do that. The
 
1206
    database name is only printed in the event that it is different
 
1207
    from the current database.  The main reason for doing this is to
 
1208
    avoid having to update gazillions of tests and result files, but
 
1209
    it also saves a few bytes of the binary log.
 
1210
   */
 
1211
  if (show_database)
 
1212
  {
 
1213
    const LEX_STRING *const db=
 
1214
      table_list->schema_table ? &INFORMATION_SCHEMA_NAME : &table->s->db;
 
1215
    if (strcmp(db->str, thd->db) != 0)
 
1216
    {
 
1217
      append_identifier(thd, packet, db->str, db->length);
 
1218
      packet->append(STRING_WITH_LEN("."));
 
1219
    }
 
1220
  }
 
1221
 
1201
1222
  append_identifier(thd, packet, alias, strlen(alias));
1202
1223
  packet->append(STRING_WITH_LEN(" (\n"));
1203
1224
  /*
4324
4345
          !my_strcasecmp(system_charset_info, tables->definer.host.str,
4325
4346
                         sctx->priv_host))
4326
4347
        tables->allowed_show= TRUE;
 
4348
#ifndef NO_EMBEDDED_ACCESS_CHECKS
 
4349
      else
 
4350
      {
 
4351
        if ((thd->col_access & (SHOW_VIEW_ACL|SELECT_ACL)) ==
 
4352
            (SHOW_VIEW_ACL|SELECT_ACL))
 
4353
          tables->allowed_show= TRUE;
 
4354
        else
 
4355
        {
 
4356
          TABLE_LIST table_list;
 
4357
          uint view_access;
 
4358
          memset(&table_list, 0, sizeof(table_list));
 
4359
          table_list.db= tables->view_db.str;
 
4360
          table_list.table_name= tables->view_name.str;
 
4361
          table_list.grant.privilege= thd->col_access;
 
4362
          view_access= get_table_grant(thd, &table_list);
 
4363
          if ((view_access & (SHOW_VIEW_ACL|SELECT_ACL)) ==
 
4364
              (SHOW_VIEW_ACL|SELECT_ACL))
 
4365
            tables->allowed_show= TRUE;
 
4366
        }
 
4367
      }
 
4368
#endif
4327
4369
    }
4328
4370
    restore_record(table, s->default_values);
4329
4371
    tmp_db_name= &tables->view_db;