oracle / odpi

ODPI-C: Oracle Database Programming Interface for Drivers and Applications
https://oracle.github.io/odpi/
Other
264 stars 75 forks source link

`dpiStmt_execute` with `DPI_MODE_EXEC_PARSE_ONLY` will create a table. #180

Closed AaronDMarasco closed 9 months ago

AaronDMarasco commented 1 year ago
  1. What version of ODPI-C are you using (see dpi.h)?

    • 4.5.0
  2. What OS (and version) is your application on?

    • Linux (CentOS 7.9)
  3. What compiler (and version) did you use?

    • GCC 11.3.0
  4. What is your version of the Oracle Client (e.g. Instant Client)? How was it installed? Where it is installed?

    • RPM-based and then copied to a network share (/opt/tools/oracle/19.17)
  5. What is your Oracle Database version?

    • 19c Enterprise 19.3.0.0.0
  6. What is the PATH environment variable (on Windows) or LD_LIBRARY_PATH (on Linux) set to?

    • /opt/tools/oracle/19.17/lib
  7. What environment variables did you set? How exactly did you set them?

    • None; I believe ORACLE_HOME is being set by the .so finding mechanism
  8. What problem or error(s) you are seeing?

    • I was trying to examine a "CREATE TABLE" statement with DPI_MODE_EXEC_PARSE_ONLY which says "Do not execute the statement but only parse it and return any parse errors."
    • It created the table anyway.
  9. Do you have a runnable code snippet to describe the problem?

    • No, sorry.
    • I know I was putting the flag into the proper field because I was originally ORing it with DPI_MODE_EXEC_DESCRIBE_ONLY, but when debugging if I tried that alone I received an error about zero iterations.
anthony-tuininga commented 1 year ago

This is not a bug in the code. It could arguably be considered a bug in the documentation, though! This is a "feature" of Oracle. Parsing DDL also executes it. There is no way around that as far as I am aware.

AaronDMarasco commented 1 year ago

@anthony-tuininga I figured something like that would be the response. But IMHO as a total newb in this domain, the documentation should tell me that.

Or maybe there needs to be a totally different "parse/verify this is legit" API call independent of "execute it but not really."

tgulacsi commented 1 year ago

The documentation (https://docs.oracle.com/en/database/oracle/oracle-database/18/lnoci/statement-functions.html#GUID-98B26708-3E02-45C0-8258-5D5544F32BE9) does say nothing about DDL statements, though it's ancient knowledge (https://asktom.oracle.com/pls/apex/asktom.search?tag=ddl-related-parse-execute-fetch). Which I had to experience myself, too.

anthony-tuininga commented 9 months ago

Note added to the documentation.