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