diff --git a/pkg/sql/create_extension.go b/pkg/sql/create_extension.go index a37dff64ed7c..5931a12d34b8 100644 --- a/pkg/sql/create_extension.go +++ b/pkg/sql/create_extension.go @@ -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, ) @@ -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", @@ -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 } diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index bfea0deaae59..842b9349d330 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -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 { diff --git a/pkg/sql/parser/testdata/create_misc b/pkg/sql/parser/testdata/create_misc index 05c2a13dcb12..f1b4983cfffc 100644 --- a/pkg/sql/parser/testdata/create_misc +++ b/pkg/sql/parser/testdata/create_misc @@ -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 ---- diff --git a/pkg/sql/sem/tree/create.go b/pkg/sql/sem/tree/create.go index 96b47bae7018..dacdea04f4ed 100644 --- a/pkg/sql/sem/tree/create.go +++ b/pkg/sql/sem/tree/create.go @@ -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 } @@ -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. diff --git a/pkg/sql/testdata/telemetry/extension b/pkg/sql/testdata/telemetry/extension index 7027f9bc2067..6b8b4317cad7 100644 --- a/pkg/sql/testdata/telemetry/extension +++ b/pkg/sql/testdata/telemetry/extension @@ -28,4 +28,4 @@ unimplemented.#54516.CREATE EXTENSION xml2 feature-usage CREATE EXTENSION asdf ---- -error: pq: unknown extension: "asdf" +error: pq: unknown extension: asdf