@@ -162,26 +162,37 @@ class PUBLIC_API DatabaseObject
162
162
163
163
164
164
/* *
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
+ */
167
168
168
169
enum class CheckOption
169
170
{
170
- CASCADED,
171
- LOCAL
171
+ CASCADED, // !< cascaded
172
+ LOCAL // !< local
172
173
};
173
174
175
+ /* *
176
+ Algorithms used to process views.
177
+ @see https://dev.mysql.com/doc/refman/5.7/en/view-algorithms.html
178
+ */
179
+
174
180
enum class Algorithm
175
181
{
176
- UNDEFINED,
177
- MERGE,
178
- TEMPTABLE
182
+ UNDEFINED, // !< undefined
183
+ MERGE, // !< merge
184
+ TEMPTABLE // !< temptable
179
185
};
180
186
187
+ /* *
188
+ View security settings.
189
+ @see https://dev.mysql.com/doc/refman/5.7/en/stored-programs-security.html
190
+ */
191
+
181
192
enum class SQLSecurity
182
193
{
183
- DEFINER,
184
- INVOKER
194
+ DEFINER, // !< definer
195
+ INVOKER // !< invoker
185
196
};
186
197
187
198
@@ -224,43 +235,58 @@ class ViewCheckOpt
224
235
public:
225
236
226
237
/* *
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
228
242
*/
243
+
229
244
Executable<Result,Op> withCheckOption (CheckOption option)
230
245
{
231
246
get_impl ()->with_check_option (option);
232
247
return std::move (*this );
233
248
}
234
249
};
235
250
251
+
236
252
template <class Op >
237
253
class ViewDefinedAs
238
- : protected ViewCheckOpt<Op>
254
+ : public ViewCheckOpt<Op>
239
255
{
240
256
protected:
241
257
242
258
using ViewCheckOpt<Op>::get_impl;
243
259
244
260
public:
245
261
246
- /* *
247
- Define the table select statement to generate the View.
248
- */
249
-
262
+ // /@{
263
+ // TODO: How to copy documentation here?
250
264
ViewCheckOpt<Op> definedAs (TableSelect&& table)
251
265
{
252
266
get_impl ()->defined_as (std::move (table));
253
267
return std::move (*this );
254
268
}
255
269
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
+
256
279
ViewCheckOpt<Op> definedAs (const TableSelect& table)
257
280
{
258
281
TableSelect table_tmp (table);
259
282
get_impl ()->defined_as (std::move (table_tmp));
260
283
return std::move (*this );
261
284
}
285
+
286
+ // /@}
262
287
};
263
288
289
+
264
290
template <class Op >
265
291
class ViewDefiner
266
292
: public ViewDefinedAs<Op>
@@ -272,7 +298,12 @@ class ViewDefiner
272
298
public:
273
299
274
300
/* *
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
276
307
*/
277
308
ViewDefinedAs<Op> definer (const string &user)
278
309
{
@@ -281,6 +312,7 @@ class ViewDefiner
281
312
}
282
313
};
283
314
315
+
284
316
template <class Op >
285
317
class ViewSecurity
286
318
: public ViewDefiner<Op>
@@ -292,15 +324,19 @@ class ViewSecurity
292
324
public:
293
325
294
326
/* *
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
296
330
*/
331
+
297
332
ViewDefiner<Op> security (SQLSecurity sec)
298
333
{
299
334
get_impl ()->security (sec);
300
335
return std::move (*this );
301
336
}
302
337
};
303
338
339
+
304
340
template <class Op >
305
341
class ViewAlgorithm
306
342
: public ViewSecurity<Op>
@@ -312,7 +348,9 @@ class ViewAlgorithm
312
348
public:
313
349
314
350
/* *
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
316
354
*/
317
355
318
356
ViewSecurity<Op> algorithm (Algorithm alg)
@@ -365,7 +403,7 @@ class View_base
365
403
366
404
/* *
367
405
Define the column names of the created/altered View.
368
- */
406
+ */
369
407
370
408
template <typename ...T>
371
409
ViewAlgorithm<Op> columns (const T&...names)
@@ -386,7 +424,12 @@ class View_base
386
424
} // namespace internal
387
425
388
426
/* *
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()`.
390
433
*/
391
434
392
435
class PUBLIC_API ViewCreate
@@ -403,7 +446,11 @@ class PUBLIC_API ViewCreate
403
446
404
447
405
448
/* *
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).
407
454
*/
408
455
409
456
class PUBLIC_API ViewAlter
@@ -421,11 +468,8 @@ class PUBLIC_API ViewAlter
421
468
422
469
namespace internal {
423
470
424
- /*
425
- View drop classes
426
- */
427
471
428
- struct ViewDrop_impl
472
+ struct ViewDrop_impl
429
473
: public Executable_impl
430
474
{
431
475
virtual void if_exists () = 0;
@@ -449,6 +493,11 @@ class ViewDropIfExists
449
493
450
494
public:
451
495
496
+ /* *
497
+ Modify drop view operation so that it checks existence of the view
498
+ before dropping it.
499
+ */
500
+
452
501
Executable<Result,Op> ifExists ()
453
502
{
454
503
get_impl ()->if_exists ();
@@ -458,8 +507,9 @@ class ViewDropIfExists
458
507
459
508
} // namespace internal
460
509
510
+
461
511
/* *
462
- The ViewDrop class represents the drop of a view
512
+ Represents an operation which drops a view.
463
513
*/
464
514
465
515
class PUBLIC_API ViewDrop
0 commit comments