mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 19:13:16 +08:00
Use table_open/close and PG aggregated directive
Fixing more places to use table_open and table_close introduced in PG12. Unifies PG version directives to use aggregated macro.
This commit is contained in:
parent
b27e883edd
commit
ed32d093dc
@ -21,7 +21,7 @@
|
||||
|
||||
#include <catalog/pg_constraint.h>
|
||||
#include "compat.h"
|
||||
#if PG96 || PG10 /* PG11 consolidates pg_foo_fn.h -> pg_foo.h */
|
||||
#if PG11_LT /* PG11 consolidates pg_foo_fn.h -> pg_foo.h */
|
||||
#include <catalog/pg_constraint_fn.h>
|
||||
#endif
|
||||
|
||||
|
@ -131,7 +131,7 @@ chunk_adjust_colref_attnos(IndexInfo *ii, Relation idxrel, Relation chunkrel)
|
||||
|
||||
if (attno == InvalidAttrNumber)
|
||||
elog(ERROR, "index attribute %s not found in chunk", NameStr(idxattr->attname));
|
||||
#if PG96 || PG10
|
||||
#if PG11_LT
|
||||
ii->ii_KeyAttrNumbers[i] = attno;
|
||||
#else
|
||||
ii->ii_IndexAttrNumbers[i] = attno;
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <catalog/pg_type.h>
|
||||
#include <parser/parse_func.h>
|
||||
#include "compat.h"
|
||||
#if PG96 || PG10 /* PG11 consolidates pg_foo_fn.h -> pg_foo.h */
|
||||
#if PG11_LT /* PG11 consolidates pg_foo_fn.h -> pg_foo.h */
|
||||
#include <catalog/pg_inherits_fn.h>
|
||||
#include <catalog/pg_constraint_fn.h>
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "hypertable_cache.h"
|
||||
#include "partitioning.h"
|
||||
|
||||
#if PG96 || PG10 /* PG11 consolidates pg_foo_fn.h -> pg_foo.h */
|
||||
#if PG11_LT /* PG11 consolidates pg_foo_fn.h -> pg_foo.h */
|
||||
#include <catalog/pg_inherits_fn.h>
|
||||
#else
|
||||
#include <catalog/pg_inherits.h>
|
||||
|
@ -219,13 +219,13 @@ compress_chunk(Oid in_table, Oid out_table, const ColumnCompressionInfo **column
|
||||
int n_keys;
|
||||
const ColumnCompressionInfo **keys;
|
||||
|
||||
/*We want to prevent other compressors from compressing this table,
|
||||
/* We want to prevent other compressors from compressing this table,
|
||||
* and we want to prevent INSERTs or UPDATEs which could mess up our compression.
|
||||
* We may as well allow readers to keep reading the uncompressed data while
|
||||
* we are compressing, so we only take an ExclusiveLock instead of AccessExclusive.
|
||||
*/
|
||||
Relation in_rel = table_open(in_table, ExclusiveLock);
|
||||
/* we are _just_ INSERTing into the out_table so in principle we could take
|
||||
/* We are _just_ INSERTing into the out_table so in principle we could take
|
||||
* a RowExclusive lock, and let other operations read and write this table
|
||||
* as we work. However, we currently compress each table as a oneshot, so
|
||||
* we're taking the stricter lock to prevent accidents.
|
||||
@ -265,12 +265,12 @@ compress_chunk(Oid in_table, Oid out_table, const ColumnCompressionInfo **column
|
||||
|
||||
truncate_relation(in_table);
|
||||
|
||||
/* recreate all indexes on out rel, we already have an exvclusive lock on it
|
||||
/* Recreate all indexes on out rel, we already have an exclusive lock on it,
|
||||
* so the strong locks taken by reindex_relation shouldn't matter. */
|
||||
reindex_relation(out_table, 0, 0);
|
||||
|
||||
RelationClose(out_rel);
|
||||
RelationClose(in_rel);
|
||||
table_close(out_rel, NoLock);
|
||||
table_close(in_rel, NoLock);
|
||||
}
|
||||
|
||||
static int16 *
|
||||
@ -1042,12 +1042,12 @@ decompress_chunk(Oid in_table, Oid out_table)
|
||||
FreeBulkInsertState(decompressor.bistate);
|
||||
}
|
||||
|
||||
/* recreate all indexes on out rel, we already have an exvclusive lock on it
|
||||
/* Recreate all indexes on out rel, we already have an exclusive lock on it,
|
||||
* so the strong locks taken by reindex_relation shouldn't matter. */
|
||||
reindex_relation(out_table, 0, 0);
|
||||
|
||||
RelationClose(out_rel);
|
||||
RelationClose(in_rel);
|
||||
table_close(out_rel, NoLock);
|
||||
table_close(in_rel, NoLock);
|
||||
}
|
||||
|
||||
static PerCompressedColumn *
|
||||
|
@ -446,8 +446,8 @@ create_compressed_table_indexes(Oid compresstable_relid, CompressColInfo *compre
|
||||
static void
|
||||
set_statistics_on_compressed_table(Oid compressed_table_id)
|
||||
{
|
||||
Relation table_rel = relation_open(compressed_table_id, ShareUpdateExclusiveLock);
|
||||
Relation attrelation = relation_open(AttributeRelationId, RowExclusiveLock);
|
||||
Relation table_rel = table_open(compressed_table_id, ShareUpdateExclusiveLock);
|
||||
Relation attrelation = table_open(AttributeRelationId, RowExclusiveLock);
|
||||
TupleDesc table_desc = RelationGetDescr(table_rel);
|
||||
Oid compressed_data_type = ts_custom_type_cache_get(CUSTOM_TYPE_COMPRESSED_DATA)->type_oid;
|
||||
for (int i = 0; i < table_desc->natts; i++)
|
||||
@ -487,8 +487,8 @@ set_statistics_on_compressed_table(Oid compressed_table_id)
|
||||
heap_freetuple(tuple);
|
||||
}
|
||||
|
||||
RelationClose(attrelation);
|
||||
RelationClose(table_rel);
|
||||
table_close(attrelation, NoLock);
|
||||
table_close(table_rel, NoLock);
|
||||
}
|
||||
|
||||
#if !PG96 && !PG10
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "with_clause_parser.h"
|
||||
#include "hypertable.h"
|
||||
#include "chunk.h"
|
||||
|
||||
#define COMPRESSION_COLUMN_METADATA_PREFIX "_ts_meta_"
|
||||
#define COMPRESSION_COLUMN_METADATA_COUNT_NAME COMPRESSION_COLUMN_METADATA_PREFIX "count"
|
||||
|
@ -193,7 +193,7 @@ reorder_chunk(Oid chunk_id, Oid index_id, bool verbose, Oid wait_id, Oid destina
|
||||
|
||||
ts_cache_release(hcache);
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER,
|
||||
#if PG96 || PG10
|
||||
#if PG11_LT
|
||||
ACL_KIND_CLASS,
|
||||
#else
|
||||
OBJECT_TABLE,
|
||||
|
Loading…
x
Reference in New Issue
Block a user