fbsql.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4. * The PEAR DB driver for PHP's fbsql extension
  5. * for interacting with FrontBase databases
  6. *
  7. * PHP version 5
  8. *
  9. * LICENSE: This source file is subject to version 3.0 of the PHP license
  10. * that is available through the world-wide-web at the following URI:
  11. * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  12. * the PHP License and are unable to obtain it through the web, please
  13. * send a note to license@php.net so we can mail you a copy immediately.
  14. *
  15. * @category Database
  16. * @package DB
  17. * @author Frank M. Kromann <frank@frontbase.com>
  18. * @author Daniel Convissor <danielc@php.net>
  19. * @copyright 1997-2007 The PHP Group
  20. * @license http://www.php.net/license/3_0.txt PHP License 3.0
  21. * @version CVS: $Id$
  22. * @link http://pear.php.net/package/DB
  23. */
  24. /**
  25. * Obtain the DB_common class so it can be extended from
  26. */
  27. //require_once 'DB/common.php';
  28. require_once 'common.php';
  29. /**
  30. * The methods PEAR DB uses to interact with PHP's fbsql extension
  31. * for interacting with FrontBase databases
  32. *
  33. * These methods overload the ones declared in DB_common.
  34. *
  35. * @category Database
  36. * @package DB
  37. * @author Frank M. Kromann <frank@frontbase.com>
  38. * @author Daniel Convissor <danielc@php.net>
  39. * @copyright 1997-2007 The PHP Group
  40. * @license http://www.php.net/license/3_0.txt PHP License 3.0
  41. * @version Release: 1.9.2
  42. * @link http://pear.php.net/package/DB
  43. * @since Class functional since Release 1.7.0
  44. */
  45. class DB_fbsql extends DB_common
  46. {
  47. // {{{ properties
  48. /**
  49. * The DB driver type (mysql, oci8, odbc, etc.)
  50. * @var string
  51. */
  52. public $phptype = 'fbsql';
  53. /**
  54. * The database syntax variant to be used (db2, access, etc.), if any
  55. * @var string
  56. */
  57. public $dbsyntax = 'fbsql';
  58. /**
  59. * The capabilities of this DB implementation
  60. *
  61. * The 'new_link' element contains the PHP version that first provided
  62. * new_link support for this DBMS. Contains false if it's unsupported.
  63. *
  64. * Meaning of the 'limit' element:
  65. * + 'emulate' = emulate with fetch row by number
  66. * + 'alter' = alter the query
  67. * + false = skip rows
  68. *
  69. * @var array
  70. */
  71. public $features = array(
  72. 'limit' => 'alter',
  73. 'new_link' => false,
  74. 'numrows' => true,
  75. 'pconnect' => true,
  76. 'prepare' => false,
  77. 'ssl' => false,
  78. 'transactions' => true,
  79. );
  80. /**
  81. * A mapping of native error codes to DB error codes
  82. * @var array
  83. */
  84. public $errorcode_map = array(
  85. 22 => DB_ERROR_SYNTAX,
  86. 85 => DB_ERROR_ALREADY_EXISTS,
  87. 108 => DB_ERROR_SYNTAX,
  88. 116 => DB_ERROR_NOSUCHTABLE,
  89. 124 => DB_ERROR_VALUE_COUNT_ON_ROW,
  90. 215 => DB_ERROR_NOSUCHFIELD,
  91. 217 => DB_ERROR_INVALID_NUMBER,
  92. 226 => DB_ERROR_NOSUCHFIELD,
  93. 231 => DB_ERROR_INVALID,
  94. 239 => DB_ERROR_TRUNCATED,
  95. 251 => DB_ERROR_SYNTAX,
  96. 266 => DB_ERROR_NOT_FOUND,
  97. 357 => DB_ERROR_CONSTRAINT_NOT_NULL,
  98. 358 => DB_ERROR_CONSTRAINT,
  99. 360 => DB_ERROR_CONSTRAINT,
  100. 361 => DB_ERROR_CONSTRAINT,
  101. );
  102. /**
  103. * The raw database connection created by PHP
  104. * @var resource
  105. */
  106. public $connection;
  107. /**
  108. * The DSN information for connecting to a database
  109. * @var array
  110. */
  111. public $dsn = array();
  112. // }}}
  113. // {{{ constructor
  114. /**
  115. * This constructor calls <kbd>parent::__construct()</kbd>
  116. *
  117. * @return void
  118. */
  119. public function __construct()
  120. {
  121. parent::__construct();
  122. }
  123. // }}}
  124. // {{{ connect()
  125. /**
  126. * Connect to the database server, log in and open the database
  127. *
  128. * Don't call this method directly. Use DB::connect() instead.
  129. *
  130. * @param array $dsn the data source name
  131. * @param bool $persistent should the connection be persistent?
  132. *
  133. * @return int|object
  134. */
  135. public function connect($dsn, $persistent = false)
  136. {
  137. if (!PEAR::loadExtension('fbsql')) {
  138. return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
  139. }
  140. $this->dsn = $dsn;
  141. if ($dsn['dbsyntax']) {
  142. $this->dbsyntax = $dsn['dbsyntax'];
  143. }
  144. $params = array(
  145. $dsn['hostspec'] ? $dsn['hostspec'] : 'localhost',
  146. $dsn['username'] ? $dsn['username'] : null,
  147. $dsn['password'] ? $dsn['password'] : null,
  148. );
  149. $connect_function = $persistent ? 'fbsql_pconnect' : 'fbsql_connect';
  150. $ini = ini_get('track_errors');
  151. $php_errormsg = '';
  152. if ($ini) {
  153. $this->connection = @call_user_func_array(
  154. $connect_function,
  155. $params
  156. );
  157. } else {
  158. @ini_set('track_errors', 1);
  159. $this->connection = @call_user_func_array(
  160. $connect_function,
  161. $params
  162. );
  163. @ini_set('track_errors', $ini);
  164. }
  165. if (!$this->connection) {
  166. return $this->raiseError(
  167. DB_ERROR_CONNECT_FAILED,
  168. null,
  169. null,
  170. null,
  171. $php_errormsg
  172. );
  173. }
  174. if ($dsn['database']) {
  175. if (!@fbsql_select_db($dsn['database'], $this->connection)) {
  176. return $this->fbsqlRaiseError();
  177. }
  178. }
  179. return DB_OK;
  180. }
  181. // }}}
  182. // {{{ disconnect()
  183. /**
  184. * Produces a DB_Error object regarding the current problem
  185. *
  186. * @param int $errno if the error is being manually raised pass a
  187. * DB_ERROR* constant here. If this isn't passed
  188. * the error information gathered from the DBMS.
  189. *
  190. * @return object the DB_Error object
  191. *
  192. * @see DB_common::raiseError(),
  193. * DB_fbsql::errorNative(), DB_common::errorCode()
  194. */
  195. public function fbsqlRaiseError($errno = null)
  196. {
  197. if ($errno === null) {
  198. $errno = $this->errorCode(fbsql_errno($this->connection));
  199. }
  200. return $this->raiseError(
  201. $errno,
  202. null,
  203. null,
  204. null,
  205. @fbsql_error($this->connection)
  206. );
  207. }
  208. // }}}
  209. // {{{ simpleQuery()
  210. /**
  211. * Disconnects from the database server
  212. *
  213. * @return bool TRUE on success, FALSE on failure
  214. */
  215. public function disconnect()
  216. {
  217. $ret = @fbsql_close($this->connection);
  218. $this->connection = null;
  219. return $ret;
  220. }
  221. // }}}
  222. // {{{ nextResult()
  223. /**
  224. * Sends a query to the database server
  225. *
  226. * @param string the SQL query string
  227. *
  228. * @return mixed + a PHP result resrouce for successful SELECT queries
  229. * + the DB_OK constant for other successful queries
  230. * + a DB_Error object on failure
  231. */
  232. public function simpleQuery($query)
  233. {
  234. $this->last_query = $query;
  235. $query = $this->modifyQuery($query);
  236. $result = @fbsql_query("$query;", $this->connection);
  237. if (!$result) {
  238. return $this->fbsqlRaiseError();
  239. }
  240. // Determine which queries that should return data, and which
  241. // should return an error code only.
  242. if ($this->_checkManip($query)) {
  243. return DB_OK;
  244. }
  245. return $result;
  246. }
  247. // }}}
  248. // {{{ fetchInto()
  249. /**
  250. * Move the internal fbsql result pointer to the next available result
  251. *
  252. * @param a valid fbsql result resource
  253. *
  254. * @access public
  255. *
  256. * @return true if a result is available otherwise return false
  257. */
  258. public function nextResult($result)
  259. {
  260. return @fbsql_next_result($result);
  261. }
  262. // }}}
  263. // {{{ freeResult()
  264. /**
  265. * Places a row from the result set into the given array
  266. *
  267. * Formating of the array and the data therein are configurable.
  268. * See DB_result::fetchInto() for more information.
  269. *
  270. * This method is not meant to be called directly. Use
  271. * DB_result::fetchInto() instead. It can't be declared "protected"
  272. * because DB_result is a separate object.
  273. *
  274. * @param resource $result the query result resource
  275. * @param array $arr the referenced array to put the data in
  276. * @param int $fetchmode how the resulting array should be indexed
  277. * @param int $rownum the row number to fetch (0 = first row)
  278. *
  279. * @return mixed DB_OK on success, NULL when the end of a result set is
  280. * reached or on failure
  281. *
  282. * @see DB_result::fetchInto()
  283. */
  284. public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
  285. {
  286. if ($rownum !== null) {
  287. if (!@fbsql_data_seek($result, $rownum)) {
  288. return null;
  289. }
  290. }
  291. if ($fetchmode & DB_FETCHMODE_ASSOC) {
  292. $arr = @fbsql_fetch_array($result, FBSQL_ASSOC);
  293. if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
  294. $arr = array_change_key_case($arr, CASE_LOWER);
  295. }
  296. } else {
  297. $arr = @fbsql_fetch_row($result);
  298. }
  299. if (!$arr) {
  300. return null;
  301. }
  302. if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
  303. $this->_rtrimArrayValues($arr);
  304. }
  305. if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
  306. $this->_convertNullArrayValuesToEmpty($arr);
  307. }
  308. return DB_OK;
  309. }
  310. // }}}
  311. // {{{ autoCommit()
  312. /**
  313. * Deletes the result set and frees the memory occupied by the result set
  314. *
  315. * This method is not meant to be called directly. Use
  316. * DB_result::free() instead. It can't be declared "protected"
  317. * because DB_result is a separate object.
  318. *
  319. * @param resource $result PHP's query result resource
  320. *
  321. * @return bool TRUE on success, FALSE if $result is invalid
  322. *
  323. * @see DB_result::free()
  324. */
  325. public function freeResult($result)
  326. {
  327. return is_resource($result) ? fbsql_free_result($result) : false;
  328. }
  329. // }}}
  330. // {{{ commit()
  331. /**
  332. * Enables or disables automatic commits
  333. *
  334. * @param bool $onoff true turns it on, false turns it off
  335. *
  336. * @return int DB_OK on success. A DB_Error object if the driver
  337. * doesn't support auto-committing transactions.
  338. */
  339. public function autoCommit($onoff = false)
  340. {
  341. if ($onoff) {
  342. $this->query("SET COMMIT TRUE");
  343. } else {
  344. $this->query("SET COMMIT FALSE");
  345. }
  346. return null;
  347. }
  348. // }}}
  349. // {{{ rollback()
  350. /**
  351. * Commits the current transaction
  352. *
  353. * @return int DB_OK on success. A DB_Error object on failure.
  354. */
  355. public function commit()
  356. {
  357. @fbsql_commit($this->connection);
  358. return 0;
  359. }
  360. // }}}
  361. // {{{ numCols()
  362. /**
  363. * Reverts the current transaction
  364. *
  365. * @return int DB_OK on success. A DB_Error object on failure.
  366. */
  367. public function rollback()
  368. {
  369. @fbsql_rollback($this->connection);
  370. return 0;
  371. }
  372. // }}}
  373. // {{{ numRows()
  374. /**
  375. * Gets the number of columns in a result set
  376. *
  377. * This method is not meant to be called directly. Use
  378. * DB_result::numCols() instead. It can't be declared "protected"
  379. * because DB_result is a separate object.
  380. *
  381. * @param resource $result PHP's query result resource
  382. *
  383. * @return int|object
  384. *
  385. * @see DB_result::numCols()
  386. */
  387. public function numCols($result)
  388. {
  389. $cols = @fbsql_num_fields($result);
  390. if (!$cols) {
  391. return $this->fbsqlRaiseError();
  392. }
  393. return $cols;
  394. }
  395. // }}}
  396. // {{{ affectedRows()
  397. /**
  398. * Gets the number of rows in a result set
  399. *
  400. * This method is not meant to be called directly. Use
  401. * DB_result::numRows() instead. It can't be declared "protected"
  402. * because DB_result is a separate object.
  403. *
  404. * @param resource $result PHP's query result resource
  405. *
  406. * @return int|object
  407. *
  408. * @see DB_result::numRows()
  409. */
  410. public function numRows($result)
  411. {
  412. $rows = @fbsql_num_rows($result);
  413. if ($rows === null) {
  414. return $this->fbsqlRaiseError();
  415. }
  416. return $rows;
  417. }
  418. // }}}
  419. // {{{ nextId()
  420. /**
  421. * Determines the number of rows affected by a data maniuplation query
  422. *
  423. * 0 is returned for queries that don't manipulate data.
  424. *
  425. * @return int the number of rows. A DB_Error object on failure.
  426. */
  427. public function affectedRows()
  428. {
  429. if ($this->_last_query_manip) {
  430. $result = @fbsql_affected_rows($this->connection);
  431. } else {
  432. $result = 0;
  433. }
  434. return $result;
  435. }
  436. /**
  437. * Returns the next free id in a sequence
  438. *
  439. * @param string $seq_name name of the sequence
  440. * @param boolean $ondemand when true, the seqence is automatically
  441. * created if it does not exist
  442. *
  443. * @return int|object
  444. * A DB_Error object on failure.
  445. *
  446. * @see DB_common::nextID(), DB_common::getSequenceName(),
  447. * DB_fbsql::createSequence(), DB_fbsql::dropSequence()
  448. */
  449. public function nextId($seq_name, $ondemand = true)
  450. {
  451. $seqname = $this->getSequenceName($seq_name);
  452. do {
  453. $repeat = 0;
  454. $this->pushErrorHandling(PEAR_ERROR_RETURN);
  455. $result = $this->query('SELECT UNIQUE FROM ' . $seqname);
  456. $this->popErrorHandling();
  457. if ($ondemand && DB::isError($result) &&
  458. $result->getCode() == DB_ERROR_NOSUCHTABLE) {
  459. $repeat = 1;
  460. $result = $this->createSequence($seq_name);
  461. if (DB::isError($result)) {
  462. return $result;
  463. }
  464. } else {
  465. $repeat = 0;
  466. }
  467. } while ($repeat);
  468. if (DB::isError($result)) {
  469. return $this->fbsqlRaiseError();
  470. }
  471. $result->fetchInto($tmp, DB_FETCHMODE_ORDERED);
  472. return $tmp[0];
  473. }
  474. // }}}
  475. // {{{ dropSequence()
  476. /**
  477. * Creates a new sequence
  478. *
  479. * @param string $seq_name name of the new sequence
  480. *
  481. * @return int DB_OK on success. A DB_Error object on failure.
  482. *
  483. * @see DB_common::createSequence(), DB_common::getSequenceName(),
  484. * DB_fbsql::nextID(), DB_fbsql::dropSequence()
  485. */
  486. public function createSequence($seq_name)
  487. {
  488. $seqname = $this->getSequenceName($seq_name);
  489. $res = $this->query('CREATE TABLE ' . $seqname
  490. . ' (id INTEGER NOT NULL,'
  491. . ' PRIMARY KEY(id))');
  492. if ($res) {
  493. $res = $this->query('SET UNIQUE = 0 FOR ' . $seqname);
  494. }
  495. return $res;
  496. }
  497. // }}}
  498. // {{{ modifyLimitQuery()
  499. /**
  500. * Deletes a sequence
  501. *
  502. * @param string $seq_name name of the sequence to be deleted
  503. *
  504. * @return int DB_OK on success. A DB_Error object on failure.
  505. *
  506. * @see DB_common::dropSequence(), DB_common::getSequenceName(),
  507. * DB_fbsql::nextID(), DB_fbsql::createSequence()
  508. */
  509. public function dropSequence($seq_name)
  510. {
  511. return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name)
  512. . ' RESTRICT');
  513. }
  514. // }}}
  515. // {{{ quoteBoolean()
  516. /**
  517. * Adds LIMIT clauses to a query string according to current DBMS standards
  518. *
  519. * @param string $query the query to modify
  520. * @param int $from the row to start to fetching (0 = the first row)
  521. * @param int $count the numbers of rows to fetch
  522. * @param mixed $params array, string or numeric data to be used in
  523. * execution of the statement. Quantity of items
  524. * passed must match quantity of placeholders in
  525. * query: meaning 1 placeholder for non-array
  526. * parameters or 1 placeholder per array element.
  527. *
  528. * @return string the query string with LIMIT clauses added
  529. *
  530. * @access protected
  531. */
  532. public function modifyLimitQuery($query, $from, $count, $params = array())
  533. {
  534. if (DB::isManip($query) || $this->_next_query_manip) {
  535. return preg_replace(
  536. '/^([\s(])*SELECT/i',
  537. "\\1SELECT TOP($count)",
  538. $query
  539. );
  540. } else {
  541. return preg_replace(
  542. '/([\s(])*SELECT/i',
  543. "\\1SELECT TOP($from, $count)",
  544. $query
  545. );
  546. }
  547. }
  548. // }}}
  549. // {{{ quoteFloat()
  550. /**
  551. * Formats a boolean value for use within a query in a locale-independent
  552. * manner.
  553. *
  554. * @param boolean the boolean value to be quoted.
  555. * @return string the quoted string.
  556. * @see DB_common::quoteSmart()
  557. * @since Method available since release 1.7.8.
  558. */
  559. public function quoteBoolean($boolean)
  560. {
  561. return $boolean ? 'TRUE' : 'FALSE';
  562. }
  563. // }}}
  564. // {{{ fbsqlRaiseError()
  565. /**
  566. * Formats a float value for use within a query in a locale-independent
  567. * manner.
  568. *
  569. * @param float the float value to be quoted.
  570. * @return string the quoted string.
  571. * @see DB_common::quoteSmart()
  572. * @since Method available since release 1.7.8.
  573. */
  574. public function quoteFloat($float)
  575. {
  576. return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
  577. }
  578. // }}}
  579. // {{{ errorNative()
  580. /**
  581. * Gets the DBMS' native error code produced by the last query
  582. *
  583. * @return int the DBMS' error code
  584. */
  585. public function errorNative()
  586. {
  587. return @fbsql_errno($this->connection);
  588. }
  589. // }}}
  590. // {{{ tableInfo()
  591. /**
  592. * Returns information about a table or a result set
  593. *
  594. * @param object|string $result DB_result object from a query or a
  595. * string containing the name of a table.
  596. * While this also accepts a query result
  597. * resource identifier, this behavior is
  598. * deprecated.
  599. * @param int $mode a valid tableInfo mode
  600. *
  601. * @return array|object
  602. * A DB_Error object on failure.
  603. *
  604. * @see DB_common::tableInfo()
  605. */
  606. public function tableInfo($result, $mode = null)
  607. {
  608. if (is_string($result)) {
  609. /*
  610. * Probably received a table name.
  611. * Create a result resource identifier.
  612. */
  613. $id = @fbsql_list_fields(
  614. $this->dsn['database'],
  615. $result,
  616. $this->connection
  617. );
  618. $got_string = true;
  619. } elseif (isset($result->result)) {
  620. /*
  621. * Probably received a result object.
  622. * Extract the result resource identifier.
  623. */
  624. $id = $result->result;
  625. $got_string = false;
  626. } else {
  627. /*
  628. * Probably received a result resource identifier.
  629. * Copy it.
  630. * Deprecated. Here for compatibility only.
  631. */
  632. $id = $result;
  633. $got_string = false;
  634. }
  635. if (!is_resource($id)) {
  636. return $this->fbsqlRaiseError(DB_ERROR_NEED_MORE_DATA);
  637. }
  638. if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
  639. $case_func = 'strtolower';
  640. } else {
  641. $case_func = 'strval';
  642. }
  643. $count = @fbsql_num_fields($id);
  644. $res = array();
  645. if ($mode) {
  646. $res['num_fields'] = $count;
  647. }
  648. for ($i = 0; $i < $count; $i++) {
  649. $res[$i] = array(
  650. 'table' => $case_func(@fbsql_field_table($id, $i)),
  651. 'name' => $case_func(@fbsql_field_name($id, $i)),
  652. 'type' => @fbsql_field_type($id, $i),
  653. 'len' => @fbsql_field_len($id, $i),
  654. 'flags' => @fbsql_field_flags($id, $i),
  655. );
  656. if ($mode & DB_TABLEINFO_ORDER) {
  657. $res['order'][$res[$i]['name']] = $i;
  658. }
  659. if ($mode & DB_TABLEINFO_ORDERTABLE) {
  660. $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
  661. }
  662. }
  663. // free the result only if we were called on a table
  664. if ($got_string) {
  665. @fbsql_free_result($id);
  666. }
  667. return $res;
  668. }
  669. // }}}
  670. // {{{ getSpecialQuery()
  671. /**
  672. * Obtains the query string needed for listing a given type of objects
  673. *
  674. * @param string $type the kind of objects you want to retrieve
  675. *
  676. * @return string the SQL query string or null if the driver doesn't
  677. * support the object type requested
  678. *
  679. * @access protected
  680. * @see DB_common::getListOf()
  681. */
  682. public function getSpecialQuery($type)
  683. {
  684. switch ($type) {
  685. case 'tables':
  686. return 'SELECT "table_name" FROM information_schema.tables'
  687. . ' t0, information_schema.schemata t1'
  688. . ' WHERE t0.schema_pk=t1.schema_pk AND'
  689. . ' "table_type" = \'BASE TABLE\''
  690. . ' AND "schema_name" = current_schema';
  691. case 'views':
  692. return 'SELECT "table_name" FROM information_schema.tables'
  693. . ' t0, information_schema.schemata t1'
  694. . ' WHERE t0.schema_pk=t1.schema_pk AND'
  695. . ' "table_type" = \'VIEW\''
  696. . ' AND "schema_name" = current_schema';
  697. case 'users':
  698. return 'SELECT "user_name" from information_schema.users';
  699. case 'functions':
  700. return 'SELECT "routine_name" FROM'
  701. . ' information_schema.psm_routines'
  702. . ' t0, information_schema.schemata t1'
  703. . ' WHERE t0.schema_pk=t1.schema_pk'
  704. . ' AND "routine_kind"=\'FUNCTION\''
  705. . ' AND "schema_name" = current_schema';
  706. case 'procedures':
  707. return 'SELECT "routine_name" FROM'
  708. . ' information_schema.psm_routines'
  709. . ' t0, information_schema.schemata t1'
  710. . ' WHERE t0.schema_pk=t1.schema_pk'
  711. . ' AND "routine_kind"=\'PROCEDURE\''
  712. . ' AND "schema_name" = current_schema';
  713. default:
  714. return null;
  715. }
  716. }
  717. // }}}
  718. }
  719. /*
  720. * Local variables:
  721. * tab-width: 4
  722. * c-basic-offset: 4
  723. * End:
  724. */