[PATCH] Escaping of SAVEPOINT names

Поиск
Список
Период
Сортировка
От Michael Paesold
Тема [PATCH] Escaping of SAVEPOINT names
Дата
Msg-id 454E5534.5050007@gmx.at
обсуждение исходный текст
Ответы Re: [PATCH] Escaping of SAVEPOINT names  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
Escaping of savepoint names in org.postgresql.jdbc3.PSQLSavepoint is
incorrect. Backslashes in (double-quoted) savepoint names are doubled
for escaping, but AFAIK, and as my testing shows, savepoint names are
like identifiers, so regular identifier quoting applies to them.

Therefore backslashes should not be doubled, because they have no
special meaning in a double-quoted string.

While at it, don't use the string literal "\"" just to append a single
double-quote character to a string buffer.

Best Regards,
Michael Paesold
diff -crN pgjdbc.c5a36d75e073/org/postgresql/jdbc3/PSQLSavepoint.java pgjdbc/org/postgresql/jdbc3/PSQLSavepoint.java
*** pgjdbc.c5a36d75e073/org/postgresql/jdbc3/PSQLSavepoint.java    2006-11-05 22:08:31.000000000 +0100
--- pgjdbc/org/postgresql/jdbc3/PSQLSavepoint.java    2006-11-05 22:08:31.000000000 +0100
***************
*** 70,87 ****
          if (_isNamed)
          {
              // We need to quote and escape the name in case it
!             // contains spaces/quotes/backslashes.
              //
              StringBuffer sb = new StringBuffer(_name.length() + 2);
!             sb.append("\"");
              for (int i = 0; i < _name.length(); i++)
              {
                  char c = _name.charAt(i);
!                 if (c == '\\' || c == '"')
                      sb.append(c);
                  sb.append(c);
              }
!             sb.append("\"");
              return sb.toString();
          }

--- 70,87 ----
          if (_isNamed)
          {
              // We need to quote and escape the name in case it
!             // contains spaces/quotes/etc.
              //
              StringBuffer sb = new StringBuffer(_name.length() + 2);
!             sb.append('"');
              for (int i = 0; i < _name.length(); i++)
              {
                  char c = _name.charAt(i);
!                 if (c == '"')
                      sb.append(c);
                  sb.append(c);
              }
!             sb.append('"');
              return sb.toString();
          }


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Michael Paesold
Дата:
Сообщение: JDBC Support for standard_conforming_strings
Следующее
От: Michael Paesold
Дата:
Сообщение: [PATCH] Comments in PGbytea byte[] to pgstring conversion