.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DBSchema::DBD 3pm" .TH DBSchema::DBD 3pm "2022-09-10" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::DBSchema::DBD \- DBIx::DBSchema Driver Writer's Guide and Base Class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& perldoc DBIx::DBSchema::DBD \& \& package DBIx::DBSchema::DBD::FooBase \& use DBIx::DBSchema::DBD; \& @ISA = qw(DBIx::DBSchema::DBD); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Drivers should be named DBIx::DBSchema::DBD::DatabaseName, where DatabaseName is the same as the \s-1DBD::\s0 driver for this database. Drivers should implement the following class methods: .IP "columns \s-1CLASS DBI_DBH TABLE\s0" 4 .IX Item "columns CLASS DBI_DBH TABLE" Given an active \s-1DBI\s0 database handle, return a listref of listrefs (see perllol), each containing six elements: column name, column type, nullability, column length, column default, and a field reserved for driver-specific use. .IP "column \s-1CLASS DBI_DBH TABLE COLUMN\s0" 4 .IX Item "column CLASS DBI_DBH TABLE COLUMN" Same as \fBcolumns\fR above, except return the listref for a single column. You can inherit from DBIx::DBSchema::DBD to provide this function. .IP "primary_key \s-1CLASS DBI_DBH TABLE\s0" 4 .IX Item "primary_key CLASS DBI_DBH TABLE" Given an active \s-1DBI\s0 database handle, return the primary key for the specified table. .IP "unique \s-1CLASS DBI_DBH TABLE\s0" 4 .IX Item "unique CLASS DBI_DBH TABLE" Deprecated method \- see the \fBindices\fR method for new drivers. .Sp Given an active \s-1DBI\s0 database handle, return a hashref of unique indices. The keys of the hashref are index names, and the values are arrayrefs which point a list of column names for each. See \*(L"\s-1HASHES OF LISTS\*(R"\s0 in perldsc and DBIx::DBSchema::Index. .IP "index \s-1CLASS DBI_DBH TABLE\s0" 4 .IX Item "index CLASS DBI_DBH TABLE" Deprecated method \- see the \fBindices\fR method for new drivers. .Sp Given an active \s-1DBI\s0 database handle, return a hashref of (non-unique) indices. The keys of the hashref are index names, and the values are arrayrefs which point a list of column names for each. See \*(L"\s-1HASHES OF LISTS\*(R"\s0 in perldsc and DBIx::DBSchema::Index. .IP "indices \s-1CLASS DBI_DBH TABLE\s0" 4 .IX Item "indices CLASS DBI_DBH TABLE" Given an active \s-1DBI\s0 database handle, return a hashref of all indices, both unique and non-unique. The keys of the hashref are index names, and the values are again hashrefs with the following keys: .RS 4 .IP "name \- Index name (redundant)" 8 .IX Item "name - Index name (redundant)" .PD 0 .IP "using \- Optional index method" 8 .IX Item "using - Optional index method" .IP "unique \- Boolean indicating whether or not this is a unique index" 8 .IX Item "unique - Boolean indicating whether or not this is a unique index" .IP "columns \- List reference of column names (or expressions)" 8 .IX Item "columns - List reference of column names (or expressions)" .RE .RS 4 .PD .Sp (See FS::DBIx::DBSchema::Index) .Sp New drivers are advised to implement this method, and existing drivers are advised to (eventually) provide this method instead of \fBindex\fR and \fBunique\fR. .Sp For backwards-compatibility with current drivers, the base DBIx::DBSchema::DBD class provides an \fBindices\fR method which uses the old \fBindex\fR and \fBunique\fR methods to provide this data. .RE .IP "default_db_catalog" 4 .IX Item "default_db_catalog" Returns the default database catalog for the \s-1DBI\s0 table_info command. Inheriting from DBIx::DBSchema::DBD will provide the default empty string. .IP "default_db_schema" 4 .IX Item "default_db_schema" Returns the default database schema for the \s-1DBI\s0 table_info command. Inheriting from DBIx::DBSchema::DBD will provide the default empty string. .IP "constraints \s-1CLASS DBI_DBH TABLE\s0" 4 .IX Item "constraints CLASS DBI_DBH TABLE" Given an active \s-1DBI\s0 database handle, return the constraints (currently, foreign keys) for the specified table, as a list of hash references. .Sp Each hash reference has the following keys: .RS 4 .IP "constraint \- contraint name" 8 .IX Item "constraint - contraint name" .PD 0 .IP "columns \- List refrence of column names" 8 .IX Item "columns - List refrence of column names" .IP "table \- Foreign taable name" 8 .IX Item "table - Foreign taable name" .IP "references \- List reference of column names in foreign table" 8 .IX Item "references - List reference of column names in foreign table" .IP "match \-" 8 .IX Item "match -" .IP "on_delete \-" 8 .IX Item "on_delete -" .IP "on_update \-" 8 .IX Item "on_update -" .RE .RS 4 .RE .IP "column_callback \s-1DBH TABLE_NAME COLUMN_OBJ\s0" 4 .IX Item "column_callback DBH TABLE_NAME COLUMN_OBJ" .PD Optional callback for driver-specific overrides to \s-1SQL\s0 column definitions. .Sp Should return a hash reference, empty for no action, or with one or more of the following keys defined: .Sp effective_type \- Optional type override used during column creation. .Sp explicit_null \- Set true to have the column definition declare \s-1NULL\s0 columns explicitly .Sp effective_default \- Optional default override used during column creation. .Sp effective_local \- Optional local override used during column creation. .IP "add_column_callback \s-1DBH TABLE_NAME COLUMN_OBJ\s0" 4 .IX Item "add_column_callback DBH TABLE_NAME COLUMN_OBJ" Optional callback for additional \s-1SQL\s0 statments to be called when adding columns to an existing table. .Sp Should return a hash reference, empty for no action, or with one or more of the following keys defined: .Sp effective_type \- Optional type override used during column creation. .Sp effective_null \- Optional nullability override used during column creation. .Sp sql_after \- Array reference of \s-1SQL\s0 statements to be executed after the column is added. .IP "alter_column_callback \s-1DBH TABLE_NAME OLD_COLUMN_OBJ NEW_COLUMN_OBJ\s0" 4 .IX Item "alter_column_callback DBH TABLE_NAME OLD_COLUMN_OBJ NEW_COLUMN_OBJ" Optional callback for overriding the \s-1SQL\s0 statments to be called when altering columns to an existing table. .Sp Should return a hash reference, empty for no action, or with one or more of the following keys defined: .Sp sql_alter \- Alter \s-1SQL\s0 statement(s) for changing everything about a column. Specifying this overrides processing of individual changes (type, nullability, default, etc.). .Sp sql_alter_type \- Alter \s-1SQL\s0 statement(s) for changing type and length (there is no default). .Sp sql_alter_null \- Alter \s-1SQL\s0 statement(s) for changing nullability to be used instead of the default. .IP "column_value_needs_quoting \s-1COLUMN_OBJ\s0" 4 .IX Item "column_value_needs_quoting COLUMN_OBJ" Optional callback for determining if a column's default value require quoting. Returns true if it does, false otherwise. .SH "TYPE MAPPING" .IX Header "TYPE MAPPING" You can define a \f(CW%typemap\fR array for your driver to map \*(L"standard\*(R" data types to database-specific types. For example, the MySQL \s-1TIMESTAMP\s0 field has non-standard auto-updating semantics; the MySQL \s-1DATETIME\s0 type is what other databases and the \s-1ODBC\s0 standard call \s-1TIMESTAMP,\s0 so one of the entries in the MySQL \f(CW%typemap\fR is: .PP .Vb 1 \& \*(AqTIMESTAMP\*(Aq => \*(AqDATETIME\*(Aq, .Ve .PP Another example is the Pg \f(CW%typemap\fR which maps the standard types \s-1BLOB\s0 and \&\s-1LONG VARBINARY\s0 to the Pg-specific \s-1BYTEA:\s0 .PP .Vb 2 \& \*(AqBLOB\*(Aq => \*(AqBYTEA\*(Aq, \& \*(AqLONG VARBINARY\*(Aq => \*(AqBYTEA\*(Aq, .Ve .PP Make sure you use all uppercase-keys. .SH "AUTHOR" .IX Header "AUTHOR" Ivan Kohler .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2000\-2005 Ivan Kohler Copyright (c) 2007\-2017 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "BUGS" .IX Header "BUGS" .SH "SEE ALSO" .IX Header "SEE ALSO" DBIx::DBSchema, DBIx::DBSchema::DBD::mysql, DBIx::DBSchema::DBD::Pg, DBIx::DBSchema::Index, \s-1DBI\s0, \s-1DBI::DBD\s0, perllol, \&\*(L"\s-1HASHES OF LISTS\*(R"\s0 in perldsc