Skip to content

Commit 5543cf4

Browse files
committed
WL#9970 (Core SSL options) Documentation.
1 parent 97a6547 commit 5543cf4

File tree

2 files changed

+139
-43
lines changed

2 files changed

+139
-43
lines changed

include/mysql_devapi.h

Lines changed: 118 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class ViewDefinedAs
271271
Specify table select operation for which the view is created.
272272
273273
@note In situations where select statement is modified after
274-
passing it to definedAs() method, later changes do not afffect
274+
passing it to definedAs() method, later changes do not affect
275275
view definition which uses the state of the statement at the time
276276
of definedAs() call.
277277
*/
@@ -324,7 +324,7 @@ class ViewSecurity
324324
public:
325325

326326
/**
327-
Specify security characteristisc of a view.
327+
Specify security characteristics of a view.
328328
329329
@see https://dev.mysql.com/doc/refman/5.7/en/stored-programs-security.html
330330
*/
@@ -363,8 +363,9 @@ class ViewAlgorithm
363363

364364

365365
/*
366-
Base blass for Create/Alter View
366+
Base class for Create/Alter View
367367
*/
368+
368369
template <class Op>
369370
class View_base
370371
: public ViewAlgorithm<Op>
@@ -887,26 +888,51 @@ class PUBLIC_API Table
887888
Represents session options to be passed at XSession/NodeSession object
888889
creation.
889890
890-
SessionSettings can be constructed using uri, common connect options (host,
891-
port, user, password, database) or using pairs of SessionSettings::Options -
892-
Value objects.
891+
SessionSettings can be constructed using URL string, common connect options
892+
(host, port, user, password, database) or with a list
893+
of `SessionSettings::Options` constants followed by option value (unless
894+
given option has no value, like `SSL_ENABLE`).
895+
896+
Examples:
897+
~~~~~~
898+
899+
SessionSettings from_url(http://github.com/"mysqlx://user:pwd@host:port/db?ssl-enable");
900+
901+
SessionSettings from_options("host", port, "user", "pwd", "db");
902+
903+
SessionSettings from_option_list(
904+
SessionSettings::USER, "user",
905+
SessionSettings::PWD, "pwd",
906+
SessionSettings::HOST, "host",
907+
SessionSettings::PORT, port,
908+
SessionSettings::DB, "db",
909+
SessionSettings::SSL_ENABLE
910+
);
911+
~~~~~~
893912
894913
@ingroup devapi
895914
*/
896915

897916
class PUBLIC_API SessionSettings
898917
{
899918
public:
919+
920+
/**
921+
Session creation options
922+
923+
@note Specifying `SSL_CA` option implies `SSL_ENABLE`.
924+
*/
925+
900926
enum Options
901927
{
902-
URI,
903-
HOST,
904-
PORT,
905-
USER,
906-
PWD,
907-
DB,
908-
SSL_ENABLE,
909-
SSL_CA
928+
URI, //!< connection URI or string
929+
HOST, //!< host name or IP address
930+
PORT, //!< X Plugin port to connect to
931+
USER, //!< user name
932+
PWD, //!< password
933+
DB, //!< default database
934+
SSL_ENABLE, //!< use TLS connection
935+
SSL_CA //!< path to a PEM file specifying trusted root certificates
910936
};
911937

912938

@@ -922,6 +948,19 @@ class PUBLIC_API SessionSettings
922948
{}
923949

924950

951+
/**
952+
Create a session using connection string or URL.
953+
954+
Connection sting has the form `"user:pass\@host:port/?option&option"`,
955+
valid URL is like a connection string with a `mysqlx://` prefix. Possible
956+
connection options are:
957+
958+
- `ssl-enable` : use TLS connection
959+
- `ssl-ca=`<path> : path to a PEM file specifying trusted root certificates
960+
961+
Specifying `ssl-ca` option implies `ssl-enable`.
962+
*/
963+
925964
SessionSettings(const string &uri)
926965
{
927966
add(URI, uri);
@@ -930,6 +969,9 @@ class PUBLIC_API SessionSettings
930969

931970
/**
932971
Create session explicitly specifying session parameters.
972+
973+
@note Session settings constructed this way request an SSL connection
974+
by default.
933975
*/
934976

935977
SessionSettings(const std::string &host, unsigned port,
@@ -956,9 +998,12 @@ class PUBLIC_API SessionSettings
956998
: SessionSettings(host, port, user, pwd.c_str(), db)
957999
{}
9581000

959-
/**
960-
Create session using the default port
961-
*/
1001+
/**
1002+
Create session using the default port
1003+
1004+
@note Session settings constructed this way request an SSL connection
1005+
by default.
1006+
*/
9621007

9631008
SessionSettings(const std::string &host,
9641009
const string &user,
@@ -974,9 +1019,12 @@ class PUBLIC_API SessionSettings
9741019
: SessionSettings(host, DEFAULT_MYSQLX_PORT, user, pwd, db)
9751020
{}
9761021

977-
/**
978-
Create session on localhost.
979-
*/
1022+
/**
1023+
Create session on localhost.
1024+
1025+
@note Session settings constructed this way request an SSL connection
1026+
by default.
1027+
*/
9801028

9811029
SessionSettings(unsigned port,
9821030
const string &user,
@@ -1054,7 +1102,25 @@ class PUBLIC_API SessionSettings
10541102

10551103

10561104
/**
1057-
Passing option - value pairs
1105+
Create session using a list of session options.
1106+
1107+
The list of options consist of `SessionSettings::Options` constant
1108+
identifying the option to set, followed by option value (unless
1109+
not required, as in the case of `SSL_ENABLE`).
1110+
1111+
Example:
1112+
~~~~~~
1113+
SessionSettings from_option_list(
1114+
SessionSettings::USER, "user",
1115+
SessionSettings::PWD, "pwd",
1116+
SessionSettings::HOST, "host",
1117+
SessionSettings::PORT, port,
1118+
SessionSettings::DB, "db",
1119+
SessionSettings::SSL_ENABLE
1120+
);
1121+
~~~~~~
1122+
1123+
@see `SessionSettings::Options`.
10581124
*/
10591125

10601126
template <typename V,typename...R>
@@ -1155,14 +1221,6 @@ namespace internal {
11551221

11561222
public:
11571223

1158-
/**
1159-
Create session specified by mysqlx connection string.
1160-
1161-
Connection string can be either an utf8 encoded single-byte
1162-
string or a wide string (which is converted to utf8 before
1163-
parsing).
1164-
*/
1165-
11661224
XSession_base(SessionSettings settings);
11671225

11681226
template<typename...T>
@@ -1303,11 +1361,42 @@ class PUBLIC_API XSession
13031361

13041362
public:
13051363

1364+
/**
1365+
Create session specified by `SessionSettings` object.
1366+
*/
1367+
13061368
XSession(SessionSettings settings)
13071369
: XSession_base(settings)
13081370
{}
13091371

13101372

1373+
/**
1374+
Create session using given session settings.
1375+
1376+
This constructor forwards arguments to a `SessionSettings` constructor.
1377+
Thus all forms of specifying session options are also directly available
1378+
in `XSession` constructor.
1379+
1380+
Examples:
1381+
~~~~~~
1382+
1383+
XSession from_uri("mysqlx://user:pwd@host:port/db?ssl-enable");
1384+
1385+
XSession from_options("host", port, "user", "pwd", "db");
1386+
1387+
XSession from_option_list(
1388+
SessionSettings::USER, "user",
1389+
SessionSettings::PWD, "pwd",
1390+
SessionSettings::HOST, "host",
1391+
SessionSettings::PORT, port,
1392+
SessionSettings::DB, "db",
1393+
SessionSettings::SSL_ENABLE
1394+
);
1395+
~~~~~~
1396+
1397+
@see `SessionSettings`
1398+
*/
1399+
13111400
template<typename...T>
13121401
XSession(T...options)
13131402
: XSession_base(SessionSettings(options...))

include/mysql_xapi.h

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ typedef object_id* MYSQLX_GUID;
106106
/**
107107
Return value flag indicating that the last reading operation
108108
did not finish reading to the end and there is still more data
109-
to be fetched by functions suchs as mysqlx_get_bytes()
109+
to be fetched by functions such as mysqlx_get_bytes()
110110
*/
111111

112112
#define RESULT_MORE_DATA 8
@@ -331,17 +331,18 @@ typedef enum mysqlx_sort_direction_enum
331331
Session options for use with `mysqlx_session_option_get()`
332332
and `mysqlx_session_option_set()` functions.
333333
334-
TODO: Document the options and what data they expect
334+
@note Specifying `MYSQLX_OPT_SSL_CA` option implies `MYSQLX_OPT_SSL_ENABLE`.
335335
*/
336336

337337
typedef enum mysqlx_opt_type_enum
338338
{
339-
MYSQLX_OPT_HOST = 1,
340-
MYSQLX_OPT_PORT = 2,
341-
MYSQLX_OPT_USER = 3,
342-
MYSQLX_OPT_PWD = 4,
343-
MYSQLX_OPT_DB = 5,
344-
MYSQLX_OPT_SSL_ENABLE = 6,
339+
MYSQLX_OPT_HOST = 1, /**< host name or IP address */
340+
MYSQLX_OPT_PORT = 2, /**< X Plugin port to connect to */
341+
MYSQLX_OPT_USER = 3, /**< user name */
342+
MYSQLX_OPT_PWD = 4, /**< password */
343+
MYSQLX_OPT_DB = 5, /**< default database */
344+
MYSQLX_OPT_SSL_ENABLE = 6, /**< use TLS connection */
345+
/** path to a PEM file specifying trusted root certificates */
345346
MYSQLX_OPT_SSL_CA = 7,
346347
}
347348
mysqlx_opt_type_t;
@@ -427,13 +428,19 @@ mysqlx_get_session(const char *host, int port, const char *user,
427428
/**
428429
Create a session using connection string or URL.
429430
430-
Connection sting has the form `"user:pass\@host:port/?option"`, valid URL
431-
is like a connection string with a `mysqlx://` prefix.
431+
Connection sting has the form `"user:pass\@host:port/?option&option"`,
432+
valid URL is like a connection string with a `mysqlx://` prefix. Possible
433+
connection options are:
432434
433-
@param conn_string character connection string
435+
- `ssl-enable` : use TLS connection
436+
- `ssl-ca=`<path> : path to a PEM file specifying trusted root certificates
437+
438+
Specifying `ssl-ca` option implies `ssl-enable`.
439+
440+
@param conn_string connection string
434441
@param[out] out_error if error happens during connect the error message
435442
is returned through this parameter
436-
@param[out] err_code if error happens during connect the error code
443+
@param[out] err_code if error happens during connect the error code
437444
is returned through this parameter
438445
439446
@return session handle if session could be created, otherwise NULL
@@ -2895,7 +2902,7 @@ mysqlx_result_next_warning(mysqlx_result_t *res);
28952902
The order of parameters in the list is not fixed, but if
28962903
`VIEW_COLUMNS()` (`VIEW_OPTION_COLUMNS`) is used it must be the
28972904
last parameter before terminating the list with `PARAM_END`. See documentation
2898-
of the convenience macros for more details on possible vuew definition
2905+
of the convenience macros for more details on possible view definition
28992906
options
29002907
29012908
@@ -2911,7 +2918,7 @@ mysqlx_view_create(mysqlx_schema_t *schema, const char *name,
29112918

29122919

29132920
/**
2914-
Return a new statement which careates a view
2921+
Return a new statement which creates a view
29152922
29162923
Creates a statement which will be used for creating a new view
29172924
in a given schema based on a previously defined select statement. Before

0 commit comments

Comments
 (0)