rfc:pdo_driver_specific_parsers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:pdo_driver_specific_parsers [2024/05/02 08:45] – Updated PR: support for more pgsql literals mbeccatirfc:pdo_driver_specific_parsers [2024/05/20 17:46] (current) – Deprecation notice for "escaped question marks inside dollar quoted string" mbeccati
Line 1: Line 1:
 ====== PHP RFC: PDO Driver specific SQL parsers ====== ====== PHP RFC: PDO Driver specific SQL parsers ======
-  * Version: 0.5+  * Version: 0.7
   * Date: 2024-04-11   * Date: 2024-04-11
   * Author: Matteo Beccati, mbeccati@php.net   * Author: Matteo Beccati, mbeccati@php.net
Line 42: Line 42:
     - single and double quoted literals with both doubling and backslash as escaping mechanisms (MySQL default)     - single and double quoted literals with both doubling and backslash as escaping mechanisms (MySQL default)
     - backtick literals with doubling as escaping mechanism (I also tested and it seems MySQL doesn't accept backslashes as escapes)     - backtick literals with doubling as escaping mechanism (I also tested and it seems MySQL doesn't accept backslashes as escapes)
-    - two-dashes, C-style comments, and Hash-comments, albeit I couldn't force the requirement of a space after "--"+    - two-dashes (if followed by 1 whitespace), C-style comments, and Hash-comments
     - Tests, as necessary     - Tests, as necessary
   - Add a PgSQL specific scanner function:   - Add a PgSQL specific scanner function:
Line 53: Line 53:
   - Add a SqLite specific scanner function:   - Add a SqLite specific scanner function:
     - single, double quoted, and backtick literals, with doubling as escaping mechanism     - single, double quoted, and backtick literals, with doubling as escaping mechanism
 +    - square brackets quoting for identifiers
     - two-dashes and C-style comments (non-nested)     - two-dashes and C-style comments (non-nested)
     - Tests, as necessary     - Tests, as necessary
Line 79: Line 80:
  
 In order to support dollar-quoted strings on Postgres, the functionality of custom quoting has been added to the common PDO parser function. The change has no side effects for other database drivers. In order to support dollar-quoted strings on Postgres, the functionality of custom quoting has been added to the common PDO parser function. The change has no side effects for other database drivers.
 +
 +One minor potential BC-break was reported while researching bug [[https://github.com/php/php-src/issues/14244|#14244]], which basically describes lack of support for dollar quoting in pdo_pgsql. One of the currently viable workarounds is to use escaped question marks inside dollar quoted strings to avoid unexpected placeholder detection. The last version of the implementation still allows that, while raising the following deprecation notice:
 +
 +''Escaping question marks inside dollar quoted strings is not required anymore and is deprecated''.
 +
 +Such BC-compatibility can be removed in the next major version.
 +
  
 ===== Research on String Literals, Identifiers, and Comments =====  ===== Research on String Literals, Identifiers, and Comments ===== 
Line 91: Line 99:
 Several [[https://dev.mysql.com/doc/refman/8.0/en/comments.html|comment types]] supported: ''-- '', ''#'', and ''/* */'' (not nested). Several [[https://dev.mysql.com/doc/refman/8.0/en/comments.html|comment types]] supported: ''-- '', ''#'', and ''/* */'' (not nested).
  
-The RFC aims to support all the above kinds of string literals with string-affecting configuration variables set to their defaults. All comment types will be supported, however "--" is recognised as comment start following the SQL standard, even if MySQL requires a space character after it.+The RFC aims to support all the above kinds of string literals with string-affecting configuration variables set to their defaults. All comment types will be supported.
  
 ==== PostgreSQL ==== ==== PostgreSQL ====
Line 121: Line 129:
 Almost SQL standard [[https://www.sqlite.org/lang_comment.html|comments]]: ''--'' and ''/* */'' (not nested). Almost SQL standard [[https://www.sqlite.org/lang_comment.html|comments]]: ''--'' and ''/* */'' (not nested).
  
-The RFC aims to support single-quoted, double-quoted, and backtick literals. All comment types are already supported. +The RFC aims to support single-quoted, double-quoted, backtick, and square-bracketed literals. All comment types are already supported. 
  
 ==== SQL Server ==== ==== SQL Server ====
Line 163: Line 171:
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
-No expected BC breaks.+No BC breaks, but a deprecation notice will be raised when using the "escaped question marks inside dollar quoted string" workaround described before.
  
 Users having applications that can work with multiple database engines should still be very careful and write portable queries, possibly using the ''PDO::quote()'' method when necessary instead of hardcoding strings containing escape characters. Users having applications that can work with multiple database engines should still be very careful and write portable queries, possibly using the ''PDO::quote()'' method when necessary instead of hardcoding strings containing escape characters.
Line 209: Line 217:
 ===== Patches and Tests ===== ===== Patches and Tests =====
  
-[[https://github.com/php/php-src/pull/14035|Draft Pull Request]]+[[https://github.com/php/php-src/pull/14035|Implementation Pull Request]]
  
 ===== References ===== ===== References =====
rfc/pdo_driver_specific_parsers.1714639540.txt.gz · Last modified: 2024/05/02 08:45 by mbeccati