/** * Load the entire schema into ram for speed. * @return Container */ public function preLoad() { $query = new Query(<<<SQL SELECT n.nspname "schema", c.relname "name", string_to_array( indrelid::text || '.' || replace( indkey::text, ' ', ' ' || indrelid::text || '.' ), ' ' ) AS columns, false "inherited", i.*, string_to_array( indkey::text, ' ' )::int[] as indkey FROM pg_index i INNER JOIN pg_class c ON i.indexrelid = c.oid LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname NOT IN ('pg_catalog', 'pg_toast', 'information_schema') SQL ); $datas = $this->db->query($query)->fetch(Result::TYPE_DETECT); parent::cacheInvalidate(); $this->initByDatas($datas); }
/** * Load the entire schema into ram for speed. * @return Container */ public function preLoad() { $query = new Query(<<<SQL SELECT t.oid AS oid, t.typname AS name, n.nspname as "schema", t.typlen AS length, t.typtype AS type, t.typcategory AS category, t.typarray AS "arrayType", t.typdefault AS default, t.typdefaultbin AS "defaultBin" FROM pg_type AS t INNER JOIN pg_namespace AS n ON n.oid = t.typnamespace WHERE t.oid IN ( SELECT DISTINCT a.atttypid as "typeOid" FROM pg_attribute AS a INNER JOIN pg_type AS t ON t.oid = a.atttypid INNER JOIN pg_class AS c ON c.oid = a.attrelid LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname NOT IN ('pg_catalog', 'pg_toast', 'information_schema') AND attisdropped = false AND attnum > 0 ) ; SQL ); $types = $this->db->query($query)->fetch(); parent::cacheInvalidate(); $this->initByDatas($types); }
/** * Load the entire schema into ram for speed. * @return Container */ public function preLoad() { $query = new Query(<<<SQL SELECT a.attrelid::text || '.' || a.attnum::text AS key, a.attrelid AS attrelid, a.attname as name, a.atttypid as "typeOid", a.attndims <> 0 as "isArray", a.attnotnull as "notNull", a.attnum as "attnum", a.attinhcount as "attinhcount", d.adsrc as "default", i.character_maximum_length as "length" FROM pg_attribute AS a INNER JOIN pg_type AS t ON t.oid = a.atttypid INNER JOIN pg_class AS c ON c.oid = a.attrelid LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace LEFT JOIN information_schema.columns as i ON n.nspname = i.table_schema AND c.relname = i.table_name AND i.column_name = a.attname LEFT JOIN pg_attrdef AS d ON d.adrelid = a.attrelid AND d.adnum = a.attnum WHERE n.nspname NOT IN ('pg_catalog', 'pg_toast', 'information_schema') AND n.nspname = ANY( current_schemas(false) ) AND attisdropped = false AND attnum > 0 ORDER BY a.attrelid::text ASC, a.attnum ASC SQL ); $attributes = $this->db->query($query)->fetch(); parent::cacheInvalidate(); $this->initByDatas($attributes); // preload references $this->preloadReferences(); }