Skip to content

Commit

Permalink
sql: support backslash_quote session setting
Browse files Browse the repository at this point in the history
This setting is based on an previous issue: cockroachdb#45774. This commit set a placeholder for PostgreSQL configuration setting called (backslash_quote)[https://www.postgresql.org/docs/12/runtime-config-compatible.html#GUC-BACKSLASH-QUOTE], and ensured it is compatible with ORMS.

When users try setting the backslash_quote session variable, CRDB will let it pass, but not making any changes. We leave the functionality implementation to future works.

Details:
- Added `backslash_quote` at varGen at `sql/vars.go` without implementing the true functionality

- Tested it with `subtest backslash_quote_test` at `pkg/sql/logictest/testdata/logic_test/set`

- Removed `backslash_quote` from `unsupported_vars.go`
  • Loading branch information
ZhouXing19 committed Jul 7, 2021
1 parent 78b15bf commit 80d8d09
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/cockroach.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/set
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,20 @@ SET standard_conforming_strings='true'

statement ok
SET standard_conforming_strings='on'


subtest backslash_quote_test

statement ok
SET backslash_quote = 'on';

statement ok
SET backslash_quote = 'off';

statement ok
SET backslash_quote = 'safe_encoding';

statement error invalid value for parameter "backslash_quote"
SET backslash_quote = '123';


2 changes: 1 addition & 1 deletion pkg/sql/unsupported_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var UnsupportedVars = func(ss ...string) map[string]struct{} {
// "application_name",
"array_nulls",
"backend_flush_after",
"backslash_quote",
//"backslash_quote",
// "bytea_output",
"check_function_bodies",
// "client_encoding",
Expand Down
5 changes: 4 additions & 1 deletion pkg/sql/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,11 @@ var varGen = map[string]sessionVar{
// See https://www.postgresql.org/docs/10/static/runtime-config-client.html#GUC-LOC-TIMEOUT
`lock_timeout`: makeCompatIntVar(`lock_timeout`, 0),

// See https://www.postgresql.org/docs/9.1/runtime-config-compatible.html
`backslash_quote`: makeCompatStringVar(`backslash_quote`, `safe_encoding`, `on`, `off`, `safe_encoding`),

// Supported for PG compatibility only.
// See https://www.postgresql.org/docs/10/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
// See https://www.postgresql.org/docs/10/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIER
`max_identifier_length`: {
Get: func(evalCtx *extendedEvalContext) string { return "128" },
},
Expand Down

0 comments on commit 80d8d09

Please sign in to comment.