changeset 17:8a0be77580c3

Use raw strings for string parameters to prepared SQL queries. As part of this, the string prefix is changed to r' instead of plain '.
author Sjoerd Mullender <sjoerd@acm.org>
date Thu, 09 Apr 2020 16:11:32 +0200 (2020-04-09)
parents 64888d282f47
children 3e289da81c9e
files DBD/monetdb.pm DBD/monetdb/TypeInfo.pm
diffstat 2 files changed, 11 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/DBD/monetdb.pm
+++ b/DBD/monetdb.pm
@@ -102,9 +102,6 @@ sub quote {
     $value = Encode::encode_utf8($value);
 
     for ($value) {
-      s/\\/\\\\/g;
-      s/\n/\\n/g;
-      s/"/\\"/g;
       s/'/''/g;
     }
 
--- a/DBD/monetdb/TypeInfo.pm
+++ b/DBD/monetdb/TypeInfo.pm
@@ -34,8 +34,8 @@ my %index =
 my @data =
 (
 #   NAME                        TYPE                              SIZE PREFIX SUFFIX  PARAMS            N  C  S      U  F      A  NAME     MIN    MAX  TYPE            SUB  RADIX   IV_P
-  ['char'                     , SQL_CHAR                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0,     0, undef, undef, undef, SQL_CHAR    , undef, undef, undef ]
-, ['character'                , SQL_CHAR                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0,     0, undef, undef, undef, SQL_CHAR    , undef, undef, undef ]
+  ['char'                     , SQL_CHAR                     , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0,     0, undef, undef, undef, SQL_CHAR    , undef, undef, undef ]
+, ['character'                , SQL_CHAR                     , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0,     0, undef, undef, undef, SQL_CHAR    , undef, undef, undef ]
 , ['decimal'                  , SQL_DECIMAL                  ,      19, undef, undef,'precision,scale', 1, 0, 2,     0, 0,     0, undef,     0,    19, SQL_DECIMAL , undef,    10, undef ]
 , ['dec'                      , SQL_DECIMAL                  ,      19, undef, undef,'precision,scale', 1, 0, 2,     0, 0,     0, undef,     0,    19, SQL_DECIMAL , undef,    10, undef ]
 , ['numeric'                  , SQL_DECIMAL                  ,      19, undef, undef,'precision,scale', 1, 0, 2,     0, 0,     0, undef,     0,    19, SQL_DECIMAL , undef,    10, undef ]
@@ -48,20 +48,20 @@ my @data =
 , ['real'                     , SQL_REAL                     ,      24, undef, undef, undef           , 1, 0, 2,     0, 0,     0, undef,     0,     0, SQL_REAL    , undef,     2, undef ]
 , ['double'                   , SQL_DOUBLE                   ,      53, undef, undef, undef           , 1, 0, 2,     0, 0,     0, undef,     0,     0, SQL_DOUBLE  , undef,     2, undef ]
 , ['double precision'         , SQL_DOUBLE                   ,      53, undef, undef, undef           , 1, 0, 2,     0, 0,     0, undef,     0,     0, SQL_DOUBLE  , undef,     2, undef ]
-, ['varchar'                  , SQL_VARCHAR                  , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_VARCHAR , undef, undef, undef ]
-, ['character varying'        , SQL_VARCHAR                  , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_VARCHAR , undef, undef, undef ]
-, ['char varying'             , SQL_VARCHAR                  , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_VARCHAR , undef, undef, undef ]
+, ['varchar'                  , SQL_VARCHAR                  , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_VARCHAR , undef, undef, undef ]
+, ['character varying'        , SQL_VARCHAR                  , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_VARCHAR , undef, undef, undef ]
+, ['char varying'             , SQL_VARCHAR                  , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_VARCHAR , undef, undef, undef ]
 , ['boolean'                  , SQL_BOOLEAN                  ,       1, undef, undef, undef           , 1, 0, 2,     0, 1,     0, undef, undef, undef, SQL_BOOLEAN , undef, undef, undef ]
 , ['bool'                     , SQL_BOOLEAN                  ,       1, undef, undef, undef           , 1, 0, 2,     0, 1,     0, undef, undef, undef, SQL_BOOLEAN , undef, undef, undef ]
 , ['bigint'                   , 25                           ,      19, undef, undef, undef           , 1, 0, 2,     0, 0,     0, undef,     0,     0, 25          , undef,    10, undef ]
 , ['blob'                     , SQL_BLOB                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_BLOB    , undef, undef, undef ]
 , ['binary large object'      , SQL_BLOB                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_BLOB    , undef, undef, undef ]
-, ['clob'                     , SQL_CLOB                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
-, ['character large object'   , SQL_CLOB                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
-, ['char large object'        , SQL_CLOB                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
-, ['string'                   , SQL_CLOB                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
-, ['text'                     , SQL_CLOB                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
-, ['tinytext'                 , SQL_CLOB                     , 1000000, "'"  , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
+, ['clob'                     , SQL_CLOB                     , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
+, ['character large object'   , SQL_CLOB                     , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
+, ['char large object'        , SQL_CLOB                     , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
+, ['string'                   , SQL_CLOB                     , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
+, ['text'                     , SQL_CLOB                     , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
+, ['tinytext'                 , SQL_CLOB                     , 1000000, "r'" , "'"  ,'length'         , 1, 1, 3, undef, 0, undef, undef, undef, undef, SQL_CLOB    , undef, undef, undef ]
 , ['date'                     , SQL_TYPE_DATE                   ,      10,      "date '", "'"                 , undef           , 1, 0, 2, undef, 0, undef, undef, undef, undef, SQL_DATE    ,     1, undef, undef ]
 , ['time'                     , SQL_TYPE_TIME                   ,      12,      "time '", "'"                 ,'precision'      , 1, 0, 2, undef, 0, undef, undef, undef, undef, SQL_DATE    ,     2, undef, undef ]
 , ['timestamp'                , SQL_TYPE_TIMESTAMP              ,      23, "timestamp '", "'"                 ,'precision'      , 1, 0, 2, undef, 0, undef, undef, undef, undef, SQL_DATE    ,     3, undef, undef ]