sql_exp * exp_atom_clob(sql_allocator *sa, str s) { sql_subtype clob; sql_find_subtype(&clob, "clob", 0, 0); return exp_atom(sa, atom_string(sa, &clob, s?sa_strdup(sa, s):NULL)); }
sql_exp * exp_atom_dbl(sql_allocator *sa, dbl f) { sql_subtype it; sql_find_subtype(&it, "double", 53, 0); return exp_atom(sa, atom_float(sa, &it, (dbl)f )); }
sql_exp * exp_atom_wrd(sql_allocator *sa, wrd w) { sql_subtype it; sql_find_subtype(&it, "wrd", 19, 0); return exp_atom(sa, atom_int(sa, &it, (lng)w )); }
sql_exp * exp_atom_lng(sql_allocator *sa, lng i) { sql_subtype it; sql_find_subtype(&it, "bigint", 19, 0); return exp_atom(sa, atom_int(sa, &it, (lng)i )); }
sql_exp * exp_atom_int(sql_allocator *sa, int i) { sql_subtype it; sql_find_subtype(&it, "int", 9, 0); return exp_atom(sa, atom_int(sa, &it, i )); }
sql_column * mvc_create_column_(mvc *m, sql_table *t, const char *name, const char *type, int digits) { sql_subtype tpe; if (!sql_find_subtype(&tpe, type, digits, 0)) return NULL; return sql_trans_create_column(m->session->tr, t, name, &tpe); }
sql_exp * exp_atom_bool(sql_allocator *sa, int b) { sql_subtype bt; sql_find_subtype(&bt, "boolean", 0, 0); if (b) return exp_atom(sa, atom_bool(sa, &bt, TRUE )); else return exp_atom(sa, atom_bool(sa, &bt, FALSE )); }
static int fits2subtype(sql_subtype *tpe, int t, long rep, long wid) { (void)rep; switch (t) { case TBIT: case TLOGICAL: sql_find_subtype(tpe, "boolean", 0, 0); break; case TBYTE: case TSBYTE: sql_find_subtype(tpe, "char", 1, 0); break; case TSTRING: sql_find_subtype(tpe, "varchar", (unsigned int)wid, 0); break; case TUSHORT: case TSHORT: sql_find_subtype(tpe, "smallint", 16, 0); break; case TUINT: case TINT: sql_find_subtype(tpe, "int", 32, 0); break; case TULONG: case TLONG: case TLONGLONG: sql_find_subtype(tpe, "bigint", 64, 0); break; case TFLOAT: sql_find_subtype(tpe, "real", 32, 0); break; case TDOUBLE: sql_find_subtype(tpe, "double", 51, 0); break; /* missing */ case TCOMPLEX: case TDBLCOMPLEX: return -1; } return 1; }