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

Edits for Postgres compatibility #2887

Merged
merged 8 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions v2.0/set-transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ No [privileges](privileges.html) are required to set the transaction isolation l

| Parameter | Description |
|-----------|-------------|
| `ISOLATION LEVEL` | By default, transactions in CockroachDB implement the strongest ANSI isolation level: `SERIALIZABLE`. At this isolation level, transactions will never result in anomalies. The `SNAPSHOT` isolation level is still supported as well for backwards compatibility, but you should avoid using it. It provides little benefit in terms of performance and can result in inconsistent state under certain complex workloads. For more information, see [Transactions: Isolation Levels](transactions.html#isolation-levels).<br/><br/>**Default**: `SERIALIZABLE` |
| `PRIORITY` | If you don't want the transaction to run with `NORMAL` priority, you can set it to `LOW` or `HIGH`.<br/><br/>Transactions with higher priority are less likely to need to be retried.<br/><br/>For more information, see [Transactions: Priorities](transactions.html#transaction-priorities).<br/><br/>**Default**: `NORMAL` |
| `ISOLATION LEVEL` | By default, transactions in CockroachDB implement the strongest ANSI isolation level: `SERIALIZABLE`. At this isolation level, transactions will never result in anomalies. The `SNAPSHOT` isolation level is still supported as well for backwards compatibility, but you should avoid using it. It provides little benefit in terms of performance and can result in inconsistent state under certain complex workloads. For more information, see [Transactions: Isolation Levels](transactions.html#isolation-levels).<br><br><span class="version-tag">New in v2.0:</span> The current isolation level is also exposed as the [session variable](show-vars.html) `transaction_isolation`.<br><br>**Default**: `SERIALIZABLE` |
| `PRIORITY` | If you don't want the transaction to run with `NORMAL` priority, you can set it to `LOW` or `HIGH`.<br><br>Transactions with higher priority are less likely to need to be retried.<br><br>For more information, see [Transactions: Priorities](transactions.html#transaction-priorities).<br><br>The current priority is also exposed as the [session variable](show-vars.html) `transaction_priority`.<br><br>**Default**: `NORMAL` |

## Examples

Expand Down
39 changes: 20 additions & 19 deletions v2.0/set-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ The variable name is case insensitive. The value can be a list of one or more it

### Supported Variables

| Variable name | Description | Initial value |
|---------------|--------------|---------------|
| `application_name` | The current application name for statistics collection. | Empty string |
| `database` | The [current database](sql-name-resolution.html#current-database). | Database in connection string, or empty if not specified |
| `default_transaction_isolation` | The default transaction isolation level for the current session. See [Transaction parameters](transactions.html#transaction-parameters) and [`SET TRANSACTION`](set-transaction.html) for more details. | Settings in connection string, or "`SERIALIZABLE`" if not specified |
| `sql_safe_updates` | If `true`, disallow potentially unsafe SQL statements, including `DELETE` without a `WHERE` clause, `UPDATE` without a `WHERE` clause, and `ALTER TABLE ... DROP COLUMN`. See [Allow Potentially Unsafe SQL Statements](use-the-built-in-sql-client.html#allow-potentially-unsafe-sql-statements) for more details. | `true` for interactive sessions from the [built-in SQL client](use-the-built-in-sql-client.html) unless `--safe-updates=false` is specified,<br>`false` for sessions from other clients |
| `search_path` | <span class="version-tag">Changed in v2.0:</span> A list of schemas that will be searched to resolve unqualified table or function names. For more details, see [Name Resolution](sql-name-resolution.html). | "`{public}`" |
| `time zone` | The default time zone for the current session.<br><br>This value can be a string representation of a local system-defined time zone (e.g., `'EST'`, `'America/New_York'`) or a positive or negative numeric offset from UTC (e.g., `-7`, `+7`). Also, `DEFAULT`, `LOCAL`, or `0` sets the session time zone to `UTC`.</br><br>See [`SET TIME ZONE`](#set-time-zone) for more details. | `UTC` |
| `tracing` | The trace recording state.<br><br>See [`SET TRACING`](#set-tracing) for more details. | `off` |
| `client_encoding` | Ignored; recognized for compatibility with PostgreSQL clients. Only possible value is "`UTF8`". | N/A |
| `client_min_messages` | Ignored; recognized for compatibility with PostgreSQL clients. | N/A |
| `extra_float_digits` | Ignored; recognized for compatibility with PostgreSQL clients. | N/A |
| `intervalstyle` | <span class="version-tag">New in v2.0:</span> Ignored; recognized for compatibility with PostgreSQL clients. Only possible value is "`postgres`". | N/A |
| `standard_conforming_strings` | Ignored; recognized for compatibility with PostgreSQL clients. Only possible value is "`on`". | N/A |
| Variable name | Description | Initial value | Can be viewed with [`SHOW`](show-vars.html)? |
|---------------|--------------|---------------|----------------------------------------------|
| `application_name` | The current application name for statistics collection. | Empty string | Yes |
| `database` | The [current database](sql-name-resolution.html#current-database). | Database in connection string, or empty if not specified | Yes |
| `default_transaction_isolation` | The default transaction isolation level for the current session. See [Transaction parameters](transactions.html#transaction-parameters) and [`SET TRANSACTION`](set-transaction.html) for more details. | Settings in connection string, or "`SERIALIZABLE`" if not specified | Yes |
| `sql_safe_updates` | If `true`, disallow potentially unsafe SQL statements, including `DELETE` without a `WHERE` clause, `UPDATE` without a `WHERE` clause, and `ALTER TABLE ... DROP COLUMN`. See [Allow Potentially Unsafe SQL Statements](use-the-built-in-sql-client.html#allow-potentially-unsafe-sql-statements) for more details. | `true` for interactive sessions from the [built-in SQL client](use-the-built-in-sql-client.html) unless `--safe-updates=false` is specified,<br>`false` for sessions from other clients | Yes |
| `search_path` | <span class="version-tag">Changed in v2.0:</span> A list of schemas that will be searched to resolve unqualified table or function names. For more details, see [Name Resolution](sql-name-resolution.html). | "`{public}`" | Yes |
| `server_version_num` | <span class="version-tag">New in v2.0:</span> The version of PostgreSQL that CockroachDB emulates. | Version-dependent | Yes |
| `timezone` | The default time zone for the current session.<br><br>This value can be a string representation of a local system-defined time zone (e.g., `'EST'`, `'America/New_York'`) or a positive or negative numeric offset from UTC (e.g., `-7`, `+7`). Also, `DEFAULT`, `LOCAL`, or `0` sets the session time zone to `UTC`.</br><br>See [Setting the Time Zone](#set-time-zone) for more details. <br><br><span class="version-tag">Changed in v2.0:</span> This session variable was named `"time zone"` (with a space) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL. | `UTC` | Yes |
| `tracing` | The trace recording state.<br><br>See [`SET TRACING`](#set-tracing) for more details. | `off` | Yes |
| `transaction_isolation` | The isolation level of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details.<br><br><span class="version-tag">Changed in v2.0:</span> This session variable was called `transaction isolation level` (with spaces) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL. | `SERIALIZABLE` | Yes |
| `transaction_priority` | The priority of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details.<br><br><span class="version-tag">Changed in v2.0:</span> This session variable was called `transaction priority` (with a space) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL. | `NORMAL` | Yes |
| `transaction_status` | The state of the current transaction. See [Transactions](transactions.html) for more details.<br><br><span class="version-tag">Changed in v2.0:</span> This session variable was called `transaction status` (with a space) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL. | `NoTxn` | Yes |
| `client_encoding` | Ignored; recognized for compatibility with PostgreSQL clients. Only possible value is "`UTF8`". | N/A | No |
| `client_min_messages` | Ignored; recognized for compatibility with PostgreSQL clients. Only possible value is "`on`". | N/A | No |
| `extra_float_digits` | Ignored; recognized for compatibility with PostgreSQL clients. | N/A | No |
| `standard_conforming_strings` | Ignored; recognized for compatibility with PostgreSQL clients. | N/A | No |

Special syntax cases:

Expand All @@ -55,7 +58,7 @@ Special syntax cases:
| `USE ...` | `SET database = ...` | This is provided as convenience for users with a MySQL/MSSQL background.
| `SET NAMES ...` | `SET client_encoding = ...` | This is provided for compatibility with PostgreSQL clients.
| `SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ...` | `SET default_transaction_isolation = ...` | This is provided for compatibility with standard SQL.
| `SET TIME ZONE ...` | `SET "time zone" = ...` | This is provided for compatibility with PostgreSQL clients.
| `SET TIME ZONE ...` | `SET timezone = ...` | This is provided for compatibility with PostgreSQL clients.

## Examples

Expand Down Expand Up @@ -160,8 +163,6 @@ You can control your client's default time zone for the current session with <co

{{site.data.alerts.callout_info}}With setting <code>SET TIME ZONE</code>, CockroachDB uses UTC as the default time zone.{{site.data.alerts.end}}

`SET TIME ZONE` uses a special syntax form used to configure the `"time zone"` session parameter because `SET` cannot assign to parameter names containing spaces.

### Parameters

The time zone value indicates the time zone for the current session.
Expand All @@ -174,7 +175,7 @@ negative numeric offset from UTC (e.g., `-7`, `+7`). Also, `DEFAULT`,
### Example: Set the Default Time Zone via `SET TIME ZONE`

~~~ sql
> SET TIME ZONE 'EST'; -- same as SET "time zone" = 'EST'
> SET TIME ZONE 'EST'; -- same as SET "timezone" = 'EST'
> SHOW TIME ZONE;
~~~
~~~ shell
Expand All @@ -186,7 +187,7 @@ negative numeric offset from UTC (e.g., `-7`, `+7`). Also, `DEFAULT`,
(1 row)
~~~
~~~ sql
> SET TIME ZONE DEFAULT; -- same as SET "time zone" = DEFAULT
> SET TIME ZONE DEFAULT; -- same as SET "timezone" = DEFAULT
> SHOW TIME ZONE;
~~~
~~~ shell
Expand Down
13 changes: 7 additions & 6 deletions v2.0/show-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ The variable name is case insensitive. It may be enclosed in double quotes; this
| `node_id` | <span class="version-tag">New in v1.1:</span> The ID of the node currently connected to.<br><br>This variable is particularly useful for verifying load balanced connections. | Node-dependent | No |
| `search_path` | <span class="version-tag">Changed in v2.0:</span> A list of schemas that will be searched to resolve unqualified table or function names. For more details, see [Name Resolution](sql-name-resolution.html). | `{public}` | Yes |
| `server_version` | The version of PostgreSQL that CockroachDB emulates. | Version-dependent | No |
| `server_version_num` | <span class="version-tag">New in v2.0:</span> The version of PostgreSQL that CockroachDB emulates. | Version-dependent | Yes |
| `session_user` | The user connected for the current session. | User in connection string | No |
| `sql_safe_updates` | If `false`, potentially unsafe SQL statements are allowed, including `DROP` of a non-empty database and all dependent objects, `DELETE` without a `WHERE` clause, `UPDATE` without a `WHERE` clause, and `ALTER TABLE .. DROP COLUMN`. See [Allow Potentially Unsafe SQL Statements](use-the-built-in-sql-client.html#allow-potentially-unsafe-sql-statements) for more details. | `true` for interactive sessions from the [built-in SQL client](use-the-built-in-sql-client.html),<br>`false` for sessions from other clients | Yes |
| `time zone` | The default time zone for the current session | `UTC` | Yes |
| `timezone` | The default time zone for the current session. <br><br><span class="version-tag">Changed in v2.0:</span> This session variable was named `"time zone"` (with a space) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL. | `UTC` | Yes |
| `tracing` | | `off` | |
| `transaction isolation level` | The isolation level of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details. | `SERIALIZABLE` | Yes |
| `transaction priority` | The priority of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details. | `NORMAL` | Yes |
| `transaction status` | The state of the current transaction. See [Transactions](transactions.html) for more details. | `NoTxn` | No |
| `transaction_isolation` | The isolation level of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details.<br><br><span class="version-tag">Changed in v2.0:</span> This session variable was called `transaction isolation level` (with spaces) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL. | `SERIALIZABLE` | Yes |
| `transaction_priority` | The priority of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details.<br><br><span class="version-tag">Changed in v2.0:</span> This session variable was called `transaction priority` (with a space) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL. | `NORMAL` | Yes |
| `transaction_status` | The state of the current transaction. See [Transactions](transactions.html) for more details.<br><br><span class="version-tag">Changed in v2.0:</span> This session variable was called `transaction status` (with a space) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL. | `NoTxn` | No |
| `client_encoding` | (Reserved; exposed only for ORM compatibility.) | `UTF8` | No |
| `client_min_messages` | (Reserved; exposed only for ORM compatibility.) | (Reserved) | No |
| `datestyle` | (Reserved; exposed only for ORM compatibility.) | `ISO` | No |
Expand All @@ -61,7 +62,7 @@ Special syntax cases supported for compatibility:
|--------|---------------|
| `SHOW TRANSACTION PRIORITY` | `SHOW "transaction priority"` |
| `SHOW TRANSACTION ISOLATION LEVEL` | `SHOW "transaction isolation level"` |
| `SHOW TIME ZONE` | `SHOW "time zone"` |
| `SHOW TIME ZONE` | `SHOW "timezone"` |
| `SHOW TRANSACTION STATUS` | `SHOW "transaction status"` |

## Examples
Expand Down Expand Up @@ -104,7 +105,7 @@ Special syntax cases supported for compatibility:
| server_version | 9.5.0 |
| session_user | root |
| standard_conforming_strings | on |
| time zone | UTC |
| timezone | UTC |
| transaction isolation level | SERIALIZABLE |
| transaction priority | NORMAL |
| transaction status | NoTxn |
Expand Down
3 changes: 2 additions & 1 deletion v2.0/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ And the following are aliases for `STRING(n)`:
- `CHARACTER VARYING(n)`
- `CHAR(n)`
- `CHAR VARYING(n)`
- `VARCHAR(n)`
- `VARCHAR(n)`


## Length

Expand Down