Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: Complete the information_schema by adding empty table definitions #8675

Closed
19 of 33 tasks
nvanbenschoten opened this issue Aug 18, 2016 · 20 comments
Closed
19 of 33 tasks
Assignees
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-vtables Virtual tables - pg_catalog, information_schema etc C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) E-easy Easy issue to tackle, requires little or no CockroachDB experience good first issue help wanted Help is requested / needed by the one who filed the issue to fix it. meta-issue Contains a list of several other issues. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-anchored-telemetry The issue number is anchored by telemetry references.

Comments

@nvanbenschoten
Copy link
Member

nvanbenschoten commented Aug 18, 2016

#8119 introduced the framework for creating virtual schemas, and specifically, the information_schema. Subsequently, a group PRs added what was deemed to be the most immediately critical set of tables. However, the specification for the information_schema is extensive, and there are a number of other tables which can be added with relative ease. The set of all information_schema tables is:

  • character_sets
  • collations
  • collation_character_set_applicability
  • columns
  • column_privileges
  • constraint_column_usage
  • engines
  • events
  • files
  • global_status
  • session_statuss
  • global_variables
  • session_variables
  • key_column_usage
  • optimizer_trace
  • parameters
  • partitions
  • plugins
  • processlist
  • profiling
  • referential_constraints
  • routines
  • schemata
  • schema_privileges
  • sequences
  • statistics
  • tables
  • tablespaces
  • table_constraints
  • table_privileges
  • triggers
  • user_privileges
  • views

The process for adding a new information_schema table is:

  1. create a new virtualSchemaTable variable with a table schema definition
  2. construct a population function implementation to populate this schema on demand
  3. add the variable to the information_schema's table list
  4. add necessary testing to testdata/information_schema

Helpful sources:

@nvanbenschoten nvanbenschoten added help wanted Help is requested / needed by the one who filed the issue to fix it. E-easy Easy issue to tackle, requires little or no CockroachDB experience labels Aug 18, 2016
@nvanbenschoten nvanbenschoten added this to the Later milestone Aug 18, 2016
@nvanbenschoten nvanbenschoten changed the title sql: Add other sql: Complete the information_schema by adding remaining tables Aug 18, 2016
@nvanbenschoten nvanbenschoten added the A-sql-pgcompat Semantic compatibility with PostgreSQL label Oct 19, 2016
@yznming
Copy link
Contributor

yznming commented Oct 25, 2016

@nvanbenschoten I'm going to create the information_schema.statistics as follow, what do you think?

CREATE TABLE information_schema.statistics (
    TABLE_CATALOG STRING NOT NULL DEFAULT '',
    TABLE_SCHEMA STRING NOT NULL DEFAULT '',
    TABLE_NAME STRING NOT NULL DEFAULT '',
    NON_UNIQUE BOOL NOT NULL DEFAULT FALSE,
    INDEX_SCHEMA STRING NOT NULL DEFAULT '',
    INDEX_NAME STRING NOT NULL DEFAULT '',
    SEQ_IN_INDEX INT NOT NULL DEFAULT 0,
    COLUMN_NAME STRING NOT NULL DEFAULT '',
    "COLLATION" STRING NOT NULL DEFAULT '',
    CARDINALITY INT NOT NULL DEFAULT 0,
    DIRECTION STRING NOT NULL DEFAULT '',
    STORING BOOL NOT NULL DEFAULT FALSE 
);

@nvanbenschoten
Copy link
Member Author

That sounds reasonable @yananzhi, thanks!

@szpony
Copy link
Contributor

szpony commented Oct 27, 2016

@nvanbenschoten I'm planning to create information_schema.views as follows :

CREATE TABLE information_schema.views (
    TABLE_CATALOG STRING NOT NULL DEFAULT '',
    TABLE_SCHEMA STRING NOT NULL DEFAULT '',
    TABLE_NAME STRING NOT NULL DEFAULT '',
    VIEW_DEFINITION STRING NOT NULL DEFAULT '',
    CHECK_OPTION STRING NOT NULL DEFAULT '',
    IS_UPDATABLE BOOL NOT NULL DEFAULT FALSE,
    IS_INSERTABLE_INTO BOOL NOT NULL DEFAULT FALSE,
    IS_TRIGGER_UPDATABLE BOOL NOT NULL DEFAULT FALSE,
    IS_TRIGGER_DELETABLE BOOL NOT NULL DEFAULT FALSE,
    IS_TRIGGER_INSERTABLE_INTO BOOL NOT NULL DEFAULT FALSE
);

It refers to the postgresql document: https://www.postgresql.org/docs/9.5/static/infoschema-views.html
Look forward to your advice. Thanks.

@nvanbenschoten
Copy link
Member Author

@mtMabo yep that looks good. Thanks!

@yangliang9004
Copy link
Contributor

@nvanbenschoten I'm planning to create information_schema.user_privileges as follows :

CREATE  TABLE information_schema .user_privileges (
   GRANTEE STRING  NOT NULL DEFAULT '',
   TABLE_CATALOG  STRING NOT  NULL  DEFAULT '',
   PRIVILEGE_TYPE  STRING NOT NULL DEFAULT '',
   IS_GRANTABLE  BOOL NOT NULL DEFAULT FALSE
);

It refers to the mysql document: https://dev.mysql.com/doc/refman/5.7/en/user-privileges-table.html
Look forward to your advice. Thanks.

@jordanlewis
Copy link
Member

@yangliang9004, LGTM

@radutopala
Copy link

radutopala commented May 14, 2017

@benesch https://github.com/radutopala/cockroach-app/issues .. found these so far, with PHP/Symfony/Doctrine.

@tbg tbg mentioned this issue Oct 7, 2017
4 tasks
tbg added a commit to tbg/cockroachdb-diesel-example that referenced this issue Oct 8, 2017
This is almost verbatim the example from

https://github.com/diesel-rs/diesel/tree/3ae353c3aff8a7ea64ed6cb39b3a045ac86cd60e/examples/postgres

with minor adjustments:

1. after `diesel setup`, edit the created `up.sql` and `down.sql` to contain
   only a trivial statement (like `SELECT 1`). This is necessary because by
   default they contain a [random trigger] that CockroachDB can't handle.
2. `schema.rs` was manually spelled out using the `table!` macro. The tutorial
   uses `infer_schema!` for which we don't have all the [internals]. Note that
   we use `BigInt` to properly support CockroachDB's `SERIAL` type. In turn,
   `struct Post` has `id: i64` instead of `i32`.
3. Some adjustments in `show_posts` to list the ID which is otherwise impossible
   to guess.
4. Pinned the diesel dependency for no good reason (to hopefully have this go
   stale later).

There are likely more problems not discovered by this toy example. See the
[tracking issue].

[random trigger]: https://github.com/diesel-rs/diesel/blob/master/diesel_cli/src/setup_sql/postgres/initial_setup/up.sql
[internals]: cockroachdb/cockroach#8675
[tracking issue]: cockroachdb/cockroach#13787
@sum12
Copy link
Contributor

sum12 commented Dec 22, 2017

@nvanbenschoten I wanted to pick up column_privileges, like this

CREATE TABLE information_schema.column_privilege (
	GRANTER STRING NOT NULL DEFAULT '',
	GRANTEE STRING NOT NULL DEFAULT '',
	TABLE_CATALOG STRING NOT NULL DEFAULT '',
	TABLE_SCHEMA STRING NOT NULL DEFAULT '',
	TABLE_NAME STRING NOT NULL DEFAULT '',
	COLUMN_NAME STRING NOT NULL DEFAULT '',
	PRIVILEGE_TYPE STRING NOT NULL DEFAULT '',
	IS_GRANTABLE BOOL NOT NULL DEFAULT FALSE
);

But the column_descriptor in ColumnDescriptor doesnot have any PriviliegeDescriptor.

Any pointers for me ?

@benesch
Copy link
Contributor

benesch commented Dec 22, 2017 via email

@nvanbenschoten
Copy link
Member Author

@sum12 thanks for the interest! @benesch is exactly right that we should handle this the same way Postgres did before they added column level privileges. Let me know if you plan to pick this up or if you have any other questions.

sum12 added a commit to sum12/cockroach that referenced this issue Dec 23, 2017
@mneverov
Copy link
Contributor

hi, i'd like to work on session_variables (variable string not null, value string not null).

mneverov added a commit to mneverov/cockroach that referenced this issue Dec 11, 2020
The `session_variables` table exposes the session variables.
Related to: cockroachdb#8675

Release note (sql change): Added session_variables table to the information_schema.
mneverov added a commit to mneverov/cockroach that referenced this issue Dec 16, 2020
The `session_variables` table exposes the session variables.
Related to: cockroachdb#8675

Release note (sql change): Added session_variables table to the information_schema.
craig bot pushed a commit that referenced this issue Dec 23, 2020
57837: sql: Add information_schema.session_variables table r=rafiss a=mneverov

sql: Add information_schema.session_variables table

The `session_variables` table exposes the session variables.
Related to: #8675

Release note (sql change): Added session_variables table to the information_schema.

Co-authored-by: Max Neverov <neverov.max@gmail.com>
@rafiss rafiss added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label May 12, 2021
@rafiss rafiss changed the title sql: Complete the information_schema by adding remaining tables sql: Complete the information_schema by adding empty table definitions May 20, 2021
mnovelodou pushed a commit to mnovelodou/cockroach that referenced this issue Jun 2, 2021
Previously, there were 38 undefined information_schema tables that
exists in postgres
This was inadequate because not having them may cause compatibility
issues
To address this, this patch defines these 38 tables as unimplemented
to allow queries

Release note (sql change): adding empty missing tables on information
schema for compatibility:
attributes
check_constraint_routine_usage
column_column_usage
column_domain_usage
column_options
constraint_table_usage
data_type_privileges
domain_constraints
domain_udt_usage
domains
element_types
foreign_data_wrapper_options
foreign_data_wrappers
foreign_server_options
foreign_servers
foreign_table_options
foreign_tables
information_schema_catalog_name
role_column_grants
role_routine_grants
role_udt_grants
role_usage_grants
routine_privileges
sql_features
sql_implementation_info
sql_parts
sql_sizing
transforms
triggered_update_columns
triggers
udt_privileges
usage_privileges
user_defined_types
user_mapping_options
user_mappings
view_column_usage
view_routine_usage
view_table_usage

Related to: cockroachdb#8675
mnovelodou pushed a commit to mnovelodou/cockroach that referenced this issue Jun 21, 2021
Previously, there were 38 undefined information_schema tables that
exists in postgres
This was inadequate because not having them may cause compatibility
issues
To address this, this patch defines these 38 tables as unimplemented
to allow queries

Release note (sql change): adding empty missing tables on information
schema for compatibility:
attributes
check_constraint_routine_usage
column_column_usage
column_domain_usage
column_options
constraint_table_usage
data_type_privileges
domain_constraints
domain_udt_usage
domains
element_types
foreign_data_wrapper_options
foreign_data_wrappers
foreign_server_options
foreign_servers
foreign_table_options
foreign_tables
information_schema_catalog_name
role_column_grants
role_routine_grants
role_udt_grants
role_usage_grants
routine_privileges
sql_features
sql_implementation_info
sql_parts
sql_sizing
transforms
triggered_update_columns
triggers
udt_privileges
usage_privileges
user_defined_types
user_mapping_options
user_mappings
view_column_usage
view_routine_usage
view_table_usage

Related to: cockroachdb#8675
craig bot pushed a commit that referenced this issue Jun 22, 2021
65854: sql: adding missing tables on information_schema r=rafiss a=mnovelodou

Previously, there were 38 undefined information_schema tables that
exists in postgres
This was inadequate because not having them may cause compatibility
issues
To address this, this patch defines these 38 tables as unimplemented
to allow queries

Release note (sql change): adding empty missing tables on information
schema for compatibility:
attributes
check_constraint_routine_usage
column_column_usage
column_domain_usage
column_options
constraint_table_usage
data_type_privileges
domain_constraints
domain_udt_usage
domains
element_types
foreign_data_wrapper_options
foreign_data_wrappers
foreign_server_options
foreign_servers
foreign_table_options
foreign_tables
information_schema_catalog_name
role_column_grants
role_routine_grants
role_udt_grants
role_usage_grants
routine_privileges
sql_features
sql_implementation_info
sql_parts
sql_sizing
transforms
triggered_update_columns
triggers
udt_privileges
usage_privileges
user_defined_types
user_mapping_options
user_mappings
view_column_usage
view_routine_usage
view_table_usage

Related to: #8675

66711: roachtest: bump predecessor to v21.1.3 r=celiala a=celiala

Release note: None


Co-authored-by: MiguelNovelo <miguel.novelo@digitalonus.com>
Co-authored-by: Celia La <celiala456@gmail.com>
@knz knz removed the hacktoberfest label Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-vtables Virtual tables - pg_catalog, information_schema etc C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) E-easy Easy issue to tackle, requires little or no CockroachDB experience good first issue help wanted Help is requested / needed by the one who filed the issue to fix it. meta-issue Contains a list of several other issues. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-anchored-telemetry The issue number is anchored by telemetry references.
Projects
None yet
Development

No branches or pull requests