Skip to content

Commit a975273

Browse files
committed
Multi-function operations
Added proper support for multi-function operations, segregating the API in single-function and multi-function operations. Removed resultset as I/O object, the read_xxx owning functions and read_all. Unit test infrastructure for async testing. Reference types lifetime fixes. Removed connection::valid. Fixed a serialization bug for statements with no parameters. Binary protocol strings now use the type recommended by MySQL. Refactored Jamfile to match best practices. Updated description in libraries.json. Close #82 Close #81 Close #73 Close #59 Close #58 Close #53 Close #41 Close #22
1 parent a3c9844 commit a975273

File tree

172 files changed

+6979
-6162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+6979
-6162
lines changed

.drone.star

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def _image(name):
1515

1616
def _b2_command(source_dir, toolset, cxxstd, variant, stdlib='native', address_model='64', server_host='localhost'):
1717
return 'python tools/ci.py ' + \
18+
'--clean=1 ' + \
1819
'--build-kind=b2 ' + \
1920
'--source-dir="{}" '.format(source_dir) + \
2021
'--toolset={} '.format(toolset) + \
@@ -28,6 +29,7 @@ def _b2_command(source_dir, toolset, cxxstd, variant, stdlib='native', address_m
2829
def _cmake_command(source_dir, build_shared_libs=0, valgrind=0, coverage=0, generator='Ninja', db='mysql8', server_host='localhost'):
2930
return 'python tools/ci.py ' + \
3031
'--build-kind=cmake ' + \
32+
'--clean=1 ' + \
3133
'--generator="{}" '.format(generator) + \
3234
'--source-dir="{}" '.format(source_dir) + \
3335
'--build-shared-libs={} '.format(build_shared_libs) + \
@@ -194,7 +196,7 @@ def docs():
194196
"image": _image('build-docs'),
195197
"pull": "if-not-exists",
196198
"commands": [
197-
'python tools/ci.py --build-kind=docs --source-dir=$(pwd)'
199+
'python tools/ci.py --build-kind=docs --clean=1 --source-dir=$(pwd)'
198200
]
199201
}]
200202
}

Jamfile

-120
This file was deleted.

doc/images/class_hierarchy.svg

+2-1
Loading

doc/images/protocol.svg

+4
Loading

doc/images/resultset.svg

+4
Loading

doc/qbk/00_main.qbk

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
[include 03_overview.qbk]
9090
[include 04_queries.qbk]
9191
[include 05_prepared_statements.qbk]
92-
[include 06_resultsets.qbk]
92+
[include 06_multi_function.qbk]
9393
[include 07_fields.qbk]
9494
[include 08_async.qbk]
9595
[include 09_ssl.qbk]

doc/qbk/02_tutorial.qbk

+17-24
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Welcome to Boost.Mysql's tutorial. We will go through the simplest
1313
possible piece of code using Boost.Mysql: a program that connects
1414
to the MySQL server and issues the query `SELECT "Hello World!"`.
1515

16-
This tutorial assumes you have a running MySQL server listening
16+
To run this tutorial, you need a running MySQL server listening
1717
in localhost on port 3306 (the default one). You should have
1818
the credentials of a valid MySQL user (username and password).
1919
No further setup is needed.
@@ -46,7 +46,8 @@ which accepts two parameters:
4646

4747
* The first one specifies the network address of the MySQL server.
4848
As we are using TCP, this is a [asioreflink ip__tcp/endpoint ip::tcp::endpoint],
49-
identifying the host and port to connect to.
49+
identifying the host and port to connect to. We will use a `boost::asio::ip::tcp::resolver`
50+
to convert the string hostname into a `boost::asio::ip::tcp::endpoint`.
5051
* The second one is a collection of MySQL handshake parameters, including
5152
username and password. This parameter must be an instance of
5253
[reflink handshake_params]. You may also set other options like
@@ -65,33 +66,25 @@ which accepts two parameters:
6566
The next step is to issue the query to the server. We will use
6667
[reflink2 connection.query tcp_ssl_connection::query],
6768
which accepts a string containing a single SQL query and instructs
68-
the server to run it. It returns a [reflink tcp_ssl_resultset]
69-
object, which allows to read the query results:
69+
the server to run it. It returns a [reflink resultset]
70+
object, containing the rows returned by the query:
7071

7172
[tutorial_query]
7273

73-
[heading Reading the results]
74+
[heading Obtaining the results]
7475

75-
A [reflink resultset] is an object that represents the result of a query.
76-
Resultsets are not containers, but I/O objects:
77-
they do not contain by themselves the entire result of the query, but allow
78-
the user to read it using several methods. We will use
79-
[reflink2 resultset.read_all tcp_ssl_resultset::read_all], which
80-
reads all the rows in the resultset and places them in a [reflink rows]
81-
object:
76+
A [reflink resultset] is an object that holds the result of a query in memory.
77+
To obtain the value we selected, we can write:
8278

83-
[tutorial_read]
79+
[tutorial_resultset]
8480

85-
A [reflink rows] object is a matrix-like container of MySQL fields.
86-
Each field is represented as a [reflink field_view], a variant-like class that
87-
can hold any type allowed in MySQL.
88-
89-
[tutorial_fields]
90-
91-
The operation `all_rows.at(0)` returns the first row from the `all_rows`
92-
container. From that row, we select the first field using `.at(0)` again.
93-
We finally stream the returned `field_view`
94-
to `std::cout`, which prints the expected phrase to the console.
81+
Let's break this into steps:
82+
* [refmem resultset rows] returns all the rows that this resultset contains.
83+
It returns a [reflink rows_view], which is a matrix-like structure.
84+
* `result.rows().at(0)` returns the first row in the resultset, represented as a [reflink row_view].
85+
* `result.rows().at(0).at(0)` returns the first field in the first row. This is a
86+
[reflink field_view], a variant-like class that can hold any type allowed in MySQL.
87+
* The obtained `field_view` is streamed to `std::cout`.
9588

9689
[heading Closing the connection]
9790

@@ -104,7 +97,7 @@ we are closing the connection, and thus may fail.
10497

10598
[heading Final notes]
10699

107-
This concludes our __Self__ tutorial! You can now learn more about the
100+
This concludes our tutorial! You can now learn more about the
108101
core functionality of this library in the [link mysql.overview overview section].
109102
You can also look at more complex [link mysql.examples examples].
110103

0 commit comments

Comments
 (0)