pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feed[PATCH] Escaping of SAVEPOINT names
2+ messages / 2 participants
[nested] [flat]
* [PATCH] Escaping of SAVEPOINT names
@ 2006-11-05 21:18 Michael Paesold <mpaesold@gmx.at>
0 siblings, 1 reply; 2+ messages in thread
From: Michael Paesold @ 2006-11-05 21:18 UTC (permalink / raw)
To: 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
Attachments:
savepoint-names.patch (text/x-patch, 1.5K) download
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();
}
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [PATCH] Escaping of SAVEPOINT names
@ 2006-11-06 05:46 Kris Jurka <books@ejurka.com>
parent: Michael Paesold <mpaesold@gmx.at>
0 siblings, 0 replies; 2+ messages in thread
From: Kris Jurka @ 2006-11-06 05:46 UTC (permalink / raw)
To: Michael Paesold <mpaesold@gmx.at>; +Cc: pgsql-jdbc
On Sun, 5 Nov 2006, Michael Paesold wrote:
> 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.
>
Applied to 8.0, 8.1, and HEAD.
Kris Jurka
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-11-06 05:46 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-05 21:18 [PATCH] Escaping of SAVEPOINT names Michael Paesold <mpaesold@gmx.at>
2006-11-06 05:46 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox