|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.141 2006/07/14 14:52:22 momjian Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.142 2006/07/26 00:34:48 momjian Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -821,7 +821,7 @@ coerce_to_boolean(ParseState *pstate, Node *node,
|
821 | 821 |
|
822 | 822 | /* coerce_to_integer()
|
823 | 823 | *Coerce an argument of a construct that requires integer input
|
824 |
| - *(LIMIT, OFFSET, etc).Also check that input is not a set. |
| 824 | + *Also check that input is not a set. |
825 | 825 | *
|
826 | 826 | * Returns the possibly-transformed node tree.
|
827 | 827 | *
|
@@ -857,7 +857,45 @@ coerce_to_integer(ParseState *pstate, Node *node,
|
857 | 857 |
|
858 | 858 | returnnode;
|
859 | 859 | }
|
| 860 | + |
| 861 | +/* coerce_to_integer64() |
| 862 | + * Coerce an argument of a construct that requires integer input |
| 863 | + * (LIMIT, OFFSET). Also check that input is not a set. |
| 864 | + * |
| 865 | + * Returns the possibly-transformed node tree. |
| 866 | + * |
| 867 | + * As with coerce_type, pstate may be NULL if no special unknown-Param |
| 868 | + * processing is wanted. |
| 869 | + */ |
| 870 | +Node* |
| 871 | +coerce_to_integer64(ParseState*pstate,Node*node, |
| 872 | +constchar*constructName) |
| 873 | +{ |
| 874 | +OidinputTypeId=exprType(node); |
| 875 | + |
| 876 | +if (inputTypeId!=INT8OID) |
| 877 | +{ |
| 878 | +node=coerce_to_target_type(pstate,node,inputTypeId, |
| 879 | +INT8OID,-1,COERCION_ASSIGNMENT, |
| 880 | +COERCE_IMPLICIT_CAST); |
| 881 | +if (node==NULL) |
| 882 | +ereport(ERROR, |
| 883 | + (errcode(ERRCODE_DATATYPE_MISMATCH), |
| 884 | +/* translator: first %s is name of a SQL construct, eg LIMIT */ |
| 885 | +errmsg("argument of %s must be type integer, not type %s", |
| 886 | +constructName,format_type_be(inputTypeId)))); |
| 887 | +} |
860 | 888 |
|
| 889 | +if (expression_returns_set(node)) |
| 890 | +ereport(ERROR, |
| 891 | + (errcode(ERRCODE_DATATYPE_MISMATCH), |
| 892 | +/* translator: %s is name of a SQL construct, eg LIMIT */ |
| 893 | +errmsg("argument of %s must not return a set", |
| 894 | +constructName))); |
| 895 | + |
| 896 | +returnnode; |
| 897 | +} |
| 898 | + |
861 | 899 |
|
862 | 900 | /* select_common_type()
|
863 | 901 | *Determine the common supertype of a list of input expression types.
|
|