2006-07-04 00:45:41 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* reloptions.h
|
2010-01-05 22:54:00 +01:00
|
|
|
* Core support for relation and tablespace options (pg_class.reloptions
|
|
|
|
* and pg_tablespace.spcoptions)
|
2006-07-04 00:45:41 +02:00
|
|
|
*
|
|
|
|
* Note: the functions dealing with text-array reloptions values declare
|
|
|
|
* them as Datum, not ArrayType *, to avoid needing to include array.h
|
|
|
|
* into a lot of low-level code.
|
|
|
|
*
|
|
|
|
*
|
2022-01-08 01:04:57 +01:00
|
|
|
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
2006-07-04 00:45:41 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/access/reloptions.h
|
2006-07-04 00:45:41 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef RELOPTIONS_H
|
|
|
|
#define RELOPTIONS_H
|
|
|
|
|
2019-12-27 00:09:00 +01:00
|
|
|
#include "access/amapi.h"
|
2009-01-26 20:41:06 +01:00
|
|
|
#include "access/htup.h"
|
2012-08-30 22:15:44 +02:00
|
|
|
#include "access/tupdesc.h"
|
2006-07-04 00:45:41 +02:00
|
|
|
#include "nodes/pg_list.h"
|
2015-08-14 15:19:28 +02:00
|
|
|
#include "storage/lock.h"
|
2006-07-04 00:45:41 +02:00
|
|
|
|
2009-01-05 18:14:28 +01:00
|
|
|
/* types supported by reloptions */
|
|
|
|
typedef enum relopt_type
|
|
|
|
{
|
|
|
|
RELOPT_TYPE_BOOL,
|
|
|
|
RELOPT_TYPE_INT,
|
|
|
|
RELOPT_TYPE_REAL,
|
2019-09-25 20:56:52 +02:00
|
|
|
RELOPT_TYPE_ENUM,
|
2009-01-05 18:14:28 +01:00
|
|
|
RELOPT_TYPE_STRING
|
|
|
|
} relopt_type;
|
|
|
|
|
|
|
|
/* kinds supported by reloptions */
|
|
|
|
typedef enum relopt_kind
|
|
|
|
{
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
RELOPT_KIND_LOCAL = 0,
|
2009-04-04 02:45:02 +02:00
|
|
|
RELOPT_KIND_HEAP = (1 << 0),
|
|
|
|
RELOPT_KIND_TOAST = (1 << 1),
|
|
|
|
RELOPT_KIND_BTREE = (1 << 2),
|
|
|
|
RELOPT_KIND_HASH = (1 << 3),
|
|
|
|
RELOPT_KIND_GIN = (1 << 4),
|
|
|
|
RELOPT_KIND_GIST = (1 << 5),
|
2010-01-22 17:40:19 +01:00
|
|
|
RELOPT_KIND_ATTRIBUTE = (1 << 6),
|
|
|
|
RELOPT_KIND_TABLESPACE = (1 << 7),
|
2011-12-17 22:41:16 +01:00
|
|
|
RELOPT_KIND_SPGIST = (1 << 8),
|
2011-12-22 22:15:57 +01:00
|
|
|
RELOPT_KIND_VIEW = (1 << 9),
|
BRIN: Block Range Indexes
BRIN is a new index access method intended to accelerate scans of very
large tables, without the maintenance overhead of btrees or other
traditional indexes. They work by maintaining "summary" data about
block ranges. Bitmap index scans work by reading each summary tuple and
comparing them with the query quals; all pages in the range are returned
in a lossy TID bitmap if the quals are consistent with the values in the
summary tuple, otherwise not. Normal index scans are not supported
because these indexes do not store TIDs.
As new tuples are added into the index, the summary information is
updated (if the block range in which the tuple is added is already
summarized) or not; in the latter case, a subsequent pass of VACUUM or
the brin_summarize_new_values() function will create the summary
information.
For data types with natural 1-D sort orders, the summary info consists
of the maximum and the minimum values of each indexed column within each
page range. This type of operator class we call "Minmax", and we
supply a bunch of them for most data types with B-tree opclasses.
Since the BRIN code is generalized, other approaches are possible for
things such as arrays, geometric types, ranges, etc; even for things
such as enum types we could do something different than minmax with
better results. In this commit I only include minmax.
Catalog version bumped due to new builtin catalog entries.
There's more that could be done here, but this is a good step forwards.
Loosely based on ideas from Simon Riggs; code mostly by Álvaro Herrera,
with contribution by Heikki Linnakangas.
Patch reviewed by: Amit Kapila, Heikki Linnakangas, Robert Haas.
Testing help from Jeff Janes, Erik Rijkers, Emanuel Calvo.
PS:
The research leading to these results has received funding from the
European Union's Seventh Framework Programme (FP7/2007-2013) under
grant agreement n° 318633.
2014-11-07 20:38:14 +01:00
|
|
|
RELOPT_KIND_BRIN = (1 << 10),
|
2017-03-31 22:28:30 +02:00
|
|
|
RELOPT_KIND_PARTITIONED = (1 << 11),
|
2009-01-05 18:14:28 +01:00
|
|
|
/* if you add a new kind, make sure you update "last_default" too */
|
2017-03-31 22:28:30 +02:00
|
|
|
RELOPT_KIND_LAST_DEFAULT = RELOPT_KIND_PARTITIONED,
|
2009-05-25 00:22:44 +02:00
|
|
|
/* some compilers treat enums as signed ints, so we can't use 1 << 31 */
|
|
|
|
RELOPT_KIND_MAX = (1 << 30)
|
2009-01-05 18:14:28 +01:00
|
|
|
} relopt_kind;
|
|
|
|
|
2009-02-02 20:31:40 +01:00
|
|
|
/* reloption namespaces allowed for heaps -- currently only TOAST */
|
|
|
|
#define HEAP_RELOPT_NAMESPACES { "toast", NULL }
|
|
|
|
|
2009-01-05 18:14:28 +01:00
|
|
|
/* generic struct to hold shared data */
|
|
|
|
typedef struct relopt_gen
|
|
|
|
{
|
|
|
|
const char *name; /* must be first (used as list termination
|
|
|
|
* marker) */
|
|
|
|
const char *desc;
|
2009-04-04 02:45:02 +02:00
|
|
|
bits32 kinds;
|
2015-08-14 15:19:28 +02:00
|
|
|
LOCKMODE lockmode;
|
2009-01-05 18:14:28 +01:00
|
|
|
int namelen;
|
|
|
|
relopt_type type;
|
|
|
|
} relopt_gen;
|
|
|
|
|
|
|
|
/* holds a parsed value */
|
|
|
|
typedef struct relopt_value
|
|
|
|
{
|
|
|
|
relopt_gen *gen;
|
|
|
|
bool isset;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
bool bool_val;
|
|
|
|
int int_val;
|
|
|
|
double real_val;
|
2019-09-25 20:56:52 +02:00
|
|
|
int enum_val;
|
2009-01-05 18:14:28 +01:00
|
|
|
char *string_val; /* allocated separately */
|
|
|
|
} values;
|
|
|
|
} relopt_value;
|
|
|
|
|
|
|
|
/* reloptions records for specific variable types */
|
|
|
|
typedef struct relopt_bool
|
|
|
|
{
|
|
|
|
relopt_gen gen;
|
|
|
|
bool default_val;
|
|
|
|
} relopt_bool;
|
2009-01-12 22:02:15 +01:00
|
|
|
|
2009-01-05 18:14:28 +01:00
|
|
|
typedef struct relopt_int
|
|
|
|
{
|
|
|
|
relopt_gen gen;
|
|
|
|
int default_val;
|
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
} relopt_int;
|
|
|
|
|
|
|
|
typedef struct relopt_real
|
|
|
|
{
|
|
|
|
relopt_gen gen;
|
|
|
|
double default_val;
|
|
|
|
double min;
|
|
|
|
double max;
|
|
|
|
} relopt_real;
|
|
|
|
|
2019-09-25 20:56:52 +02:00
|
|
|
/*
|
|
|
|
* relopt_enum_elt_def -- One member of the array of acceptable values
|
|
|
|
* of an enum reloption.
|
|
|
|
*/
|
|
|
|
typedef struct relopt_enum_elt_def
|
|
|
|
{
|
|
|
|
const char *string_val;
|
|
|
|
int symbol_val;
|
|
|
|
} relopt_enum_elt_def;
|
|
|
|
|
|
|
|
typedef struct relopt_enum
|
|
|
|
{
|
|
|
|
relopt_gen gen;
|
|
|
|
relopt_enum_elt_def *members;
|
|
|
|
int default_val;
|
|
|
|
const char *detailmsg;
|
|
|
|
/* null-terminated array of members */
|
|
|
|
} relopt_enum;
|
|
|
|
|
2009-01-12 22:02:15 +01:00
|
|
|
/* validation routines for strings */
|
2017-10-31 15:34:31 +01:00
|
|
|
typedef void (*validate_string_relopt) (const char *value);
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
typedef Size (*fill_string_relopt) (const char *value, void *ptr);
|
|
|
|
|
|
|
|
/* validation routine for the whole option set */
|
|
|
|
typedef void (*relopts_validator) (void *parsed_options, relopt_value *vals, int nvals);
|
2009-01-08 20:34:41 +01:00
|
|
|
|
2009-01-05 18:14:28 +01:00
|
|
|
typedef struct relopt_string
|
|
|
|
{
|
|
|
|
relopt_gen gen;
|
|
|
|
int default_len;
|
|
|
|
bool default_isnull;
|
2009-01-08 20:34:41 +01:00
|
|
|
validate_string_relopt validate_cb;
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
fill_string_relopt fill_cb;
|
2011-08-09 14:25:44 +02:00
|
|
|
char *default_val;
|
2009-01-05 18:14:28 +01:00
|
|
|
} relopt_string;
|
|
|
|
|
2019-11-14 05:59:59 +01:00
|
|
|
/* This is the table datatype for build_reloptions() */
|
2009-01-12 22:02:15 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-03-23 17:36:27 +01:00
|
|
|
const char *optname; /* option's name */
|
|
|
|
relopt_type opttype; /* option's datatype */
|
|
|
|
int offset; /* offset of field in result struct */
|
2009-01-12 22:02:15 +01:00
|
|
|
} relopt_parse_elt;
|
|
|
|
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
/* Local reloption definition */
|
|
|
|
typedef struct local_relopt
|
|
|
|
{
|
|
|
|
relopt_gen *option; /* option definition */
|
|
|
|
int offset; /* offset of parsed value in bytea structure */
|
|
|
|
} local_relopt;
|
|
|
|
|
|
|
|
/* Structure to hold local reloption data for build_local_reloptions() */
|
|
|
|
typedef struct local_relopts
|
|
|
|
{
|
|
|
|
List *options; /* list of local_relopt definitions */
|
|
|
|
List *validators; /* list of relopts_validator callbacks */
|
|
|
|
Size relopt_struct_size; /* size of parsed bytea structure */
|
|
|
|
} local_relopts;
|
|
|
|
|
2009-01-05 18:14:28 +01:00
|
|
|
/*
|
2019-11-14 05:59:59 +01:00
|
|
|
* Utility macro to get a value for a string reloption once the options
|
|
|
|
* are parsed. This gets a pointer to the string value itself. "optstruct"
|
|
|
|
* is the StdRdOptions struct or equivalent, "member" is the struct member
|
|
|
|
* corresponding to the string option.
|
2009-01-08 20:34:41 +01:00
|
|
|
*/
|
|
|
|
#define GET_STRING_RELOPTION(optstruct, member) \
|
|
|
|
((optstruct)->member == 0 ? NULL : \
|
2009-01-12 22:02:15 +01:00
|
|
|
(char *)(optstruct) + (optstruct)->member)
|
2009-01-08 20:34:41 +01:00
|
|
|
|
2009-04-04 02:45:02 +02:00
|
|
|
extern relopt_kind add_reloption_kind(void);
|
2017-10-31 15:34:31 +01:00
|
|
|
extern void add_bool_reloption(bits32 kinds, const char *name, const char *desc,
|
2019-09-25 03:13:52 +02:00
|
|
|
bool default_val, LOCKMODE lockmode);
|
2017-10-31 15:34:31 +01:00
|
|
|
extern void add_int_reloption(bits32 kinds, const char *name, const char *desc,
|
2019-09-25 03:13:52 +02:00
|
|
|
int default_val, int min_val, int max_val,
|
|
|
|
LOCKMODE lockmode);
|
2017-10-31 15:34:31 +01:00
|
|
|
extern void add_real_reloption(bits32 kinds, const char *name, const char *desc,
|
2019-09-25 03:13:52 +02:00
|
|
|
double default_val, double min_val, double max_val,
|
|
|
|
LOCKMODE lockmode);
|
2019-09-25 20:56:52 +02:00
|
|
|
extern void add_enum_reloption(bits32 kinds, const char *name, const char *desc,
|
|
|
|
relopt_enum_elt_def *members, int default_val,
|
|
|
|
const char *detailmsg, LOCKMODE lockmode);
|
2017-10-31 15:34:31 +01:00
|
|
|
extern void add_string_reloption(bits32 kinds, const char *name, const char *desc,
|
2019-09-25 03:13:52 +02:00
|
|
|
const char *default_val, validate_string_relopt validator,
|
|
|
|
LOCKMODE lockmode);
|
2009-01-12 22:02:15 +01:00
|
|
|
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
extern void init_local_reloptions(local_relopts *opts, Size relopt_struct_size);
|
|
|
|
extern void register_reloptions_validator(local_relopts *opts,
|
|
|
|
relopts_validator validator);
|
|
|
|
extern void add_local_bool_reloption(local_relopts *opts, const char *name,
|
|
|
|
const char *desc, bool default_val,
|
|
|
|
int offset);
|
|
|
|
extern void add_local_int_reloption(local_relopts *opts, const char *name,
|
|
|
|
const char *desc, int default_val,
|
|
|
|
int min_val, int max_val, int offset);
|
|
|
|
extern void add_local_real_reloption(local_relopts *opts, const char *name,
|
|
|
|
const char *desc, double default_val,
|
|
|
|
double min_val, double max_val,
|
|
|
|
int offset);
|
|
|
|
extern void add_local_enum_reloption(local_relopts *relopts,
|
|
|
|
const char *name, const char *desc,
|
|
|
|
relopt_enum_elt_def *members,
|
|
|
|
int default_val, const char *detailmsg,
|
|
|
|
int offset);
|
|
|
|
extern void add_local_string_reloption(local_relopts *opts, const char *name,
|
|
|
|
const char *desc,
|
|
|
|
const char *default_val,
|
|
|
|
validate_string_relopt validator,
|
|
|
|
fill_string_relopt filler, int offset);
|
|
|
|
|
2006-07-04 00:45:41 +02:00
|
|
|
extern Datum transformRelOptions(Datum oldOptions, List *defList,
|
2017-10-31 15:34:31 +01:00
|
|
|
const char *namspace, char *validnsps[],
|
Remove WITH OIDS support, change oid catalog column visibility.
Previously tables declared WITH OIDS, including a significant fraction
of the catalog tables, stored the oid column not as a normal column,
but as part of the tuple header.
This special column was not shown by default, which was somewhat odd,
as it's often (consider e.g. pg_class.oid) one of the more important
parts of a row. Neither pg_dump nor COPY included the contents of the
oid column by default.
The fact that the oid column was not an ordinary column necessitated a
significant amount of special case code to support oid columns. That
already was painful for the existing, but upcoming work aiming to make
table storage pluggable, would have required expanding and duplicating
that "specialness" significantly.
WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0).
Remove it.
Removing includes:
- CREATE TABLE and ALTER TABLE syntax for declaring the table to be
WITH OIDS has been removed (WITH (oids[ = true]) will error out)
- pg_dump does not support dumping tables declared WITH OIDS and will
issue a warning when dumping one (and ignore the oid column).
- restoring an pg_dump archive with pg_restore will warn when
restoring a table with oid contents (and ignore the oid column)
- COPY will refuse to load binary dump that includes oids.
- pg_upgrade will error out when encountering tables declared WITH
OIDS, they have to be altered to remove the oid column first.
- Functionality to access the oid of the last inserted row (like
plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed.
The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false)
for CREATE TABLE) is still supported. While that requires a bit of
support code, it seems unnecessary to break applications / dumps that
do not use oids, and are explicit about not using them.
The biggest user of WITH OID columns was postgres' catalog. This
commit changes all 'magic' oid columns to be columns that are normally
declared and stored. To reduce unnecessary query breakage all the
newly added columns are still named 'oid', even if a table's column
naming scheme would indicate 'reloid' or such. This obviously
requires adapting a lot code, mostly replacing oid access via
HeapTupleGetOid() with access to the underlying Form_pg_*->oid column.
The bootstrap process now assigns oids for all oid columns in
genbki.pl that do not have an explicit value (starting at the largest
oid previously used), only oids assigned later by oids will be above
FirstBootstrapObjectId. As the oid column now is a normal column the
special bootstrap syntax for oids has been removed.
Oids are not automatically assigned during insertion anymore, all
backend code explicitly assigns oids with GetNewOidWithIndex(). For
the rare case that insertions into the catalog via SQL are called for
the new pg_nextoid() function can be used (which only works on catalog
tables).
The fact that oid columns on system tables are now normal columns
means that they will be included in the set of columns expanded
by * (i.e. SELECT * FROM pg_class will now include the table's oid,
previously it did not). It'd not technically be hard to hide oid
column by default, but that'd mean confusing behavior would either
have to be carried forward forever, or it'd cause breakage down the
line.
While it's not unlikely that further adjustments are needed, the
scope/invasiveness of the patch makes it worthwhile to get merge this
now. It's painful to maintain externally, too complicated to commit
after the code code freeze, and a dependency of a number of other
patches.
Catversion bump, for obvious reasons.
Author: Andres Freund, with contributions by John Naylor
Discussion: https://postgr.es/m/20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de
2018-11-21 00:36:57 +01:00
|
|
|
bool acceptOidsOff, bool isReset);
|
2007-12-02 00:44:44 +01:00
|
|
|
extern List *untransformRelOptions(Datum options);
|
2009-01-26 20:41:06 +01:00
|
|
|
extern bytea *extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
|
Restructure index access method API to hide most of it at the C level.
This patch reduces pg_am to just two columns, a name and a handler
function. All the data formerly obtained from pg_am is now provided
in a C struct returned by the handler function. This is similar to
the designs we've adopted for FDWs and tablesample methods. There
are multiple advantages. For one, the index AM's support functions
are now simple C functions, making them faster to call and much less
error-prone, since the C compiler can now check function signatures.
For another, this will make it far more practical to define index access
methods in installable extensions.
A disadvantage is that SQL-level code can no longer see attributes
of index AMs; in particular, some of the crosschecks in the opr_sanity
regression test are no longer possible from SQL. We've addressed that
by adding a facility for the index AM to perform such checks instead.
(Much more could be done in that line, but for now we're content if the
amvalidate functions more or less replace what opr_sanity used to do.)
We might also want to expose some sort of reporting functionality, but
this patch doesn't do that.
Alexander Korotkov, reviewed by Petr Jelínek, and rather heavily
editorialized on by me.
2016-01-18 01:36:59 +01:00
|
|
|
amoptions_function amoptions);
|
2019-11-05 01:17:05 +01:00
|
|
|
extern void *build_reloptions(Datum reloptions, bool validate,
|
|
|
|
relopt_kind kind,
|
|
|
|
Size relopt_struct_size,
|
|
|
|
const relopt_parse_elt *relopt_elems,
|
|
|
|
int num_relopt_elems);
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
extern void *build_local_reloptions(local_relopts *relopts, Datum options,
|
|
|
|
bool validate);
|
2006-07-04 00:45:41 +02:00
|
|
|
|
|
|
|
extern bytea *default_reloptions(Datum reloptions, bool validate,
|
2009-01-05 18:14:28 +01:00
|
|
|
relopt_kind kind);
|
2006-07-04 00:45:41 +02:00
|
|
|
extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate);
|
2014-07-14 23:24:40 +02:00
|
|
|
extern bytea *view_reloptions(Datum reloptions, bool validate);
|
2019-11-14 04:34:28 +01:00
|
|
|
extern bytea *partitioned_table_reloptions(Datum reloptions, bool validate);
|
Restructure index access method API to hide most of it at the C level.
This patch reduces pg_am to just two columns, a name and a handler
function. All the data formerly obtained from pg_am is now provided
in a C struct returned by the handler function. This is similar to
the designs we've adopted for FDWs and tablesample methods. There
are multiple advantages. For one, the index AM's support functions
are now simple C functions, making them faster to call and much less
error-prone, since the C compiler can now check function signatures.
For another, this will make it far more practical to define index access
methods in installable extensions.
A disadvantage is that SQL-level code can no longer see attributes
of index AMs; in particular, some of the crosschecks in the opr_sanity
regression test are no longer possible from SQL. We've addressed that
by adding a facility for the index AM to perform such checks instead.
(Much more could be done in that line, but for now we're content if the
amvalidate functions more or less replace what opr_sanity used to do.)
We might also want to expose some sort of reporting functionality, but
this patch doesn't do that.
Alexander Korotkov, reviewed by Petr Jelínek, and rather heavily
editorialized on by me.
2016-01-18 01:36:59 +01:00
|
|
|
extern bytea *index_reloptions(amoptions_function amoptions, Datum reloptions,
|
2009-01-05 18:14:28 +01:00
|
|
|
bool validate);
|
2010-01-22 17:40:19 +01:00
|
|
|
extern bytea *attribute_reloptions(Datum reloptions, bool validate);
|
2010-01-05 22:54:00 +01:00
|
|
|
extern bytea *tablespace_reloptions(Datum reloptions, bool validate);
|
2015-08-14 15:19:28 +02:00
|
|
|
extern LOCKMODE AlterTableGetRelOptionsLockLevel(List *defList);
|
2006-07-04 00:45:41 +02:00
|
|
|
|
|
|
|
#endif /* RELOPTIONS_H */
|