← Index
Performance Profile   « block view • line view • sub view »
For /home/chris/git/koha.git/cataloguing/addbiblio.pl
  Run on Tue Aug 25 11:37:23 2009
Reported on Tue Aug 25 11:37:54 2009

File /usr/share/perl5/CGI/Session/Driver/mysql.pm
Statements Executed 26
Total Time 0.0390965 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
22243µs82µsCGI::Session::Driver::mysql::::table_nameCGI::Session::Driver::mysql::table_name
11139µs57µsCGI::Session::Driver::mysql::::initCGI::Session::Driver::mysql::init
11130µs38.5msCGI::Session::Driver::mysql::::storeCGI::Session::Driver::mysql::store
0000s0sCGI::Session::Driver::mysql::::BEGINCGI::Session::Driver::mysql::BEGIN
0000s0sCGI::Session::Driver::mysql::::_mk_dsnstrCGI::Session::Driver::mysql::_mk_dsnstr
LineStmts.Exclusive
Time
Avg.Code
1package CGI::Session::Driver::mysql;
2
3# $Id: mysql.pm 447 2008-11-01 03:46:08Z markstos $
4
53164µs55µsuse strict;
# spent 15µs making 1 call to strict::import
6341µs14µsuse Carp;
# spent 71µs making 1 call to Exporter::import
73520µs173µsuse CGI::Session::Driver::DBI;
# spent 16µs making 1 call to UNIVERSAL::import
8
9111µs11µs@CGI::Session::Driver::mysql::ISA = qw( CGI::Session::Driver::DBI );
101500ns500ns$CGI::Session::Driver::mysql::VERSION = '4.38';
11
12sub _mk_dsnstr {
13 my ($class, $dsn) = @_;
14 unless ( $class && $dsn && ref($dsn) && (ref($dsn) eq 'HASH')) {
15 croak "_mk_dsnstr(): usage error";
16 }
17
18 my $dsnstr = $dsn->{DataSource};
19 if ( $dsn->{Socket} ) {
20 $dsnstr .= sprintf(";mysql_socket=%s", $dsn->{Socket});
21 }
22 if ( $dsn->{Host} ) {
23 $dsnstr .= sprintf(";host=%s", $dsn->{Host});
24 }
25 if ( $dsn->{Port} ) {
26 $dsnstr .= sprintf(";port=%s", $dsn->{Port});
27 }
28 return $dsnstr;
29}
30
31
32
# spent 57µs (39+19) within CGI::Session::Driver::mysql::init which was called # once (39µs+19µs) by CGI::Session::Driver::new at line 38 of /usr/share/perl5/CGI/Session/Driver.pm
sub init {
3311µs1µs my $self = shift;
3411µs1µs if ( $self->{DataSource} && ($self->{DataSource} !~ /^dbi:mysql/i) ) {
35 $self->{DataSource} = "dbi:mysql:database=" . $self->{DataSource};
36 }
37
381800ns800ns if ( $self->{Socket} && $self->{DataSource} ) {
39 $self->{DataSource} .= ';mysql_socket=' . $self->{Socket};
40 }
41135µs35µs return $self->SUPER::init();
# spent 19µs making 1 call to CGI::Session::Driver::DBI::init
42}
43
44
# spent 38.5ms (30µs+38.5) within CGI::Session::Driver::mysql::store which was called # once (30µs+38.5ms) by CGI::Session::flush at line 253 of /usr/share/perl5/CGI/Session.pm
sub store {
4511µs1µs my $self = shift;
4613µs3µs my ($sid, $datastr) = @_;
471700ns700ns croak "store(): usage error" unless $sid && $datastr;
48
4912µs2µs my $dbh = $self->{Handle};
50138.3ms38.3ms $dbh->do("INSERT INTO " . $self->table_name .
# spent 38.5ms making 1 call to DBI::db::do # spent 40µs making 1 call to CGI::Session::Driver::mysql::table_name
51 " ($self->{IdColName}, $self->{DataColName}) VALUES(?, ?) ON DUPLICATE KEY UPDATE $self->{DataColName} = ?",
52 undef, $sid, $datastr, $datastr)
53 or return $self->set_error( "store(): \$dbh->do failed " . $dbh->errstr );
5413µs3µs return 1;
55}
56
57
58
# spent 82µs (43+38) within CGI::Session::Driver::mysql::table_name which was called 2 times, avg 41µs/call: # once (21µs+20µs) by CGI::Session::Driver::DBI::retrieve at line 68 of /usr/share/perl5/CGI/Session/Driver/DBI.pm # once (22µs+18µs) by CGI::Session::Driver::mysql::store at line 50
sub table_name {
5922µs900ns my $self = shift;
60
61243µs21µs return $self->SUPER::table_name(@_);
# spent 38µs making 2 calls to CGI::Session::Driver::DBI::table_name, avg 19µs/call
62}
63
6414µs4µs1;
65
66__END__;
67
68=pod
69
70=head1 NAME
71
72CGI::Session::Driver::mysql - CGI::Session driver for MySQL database
73
74=head1 SYNOPSIS
75
76 $s = new CGI::Session( 'driver:mysql', $sid);
77 $s = new CGI::Session( 'driver:mysql', $sid, { DataSource => 'dbi:mysql:test',
78 User => 'sherzodr',
79 Password => 'hello' });
80 $s = new CGI::Session( 'driver:mysql', $sid, { Handle => $dbh } );
81
82=head1 DESCRIPTION
83
84B<mysql> stores session records in a MySQL table. For details see L<CGI::Session::Driver::DBI|CGI::Session::Driver::DBI>, its parent class.
85
86It's especially important for the MySQL driver that the session ID column be
87defined as a primary key, or at least "unique", like this:
88
89 CREATE TABLE sessions (
90 id CHAR(32) NOT NULL PRIMARY KEY,
91 a_session TEXT NOT NULL
92 );
93
94To use different column names, change the 'create table' statement, and then simply do this:
95
96 $s = new CGI::Session('driver:mysql', undef,
97 {
98 TableName=>'session',
99 IdColName=>'my_id',
100 DataColName=>'my_data',
101 DataSource=>'dbi:mysql:project',
102 });
103
104or
105
106 $s = new CGI::Session('driver:mysql', undef,
107 {
108 TableName=>'session',
109 IdColName=>'my_id',
110 DataColName=>'my_data',
111 Handle=>$dbh,
112 });
113
114=head2 DRIVER ARGUMENTS
115
116B<mysql> driver supports all the arguments documented in L<CGI::Session::Driver::DBI|CGI::Session::Driver::DBI>. In addition, I<DataSource> argument can optionally leave leading "dbi:mysql:" string out:
117
118 $s = new CGI::Session( 'driver:mysql', $sid, {DataSource=>'shopping_cart'});
119 # is the same as:
120 $s = new CGI::Session( 'driver:mysql', $sid, {DataSource=>'dbi:mysql:shopping_cart'});
121
122=head2 BACKWARDS COMPATIBILITY
123
124As of V 4.30, the global variable $CGI::Session::MySQL::TABLE_NAME cannot be used to set the session
125table's name.
126
127This is due to changes in CGI::Session::Driver's new() method, which now allows the table's name to be
128changed (as well as allowing both the 'id' column name and the 'a_session' column name to be changed).
129
130See the documentation for CGI::Session::Driver::DBI for details.
131
132In particular, the new syntax for C<new()> applies to all database drivers, whereas the old - and bad -
133global variable method only applied to MySQL.
134
135Alternately, call $session -> table_name('new_name') just after creating the session object if you wish to
136change the session table's name.
137
138=head1 LICENSING
139
140For support and licensing see L<CGI::Session|CGI::Session>.
141
142=cut