This commit is contained in:
Neil Alexander 2022-11-08 15:01:55 +00:00
parent 40122b5423
commit d9ab350ecf
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 1 additions and 9 deletions

View file

@ -28,7 +28,7 @@ var serverNamesTables = []string{
func UpServerNames(ctx context.Context, tx *sql.Tx, serverName gomatrixserverlib.ServerName) error {
for _, table := range serverNamesTables {
q := fmt.Sprintf(
"SELECT name FROM sqlite_schema WHERE type='table' AND name=%s;",
"SELECT COUNT(name) FROM sqlite_schema WHERE type='table' AND name=%s;",
pq.QuoteIdentifier(table),
)
var c int

View file

@ -17,14 +17,6 @@ import (
func UpServerNamesPopulate(ctx context.Context, tx *sql.Tx, serverName gomatrixserverlib.ServerName) error {
for _, table := range serverNamesTables {
q := fmt.Sprintf(
"SELECT name FROM sqlite_schema WHERE type='table' AND name=%s;",
pq.QuoteIdentifier(table),
)
var c int
if err := tx.QueryRowContext(ctx, q).Scan(&c); err != nil || c == 0 {
continue
}
q = fmt.Sprintf(
"UPDATE %s SET server_name = %s WHERE server_name = '';",
pq.QuoteIdentifier(table), pq.QuoteLiteral(string(serverName)),
)