6.6. SQL Limitations #
- 6.6.1. ALTER SYSTEMLimitations
- 6.6.2.
ALTER TABLELimitations
- 6.6.3.
CREATE TABLELimitations
- 6.6.4.
DROP TABLELimitations
- 6.6.5.
CREATE INDEX CONCURRENTLYLimitations
- 6.6.6.
UPDATELimitations
- 6.6.7.
INSERT ON CONFLICT DO UPDATELimitations
- 6.6.8. Limitations of Managing Global Roles
- 6.6.9. Limitations of User Mappings
- 6.6.10.
ALTER SCHEMALimitations
- 6.6.11.
DROP SERVERLimitations
- 6.6.12. Limitations of Using Custom Databases
- 6.6.13.
CREATE COLLATIONLimitations
- 6.6.14. Logical Replication Limitations
- 6.6.15. Other Limitations
- 6.6.2.
To ensure consistency of a sharded database, Shardman imposes some restrictions on SQL commands executed.
6.6.1.  ALTER SYSTEM Limitations #
- ALTER SYSTEMis prohibited (configuration changes should be performed via- shardmanctl config update).
6.6.2. ALTER TABLE Limitations #
- ALTER TABLEis prohibited for partitions of sharded tables.
- All forms of - ALTER TABLEare prohibited for sharded or global tables except these:- ALTER TABLE OWNERis allowed. For sharded table it also changes the owner of table partitions. Only the global user can be an owner of sharded or global table.
- ALTER TABLE COLUMN TYPEis allowed with limitations. You cannot alter type of sharded table column participating in sharding or partitioning key. You cannot alter type of sharded table column with- USINGclause (but for global tables it is allowed). Also, it is a user's duty for now to create and keep new type exactly equal on every cluster node.
- ALTER TABLE COLUMN RENAMEis allowed.
- Adding or dropping table-wide unique constraints and checks is allowed. For global tables dropping primary key constraint or dropping columns, participating in primary key, is forbidden. 
- Adding foreign keys between sharded tables is possible only when they are colocated and a foreign key references tuples that are stored in the same replication group. A foreign key between sharded tables must begin with the columns used for table partitioning in both tables. A foreign key on a global table can reference only another global table. A foreign key on a sharded table can reference a colocated sharded table or a global table. 
- SET/- DROP NOT NULLis allowed.
- Setting storage options is allowed for global tables. 
- Global tables cannot inherit other tables. 
- ALTER COLUMN SET STATISTICSis allowed for global and sharded tables.
 
6.6.3. CREATE TABLE Limitations #
- For - CREATE TABLE, all limitations for- ALTER TABLEapply.
- Using of non-builtin types (types with OIDs >= 10000) or non-base types or arrays are not allowed in 'distributed_by' columns. 
- Only the global user can create sharded or global table. 
- In a colocated table, the number and types of columns used for table partitioning must be the same as for the table to colocate with. 
- A temporary table cannot be created as sharded or global. 
- Self-referencing sharded tables are allowed only if a foreign key is referencing the same partition of the sharded table. 
- For tables created using - LIKE- source_tablewhere- source_tableis a local table, the following limitations apply:- Copying without the - like_optionclause or with- INCLUDING INDEXESis only supported.
- With - INCLUDING INDEXES, only unique indexes and indexes supporting the primary relation key are copied.
- Copying indexes for columns is not supported. 
- EXCLUDEconstraints are not supported.
- Local tables used in - CREATE TABLE LIKEstatement must only have columns of base types.
- Partial indexes are not supported. 
- Standard collations are only supported. 
- NULLS NOT DISTINCTconstraint is not supported.
 
6.6.4. DROP TABLE Limitations #
- Sharded or global tables and local tables cannot be dropped in the same statement with - DROP TABLE.
- Partitions of a sharded table cannot be dropped. 
6.6.5. CREATE INDEX CONCURRENTLY Limitations #
- CREATE INDEX CONCURRENTLYis a non-transactional command. If a problem arises while building index on sharded or global tabe, such as network failure, deadlock or a uniqueness violation in a unique index, the- CREATE INDEX CONCURRENTLYwill partially fail, but can leave behind valid or invalid indexes on Shardman cluster nodes. Also an index can be completely missing on some nodes. In the later case- DROP INDEXwill fail to drop the index. The recommended way to remove such index cluster-wide is to use- DROP INDEX IF EXISTScommand. Note that- DROP INDEX CONCURRENTLYis not supported on sharded tables, so this operation should be better performed in a maintenance window.
6.6.6. UPDATE Limitations #
- UPDATEof a sharded table is executed as a series of usual UPDATEs if it doesn't move data between partitions or subpartitions. Otherwise it is executed internally as- DELETEfrom one partition and- INSERTinto another (so called target partition). If a partition where- UPDATEINSERTs data, is going to be UPDATED in the same statement, an error will be raised. In practice this means that if- UPDATEmoves data between partitions, you should explicitly exclude target partition from updating in- WHEREclause of the statement.
6.6.7. INSERT ON CONFLICT DO UPDATE Limitations #
- INSERT ON CONFLICT DO UPDATE- table_name... ON CONFLICT [conflict_target] conflict_action [WHERE condition]- DO UPDATE. For sharded tables it is supported if expressions in- SETand- WHEREclause can be safely deparsed (currently deparsing of sqlvalue-functions, parameters and subqueries inside these clauses is not supported) and a non-partial unique index, containing only table columns (not coulmn-based expressions), corresponds to conflict_target expression. This is usually the case with table's primary key.
6.6.8. Limitations of Managing Global Roles #
- Global users can be created only by user with - CREATEROLEpermission on all cluster nodes.
- Global roles cannot be renamed. 
- Global and local roles cannot be dropped in the same statement. 
- GRANTto a local and global role in the same statement is prohibited.
- REVOKEfrom a local and global role in the same statement is prohibited.
6.6.9. Limitations of User Mappings #
- The - CREATE USER MAPPING,- ALTER USER MAPPING, and- DROP USER MAPPINGcommands are prohibited when applied to mappings for foreign servers from the Shardman cluster. Use Shardman mechanisms of Managing Users and Roles instead.
6.6.10. ALTER SCHEMA Limitations #
- Schemas containing global or sharded tables cannot be renamed with - ALTER SCHEMA. Shardman service schemas (- shardman) cannot be renamed or dropped.
6.6.11. DROP SERVER Limitations #
- Shardman cluster servers cannot be dropped with - DROP SERVER. Use Shardman tools to remove servers from the cluster.
6.6.12. Limitations of Using Custom Databases #
- Custom databases are not supported. All the local custom databases can be corrupted or lost during the shardmanctl operations. 
6.6.13. CREATE COLLATION Limitations #
- If you use custom collation with - CREATE COLLATION, all servers must have same version of icu. Otherwise results of queries on sharded tables may be incorrect.
6.6.14. Logical Replication Limitations #
- If you attempt to publish a table containing foreign partitions with the - publish_via_partition_rootoption enabled, the operation will fail. Without this option, only the local partitions will be included in the publication.
- When using - FOR TABLES IN SCHEMAor- FOR ALL TABLES, only local partitions will be published.
- If you publish using - FOR TABLES IN SCHEMA WITHor- FOR ALL TABLESalong with the- publish_via_partition_rootoption, any tables with foreign partitions will be excluded from the publication. Adding foreign partitions to the tables included in publications with- publish_via_partition_rootwill also result in error.
- When executing - ALTER SUBSCRIPTION ... REFRESH PUBLICATION, depending on changes to table partitions, tables may be added to or removed from the publication.
- When using - FOR ALL TABLES, tables from the- shardmanschema are excluded from the publication. However, you can still create a publication specifically for tables in this schema or for individual tables within it.
6.6.15. Other Limitations #
- DROP TYPE CASCADEis prohibited if it affects types used in global or sharded tables.
- Access privileges management per columns is not supported for global tables.