mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 10:33:27 +08:00
Block renaming of hypertables
This commit is contained in:
parent
5e44e996f4
commit
549b69ea81
@ -744,7 +744,8 @@ prev_ProcessUtility(Node *parsetree,
|
||||
|
||||
}
|
||||
|
||||
/* Hook-intercept for ProcessUtility. Used to make COPY use a temp copy table. */
|
||||
/* Hook-intercept for ProcessUtility. Used to make COPY use a temp copy table and */
|
||||
/* blocking renaming of hypertables. */
|
||||
void iobeamdb_ProcessUtility(Node *parsetree,
|
||||
const char *queryString,
|
||||
ProcessUtilityContext context,
|
||||
@ -752,7 +753,13 @@ void iobeamdb_ProcessUtility(Node *parsetree,
|
||||
DestReceiver *dest,
|
||||
char *completionTag)
|
||||
{
|
||||
if (IobeamLoaded() && IsA(parsetree, CopyStmt))
|
||||
|
||||
if (!IobeamLoaded()){
|
||||
prev_ProcessUtility(parsetree, queryString, context, params, dest, completionTag);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsA(parsetree, CopyStmt))
|
||||
{
|
||||
CopyStmt *copystmt = (CopyStmt *) parsetree;
|
||||
Oid relId = RangeVarGetRelid(copystmt->relation, NoLock, true);
|
||||
@ -764,9 +771,24 @@ void iobeamdb_ProcessUtility(Node *parsetree,
|
||||
}
|
||||
}
|
||||
prev_ProcessUtility((Node *)copystmt, queryString, context, params, dest, completionTag);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
/* We don't support renaming hypertables yet so we need to block it */
|
||||
if (IsA(parsetree, RenameStmt))
|
||||
{
|
||||
prev_ProcessUtility(parsetree, queryString, context, params, dest, completionTag);
|
||||
RenameStmt *renamestmt = (RenameStmt *) parsetree;
|
||||
Oid relId = RangeVarGetRelid(renamestmt->relation, NoLock, true);
|
||||
if (OidIsValid(relId)) {
|
||||
hypertable_info* hinfo = get_hypertable_info(relId);
|
||||
if (hinfo != NULL && renamestmt->renameType == OBJECT_TABLE)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("Renaming hypertables is not yet supported")));
|
||||
}
|
||||
prev_ProcessUtility((Node *)renamestmt, queryString, context, params, dest, completionTag);
|
||||
return;
|
||||
}
|
||||
|
||||
prev_ProcessUtility(parsetree, queryString, context, params, dest, completionTag);
|
||||
}
|
||||
|
@ -125,6 +125,19 @@ Child tables: _iobeamdb_internal._hyper_2_2_0_3_data,
|
||||
device_id | text | | extended | |
|
||||
Child tables: _iobeamdb_internal._hyper_2_0_replica
|
||||
|
||||
-- Test that renaming hypertable is blocked
|
||||
\set ON_ERROR_STOP 0
|
||||
ALTER TABLE "testNs" RENAME TO "newname";
|
||||
ERROR: Renaming hypertables is not yet supported
|
||||
\set ON_ERROR_STOP 1
|
||||
-- Test that renaming ordinary table works
|
||||
CREATE TABLE renametable (foo int);
|
||||
ALTER TABLE "renametable" RENAME TO "newname";
|
||||
SELECT * FROM "newname";
|
||||
foo
|
||||
-----
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM _iobeamdb_catalog.hypertable;
|
||||
id | schema_name | table_name | associated_schema_name | associated_table_prefix | root_schema_name | root_table_name | replication_factor | placement | time_column_name | time_column_type | created_on | chunk_size_bytes
|
||||
----+-------------+--------------------+------------------------+-------------------------+--------------------+-----------------+--------------------+-----------+------------------+------------------+------------+------------------
|
||||
@ -159,7 +172,8 @@ SELECT * FROM _iobeamdb_catalog.hypertable;
|
||||
Schema | Name | Type | Owner
|
||||
--------+--------------------+-------+----------
|
||||
public | chunk_closing_test | table | postgres
|
||||
(1 row)
|
||||
public | newname | table | postgres
|
||||
(2 rows)
|
||||
|
||||
\dt "_iobeamdb_catalog".*
|
||||
List of relations
|
@ -1,16 +0,0 @@
|
||||
\set ON_ERROR_STOP 1
|
||||
\o /dev/null
|
||||
\ir include/insert_single.sql
|
||||
\o
|
||||
\set ECHO ALL
|
||||
|
||||
\c single
|
||||
\d+ "_iobeamdb_internal".*
|
||||
|
||||
SELECT * FROM _iobeamdb_catalog.hypertable;
|
||||
DROP TABLE "testNs";
|
||||
|
||||
SELECT * FROM _iobeamdb_catalog.hypertable;
|
||||
\dt "public".*
|
||||
\dt "_iobeamdb_catalog".*
|
||||
\dt+ "_iobeamdb_internal".*
|
Loading…
x
Reference in New Issue
Block a user