示例#1
0
static PT_NODE *
pt_check_access_status (PARSER_CONTEXT * parser, PT_NODE * node)
{
  DB_VALUE oid_val;
  MOP classop;
  PT_NODE *entity = NULL;
  PT_NODE *derived_table = NULL;
  PT_NODE *arg = NULL;

  if (!au_is_dba_group_member (Au_user))
    {
      PT_ERRORmf (parser, NULL, MSGCAT_SET_ERROR, -(ER_AU_DBA_ONLY), "show access status");
      return node;
    }

  entity = node->info.query.q.select.from;
  assert (entity != NULL);

  derived_table = entity->info.spec.derived_table;
  assert (derived_table != NULL);

  classop = sm_find_class ("db_user");
  if (classop == NULL)
    {
      assert (er_errid () != NO_ERROR);
      PT_ERRORc (parser, node, er_msg ());
      return node;
    }

  db_make_oid (&oid_val, &classop->oid_info.oid);
  arg = pt_dbval_to_value (parser, &oid_val);

  derived_table->info.showstmt.show_args = parser_append_node (arg, derived_table->info.showstmt.show_args);

  return node;
}
示例#2
0
/*
 * pt_check_show_index () - semantic check for show index.
 *   return:
 *   parser(in):
 *   node(in):
 */
static PT_NODE *
pt_check_show_index (PARSER_CONTEXT * parser, PT_NODE * node)
{
  PT_NODE *show_args_node = NULL;
  MOP cls;
  const char *table_name = NULL;
  const char *index_name = NULL;
  SM_CLASS *sm_class = NULL;
  SM_CLASS_CONSTRAINT *sm_all_constraints = NULL;
  SM_CLASS_CONSTRAINT *sm_constraint = NULL;
  PT_NODE *entity = NULL;
  PT_NODE *derived_table = NULL;
  SHOWSTMT_TYPE show_type;
  int error = NO_ERROR;
  int save;
  int partition_type = DB_NOT_PARTITIONED_CLASS;
  PT_NODE *partition_node = NULL;

  if (node->node_type != PT_SELECT)
    {
      return node;
    }

  entity = node->info.query.q.select.from;
  assert (entity != NULL);

  derived_table = entity->info.spec.derived_table;
  assert (derived_table != NULL);

  show_type = derived_table->info.showstmt.show_type;
  assert (show_type == SHOWSTMT_INDEX_HEADER || show_type == SHOWSTMT_INDEX_CAPACITY
	  || show_type == SHOWSTMT_ALL_INDEXES_HEADER || show_type == SHOWSTMT_ALL_INDEXES_CAPACITY);

  show_args_node = derived_table->info.showstmt.show_args;
  assert (show_args_node != NULL);

  assert (show_args_node->node_type == PT_VALUE);
  assert (show_args_node->type_enum == PT_TYPE_CHAR);
  assert (show_args_node->info.value.data_value.str->length < DB_MAX_IDENTIFIER_LENGTH);

  /* check table name */
  table_name = (const char *) show_args_node->info.value.data_value.str->bytes;
  cls = sm_find_class (table_name);
  if (cls == NULL)
    {
      PT_ERRORmf (parser, show_args_node, MSGCAT_SET_ERROR, -(ER_LC_UNKNOWN_CLASSNAME), table_name);
      return node;
    }

  AU_DISABLE (save);
  error = au_fetch_class_force (cls, &sm_class, AU_FETCH_READ);
  AU_ENABLE (save);
  if (error == NO_ERROR)
    {
      if (sm_get_class_type (sm_class) != SM_CLASS_CT)
	{
	  PT_ERRORm (parser, show_args_node, MSGCAT_SET_ERROR, -(ER_OBJ_NOT_A_CLASS));
	  return node;
	}
    }

  /* check index name */
  if (show_type == SHOWSTMT_INDEX_HEADER || show_type == SHOWSTMT_INDEX_CAPACITY)
    {
      show_args_node = show_args_node->next;
      assert (show_args_node != NULL);
      assert (show_args_node->node_type == PT_VALUE);
      assert (show_args_node->type_enum == PT_TYPE_CHAR);
      assert (show_args_node->info.value.data_value.str->length < DB_MAX_IDENTIFIER_LENGTH);

      index_name = (const char *) show_args_node->info.value.data_value.str->bytes;
      sm_all_constraints = sm_class_constraints (cls);
      sm_constraint = classobj_find_constraint_by_name (sm_all_constraints, index_name);
      if (sm_all_constraints == NULL || sm_constraint == NULL)
	{
	  PT_ERRORmf (parser, show_args_node, MSGCAT_SET_ERROR, -(ER_SM_NO_INDEX), index_name);
	  return node;
	}
    }

  /* get partition type and pass it by args */
  error = sm_partitioned_class_type (cls, &partition_type, NULL, NULL);
  if (error != NO_ERROR)
    {
      PT_ERRORc (parser, show_args_node, er_msg ());
      return node;
    }

  partition_node = pt_make_integer_value (parser, partition_type);
  if (partition_node == NULL)
    {
      PT_INTERNAL_ERROR (parser, "allocate new node");
      return node;
    }
  parser_append_node (partition_node, show_args_node);

  return node;
}
示例#3
0
/*
 * pt_check_show_heap () - check table exists or not 
 *   return: PT_NODE pointer
 *
 *   parser(in):
 *   node(in):
 */
static PT_NODE *
pt_check_table_in_show_heap (PARSER_CONTEXT * parser, PT_NODE * node)
{
  int error = NO_ERROR;
  PT_NODE *show_args_node = NULL, *spec, *derived_table;
  PT_NODE *partition_node = NULL;
  SHOWSTMT_TYPE show_type;
  int partition_type = DB_NOT_PARTITIONED_CLASS;
  const char *table_name = NULL;
  MOP cls;
  SM_CLASS *sm_class = NULL;
  int save;

  if (node->node_type != PT_SELECT)
    {
      return node;
    }

  spec = node->info.query.q.select.from;
  assert (spec != NULL);

  derived_table = spec->info.spec.derived_table;
  assert (derived_table != NULL);

  show_type = derived_table->info.showstmt.show_type;
  assert (show_type == SHOWSTMT_HEAP_HEADER || show_type == SHOWSTMT_ALL_HEAP_HEADER
	  || show_type == SHOWSTMT_HEAP_CAPACITY || show_type == SHOWSTMT_ALL_HEAP_CAPACITY);

  show_args_node = derived_table->info.showstmt.show_args;
  assert (show_args_node != NULL);

  assert (show_args_node->node_type == PT_VALUE);
  assert (show_args_node->type_enum == PT_TYPE_CHAR);

  table_name = (const char *) show_args_node->info.value.data_value.str->bytes;

  cls = sm_find_class (table_name);
  if (cls == NULL)
    {
      PT_ERRORmf (parser, show_args_node, MSGCAT_SET_ERROR, -(ER_LC_UNKNOWN_CLASSNAME), table_name);
      return node;
    }

  AU_DISABLE (save);
  error = au_fetch_class_force (cls, &sm_class, AU_FETCH_READ);
  AU_ENABLE (save);
  if (error == NO_ERROR)
    {
      if (sm_get_class_type (sm_class) != SM_CLASS_CT)
	{
	  PT_ERRORm (parser, show_args_node, MSGCAT_SET_ERROR, -(ER_OBJ_NOT_A_CLASS));
	  return node;
	}
    }

  error = sm_partitioned_class_type (cls, &partition_type, NULL, NULL);
  if (error != NO_ERROR)
    {
      PT_ERRORc (parser, show_args_node, er_msg ());
      return node;
    }

  partition_node = pt_make_integer_value (parser, partition_type);
  if (partition_node == NULL)
    {
      PT_INTERNAL_ERROR (parser, "allocate new node");
      return node;
    }

  parser_append_node (partition_node, show_args_node);

  return node;
}
示例#4
0
/*
 * stats_dump () - Dumps the given statistics about a class
 *   return:
 *   classname(in): The name of class to be printed
 *   fp(in):
 */
void
stats_dump (const char *class_name_p, FILE * file_p)
{
  MOP class_mop;
  CLASS_STATS *class_stats_p;
  SM_CLASS *smclass_p;
  int i, j, k;
  const char *name_p;
  const char *prefix_p = "";
  time_t tloc;

  class_mop = sm_find_class (class_name_p);
  if (class_mop == NULL)
    {
      return;
    }

  smclass_p = sm_get_class_with_statistics (class_mop);
  if (smclass_p == NULL)
    {
      return;
    }

  class_stats_p = smclass_p->stats;
  if (class_stats_p == NULL)
    {
      return;
    }

  fprintf (file_p, "\nCLASS STATISTICS\n");
  fprintf (file_p, "****************\n");
  fprintf (file_p, " Class name: %s", class_name_p);
  tloc = (time_t) class_stats_p->time_stamp;
  fprintf (file_p, " Timestamp: %s", ctime (&tloc));
  fprintf (file_p, " Total pages in class heap: %d\n",
	   class_stats_p->heap_size);
  fprintf (file_p, " Total objects: %d\n", class_stats_p->num_objects);
  fprintf (file_p, " Number of attributes: %d\n", class_stats_p->n_attrs);

  for (i = 0; i < class_stats_p->n_attrs; i++)
    {
      name_p = sm_get_att_name (class_mop, class_stats_p->attr_stats[i].id);
      fprintf (file_p, " Atrribute: %s\n", (name_p ? name_p : "not found"));
      fprintf (file_p, "    id: %d\n", class_stats_p->attr_stats[i].id);
      fprintf (file_p, "    Type: ");

      switch (class_stats_p->attr_stats[i].type)
	{
	case DB_TYPE_INTEGER:
	  fprintf (file_p, "DB_TYPE_INTEGER\n");
	  break;

	case DB_TYPE_BIGINT:
	  fprintf (file_p, "DB_TYPE_BIGINT\n");
	  break;

	case DB_TYPE_FLOAT:
	  fprintf (file_p, "DB_TYPE_FLOAT\n");
	  break;

	case DB_TYPE_DOUBLE:
	  fprintf (file_p, "DB_TYPE_DOUBLE\n");
	  break;

	case DB_TYPE_STRING:
	  fprintf (file_p, "DB_TYPE_STRING\n");
	  break;

	case DB_TYPE_OBJECT:
	  fprintf (file_p, "DB_TYPE_OBJECT\n");
	  break;

	case DB_TYPE_SET:
	  fprintf (file_p, "DB_TYPE_SET\n");
	  break;

	case DB_TYPE_MULTI_SET:
	  fprintf (file_p, "DB_TYPE_MULTI_SET\n");
	  break;

	case DB_TYPE_SEQUENCE:
	  fprintf (file_p, "DB_TYPE_SEQUENCE\n");
	  break;

	case DB_TYPE_TIME:
	  fprintf (file_p, "DB_TYPE_TIME\n");
	  break;

	case DB_TYPE_UTIME:
	  fprintf (file_p, "DB_TYPE_UTIME\n");
	  break;

	case DB_TYPE_DATETIME:
	  fprintf (file_p, "DB_TYPE_DATETIME\n");
	  break;

	case DB_TYPE_MONETARY:
	  fprintf (file_p, "DB_TYPE_MONETARY\n");
	  break;

	case DB_TYPE_DATE:
	  fprintf (file_p, "DB_TYPE_DATE\n");
	  break;

	case DB_TYPE_ELO:
	  fprintf (file_p, "DB_TYPE_ELO\n");
	  break;

	case DB_TYPE_VARIABLE:
	  fprintf (file_p, "DB_TYPE_VARIABLE\n");
	  break;

	case DB_TYPE_SUB:
	  fprintf (file_p, "DB_TYPE_SUB\n");
	  break;

	case DB_TYPE_POINTER:
	  fprintf (file_p, "DB_TYPE_POINTER\n");
	  break;

	case DB_TYPE_NULL:
	  fprintf (file_p, "DB_TYPE_NULL\n");
	  break;

	case DB_TYPE_NUMERIC:
	  fprintf (file_p, "DB_TYPE_NUMERIC\n");
	  break;

	case DB_TYPE_BIT:
	  fprintf (file_p, "DB_TYPE_BIT\n");
	  break;

	case DB_TYPE_VARBIT:
	  fprintf (file_p, "DB_TYPE_VARBIT\n");
	  break;

	case DB_TYPE_CHAR:
	  fprintf (file_p, "DB_TYPE_CHAR\n");
	  break;

	case DB_TYPE_NCHAR:
	  fprintf (file_p, "DB_TYPE_NCHARL\n");
	  break;

	case DB_TYPE_VARNCHAR:
	  fprintf (file_p, "DB_TYPE_VARNCHARL\n");
	  break;

	case DB_TYPE_DB_VALUE:
	  fprintf (file_p, "DB_TYPE_DB_VALUE\n");
	  break;

	default:
	  fprintf (file_p, "UNKNOWN_TYPE\n");
	  break;
	}

      stats_print_min_max (&(class_stats_p->attr_stats[i]), file_p);
      fprintf (file_p, "    B+tree statistics:\n");

      for (j = 0; j < class_stats_p->attr_stats[i].n_btstats; j++)
	{
	  BTREE_STATS *bt_statsp = &class_stats_p->attr_stats[i].bt_stats[j];
	  fprintf (file_p, "        BTID: { %d , %d }\n",
		   bt_statsp->btid.vfid.volid, bt_statsp->btid.vfid.fileid);
	  fprintf (file_p, "        Cardinality: %d (", bt_statsp->keys);

	  prefix_p = "";
	  for (k = 0; k < bt_statsp->key_size; k++)
	    {
	      fprintf (file_p, "%s%d", prefix_p, bt_statsp->pkeys[k]);
	      prefix_p = ",";
	    }
	  fprintf (file_p, ") ,");
	  fprintf (file_p, " Total pages: %d , Leaf pages: %d ,"
		   " Height: %d\n",
		   bt_statsp->pages, bt_statsp->leafs, bt_statsp->height);
	}
      fprintf (file_p, "\n");
    }

  fprintf (file_p, "\n\n");
}