Skip to content

Named statement parameters are unnecessarily converted to positional on Oracle #3744

@morozov

Description

@morozov

Bug Report

Q A
Version 2.10.0

Summary

The current library design around handling named and positional parameters in prepared statements is a bit of a mess.

Current behaviour

  1. When a statement containing named parameters is executed via the wrapper connection's executeQuery(), the parameters get unconditionally converted to the positional ones via SQLParserUtils::expandListParameters().
  2. The OCI8Statement class converts positional parameters back to the named ones via OCI8Statement::convertPositionalToNamedPlaceholders().

Therefore:

  1. Parameter names get lost in translation: SELECT :COL1 COL1 FROM DUALSELECT :param1 COL1 FROM DUAL.
  2. Extra overhead on query parsing and conversion back and forth.
  3. The wrapper connection implements driver-specific logic which is wrong by design.

How to reproduce

Currently, there's no mechanism to observe the queries in the form in which they hit the underlying DB driver. See the data flow in the new data item added to queryConversionProvider() added in #3738.

Expected behavior

  1. The wrapper statement doesn't contain any conversion logic.
  2. The driver statement converts the unsupported parameters to the supported ones.
  3. No unnecessary conversion happens.

Underlying driver support for parameter binding

Driver Positional Named Expected improvement
ibm_db2 Y N
mysqli Y N
oci8 N Y
pdo_* Y Y
sqlsrv Y N

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions