Example #1
0
 /**
  * Returns the query plan.
  * @param string $sql the sql string
  * @return array $response 
  */
 public function plan($sql, array &$errors)
 {
     // init error array
     $errors = array();
     $plan = $this->_processor->getPlan($sql, $errors);
     return $plan;
 }
Example #2
0
 /**
  * Construtor.
  */
 public function __construct()
 {
     parent::__construct();
     // get parallel query obejct
     $this->_paraQuery = new ParallelQuery();
     // get daiquiri config instance
     $config = Daiquiri_Config::getInstance();
     // check if server is a PaQu enabled server...
     $adapter = Daiquiri_Config::getInstance()->getUserDbAdapter();
     // check if PaQu spider plugin is installed.
     $adapter->setFetchMode(Zend_Db::FETCH_ASSOC);
     $pluginAvail = $adapter->fetchAll('SELECT name FROM mysql.func WHERE name="spider_bg_direct_sql";');
     if (empty($pluginAvail) || $pluginAvail[0]['name'] !== "spider_bg_direct_sql") {
         //    throw new Exception('PaQu spider engine setup not correct.');
     }
     // set options in parallel query object
     $this->_paraQuery->setEngine($config->query->userDb->engine);
     $this->_paraQuery->setDB($config->query->scratchdb);
     $this->_paraQuery->setConnectOnServerSite($config->query->processor->paqu->serverConnectStr);
     $this->_paraQuery->setSpiderUsr($config->query->processor->paqu->spiderUsr);
     $this->_paraQuery->setSpiderPwd($config->query->processor->paqu->spiderPwd);
     // set the tables that only reside on the head node
     $listOfHeadNodeTables = array();
     // all tables in the user db are head node tables, therefore add the database name and a list
     // of all tables in the database
     $listOfHeadNodeTables[] = $this->_userDb;
     // get list of tables in user database
     $resource = Query_Model_Resource_AbstractQuery::factory();
     $stmt = $resource->getAdapter()->query('SHOW TABLES;');
     foreach ($stmt->fetchAll() as $row) {
         $listOfHeadNodeTables[] = array_shift($row);
     }
     $this->_paraQuery->setHeadNodeTables($listOfHeadNodeTables);
     if (empty($config->query->processor->paqu->federated)) {
         $this->_paraQuery->setFedEngine("FEDERATED");
     } else {
         $this->_paraQuery->setFedEngine($config->query->processor->paqu->federated);
     }
 }
Example #3
0
 /**
  * Returns a set of functions with description.
  * @return array $response
  */
 public function nativeFunctions()
 {
     $rows = Query_Model_Resource_AbstractProcessor::factory()->getFunctions();
     foreach ($rows as $key => &$row) {
         $row['id'] = $key + 1;
         $row['value'] = $row['name'] . '()';
     }
     return array('basic_functions' => $rows, 'status' => 'ok');
 }