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 4 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> Alias: `transaction_isolation`<br><br>**Default**: `SERIALIZABLE` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below:

<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`.

(it's not an alias.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also btw this is now new in v2.0.

| `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><span class="version-tag">New in v2.0:</span> Alias: `transaction_priority`<br><br>**Default**: `NORMAL` |

## Examples

Expand Down
14 changes: 9 additions & 5 deletions v2.0/set-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ The variable name is case insensitive. The value can be a list of one or more it
| `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 |
| `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` | Yes |
| `server_version_num` | <span class="version-tag">New in v2.0:</span> The version of PostgreSQL that CockroachDB emulates. | Version-dependent | Yes |
| `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. <br><br><span class="version-tag">New in v2.0:</span> Alias: `"timezone"` | `UTC` | Yes |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable has been renamed.

This entire line must be replaced with:

| `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 was 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 level` | The isolation level of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details.<br><br><span class="version-tag">New in v2.0:</span> Alias: `transaction_isolation` | `SERIALIZABLE` | Yes |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variables have been renamed.

These three lines must be entirely replaced by:

| `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 was 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 was 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 was renamed for compatibility with PostgreSQL. | `NoTxn` | 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">New in v2.0:</span> Alias: `transaction_priority` | `NORMAL` | Yes |
| `transaction status` | The state of the current transaction. See [Transactions](transactions.html) for more details.<br><br><span class="version-tag">New in v2.0:</span> Alias: `transaction_status` | `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 |
Expand All @@ -54,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 @@ -159,7 +163,7 @@ 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.
`SET TIME ZONE` uses a special syntax form used to configure the `"timezone"` session parameter because `SET` cannot assign to parameter names containing spaces.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire line must be deleted as it is no longer accurate.


### Parameters

Expand All @@ -173,7 +177,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 @@ -185,7 +189,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
14 changes: 8 additions & 6 deletions v2.0/show-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ 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 |
| `time zone` | The default time zone for the current session. <br><br><span class="version-tag">New in v2.0:</span> Alias: `"timezone"` | `UTC` | Yes |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace:

| `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 was 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 level` | The isolation level of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details.<br><br><span class="version-tag">New in v2.0:</span> Alias: `transaction_isolation` | `SERIALIZABLE` | Yes |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take the 3 lines over from my comment on set-vars.md, adjusting the last column as needed.

| `transaction priority` | The priority of the current transaction. See [Transaction parameters](transactions.html#transaction-parameters) for more details.<br><br><span class="version-tag">New in v2.0:</span> Alias: `transaction_priority` | `NORMAL` | Yes |
| `transaction_read_only` | <span class="version-tag">New in v2.0:</span> (Reserved; exposed only for ORM compatibility.) | `off` | No |
| `transaction status` | The state of the current transaction. See [Transactions](transactions.html) for more details.<br><br><span class="version-tag">New in v2.0:</span> Alias: `transaction_status` | `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 @@ -60,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 @@ -103,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
4 changes: 3 additions & 1 deletion v2.0/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ In CockroachDB, the following are aliases for `STRING`:

- `CHARACTER`
- `CHAR`
- `"char"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is not accurate and should be removed. Just curious: why did you add it?

- `VARCHAR`
- `TEXT`

Expand All @@ -25,7 +26,8 @@ And the following are aliases for `STRING(n)`:
- `CHARACTER VARYING(n)`
- `CHAR(n)`
- `CHAR VARYING(n)`
- `VARCHAR(n)`
- `VARCHAR(n)`


## Length

Expand Down