mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-31 10:17:13 +02:00
extract public to schema variable so we can use a constant later
This commit is contained in:
@ -28,9 +28,10 @@ class DescribeSQLRewriter extends AbstractSQLRewriter
|
|||||||
* Generates a PostgreSQL-compatible SQL query to mimic MySQL's "DESCRIBE".
|
* Generates a PostgreSQL-compatible SQL query to mimic MySQL's "DESCRIBE".
|
||||||
*
|
*
|
||||||
* @param string $tableName The table name
|
* @param string $tableName The table name
|
||||||
|
* @param string $schema The schema name
|
||||||
* @return string The generated SQL query
|
* @return string The generated SQL query
|
||||||
*/
|
*/
|
||||||
public function generatePostgresDescribeTable($tableName)
|
public function generatePostgresDescribeTable($tableName, $schema = "public")
|
||||||
{
|
{
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
@ -70,7 +71,7 @@ class DescribeSQLRewriter extends AbstractSQLRewriter
|
|||||||
LEFT JOIN pg_constraint p ON p.conrelid = c.oid AND f.attnum = ANY (p.conkey)
|
LEFT JOIN pg_constraint p ON p.conrelid = c.oid AND f.attnum = ANY (p.conkey)
|
||||||
LEFT JOIN pg_class AS g ON p.confrelid = g.oid
|
LEFT JOIN pg_class AS g ON p.confrelid = g.oid
|
||||||
WHERE c.relkind = 'r'::char
|
WHERE c.relkind = 'r'::char
|
||||||
AND n.nspname = 'public'
|
AND n.nspname = '$schema'
|
||||||
AND c.relname = '$tableName'
|
AND c.relname = '$tableName'
|
||||||
AND f.attnum > 0 ORDER BY number
|
AND f.attnum > 0 ORDER BY number
|
||||||
SQL;
|
SQL;
|
||||||
|
@ -358,7 +358,7 @@ class SelectSQLRewriter extends AbstractSQLRewriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This method is specifically to handle should_suggest_persistent_object_cache in wp site health
|
// This method is specifically to handle should_suggest_persistent_object_cache in wp site health
|
||||||
protected function postgresTableSizeRewrite()
|
protected function postgresTableSizeRewrite($schema = 'public')
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
@ -373,7 +373,7 @@ class SelectSQLRewriter extends AbstractSQLRewriter
|
|||||||
INNER JOIN
|
INNER JOIN
|
||||||
pg_stat_user_tables S ON (S.relid = C.oid)
|
pg_stat_user_tables S ON (S.relid = C.oid)
|
||||||
WHERE
|
WHERE
|
||||||
N.nspname = 'public' AND
|
N.nspname = $schema AND
|
||||||
C.relname IN ('wp_comments','wp_options','wp_posts','wp_terms','wp_users')
|
C.relname IN ('wp_comments','wp_options','wp_posts','wp_terms','wp_users')
|
||||||
GROUP BY
|
GROUP BY
|
||||||
C.relname, pg_total_relation_size(C.oid), S.n_live_tup;
|
C.relname, pg_total_relation_size(C.oid), S.n_live_tup;
|
||||||
|
@ -28,9 +28,10 @@ class ShowFullColumnsSQLRewriter extends AbstractSQLRewriter
|
|||||||
* Generates a PostgreSQL-compatible SQL query to mimic MySQL's "SHOW FULL COLUMNS".
|
* Generates a PostgreSQL-compatible SQL query to mimic MySQL's "SHOW FULL COLUMNS".
|
||||||
*
|
*
|
||||||
* @param string $tableName The table name
|
* @param string $tableName The table name
|
||||||
|
* @param string $schema The schema name
|
||||||
* @return string The generated SQL query
|
* @return string The generated SQL query
|
||||||
*/
|
*/
|
||||||
public function generatePostgresShowColumns($tableName)
|
public function generatePostgresShowColumns($tableName, $schema = "public")
|
||||||
{
|
{
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT
|
SELECT
|
||||||
@ -62,7 +63,7 @@ class ShowFullColumnsSQLRewriter extends AbstractSQLRewriter
|
|||||||
FROM pg_catalog.pg_class c
|
FROM pg_catalog.pg_class c
|
||||||
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
||||||
WHERE c.relname = '$tableName'
|
WHERE c.relname = '$tableName'
|
||||||
AND n.nspname = 'public'
|
AND n.nspname = '$schema'
|
||||||
)
|
)
|
||||||
ORDER BY
|
ORDER BY
|
||||||
a.attnum;
|
a.attnum;
|
||||||
|
@ -24,9 +24,9 @@ class ShowTableStatusSQLRewriter extends AbstractSQLRewriter
|
|||||||
NULL AS Row_format,
|
NULL AS Row_format,
|
||||||
cls.reltuples AS Rows,
|
cls.reltuples AS Rows,
|
||||||
NULL AS Avg_row_length,
|
NULL AS Avg_row_length,
|
||||||
pg_relation_size(cls.oid) AS Data_length,
|
pg_size_pretty(pg_relation_size(cls.oid)) AS Data_length,
|
||||||
NULL AS Max_data_length,
|
NULL AS Max_data_length,
|
||||||
pg_indexes_size(cls.oid) AS Index_length,
|
pg_size_pretty(pg_indexes_size(cls.oid)) AS Index_length,
|
||||||
NULL AS Data_free,
|
NULL AS Data_free,
|
||||||
NULL AS Auto_increment,
|
NULL AS Auto_increment,
|
||||||
NULL AS Create_time,
|
NULL AS Create_time,
|
||||||
|
@ -4,6 +4,7 @@ class ShowTablesSQLRewriter extends AbstractSQLRewriter
|
|||||||
{
|
{
|
||||||
public function rewrite(): string
|
public function rewrite(): string
|
||||||
{
|
{
|
||||||
return 'SELECT tablename FROM pg_tables WHERE schemaname = \'public\';';
|
$schema = "public";
|
||||||
|
return 'SELECT tablename FROM pg_tables WHERE schemaname = \'$schema\';';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user