Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Disallow modifying template databases #1106

Closed
m-iancu opened this issue Apr 2, 2019 · 0 comments
Closed

[YSQL] Disallow modifying template databases #1106

m-iancu opened this issue Apr 2, 2019 · 0 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL)
Projects

Comments

@m-iancu
Copy link
Contributor

m-iancu commented Apr 2, 2019

We currently do not support creating user tables in template1 and template0. Specifically because our internal copydb during CREATE DATABASE will only copy the system catalogs. It will not will not duplicate the tablets for any user tables and therefore might leave that database in an inconsistent state.

We should disable create tables or indexes in template databases. Other things (that do not require storage) such as (non-materialized) views might work, but it's better to disable every DDL (except for initdb mode) for now.

@m-iancu m-iancu changed the title Disallow creating tables in template databases [YSQL] Disallow creating tables in template databases Apr 2, 2019
@m-iancu m-iancu changed the title [YSQL] Disallow creating tables in template databases [YSQL] Disallow creating user tables in template databases Apr 2, 2019
@ndeodhar ndeodhar added the area/ysql Yugabyte SQL (YSQL) label Apr 2, 2019
@m-iancu m-iancu changed the title [YSQL] Disallow creating user tables in template databases [YSQL] Disallow modifying template databases Apr 2, 2019
yugabyte-ci pushed a commit that referenced this issue Apr 9, 2019
…template databases

Summary:
1. Earlier "unsupported feature" error was shown in case YB_ENABLED_IN_POSTGRES=1 and current DB
is not template0/template1. It was possible to connect to template0/template1 DB and call any unsupported feature (like VACUUM, DROP DATABASE etc).

Now name of current DB is ignored. All features allowed only in "initdb" mode (by checking YB_PG_INITDB_MODE env variable)

2. The following functions are restricted when user connected to template0/template1 database:
    - CREATE TABLE
    - CREATE SEQUENCE

Test Plan:
Unit tests are added

yb_build.sh --java-test org.yb.pgsql.TestPgMisc

Reviewers: neil, mihnea, neha

Reviewed By: neha

Subscribers: neha, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D6430
@m-iancu m-iancu added this to To do in YSQL via automation Apr 15, 2019
@m-iancu m-iancu moved this from To do to Done in YSQL Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL)
Projects
YSQL
  
Done
Development

No branches or pull requests

3 participants