Skip to content

Commit ee039dd

Browse files
committed
Docs: Spelling and other... [ci skip]
1 parent c58e68e commit ee039dd

File tree

8 files changed

+84
-87
lines changed

8 files changed

+84
-87
lines changed

ABOUT_PREPARED_V2.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ implementation *and* API of prepared statements is in `PreparedImpl`.
3535
ddox-generated documentation, AND no longer accomplishes anything *anyway*
3636
now that `PreparedImpl` no longer has any dtor (for various complicated
3737
reasons relating to struct dtors, the auto-purge feature from v1.1.4 and
38-
recognizing that manual release of statements from the server isn't stictly
38+
recognizing that manual release of statements from the server isn't strictly
3939
necessary, being per-connection after all).
4040

41-
6. Mysql-native is not currently tempated on connection type, it uses a literal
41+
6. Mysql-native is not currently templated on connection type, it uses a literal
4242
`Connection` throughout. Unfortunately, this means the `LockedConnection!Connection`
4343
returned by Vibe.d's connection pools (which `MySQLPool` is based on) gets
4444
downgraded to a mere `Connection`. Ordinarily this would be fine if it was only
@@ -51,36 +51,36 @@ to correct this just to still compile anyway.
5151
Why these problems?
5252
-------------------
5353

54-
I believe, for the most part, these issues are ultimately symptomatic of the
54+
I think, for the most part, these issues are ultimately symptomatic of the
5555
Prepared abstraction not accurately matching the reality. Thus, it needs
5656
high-level rethinking:
5757

5858
Currently, `Prepared` (just like the original functionality in the old
5959
pre-v1.0.0 `Command` struct) is designed around the low-level reality that
6060
MySQL ties prepared statements to individual connections. But then, instead
6161
of treating prepared statements as something owned by a connection (as they
62-
realistically are), `Prepared` flips this around and *has a* connection,
63-
instead of the reality that a connection *has a* prepared statement.
62+
realistically are), `Prepared` flips this around and *has a* connection
63+
instead.
6464

6565
It's also wrong on a higher level: Conceptually, to a database's human user,
6666
a prepared statement is...an SQL statement...that just has special "slots"
6767
for parameters and provides certain benefits. To a user, that's it, nothing
6868
more. That these particular statements happen to be tied to individual
6969
connections is merely an implementation detail of the communications protocol.
7070

71-
I believe these disconnects are the main cause of the above problems with `Prepared`.
71+
I believe these disconnects are the major cause of the above problems with `Prepared`.
7272

7373
Solution for v2.0.0:
7474
--------------------
7575

7676
Originally, I was thinking about (if anything *at all*) *maybe* offering an
7777
additional abstraction over top `Prepared` which manages prepared statements
7878
across multiple connections. But that would only address the first problem
79-
above, not all of them, and I now believe would liklely create additional
79+
above, not all of them, and I now believe would likely create additional
8080
mess and problems due to the original disconnect only being covered up,
81-
not resoloved.
81+
not resolved.
8282

83-
So I think a re-design is warranted:
83+
So I think a redesign is warranted:
8484

8585
- Get rid of `PreparedImpl`. Just have a `Prepared` struct and be done with it.
8686
In the unlikely case anyone really does need deterministic server-side release
@@ -103,7 +103,7 @@ automatically creates it.
103103

104104
- `struct Prepared` itself shouldn't have any "release" or "register"
105105
functionality of its own, at all. That should be fully considered a
106-
charactaristic of the communications channel, not a charactaristic of
106+
charactaristic of the communications channel, not a characteristic of
107107
statements.
108108

109109
- `Connection` should have a `.release(Prepared)` to manually release a
@@ -112,8 +112,8 @@ the statement hasn't been registered on the connection, or has already been
112112
released (as defined by the statement's SQL string).
113113

114114
- Any functionality to manually release a Prepared from ALL connections
115-
should be in `MySQLPool`. I'm undecided whether this would be essential
116-
for v2.0.0 or could be deferred until v2.1.0 or so.
115+
should be in `MySQLPool`. This will not be in v2.0.0 though,
116+
it is delayed until v2.1.0 or so.
117117

118118
- Connection and MySQLPool should also have `.register(Prepared)`
119119
(or is there a better name?) to manually create a prepared statement on a
@@ -123,9 +123,10 @@ will be still be automatically registered when its actually used.
123123

124124
- When a statement is manually registered on a MySQLPool (as opposed to
125125
a Connection), The MySQLPool will manually register it on all
126-
currenty-open connections. After this point, the statement will automatically
126+
currently-open connections. After this point, the statement will automatically
127127
be registered on all new connections, immediately upon each new connection's
128-
creation, until `MySQLPool.release` is called on the statement.
128+
creation, until `MySQLPool.release` is called on the statement. This will also
129+
not be in v2.0.0 though, it is delayed until v2.1.0 or so.
129130

130131
- In the future, other functionality could be added:
131132
`Connection/MySQLPool.releaseAllPrepared`, `Connection/MySQLPool.releaseStalePrepared`,
@@ -164,22 +165,22 @@ value in that.
164165

165166
It could be argued that mysql-native is, in some ways, higher level than
166167
that original charter, and the same could be said for some of these changes.
167-
However, I don't beleive these changes make it too high-level for the vast
168+
However, I don't think these changes make it too high-level for the vast
168169
majority of use-cases, and I do believe these higher-level interfaces are
169170
more than worthwhile and moving in a very good direction for the average D
170171
database user.
171172

172173
So what of the need for a stripped-down low-level API?
173174
------------------------------------------------------
174175

175-
First off all, there's nothing stopping other high-level DB libs from basing
176+
First of all, there's nothing stopping other high-level DB libs from basing
176177
their MySQL/MariaDB support on top of mysql-native's higher-level interfaces.
177178
That's entirely viable, and may even make things easier for the lib developers.
178179
And mysql-native *does* intend to reduce any overhead it does have and keep
179180
that to a minimum, even for high-level functionality (IMO, that's part of D's
180181
own charter, after all).
181182

182-
But aside from that: For the sake of sensible code hygeine and maintainability,
183+
But aside from that: For the sake of sensible code hygiene and maintainability,
183184
my intention for the near-term future of this library is to clean up the
184185
internal design and separate all the low-level communications code out of the
185186
higher-level interfaces. This will have the additional benefit of opening the

MIGRATING_TO_V2.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ of the change in
1212
Unfortunately, these improvements have necessitated some breaking
1313
changes to the API for the
1414
[Prepared](http://semitwist.com/mysql-native/mysql/prepared/Prepared.html)
15-
struct. Any code which uses prepared statements will need a small update.
15+
struct. Any code which uses prepared statements will need some small updates.
1616

1717
The changes needed in your code are simple syntactical changes. Before,
1818
in v1.x.x, you would call the exec/query functions on your Prepared
@@ -50,7 +50,7 @@ handles all the details necessary to make this work. If you wish to know
5050
exactly how this is done, see
5151
[ABOUT_PREPARED_V2.md](https://github.com/mysql-d/mysql-native/blob/master/ABOUT_PREPARED_V2.md).
5252

53-
Also, note that `prepare()` function has moved from `mysql.prepared` to
53+
Also, note that the `prepare()` function has moved from `mysql.prepared` to
5454
`mysql.connection` as it is specific to `mysql.connection.Connection`, and
5555
this helps keep `mysql.prepared` completely non-dependent on `mysql.connection`.
5656

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ client driver for MySQL and MariaDB.
55

66
This package attempts to provide composite objects and methods that will
77
allow a wide range of common database operations, but be relatively easy to
8-
use. It has no dependecies on GPL header files or libraries, instead communicating
8+
use. It has no dependencies on GPL header files or libraries, instead communicating
99
directly with the server via the
1010
[published client/server protocol](http://dev.mysql.com/doc/internals/en/client-server-protocol.html).
1111

@@ -40,7 +40,6 @@ The primary interfaces:
4040
- [exec()](http://semitwist.com/mysql-native/mysql/commands/exec.html): Plain old SQL statement that does NOT return rows (like INSERT/UPDATE/CREATE/etc), returns number of rows affected
4141
- [query()](http://semitwist.com/mysql-native/mysql/commands/query.html): Execute an SQL statement that DOES return rows (ie, SELECT) and handle the rows one at a time, as an input range.
4242
- [queryRow()](http://semitwist.com/mysql-native/mysql/commands/queryRow.html): Execute an SQL statement and get the first row.
43-
- [queryRowTuple()](http://semitwist.com/mysql-native/mysql/commands/queryRowTuple.html): Execute an SQL statement and get the first row into a matching tuple of D variables.
4443
- [queryValue()](http://semitwist.com/mysql-native/mysql/commands/queryValue.html): Execute an SQL statement and get the first value in the first row.
4544
- [prepare()](http://semitwist.com/mysql-native/mysql/prepared/prepare.html): Create a prepared statement
4645
- [Prepared](http://semitwist.com/mysql-native/mysql/prepared/PreparedImpl.html): A prepared statement, optionally pass it to the exec/query function in place of an SQL string.

source/mysql/commands.d

+31-30
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ package bool execQueryImpl(Connection conn, ExecQueryImplInfo info)
126126
}
127127

128128
/++
129-
Execute a one-off SQL command, such as INSERT/UPDATE/CREATE/etc.
129+
Execute an SQL command or prepared statement, such as INSERT/UPDATE/CREATE/etc.
130130
131131
This method is intended for commands such as which do not produce a result set
132-
(otherwise, use one of the query functions instead.) If the SQL command does
132+
(otherwise, use one of the `query` functions instead.) If the SQL command does
133133
produces a result set (such as SELECT), `mysql.exceptions.MYXResultRecieved`
134134
will be thrown.
135135
@@ -163,13 +163,13 @@ ulong exec(Connection conn, ref Prepared prepared)
163163
/++
164164
This function is provided ONLY as a temporary aid in upgrading to mysql-native v2.0.0.
165165
166-
See `BackwardCompatPrepared` for more info.
166+
See `mysql.connection.BackwardCompatPrepared` for more info.
167167
+/
168-
ulong exec(Connection conn, ref BackwardCompatPrepared prepared)
168+
ulong exec(Connection conn, ref BackwardCompatPrepared bcp)
169169
{
170-
auto p = prepared.prepared;
170+
auto p = bcp.prepared;
171171
auto result = exec(conn, p);
172-
prepared._prepared = p;
172+
bcp._prepared = p;
173173
return result;
174174
}
175175

@@ -188,11 +188,11 @@ package ulong execImpl(Connection conn, ExecQueryImplInfo info)
188188
}
189189

190190
/++
191-
Execute a one-off SQL SELECT command where you want to deal with the
192-
result set one row at a time.
191+
Execute an SQL SELECT command or prepared statement.
193192
194-
If you need random access to the resulting `mysql.result.Row` elements,
195-
simply call $(LINK2 https://dlang.org/phobos/std_array.html#array, `std.array.array()`)
193+
This returns an input range of `mysql.result.Row`, so if you need random access
194+
to the `mysql.result.Row` elements, simply call
195+
$(LINK2 https://dlang.org/phobos/std_array.html#array, `std.array.array()`)
196196
on the result.
197197
198198
If the SQL command does not produce a result set (such as INSERT/CREATE/etc),
@@ -240,13 +240,13 @@ ResultRange query(Connection conn, ref Prepared prepared, ColumnSpecialization[]
240240
/++
241241
This function is provided ONLY as a temporary aid in upgrading to mysql-native v2.0.0.
242242
243-
See `BackwardCompatPrepared` for more info.
243+
See `mysql.connection.BackwardCompatPrepared` for more info.
244244
+/
245-
ResultRange query(Connection conn, ref BackwardCompatPrepared prepared, ColumnSpecialization[] csa = null)
245+
ResultRange query(Connection conn, ref BackwardCompatPrepared bcp, ColumnSpecialization[] csa = null)
246246
{
247-
auto p = prepared.prepared;
247+
auto p = bcp.prepared;
248248
auto result = query(conn, p, csa);
249-
prepared._prepared = p;
249+
bcp._prepared = p;
250250
return result;
251251
}
252252

@@ -266,7 +266,8 @@ package ResultRange queryImpl(ColumnSpecialization[] csa,
266266
}
267267

268268
/++
269-
Execute a one-off SQL SELECT command where you only want the first `mysql.result.Row` (if any).
269+
Execute an SQL SELECT command or prepared statement where you only want the
270+
first `mysql.result.Row`, if any.
270271
271272
If the SQL command does not produce a result set (such as INSERT/CREATE/etc),
272273
then `mysql.exceptions.MYXNoResultRecieved` will be thrown. Use
@@ -308,13 +309,13 @@ Nullable!Row queryRow(Connection conn, ref Prepared prepared, ColumnSpecializati
308309
/++
309310
This function is provided ONLY as a temporary aid in upgrading to mysql-native v2.0.0.
310311
311-
See `BackwardCompatPrepared` for more info.
312+
See `mysql.connection.BackwardCompatPrepared` for more info.
312313
+/
313-
Nullable!Row queryRow(Connection conn, ref BackwardCompatPrepared prepared, ColumnSpecialization[] csa = null)
314+
Nullable!Row queryRow(Connection conn, ref BackwardCompatPrepared bcp, ColumnSpecialization[] csa = null)
314315
{
315-
auto p = prepared.prepared;
316+
auto p = bcp.prepared;
316317
auto result = queryRow(conn, p, csa);
317-
prepared._prepared = p;
318+
bcp._prepared = p;
318319
return result;
319320
}
320321

@@ -334,8 +335,8 @@ package Nullable!Row queryRowImpl(ColumnSpecialization[] csa, Connection conn,
334335
}
335336

336337
/++
337-
Execute a one-off SQL SELECT command where you only want the first `mysql.result.Row`,
338-
and place result values into a set of D variables.
338+
Execute an SQL SELECT command or prepared statement where you only want the
339+
first `mysql.result.Row`, and place result values into a set of D variables.
339340
340341
This method will throw if any column type is incompatible with the corresponding D variable.
341342
@@ -375,13 +376,13 @@ void queryRowTuple(T...)(Connection conn, ref Prepared prepared, ref T args)
375376
/++
376377
This function is provided ONLY as a temporary aid in upgrading to mysql-native v2.0.0.
377378
378-
See `BackwardCompatPrepared` for more info.
379+
See `mysql.connection.BackwardCompatPrepared` for more info.
379380
+/
380-
void queryRowTuple(T...)(Connection conn, ref BackwardCompatPrepared prepared, ref T args)
381+
void queryRowTuple(T...)(Connection conn, ref BackwardCompatPrepared bcp, ref T args)
381382
{
382-
auto p = prepared.prepared;
383+
auto p = bcp.prepared;
383384
queryRowTuple(conn, p, args);
384-
prepared._prepared = p;
385+
bcp._prepared = p;
385386
}
386387

387388
/// Common implementation for `queryRowTuple` overloads.
@@ -425,7 +426,7 @@ unittest
425426
}
426427

427428
/++
428-
Execute a one-off SQL SELECT command and returns a single value,
429+
Execute an SQL SELECT command or prepared statement and return a single value:
429430
the first column of the first row received.
430431
431432
If the query did not produce any rows, or the rows it produced have zero columns,
@@ -475,13 +476,13 @@ Nullable!Variant queryValue(Connection conn, ref Prepared prepared, ColumnSpecia
475476
/++
476477
This function is provided ONLY as a temporary aid in upgrading to mysql-native v2.0.0.
477478
478-
See `BackwardCompatPrepared` for more info.
479+
See `mysql.connection.BackwardCompatPrepared` for more info.
479480
+/
480-
Nullable!Variant queryValue(Connection conn, ref BackwardCompatPrepared prepared, ColumnSpecialization[] csa = null)
481+
Nullable!Variant queryValue(Connection conn, ref BackwardCompatPrepared bcp, ColumnSpecialization[] csa = null)
481482
{
482-
auto p = prepared.prepared;
483+
auto p = bcp.prepared;
483484
auto result = queryValue(conn, p, csa);
484-
prepared._prepared = p;
485+
bcp._prepared = p;
485486
return result;
486487
}
487488

0 commit comments

Comments
 (0)