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

update several statements #2831

Merged
merged 3 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion sql-statements/sql-statement-do.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ aliases: ['/docs/dev/reference/sql/statements/do/']

# DO

This statement executes an expression, without returning a result. In MySQL, a common use-case is to execute stored programs without needing to handle the result. Since TiDB does not provide stored routines, this function has a more limited use.
`DO` executes the expressions but does not return any results. In most respects, `DO` is shorthand for `SELECT expr, ...`.
bobotu marked this conversation as resolved.
Show resolved Hide resolved

> **Note:**
>
> `DO` only executes expressions. It cannot be used in all cases where `SELECT` can be used. For example, `DO id FROM t1` is invalid because it references a table.

In MySQL, a common use-case is to execute stored procedure or trigger. Since TiDB does not provide stored procedure or trigger, this function has a more limited use.
bobotu marked this conversation as resolved.
Show resolved Hide resolved

## Synopsis

Expand All @@ -25,6 +31,8 @@ This statement executes an expression, without returning a result. In MySQL, a c

## Examples

This SELECT statement pauses, but also produces a result set
bobotu marked this conversation as resolved.
Show resolved Hide resolved

```sql
mysql> SELECT SLEEP(5);
+----------+
Expand All @@ -33,7 +41,11 @@ mysql> SELECT SLEEP(5);
| 0 |
+----------+
1 row in set (5.00 sec)
```

DO, on the other hand, pauses without producing a result set.

```sql
mysql> DO SLEEP(5);
Query OK, 0 rows affected (5.00 sec)

Expand Down
21 changes: 20 additions & 1 deletion sql-statements/sql-statement-set-variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,26 @@ aliases: ['/docs/dev/reference/sql/statements/set-variable/']

# `SET [GLOBAL|SESSION] <variable>`

The statement `SET [GLOBAL|SESSION]` modifies one of TiDB's built in variables, of either `SESSION` or `GLOBAL` scope. Note that similar to MySQL, changes to `GLOBAL` variables will not apply to either existing connections, or the local connection. Only new sessions will reflect the changes to the value.
The statement `SET [GLOBAL|SESSION]` modifies one of TiDB's built in variables, of either `SESSION` or `GLOBAL` scope.

> **Note:**
>
> Similar to MySQL, changes to `GLOBAL` variables will not apply to either existing connections, or the local connection. Only new sessions will reflect the changes to the value.
bobotu marked this conversation as resolved.
Show resolved Hide resolved

## Synopsis

**SetStmt:**

![SetStmt](/media/sqlgram/SetStmt.png)

**VariableAssignment:**

![VariableAssignment](/media/sqlgram/VariableAssignment.png)

## Examples

Get the value of `sql_mode`.

```sql
mysql> SHOW GLOBAL VARIABLES LIKE 'sql_mode';
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
Expand All @@ -33,7 +43,12 @@ mysql> SHOW SESSION VARIABLES LIKE 'sql_mode';
| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

Update the value of `sql_mode` globally.
Checking the value of `SQL_mode` after the update, you can see that the value of SESSION level has not been updated:
bobotu marked this conversation as resolved.
Show resolved Hide resolved

```sql
mysql> SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER';
Query OK, 0 rows affected (0.03 sec)

Expand All @@ -52,7 +67,11 @@ mysql> SHOW SESSION VARIABLES LIKE 'sql_mode';
| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

Using `SET SESSION` takes effect immediately:

```sql
mysql> SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER';
Query OK, 0 rows affected (0.01 sec)

Expand Down
192 changes: 115 additions & 77 deletions sql-statements/sql-statement-show-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,85 +25,123 @@ This statement shows a list of variables for the scope of either `GLOBAL` or `SE

## Examples

List all TiDB specific variables. For the meaning of them, refer to [TiDB Specific System Variables](/tidb-specific-system-variables.md).
bobotu marked this conversation as resolved.
Show resolved Hide resolved

```sql
mysql> SHOW GLOBAL VARIABLES LIKE 'tidb%';
+-------------------------------------+---------------+
| Variable_name | Value |
+-------------------------------------+---------------+
| tidb_ddl_error_count_limit | 512 |
| tidb_dml_batch_size | 20000 |
| tidb_force_priority | NO_PRIORITY |
| tidb_batch_insert | 0 |
| tidb_skip_utf8_check | 0 |
| tidb_backoff_lock_fast | 100 |
| tidb_opt_join_reorder_threshold | 0 |
| tidb_auto_analyze_end_time | 23:59 +0000 |
| tidb_slow_log_threshold | 300 |
| tidb_opt_correlation_exp_factor | 1 |
| tidb_mem_quota_sort | 1073741824 |
| tidb_current_ts | 0 |
| tidb_ddl_reorg_batch_size | 256 |
| tidb_checksum_table_concurrency | 4 |
| tidb_check_mb4_value_in_utf8 | 1 |
| tidb_distsql_scan_concurrency | 15 |
| tidb_optimizer_selectivity_level | 0 |
| tidb_opt_agg_push_down | 0 |
| tidb_max_chunk_size | 1024 |
| tidb_low_resolution_tso | 0 |
| tidb_index_lookup_size | 20000 |
| tidb_skip_isolation_level_check | 0 |
| tidb_opt_write_row_id | 0 |
| tidb_wait_split_region_finish | 1 |
| tidb_index_lookup_join_concurrency | 4 |
| tidb_mem_quota_indexlookupjoin | 34359738368 |
| tidb_replica_read | leader |
| tidb_ddl_reorg_priority | PRIORITY_LOW |
| tidb_batch_commit | 0 |
| tidb_mem_quota_mergejoin | 34359738368 |
| tidb_mem_quota_query | 34359738368 |
| tidb_batch_delete | 0 |
| tidb_build_stats_concurrency | 4 |
| tidb_enable_index_merge | 0 |
| tidb_enable_radix_join | 0 |
| tidb_retry_limit | 10 |
| tidb_query_log_max_len | 2048 |
| tidb_config | |
| tidb_ddl_reorg_worker_cnt | 4 |
| tidb_opt_insubq_to_join_and_agg | 1 |
| tidb_enable_vectorized_expression | 1 |
| tidb_mem_quota_hashjoin | 34359738368 |
| tidb_disable_txn_auto_retry | 1 |
| tidb_enable_window_function | 1 |
| tidb_init_chunk_size | 32 |
| tidb_constraint_check_in_place | 0 |
| tidb_wait_split_region_timeout | 300 |
| tidb_hash_join_concurrency | 5 |
| tidb_enable_fast_analyze | 0 |
| tidb_enable_cascades_planner | 0 |
| tidb_txn_mode | |
| tidb_index_serial_scan_concurrency | 1 |
| tidb_projection_concurrency | 4 |
| tidb_enable_noop_functions | 0 |
| tidb_index_lookup_concurrency | 4 |
| tidb_hashagg_partial_concurrency | 4 |
| tidb_general_log | 0 |
| tidb_enable_streaming | 0 |
| tidb_backoff_weight | 2 |
| tidb_mem_quota_topn | 34359738368 |
| tidb_scatter_region | 0 |
| tidb_index_join_batch_size | 25000 |
| tidb_snapshot | |
| tidb_expensive_query_time_threshold | 60 |
| tidb_slow_query_file | tidb-slow.log |
| tidb_auto_analyze_ratio | 0.5 |
| tidb_enable_table_partition | auto |
| tidb_auto_analyze_start_time | 00:00 +0000 |
| tidb_mem_quota_nestedloopapply | 34359738368 |
| tidb_mem_quota_indexlookupreader | 34359738368 |
| tidb_hashagg_final_concurrency | 4 |
| tidb_opt_correlation_threshold | 0.9 |
+-------------------------------------+---------------+
68 rows in set (0.01 sec)
+-------------------------------------+---------------------+
| Variable_name | Value |
+-------------------------------------+---------------------+
| tidb_allow_batch_cop | 0 |
| tidb_allow_remove_auto_inc | 0 |
| tidb_auto_analyze_end_time | 23:59 +0000 |
| tidb_auto_analyze_ratio | 0.5 |
| tidb_auto_analyze_start_time | 00:00 +0000 |
| tidb_backoff_lock_fast | 100 |
| tidb_backoff_weight | 2 |
| tidb_batch_commit | 0 |
| tidb_batch_delete | 0 |
| tidb_batch_insert | 0 |
| tidb_build_stats_concurrency | 4 |
| tidb_capture_plan_baselines | off |
| tidb_check_mb4_value_in_utf8 | 1 |
| tidb_checksum_table_concurrency | 4 |
| tidb_config | |
| tidb_constraint_check_in_place | 0 |
| tidb_current_ts | 0 |
| tidb_ddl_error_count_limit | 512 |
| tidb_ddl_reorg_batch_size | 256 |
| tidb_ddl_reorg_priority | PRIORITY_LOW |
| tidb_ddl_reorg_worker_cnt | 4 |
| tidb_disable_txn_auto_retry | 1 |
| tidb_distsql_scan_concurrency | 15 |
| tidb_dml_batch_size | 20000 |
| tidb_enable_cascades_planner | 0 |
| tidb_enable_chunk_rpc | 1 |
| tidb_enable_collect_execution_info | 1 |
| tidb_enable_fast_analyze | 0 |
| tidb_enable_index_merge | 0 |
| tidb_enable_noop_functions | 0 |
| tidb_enable_radix_join | 0 |
| tidb_enable_slow_log | 1 |
| tidb_enable_stmt_summary | 1 |
| tidb_enable_streaming | 0 |
| tidb_enable_table_partition | on |
| tidb_enable_vectorized_expression | 1 |
| tidb_enable_window_function | 1 |
| tidb_evolve_plan_baselines | off |
| tidb_evolve_plan_task_end_time | 23:59 +0000 |
| tidb_evolve_plan_task_max_time | 600 |
| tidb_evolve_plan_task_start_time | 00:00 +0000 |
| tidb_expensive_query_time_threshold | 60 |
| tidb_force_priority | NO_PRIORITY |
| tidb_general_log | 0 |
| tidb_hash_join_concurrency | 5 |
| tidb_hashagg_final_concurrency | 4 |
| tidb_hashagg_partial_concurrency | 4 |
| tidb_index_join_batch_size | 25000 |
| tidb_index_lookup_concurrency | 4 |
| tidb_index_lookup_join_concurrency | 4 |
| tidb_index_lookup_size | 20000 |
| tidb_index_serial_scan_concurrency | 1 |
| tidb_init_chunk_size | 32 |
| tidb_isolation_read_engines | tikv, tiflash, tidb |
| tidb_low_resolution_tso | 0 |
| tidb_max_chunk_size | 1024 |
| tidb_max_delta_schema_count | 1024 |
| tidb_mem_quota_hashjoin | 34359738368 |
| tidb_mem_quota_indexlookupjoin | 34359738368 |
| tidb_mem_quota_indexlookupreader | 34359738368 |
| tidb_mem_quota_mergejoin | 34359738368 |
| tidb_mem_quota_nestedloopapply | 34359738368 |
| tidb_mem_quota_query | 1073741824 |
| tidb_mem_quota_sort | 34359738368 |
| tidb_mem_quota_topn | 34359738368 |
| tidb_metric_query_range_duration | 60 |
| tidb_metric_query_step | 60 |
| tidb_opt_agg_push_down | 0 |
| tidb_opt_concurrency_factor | 3 |
| tidb_opt_copcpu_factor | 3 |
| tidb_opt_correlation_exp_factor | 1 |
| tidb_opt_correlation_threshold | 0.9 |
| tidb_opt_cpu_factor | 3 |
| tidb_opt_desc_factor | 3 |
| tidb_opt_disk_factor | 1.5 |
| tidb_opt_distinct_agg_push_down | 0 |
| tidb_opt_insubq_to_join_and_agg | 1 |
| tidb_opt_join_reorder_threshold | 0 |
| tidb_opt_memory_factor | 0.001 |
| tidb_opt_network_factor | 1 |
| tidb_opt_scan_factor | 1.5 |
| tidb_opt_seek_factor | 20 |
| tidb_opt_write_row_id | 0 |
| tidb_optimizer_selectivity_level | 0 |
| tidb_pprof_sql_cpu | 0 |
| tidb_projection_concurrency | 4 |
| tidb_query_log_max_len | 4096 |
| tidb_record_plan_in_slow_log | 1 |
| tidb_replica_read | leader |
| tidb_retry_limit | 10 |
| tidb_row_format_version | 2 |
| tidb_scatter_region | 0 |
| tidb_skip_isolation_level_check | 0 |
| tidb_skip_utf8_check | 0 |
| tidb_slow_log_threshold | 300 |
| tidb_slow_query_file | tidb-slow.log |
| tidb_snapshot | |
| tidb_stmt_summary_history_size | 24 |
| tidb_stmt_summary_internal_query | 0 |
| tidb_stmt_summary_max_sql_length | 4096 |
| tidb_stmt_summary_max_stmt_count | 200 |
| tidb_stmt_summary_refresh_interval | 1800 |
| tidb_store_limit | 0 |
| tidb_txn_mode | |
| tidb_use_plan_baselines | on |
| tidb_wait_split_region_finish | 1 |
| tidb_wait_split_region_timeout | 300 |
| tidb_window_concurrency | 4 |
+-------------------------------------+---------------------+
108 rows in set (0.01 sec)

mysql> SHOW GLOBAL VARIABLES LIKE 'time_zone%';
+---------------+--------+
Expand Down