Skip to content

Commit bc5627d

Browse files
committed
ODBC cleanup, Impl NS (WIP), freeTDS (WIP)
default source handled in front end
1 parent 3fba339 commit bc5627d

14 files changed

Lines changed: 991 additions & 432 deletions

File tree

src/std/database/exception.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
module std.database.exception;
22
import std.exception;
33

4+
struct DatabaseError {
5+
string message;
6+
}
7+
48
class DatabaseException : Exception {
59
this(string msg, string file = __FILE__, size_t line = __LINE__) {
610
super(msg, file, line);
711
}
12+
13+
this(ref DatabaseError error, string msg, string file = __FILE__, size_t line = __LINE__) {
14+
super(msg ~ ": " ~ error.message, file, line);
15+
}
816
}
917

1018
class ConnectionException : DatabaseException {
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
module std.database.freetds.bindings;
2+
import core.stdc.config;
3+
4+
extern(System) {
5+
alias RETCODE = int;
6+
7+
alias int DBINT;
8+
alias ubyte BYTE;
9+
alias int STATUS;
10+
11+
enum {
12+
REG_ROW = -1,
13+
MORE_ROWS = -1,
14+
NO_MORE_ROWS = -2,
15+
BUF_FULL = -3,
16+
NO_MORE_RESULTS = 2,
17+
SUCCEED = 1,
18+
FAIL = 0
19+
}
20+
21+
enum {
22+
INT_EXIT = 0,
23+
INT_CONTINUE = 1,
24+
INT_CANCEL = 2,
25+
INT_TIMEOUT = 3
26+
}
27+
28+
enum {
29+
DBSETHOST = 1, /* this sets client host name */
30+
DBSETUSER = 2,
31+
DBSETPWD = 3,
32+
DBSETHID = 4, /* not implemented */
33+
DBSETAPP = 5,
34+
DBSETBCP = 6,
35+
DBSETNATLANG = 7,
36+
DBSETNOSHORT = 8, /* not implemented */
37+
DBSETHIER = 9, /* not implemented */
38+
DBSETCHARSET = 10,
39+
DBSETPACKET = 11,
40+
DBSETENCRYPT = 12,
41+
DBSETLABELED = 13,
42+
DBSETDBNAME = 14
43+
}
44+
45+
enum {
46+
SYBCHAR = 47,
47+
SYBVARCHAR = 39,
48+
SYBINTN = 38,
49+
SYBINT1 = 48,
50+
SYBINT2 = 52,
51+
SYBINT4 = 56,
52+
SYBINT8 = 127,
53+
SYBFLT8 = 62,
54+
SYBDATETIME = 61,
55+
SYBBIT = 50,
56+
SYBBITN = 104,
57+
SYBTEXT = 35,
58+
SYBNTEXT = 99,
59+
SYBIMAGE = 34,
60+
SYBMONEY4 = 122,
61+
SYBMONEY = 60,
62+
SYBDATETIME4 = 58,
63+
SYBREAL = 59,
64+
SYBBINARY = 45,
65+
SYBVOID = 31,
66+
SYBVARBINARY = 37,
67+
SYBNUMERIC = 108,
68+
SYBDECIMAL = 106,
69+
SYBFLTN = 109,
70+
SYBMONEYN = 110,
71+
SYBDATETIMN = 111,
72+
SYBNVARCHAR = 103
73+
};
74+
75+
enum {
76+
NTBSTRINGBIND = 2,
77+
}
78+
79+
RETCODE dbinit();
80+
void dbexit();
81+
82+
alias EHANDLEFUNC = int function(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr);
83+
84+
alias MHANDLEFUNC = int function(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname,
85+
char *proc, int line);
86+
87+
void dbsetuserdata(DBPROCESS * dbproc, BYTE * ptr);
88+
BYTE *dbgetuserdata(DBPROCESS * dbproc);
89+
90+
EHANDLEFUNC dberrhandle(EHANDLEFUNC handler);
91+
MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler);
92+
93+
struct LOGINREC;
94+
alias tds_dblib_loginrec = LOGINREC;
95+
96+
LOGINREC *dblogin();
97+
void dbloginfree(LOGINREC * login);
98+
99+
RETCODE dbsetlname(LOGINREC * login, const char *value, int which);
100+
101+
struct DBPROCESS;
102+
alias tds_dblib_dbprocess = DBPROCESS;
103+
104+
DBPROCESS *dbopen(LOGINREC * login, const char *server);
105+
DBPROCESS *tdsdbopen(LOGINREC * login, const char *server, int msdblib);
106+
void dbclose(DBPROCESS * dbproc);
107+
108+
RETCODE dbuse(DBPROCESS* dbproc, const char *name);
109+
110+
// something about array def is a problem
111+
//RETCODE dbcmd(DBPROCESS * dbproc, const char[] cmdstring);
112+
RETCODE dbcmd(DBPROCESS * dbproc, const char* cmdstring);
113+
114+
RETCODE dbsqlexec(DBPROCESS * dbproc);
115+
116+
RETCODE dbresults(DBPROCESS * dbproc);
117+
int dbnumcols(DBPROCESS * dbproc);
118+
119+
char *dbcolname(DBPROCESS * dbproc, int column);
120+
int dbcoltype(DBPROCESS * dbproc, int column);
121+
DBINT dbcollen(DBPROCESS * dbproc, int column);
122+
123+
RETCODE dbbind(DBPROCESS * dbproc, int column, int vartype, DBINT varlen, BYTE * varaddr);
124+
RETCODE dbnullbind(DBPROCESS * dbproc, int column, DBINT * indicator);
125+
126+
STATUS dbnextrow(DBPROCESS * dbproc);
127+
128+
}
129+
130+

0 commit comments

Comments
 (0)