Module type Dbf_sql.SQL_db


module type SQL_db = sig .. end


type numeric_option =
| NO_None
| NO_Unsigned
| NO_UnsignedZeroFill

type ty =
| TinyInt of int option * numeric_option
| MediumInt of int option * numeric_option
| Int of int option * numeric_option
| BigInt of int option * numeric_option
| Double of (int * int) option * numeric_option
| Float of (int * int) option * numeric_option
| Decimal of (int * int) option * numeric_option
| Char of int
| VarChar of int
| TinyBlob
| Blob
| MediumBlob
| LongBlob
| TinyText
| Text
| MediumText
| LongText

type table = {
   mutable ta_name : string;
   mutable ta_comment : string;
   mutable ta_pkey : column list;
   mutable ta_db : db;
   mutable ta_columns : column list;
   mutable ta_logged : bool;
}
type vtable = {
   mutable vt_name : string;
   mutable vt_db : db;
   mutable vt_ftable : table;
   mutable vt_join : (table * (column * column) list)
list
;
}
type column = {
   mutable col_name : string;
   mutable col_comment : string;
   mutable col_table : table;
   mutable col_type : ty;
   mutable col_nullable : bool;
   mutable col_spec_options : string list Dbf_misc.StringMap.t;
   mutable col_spec_ty : string Dbf_misc.StringMap.t;
   mutable col_ocaml_ty : string;
   mutable col_sql2ml : string;
   mutable col_ml2sql : string;
}
type index = {
   mutable idx_name : string;
   mutable idx_columns : column list;
   mutable idx_unique : bool;
   mutable idx_db : db;
}
type query = {
   mutable qry_name : string;
   mutable qry_query : string;
   mutable qry_comment : string;
   mutable qry_db : db;
}
type db = {
   mutable db_tables : table list;
   mutable db_vtables : vtable list;
   mutable db_indexes : index list;
   mutable db_queries : query list;
}
exception Duplicated_name of string
exception Invalid_name of string
exception Invalid_args of string
val validate_name : string -> bool
val validate_name_exn : string -> unit
val create_empty : unit -> db
val create_table_name : db -> ?prefix:string -> ?from:int -> unit -> string
val table_by_name : db -> string -> table
val table_by_name_opt : db -> string -> table option
val insert_table : db ->
name:string -> comment:string -> logged:bool -> table
val unlink_table : table ->
vtable list * index list
val rename_table : table -> name:string -> unit
val set_primary_key : table -> column list -> unit
val unset_primary_key : table -> unit
val column_fullname : column -> string
val create_column_name : table -> ?prefix:string -> ?from:int -> unit -> string
val column_by_name : table -> name:string -> column
val column_by_name_opt : table -> name:string -> column option
val insert_column : table ->
name:string ->
comment:string ->
ty:ty -> ?nullable:bool -> unit -> column
val rename_column : column -> name:string -> unit
val unlink_column : column ->
vtable list * index list * bool
val string_of_spec_options : string list Dbf_misc.StringMap.t -> string
val create_vtable_name : db -> ?prefix:string -> ?from:int -> unit -> string
val vtable_by_name : db -> string -> vtable
val vtable_by_name_opt : db -> string -> vtable option
val create_vtable : name:string -> table:table -> vtable
val link_vtable_to_db : vtable -> unit
val do_join : vtable ->
table ->
(column * column) list -> unit
val table_in_join : vtable -> table -> bool
val rename_vtable : vtable -> name:string -> unit
val unlink_vtable : vtable -> unit
val string_of_vtable : vtable -> string
val vtables_using_table : table -> vtable list
val vtables_using_column : column -> vtable list
val create_index_name : db -> ?prefix:string -> ?from:int -> unit -> string
val index_by_name : db -> string -> index
val index_by_name_opt : db -> string -> index option
val insert_index : name:string ->
columns:column list -> unique:bool -> index
val rename_index : index -> name:string -> unit
val unlink_index : index -> unit
val column_in_index : index -> column -> bool
val string_of_index : index -> string
val table_of_index : index -> table
val update_index : index ->
name:string -> columns:column list -> unique:bool -> unit
val indexes_using_table : table -> index list
val indexes_using_column : column -> index list

type query_state =
| Query_ok of column option list
* (string * column option) list
| Query_parse_error of int * int * string
| Query_invalid_against_schema of string
| Query_incorrect of string
val create_query_name : db -> ?prefix:string -> ?from:int -> unit -> string
val query_by_name : db -> string -> query
val query_by_name_opt : db -> string -> query option
val insert_query : db ->
name:string -> query:string -> comment:string -> query
val rename_query : query -> name:string -> unit
val unlink_query : query -> unit
val update_query : query -> name:string -> query:string -> comment:string -> unit
val query_state : query -> query_state
val string_of_query_state : query_state -> string