Skip to content
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
44 changes: 23 additions & 21 deletions _data/sidebar_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ entries:
- title: Install Client Drivers
url: /install-client-drivers.html

- title: SQL Feature Support
url: /sql-feature-support.html

thirdlevel:
- title: SQL Statements
thirdlevelitems:
Expand Down Expand Up @@ -216,10 +219,27 @@ entries:
- title: <code>UPSERT</code>
url: /upsert.html

- title: SQL Grammar
url: /sql-grammar.html
- title: SQL Syntax
thirdlevelitems:

- title: Keywords & Identifiers
url: /keywords-and-identifiers.html

- title: Constants
url: /sql-constants.html

- title: Value Expressions
url: /sql-expressions.html

- title: Table Expressions
url: /table-expressions.html

- title: Name Resolution
url: /sql-name-resolution.html

- title: Full SQL Grammar
url: /sql-grammar.html

thirdlevel:
- title: Constraints
thirdlevelitems:

Expand Down Expand Up @@ -247,12 +267,6 @@ entries:
- title: Data Definition
thirdlevelitems:

- title: Keywords & Identifiers
url: /keywords-and-identifiers.html

- title: Constants
url: /sql-constants.html

- title: Indexes
url: /indexes.html

Expand Down Expand Up @@ -307,15 +321,6 @@ entries:
- title: <code>BYTES</code>
url: /bytes.html

- title: Expressions
thirdlevelitems:

- title: Value Expressions
url: /sql-expressions.html

- title: Table Expressions
url: /table-expressions.html

- title: Privileges
url: /privileges.html

Expand Down Expand Up @@ -422,9 +427,6 @@ entries:
- title: CockroachDB in Comparison
url: /cockroachdb-in-comparison.html

- title: SQL Feature Support
url: /sql-feature-support.html

- title: CockroachDB Architecture
url: /cockroachdb-architecture.html

Expand Down
11 changes: 9 additions & 2 deletions show-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Variable | Description
------|------------
`DATABASE` | The default database for the current session, as set by [`SET DATABASE`](set-database.html) or the client's connection string. This variable can be viewed with [`SHOW DATABASE`](show-database.html) as well.
`DEFAULT_TRANSACTION_ISOLATION` | The default transaction isolation level for the current session, as set by `SET DEFAULT_TRANSACTION_ISOLATION` or the client's connection string.
`MAX_INDEX_KEYS` | Not usable; exposed only for ORM compatibility.
`SEARCH_PATH` | A list of databases or namespaces that will be searched to resolve unqualified table or function names. For more details, see [Name Resolution](sql-name-resolution.html).
`SERVER_VERSION` | The version of PostgreSQL that CockroachDB emulates.
`SYNTAX` | The default SQL syntax for the current session, as set by `SET SYNTAX`. This variable can be viewed with `SHOW SYNTAX` as well.
`TIME ZONE` | The default time zone for the current session, as set by [`SET TIME ZONE`](set-time-zone.html). This variable can be viewed with [`SHOW TIME ZONE`](show-time-zone.html) as well.
`TRANSACTION ISOLATION LEVEL` | The isolation level of the current transaction, as set by [`SET TRANSACTION ISOLATION LEVEL`](set-transaction.html). When run in the context of a transaction, [`SHOW TRANSACTION ISOLATION LEVEL`](show-transaction.html) returns this variable as well.<br><br>This will differ from `DEFAULT_TRANSACTION_ISOLATION` only when `SHOW ALL` is run in the context of a transaction and `SET TRANSACTION ISOLATION LEVEL` has been used to set a non-default isolation level for the specific transaction.
Expand All @@ -34,18 +37,22 @@ Variable | Description
~~~ sql
> SHOW ALL;
~~~

~~~
+-------------------------------+--------------+
| Variable | Value |
+-------------------------------+--------------+
| DATABASE | bank |
| DATABASE | test |
| DEFAULT_TRANSACTION_ISOLATION | SERIALIZABLE |
| MAX_INDEX_KEYS | 32 |
| SEARCH_PATH | pg_catalog |
| SERVER_VERSION | 9.5.0 |
| SYNTAX | Traditional |
| TIME ZONE | UTC |
| TRANSACTION ISOLATION LEVEL | SERIALIZABLE |
| TRANSACTION PRIORITY | NORMAL |
+-------------------------------+--------------+
(6 rows)
(9 rows)
~~~

## See Also
Expand Down
19 changes: 8 additions & 11 deletions sql-name-resolution.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ toc: false
A SQL client can have access to multiple databases side-by-side. The
same table name (e.g., `orders`) can exist in multiple
databases. When a query specifies a table name without a database
name (e.g., `select * from orders`), how does CockroachDB know
name (e.g., `SELECT * FROM orders`), how does CockroachDB know
which `orders` table is being considered?

This page details how CockroachDB performs *name resolution* to answer
This page details how CockroachDB performs **name resolution** to answer
this question.

<div id="toc"></div>

## Overview

The following *name resolution algorithm* is used both to determine
The following **name resolution algorithm** is used both to determine
table names in [table expressions](table-expressions.html) and
function names in [value expressions](sql-expressions.html):

Expand All @@ -28,23 +28,20 @@ function names in [value expressions](sql-expressions.html):
- Try to find the name using the [search path](#search-path).
- If the name is not found, produce an error.

## Search path
## Search Path

In addition to the default database configurable via [`SET DATABASE`](set-database.html),
unqualified names are also looked up in the current session's *search path*.
In addition to the default database configurable via [`SET DATABASE`](set-database.html), unqualified names are also looked up in the current session's *search path*.

The search path is a session variable containing a list of databases,
or *name spaces*, where names are looked up.
or *namespaces*, where names are looked up.

The current search path can be inspected using the statement `SHOW
SEARCH_PATH`, or [`SHOW ALL`](show-all.html).
The current search path can be inspected using the statement `SHOW SEARCH_PATH`, or [`SHOW ALL`](show-all.html).

By default, the search path for new columns includes just
`pg_catalog`, so that queries can use PostgreSQL compatibility
functions and virtual tables in that namespace without the need to
prefix them with "`pg_catalog.`" every time.

## See also
## See Also

- [List of predefined databases](predefined-namespaces.html)
- [`SET DATABASE`](set-database.html)