apache / apache/shardingsphere

Table cannot be prefixed with pg_ in ShardingSphere-Proxy PostgreSQL/openGauss

Open
#22,341 2 comments 0 reactions 0 assignees View on GitHub
db: openGauss db: PostgreSQL in: proxy type: bug
Dominant language
Java
Stars
20.8k
Forks
6.9k
Avg merge
11h 38m
Merged PRs (30d)
326

Description

## Bug Report

### Which version of ShardingSphere did you use?

d9798c3c6480ab5434c65b0e726aca72830d140d

This issue is caused by #13692. So this impact ShardingSphere-Proxy >= 5.1.0

### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-Proxy PostgreSQL/openGauss

### Expected behavior

DML operations without error.

### Actual behavior

```
postgres=> create table pg_mytable ();
CREATE TABLE
postgres=> select * from pg_mytable;
ERROR: relation "pg_mytable" does not exist
LINE 1: select * from pg_mytable;
^
```

```
[INFO ] 2022-11-22 17:44:46.210 [Connection-2-ThreadExecutor] o.a.s.p.b.h.a.e.AbstractDatabaseMetadataExecutor$DefaultDatabaseMetadataExecutor - Actual SQL: ds_0 ::: select * from pg_mytable;
[ERROR] 2022-11-22 17:44:46.225 [Connection-2-ThreadExecutor] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
org.postgresql.util.PSQLException: ERROR: relation "pg_mytable" does not exist
Position: 15
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:490)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:408)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:181)
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:133)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
at org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetadataExecutor$DefaultDatabaseMetadataExecutor.getSourceData(AbstractDatabaseMetadataExecutor.java:216)
at org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetadataExecutor.execute(AbstractDatabaseMetadataExecutor.java:76)
at org.apache.shardingsphere.proxy.backend.handler.admin.DatabaseAdminQueryBackendHandler.execute(DatabaseAdminQueryBackendHandler.java:56)
at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor.execute(PostgreSQLComQueryExecutor.java:76)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:111)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
```

Contributor guide

Open the contributing guide

Research direction

Start at AbstractDatabaseMetadataExecutor$DefaultDatabaseMetadataExecutor.getSourceData in the stack trace and review the behavior introduced by #13692. Reproduce the PostgreSQL/openGauss case with CREATE TABLE pg_mytable and SELECT from it; done means DML against the prefixed table completes without a relation-not-found error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.