Skip to content

Commit c2bc0db

Browse files
committed
fix(oracle): use view available for all users for driver.Version
Use v$version instead of v$instance because it is available to all users. Like v$instance, v$version is available in all oracle versions from the past 20+ years. Typical Version() output is "Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production" Testing Done: Oracle Express 21c and 11g For 11g: docker run -d -p 1521:1521 -e ORACLE_PASSWORD=foobar gvenzl/oracle-xe:11-slim ./usql oracle://sys:foobar@localhost/xe # version is shown correctly create user test identified by test; GRANT CREATE SESSION to test; \connect oracle://test:test@localhost/xe # version is still shown correctly, despite minimal privileges 21c in the issue was also tested that way.
1 parent ce82ecc commit c2bc0db

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

contrib/godror/usql-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
DB="godror://system:P4ssw0rd@localhost/orasid"
2-
VSQL="SELECT version FROM v\$instance"
2+
VSQL="SELECT banner as version FROM v\$version"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
DB="oracle://system:P4ssw0rd@localhost:1522/db1"
2-
VSQL="SELECT version FROM v\$instance"
2+
VSQL="SELECT banner as version FROM v\$version"

contrib/oracle/usql-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
DB="oracle://system:P4ssw0rd@localhost/free"
2-
VSQL="SELECT version FROM v\$instance"
2+
VSQL="SELECT banner as version FROM v\$version"

drivers/oracle/orshared/orshared.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ func Register(name string, err func(error) (string, string), isPasswordErr func(
3737
},
3838
Version: func(ctx context.Context, db drivers.DB) (string, error) {
3939
var ver string
40-
if err := db.QueryRowContext(ctx, `SELECT version FROM v$instance`).Scan(&ver); err != nil {
40+
if err := db.QueryRowContext(ctx, `SELECT banner FROM v$version`).Scan(&ver); err != nil {
4141
return "", err
4242
}
43-
return "Oracle Database " + ver, nil
43+
return ver, nil
4444
},
4545
User: func(ctx context.Context, db drivers.DB) (string, error) {
4646
var user string

0 commit comments

Comments
 (0)