Skip to content

Commit 97a6547

Browse files
committed
WL#10037 (View DDL) Documenttion.
1 parent ca755a6 commit 97a6547

File tree

2 files changed

+473
-45
lines changed

2 files changed

+473
-45
lines changed

include/mysql_devapi.h

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -162,26 +162,37 @@ class PUBLIC_API DatabaseObject
162162

163163

164164
/**
165-
View creation and alter classes
166-
*/
165+
Check options for an updatable view.
166+
@see https://dev.mysql.com/doc/refman/5.7/en/view-check-option.html
167+
*/
167168

168169
enum class CheckOption
169170
{
170-
CASCADED,
171-
LOCAL
171+
CASCADED, //!< cascaded
172+
LOCAL //!< local
172173
};
173174

175+
/**
176+
Algorithms used to process views.
177+
@see https://dev.mysql.com/doc/refman/5.7/en/view-algorithms.html
178+
*/
179+
174180
enum class Algorithm
175181
{
176-
UNDEFINED,
177-
MERGE,
178-
TEMPTABLE
182+
UNDEFINED, //!< undefined
183+
MERGE, //!< merge
184+
TEMPTABLE //!< temptable
179185
};
180186

187+
/**
188+
View security settings.
189+
@see https://dev.mysql.com/doc/refman/5.7/en/stored-programs-security.html
190+
*/
191+
181192
enum class SQLSecurity
182193
{
183-
DEFINER,
184-
INVOKER
194+
DEFINER, //!< definer
195+
INVOKER //!< invoker
185196
};
186197

187198

@@ -224,43 +235,58 @@ class ViewCheckOpt
224235
public:
225236

226237
/**
227-
Set constraints on the View.
238+
Specify checks that are done upon insertion of rows into an updatable
239+
view.
240+
241+
@see https://dev.mysql.com/doc/refman/5.7/en/view-check-option.html
228242
*/
243+
229244
Executable<Result,Op> withCheckOption(CheckOption option)
230245
{
231246
get_impl()->with_check_option(option);
232247
return std::move(*this);
233248
}
234249
};
235250

251+
236252
template <class Op>
237253
class ViewDefinedAs
238-
: protected ViewCheckOpt<Op>
254+
: public ViewCheckOpt<Op>
239255
{
240256
protected:
241257

242258
using ViewCheckOpt<Op>::get_impl;
243259

244260
public:
245261

246-
/**
247-
Define the table select statement to generate the View.
248-
*/
249-
262+
///@{
263+
// TODO: How to copy documentation here?
250264
ViewCheckOpt<Op> definedAs(TableSelect&& table)
251265
{
252266
get_impl()->defined_as(std::move(table));
253267
return std::move(*this);
254268
}
255269

270+
/**
271+
Specify table select operation for which the view is created.
272+
273+
@note In situations where select statement is modified after
274+
passing it to definedAs() method, later changes do not afffect
275+
view definition which uses the state of the statement at the time
276+
of definedAs() call.
277+
*/
278+
256279
ViewCheckOpt<Op> definedAs(const TableSelect& table)
257280
{
258281
TableSelect table_tmp(table);
259282
get_impl()->defined_as(std::move(table_tmp));
260283
return std::move(*this);
261284
}
285+
286+
///@}
262287
};
263288

289+
264290
template <class Op>
265291
class ViewDefiner
266292
: public ViewDefinedAs<Op>
@@ -272,7 +298,12 @@ class ViewDefiner
272298
public:
273299

274300
/**
275-
Define the View’s definer.
301+
Specify definer of a view.
302+
303+
The definer is used to determine access rights for the view. It is specified
304+
as a valid MySQL account name of the form "user@host".
305+
306+
@see https://dev.mysql.com/doc/refman/5.7/en/stored-programs-security.html
276307
*/
277308
ViewDefinedAs<Op> definer(const string &user)
278309
{
@@ -281,6 +312,7 @@ class ViewDefiner
281312
}
282313
};
283314

315+
284316
template <class Op>
285317
class ViewSecurity
286318
: public ViewDefiner<Op>
@@ -292,15 +324,19 @@ class ViewSecurity
292324
public:
293325

294326
/**
295-
Define the View’s security scheme.
327+
Specify security characteristisc of a view.
328+
329+
@see https://dev.mysql.com/doc/refman/5.7/en/stored-programs-security.html
296330
*/
331+
297332
ViewDefiner<Op> security(SQLSecurity sec)
298333
{
299334
get_impl()->security(sec);
300335
return std::move(*this);
301336
}
302337
};
303338

339+
304340
template <class Op>
305341
class ViewAlgorithm
306342
: public ViewSecurity<Op>
@@ -312,7 +348,9 @@ class ViewAlgorithm
312348
public:
313349

314350
/**
315-
define the View’s algorithm.
351+
Specify algorithm used to process the view.
352+
353+
@see https://dev.mysql.com/doc/refman/5.7/en/view-algorithms.html
316354
*/
317355

318356
ViewSecurity<Op> algorithm(Algorithm alg)
@@ -365,7 +403,7 @@ class View_base
365403

366404
/**
367405
Define the column names of the created/altered View.
368-
*/
406+
*/
369407

370408
template<typename...T>
371409
ViewAlgorithm<Op> columns(const T&...names)
@@ -386,7 +424,12 @@ class View_base
386424
} // namespace internal
387425

388426
/**
389-
The ViewCreate class represents the creation of a view
427+
Represents an operation which creates a view.
428+
429+
The query for which the view is created must be specified with
430+
`definedAs()` method. Other methods can specify different view creation
431+
options. When operation is fully specified, it can be executed with
432+
a call to `execute()`.
390433
*/
391434

392435
class PUBLIC_API ViewCreate
@@ -403,7 +446,11 @@ class PUBLIC_API ViewCreate
403446

404447

405448
/**
406-
The ViewCreate class represents the creation of a view
449+
Represents an operation which modifies an existing view.
450+
451+
ViewAlter operation must specify new query for the view with
452+
`definedAs()` method (it is not possible to change other characteristics
453+
of a view without changing its query).
407454
*/
408455

409456
class PUBLIC_API ViewAlter
@@ -421,11 +468,8 @@ class PUBLIC_API ViewAlter
421468

422469
namespace internal {
423470

424-
/*
425-
View drop classes
426-
*/
427471

428-
struct ViewDrop_impl
472+
struct ViewDrop_impl
429473
: public Executable_impl
430474
{
431475
virtual void if_exists() = 0;
@@ -449,6 +493,11 @@ class ViewDropIfExists
449493

450494
public:
451495

496+
/**
497+
Modify drop view operation so that it checks existence of the view
498+
before dropping it.
499+
*/
500+
452501
Executable<Result,Op> ifExists()
453502
{
454503
get_impl()->if_exists();
@@ -458,8 +507,9 @@ class ViewDropIfExists
458507

459508
} // namespace internal
460509

510+
461511
/**
462-
The ViewDrop class represents the drop of a view
512+
Represents an operation which drops a view.
463513
*/
464514

465515
class PUBLIC_API ViewDrop

0 commit comments

Comments
 (0)