/**
  * Compiles a CREATE TABLE statement from components array
  *
  * @param	array		Array of SQL query components
  * @return	array		array with SQL CREATE TABLE/INDEX command(s)
  * @see parseCREATETABLE()
  */
 public function compileCREATETABLE($components)
 {
     // Execute query (based on handler derived from the TABLE name which we actually know for once!)
     switch ((string) $GLOBALS['TYPO3_DB']->handlerCfg[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]['type']) {
         case 'native':
             $query[] = parent::compileCREATETABLE($components);
             break;
         case 'adodb':
             // Create fields and keys:
             $fieldsKeys = array();
             $indexKeys = array();
             foreach ($components['FIELDS'] as $fN => $fCfg) {
                 $handlerKey = $GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE']);
                 $fieldsKeys[$fN] = $GLOBALS['TYPO3_DB']->quoteName($fN, $handlerKey, TRUE) . ' ' . $this->compileFieldCfg($fCfg['definition']);
             }
             if (isset($components['KEYS']) && is_array($components['KEYS'])) {
                 foreach ($components['KEYS'] as $kN => $kCfg) {
                     if ($kN === 'PRIMARYKEY') {
                         foreach ($kCfg as $n => $field) {
                             $fieldsKeys[$field] .= ' PRIMARY';
                         }
                     } elseif ($kN === 'UNIQUE') {
                         foreach ($kCfg as $n => $field) {
                             $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($n, $components['TABLE'], $field, array('UNIQUE')));
                         }
                     } else {
                         $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($components['TABLE'] . '_' . $kN, $components['TABLE'], $kCfg));
                     }
                 }
             }
             // Generally create without OID on PostgreSQL
             $tableOptions = array('postgres' => 'WITHOUT OIDS');
             // Fetch table/index generation query:
             $tableName = $GLOBALS['TYPO3_DB']->quoteName($components['TABLE'], NULL, TRUE);
             $query = array_merge($GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->lastHandlerKey]->DataDictionary->CreateTableSQL($tableName, implode(',' . chr(10), $fieldsKeys), $tableOptions), $indexKeys);
             break;
     }
     return $query;
 }