Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Make sure that queries use LIKE with _ escaped
Browse files Browse the repository at this point in the history
For example:

SELECT nspname
FROM pg_namespace
WHERE nspname NOT LIKE 'pg_%'
  AND nspname != 'information_schema'
ORDER BY nspname

will get every schema whose name isn't information_schema and doesn't begin
with pg (the _ character is a joker character when used with LIKE, meaning
"replace-me-with-one-character-whatever-it-is").

So, we need to escape the underscore to get rid of its special meaning.
  • Loading branch information
gleu committed Mar 6, 2012
1 parent 8702f1a commit 58c8268
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG
Expand Up @@ -37,8 +37,9 @@ Changes

Date Dev Ver Change details
---------- --- ------ --------------
2012-03-06 GL 1.14.3 Fix enabling the OK button of the view dialog. Per report
from Colin Beckingham.
2012-03-06 GL 1.14.3 Make sure that queries use LIKE with _ escaped.
2012-03-06 GL 1.14.3 Fix enabling the OK button of the view dialog. Per
report from Colin Beckingham.
2012-03-05 GL 1.14.3 Fix the trigger SQL. Per report from Attila.
2012-03-01 GL 1.14.3 Another fix on the autovacuum widgets in the table
dialog. Report from Bartosz Dmytrak.
Expand Down
2 changes: 1 addition & 1 deletion pgadmin/dlg/dlgFunction.cpp
Expand Up @@ -383,7 +383,7 @@ int dlgFunction::Go(bool modal)
// create mode
restrict = wxT("(typtype IN ('b', 'c', 'd', 'p') AND typname NOT IN ('any', 'trigger', 'language_handler'))");
if (!settings->GetShowSystemObjects())
restrict += wxT(" AND nspname NOT LIKE 'pg_toast%' AND nspname NOT LIKE 'pg_temp%'");
restrict += wxT(" AND nspname NOT LIKE E'pg\\\\_toast%' AND nspname NOT LIKE E'pg\\\\_temp%'");

DatatypeReader tr(database, restrict);
while (tr.HasMore())
Expand Down

0 comments on commit 58c8268

Please sign in to comment.