@@ -43,6 +43,81 @@ type DatabaseQuery interface {
4343
4444 // ExplainQuery explains an AQL query and return information about it.
4545 ExplainQuery (ctx context.Context , query string , bindVars map [string ]interface {}, opts * ExplainQueryOptions ) (ExplainQueryResult , error )
46+
47+ // GetQueryProperties returns the properties of the query system.
48+ GetQueryProperties (ctx context.Context ) (QueryProperties , error )
49+
50+ // UpdateQueryProperties updates the properties of the query system.
51+ // The properties are updated with the provided options.
52+ // The updated properties are returned.
53+ UpdateQueryProperties (ctx context.Context , options QueryProperties ) (QueryProperties , error )
54+
55+ // ListOfRunningAQLQueries returns a list of currently running AQL queries.
56+ // If the all parameter is set to true, it returns all queries, otherwise only the queries that are currently running.
57+ // The result is a list of RunningAQLQuery objects.
58+ ListOfRunningAQLQueries (ctx context.Context , all * bool ) ([]RunningAQLQuery , error )
59+
60+ // ListOfSlowAQLQueries returns a list of slow AQL queries.
61+ // If the all parameter is set to true, it returns all slow queries, otherwise only the queries that are currently running.
62+ // The result is a list of RunningAQLQuery objects.
63+ // Slow queries are defined as queries that have been running longer than the configured slow query threshold.
64+ // The slow query threshold can be configured in the query properties.
65+ // The result is a list of RunningAQLQuery objects.
66+ ListOfSlowAQLQueries (ctx context.Context , all * bool ) ([]RunningAQLQuery , error )
67+
68+ // ClearSlowAQLQueries clears the list of slow AQL queries.
69+ // If the all parameter is set to true, it clears all slow queries, otherwise only
70+ // the queries that are currently running.
71+ ClearSlowAQLQueries (ctx context.Context , all * bool ) error
72+
73+ // KillAQLQuery kills a running AQL query.
74+ // The queryId is the unique identifier of the query
75+ KillAQLQuery (ctx context.Context , queryId string , all * bool ) error
76+
77+ // GetAllOptimizerRules returns all optimizer rules available in the database.
78+ // The result is a list of OptimizerRule objects.
79+ GetAllOptimizerRules (ctx context.Context ) ([]OptimizerRules , error )
80+
81+ // GetQueryPlanCache returns a list of cached query plans.
82+ // The result is a list of QueryPlanCacheRespObject objects.
83+ GetQueryPlanCache (ctx context.Context ) ([]QueryPlanCacheRespObject , error )
84+
85+ // ClearQueryPlanCache clears the query plan cache.
86+ ClearQueryPlanCache (ctx context.Context ) error
87+
88+ // GetQueryEntriesCache returns a list of cached query entries.
89+ // The result is a list of QueryCacheEntriesRespObject objects.
90+ GetQueryEntriesCache (ctx context.Context ) ([]QueryCacheEntriesRespObject , error )
91+
92+ // ClearQueryCache clears the query cache.
93+ // This will remove all cached query entries.
94+ ClearQueryCache (ctx context.Context ) error
95+
96+ // GetQueryCacheProperties returns the properties of the query cache.
97+ // The result is a QueryCacheProperties object.
98+ GetQueryCacheProperties (ctx context.Context ) (QueryCacheProperties , error )
99+
100+ // SetQueryCacheProperties sets the properties of the query cache.
101+ // The properties are updated with the provided options.
102+ SetQueryCacheProperties (ctx context.Context , options QueryCacheProperties ) (QueryCacheProperties , error )
103+
104+ // CreateUserDefinedFunction creates a user-defined function in the database.
105+ // The function is created with the provided options.
106+ // The function is created in the system collection `_aqlfunctions`.
107+ // The function is created with the provided code and name.
108+ // If the function already exists, it will be updated with the new code.
109+ CreateUserDefinedFunction (ctx context.Context , options UserDefinedFunctionObject ) (bool , error )
110+
111+ // DeleteUserDefinedFunction removes a user-defined AQL function from the current database.
112+ // If group is true, all functions with the given name as a namespace prefix will be deleted.
113+ // If group is false, only the function with the fully qualified name will be removed.
114+ // It returns the number of functions deleted.
115+ DeleteUserDefinedFunction (ctx context.Context , name * string , group * bool ) (* int , error )
116+
117+ // GetUserDefinedFunctions retrieves all user-defined AQL functions registered in the current database.
118+ // It returns a list of UserDefinedFunctionObject, each containing the function's name, code, and isDeterministic.
119+ // The returned list may be empty array if no user-defined functions are registered.
120+ GetUserDefinedFunctions (ctx context.Context ) ([]UserDefinedFunctionObject , error )
46121}
47122
48123type QuerySubOptions struct {
@@ -330,3 +405,129 @@ type ExplainQueryResult struct {
330405 // This attribute is not present when allPlans is set to true.
331406 Cacheable * bool `json:"cacheable,omitempty"`
332407}
408+
409+ type QueryProperties struct {
410+ Enabled * bool `json:"enabled"`
411+ TrackSlowQueries * bool `json:"trackSlowQueries"`
412+ TrackBindVars * bool `json:"trackBindVars"`
413+ MaxSlowQueries * int `json:"maxSlowQueries"`
414+ SlowQueryThreshold * float64 `json:"slowQueryThreshold"`
415+ MaxQueryStringLength * int `json:"maxQueryStringLength"`
416+ }
417+
418+ type RunningAQLQuery struct {
419+ // The unique identifier of the query.
420+ Id * string `json:"id,omitempty"`
421+ // The database in which the query is running.
422+ Database * string `json:"database,omitempty"`
423+ // The user who executed the query.
424+ // This is the user who executed the query, not the user who is currently running the
425+ User * string `json:"user,omitempty"`
426+ // The query string.
427+ // This is the AQL query string that was executed.
428+ Query * string `json:"query,omitempty"`
429+ // The bind variables used in the query.
430+ BindVars * map [string ]interface {} `json:"bindVars,omitempty"`
431+ // The time when the query started executing.
432+ // This is the time when the query started executing on the server.
433+ Started * string `json:"started,omitempty"`
434+ // The time when the query was last updated.
435+ // This is the time when the query was last updated on the server.
436+ RunTime * float64 `json:"runTime,omitempty"`
437+ // The PeakMemoryUsage is the peak memory usage of the query in bytes.
438+ PeakMemoryUsage * uint64 `json:"peakMemoryUsage,omitempty"`
439+ // The State of the query.
440+ // This is the current state of the query, e.g. "running", "finished", "executing", etc.
441+ State * string `json:"state,omitempty"`
442+ // The stream option indicates whether the query is executed in streaming mode.
443+ Stream * bool `json:"stream,omitempty"`
444+ }
445+
446+ type Flags struct {
447+ // CanBeDisabled indicates whether the query can be disabled.
448+ CanBeDisabled * bool `json:"canBeDisabled,omitempty"`
449+ // CanBeExecuted indicates whether the query can be executed.
450+ CanCreateAdditionalPlans * bool `json:"canCreateAdditionalPlans,omitempty"`
451+ //ClusterOnly indicates whether the query is only available in a cluster environment.
452+ ClusterOnly * bool `json:"clusterOnly,omitempty"`
453+ // DisabledByDefault indicates whether the query is disabled by default.
454+ // This means that the query is not executed unless explicitly enabled.
455+ DisabledByDefault * bool `json:"disabledByDefault,omitempty"`
456+ // EnterpriseOnly indicates whether the query is only available in the Enterprise Edition.
457+ EnterpriseOnly * bool `json:"enterpriseOnly,omitempty"`
458+ // Hidden indicates whether the query is hidden from the user.
459+ Hidden * bool `json:"hidden,omitempty"`
460+ }
461+
462+ type OptimizerRules struct {
463+ // Name of the optimizer rule.
464+ Name string `json:"name,omitempty"`
465+ Flags `json:"flags,omitempty"`
466+ }
467+
468+ type CacheRespObject struct {
469+ // BindVars are the bind variables used in the query.
470+ BindVars map [string ]interface {} `json:"bindVars,omitempty"`
471+ // DataSources is a list of data sources used in the query.
472+ DataSources * []string `json:"dataSources,omitempty"`
473+ // Hash is the plan cache key.
474+ Hash * string `json:"hash,omitempty"`
475+ // Hits is the number of times the cached plan has been utilized so far.
476+ Hits * uint32 `json:"hits,omitempty"`
477+ // Query is the AQL query string.
478+ Query * string `json:"query,omitempty"`
479+ }
480+
481+ type QueryPlanCacheRespObject struct {
482+ CacheRespObject `json:",inline"`
483+ // QueryHash is the hash of the AQL query string.
484+ QueryHash * uint32 `json:"queryHash,omitempty"`
485+ // FullCount indicates whether the query result contains the full count of documents.
486+ FullCount * bool `json:"fullCount,omitempty"`
487+ // Created is the time when the query plan has been added to the cache.
488+ Created * string `json:"created,omitempty"`
489+ // MemoryUsage is the memory usage of the cached plan in bytes.
490+ // This is the amount of memory used by the cached plan on the server.
491+ MemoryUsage * uint64 `json:"memoryUsage,omitempty"`
492+ }
493+
494+ type QueryCacheEntriesRespObject struct {
495+ CacheRespObject `json:",inline"`
496+ // Result is the number of documents in the query result.
497+ Results * uint32 `json:"results,omitempty"`
498+ // RunTime is the time it took to execute the query in seconds.
499+ RunTime string `json:"runTime,omitempty"`
500+ // Size is the size of the query result in bytes.
501+ Size * uint64 `json:"size,omitempty"`
502+ // Started is the time when the query has been started.
503+ // Date and time at which the query result has been added to the cache.
504+ Started * string `json:"started,omitempty"`
505+ }
506+
507+ type QueryCacheProperties struct {
508+ // IncludeSystem indicates whether the query cache includes system collections.
509+ IncludeSystem * bool `json:"includeSystem,omitempty"`
510+ // MaxEntrySize is the maximum size of a single query cache entry in bytes.
511+ MaxEntrySize * uint64 `json:"maxEntrySize,omitempty"`
512+ // MaxResults is the maximum number of results that can be stored in the query cache.
513+ MaxResults * uint16 `json:"maxResults,omitempty"`
514+ // MaxResultsSize is the maximum size of the query cache in bytes.
515+ MaxResultsSize * uint64 `json:"maxResultsSize,omitempty"`
516+ // Mode is the query cache mode.
517+ // The mode can be one of the following values:
518+ // "on" - the query cache is enabled and will be used for all queries.
519+ // "off" - the query cache is disabled and will not be used for any queries.
520+ // "demand" - the query cache is enabled, but will only be used for queries that explicitly request it.
521+ Mode * string `json:"mode,omitempty"`
522+ }
523+
524+ type UserDefinedFunctionObject struct {
525+ // Code is the JavaScript function body as a string.
526+ Code * string `json:"code"`
527+
528+ // Name is the fully qualified name of the user-defined function, including namespace.
529+ Name * string `json:"name"`
530+
531+ // IsDeterministic indicates whether the function always produces the same output for identical input.
532+ IsDeterministic * bool `json:"isDeterministic"`
533+ }
0 commit comments