Skip to content

Commit

Permalink
Merge pull request #10691 from andrioni/andrioni/standard-conforming-…
Browse files Browse the repository at this point in the history
…strings

Support setting `standard_conforming_strings` to `on`
  • Loading branch information
andrioni committed Feb 15, 2022
2 parents b23318c + ace6ae2 commit 04b5f7e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/user/content/release-notes.md
Expand Up @@ -122,6 +122,9 @@ changes that have not yet been documented.
- Improve the clarity of any Avro schema resolution errors found when
creating materialized sources and views. {{% gh 8415 %}}

- Allow setting `standard_conforming_strings` to its default value of `on`.
Setting it to `off` is still not supported.

{{< comment >}}
Only add new release notes above this line.

Expand Down
10 changes: 9 additions & 1 deletion src/coord/src/session/vars.rs
Expand Up @@ -347,7 +347,15 @@ impl Vars {
} else if name == SQL_SAFE_UPDATES.name {
self.sql_safe_updates.set(value, local)
} else if name == STANDARD_CONFORMING_STRINGS.name {
Err(CoordError::ReadOnlyParameter(&STANDARD_CONFORMING_STRINGS))
match bool::parse(value) {
Ok(value) if value == *STANDARD_CONFORMING_STRINGS.value => Ok(()),
Ok(_) => Err(CoordError::ConstrainedParameter(
&STANDARD_CONFORMING_STRINGS,
)),
Err(()) => Err(CoordError::InvalidParameterType(
&STANDARD_CONFORMING_STRINGS,
)),
}
} else if name == TIMEZONE.name {
if UncasedStr::new(value) != TIMEZONE.value {
return Err(CoordError::ConstrainedParameter(&TIMEZONE));
Expand Down
13 changes: 13 additions & 0 deletions test/testdrive/session.td
Expand Up @@ -41,6 +41,19 @@ contains:parameter "client_encoding" can only be set to "UTF8"
! SET NAMES = "something";
contains:unrecognized configuration parameter "names"

# standard_conforming_strings is constrained to true
> SET standard_conforming_strings = ON;

> SET standard_conforming_strings = true;

> SET standard_conforming_strings TO TRUE;

! SET standard_conforming_strings = OFF;
contains:parameter "standard_conforming_strings" can only be set to "on"

! SET standard_conforming_strings = typo;
contains:parameter "standard_conforming_strings" requires a "boolean" value

> SET sql_safe_updates = on
> SHOW sql_safe_updates
on
Expand Down

0 comments on commit 04b5f7e

Please sign in to comment.