if (db != NULL) {
slog_info(admin,
"registered new auto-database: %s", name);
- }
+ }
}
- return db;
+ return db;
}
/*
db = find_or_register_database(admin, arg);
if (db == NULL)
return admin_error(admin, "no such database: %s", arg);
- if (db == admin->pool->db)
+ if (db->admin)
return admin_error(admin, "cannot disable admin db: %s", arg);
db->db_disabled = 1;
db = find_database(arg);
if (db == NULL)
return admin_error(admin, "no such database: %s", arg);
- if (db == admin->pool->db)
+ if (db->admin)
return admin_error(admin, "cannot disable admin db: %s", arg);
db->db_disabled = 0;
}
}
+ /* are new connections allowed? */
+ if (db->db_disabled) {
+ disconnect_client(client, true, "database does not allow connections: %s", dbname);
+ return false;
+ }
+
/* find user */
if (cf_auth_type == AUTH_ANY) {
/* ignore requested user */
disconnect_client(client, true, "no memory for pool");
return false;
}
- if (client->pool->db->db_disabled) {
- disconnect_client(client, true, "pgbouncer database is disabled");
- return false;
- }
return check_fast_fail(client);
}
test `wc -l <$LOGDIR/test.tmp` -eq 50
}
+# test pause/resume
+test_enable_disable() {
+ rm -f $LOGDIR/test.tmp
+ psql -tAq p0 -c "select 'enabled 1'" >>$LOGDIR/test.tmp 2>&1
+
+ admin "disable p0"
+ psql -tAq p0 -c "select 'disabled 1'" >>$LOGDIR/test.tmp 2>&1
+ admin "enable p0"
+ psql -tAq p0 -c "select 'enabled 2'" >>$LOGDIR/test.tmp 2>&1
+
+ grep -q "enabled 1" $LOGDIR/test.tmp || return 1
+ grep -q "enabled 2" $LOGDIR/test.tmp || return 1
+ grep -q "disabled 1" $LOGDIR/test.tmp && return 1
+ grep -q "does not allow" $LOGDIR/test.tmp || return 1
+ return 0
+}
+
# test pool database restart
test_database_restart() {
admin "set server_login_retry=1"
test_online_restart
test_pause_resume
test_suspend_resume
+test_enable_disable
test_database_restart
test_database_change
"