Something went wrong. Try again.
SQL frontend over the catalog engine
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263(*--------------------------------------------------------------------------- Copyright (c) 2026 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*)
(** Views: a [SELECT] a store keeps as the text of its [CREATE VIEW] ({!Catalog.Spi.definitions}), checked when it is created and expanded where it is read (lang_createview.html). *)
val of_sql : string -> Ast.create_view option(** [of_sql sql] is the [CREATE VIEW] [sql] holds, or [None] where it holds anything else. *)
val find : Catalog.t -> string -> Ast.create_view option(** [find cat name] is the view [name] of [cat], or [None]. *)
val expanding : string -> (unit -> 'a) -> 'a(** [expanding name f] is [f ()] with the view [name] marked as being expanded on this domain, so that a view defined through itself is found.
@raise Catalog.Error ["view name is circularly defined"] where [name] is already being expanded. *)
val columns : Resolve.env -> Ast.create_view -> string list(** [columns env cv] is the columns of the view [cv]: its column list, or the names of its result columns, a [*] expanded over the sources [env] holds (select.c, sqlite3ViewGetColumnNames).
@raise Catalog.Error as {!Resolve.check_stars} and {!Resolve.check_widths} refuse its [SELECT].*)
val collation : Resolve.env -> Ast.create_view -> string -> string option(** [collation env cv col] is the collating sequence the result column [col] of [cv] carries ({!Resolve.output_collation}), or [None]. *)
val affinity : Resolve.env -> Ast.create_view -> string -> Value_ops.affinity option(** [affinity env cv col] is the affinity of the result column [col] of [cv] ({!Resolve.output_affinity}), or [None]. *)
val decl_type : Resolve.env -> Ast.create_view -> string -> string option(** [decl_type env cv col] is the type the result column [col] of [cv] reports ({!Resolve.output_type}), or [None]. *)
val over : Catalog.t -> Query.catalog -> Query.catalog(** [over cat q] is [q] reading the views of [cat] too: a name no table of [cat] holds that a view of [cat] defines has the view's columns, and rows its [SELECT] yields over that same catalog; it has no rowid and serves no index.*)
type holder = [ `Table | `View | `Index ](** The type for what already holds a name a view would take. *)
val check_create : held:holder option -> Ast.create_view -> bool(** [check_create ~held cv] is [true] where [cv] is to be defined, and [false] for a [CREATE VIEW IF NOT EXISTS] of a name a table or a view holds.
@raise Catalog.Error ["parameters are not allowed in views"], or in sqlite3's words for a name [held] by a table, a view or an index. *)