Repository: GoogleCloudPlatform/pgadapter
Pull request #1564 (2024-03-20 14:30:41)

chore: include schema name in query

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/GoogleCloudPlatform/pgadapter/pull/1564?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 90.86%. Comparing base [(`41c3be4`)](https://app.codecov.io/gh/GoogleCloudPlatform/pgadapter/commit/41c3be4b94f9a8e417dcecd773465f1103fe5607?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform) to head [(`818250a`)](https://app.codecov.io/gh/GoogleCloudPlatform/pgadapter/pull/1564?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform).


<details><summary>Additional details and impacted files</summary>


```diff
@@                  Coverage Diff                  @@
##             postgresql-dialect    #1564   +/-   ##
=====================================================
  Coverage                 90.86%   90.86%           
  Complexity                 2704     2704           
=====================================================
  Files                       144      144           
  Lines                      9257     9257           
  Branches                   1345     1345           
=====================================================
  Hits                       8411     8411           
  Misses                      568      568           
  Partials                    278      278           
```

| [Flag](https://app.codecov.io/gh/GoogleCloudPlatform/pgadapter/pull/1564/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform) | Coverage Δ | |
|---|---|---|
| [all_tests](https://app.codecov.io/gh/GoogleCloudPlatform/pgadapter/pull/1564/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform) | `90.86% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform#carryforward-flags-in-the-pull-request-comment) to find out more.


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/GoogleCloudPlatform/pgadapter/pull/1564?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform).


Patch:
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/statements/PgCatalog.java b/src/main/java/com/google/cloud/spanner/pgadapter/statements/PgCatalog.java
index 3e60c318..58141d73 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/statements/PgCatalog.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/statements/PgCatalog.java
@@ -797,7 +797,7 @@ public class PgCatalog {
             + "                 group by c.constraint_catalog, c.constraint_schema,\n"
             + "                          c.constraint_name) fck on tc.constraint_catalog=fck.constraint_catalog and tc.constraint_schema=fck.constraint_schema and tc.constraint_name=fck.constraint_name\n"
             + "left outer join information_schema.check_constraints cc on cc.constraint_catalog=tc.constraint_catalog and cc.constraint_schema=tc.constraint_schema and cc.constraint_name=tc.constraint_name\n"
-            + "where tc.constraint_schema='public' and not substr(tc.constraint_name, 1, length('CK_IS_NOT_NULL_')) = 'CK_IS_NOT_NULL_'\n"
+            + "where tc.constraint_schema not in (select schema_name from information_schema.schemata where schema_owner='spanner_system') and not substr(tc.constraint_name, 1, length('CK_IS_NOT_NULL_')) = 'CK_IS_NOT_NULL_'\n"
             + ")";
 
     public static final String EMPTY_PG_CONSTRAINT_CTE =
diff --git a/src/main/resources/metadata/default_command_metadata.json b/src/main/resources/metadata/default_command_metadata.json
index 7249045c..7e711d23 100644
--- a/src/main/resources/metadata/default_command_metadata.json
+++ b/src/main/resources/metadata/default_command_metadata.json
@@ -154,7 +154,7 @@
     },
     {
       "input_pattern": "^SELECT n\\.nspname as \"[^\"]*\",[ \n]+c\\.relname as \"[^\"]*\",[ \n]+CASE c\\.relkind (WHEN '.' THEN '[^']*' )+END as \"[^\"]*\",[ \n]+pg_catalog\\.pg_get_userbyid\\(c\\.relowner\\) as \"[^\"]*\"\nFROM pg_catalog\\.pg_class c[ \n]+LEFT JOIN pg_catalog\\.pg_namespace n ON n\\.oid = c\\.relnamespace\nWHERE c\\.relkind IN \\('r'(?:,'p')?(?:,'t')?,'s',''\\)[ \n]+AND (?:n\\.nspname !~ '\\^pg_toast'[ \n]+AND )?c\\.relname OPERATOR\\(pg_catalog\\.~\\) '\\^\\((?<tablename>.*)\\)\\$'[ \n]+AND pg_catalog\\.pg_table_is_visible\\(c\\.oid\\)\nORDER BY 1,2;?$",
-      "output_pattern": "SELECT * FROM information_schema.tables WHERE LOWER(table_name) = LOWER('%s');",
+      "output_pattern": "SELECT * FROM information_schema.tables WHERE table_schema='public' AND LOWER(table_name) = LOWER('%s');",
       "matcher_array": [
         "tablename"
       ],
@@ -162,7 +162,7 @@
     },
     {
       "input_pattern": "(?s)^SELECT n\\.nspname as \"Schema\",\\s*c\\.relname as \"Name\",\\s*CASE c.relkind .* END as \"Type\",\\s*pg_catalog\\.pg_get_userbyid\\(c\\.relowner\\) as \"Owner\"\\s+FROM pg_catalog\\.pg_class c\\s+LEFT JOIN pg_catalog\\.pg_namespace n ON n\\.oid = c\\.relnamespace\\s+LEFT JOIN pg_catalog\\.pg_am am ON am\\.oid = c\\.relam\\s+WHERE c\\.relkind IN \\('r','p','t','s',''\\)\\s+AND c.relname OPERATOR\\(pg_catalog\\.~\\) '\\^\\((?<tablename>.*)\\)\\$' COLLATE pg_catalog\\.default\\s+AND pg_catalog\\.pg_table_is_visible\\(c\\.oid\\)\nORDER BY 1,2;?$",
-      "output_pattern": "SELECT * FROM information_schema.tables WHERE LOWER(table_name) = LOWER('%s');",
+      "output_pattern": "SELECT * FROM information_schema.tables WHERE table_schema='public' AND LOWER(table_name) = LOWER('%s');",
       "matcher_array": [
         "tablename"
       ],
@@ -170,7 +170,7 @@
     },
     {
       "input_pattern": "(?s)^SELECT n\\.nspname as \"Schema\",\\s*c\\.relname as \"Name\",\\s*CASE c.relkind .* END as \"Type\",\\s*pg_catalog\\.pg_get_userbyid\\(c\\.relowner\\) as \"Owner\"\\s+FROM pg_catalog\\.pg_class c\\s+LEFT JOIN pg_catalog\\.pg_namespace n ON n\\.oid = c.relnamespace\\s+WHERE c.relkind IN \\('r','p','s',''\\)\\s+AND n\\.nspname !~ '\\^pg_toast'\\s+AND c\\.relname OPERATOR\\(pg_catalog\\.~\\) '\\^\\((?<tablename>.*)\\)\\$' COLLATE pg_catalog\\.default\\s+AND pg_catalog\\.pg_table_is_visible\\(c.oid\\)\\s+ORDER BY 1,2;?$",
-      "output_pattern": "SELECT * FROM information_schema.tables WHERE LOWER(table_name) = LOWER('%s');",
+      "output_pattern": "SELECT * FROM information_schema.tables WHERE table_schema='public' AND LOWER(table_name) = LOWER('%s');",
       "matcher_array": [
         "tablename"
       ],
@@ -184,7 +184,7 @@
     },
     {
       "input_pattern": "^SELECT n\\.nspname as \"[^\"]*\",[ \n]+c\\.relname as \"[^\"]*\",[ \n]+CASE c\\.relkind (WHEN '.' THEN '[^']*' )+END as \"[^\"]*\",[ \n]+pg_catalog\\.pg_get_userbyid\\(c\\.relowner\\) as \"[^\"]*\",[ \n]+c2\\.relname as \"[^\"]*\"\nFROM pg_catalog\\.pg_class c[ \n]+LEFT JOIN pg_catalog\\.pg_namespace n ON n\\.oid = c\\.relnamespace\\s+(?:LEFT JOIN pg_catalog\\.pg_am am ON am\\.oid = c.relam\\s+)?LEFT JOIN pg_catalog\\.pg_index i ON i\\.indexrelid = c\\.oid[ \n]+LEFT JOIN pg_catalog\\.pg_class c2 ON i\\.indrelid = c2\\.oid\nWHERE c\\.relkind IN \\('i'(?:,'I')?,'s',''\\)[ \n]+AND (?:n\\.nspname !~ '\\^pg_toast'[ \n]+AND )?c\\.relname OPERATOR\\(pg_catalog\\.~\\) '\\^\\((?<indexname>.*)\\)\\$'[ \n]+AND pg_catalog\\.pg_table_is_visible\\(c\\.oid\\)\nORDER BY 1,2;?$",
-      "output_pattern": "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE LOWER(index_name) = LOWER('%s');",
+      "output_pattern": "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE table_schema='public' AND LOWER(index_name) = LOWER('%s');",
       "matcher_array": [
         "indexname"
       ],
@@ -192,7 +192,7 @@
     },
     {
       "input_pattern": "(?s)^SELECT n\\.nspname as \"Schema\",\\s*c\\.relname as \"Name\",\\s*CASE c\\.relkind WHEN .* END as \"Type\",\\s*pg_catalog\\.pg_get_userbyid\\(c\\.relowner\\) as \"Owner\",\\s*c2\\.relname as \"Table\"\\s+FROM pg_catalog\\.pg_class c\\s+LEFT JOIN pg_catalog\\.pg_namespace n ON n\\.oid = c\\.relnamespace(?:\\s+LEFT JOIN pg_catalog\\.pg_am am ON am\\.oid = c\\.relam)?\\s+LEFT JOIN pg_catalog\\.pg_index i ON i\\.indexrelid = c\\.oid\\s+LEFT JOIN pg_catalog\\.pg_class c2 ON i\\.indrelid = c2.oid\\s+WHERE c\\.relkind IN \\('i','I','s',''\\)\\s+AND n\\.nspname !~ '\\^pg_toast'\\s+AND c\\.relname OPERATOR\\(pg_catalog\\.~\\) '\\^\\((?<indexname>.*)\\)\\$' COLLATE pg_catalog\\.default\\s+AND pg_catalog\\.pg_table_is_visible\\(c\\.oid\\)\\s+ORDER BY 1,2;?$",
-      "output_pattern": "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE LOWER(index_name) = LOWER('%s');",
+      "output_pattern": "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE table_schema='public' AND LOWER(index_name) = LOWER('%s');",
       "matcher_array": [
         "indexname"
       ],
@@ -200,7 +200,7 @@
     },
     {
       "input_pattern": "(?s)^SELECT n\\.nspname as \"Schema\",\\s*c\\.relname as \"Name\",\\s*CASE c\\.relkind WHEN .* END as \"Type\",\\s*pg_catalog\\.pg_get_userbyid\\(c\\.relowner\\) as \"Owner\",\\s*c2\\.relname as \"Table\"\\s+FROM pg_catalog\\.pg_class c\\s+LEFT JOIN pg_catalog\\.pg_namespace n ON n\\.oid = c\\.relnamespace\\s+LEFT JOIN pg_catalog\\.pg_am am ON am.oid = c\\.relam\\s+LEFT JOIN pg_catalog\\.pg_index i ON i\\.indexrelid = c\\.oid\\s+LEFT JOIN pg_catalog\\.pg_class c2 ON i\\.indrelid = c2\\.oid\\s+WHERE c\\.relkind IN \\('i','I','s',''\\)\\s+AND c\\.relname OPERATOR\\(pg_catalog\\.~\\) '\\^\\((?<indexname>.*)\\)\\$' COLLATE pg_catalog\\.default\\s+AND pg_catalog\\.pg_table_is_visible\\(c\\.oid\\)\\s+ORDER BY 1,2;?$",
-      "output_pattern": "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE LOWER(index_name) = LOWER('%s');",
+      "output_pattern": "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE table_schema='public' AND LOWER(index_name) = LOWER('%s');",
       "matcher_array": [
         "indexname"
       ],
@@ -238,7 +238,7 @@
     },
     {
       "input_pattern": "^SELECT pg_catalog\\.quote_ident\\(attname\\)[ \n]+FROM pg_catalog\\.pg_attribute a, pg_catalog\\.pg_class c[ \n]+WHERE c\\.oid = a\\.attrelid[ \n]+AND a\\.attnum > \\d+[ \n]+AND NOT a\\.attisdropped[ \n]+AND substring\\(pg_catalog\\.quote_ident\\(attname\\),\\d+,\\d+\\)='(?<attrprefix>.*)'[ \n]+AND \\(pg_catalog\\.quote_ident\\(relname\\)='(?<tablename>.*)'[ \n]+OR '\"' \\|\\| relname \\|\\| '\"'='.*'\\)[ \n]+AND pg_catalog\\.pg_table_is_visible\\(c\\.oid\\)\nLIMIT 1000$",
-      "output_pattern": "SELECT column_name AS quote_ident FROM information_schema.columns WHERE table_name = '%s' AND STARTS_WITH(LOWER(COLUMN_NAME), LOWER('%s')) LIMIT 1000;",
+      "output_pattern": "SELECT column_name AS quote_ident FROM information_schema.columns WHERE table_schema='public' AND table_name = '%s' AND STARTS_WITH(LOWER(COLUMN_NAME), LOWER('%s')) LIMIT 1000;",
       "matcher_array": [
         "tablename",
         "attrprefix"
@@ -255,7 +255,7 @@
     },
     {
       "input_pattern": "^SELECT pg_catalog\\.quote_ident\\(c\\.relname\\) FROM pg_catalog\\.pg_class c WHERE c\\.relkind IN \\('r', 'p'\\) AND substring\\(pg_catalog\\.quote_ident\\(c\\.relname\\),\\d+,\\d+\\)='(?<prefix>.*)' AND pg_catalog\\.pg_table_is_visible\\(c\\.oid\\) AND c\\.relnamespace <> \\(SELECT oid FROM pg_catalog\\.pg_namespace WHERE nspname = 'pg_catalog'\\)\nUNION\nSELECT pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.' FROM pg_catalog\\.pg_namespace n WHERE substring\\(pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.',\\d+,\\d+\\)='(.*) AND \\(SELECT pg_catalog\\.count\\(\\*\\) FROM pg_catalog\\.pg_namespace WHERE substring\\(pg_catalog\\.quote_ident\\(nspname\\) \\|\\| '\\.',\\d+,\\d+\\) = substring\\('(.*),\\d+,pg_catalog\\.length\\(pg_catalog\\.quote_ident\\(nspname\\)\\)\\+\\d+\\)\\) > \\d+\nUNION\nSELECT pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.' \\|\\| pg_catalog\\.quote_ident\\(c\\.relname\\) FROM pg_catalog\\.pg_class c, pg_catalog\\.pg_namespace n WHERE c\\.relnamespace = n\\.oid AND c\\.relkind IN \\('r', 'p'\\) AND substring\\(pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.' \\|\\| pg_catalog\\.quote_ident\\(c\\.relname\\),\\d+,\\d+\\)='(.*) AND substring\\(pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.',\\d+,\\d+\\) = substring\\('(.*),\\d+,pg_catalog\\.length\\(pg_catalog\\.quote_ident\\(n\\.nspname\\)\\)\\+\\d+\\) AND \\(SELECT pg_catalog\\.count\\(\\*\\) FROM pg_catalog\\.pg_namespace WHERE substring\\(pg_catalog\\.quote_ident\\(nspname\\) \\|\\| '\\.',\\d+,\\d+\\) = substring\\('(.*),\\d+,pg_catalog\\.length\\(pg_catalog\\.quote_ident\\(nspname\\)\\)\\+\\d+\\)\\) = \\d+\nLIMIT \\d+$",
-      "output_pattern": "SELECT table_name AS quote_ident FROM INFORMATION_SCHEMA.TABLES WHERE STARTS_WITH(LOWER(table_name), LOWER('%s')) LIMIT 1000;",
+      "output_pattern": "SELECT table_name AS quote_ident FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='public' AND STARTS_WITH(LOWER(table_name), LOWER('%s')) LIMIT 1000;",
       "matcher_array": [
         "prefix"
       ],
@@ -263,7 +263,7 @@
     },
     {
       "input_pattern": "^SELECT pg_catalog\\.quote_ident\\(c\\.relname\\) FROM pg_catalog\\.pg_class c WHERE c\\.relkind IN \\('i', 'I'\\) AND substring\\(pg_catalog\\.quote_ident\\(c\\.relname\\),\\d+,\\d+\\)='(?<prefix>.*)' AND pg_catalog\\.pg_table_is_visible\\(c\\.oid\\) AND c\\.relnamespace <> \\(SELECT oid FROM pg_catalog\\.pg_namespace WHERE nspname = 'pg_catalog'\\)\nUNION\nSELECT pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.' FROM pg_catalog\\.pg_namespace n WHERE substring\\(pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.',\\d+,\\d+\\)='(.*)' AND \\(SELECT pg_catalog\\.count\\(\\*\\) FROM pg_catalog\\.pg_namespace WHERE substring\\(pg_catalog\\.quote_ident\\(nspname\\) \\|\\| '\\.',\\d+,\\d+\\) = substring\\('(.*)',\\d+,pg_catalog\\.length\\(pg_catalog\\.quote_ident\\(nspname\\)\\)\\+\\d+\\)\\) > \\d+\nUNION\nSELECT pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.' \\|\\| pg_catalog\\.quote_ident\\(c\\.relname\\) FROM pg_catalog\\.pg_class c, pg_catalog\\.pg_namespace n WHERE c\\.relnamespace = n\\.oid AND c\\.relkind IN \\('i', 'I'\\) AND substring\\(pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.' \\|\\| pg_catalog\\.quote_ident\\(c\\.relname\\),\\d+,\\d+\\)='(.*)' AND substring\\(pg_catalog\\.quote_ident\\(n\\.nspname\\) \\|\\| '\\.',\\d+,\\d+\\) = substring\\('(.*)',\\d+,pg_catalog\\.length\\(pg_catalog\\.quote_ident\\(n\\.nspname\\)\\)\\+\\d+\\) AND \\(SELECT pg_catalog\\.count\\(\\*\\) FROM pg_catalog\\.pg_namespace WHERE substring\\(pg_catalog\\.quote_ident\\(nspname\\) \\|\\| '\\.',\\d+,\\d+\\) = substring\\('(.*)',\\d+,pg_catalog\\.length\\(pg_catalog\\.quote_ident\\(nspname\\)\\)\\+\\d+\\)\\) = \\d+\nLIMIT \\d+$",
-      "output_pattern": "SELECT index_name AS quote_ident FROM INFORMATION_SCHEMA.INDEXES WHERE STARTS_WITH(LOWER(index_name), LOWER('%s')) LIMIT 1000;",
+      "output_pattern": "SELECT index_name AS quote_ident FROM INFORMATION_SCHEMA.INDEXES WHERE table_schema='public' AND STARTS_WITH(LOWER(index_name), LOWER('%s')) LIMIT 1000;",
       "matcher_array": [
         "prefix"
       ],


Test patch:
diff --git a/src/test/java/com/google/cloud/spanner/pgadapter/statements/PSQLTest.java b/src/test/java/com/google/cloud/spanner/pgadapter/statements/PSQLTest.java
index 45533ed1..7a65bb7a 100644
--- a/src/test/java/com/google/cloud/spanner/pgadapter/statements/PSQLTest.java
+++ b/src/test/java/com/google/cloud/spanner/pgadapter/statements/PSQLTest.java
@@ -376,7 +376,7 @@ public class PSQLTest {
             + "  AND pg_catalog.pg_table_is_visible(c.oid)\n"
             + "ORDER BY 1,2;";
     String expected =
-        "SELECT * FROM information_schema.tables WHERE LOWER(table_name) = LOWER('users')";
+        "SELECT * FROM information_schema.tables WHERE table_schema='public' AND LOWER(table_name) = LOWER('users')";
 
     assertEquals(expected, translate(sql));
   }
@@ -400,7 +400,7 @@ public class PSQLTest {
             + "  AND pg_catalog.pg_table_is_visible(c.oid)\n"
             + "ORDER BY 1,2;";
     String expected =
-        "SELECT * FROM information_schema.tables WHERE LOWER(table_name) ="
+        "SELECT * FROM information_schema.tables WHERE table_schema='public' AND LOWER(table_name) ="
             + " LOWER('bobby''; DROP TABLE USERS; SELECT''')";
 
     assertEquals(expected, translate(sql));
@@ -456,7 +456,7 @@ public class PSQLTest {
             + "  AND pg_catalog.pg_table_is_visible(c.oid)\n"
             + "ORDER BY 1,2;";
     String expected =
-        "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE LOWER(index_name) ="
+        "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE table_schema='public' AND LOWER(index_name) ="
             + " LOWER('index')";
 
     assertEquals(expected, translate(sql));
@@ -484,7 +484,7 @@ public class PSQLTest {
             + "  AND pg_catalog.pg_table_is_visible(c.oid)\n"
             + "ORDER BY 1,2;";
     String expected =
-        "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE LOWER(index_name) ="
+        "SELECT table_catalog, table_schema, table_name, index_name, index_type, parent_table_name, is_unique, is_null_filtered, index_state, spanner_is_managed FROM information_schema.indexes WHERE table_schema='public' AND LOWER(index_name) ="
             + " LOWER('bobby''; DROP TABLE USERS; SELECT''')";
 
     assertEquals(expected, translate(sql));
@@ -617,7 +617,7 @@ public class PSQLTest {
             + "LIMIT 1000";
     String expected =
         "SELECT column_name AS quote_ident FROM information_schema.columns WHERE"
-            + " table_name = 'user' AND STARTS_WITH(LOWER(COLUMN_NAME), LOWER('age')) LIMIT 1000";
+            + " table_schema='public' AND table_name = 'user' AND STARTS_WITH(LOWER(COLUMN_NAME), LOWER('age')) LIMIT 1000";
 
     assertEquals(expected, translate(sql));
   }
@@ -681,7 +681,7 @@ public class PSQLTest {
             + "LIMIT 1000";
     String expected =
         "SELECT table_name AS quote_ident FROM INFORMATION_SCHEMA.TABLES WHERE"
-            + " STARTS_WITH(LOWER(table_name), LOWER('user')) LIMIT 1000";
+            + " table_schema='public' AND STARTS_WITH(LOWER(table_name), LOWER('user')) LIMIT 1000";
 
     assertEquals(expected, translate(sql));
   }
@@ -713,7 +713,7 @@ public class PSQLTest {
             + "LIMIT 1000";
     String expected =
         "SELECT index_name AS quote_ident FROM INFORMATION_SCHEMA.INDEXES WHERE"
-            + " STARTS_WITH(LOWER(index_name), LOWER('index')) LIMIT 1000";
+            + " table_schema='public' AND STARTS_WITH(LOWER(index_name), LOWER('index')) LIMIT 1000";
 
     assertEquals(expected, translate(sql));
   }