-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Add syntax documentation for logical replication (#23270)
* Add syntax documentation for logical replication * Fix missing semicolon in drop_replication_slot * Fix the description of USE_SNAPSHOT * Improve language of assumptions in examples. Co-authored-by: Dwight Hodge <[email protected]> * Fix grammar in create publication example. Co-authored-by: Dwight Hodge <[email protected]> * Fix grammar in alter publication Co-authored-by: Dwight Hodge <[email protected]> * Improve grammar of SET table in alter publication Co-authored-by: Dwight Hodge <[email protected]> * Improve grammar in limitation of create publication Co-authored-by: Dwight Hodge <[email protected]> * Update docs/content/preview/api/ysql/the-sql-language/statements/streaming_drop_repl_slot.md Co-authored-by: Dwight Hodge <[email protected]> * Update docs/content/preview/api/ysql/the-sql-language/statements/ddl_drop_publication.md Co-authored-by: Dwight Hodge <[email protected]> * Update docs/content/preview/api/ysql/the-sql-language/statements/ddl_create_publication.md Co-authored-by: Dwight Hodge <[email protected]> * Update docs/content/preview/api/ysql/the-sql-language/statements/ddl_create_publication.md Co-authored-by: Dwight Hodge <[email protected]> * Describe the start replication example * Include a full example in the start_replication case --------- Co-authored-by: Dwight Hodge <[email protected]>
- Loading branch information
Showing
8 changed files
with
452 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
docs/content/preview/api/ysql/the-sql-language/statements/ddl_alter_publication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
title: ALTER PUBLICATION statement [YSQL] | ||
headerTitle: ALTER PUBLICATION | ||
linkTitle: ALTER PUBLICATION | ||
description: Change properties of an existing publication. | ||
menu: | ||
preview: | ||
identifier: ddl_alter_publication | ||
parent: statements | ||
type: docs | ||
--- | ||
|
||
## Synopsis | ||
|
||
Use the `ALTER PUBLICATION` statement to change properties of an existing publication. | ||
|
||
## Syntax | ||
|
||
{{%ebnf%}} | ||
alter_publication, | ||
alter_publication_action | ||
{{%/ebnf%}} | ||
|
||
## Semantics | ||
|
||
### *alter_publication_action* | ||
|
||
Specify one of the following actions. | ||
|
||
#### ADD TABLE *table_name { ',' table_name }* | ||
|
||
Add the specified tables to the publication. | ||
|
||
#### SET TABLE *table_name { ',' table_name }* | ||
|
||
Replace the list of tables/schemas in the publication with the specified list. The existing tables/schemas that were present in the publication will be removed. | ||
|
||
#### DROP TABLE *table_name { ',' table_name }* | ||
|
||
Remove the specified tables from the publication. | ||
|
||
#### RENAME TO *publication_name* | ||
|
||
Rename the publication name to the specified name. | ||
|
||
#### OWNER TO *new_owner* | ||
|
||
Change the owner of the publication to the *new_owner*. | ||
|
||
### Permissions | ||
|
||
To alter a publication, the invoking user must own the publication. Adding a table to a publication additionally requires owning that table. To alter the owner, you must also be a direct or indirect member of the new owning role. The new owner must have `CREATE` privilege on the database. Also, the new owner of a `FOR ALL TABLES` publication must be a superuser. However, a superuser can change the ownership of a publication regardless of these restrictions. | ||
|
||
## Examples | ||
|
||
Assume that you have created the tables `users`, `departments`, and `employees`. | ||
|
||
To create a publication `my_publication`, use the following command: | ||
|
||
```sql | ||
yugabyte=# CREATE PUBLICATION my_publication FOR TABLE employees; | ||
``` | ||
|
||
Add the `users` and `departments` tables to the publication `my_publication`: | ||
|
||
```sql | ||
yugabyte=# ALTER PUBLICATION my_publication ADD TABLE users, departments; | ||
``` | ||
|
||
Drop the `employees` table from the publication `my_publication`: | ||
|
||
```sql | ||
yugabyte=# ALTER PUBLICATION my_publication DROP TABLE employees; | ||
``` | ||
|
||
Set the `departments` table to be the only table in the publication `my_publication`. The table `users` will be removed from the publication as a result of the command. | ||
|
||
```sql | ||
yugabyte=# ALTER PUBLICATION my_publication SET TABLE departments; | ||
``` | ||
|
||
Rename the publication `my_publication` to `renamed_publication`. | ||
|
||
```sql | ||
yugabyte=# ALTER PUBLICATION my_publication RENAME TO renamed_publication; | ||
``` | ||
|
||
## See also | ||
|
||
- [`CREATE PUBLICATION`](../ddl_create_publication) | ||
- [`DROP PUBLICATION`](../ddl_drop_publication) |
81 changes: 81 additions & 0 deletions
81
.../content/preview/api/ysql/the-sql-language/statements/ddl_create_publication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
title: CREATE PUBLICATION [YSQL] | ||
headerTitle: CREATE PUBLICATION | ||
linkTitle: CREATE PUBLICATION | ||
description: Use the CREATE PUBLICATION statement to create a publication in a database. | ||
menu: | ||
preview: | ||
identifier: ddl_create_publication | ||
parent: statements | ||
type: docs | ||
--- | ||
|
||
## Synopsis | ||
|
||
Use the `CREATE PUBLICATION` statement to create a publication in a database. A publication is a set of changes generated from a table or a group of tables, and might also be described as a change set or replication set. It defines the publication name and the tables included in it. | ||
|
||
## Syntax | ||
|
||
{{%ebnf%}} | ||
create_publication, | ||
publication_for_option | ||
{{%/ebnf%}} | ||
|
||
## Semantics | ||
|
||
Create a publication with *publication_name*. If `publication_name` already exists in the specified database, an error will be raised. | ||
|
||
### Tables | ||
|
||
The `FOR TABLE` option specifies a list of tables to add to the publication while the `FOR ALL TABLES` option marks the publication as one that replicates changes for all tables in the database, including tables created in the future. | ||
|
||
If `FOR TABLE` or `FOR ALL TABLES` are not specified, then the publication starts out with an empty set of tables. This is useful if tables are to be added later. | ||
|
||
### Permissions | ||
|
||
To create a publication, the invoking user must have the `CREATE` privilege for the current database. (Superusers bypass this check.) | ||
|
||
To add a table to a publication, the invoking user must have ownership rights on the table. The `FOR ALL TABLES` clause requires the invoking user to be a **superuser**. | ||
|
||
### Limitations | ||
|
||
Publishing a subset of operations (create, update, delete, truncate) via a Publication is not currently supported. | ||
|
||
## Examples | ||
|
||
### Publication with two tables | ||
|
||
```sql | ||
yugabyte=# CREATE PUBLICATION mypublication FOR TABLE users, departments; | ||
``` | ||
|
||
In this example, the publication `mypublication` consists of two tables, `users` and `departments`. | ||
|
||
```sql{.nocopy} | ||
yugabyte=# select * from pg_publication; | ||
pubname | pubowner | puballtables | pubinsert | pubupdate | pubdelete | pubtruncate | ||
---------------+----------+--------------+-----------+-----------+-----------+------------- | ||
mypublication | 13250 | f | t | t | t | t | ||
(1 row) | ||
``` | ||
|
||
### Publication for all tables | ||
|
||
```sql | ||
yugabyte=# CREATE PUBLICATION puballtables FOR ALL TABLES; | ||
``` | ||
|
||
In this example, the publication `puballtables` includes all the current as well as future tables. | ||
|
||
```sql{.nocopy} | ||
yugabyte=# select * from pg_publication; | ||
pubname | pubowner | puballtables | pubinsert | pubupdate | pubdelete | pubtruncate | ||
---------------+----------+--------------+-----------+-----------+-----------+------------- | ||
puballtables | 13250 | t | t | t | t | t | ||
(1 row) | ||
``` | ||
|
||
## See also | ||
|
||
- [`ALTER PUBLICATION`](../ddl_alter_publication) | ||
- [`DROP PUBLICATION`](../ddl_drop_publication) |
48 changes: 48 additions & 0 deletions
48
docs/content/preview/api/ysql/the-sql-language/statements/ddl_drop_publication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: DROP PUBLICATION statement [YSQL] | ||
headerTitle: DROP PUBLICATION | ||
linkTitle: DROP PUBLICATION | ||
description: Use the DROP PUBLICATION statement to remove a publication from a database. | ||
menu: | ||
preview: | ||
identifier: ddl_drop_publication | ||
parent: statements | ||
aliases: | ||
- /preview/api/ysql/commands/ddl_drop_publication/ | ||
type: docs | ||
--- | ||
|
||
## Synopsis | ||
|
||
Use the `DROP PUBLICATION` statement to remove a publication from a database. | ||
|
||
## Syntax | ||
|
||
{{%ebnf%}} | ||
drop_publication, | ||
{{%/ebnf%}} | ||
|
||
## Semantics | ||
|
||
Drop a publication named *publication_name*. If `publication_name` doesn't exist in the specified database, an error will be raised unless the `IF EXISTS` clause is used. | ||
|
||
### RESTRICT / CASCADE | ||
|
||
These key words do not have any effect, since there are no dependencies on publications. | ||
|
||
### Permissions | ||
|
||
A publication can only be dropped by its owner or a superuser. | ||
|
||
## Examples | ||
|
||
Basic example. | ||
|
||
```sql | ||
yugabyte=# DROP PUBLICATION mypublication; | ||
``` | ||
|
||
## See also | ||
|
||
- [`CREATE PUBLICATION`](../ddl_create_publication) | ||
- [`ALTER PUBLICATION`](../ddl_alter_publication) |
Oops, something went wrong.