Follow-up r84475 CR; and also documentation fixes; PhpStorm 2.1 is *even more* fussy...
[lhc/web/wiklou.git] / includes / db / DatabaseMysql.php
1 <?php
2 /**
3 * This is the MySQL database abstraction layer.
4 *
5 * @file
6 * @ingroup Database
7 */
8
9 /**
10 * Database abstraction object for mySQL
11 * Inherit all methods and properties of Database::Database()
12 *
13 * @ingroup Database
14 * @see Database
15 */
16 class DatabaseMysql extends DatabaseBase {
17 function getType() {
18 return 'mysql';
19 }
20
21 protected function doQuery( $sql ) {
22 if( $this->bufferResults() ) {
23 $ret = mysql_query( $sql, $this->mConn );
24 } else {
25 $ret = mysql_unbuffered_query( $sql, $this->mConn );
26 }
27 return $ret;
28 }
29
30 function open( $server, $user, $password, $dbName ) {
31 global $wgAllDBsAreLocalhost;
32 wfProfileIn( __METHOD__ );
33
34 # Load mysql.so if we don't have it
35 wfDl( 'mysql' );
36
37 # Fail now
38 # Otherwise we get a suppressed fatal error, which is very hard to track down
39 if ( !function_exists( 'mysql_connect' ) ) {
40 throw new DBConnectionError( $this, "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n" );
41 }
42
43 # Debugging hack -- fake cluster
44 if ( $wgAllDBsAreLocalhost ) {
45 $realServer = 'localhost';
46 } else {
47 $realServer = $server;
48 }
49 $this->close();
50 $this->mServer = $server;
51 $this->mUser = $user;
52 $this->mPassword = $password;
53 $this->mDBname = $dbName;
54
55 wfProfileIn("dbconnect-$server");
56
57 # The kernel's default SYN retransmission period is far too slow for us,
58 # so we use a short timeout plus a manual retry. Retrying means that a small
59 # but finite rate of SYN packet loss won't cause user-visible errors.
60 $this->mConn = false;
61 if ( ini_get( 'mysql.connect_timeout' ) <= 3 ) {
62 $numAttempts = 2;
63 } else {
64 $numAttempts = 1;
65 }
66 $this->installErrorHandler();
67 for ( $i = 0; $i < $numAttempts && !$this->mConn; $i++ ) {
68 if ( $i > 1 ) {
69 usleep( 1000 );
70 }
71 if ( $this->mFlags & DBO_PERSISTENT ) {
72 $this->mConn = mysql_pconnect( $realServer, $user, $password );
73 } else {
74 # Create a new connection...
75 $this->mConn = mysql_connect( $realServer, $user, $password, true );
76 }
77 #if ( $this->mConn === false ) {
78 #$iplus = $i + 1;
79 #wfLogDBError("Connect loop error $iplus of $max ($server): " . mysql_errno() . " - " . mysql_error()."\n");
80 #}
81 }
82 $phpError = $this->restoreErrorHandler();
83 # Always log connection errors
84 if ( !$this->mConn ) {
85 $error = $this->lastError();
86 if ( !$error ) {
87 $error = $phpError;
88 }
89 wfLogDBError( "Error connecting to {$this->mServer}: $error\n" );
90 wfDebug( "DB connection error\n" );
91 wfDebug( "Server: $server, User: $user, Password: " .
92 substr( $password, 0, 3 ) . "..., error: " . mysql_error() . "\n" );
93 }
94
95 wfProfileOut("dbconnect-$server");
96
97 if ( $dbName != '' && $this->mConn !== false ) {
98 $success = @/**/mysql_select_db( $dbName, $this->mConn );
99 if ( !$success ) {
100 $error = "Error selecting database $dbName on server {$this->mServer} " .
101 "from client host " . wfHostname() . "\n";
102 wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n");
103 wfDebug( $error );
104 }
105 } else {
106 # Delay USE query
107 $success = (bool)$this->mConn;
108 }
109
110 if ( $success ) {
111 $version = $this->getServerVersion();
112 if ( version_compare( $version, '4.1' ) >= 0 ) {
113 // Tell the server we're communicating with it in UTF-8.
114 // This may engage various charset conversions.
115 global $wgDBmysql5;
116 if( $wgDBmysql5 ) {
117 $this->query( 'SET NAMES utf8', __METHOD__ );
118 } else {
119 $this->query( 'SET NAMES binary', __METHOD__ );
120 }
121 // Set SQL mode, default is turning them all off, can be overridden or skipped with null
122 global $wgSQLMode;
123 if ( is_string( $wgSQLMode ) ) {
124 $mode = $this->addQuotes( $wgSQLMode );
125 $this->query( "SET sql_mode = $mode", __METHOD__ );
126 }
127 }
128
129 // Turn off strict mode if it is on
130 } else {
131 $this->reportConnectionError( $phpError );
132 }
133
134 $this->mOpened = $success;
135 wfProfileOut( __METHOD__ );
136 return $success;
137 }
138
139 function close() {
140 $this->mOpened = false;
141 if ( $this->mConn ) {
142 if ( $this->trxLevel() ) {
143 $this->commit();
144 }
145 return mysql_close( $this->mConn );
146 } else {
147 return true;
148 }
149 }
150
151 function freeResult( $res ) {
152 if ( $res instanceof ResultWrapper ) {
153 $res = $res->result;
154 }
155 if ( !@/**/mysql_free_result( $res ) ) {
156 throw new DBUnexpectedError( $this, "Unable to free MySQL result" );
157 }
158 }
159
160 function fetchObject( $res ) {
161 if ( $res instanceof ResultWrapper ) {
162 $res = $res->result;
163 }
164 @/**/$row = mysql_fetch_object( $res );
165 if( $this->lastErrno() ) {
166 throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() ) );
167 }
168 return $row;
169 }
170
171 function fetchRow( $res ) {
172 if ( $res instanceof ResultWrapper ) {
173 $res = $res->result;
174 }
175 @/**/$row = mysql_fetch_array( $res );
176 if ( $this->lastErrno() ) {
177 throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() ) );
178 }
179 return $row;
180 }
181
182 function numRows( $res ) {
183 if ( $res instanceof ResultWrapper ) {
184 $res = $res->result;
185 }
186 @/**/$n = mysql_num_rows( $res );
187 if( $this->lastErrno() ) {
188 throw new DBUnexpectedError( $this, 'Error in numRows(): ' . htmlspecialchars( $this->lastError() ) );
189 }
190 return $n;
191 }
192
193 function numFields( $res ) {
194 if ( $res instanceof ResultWrapper ) {
195 $res = $res->result;
196 }
197 return mysql_num_fields( $res );
198 }
199
200 function fieldName( $res, $n ) {
201 if ( $res instanceof ResultWrapper ) {
202 $res = $res->result;
203 }
204 return mysql_field_name( $res, $n );
205 }
206
207 function insertId() { return mysql_insert_id( $this->mConn ); }
208
209 function dataSeek( $res, $row ) {
210 if ( $res instanceof ResultWrapper ) {
211 $res = $res->result;
212 }
213 return mysql_data_seek( $res, $row );
214 }
215
216 function lastErrno() {
217 if ( $this->mConn ) {
218 return mysql_errno( $this->mConn );
219 } else {
220 return mysql_errno();
221 }
222 }
223
224 function lastError() {
225 if ( $this->mConn ) {
226 # Even if it's non-zero, it can still be invalid
227 wfSuppressWarnings();
228 $error = mysql_error( $this->mConn );
229 if ( !$error ) {
230 $error = mysql_error();
231 }
232 wfRestoreWarnings();
233 } else {
234 $error = mysql_error();
235 }
236 if( $error ) {
237 $error .= ' (' . $this->mServer . ')';
238 }
239 return $error;
240 }
241
242 function affectedRows() { return mysql_affected_rows( $this->mConn ); }
243
244 function replace( $table, $uniqueIndexes, $rows, $fname = 'DatabaseMysql::replace' ) {
245 return $this->nativeReplace( $table, $rows, $fname );
246 }
247
248 /**
249 * Estimate rows in dataset
250 * Returns estimated count, based on EXPLAIN output
251 * Takes same arguments as Database::select()
252 */
253 public function estimateRowCount( $table, $vars='*', $conds='', $fname = 'DatabaseMysql::estimateRowCount', $options = array() ) {
254 $options['EXPLAIN'] = true;
255 $res = $this->select( $table, $vars, $conds, $fname, $options );
256 if ( $res === false ) {
257 return false;
258 }
259 if ( !$this->numRows( $res ) ) {
260 return 0;
261 }
262
263 $rows = 1;
264 foreach ( $res as $plan ) {
265 $rows *= $plan->rows > 0 ? $plan->rows : 1; // avoid resetting to zero
266 }
267 return $rows;
268 }
269
270 function fieldInfo( $table, $field ) {
271 $table = $this->tableName( $table );
272 $res = $this->query( "SELECT * FROM $table LIMIT 1", __METHOD__, true );
273 if ( !$res ) {
274 return false;
275 }
276 $n = mysql_num_fields( $res->result );
277 for( $i = 0; $i < $n; $i++ ) {
278 $meta = mysql_fetch_field( $res->result, $i );
279 if( $field == $meta->name ) {
280 return new MySQLField($meta);
281 }
282 }
283 return false;
284 }
285
286 /**
287 * Get information about an index into an object
288 * Returns false if the index does not exist
289 */
290 function indexInfo( $table, $index, $fname = 'DatabaseMysql::indexInfo' ) {
291 # SHOW INDEX works in MySQL 3.23.58, but SHOW INDEXES does not.
292 # SHOW INDEX should work for 3.x and up:
293 # http://dev.mysql.com/doc/mysql/en/SHOW_INDEX.html
294 $table = $this->tableName( $table );
295 $index = $this->indexName( $index );
296 $sql = 'SHOW INDEX FROM ' . $table;
297 $res = $this->query( $sql, $fname );
298
299 if ( !$res ) {
300 return null;
301 }
302
303 $result = array();
304
305 foreach ( $res as $row ) {
306 if ( $row->Key_name == $index ) {
307 $result[] = $row;
308 }
309 }
310
311 return empty( $result ) ? false : $result;
312 }
313
314 function selectDB( $db ) {
315 $this->mDBname = $db;
316 return mysql_select_db( $db, $this->mConn );
317 }
318
319 function strencode( $s ) {
320 $sQuoted = mysql_real_escape_string( $s, $this->mConn );
321
322 if($sQuoted === false) {
323 $this->ping();
324 $sQuoted = mysql_real_escape_string( $s, $this->mConn );
325 }
326 return $sQuoted;
327 }
328
329 /**
330 * MySQL uses `backticks` for identifier quoting instead of the sql standard "double quotes".
331 */
332 public function addIdentifierQuotes( $s ) {
333 return "`" . $this->strencode( $s ) . "`";
334 }
335
336 public function isQuotedIdentifier( $name ) {
337 return strlen($name) && $name[0] == '`' && substr( $name, -1, 1 ) == '`';
338 }
339
340 function ping() {
341 $ping = mysql_ping( $this->mConn );
342 if ( $ping ) {
343 return true;
344 }
345
346 mysql_close( $this->mConn );
347 $this->mOpened = false;
348 $this->mConn = false;
349 $this->open( $this->mServer, $this->mUser, $this->mPassword, $this->mDBname );
350 return true;
351 }
352
353 /**
354 * Returns slave lag.
355 *
356 * On MySQL 4.1.9 and later, this will do a SHOW SLAVE STATUS. On earlier
357 * versions of MySQL, it uses SHOW PROCESSLIST, which requires the PROCESS
358 * privilege.
359 *
360 * @result int
361 */
362 function getLag() {
363 if ( !is_null( $this->mFakeSlaveLag ) ) {
364 wfDebug( "getLag: fake slave lagged {$this->mFakeSlaveLag} seconds\n" );
365 return $this->mFakeSlaveLag;
366 }
367
368 /*if ( version_compare( $this->getServerVersion(), '4.1.9', '>=' ) ) {
369 return $this->getLagFromSlaveStatus();
370 } else */{
371 return $this->getLagFromProcesslist();
372 }
373 }
374
375 function getLagFromSlaveStatus() {
376 $res = $this->query( 'SHOW SLAVE STATUS', __METHOD__ );
377 if ( !$res ) {
378 return false;
379 }
380 $row = $res->fetchObject();
381 if ( !$row ) {
382 return false;
383 }
384 if ( strval( $row->Seconds_Behind_Master ) === '' ) {
385 return false;
386 } else {
387 return intval( $row->Seconds_Behind_Master );
388 }
389 }
390
391 function getLagFromProcesslist() {
392 $res = $this->query( 'SHOW PROCESSLIST', __METHOD__ );
393 if( !$res ) {
394 return false;
395 }
396 # Find slave SQL thread
397 foreach( $res as $row ) {
398 /* This should work for most situations - when default db
399 * for thread is not specified, it had no events executed,
400 * and therefore it doesn't know yet how lagged it is.
401 *
402 * Relay log I/O thread does not select databases.
403 */
404 if ( $row->User == 'system user' &&
405 $row->State != 'Waiting for master to send event' &&
406 $row->State != 'Connecting to master' &&
407 $row->State != 'Queueing master event to the relay log' &&
408 $row->State != 'Waiting for master update' &&
409 $row->State != 'Requesting binlog dump' &&
410 $row->State != 'Waiting to reconnect after a failed master event read' &&
411 $row->State != 'Reconnecting after a failed master event read' &&
412 $row->State != 'Registering slave on master'
413 ) {
414 # This is it, return the time (except -ve)
415 if ( $row->Time > 0x7fffffff ) {
416 return false;
417 } else {
418 return $row->Time;
419 }
420 }
421 }
422 return false;
423 }
424
425 /**
426 * Wait for the slave to catch up to a given master position.
427 *
428 * @param $pos DBMasterPos object
429 * @param $timeout Integer: the maximum number of seconds to wait for synchronisation
430 */
431 function masterPosWait( DBMasterPos $pos, $timeout ) {
432 $fname = 'DatabaseBase::masterPosWait';
433 wfProfileIn( $fname );
434
435 # Commit any open transactions
436 if ( $this->mTrxLevel ) {
437 $this->commit();
438 }
439
440 if ( !is_null( $this->mFakeSlaveLag ) ) {
441 $status = parent::masterPosWait( $pos, $timeout );
442 wfProfileOut( $fname );
443 return $status;
444 }
445
446 # Call doQuery() directly, to avoid opening a transaction if DBO_TRX is set
447 $encFile = $this->addQuotes( $pos->file );
448 $encPos = intval( $pos->pos );
449 $sql = "SELECT MASTER_POS_WAIT($encFile, $encPos, $timeout)";
450 $res = $this->doQuery( $sql );
451
452 if ( $res && $row = $this->fetchRow( $res ) ) {
453 wfProfileOut( $fname );
454 return $row[0];
455 } else {
456 wfProfileOut( $fname );
457 return false;
458 }
459 }
460
461 /**
462 * Get the position of the master from SHOW SLAVE STATUS
463 *
464 * @return MySQLMasterPos|false
465 */
466 function getSlavePos() {
467 if ( !is_null( $this->mFakeSlaveLag ) ) {
468 return parent::getSlavePos();
469 }
470
471 $res = $this->query( 'SHOW SLAVE STATUS', 'DatabaseBase::getSlavePos' );
472 $row = $this->fetchObject( $res );
473
474 if ( $row ) {
475 $pos = isset( $row->Exec_master_log_pos ) ? $row->Exec_master_log_pos : $row->Exec_Master_Log_Pos;
476 return new MySQLMasterPos( $row->Relay_Master_Log_File, $pos );
477 } else {
478 return false;
479 }
480 }
481
482 /**
483 * Get the position of the master from SHOW MASTER STATUS
484 *
485 * @return MySQLMasterPos|false
486 */
487 function getMasterPos() {
488 if ( $this->mFakeMaster ) {
489 return parent::getMasterPos();
490 }
491
492 $res = $this->query( 'SHOW MASTER STATUS', 'DatabaseBase::getMasterPos' );
493 $row = $this->fetchObject( $res );
494
495 if ( $row ) {
496 return new MySQLMasterPos( $row->File, $row->Position );
497 } else {
498 return false;
499 }
500 }
501
502 function getServerVersion() {
503 return mysql_get_server_info( $this->mConn );
504 }
505
506 function useIndexClause( $index ) {
507 return "FORCE INDEX (" . $this->indexName( $index ) . ")";
508 }
509
510 function lowPriorityOption() {
511 return 'LOW_PRIORITY';
512 }
513
514 public static function getSoftwareLink() {
515 return '[http://www.mysql.com/ MySQL]';
516 }
517
518 function standardSelectDistinct() {
519 return false;
520 }
521
522 public function setTimeout( $timeout ) {
523 $this->query( "SET net_read_timeout=$timeout" );
524 $this->query( "SET net_write_timeout=$timeout" );
525 }
526
527 public function lock( $lockName, $method, $timeout = 5 ) {
528 $lockName = $this->addQuotes( $lockName );
529 $result = $this->query( "SELECT GET_LOCK($lockName, $timeout) AS lockstatus", $method );
530 $row = $this->fetchObject( $result );
531
532 if( $row->lockstatus == 1 ) {
533 return true;
534 } else {
535 wfDebug( __METHOD__." failed to acquire lock\n" );
536 return false;
537 }
538 }
539
540 /**
541 * FROM MYSQL DOCS: http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock
542 */
543 public function unlock( $lockName, $method ) {
544 $lockName = $this->addQuotes( $lockName );
545 $result = $this->query( "SELECT RELEASE_LOCK($lockName) as lockstatus", $method );
546 $row = $this->fetchObject( $result );
547 return $row->lockstatus;
548 }
549
550 public function lockTables( $read, $write, $method, $lowPriority = true ) {
551 $items = array();
552
553 foreach( $write as $table ) {
554 $tbl = $this->tableName( $table ) .
555 ( $lowPriority ? ' LOW_PRIORITY' : '' ) .
556 ' WRITE';
557 $items[] = $tbl;
558 }
559 foreach( $read as $table ) {
560 $items[] = $this->tableName( $table ) . ' READ';
561 }
562 $sql = "LOCK TABLES " . implode( ',', $items );
563 $this->query( $sql, $method );
564 }
565
566 public function unlockTables( $method ) {
567 $this->query( "UNLOCK TABLES", $method );
568 }
569
570 /**
571 * Get search engine class. All subclasses of this
572 * need to implement this if they wish to use searching.
573 *
574 * @return String
575 */
576 public function getSearchEngine() {
577 return 'SearchMySQL';
578 }
579
580 public function setBigSelects( $value = true ) {
581 if ( $value === 'default' ) {
582 if ( $this->mDefaultBigSelects === null ) {
583 # Function hasn't been called before so it must already be set to the default
584 return;
585 } else {
586 $value = $this->mDefaultBigSelects;
587 }
588 } elseif ( $this->mDefaultBigSelects === null ) {
589 $this->mDefaultBigSelects = (bool)$this->selectField( false, '@@sql_big_selects' );
590 }
591 $encValue = $value ? '1' : '0';
592 $this->query( "SET sql_big_selects=$encValue", __METHOD__ );
593 }
594
595 /**
596 * DELETE where the condition is a join. MySql uses multi-table deletes.
597 */
598 function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'DatabaseBase::deleteJoin' ) {
599 if ( !$conds ) {
600 throw new DBUnexpectedError( $this, 'DatabaseBase::deleteJoin() called with empty $conds' );
601 }
602
603 $delTable = $this->tableName( $delTable );
604 $joinTable = $this->tableName( $joinTable );
605 $sql = "DELETE $delTable FROM $delTable, $joinTable WHERE $delVar=$joinVar ";
606
607 if ( $conds != '*' ) {
608 $sql .= ' AND ' . $this->makeList( $conds, LIST_AND );
609 }
610
611 return $this->query( $sql, $fname );
612 }
613
614 /**
615 * Determines if the last failure was due to a deadlock
616 */
617 function wasDeadlock() {
618 return $this->lastErrno() == 1213;
619 }
620
621 /**
622 * Determines if the last query error was something that should be dealt
623 * with by pinging the connection and reissuing the query
624 */
625 function wasErrorReissuable() {
626 return $this->lastErrno() == 2013 || $this->lastErrno() == 2006;
627 }
628
629 /**
630 * Determines if the last failure was due to the database being read-only.
631 */
632 function wasReadOnlyError() {
633 return $this->lastErrno() == 1223 ||
634 ( $this->lastErrno() == 1290 && strpos( $this->lastError(), '--read-only' ) !== false );
635 }
636
637 function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseMysql::duplicateTableStructure' ) {
638 $tmp = $temporary ? 'TEMPORARY ' : '';
639 if ( strcmp( $this->getServerVersion(), '4.1' ) < 0 ) {
640 # Hack for MySQL versions < 4.1, which don't support
641 # "CREATE TABLE ... LIKE". Note that
642 # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
643 # would not create the indexes we need....
644 #
645 # Note that we don't bother changing around the prefixes here be-
646 # cause we know we're using MySQL anyway.
647
648 $res = $this->query( 'SHOW CREATE TABLE ' . $this->addIdentifierQuotes( $oldName ) );
649 $row = $this->fetchRow( $res );
650 $oldQuery = $row[1];
651 $query = preg_replace( '/CREATE TABLE `(.*?)`/',
652 "CREATE $tmp TABLE " . $this->addIdentifierQuotes( $newName ), $oldQuery );
653 if ($oldQuery === $query) {
654 # Couldn't do replacement
655 throw new MWException( "could not create temporary table $newName" );
656 }
657 } else {
658 $newName = $this->addIdentifierQuotes( $newName );
659 $oldName = $this->addIdentifierQuotes( $oldName );
660 $query = "CREATE $tmp TABLE $newName (LIKE $oldName)";
661 }
662 $this->query( $query, $fname );
663 }
664
665 /**
666 * List all tables on the database
667 *
668 * @param $prefix Only show tables with this prefix, e.g. mw_
669 * @param $fname String: calling function name
670 */
671 function listTables( $prefix = null, $fname = 'DatabaseMysql::listTables' ) {
672 $result = $this->query( "SHOW TABLES", $fname);
673
674 $endArray = array();
675
676 foreach( $result as $table ) {
677 $vars = get_object_vars($table);
678 $table = array_pop( $vars );
679
680 if( !$prefix || strpos( $table, $prefix ) === 0 ) {
681 $endArray[] = $table;
682 }
683 }
684
685 return $endArray;
686 }
687
688 public function dropTable( $tableName, $fName = 'DatabaseMysql::dropTable' ) {
689 if( !$this->tableExists( $tableName ) ) {
690 return false;
691 }
692 return $this->query( "DROP TABLE IF EXISTS " . $this->tableName( $tableName ), $fName );
693 }
694
695 protected function getDefaultSchemaVars() {
696 $vars = parent::getDefaultSchemaVars();
697 $vars['wgDBTableOptions'] = $GLOBALS['wgDBTableOptions'];
698 return $vars;
699 }
700
701 /**
702 * Get status information from SHOW STATUS in an associative array
703 *
704 * @return array
705 */
706 function getMysqlStatus( $which = "%" ) {
707 $res = $this->query( "SHOW STATUS LIKE '{$which}'" );
708 $status = array();
709
710 foreach ( $res as $row ) {
711 $status[$row->Variable_name] = $row->Value;
712 }
713
714 return $status;
715 }
716
717 }
718
719 /**
720 * Legacy support: Database == DatabaseMysql
721 */
722 class Database extends DatabaseMysql {}
723
724 /**
725 * Utility class.
726 * @ingroup Database
727 */
728 class MySQLField implements Field {
729 private $name, $tablename, $default, $max_length, $nullable,
730 $is_pk, $is_unique, $is_multiple, $is_key, $type;
731
732 function __construct ( $info ) {
733 $this->name = $info->name;
734 $this->tablename = $info->table;
735 $this->default = $info->def;
736 $this->max_length = $info->max_length;
737 $this->nullable = !$info->not_null;
738 $this->is_pk = $info->primary_key;
739 $this->is_unique = $info->unique_key;
740 $this->is_multiple = $info->multiple_key;
741 $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
742 $this->type = $info->type;
743 }
744
745 function name() {
746 return $this->name;
747 }
748
749 function tableName() {
750 return $this->tableName;
751 }
752
753 function type() {
754 return $this->type;
755 }
756
757 function isNullable() {
758 return $this->nullable;
759 }
760
761 function defaultValue() {
762 return $this->default;
763 }
764
765 function isKey() {
766 return $this->is_key;
767 }
768
769 function isMultipleKey() {
770 return $this->is_multiple;
771 }
772 }
773
774 class MySQLMasterPos implements DBMasterPos {
775 var $file, $pos;
776
777 function __construct( $file, $pos ) {
778 $this->file = $file;
779 $this->pos = $pos;
780 }
781
782 function __toString() {
783 return "{$this->file}/{$this->pos}";
784 }
785 }