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
26 changes: 26 additions & 0 deletions modules/n1ql/pages/n1ql-intro/sysinfo.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@
:description: {sqlpp} has a system namespace that stores metadata about data containers, the Query service, and the system as a whole. \
You can query the system namespace to get this information.

// Pass through HTML table styles for this page

ifdef::basebackend-html[]
++++
<style type="text/css">
/* No maximum width for table cells */
.doc table.spread > tbody > tr > *,
.doc table.stretch > tbody > tr > * {
max-width: none !important;
}

/* Ignore fixed column widths */
table:not(.fixed-width) col{
width: auto !important;
}

/* Do not hyphenate words in the table */
td.tableblock p,
p.tableblock{
hyphens: manual !important;
}
</style>
++++
endif::[]

[abstract]
{description}

Expand All @@ -29,6 +54,7 @@ xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#vitals[system:vitals]
xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#sys-active-req[system:active_requests]
xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#sys-prepared[system:prepareds]
xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#sys-completed-req[system:completed_requests]
xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#sys-history[system:completed_requests_history]

a| [%hardbreaks]
<<sys_my-user-info,system:my_user_info>>
Expand Down
259 changes: 259 additions & 0 deletions modules/n1ql/pages/n1ql-language-reference/metafun.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,265 @@ SELECT DS_VERSION() as server_version;
----
====

[[finderr,FINDERR()]]
== FINDERR(`expression`)

ifeval::['{page-component-version}' == '7.6']
[.status]#Couchbase Server 7.6.4#
endif::[]

=== Description

Returns the full details of any Query service or cbq shell error.

=== Arguments

expression:: One of the following:
+
--
* A number representing an error code.
In this case, the function returns the full details of the error matching the error code.

* A string.
In this case, the function searches for the target string in all of the error message fields except for `user_error`, and returns the full details of any errors that match the string.

* A regular expression.
In this case, the function searches for the regular expression in all of the error message fields except for `user_error`, and returns the full details of any errors that match the pattern.
--

=== Return Value

The return value is an array of one or more objects, each of which contains the details of an error that matches the find expression.

For each error, the function returns the following fields.

[options="header", cols="~a,~a,~a"]
|===
|Name|Description|Schema

|**applies_to** +
__required__
|One of the following:

* `cbq-shell`: The error applies to the cbq shell.
* `Server`: The error applies to the server.
|enum (cbq-shell, Server)

|**code** +
__required__
|A number representing the error.
|Integer

|**description** +
__required__
|Message describing why the error occurred.
|String

|**reason** +
__optional__
|List of possible causes of the error.
|String array

|**user_action** +
__optional__
|List of possible steps a user can take to mitigate the error.
|String array

|**user_error** +
__optional__
|One of the following:

* `Yes`: The error was caused by the user.
* `No`: The error was caused by other services, or was internal to the server.
* `Maybe`: A combination of both.
|enum (Yes, No, Maybe)
|===

NOTE: The error details also include a `symbol` field, which contains a representation string for the error.
This field is for internal use only, and is not shown in the results.
However, the FINDERR function does search this field when the find expression is a string or a regular expression.

=== Examples

[[finderr-ex1,FINDERR() Example 1]]
.Find error details by code number
====
.Query
[source,sqlpp]
----
SELECT FINDERR(5011);
----

.Results
[source,json]
----
[
{
"$1": [
{
"applies_to": "Server",
"code": 5011,
"description": "Abort: «reason»",
"reason": [
[
"The SQL++ abort() function was called in the statement.",
"e.g. SELECT abort('An example cause')"
]
],
"user_error": "Yes"
}
]
}
]
----
====

[[finderr-ex2,FINDERR() Example 2]]
.Find error details by matching a string
====
.Query
[source,sqlpp]
----
SELECT FINDERR("A semantic error is present in the statement.");
----

.Results
[source,json]
----
[
{
"$1": [
{
"applies_to": "Server",
"code": 3100,
"description": "A semantic error is present in the statement.",
"reason": [
"The statement includes portions that violate semantic constraints."
],
"user_action": [
"The cause will contain more detail on the violation; revise the statement and re-submit."
],
"user_error": "Yes"
}
]
}
]
----
====

[[finderr-ex3,FINDERR() Example 3]]
.Find multiple error details by matching a string
====
.Query
[source,sqlpp]
----
SELECT FINDERR("semantic");
----

.Results
[source,json]
----
[
{
"$1": [
{
"applies_to": "Server",
"code": 3100,
"description": "A semantic error is present in the statement.",
"reason": [
"The statement includes portions that violate semantic constraints."
],
"user_action": [
"The cause will contain more detail on the violation; revise the statement and re-submit."
],
"user_error": "Yes"
},
{
"applies_to": "Server",
"code": 3220,
"description": "«name» window function «clause» «reason»",
"reason": [
"A violation of the window function semantic restrictions was present in the statement."
],
"user_action": [
"Revise the statement to remove the violation."
],
"user_error": "Yes"
},
{
"applies_to": "Server",
"code": 3300,
"description": "recursive_with semantics: «cause»",
"reason": [
"The statement specifies restricted syntax in a recursive common table expression definition."
],
"user_action": [
"Revise the statement removing the restricted syntax."
],
"user_error": "Yes"
}
]
}
]
----
====

[[finderr-ex4,FINDERR() Example 4]]
.Find multiple error details by matching a regular expression
====
.Query
[source,sqlpp]
----
SELECT FINDERR("[IU][NP]SERT");
----

.Results
[source,json]
----
[
{
"$1": [
{
"applies_to": "Server",
"code": 3150,
"description": "MERGE with ON KEY clause cannot have document key specification in INSERT action.",
"reason": [
[
"A lookup merge statement specified a document key.",
"e.g. MERGE INTO default USING [{},{}] AS source ON KEY 'aaa' WHEN NOT MATCHED THEN INSERT ('key',{})"
]
],
"user_action": [
"Refer to the documentation for lookup merge statements."
],
"user_error": "Yes"
},
// ...
{
"applies_to": "Server",
"code": 5072,
"description": "No UPSERT key for «value»",
"user_action": [
"Contact support."
]
},
// ...
{
"applies_to": "Server",
"code": 15005,
"description": "No keys to insert «details»"
}
]
}
]
----
====

=== See Also

* The xref:cli:finderr.adoc[finderr] command line tool
* xref:n1ql:n1ql-language-reference/n1ql-error-codes.adoc[]

[[flatten_keys,FLATTEN_KEYS()]]
== FLATTEN_KEYS(`expr1` [ `modifiers` ], `expr2` [ `modifiers` ], ...)

Expand Down
35 changes: 31 additions & 4 deletions modules/n1ql/pages/n1ql-language-reference/sequenceops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ INSERT INTO bookings
====

[[ex-nextval-key]]
.Insert a sequential value in a document key
.Insert a sequential value in a document key and body
====
The following statement uses the `ordNum` sequence to generate the document key and a booking number within the body of the document.

Expand All @@ -201,6 +201,12 @@ INSERT INTO bookings
RETURNING META().id, *;
----

This query gives different results, depending on the version of Couchbase Server.

'''

[.status]##Couchbase Server 7.6&ndash;7.6.3##

.Results
[source,json]
----
Expand All @@ -215,12 +221,33 @@ INSERT INTO bookings
]
----

Since the key is not part of the document, the query has incremented the sequence twice.
This gives a different sequence number for the document key and the document value, which may not be what you want.
In versions of Couchbase Server prior to 7.6.4, the key is not regarded as part of the document, so this query increments the sequence twice.
This gives a different sequence number for the document key and the document value.

'''

[.status]#Couchbase Server 7.6.4#

.Results
[source,json]
----
[
{
"id": "1001",
"bookings": {
"num": 1001,
"user": 1
}
}
]
----

In Couchbase Server 7.6.4 and later, the entire VALUES clause (key, value, and options) is regarded as a single document, so the query only increments the sequence once.
This gives the same sequence number in the document key and the document value.
====

[[ex-nextval-same]]
.Insert the same sequential value in a document key and body
.Insert a sequential value with INSERT SELECT
====
The following statement uses an INSERT SELECT statement.
With this query, the document key and document value are both generated within the same document.
Expand Down
Loading