mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 19:59:48 +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 <catalog/pg_constraint.h>
|
||||||
#include "compat.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>
|
#include <catalog/pg_constraint_fn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ chunk_adjust_colref_attnos(IndexInfo *ii, Relation idxrel, Relation chunkrel)
|
|||||||
|
|
||||||
if (attno == InvalidAttrNumber)
|
if (attno == InvalidAttrNumber)
|
||||||
elog(ERROR, "index attribute %s not found in chunk", NameStr(idxattr->attname));
|
elog(ERROR, "index attribute %s not found in chunk", NameStr(idxattr->attname));
|
||||||
#if PG96 || PG10
|
#if PG11_LT
|
||||||
ii->ii_KeyAttrNumbers[i] = attno;
|
ii->ii_KeyAttrNumbers[i] = attno;
|
||||||
#else
|
#else
|
||||||
ii->ii_IndexAttrNumbers[i] = attno;
|
ii->ii_IndexAttrNumbers[i] = attno;
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <catalog/pg_type.h>
|
#include <catalog/pg_type.h>
|
||||||
#include <parser/parse_func.h>
|
#include <parser/parse_func.h>
|
||||||
#include "compat.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_inherits_fn.h>
|
||||||
#include <catalog/pg_constraint_fn.h>
|
#include <catalog/pg_constraint_fn.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "hypertable_cache.h"
|
#include "hypertable_cache.h"
|
||||||
#include "partitioning.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>
|
#include <catalog/pg_inherits_fn.h>
|
||||||
#else
|
#else
|
||||||
#include <catalog/pg_inherits.h>
|
#include <catalog/pg_inherits.h>
|
||||||
|
@ -219,13 +219,13 @@ compress_chunk(Oid in_table, Oid out_table, const ColumnCompressionInfo **column
|
|||||||
int n_keys;
|
int n_keys;
|
||||||
const ColumnCompressionInfo **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.
|
* 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 may as well allow readers to keep reading the uncompressed data while
|
||||||
* we are compressing, so we only take an ExclusiveLock instead of AccessExclusive.
|
* we are compressing, so we only take an ExclusiveLock instead of AccessExclusive.
|
||||||
*/
|
*/
|
||||||
Relation in_rel = table_open(in_table, ExclusiveLock);
|
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
|
* 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
|
* as we work. However, we currently compress each table as a oneshot, so
|
||||||
* we're taking the stricter lock to prevent accidents.
|
* 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);
|
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. */
|
* so the strong locks taken by reindex_relation shouldn't matter. */
|
||||||
reindex_relation(out_table, 0, 0);
|
reindex_relation(out_table, 0, 0);
|
||||||
|
|
||||||
RelationClose(out_rel);
|
table_close(out_rel, NoLock);
|
||||||
RelationClose(in_rel);
|
table_close(in_rel, NoLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16 *
|
static int16 *
|
||||||
@ -1042,12 +1042,12 @@ decompress_chunk(Oid in_table, Oid out_table)
|
|||||||
FreeBulkInsertState(decompressor.bistate);
|
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. */
|
* so the strong locks taken by reindex_relation shouldn't matter. */
|
||||||
reindex_relation(out_table, 0, 0);
|
reindex_relation(out_table, 0, 0);
|
||||||
|
|
||||||
RelationClose(out_rel);
|
table_close(out_rel, NoLock);
|
||||||
RelationClose(in_rel);
|
table_close(in_rel, NoLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PerCompressedColumn *
|
static PerCompressedColumn *
|
||||||
|
@ -446,8 +446,8 @@ create_compressed_table_indexes(Oid compresstable_relid, CompressColInfo *compre
|
|||||||
static void
|
static void
|
||||||
set_statistics_on_compressed_table(Oid compressed_table_id)
|
set_statistics_on_compressed_table(Oid compressed_table_id)
|
||||||
{
|
{
|
||||||
Relation table_rel = relation_open(compressed_table_id, ShareUpdateExclusiveLock);
|
Relation table_rel = table_open(compressed_table_id, ShareUpdateExclusiveLock);
|
||||||
Relation attrelation = relation_open(AttributeRelationId, RowExclusiveLock);
|
Relation attrelation = table_open(AttributeRelationId, RowExclusiveLock);
|
||||||
TupleDesc table_desc = RelationGetDescr(table_rel);
|
TupleDesc table_desc = RelationGetDescr(table_rel);
|
||||||
Oid compressed_data_type = ts_custom_type_cache_get(CUSTOM_TYPE_COMPRESSED_DATA)->type_oid;
|
Oid compressed_data_type = ts_custom_type_cache_get(CUSTOM_TYPE_COMPRESSED_DATA)->type_oid;
|
||||||
for (int i = 0; i < table_desc->natts; i++)
|
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);
|
heap_freetuple(tuple);
|
||||||
}
|
}
|
||||||
|
|
||||||
RelationClose(attrelation);
|
table_close(attrelation, NoLock);
|
||||||
RelationClose(table_rel);
|
table_close(table_rel, NoLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !PG96 && !PG10
|
#if !PG96 && !PG10
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include "with_clause_parser.h"
|
#include "with_clause_parser.h"
|
||||||
#include "hypertable.h"
|
#include "hypertable.h"
|
||||||
#include "chunk.h"
|
|
||||||
|
|
||||||
#define COMPRESSION_COLUMN_METADATA_PREFIX "_ts_meta_"
|
#define COMPRESSION_COLUMN_METADATA_PREFIX "_ts_meta_"
|
||||||
#define COMPRESSION_COLUMN_METADATA_COUNT_NAME COMPRESSION_COLUMN_METADATA_PREFIX "count"
|
#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);
|
ts_cache_release(hcache);
|
||||||
aclcheck_error(ACLCHECK_NOT_OWNER,
|
aclcheck_error(ACLCHECK_NOT_OWNER,
|
||||||
#if PG96 || PG10
|
#if PG11_LT
|
||||||
ACL_KIND_CLASS,
|
ACL_KIND_CLASS,
|
||||||
#else
|
#else
|
||||||
OBJECT_TABLE,
|
OBJECT_TABLE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user