1Rose::DB::MariaDB(3) User Contributed Perl Documentation Rose::DB::MariaDB(3)
2
3
4
6 Rose::DB::MariaDB - MariaDB driver class for Rose::DB.
7
9 use Rose::DB;
10
11 Rose::DB->register_db(
12 domain => 'development',
13 type => 'main',
14 driver => 'mariadb',
15 database => 'dev_db',
16 host => 'localhost',
17 username => 'devuser',
18 password => 'mysecret',
19 );
20
21
22 Rose::DB->default_domain('development');
23 Rose::DB->default_type('main');
24 ...
25
26 # Set max length of varchar columns used to emulate the array data type
27 Rose::DB::MariaDB->max_array_characters(128);
28
29 $db = Rose::DB->new; # $db is really a Rose::DB::MariaDB-derived object
30 ...
31
33 Rose::DB blesses objects into a class derived from Rose::DB::MariaDB
34 when the driver is "mariadb". This mapping of driver names to class
35 names is configurable. See the documentation for Rose::DB's new() and
36 driver_class() methods for more information.
37
38 This class cannot be used directly. You must use Rose::DB and let its
39 new() method return an object blessed into the appropriate class for
40 you, according to its driver_class() mappings.
41
42 Only the methods that are new or have different behaviors than those in
43 Rose::DB are documented here. See the Rose::DB documentation for the
44 full list of methods.
45
47 coerce_autoincrement_to_serial [BOOL]
48 Get or set a boolean value that indicates whether or not "auto-
49 increment" columns will be considered to have the column type
50 "serial." If true, "integer" columns are coerced to the "serial"
51 column type, and "bigint" columns use the "bigserial" column type.
52 The default value is true.
53
54 This setting comes into play when Rose::DB::Object::Loader is used
55 to auto-create column metadata based on an existing database
56 schema.
57
58 max_array_characters [INT]
59 Get or set the maximum length of varchar columns used to emulate
60 the array data type. The default value is 255.
61
62 MariaDB does not have a native "ARRAY" data type, but this data
63 type can be emulated using a "VARCHAR" column and a specially
64 formatted string. The formatting and parsing of this string is
65 handled by the format_array and parse_array object methods. The
66 maximum length limit is honored by the format_array object method.
67
68 max_interval_characters [INT]
69 Get or set the maximum length of varchar columns used to emulate
70 the interval data type. The default value is 255.
71
72 MariaDB does not have a native "interval" data type, but this data
73 type can be emulated using a "VARCHAR" column and a specially
74 formatted string. The formatting and parsing of this string is
75 handled by the format_interval and parse_interval object methods.
76 The maximum length limit is honored by the format_interval object
77 method.
78
80 mariadb_auto_reconnect [BOOL]
81 Get or set the mariadb_auto_reconnect database handle attribute.
82 This is set directly on the dbh, if one exists. Otherwise, it will
83 be set when the dbh is created. If no value for this attribute is
84 defined (the default) then it will not be set when the dbh is
85 created, deferring instead to whatever default value DBD::MariaDB
86 chooses.
87
88 Returns the value of this attribute in the dbh, if one exists, or
89 the value that will be set when the dbh is next created.
90
91 See the DBD::MariaDB documentation to learn more about this
92 attribute.
93
94 mariadb_bind_type_guessing [BOOL]
95 Get or set the mariadb_bind_type_guessing database handle
96 attribute. This is set directly on the dbh, if one exists.
97 Otherwise, it will be set when the dbh is created. If no value for
98 this attribute is defined (the default) then it will not be set
99 when the dbh is created, deferring instead to whatever default
100 value DBD::MariaDB chooses.
101
102 Returns the value of this attribute in the dbh, if one exists, or
103 the value that will be set when the dbh is next created.
104
105 See the DBD::MariaDB documentation to learn more about this
106 attribute.
107
108 mariadb_client_found_rows [BOOL]
109 Get or set the mariadb_client_found_rows database handle attribute.
110 This is set directly on the dbh, if one exists. Otherwise, it will
111 be set when the dbh is created. If no value for this attribute is
112 defined (the default) then it will not be set when the dbh is
113 created, deferring instead to whatever default value DBD::MariaDB
114 chooses.
115
116 Returns the value of this attribute in the dbh, if one exists, or
117 the value that will be set when the dbh is next created.
118
119 See the DBD::MariaDB documentation to learn more about this
120 attribute.
121
122 mariadb_compression [BOOL]
123 Get or set the mariadb_compression database handle attribute. This
124 is set directly on the dbh, if one exists. Otherwise, it will be
125 set when the dbh is created. If no value for this attribute is
126 defined (the default) then it will not be set when the dbh is
127 created, deferring instead to whatever default value DBD::MariaDB
128 chooses.
129
130 Returns the value of this attribute in the dbh, if one exists, or
131 the value that will be set when the dbh is next created.
132
133 See the DBD::MariaDB documentation to learn more about this
134 attribute.
135
136 mariadb_connect_timeout [BOOL]
137 Get or set the mariadb_connect_timeout database handle attribute.
138 This is set directly on the dbh, if one exists. Otherwise, it will
139 be set when the dbh is created. If no value for this attribute is
140 defined (the default) then it will not be set when the dbh is
141 created, deferring instead to whatever default value DBD::MariaDB
142 chooses.
143
144 Returns the value of this attribute in the dbh, if one exists, or
145 the value that will be set when the dbh is next created.
146
147 See the DBD::MariaDB documentation to learn more about this
148 attribute.
149
150 mariadb_embedded_groups [STRING]
151 Get or set the mariadb_embedded_groups database handle attribute.
152 This is set directly on the dbh, if one exists. Otherwise, it will
153 be set when the dbh is created. If no value for this attribute is
154 defined (the default) then it will not be set when the dbh is
155 created, deferring instead to whatever default value DBD::MariaDB
156 chooses.
157
158 Returns the value of this attribute in the dbh, if one exists, or
159 the value that will be set when the dbh is next created.
160
161 See the DBD::MariaDB documentation to learn more about this
162 attribute.
163
164 mariadb_embedded_options [STRING]
165 Get or set the mariadb_embedded_options database handle attribute.
166 This is set directly on the dbh, if one exists. Otherwise, it will
167 be set when the dbh is created. If no value for this attribute is
168 defined (the default) then it will not be set when the dbh is
169 created, deferring instead to whatever default value DBD::MariaDB
170 chooses.
171
172 Returns the value of this attribute in the dbh, if one exists, or
173 the value that will be set when the dbh is next created.
174
175 See the DBD::MariaDB documentation to learn more about this
176 attribute.
177
178 mariadb_enable_utf8 [BOOL]
179 Get or set the mariadb_enable_utf8 database handle attribute. This
180 is set directly on the dbh, if one exists, by executing the SQL
181 "SET NAMES utf8". Otherwise, it will be set when the dbh is
182 created. If no value for this attribute is defined (the default)
183 then it will not be set when the dbh is created, deferring instead
184 to whatever default value DBD::MariaDB chooses.
185
186 Returns the value of this attribute in the dbh, if one exists, or
187 the value that will be set when the dbh is next created.
188
189 See the DBD::MariaDB documentation to learn more about this
190 attribute.
191
192 mariadb_enable_utf8mb4 [BOOL]
193 Get or set the mariadb_enable_utf8mb4 database handle attribute.
194 This is set directly on the dbh, if one exists, by executing the
195 SQL "SET NAMES utf8mb4". Otherwise, it will be set when the dbh is
196 created. If no value for this attribute is defined (the default)
197 then it will not be set when the dbh is created, deferring instead
198 to whatever default value DBD::MariaDB chooses.
199
200 Returns the value of this attribute in the dbh, if one exists, or
201 the value that will be set when the dbh is next created.
202
203 See the DBD::MariaDB documentation to learn more about this
204 attribute.
205
206 mariadb_local_infile [STRING]
207 Get or set the mariadb_local_infile database handle attribute.
208 This is set directly on the dbh, if one exists. Otherwise, it will
209 be set when the dbh is created. If no value for this attribute is
210 defined (the default) then it will not be set when the dbh is
211 created, deferring instead to whatever default value DBD::MariaDB
212 chooses.
213
214 Returns the value of this attribute in the dbh, if one exists, or
215 the value that will be set when the dbh is next created.
216
217 See the DBD::MariaDB documentation to learn more about this
218 attribute.
219
220 mariadb_multi_statements [BOOL]
221 Get or set the mariadb_multi_statements database handle attribute.
222 This is set directly on the dbh, if one exists. Otherwise, it will
223 be set when the dbh is created. If no value for this attribute is
224 defined (the default) then it will not be set when the dbh is
225 created, deferring instead to whatever default value DBD::MariaDB
226 chooses.
227
228 Returns the value of this attribute in the dbh, if one exists, or
229 the value that will be set when the dbh is next created.
230
231 See the DBD::MariaDB documentation to learn more about this
232 attribute.
233
234 mariadb_read_default_file [STRING]
235 Get or set the mariadb_read_default_file database handle attribute.
236 This is set directly on the dbh, if one exists. Otherwise, it will
237 be set when the dbh is created. If no value for this attribute is
238 defined (the default) then it will not be set when the dbh is
239 created, deferring instead to whatever default value DBD::MariaDB
240 chooses.
241
242 Returns the value of this attribute in the dbh, if one exists, or
243 the value that will be set when the dbh is next created.
244
245 See the DBD::MariaDB documentation to learn more about this
246 attribute.
247
248 mariadb_read_default_group [STRING]
249 Get or set the mariadb_read_default_group database handle
250 attribute. This is set directly on the dbh, if one exists.
251 Otherwise, it will be set when the dbh is created. If no value for
252 this attribute is defined (the default) then it will not be set
253 when the dbh is created, deferring instead to whatever default
254 value DBD::MariaDB chooses.
255
256 Returns the value of this attribute in the dbh, if one exists, or
257 the value that will be set when the dbh is next created.
258
259 See the DBD::MariaDB documentation to learn more about this
260 attribute.
261
262 mariadb_socket [STRING]
263 Get or set the mariadb_socket database handle attribute. This is
264 set directly on the dbh, if one exists. Otherwise, it will be set
265 when the dbh is created. If no value for this attribute is defined
266 (the default) then it will not be set when the dbh is created,
267 deferring instead to whatever default value DBD::MariaDB chooses.
268
269 Returns the value of this attribute in the dbh, if one exists, or
270 the value that will be set when the dbh is next created.
271
272 See the DBD::MariaDB documentation to learn more about this
273 attribute.
274
275 mariadb_ssl [BOOL]
276 Get or set the mariadb_ssl database handle attribute. This is set
277 directly on the dbh, if one exists. Otherwise, it will be set when
278 the dbh is created. If no value for this attribute is defined (the
279 default) then it will not be set when the dbh is created, deferring
280 instead to whatever default value DBD::MariaDB chooses.
281
282 Returns the value of this attribute in the dbh, if one exists, or
283 the value that will be set when the dbh is next created.
284
285 See the DBD::MariaDB documentation to learn more about this
286 attribute.
287
288 mariadb_ssl_ca_file [STRING]
289 Get or set the mariadb_ssl_ca_file database handle attribute. This
290 is set directly on the dbh, if one exists. Otherwise, it will be
291 set when the dbh is created. If no value for this attribute is
292 defined (the default) then it will not be set when the dbh is
293 created, deferring instead to whatever default value DBD::MariaDB
294 chooses.
295
296 Returns the value of this attribute in the dbh, if one exists, or
297 the value that will be set when the dbh is next created.
298
299 See the DBD::MariaDB documentation to learn more about this
300 attribute.
301
302 mariadb_ssl_ca_path [STRING]
303 Get or set the mariadb_ssl_ca_path database handle attribute. This
304 is set directly on the dbh, if one exists. Otherwise, it will be
305 set when the dbh is created. If no value for this attribute is
306 defined (the default) then it will not be set when the dbh is
307 created, deferring instead to whatever default value DBD::MariaDB
308 chooses.
309
310 Returns the value of this attribute in the dbh, if one exists, or
311 the value that will be set when the dbh is next created.
312
313 See the DBD::MariaDB documentation to learn more about this
314 attribute.
315
316 mariadb_ssl_cipher [STRING]
317 Get or set the mariadb_ssl_cipher database handle attribute. This
318 is set directly on the dbh, if one exists. Otherwise, it will be
319 set when the dbh is created. If no value for this attribute is
320 defined (the default) then it will not be set when the dbh is
321 created, deferring instead to whatever default value DBD::MariaDB
322 chooses.
323
324 Returns the value of this attribute in the dbh, if one exists, or
325 the value that will be set when the dbh is next created.
326
327 See the DBD::MariaDB documentation to learn more about this
328 attribute.
329
330 mariadb_ssl_client_cert [STRING]
331 Get or set the mariadb_ssl_client_cert database handle attribute.
332 This is set directly on the dbh, if one exists. Otherwise, it will
333 be set when the dbh is created. If no value for this attribute is
334 defined (the default) then it will not be set when the dbh is
335 created, deferring instead to whatever default value DBD::MariaDB
336 chooses.
337
338 Returns the value of this attribute in the dbh, if one exists, or
339 the value that will be set when the dbh is next created.
340
341 See the DBD::MariaDB documentation to learn more about this
342 attribute.
343
344 mariadb_ssl_client_key [STRING]
345 Get or set the mariadb_ssl_client_key database handle attribute.
346 This is set directly on the dbh, if one exists. Otherwise, it will
347 be set when the dbh is created. If no value for this attribute is
348 defined (the default) then it will not be set when the dbh is
349 created, deferring instead to whatever default value DBD::MariaDB
350 chooses.
351
352 Returns the value of this attribute in the dbh, if one exists, or
353 the value that will be set when the dbh is next created.
354
355 See the DBD::MariaDB documentation to learn more about this
356 attribute.
357
358 mariadb_use_result [BOOL]
359 Get or set the mariadb_use_result database handle attribute. This
360 is set directly on the dbh, if one exists. Otherwise, it will be
361 set when the dbh is created. If no value for this attribute is
362 defined (the default) then it will not be set when the dbh is
363 created, deferring instead to whatever default value DBD::MariaDB
364 chooses.
365
366 Returns the value of this attribute in the dbh, if one exists, or
367 the value that will be set when the dbh is next created.
368
369 See the DBD::MariaDB documentation to learn more about this
370 attribute.
371
372 Value Parsing and Formatting
373 format_array ARRAYREF | LIST
374 Given a reference to an array or a list of values, return a
375 specially formatted string. Undef is returned if ARRAYREF points
376 to an empty array or if LIST is not passed. The array or list must
377 not contain undefined values.
378
379 If the resulting string is longer than max_array_characters, a
380 fatal error will occur.
381
382 format_interval DURATION
383 Given a DateTime::Duration object, return a string formatted
384 according to the rules of PostgreSQL's "INTERVAL" column type. If
385 DURATION is undefined, a DateTime::Duration object, a valid
386 interval keyword (according to validate_interval_keyword), or if it
387 looks like a function call (matches "/^\w+\(.*\)$/") and
388 keyword_function_calls is true, then it is returned unmodified.
389
390 If the resulting string is longer than max_interval_characters, a
391 fatal error will occur.
392
393 format_set ARRAYREF | LIST
394 Given a reference to an array or a list of values, return a string
395 formatted according to the rules of MariaDB's "SET" data type.
396 Undef is returned if ARRAYREF points to an empty array or if LIST
397 is not passed. If the array or list contains undefined values, a
398 fatal error will occur.
399
400 parse_array STRING | LIST | ARRAYREF
401 Parse STRING and return a reference to an array. STRING should be
402 formatted according to the MariaDB array data type emulation format
403 returned by format_array(). Undef is returned if STRING is
404 undefined.
405
406 If a LIST of more than one item is passed, a reference to an array
407 containing the values in LIST is returned.
408
409 If a an ARRAYREF is passed, it is returned as-is.
410
411 parse_interval STRING
412 Parse STRING and return a DateTime::Duration object. STRING should
413 be formatted according to the PostgreSQL native "interval" (years,
414 months, days, hours, minutes, seconds) data type.
415
416 If STRING is a DateTime::Duration object, a valid interval keyword
417 (according to validate_interval_keyword), or if it looks like a
418 function call (matches "/^\w+\(.*\)$/") and keyword_function_calls
419 is true, then it is returned unmodified. Otherwise, undef is
420 returned if STRING could not be parsed as a valid "interval" value.
421
422 parse_set STRING | LIST | ARRAYREF
423 Parse STRING and return a reference to an array. STRING should be
424 formatted according to MariaDB's "SET" data type. Undef is
425 returned if STRING is undefined.
426
427 If a LIST of more than one item is passed, a reference to an array
428 containing the values in LIST is returned.
429
430 If a an ARRAYREF is passed, it is returned as-is.
431
432 validate_date_keyword STRING
433 Returns true if STRING is a valid keyword for the MariaDB "date"
434 data type. Valid (case-insensitive) date keywords are:
435
436 curdate()
437 current_date
438 current_date()
439 now()
440 sysdate()
441 00000-00-00
442
443 Any string that looks like a function call (matches /^\w+\(.*\)$/)
444 is also considered a valid date keyword if keyword_function_calls
445 is true.
446
447 validate_datetime_keyword STRING
448 Returns true if STRING is a valid keyword for the MariaDB
449 "datetime" data type, false otherwise. Valid (case-insensitive)
450 datetime keywords are:
451
452 curdate()
453 current_date
454 current_date()
455 current_time
456 current_time()
457 current_timestamp
458 current_timestamp()
459 curtime()
460 now()
461 sysdate()
462 0000-00-00 00:00:00
463
464 Any string that looks like a function call (matches /^\w+\(.*\)$/)
465 is also considered a valid datetime keyword if
466 keyword_function_calls is true.
467
468 validate_timestamp_keyword STRING
469 Returns true if STRING is a valid keyword for the MariaDB
470 "timestamp" data type, false otherwise. Valid (case-insensitive)
471 timestamp keywords are:
472
473 curdate()
474 current_date
475 current_date()
476 current_time
477 current_time()
478 current_timestamp
479 current_timestamp()
480 curtime()
481 now()
482 sysdate()
483 0000-00-00 00:00:00
484 00000000000000
485
486 Any string that looks like a function call (matches /^\w+\(.*\)$/)
487 is also considered a valid timestamp keyword if
488 keyword_function_calls is true.
489
491 John C. Siracusa (siracusa@gmail.com)
492
494 Copyright (c) 2020 by John C. Siracusa. All rights reserved. This
495 program is free software; you can redistribute it and/or modify it
496 under the same terms as Perl itself.
497
498
499
500perl v5.36.0 2023-03-01 Rose::DB::MariaDB(3)