1 | /* |
2 | * This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
5 | * |
6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
7 | */ |
8 | |
9 | #ifndef SQL_TYPES_H |
10 | #define SQL_TYPES_H |
11 | |
12 | #include "sql_mem.h" |
13 | #include "sql_list.h" |
14 | #include "sql_string.h" |
15 | #include "sql_catalog.h" |
16 | #include "sql_storage.h" |
17 | #include "stream.h" |
18 | |
19 | extern list *aliases; |
20 | extern list *types; |
21 | extern list *aggrs; |
22 | extern list *funcs; |
23 | |
24 | extern int bits2digits(int b); |
25 | extern int digits2bits(int d); |
26 | |
27 | extern int sql_type_convert(int form, int to); /* return 1, convert possible but it's a down cast, 2 convert possible can be done savely */ |
28 | extern bool is_commutative(const char *fnm); /* return true if commutative */ |
29 | |
30 | extern char *sql_bind_alias(const char *alias); |
31 | |
32 | extern int sql_find_subtype(sql_subtype *res, const char *name, unsigned int digits, unsigned int scale); |
33 | extern sql_subtype *sql_find_numeric(sql_subtype *r, int localtype, unsigned int digits); |
34 | |
35 | extern sql_subtype *sql_bind_subtype(sql_allocator *sa, const char *name, unsigned int digits, unsigned int scale); |
36 | extern sql_subtype *sql_bind_localtype(const char *name); |
37 | extern sql_subtype *sql_create_subtype(sql_allocator *sa, sql_type *t, unsigned int s, unsigned int d); |
38 | extern void sql_init_subtype(sql_subtype *res, sql_type *t, unsigned int digits, unsigned int scale); |
39 | extern char *sql_subtype_string(sql_subtype *t); |
40 | |
41 | extern int type_cmp(sql_type *t1, sql_type *t2); |
42 | extern int subtype_cmp(sql_subtype *t1, sql_subtype *t2); |
43 | extern int arg_subtype_cmp(sql_arg *a, sql_subtype *t); |
44 | extern int is_subtype(sql_subtype *t1, sql_subtype *t2); |
45 | extern char *subtype2string(sql_subtype *t); |
46 | extern char *subtype2string2(sql_subtype *tpe); |
47 | |
48 | extern sql_arg *sql_create_arg(sql_allocator *sa, const char *name, sql_subtype *t, char inout); |
49 | extern sql_arg *arg_dup(sql_allocator *sa, sql_arg *a); |
50 | |
51 | extern sql_subaggr *sql_bind_aggr(sql_allocator *sa, sql_schema *s, const char *name, sql_subtype *type); |
52 | extern sql_subaggr *sql_bind_aggr_(sql_allocator *sa, sql_schema *s, const char *name, list *types); |
53 | extern sql_subaggr *sql_bind_member_aggr(sql_allocator *sa, sql_schema *s, const char *name, sql_subtype *tp, int nrargs); |
54 | extern sql_subaggr *sql_find_aggr(sql_allocator *sa, sql_schema *s, const char *name); |
55 | extern int subaggr_cmp( sql_subaggr *a1, sql_subaggr *a2); |
56 | |
57 | extern int subfunc_cmp( sql_subfunc *f1, sql_subfunc *f2); |
58 | extern sql_subfunc *sql_find_func_by_name(sql_allocator *sa, sql_schema *s, const char *name, int nrargs, sql_ftype type); |
59 | extern sql_subfunc *sql_find_func(sql_allocator *sa, sql_schema *s, const char *name, int nrargs, sql_ftype type, sql_subfunc *prev); |
60 | extern list *sql_find_funcs(sql_allocator *sa, sql_schema *s, const char *name, int nrargs, sql_ftype type); |
61 | extern sql_subfunc *sql_bind_member(sql_allocator *sa, sql_schema *s, const char *name, sql_subtype *tp, int nrargs, sql_subfunc *prev); |
62 | extern sql_subfunc *sql_bind_func(sql_allocator *sa, sql_schema *s, const char *name, sql_subtype *tp1, sql_subtype *tp2, sql_ftype type); |
63 | extern sql_subfunc *sql_bind_func3(sql_allocator *sa, sql_schema *s, const char *name, sql_subtype *tp1, sql_subtype *tp2, sql_subtype *tp3, sql_ftype type); |
64 | extern sql_subfunc *sql_bind_func_result(sql_allocator *sa, sql_schema *s, const char *name, sql_subtype *tp1, sql_subtype *tp2, sql_subtype *res); |
65 | extern sql_subfunc *sql_bind_func_result3(sql_allocator *sa, sql_schema *s, const char *name, sql_subtype *tp1, sql_subtype *tp2, sql_subtype *tp3, sql_subtype *res); |
66 | |
67 | extern sql_subfunc *sql_bind_func_(sql_allocator *sa, sql_schema *s, const char *name, list *ops, sql_ftype type); |
68 | |
69 | extern sql_subfunc* sql_dup_subfunc(sql_allocator *sa, sql_func *f, list *ops, sql_subtype *member); |
70 | |
71 | extern char *sql_func_imp(sql_func *f); |
72 | extern char *sql_func_mod(sql_func *f); |
73 | extern int is_sqlfunc(sql_func *f); |
74 | |
75 | extern void types_init(sql_allocator *sa, int debug); |
76 | |
77 | #endif /* SQL_TYPES_H */ |
78 | |