Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-23.1.0: sql: fix the pretty-printing of CREATE EXTENSION #102149

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/sql/create_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (n *createExtensionNode) unimplementedExtensionError(issue int) error {
name := n.CreateExtension.Name
return unimplemented.NewWithIssueDetailf(
issue,
"CREATE EXTENSION "+name,
"CREATE EXTENSION "+string(name),
"extension %q is not yet supported",
name,
)
Expand All @@ -48,7 +48,7 @@ func (n *createExtensionNode) startExec(params runParams) error {
"fuzzystrmatch",
"pgcrypto",
"uuid-ossp":
telemetry.Inc(sqltelemetry.CreateExtensionCounter(n.CreateExtension.Name))
telemetry.Inc(sqltelemetry.CreateExtensionCounter(string(n.CreateExtension.Name)))
return nil
case "postgis_raster",
"postgis_topology",
Expand Down Expand Up @@ -105,7 +105,7 @@ func (n *createExtensionNode) startExec(params runParams) error {
"xml2":
return n.unimplementedExtensionError(54516)
}
return pgerror.Newf(pgcode.UndefinedParameter, "unknown extension: %q", n.CreateExtension.Name)
return pgerror.Newf(pgcode.UndefinedParameter, "unknown extension: %s", n.CreateExtension.Name)
}

func (n *createExtensionNode) Next(params runParams) (bool, error) { return false, nil }
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -4472,10 +4472,10 @@ create_schedule_stmt:
create_extension_stmt:
CREATE EXTENSION IF NOT EXISTS name
{
$$.val = &tree.CreateExtension{IfNotExists: true, Name: $6}
$$.val = &tree.CreateExtension{IfNotExists: true, Name: tree.Name($6)}
}
| CREATE EXTENSION name {
$$.val = &tree.CreateExtension{Name: $3}
$$.val = &tree.CreateExtension{Name: tree.Name($3)}
}
| CREATE EXTENSION IF NOT EXISTS name WITH error
{
Expand Down
8 changes: 8 additions & 0 deletions pkg/sql/parser/testdata/create_misc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ CREATE EXTENSION bob -- fully parenthesized
CREATE EXTENSION bob -- literals removed
CREATE EXTENSION bob -- identifiers removed

parse
CREATE EXTENSION "a-b"
----
CREATE EXTENSION "a-b"
CREATE EXTENSION "a-b" -- fully parenthesized
CREATE EXTENSION "a-b" -- literals removed
CREATE EXTENSION "a-b" -- identifiers removed

parse
CREATE EXTENSION IF NOT EXISTS bob
----
Expand Down
6 changes: 4 additions & 2 deletions pkg/sql/sem/tree/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ func (o *CreateStatsOptions) CombineWith(other *CreateStatsOptions) error {

// CreateExtension represents a CREATE EXTENSION statement.
type CreateExtension struct {
Name string
Name Name
IfNotExists bool
}

Expand All @@ -2133,7 +2133,9 @@ func (node *CreateExtension) Format(ctx *FmtCtx) {
// do not contain sensitive information and
// 2) we want to get telemetry on which extensions
// users attempt to load.
ctx.WriteString(node.Name)
ctx.WithFlags(ctx.flags&^FmtAnonymize, func() {
ctx.FormatNode(&node.Name)
})
}

// CreateExternalConnection represents a CREATE EXTERNAL CONNECTION statement.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/testdata/telemetry/extension
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ unimplemented.#54516.CREATE EXTENSION xml2
feature-usage
CREATE EXTENSION asdf
----
error: pq: unknown extension: "asdf"
error: pq: unknown extension: asdf