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] Enable support for ALTER TABLE .. SET SCHEMA commands #23114

Closed
1 task done
OlegLoginov opened this issue Jul 3, 2024 · 3 comments
Closed
1 task done

[YSQL] Enable support for ALTER TABLE .. SET SCHEMA commands #23114

OlegLoginov opened this issue Jul 3, 2024 · 3 comments
Assignees
Labels
2024.1 Backport Required area/ysql Yugabyte SQL (YSQL) kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue

Comments

@OlegLoginov
Copy link
Contributor

OlegLoginov commented Jul 3, 2024

Jira Link: DB-12047

Description

ALTER TABLE relation_expr SET SCHEMA name
ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name

Issue Type

kind/enhancement

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@OlegLoginov OlegLoginov added the area/ysql Yugabyte SQL (YSQL) label Jul 3, 2024
@OlegLoginov OlegLoginov self-assigned this Jul 3, 2024
@yugabyte-ci yugabyte-ci added kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue labels Jul 3, 2024
OlegLoginov added a commit that referenced this issue Aug 6, 2024
Summary:
The diff implements the syntax:
* `ALTER TABLE t SET SCHEMA s`
* `ALTER TABLE IF EXISTS t SET SCHEMA s`
PG side:
* Fixed `AlterObjectSchemaStmt` handling in the grammar.
* Updated `AlterRelationNamespaceInternal` handler.
* New function `YBCAlterTableNamespace`.
YB side:
* New `YBCPgAlterTableSetSchema` function.
* New `PgApiImpl::AlterTableSetSchema` wrapper.
* New `PgAlterTable::SetSchema` method.
* Added `string schema_name` into `PgRenameTablePB` proto-buffer.
* Updated `YBTableAlterer::ToRequest`.
* Updated `CatalogManager::AlterTable`.
* Added `YBTableName::YBTableName(YQLDatabase db_type)` constructor.

**Upgrade/Rollback safety:**
The changed `PgRenameTablePB` is only used for communications between
PG & TS processes. The processes should be always in sync, so the change
does not need `AutoFlag` or any other special handling for the upgrade safety.

Jira: DB-12047

Test Plan:
Updated tests for SET SCHEMA:
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressTable#testPgRegressTable
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressMisc#testPgRegressMiscSerial
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgaudit#schedule

New C++ tests for SET SCHEMA:
./yb_build.sh --cxx-test pg_mini-test --gtest_filter PgMiniTest.AlterTableSetSchema
./yb_build.sh --cxx-test pg_mini-test --gtest_filter PgMiniTest.AlterPartitionedTableSetSchema

Other related tests:
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressMatview#testPgRegressMatview

Reviewers: mihnea, fizaa, myang, xCluster, hsunder

Reviewed By: myang

Subscribers: jason, ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D36474
OlegLoginov added a commit that referenced this issue Aug 8, 2024
Summary:
The test file `yb_pg_pgaudit.out` was changed in the previous fix - 34f9741 / D36474.
The test change was not good - it incremented the audit numbers.
This corrective diff changes `yb_pg_pgaudit.sql` to return back the `audit numbers`.

Jira: DB-12047

Test Plan: ./yb_build.sh --java-test org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgaudit#schedule

Reviewers: jason, mihnea, myang

Reviewed By: jason

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D37150
@OlegLoginov
Copy link
Contributor Author

Fixed in the master branch.
(Let me know if we need any backports. Backports are not planned for now.)

@OlegLoginov
Copy link
Contributor Author

OlegLoginov commented Aug 9, 2024

NOTE: the next commit breaks the functionality by mistake:
3d4bc2a#diff-f8d636ae673f702b8477da50fe7f6b8cdc9c5ad10d54a6e10bbcc0ce1eb1c51eL10063-R10074

See: #23457
Fix: [#23457] YSQL: Revert bad grammar changes
Diff: D37210

jasonyb pushed a commit that referenced this issue Aug 9, 2024
Summary:
 a2dfb8c [PLAT-14119][PLAT-14591][PLAT-14824][PLAT-14849][PLAT-14725][PLAT-14747] : Audit Log and PG Compatibility fixes and improvements
 927a0f9 [DOC-435] Split supported versus unsupported OSs into two tables. (#23372)
 ef62972 [PLAT-14034][PLAT-14762] Support TLS for db scoped replication
 Excluded: 34f9741 [#23114] YSQL: Implement ALTER TABLE.. SET SCHEMA..
 15149f2 [#23401] YSQL: Graceful error if syscache is accessed in DocDB
 b4fd3fc [PLAT-14822] [Retryability]fault injection tests for smartResize are failing
 e0629f3 [#23404] docdb: Fix test PgsqlAddColumnCompactWithPackedRow failing on ASAN
 1d1780c [#23414] xCluster: Convert enable_xcluster_api_v2 to an AutoFlag
 95317f9 [PLAT-13373] Use latest YBC for universe tasks that install YBC
 Excluded: 44486bc [#20997] YSQL, ASH: New wait event for the ASH collector
 dc04092 [Docs] Small Improvements (#23395)
 manually excluded: 9df2d82 [#15665] YSQL: Trigger ANALYZE of PG auto analyze service
 7c338c3 [PLAT-14839]rename v2 group mapping models and add creation time
 de504ed [#21510] YSQL: Fix the unit test testSeekNextEstimationIndexScan which is failing during Connection Manager
 4cb5e0d [PLAT-14861][PLAT-14862] - fix : Disaster recovery ui issues
 de8a50a [PLAT-14247]Support restore to Point in time part 1 - Universe changes with schedule creation/edit/delete
 128afe7 [#21202] YSQL: Merge Connection Manager logs with Java UT logs
 4b479fa [PLAT-13843] Upgrade requests library

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37134
jasonyb pushed a commit that referenced this issue Aug 9, 2024
Summary:
 43d4b49 [PLAT-14771]: Restrict user actions on releases page based on appropriate RBAC permissions
 1473a23 [PLAT-14792]: Master and TServer nodes displays empty tool tip if nodes are unreachable
 Excluded: 78a2bc7 [#23114] YSQL: Refactoring the yb_pg_pgaudit.sql/.out test.
 da9b281 [doc][ybm] Prometheus integration (#23292)
 bd4874b [#13358] YSQL: Fix DDL atomicity stress test failure in tsan build
 edd8e3f [PLAT-14524] Undo all @JsonProperty annotations added earlier to fix APIs
 Excluded: 4a2657e [PLAT-14787] Implement a master tablet lb api for YW
 b9d2e9d [#23445]yugabyted: Node not starting with DNS name and `--secure` option
 f171e13 [#23447]yugabyted: Node doesn't restart with `--secure` enabled
 d4f036d [PLAT-14790] Region metadata is not populated when provisioned nodes are added via Node Agent when using assisted Manual Provisioning (provision_instance.py script)
 71ab66f [doc][ybm] Backup and restore clarifications (#23400)
 4768023 [doc] ysql_yb_bnl_batch_size flag (#23397)
 3d4bc2a [#23117] YSQL: Enable ALTER VIEW in parser
 Excluded: 03bbbed Bumping version to 2.23.1.0 on branch master
 622046d [#23335] DocDB: Set field close timestamp for the log segment being copied
 Excluded: f69b08f [#1999] YSQL: fix temp table INSERT ON CONFLICT
 Excluded: efd4cb7 [#23429] YSQL: fix INSERT ON CONFLICT TupleDesc ref leak
 Excluded: 9e7181f [PLAT-14785] Add REST APIs for job scheduler (auto-master failover)
 d56903c [PLAT-14850]API Token authentication loops through the users and checks token against each of these.

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37201
jasonyb pushed a commit that referenced this issue Aug 13, 2024
… SCHEMA..

Summary:
Original commits:
- 34f9741 / D36474
- 78a2bc7 / D37150

Merge:

- yb_pg_pgaudit.out:
  - AUDIT: SESSION,39: YB pg15 180a1f7
    changes "SELECT 'yb'" to CREATE TABLE workaround.  YB master
    34f9741 and
    78a2bc7 remove the workaround.
    Remove the workaround.
  - AUDIT: SESSION,42: (same: YB pg15 comments that the output is
    different, but the output is no longer different after YB master
    fixes things).
  - AUDIT: SESSION,97: YB pg15 180a1f7
    adds workaround that is no longer needed thanks to YB master
    34f9741: remove.
  - second AUDIT: SESSION,94: (same)
- yb_pg_pgaudit.sql: (same as above)
- yb_schema.out:
  - \d+ S2.P_TBL: adjust output according to upstream PG d56e0fde828b95497ce9acfb4ce18bab64803c82.

---

The diff implements the syntax:
* `ALTER TABLE t SET SCHEMA s`
* `ALTER TABLE IF EXISTS t SET SCHEMA s`
PG side:
* Fixed `AlterObjectSchemaStmt` handling in the grammar.
* Updated `AlterRelationNamespaceInternal` handler.
* New function `YBCAlterTableNamespace`.
YB side:
* New `YBCPgAlterTableSetSchema` function.
* New `PgApiImpl::AlterTableSetSchema` wrapper.
* New `PgAlterTable::SetSchema` method.
* Added `string schema_name` into `PgRenameTablePB` proto-buffer.
* Updated `YBTableAlterer::ToRequest`.
* Updated `CatalogManager::AlterTable`.
* Added `YBTableName::YBTableName(YQLDatabase db_type)` constructor.

**Upgrade/Rollback safety:**
The changed `PgRenameTablePB` is only used for communications between
PG & TS processes. The processes should be always in sync, so the change
does not need `AutoFlag` or any other special handling for the upgrade safety.

Jira: DB-12047

Test Plan:
Updated tests for SET SCHEMA:
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressTable#testPgRegressTable
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressMisc#testPgRegressMiscSerial
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgaudit#schedule

New C++ tests for SET SCHEMA:
./yb_build.sh --cxx-test pg_mini-test --gtest_filter PgMiniTest.AlterTableSetSchema
./yb_build.sh --cxx-test pg_mini-test --gtest_filter PgMiniTest.AlterPartitionedTableSetSchema

Other related tests:
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressMatview#testPgRegressMatview

Jenkins: rebase: pg15-cherrypicks

Reviewers: loginov

Reviewed By: loginov

Subscribers: yql, ybase, jason

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37149
@sushantrmishra
Copy link

Reopening the issues to complete the backport for 2024.1

OlegLoginov added a commit that referenced this issue Aug 25, 2024
Summary:
Original diff: 34f9741 / D36474
Original commit: 34f9741

The diff implements the syntax:
* `ALTER TABLE t SET SCHEMA s`
* `ALTER TABLE IF EXISTS t SET SCHEMA s`
PG side:
* Fixed `AlterObjectSchemaStmt` handling in the grammar.
* Updated `AlterRelationNamespaceInternal` handler.
* New function `YBCAlterTableNamespace`.
YB side:
* New `YBCPgAlterTableSetSchema` function.
* New `PgApiImpl::AlterTableSetSchema` wrapper.
* New `PgAlterTable::SetSchema` method.
* Added `string schema_name` into `PgRenameTablePB` proto-buffer.
* Updated `YBTableAlterer::ToRequest`.
* Updated `CatalogManager::AlterTable`.
* Added `YBTableName::YBTableName(YQLDatabase db_type)` constructor.

**Upgrade/Rollback safety:**
The changed `PgRenameTablePB` is only used for communications between
PG & TS processes. The processes should be always in sync, so the change
does not need `AutoFlag` or any other special handling for the upgrade safety.

Jira: DB-12047

Test Plan:
Updated tests for SET SCHEMA:
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressTable#testPgRegressTable
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressMisc#testPgRegressMiscSerial
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgaudit#schedule

New C++ tests for SET SCHEMA:
./yb_build.sh --cxx-test pg_mini-test --gtest_filter PgMiniTest.AlterTableSetSchema
./yb_build.sh --cxx-test pg_mini-test --gtest_filter PgMiniTest.AlterPartitionedTableSetSchema

Other related tests:
./yb_build.sh --java-test org.yb.pgsql.TestPgRegressMatview#testPgRegressMatview

Reviewers: mihnea, fizaa, myang, xCluster, hsunder

Reviewed By: myang

Subscribers: yql, ybase, jason

Differential Revision: https://phorge.dev.yugabyte.com/D37478
OlegLoginov added a commit that referenced this issue Aug 27, 2024
…t test.

Summary:
Original commit: 78a2bc7 / D37150

The test file `yb_pg_pgaudit.out` was changed in the previous fix - 34f9741 / D36474.
The test change was not good - it incremented the audit numbers.
This corrective diff changes `yb_pg_pgaudit.sql` to return back the `audit numbers`.

Jira: DB-12047

Test Plan: ./yb_build.sh --java-test org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgaudit#schedule

Reviewers: jason, mihnea, myang

Reviewed By: myang

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D37517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2024.1 Backport Required area/ysql Yugabyte SQL (YSQL) kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue
Projects
None yet
Development

No branches or pull requests

3 participants