readysettech / readyset

Readyset is a MySQL and Postgres wire-compatible caching layer that sits in front of existing databases to speed up queries and horizontally scale read throughput. Under the hood, ReadySet caches the results of cached select statements and incrementally updates these results over time as the underlying data changes.
https://readyset.io
Other
4.55k stars 126 forks source link

PostgreSQL Invalid custom schema #1343

Open beyond007jj opened 4 months ago

beyond007jj commented 4 months ago

Describe the problem PostgreSQL version: PostgreSQL 15.7 The default currentSchema seems to be 'public', but the custom currentSchema is invalid An error occurred while running the following code ‘myschema’ ` spring:

  application:
    name: readyset-demo
  datasource:
    driverClassName: org.postgresql.Driver
    url: jdbc:postgresql://sql-proxy:5433/mydb?currentSchema=myschema&stringtype=unspecified
    username: pguser
    password: xxxxxx
    hikari:
#      connection-init-sql: SET search_path TO myschema

`

mybatis insert table 'student', error message: ` org.springframework.jdbc.BadSqlGrammarException:

Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: relation "student" does not exist

The error may exist in com/xxx/xxx/readyset/demo/dao/StudentDao.java (best guess)

The error may involve com.xxx.xxx.readyset.demo.dao.StudentDao.insert-Inline

The error occurred while setting parameters

SQL: INSERT INTO student ( id, name, age ) VALUES ( ?, ?, ? )

Cause: org.postgresql.util.PSQLException: ERROR: relation "student" does not exist

; bad SQL grammar []

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:246)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:107)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439)
at jdk.proxy2/jdk.proxy2.$Proxy65.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:152)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at jdk.proxy2/jdk.proxy2.$Proxy68.insert(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:354)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223)
at jdk.proxy2/jdk.proxy2.$Proxy69.insert(Unknown Source)
at com.baomidou.mybatisplus.extension.service.IService.save(IService.java:61)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:354)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:716)
at com.xxx.xxx.readyset.demo.service.impl.StudentServiceImpl$$SpringCGLIB$$0.save(<generated>)
at com.xxx.xxx.readyset.demo.StudentServiceTest.insertTest(StudentServiceTest.java:37)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

`

but,If the comment 'connection-init-sql' is opened, it can be queried normally.