You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/n1ql/pages/n1ql-language-reference/metafun.adoc
+256Lines changed: 256 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -331,6 +331,262 @@ SELECT DS_VERSION() as server_version;
331
331
----
332
332
====
333
333
334
+
[[finderr,FINDERR()]]
335
+
== FINDERR(`expression`)
336
+
337
+
[.status]#Couchbase Server 7.6.5#
338
+
339
+
=== Description
340
+
341
+
Returns the full details of any Query service or cbq shell error.
342
+
343
+
=== Arguments
344
+
345
+
expression:: One of the following:
346
+
+
347
+
--
348
+
* A number representing an error code.
349
+
In this case, the function returns the full details of the error matching the error code.
350
+
351
+
* A string.
352
+
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.
353
+
354
+
* A regular expression.
355
+
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.
356
+
--
357
+
358
+
=== Return Value
359
+
360
+
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.
361
+
362
+
For each error, the function returns the following fields.
363
+
364
+
[options="header", cols="~a,~a,~a"]
365
+
|===
366
+
|Name|Description|Schema
367
+
368
+
|**applies_to** +
369
+
__required__
370
+
|One of the following:
371
+
372
+
* `cbq-shell`: The error applies to the cbq shell.
373
+
* `Server`: The error applies to the server.
374
+
|enum (cbq-shell, Server)
375
+
376
+
|**code** +
377
+
__required__
378
+
|A number representing the error.
379
+
|Integer
380
+
381
+
|**description** +
382
+
__required__
383
+
|Message describing why the error occurred.
384
+
|String
385
+
386
+
|**reason** +
387
+
__optional__
388
+
|List of possible causes of the error.
389
+
|String array
390
+
391
+
|**user_action** +
392
+
__optional__
393
+
|List of possible steps a user can take to mitigate the error.
394
+
|String array
395
+
396
+
|**user_error** +
397
+
__optional__
398
+
|One of the following:
399
+
400
+
* `Yes`: The error was caused by the user.
401
+
* `No`: The error was caused by other services, or was internal to the server.
402
+
* `Maybe`: A combination of both.
403
+
|enum (Yes, No, Maybe)
404
+
|===
405
+
406
+
NOTE: The error details also include a `symbol` field, which contains a representation string for the error.
407
+
This field is for internal use only, and is not shown in the results.
408
+
However, the FINDERR function does search this field when the find expression is a string or a regular expression.
409
+
410
+
=== Examples
411
+
412
+
[[finderr-ex1,FINDERR() Example 1]]
413
+
.Find error details by code number
414
+
====
415
+
.Query
416
+
[source,sqlpp]
417
+
----
418
+
SELECT FINDERR(5011);
419
+
----
420
+
421
+
.Results
422
+
[source,json]
423
+
----
424
+
[
425
+
{
426
+
"$1": [
427
+
{
428
+
"applies_to": "Server",
429
+
"code": 5011,
430
+
"description": "Abort: «reason»",
431
+
"reason": [
432
+
[
433
+
"The SQL++ abort() function was called in the statement.",
434
+
"e.g. SELECT abort('An example cause')"
435
+
]
436
+
],
437
+
"user_error": "Yes"
438
+
}
439
+
]
440
+
}
441
+
]
442
+
----
443
+
====
444
+
445
+
[[finderr-ex2,FINDERR() Example 2]]
446
+
.Find error details by matching a string
447
+
====
448
+
.Query
449
+
[source,sqlpp]
450
+
----
451
+
SELECT FINDERR("A semantic error is present in the statement.");
452
+
----
453
+
454
+
.Results
455
+
[source,json]
456
+
----
457
+
[
458
+
{
459
+
"$1": [
460
+
{
461
+
"applies_to": "Server",
462
+
"code": 3100,
463
+
"description": "A semantic error is present in the statement.",
464
+
"reason": [
465
+
"The statement includes portions that violate semantic constraints."
466
+
],
467
+
"user_action": [
468
+
"The cause will contain more detail on the violation; revise the statement and re-submit."
469
+
],
470
+
"user_error": "Yes"
471
+
}
472
+
]
473
+
}
474
+
]
475
+
----
476
+
====
477
+
478
+
[[finderr-ex3,FINDERR() Example 3]]
479
+
.Find multiple error details by matching a string
480
+
====
481
+
.Query
482
+
[source,sqlpp]
483
+
----
484
+
SELECT FINDERR("semantic");
485
+
----
486
+
487
+
.Results
488
+
[source,json]
489
+
----
490
+
[
491
+
{
492
+
"$1": [
493
+
{
494
+
"applies_to": "Server",
495
+
"code": 3100,
496
+
"description": "A semantic error is present in the statement.",
497
+
"reason": [
498
+
"The statement includes portions that violate semantic constraints."
499
+
],
500
+
"user_action": [
501
+
"The cause will contain more detail on the violation; revise the statement and re-submit."
502
+
],
503
+
"user_error": "Yes"
504
+
},
505
+
{
506
+
"applies_to": "Server",
507
+
"code": 3220,
508
+
"description": "«name» window function «clause» «reason»",
509
+
"reason": [
510
+
"A violation of the window function semantic restrictions was present in the statement."
0 commit comments