Benchmark-database-introspection.patch
| system/libraries/drivers/Database/Mysql.php (working copy) | ||
|---|---|---|
| 282 | 282 |
{
|
| 283 | 283 |
$tables = array(); |
| 284 | 284 | |
| 285 |
if ($query = $this->query('SHOW TABLES FROM '.$this->escape_table($this->db_config['connection']['database'])))
|
|
| 285 |
// Start the benchmark |
|
| 286 |
$start = microtime(TRUE); |
|
| 287 | ||
| 288 |
$sql = 'SHOW TABLES FROM '.$this->escape_table($this->db_config['connection']['database']); |
|
| 289 |
$result = $this->query($sql); |
|
| 290 | ||
| 291 |
// Stop the benchmark |
|
| 292 |
$stop = microtime(TRUE); |
|
| 293 | ||
| 294 |
if ($this->db_config['benchmark'] === TRUE) |
|
| 286 | 295 |
{
|
| 287 |
foreach ($query->result(FALSE) as $row) |
|
| 288 |
{
|
|
| 289 |
$tables[] = current($row); |
|
| 290 |
} |
|
| 296 |
// Benchmark the query |
|
| 297 |
Database::$benchmarks[] = array('query' => $sql, 'time' => $stop - $start, 'rows' => count($result));
|
|
| 298 |
} |
|
| 299 | ||
| 300 |
foreach ($result->result(FALSE) as $row) |
|
| 301 |
{
|
|
| 302 |
$tables[] = current($row); |
|
| 291 | 303 |
} |
| 292 | 304 | |
| 293 | 305 |
return $tables; |
| ... | ... | |
| 328 | 340 | |
| 329 | 341 |
public function field_data($table) |
| 330 | 342 |
{
|
| 331 |
$result = $this->query('SHOW COLUMNS FROM '.$this->escape_table($table));
|
|
| 343 |
// Start the benchmark |
|
| 344 |
$start = microtime(TRUE); |
|
| 345 | ||
| 346 |
$sql = 'SHOW COLUMNS FROM '.$this->escape_table($table); |
|
| 347 |
$result = $this->query($sql); |
|
| 348 | ||
| 349 |
// Stop the benchmark |
|
| 350 |
$stop = microtime(TRUE); |
|
| 351 | ||
| 352 |
if ($this->db_config['benchmark'] === TRUE) |
|
| 353 |
{
|
|
| 354 |
// Benchmark the query |
|
| 355 |
Database::$benchmarks[] = array('query' => $sql, 'time' => $stop - $start, 'rows' => count($result));
|
|
| 356 |
} |
|
| 332 | 357 | |
| 333 | 358 |
return $result->result_array(TRUE); |
| 334 | 359 |
} |
| system/libraries/drivers/Database/Pgsql.php (working copy) | ||
|---|---|---|
| 240 | 240 | |
| 241 | 241 |
public function list_tables() |
| 242 | 242 |
{
|
| 243 |
$tables = array(); |
|
| 244 | ||
| 245 |
// Start the benchmark |
|
| 246 |
$start = microtime(TRUE); |
|
| 247 | ||
| 243 | 248 |
$sql = 'SELECT table_schema || \'.\' || table_name FROM information_schema.tables WHERE table_schema NOT IN (\'pg_catalog\', \'information_schema\')'; |
| 244 |
$result = $this->query($sql)->result(FALSE, PGSQL_ASSOC); |
|
| 249 |
$result = $this->query($sql); |
|
| 250 | ||
| 251 |
// Stop the benchmark |
|
| 252 |
$stop = microtime(TRUE); |
|
| 253 | ||
| 254 |
if ($this->db_config['benchmark'] === TRUE) |
|
| 255 |
{
|
|
| 256 |
// Benchmark the query |
|
| 257 |
Database::$benchmarks[] = array('query' => $sql, 'time' => $stop - $start, 'rows' => count($result));
|
|
| 258 |
} |
|
| 245 | 259 | |
| 246 |
$retval = array(); |
|
| 247 |
foreach ($result as $row) |
|
| 260 |
foreach ($result->result(FALSE) as $row) |
|
| 248 | 261 |
{
|
| 249 |
$retval[] = current($row);
|
|
| 262 |
$tables[] = current($row);
|
|
| 250 | 263 |
} |
| 251 | 264 | |
| 252 |
return $retval;
|
|
| 265 |
return $tables;
|
|
| 253 | 266 |
} |
| 254 | 267 | |
| 255 | 268 |
public function show_error() |
| ... | ... | |
| 285 | 298 | |
| 286 | 299 |
public function field_data($table) |
| 287 | 300 |
{
|
| 301 |
// Start the benchmark |
|
| 302 |
$start = microtime(TRUE); |
|
| 303 | ||
| 288 | 304 |
// http://www.postgresql.org/docs/8.3/static/infoschema-columns.html |
| 289 |
$result = $this->query('
|
|
| 305 |
$sql = '
|
|
| 290 | 306 |
SELECT column_name, column_default, is_nullable, data_type, udt_name, |
| 291 | 307 |
character_maximum_length, numeric_precision, numeric_precision_radix, numeric_scale |
| 292 | 308 |
FROM information_schema.columns |
| 293 | 309 |
WHERE table_name = \''. $this->escape_str($table) .'\' |
| 294 | 310 |
ORDER BY ordinal_position |
| 295 |
'); |
|
| 311 |
'; |
|
| 312 |
$result = $this->query($sql); |
|
| 313 | ||
| 314 |
// Stop the benchmark |
|
| 315 |
$stop = microtime(TRUE); |
|
| 316 | ||
| 317 |
if ($this->db_config['benchmark'] === TRUE) |
|
| 318 |
{
|
|
| 319 |
// Benchmark the query |
|
| 320 |
Database::$benchmarks[] = array('query' => $sql, 'time' => $stop - $start, 'rows' => count($result));
|
|
| 321 |
} |
|
| 296 | 322 | |
| 297 | 323 |
return $result->result_array(TRUE); |
| 298 | 324 |
} |
| system/libraries/drivers/Database/Mssql.php (working copy) | ||
|---|---|---|
| 266 | 266 | |
| 267 | 267 |
public function list_tables() |
| 268 | 268 |
{
|
| 269 |
$tables = array(); |
|
| 270 | ||
| 271 |
// Start the benchmark |
|
| 272 |
$start = microtime(TRUE); |
|
| 273 | ||
| 269 | 274 |
$sql = 'SHOW TABLES FROM ['.$this->db_config['connection']['database'].']'; |
| 270 |
$result = $this->query($sql)->result(FALSE, MSSQL_ASSOC); |
|
| 275 |
$result = $this->query($sql); |
|
| 276 | ||
| 277 |
// Stop the benchmark |
|
| 278 |
$stop = microtime(TRUE); |
|
| 279 | ||
| 280 |
if ($this->db_config['benchmark'] === TRUE) |
|
| 281 |
{
|
|
| 282 |
// Benchmark the query |
|
| 283 |
Database::$benchmarks[] = array('query' => $sql, 'time' => $stop - $start, 'rows' => count($result));
|
|
| 284 |
} |
|
| 271 | 285 | |
| 272 |
$retval = array(); |
|
| 273 |
foreach ($result as $row) |
|
| 286 |
foreach ($result->result(FALSE) as $row) |
|
| 274 | 287 |
{
|
| 275 |
$retval[] = current($row);
|
|
| 288 |
$tables[] = current($row);
|
|
| 276 | 289 |
} |
| 277 | 290 | |
| 278 |
return $retval;
|
|
| 291 |
return $tables;
|
|
| 279 | 292 |
} |
| 280 | 293 | |
| 281 | 294 |
public function show_error() |
| ... | ... | |
| 298 | 311 | |
| 299 | 312 |
public function field_data($table) |
| 300 | 313 |
{
|
| 301 |
$query = $this->query('SHOW COLUMNS FROM '.$this->escape_table($table), $this->link);
|
|
| 314 |
// Start the benchmark |
|
| 315 |
$start = microtime(TRUE); |
|
| 316 | ||
| 317 |
$sql = 'SHOW COLUMNS FROM '.$this->escape_table($table); |
|
| 318 |
$result = $this->query($sql); |
|
| 319 | ||
| 320 |
// Stop the benchmark |
|
| 321 |
$stop = microtime(TRUE); |
|
| 322 | ||
| 323 |
if ($this->db_config['benchmark'] === TRUE) |
|
| 324 |
{
|
|
| 325 |
// Benchmark the query |
|
| 326 |
Database::$benchmarks[] = array('query' => $sql, 'time' => $stop - $start, 'rows' => count($result));
|
|
| 327 |
} |
|
| 302 | 328 | |
| 303 |
return $query->result_array(TRUE);
|
|
| 329 |
return $result->result_array(TRUE);
|
|
| 304 | 330 |
} |
| 305 | 331 |
} |
| 306 | 332 | |
| system/libraries/drivers/Database/Pdosqlite.php (working copy) | ||
|---|---|---|
| 223 | 223 |
$sql = "SELECT `name` FROM `sqlite_master` WHERE `type`='table' ORDER BY `name`;"; |
| 224 | 224 |
try |
| 225 | 225 |
{
|
| 226 |
// Start the benchmark |
|
| 227 |
$start = microtime(TRUE); |
|
| 228 | ||
| 226 | 229 |
$result = $this->query($sql)->result(FALSE, PDO::FETCH_ASSOC); |
| 230 | ||
| 231 |
// Stop the benchmark |
|
| 232 |
$stop = microtime(TRUE); |
|
| 233 | ||
| 234 |
if ($this->db_config['benchmark'] === TRUE) |
|
| 235 |
{
|
|
| 236 |
// Benchmark the query |
|
| 237 |
Database::$benchmarks[] = array('query' => $sql, 'time' => $stop - $start, 'rows' => count($result));
|
|
| 238 |
} |
|
| 239 | ||
| 227 | 240 |
$tables = array(); |
| 228 | 241 |
foreach ($result as $row) |
| 229 | 242 |
{
|