Re: Inconsistent behaviour with Dollar-quoted String Constants
[email protected] (David Christensen) Sun, 8 Jan 2012 22:22:39 -0600
| Newsgroups | perl.dbd.pg |
|---|---|
| Message-ID | <[email protected]> |
Proposed patch: commit 830ba62d179fca2ccf01d7900aa58676a4a17f9c Author: David Christensen <[email protected]> Date: Sun Jan 8 22:16:40 2012 -0600 allow hi-bit chars in dollar-quoted identifiers diff --git a/dbdimp.c b/dbdimp.c index 0c1d22f..b6f1235 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -1785,12 +1785,12 @@ static void pg_st_split_statement (pTHX_ imp_sth_t * imp_sth, int version, char (*statement == '$' || *statement == '_' || (*statement >= 'A' && *statement <= 'Z') - || (*statement >= 'a' && *statement <= 'z'))) { + || (*statement >= 'a' && *statement <= 'z') + || ((unsigned char)*statement >= (unsigned char)'\200'))) { /* "SQL identifiers must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($) */ - /* Postgres technically allows \200-\377 as well, but we don't */ sectionsize = 0; /* How far from the first dollar sign are we? */ found = 0; /* Have we found the end of the dollarquote? */ @@ -1808,7 +1808,7 @@ static void pg_st_split_statement (pTHX_ imp_sth_t * imp_sth, int version, char || (ch >= 58 && ch <= 64) || (ch >= 91 && ch <= 94) || ch == 96 - || (ch >= 123)) { + ) { break; } } /* end first scan */ diff --git a/t/12placeholders.t b/t/12placeholders.t index f897b22..921f0f9 100644 --- a/t/12placeholders.t +++ b/t/12placeholders.t @@ -17,7 +17,7 @@ my $dbh = connect_database(); if (! $dbh) { plan skip_all => 'Connection to database failed, cannot continue testing'; } -plan tests => 235; +plan tests => 238; my $t='Connect to database for placeholder testing'; isnt ($dbh, undef, $t); @@ -553,6 +553,15 @@ for my $char (qw{0 9 A Z a z}) { ## six letters is ($@, q{}, $t); } +for my $ident (qq{\x{5317}}, qq{abc\x{5317}}, qq{_cde\x{5317}}) { ## hi-bit chars + eval { + $sth = $dbh->prepare(qq{SELECT \$$ident\$ 123 \$$ident\$}); + $sth->execute(); + $sth->finish(); + }; + is ($@, q{}, $t); +} + } SKIP: { Regards, David -- David Christensen End Point Corporation [email protected]