Skip to content

Configurable database name regexp #667

Open
@afterlook

Description

@afterlook

databaseNameRegexp = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$")
postgres-operator/pkg/cluster/cluster.go
Is there some kind of reason why this regex looks as it is?

The pattern seems to follow this from the documentation (not to the dot):

SQL identifiers and key words 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 ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard.

But as long as the name is quoted in SQL statement, we should be able to put whatever we like with the exception of \0.
I have this issue that I have to migrate postgres to k8s, but all our databases are named in the following fashion: [a-z]+-[a-z]+.

I'm not very familiar with the operator's code, but if quoted identifiers are used everywhere, then I don't see any reason why the regex shouldn't be expanded.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions