|
2 | 2 | Usage: app [connection string]
|
3 | 3 |
|
4 | 4 | If connection string isn't provided, the following default connection string will be used:
|
5 |
| - host=localhost;port=3306;user=testuser;pwd=testpassword;db=testdb |
| 5 | + host=localhost;port=3306;user=testuser;pwd=testpassword;db=testdb |
6 | 6 |
|
7 | 7 | (optional) -version=Have_vibe_d_core:
|
8 |
| - Link with Vibe.d, and run test using use Vibe.d sockets instead of Phobos sockets. |
| 8 | + Link with Vibe.d, and run test using use Vibe.d sockets instead of Phobos sockets. |
9 | 9 |
|
10 | 10 | (optional) -version=UseConnPool:
|
11 |
| - Run test using use Vibe.d conenction pool. Requires -version=Have_vibe_d_core |
| 11 | + Run test using use Vibe.d conenction pool. Requires -version=Have_vibe_d_core |
12 | 12 | +/
|
13 | 13 |
|
14 | 14 | import mysql.connection;
|
15 | 15 | import std.stdio;
|
16 | 16 |
|
17 | 17 | void main(string[] args)
|
18 | 18 | {
|
19 |
| - string connStr = "host=localhost;port=3306;user=testuser;pwd=testpassword;db=testdb"; |
20 |
| - if(args.length > 1) |
21 |
| - connStr = args[1]; |
22 |
| - else |
23 |
| - writeln("No connection string provided on cmdline, using default:\n", connStr); |
24 |
| - |
25 |
| - try testMySql(connStr); |
26 |
| - catch( Exception e ){ |
27 |
| - writeln("Failed: ", e.toString()); |
28 |
| - } |
| 19 | + string connStr = "host=localhost;port=3306;user=testuser;pwd=testpassword;db=testdb"; |
| 20 | + if(args.length > 1) |
| 21 | + connStr = args[1]; |
| 22 | + else |
| 23 | + writeln("No connection string provided on cmdline, using default:\n", connStr); |
| 24 | + |
| 25 | + try testMySql(connStr); |
| 26 | + catch( Exception e ){ |
| 27 | + writeln("Failed: ", e.toString()); |
| 28 | + } |
29 | 29 | }
|
30 | 30 |
|
31 | 31 | void testMySql(string connStr)
|
32 | 32 | {
|
33 |
| - version(UseConnPool) |
34 |
| - { |
35 |
| - import mysql.db; |
36 |
| - auto mdb = new MysqlDB(connStr); |
37 |
| - auto c = mdb.lockConnection(); |
38 |
| - scope(exit) c.close(); |
39 |
| - } |
40 |
| - else |
41 |
| - { |
42 |
| - auto c = new Connection(connStr); |
43 |
| - scope(exit) c.close(); |
44 |
| - } |
| 33 | + version(UseConnPool) |
| 34 | + { |
| 35 | + import mysql.db; |
| 36 | + auto mdb = new MysqlDB(connStr); |
| 37 | + auto c = mdb.lockConnection(); |
| 38 | + scope(exit) c.close(); |
| 39 | + } |
| 40 | + else |
| 41 | + { |
| 42 | + auto c = new Connection(connStr); |
| 43 | + scope(exit) c.close(); |
| 44 | + } |
45 | 45 |
|
46 | 46 | // writefln("You have connected to server version %s", c.serverVersion);
|
47 | 47 | // writefln("With currents stats : %s", c.serverStats());
|
48 |
| - auto caps = c.serverCapabilities; |
49 |
| - writefln("MySQL Server %s with capabilities (%b):", c.serverVersion, caps); |
50 |
| - if(caps && SvrCapFlags.OLD_LONG_PASSWORD) |
51 |
| - writeln("\tLong passwords"); |
52 |
| - if(caps && SvrCapFlags.FOUND_NOT_AFFECTED) |
53 |
| - writeln("\tReport rows found rather than rows affected"); |
54 |
| - if(caps && SvrCapFlags.ALL_COLUMN_FLAGS) |
55 |
| - writeln("\tSend all column flags"); |
56 |
| - if(caps && SvrCapFlags.WITH_DB) |
57 |
| - writeln("\tCan take database as part of login"); |
58 |
| - if(caps && SvrCapFlags.NO_SCHEMA) |
59 |
| - writeln("\tCan disallow database name as part of column name database.table.column"); |
60 |
| - if(caps && SvrCapFlags.CAN_COMPRESS) |
61 |
| - writeln("\tCan compress packets"); |
62 |
| - if(caps && SvrCapFlags.ODBC) |
63 |
| - writeln("\tCan handle ODBC"); |
64 |
| - if(caps && SvrCapFlags.LOCAL_FILES) |
65 |
| - writeln("\tCan use LOAD DATA LOCAL"); |
66 |
| - if(caps && SvrCapFlags.IGNORE_SPACE) |
67 |
| - writeln("\tCan ignore spaces before '('"); |
68 |
| - if(caps && SvrCapFlags.PROTOCOL41) |
69 |
| - writeln("\tCan use 4.1+ protocol"); |
70 |
| - if(caps && SvrCapFlags.INTERACTIVE) |
71 |
| - writeln("\tInteractive client?"); |
72 |
| - if(caps && SvrCapFlags.SSL) |
73 |
| - writeln("\tCan switch to SSL after handshake"); |
74 |
| - if(caps && SvrCapFlags.IGNORE_SIGPIPE) |
75 |
| - writeln("\tIgnore sigpipes?"); |
76 |
| - if(caps && SvrCapFlags.TRANSACTIONS) |
77 |
| - writeln("\tTransaction Support"); |
78 |
| - if(caps && SvrCapFlags.SECURE_CONNECTION) |
79 |
| - writeln("\t4.1+ authentication"); |
80 |
| - if(caps && SvrCapFlags.MULTI_STATEMENTS) |
81 |
| - writeln("\tMultiple statement support"); |
82 |
| - if(caps && SvrCapFlags.MULTI_RESULTS) |
83 |
| - writeln("\tMultiple result set support"); |
84 |
| - writeln(); |
85 |
| - |
86 |
| - MetaData md = MetaData(c); |
87 |
| - auto dbList = md.databases(); |
88 |
| - writefln("Found %s databases", dbList.length); |
89 |
| - foreach( db; dbList ) |
90 |
| - { |
91 |
| - c.selectDB(db); |
92 |
| - auto curTables = md.tables(); |
93 |
| - writefln("Database '%s' has %s table%s.", db, curTables.length, curTables.length == 1?"":"s"); |
94 |
| - foreach(tbls ; curTables) |
95 |
| - { |
96 |
| - writefln("\t%s", tbls); |
97 |
| - } |
98 |
| - } |
| 48 | + auto caps = c.serverCapabilities; |
| 49 | + writefln("MySQL Server %s with capabilities (%b):", c.serverVersion, caps); |
| 50 | + if(caps && SvrCapFlags.OLD_LONG_PASSWORD) |
| 51 | + writeln("\tLong passwords"); |
| 52 | + if(caps && SvrCapFlags.FOUND_NOT_AFFECTED) |
| 53 | + writeln("\tReport rows found rather than rows affected"); |
| 54 | + if(caps && SvrCapFlags.ALL_COLUMN_FLAGS) |
| 55 | + writeln("\tSend all column flags"); |
| 56 | + if(caps && SvrCapFlags.WITH_DB) |
| 57 | + writeln("\tCan take database as part of login"); |
| 58 | + if(caps && SvrCapFlags.NO_SCHEMA) |
| 59 | + writeln("\tCan disallow database name as part of column name database.table.column"); |
| 60 | + if(caps && SvrCapFlags.CAN_COMPRESS) |
| 61 | + writeln("\tCan compress packets"); |
| 62 | + if(caps && SvrCapFlags.ODBC) |
| 63 | + writeln("\tCan handle ODBC"); |
| 64 | + if(caps && SvrCapFlags.LOCAL_FILES) |
| 65 | + writeln("\tCan use LOAD DATA LOCAL"); |
| 66 | + if(caps && SvrCapFlags.IGNORE_SPACE) |
| 67 | + writeln("\tCan ignore spaces before '('"); |
| 68 | + if(caps && SvrCapFlags.PROTOCOL41) |
| 69 | + writeln("\tCan use 4.1+ protocol"); |
| 70 | + if(caps && SvrCapFlags.INTERACTIVE) |
| 71 | + writeln("\tInteractive client?"); |
| 72 | + if(caps && SvrCapFlags.SSL) |
| 73 | + writeln("\tCan switch to SSL after handshake"); |
| 74 | + if(caps && SvrCapFlags.IGNORE_SIGPIPE) |
| 75 | + writeln("\tIgnore sigpipes?"); |
| 76 | + if(caps && SvrCapFlags.TRANSACTIONS) |
| 77 | + writeln("\tTransaction Support"); |
| 78 | + if(caps && SvrCapFlags.SECURE_CONNECTION) |
| 79 | + writeln("\t4.1+ authentication"); |
| 80 | + if(caps && SvrCapFlags.MULTI_STATEMENTS) |
| 81 | + writeln("\tMultiple statement support"); |
| 82 | + if(caps && SvrCapFlags.MULTI_RESULTS) |
| 83 | + writeln("\tMultiple result set support"); |
| 84 | + writeln(); |
| 85 | + |
| 86 | + MetaData md = MetaData(c); |
| 87 | + auto dbList = md.databases(); |
| 88 | + writefln("Found %s databases", dbList.length); |
| 89 | + foreach( db; dbList ) |
| 90 | + { |
| 91 | + c.selectDB(db); |
| 92 | + auto curTables = md.tables(); |
| 93 | + writefln("Database '%s' has %s table%s.", db, curTables.length, curTables.length == 1?"":"s"); |
| 94 | + foreach(tbls ; curTables) |
| 95 | + { |
| 96 | + writefln("\t%s", tbls); |
| 97 | + } |
| 98 | + } |
99 | 99 | }
|
0 commit comments