diff --git a/modules/n1ql/pages/n1ql-language-reference/metafun.adoc b/modules/n1ql/pages/n1ql-language-reference/metafun.adoc index ca796b3bb..d8ea65dca 100644 --- a/modules/n1ql/pages/n1ql-language-reference/metafun.adoc +++ b/modules/n1ql/pages/n1ql-language-reference/metafun.adoc @@ -428,7 +428,8 @@ SELECT `Flavor` FROM EVALUATE("INFER `travel-sample`")[0] inf; === Description This function extracts Data Definition Language (DDL) statements of buckets and returns them as an array of strings. -It retrieves definitions for buckets, scopes, collections, indexes, and sequences. +It retrieves definitions for buckets, scopes, collections, indexes, sequences, functions, and prepared statements. + You can use these definitions for purposes such as replication, backup, or auditing. The function supports the following statements: @@ -438,6 +439,8 @@ The function supports the following statements: * CREATE COLLECTION * CREATE INDEX * CREATE SEQUENCE +* CREATE FUNCTION [.status]#Couchbase Server 8.0.1# +* PREPARE [.status]#Couchbase Server 8.0.1# NOTE: To execute this function, you must have the `query_system_catalog` role. Also, to extract DDLs from a specific bucket, you need necessary permissions on that bucket. @@ -489,6 +492,17 @@ Accepts either a numeric value or an array of strings, but not both. ! CREATE SEQUENCE ! `"sequence"` ! `16` + +! CREATE OR REPLACE FUNCTION + +[.status]#Couchbase Server 8.0.1# + +! `"function"` +! `32` + +! PREPARE + +[.status]#Couchbase Server 8.0.1# +! `"prepared"` +! `64` !=== To extract multiple statement types, specify an array of their string values or a single numeric value that represents the sum of their respective numeric values. @@ -591,6 +605,32 @@ In this query, the value `3` represents the sum of the flags for bucket (`1`) an ---- ==== +[[finderr-ex4,EXTRACTDDL() Example 4]] +.Extracting CREATE FUNCTION and PREPARE statements from the `travel-sample` bucket +==== +.Query +[source,sqlpp] +---- +SELECT extractddl("travel-sample",{"flags":["function","prepared"]}); +---- +.Results +[source,json] +---- +[ + { + "$1": [ + "CREATE OR REPLACE FUNCTION `celsius`(...) + LANGUAGE INLINE AS (args[0] - 32) * 5/9;", + "PREPARE SELECT * FROM route\n + WHERE airline = \"FL\";", + "PREPARE NameParam AS\nSELECT * FROM hotel\n + WHERE city=$city AND country=$country;" + ] + } +] +---- +==== + [[finderr,FINDERR()]] == FINDERR(`expression`)