GoogleCloudPlatform / GoogleCloudPlatform/cloud-spanner-emulator
Roles metadata is missing
- Dominant language
- C++
- Stars
- 334
- Forks
- 77
- Avg merge
- 8m
- Merged PRs (30d)
- 2
Description
Hi Spanner team, I hit this with the emulator while testing database roles.
## Summary
The emulator accepts `CREATE ROLE`, but the role does not show up in role metadata. Real Spanner shows the same role in `GetDatabaseDdl`, `INFORMATION_SCHEMA.ROLES`, and `databaseRoles.list`.
## Environment
- Emulator version: 1.5.53
## Repro
```sh
SPANNER_EMULATOR_HOST=localhost:9010 \
gcloud spanner databases create db \
--instance=test-instance \
--project=my-project
SPANNER_EMULATOR_HOST=localhost:9010 \
gcloud spanner databases ddl update db \
--instance=test-instance \
--project=my-project \
--ddl='CREATE ROLE my-super-role'
SPANNER_EMULATOR_HOST=localhost:9010 \
gcloud spanner databases ddl update db \
--instance=test-instance \
--project=my-project \
--ddl='CREATE SCHEMA s'
Schema updating...
.....done.
```
## Actual
`GetDatabaseDdl` shows the schema but not the role:
```sh
SPANNER_EMULATOR_HOST=localhost:9010 \
gcloud spanner databases ddl describe db \
--instance=test-instance \
--project=my-project
```
```sql
CREATE SCHEMA s;
```
`databaseRoles.list` returns 501:
```sh
SPANNER_EMULATOR_HOST=localhost:9010 \
gcloud spanner databases roles list \
--instance=test-instance \
--database=db \
--project=my-project \
--format=json
```
```text
status: 501
content: {"code":12}
```
`INFORMATION_SCHEMA.ROLES` returns 500:
```sh
SPANNER_EMULATOR_HOST=localhost:9010 \
gcloud spanner databases execute-sql db \
--instance=test-instance \
--project=my-project \
--sql='SELECT ROLE_NAME FROM INFORMATION_SCHEMA.ROLES ORDER BY ROLE_NAME' \
--format=json
```
```text
status: 500
content: {"code": 13, "message": "failed to marshal error message"}
```
```sh
SPANNER_EMULATOR_HOST=localhost:9010 \
gcloud spanner databases execute-sql db \
--instance=test-instance \
--project=my-project \
--sql='SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA' \
--format=json
```
```json
{
"rows": [
[""],
["INFORMATION_SCHEMA"],
["SPANNER_SYS"],
["s"]
]
}
```
## Expected
After `CREATE ROLE my-super-role` succeeds, `my-super-role` should be visible through the same metadata surfaces as real Spanner:
- `GetDatabaseDdl`
- `INFORMATION_SCHEMA.ROLES`
- `databaseRoles.list`
Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.