1998-05-09 19:31:34 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* parse_coerce.h
|
2000-01-16 19:14:49 -05:00
|
|
|
* Routines for type coercion.
|
1998-05-09 19:31:34 -04:00
|
|
|
*
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 17:35:25 -04:00
|
|
|
*
|
2002-06-20 16:29:54 -04:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1998-05-09 19:31:34 -04:00
|
|
|
*
|
2003-02-03 16:15:45 -05:00
|
|
|
* $Id: parse_coerce.h,v 1.49 2003/02/03 21:15:44 tgl Exp $
|
1998-05-09 19:31:34 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#ifndef PARSE_COERCE_H
|
|
|
|
|
#define PARSE_COERCE_H
|
|
|
|
|
|
1999-07-15 11:21:54 -04:00
|
|
|
#include "catalog/pg_type.h"
|
1999-07-16 13:07:40 -04:00
|
|
|
#include "parser/parse_node.h"
|
1999-07-13 21:20:30 -04:00
|
|
|
|
1998-09-01 00:40:42 -04:00
|
|
|
typedef enum CATEGORY
|
|
|
|
|
{
|
2001-10-28 01:26:15 -05:00
|
|
|
INVALID_TYPE,
|
|
|
|
|
UNKNOWN_TYPE,
|
|
|
|
|
BOOLEAN_TYPE,
|
|
|
|
|
STRING_TYPE,
|
|
|
|
|
BITSTRING_TYPE,
|
|
|
|
|
NUMERIC_TYPE,
|
|
|
|
|
DATETIME_TYPE,
|
|
|
|
|
TIMESPAN_TYPE,
|
|
|
|
|
GEOMETRIC_TYPE,
|
|
|
|
|
NETWORK_TYPE,
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 17:35:25 -04:00
|
|
|
USER_TYPE
|
1999-05-25 18:43:53 -04:00
|
|
|
} CATEGORY;
|
1998-05-09 19:31:34 -04:00
|
|
|
|
|
|
|
|
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 17:35:25 -04:00
|
|
|
extern bool IsBinaryCoercible(Oid srctype, Oid targettype);
|
1998-05-09 19:31:34 -04:00
|
|
|
extern bool IsPreferredType(CATEGORY category, Oid type);
|
|
|
|
|
extern CATEGORY TypeCategory(Oid type);
|
|
|
|
|
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 17:35:25 -04:00
|
|
|
extern Node *coerce_to_target_type(Node *expr, Oid exprtype,
|
|
|
|
|
Oid targettype, int32 targettypmod,
|
|
|
|
|
CoercionContext ccontext,
|
|
|
|
|
CoercionForm cformat);
|
|
|
|
|
extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
|
|
|
|
|
CoercionContext ccontext);
|
|
|
|
|
extern Node *coerce_type(Node *node, Oid inputTypeId, Oid targetTypeId,
|
|
|
|
|
CoercionContext ccontext, CoercionForm cformat);
|
2003-02-03 16:15:45 -05:00
|
|
|
extern Node *coerce_to_domain(Node *arg, Oid baseTypeId, Oid typeId,
|
|
|
|
|
CoercionForm cformat);
|
1998-05-09 19:31:34 -04:00
|
|
|
|
2002-05-12 19:43:04 -04:00
|
|
|
extern Node *coerce_to_boolean(Node *node, const char *constructName);
|
2001-06-19 18:39:12 -04:00
|
|
|
|
2001-03-21 23:01:46 -05:00
|
|
|
extern Oid select_common_type(List *typeids, const char *context);
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 17:35:25 -04:00
|
|
|
extern Node *coerce_to_common_type(Node *node, Oid targetTypeId,
|
2001-03-21 23:01:46 -05:00
|
|
|
const char *context);
|
2001-10-28 01:26:15 -05:00
|
|
|
|
2002-10-24 18:09:00 -04:00
|
|
|
extern bool find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
|
|
|
|
|
CoercionContext ccontext,
|
|
|
|
|
Oid *funcid);
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 17:35:25 -04:00
|
|
|
extern Oid find_typmod_coercion_function(Oid typeId, int *nargs);
|
|
|
|
|
|
2001-11-05 12:46:40 -05:00
|
|
|
#endif /* PARSE_COERCE_H */
|