xo / usql

Universal command-line interface for SQL databases
MIT License
8.92k stars 351 forks source link

Oracle - slice bound out of range #105

Closed PrimaMateria closed 4 years ago

PrimaMateria commented 4 years ago

Hi, I am not able to figure out how to connect to oracle db. I am always getting the same error whatever url I specify.

~
❯ echo  $ORACLE_HOME
/Users/user/homebrew/opt/instantclient-sdk/
❯ usql
Type "help" for help.

(not connected)=> \drivers
Available Drivers:
  avatica [av, phoenix]
  clickhouse [ch]
  cockroachdb (postgres) [cr, cdb, crdb, cockroach]
  cql [ca, scy, scylla, datastax, cassandra]
  firebirdsql [fb, firebird]
  goracle [or, ora, oci, oci8, odpi, oracle, odpi-c]
  hdb [sa, sap, hana, saphana]
  ignite [ig, gridgain]
  memsql (mysql) [me]
  mssql [ms, sqlserver]
  mymysql [zm, mymy]
  mysql [my, maria, aurora, mariadb, percona]
  n1ql [n1, couchbase]
  odbc [od]
  pgx [px]
  postgres [pg, pgsql, postgresql]
  presto [pr, prs, prestos, prestodb, prestodbs]
  redshift (postgres) [rs]
  snowflake [sf]
  sqlite3 [sq, file, sqlite]
  tds [ax, ase, sapase]
  tidb (mysql) [ti]
  vertica [ve]
  vitess (mysql) [vt]
  voltdb [vo, vdb, volt]
(not connected)=> \c oracle://server/service
error: %!v(PANIC=Error method: runtime error: slice bounds out of range [313:9])

I tried several combinations - username and password, port, sid, service name. All end with the same error.

chakri-stark commented 4 years ago

Yes, if I give a command with -c "query", I am getting PANIC error Else, there is no output, nothing at all, just empty line

chakri-stark commented 4 years ago

My observations: I have encountered this issue when my instance is not setup proper

With proper oracle setup, I was not getting the panic error. But, If I use some improper query, I am getting PANIC error. May be improper query is to be handled and meaningful error message has to be displayed.

BTW, USQL is a wonderful tool to use :)

nperrier commented 4 years ago

I was able to connect, but anytime I execute invalid sql syntax I get the message:

error: %!v(PANIC=Error method: runtime error: slice bounds out of range [17:9])

My Oracle db is inside a docker container if that helps. I'm using version Oracle 12.2c and the latest version of usql. I'm on MacOS Mojave.

kenshaw commented 4 years ago

An update: Oracle has made it extremely difficult to work with their database. I'm committed to fixing this issue, and getting usql working with Oracle, but Oracle isn't making it any easier. Previously I had been developing locally against Docker images as well as against production and staging deployments of the Oracle database. Unfortunately, at the moment, I am not currently administering any Oracle databases in a staging or production environment and Oracle has decided to DMCA every Docker image off the net, leaving only their broken, non-working images. I've filed an issue against their GitHub, which has not been responded to. While I have a number of development systems available to test with, sadly I cannot seem to get any working with Oracle 19.3 in any kind of capacity. It's not that I'm unable or unwilling, but that I don't have time to deal with Oracle's broken builds, non-standard environments, and insane (antiquated?) procedures necessary to fix this issue. As something of a mild-perfectionist, the fact that usql is not working properly with one of the major databases really rankles me, but I may not have enough time to fix this issue in any kind of quick fashion.

I deeply apologize to those who would like to use usql with Oracle (I would too!), but as it is, I feel that it's really Oracle that's unusable, and not usql. That said, if anyone wanted to track down this issue and fix it, I'd be happy to accept a PR for it.

kenshaw commented 4 years ago

I tracked down the issue from within usql, I still don't know how this strange message is being generated, but the errors should be handled/unwrapped properly now from within usql:

$ go build -tags 'no_base,oracle' && ./usql or://localhost:1521/blah
error: godror: ORA-12545: Connect failed because target host or object does not exist
$
nperrier commented 4 years ago

https://www.orafaq.com/wiki/ORA-12545

kenshaw commented 4 years ago

@nperrier appreciate the pointer. The ORA-12545 error in the above is how usql formats the error message that's being reported by the godror driver, which in turn is using Oracle's C library, and is returning that error message. This is the standard error message formatting for all of the databases that usql supports. As I am not able to actually run an Oracle database (see my previous comment), I can't fix any remaining connectivity issues in either usql or the godror driver.

nperrier commented 4 years ago

Thanks @kenshaw, appreciate the work.

I agree, Oracle's databases are incredibly backwards (they don't even have a BOOLEAN type and it's almost the year 2020).