diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2015-12-18 21:35:22 +0300 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2015-12-18 21:35:22 +0300 |
commit | bbbd807097092c7f292872e7da02eee35d67e54b (patch) | |
tree | 754831612e24305dee439214ba0c55089a0847db /src/backend/parser | |
parent | 3c7042a7d7871b47dae3c9777c8020e41dedee89 (diff) | |
download | postgresql-bbbd807097092c7f292872e7da02eee35d67e54b.tar.gz postgresql-bbbd807097092c7f292872e7da02eee35d67e54b.zip |
Revert 9246af6799819847faa33baf441251003acbb8fe because
I miss too much. Patch is returned to commitfest process.
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/gram.y | 31 | ||||
-rw-r--r-- | src/backend/parser/parse_node.c | 49 | ||||
-rw-r--r-- | src/backend/parser/parse_target.c | 2 |
3 files changed, 18 insertions, 64 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index ce95f0f2a73..c4bed8a5ef7 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -13193,35 +13193,6 @@ indirection_el: A_Indices *ai = makeNode(A_Indices); ai->lidx = NULL; ai->uidx = $2; - ai->lidx_default = false; - ai->uidx_default = false; - $$ = (Node *) ai; - } - | '[' ':' ']' - { - A_Indices *ai = makeNode(A_Indices); - ai->lidx = NULL; - ai->uidx = NULL; - ai->lidx_default = true; - ai->uidx_default = true; - $$ = (Node *) ai; - } - | '[' ':' a_expr ']' - { - A_Indices *ai = makeNode(A_Indices); - ai->lidx = NULL; - ai->uidx = $3; - ai->lidx_default = true; - ai->uidx_default = false; - $$ = (Node *) ai; - } - | '[' a_expr ':' ']' - { - A_Indices *ai = makeNode(A_Indices); - ai->lidx = $2; - ai->uidx = NULL; - ai->lidx_default = false; - ai->uidx_default = true; $$ = (Node *) ai; } | '[' a_expr ':' a_expr ']' @@ -13229,8 +13200,6 @@ indirection_el: A_Indices *ai = makeNode(A_Indices); ai->lidx = $2; ai->uidx = $4; - ai->lidx_default = false; - ai->uidx_default = false; $$ = (Node *) ai; } ; diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index de6e0b89342..4130cbff5ed 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -311,7 +311,7 @@ transformArraySubscripts(ParseState *pstate, elementType = transformArrayType(&arrayType, &arrayTypMod); /* - * A list containing only single subscripts (uidx) refers to a single array + * A list containing only single subscripts refers to a single array * element. If any of the items are double subscripts (lower:upper), then * the subscript expression means an array slice operation. In this case, * we supply a default lower bound of 1 for any items that contain only a @@ -322,7 +322,7 @@ transformArraySubscripts(ParseState *pstate, { A_Indices *ai = (A_Indices *) lfirst(idx); - if (ai->lidx != NULL || ai->lidx_default) + if (ai->lidx != NULL) { isSlice = true; break; @@ -335,17 +335,9 @@ transformArraySubscripts(ParseState *pstate, foreach(idx, indirection) { A_Indices *ai = (A_Indices *) lfirst(idx); - Node *subexpr = NULL; + Node *subexpr; Assert(IsA(ai, A_Indices)); - if ((ai->uidx_default || ai->lidx_default) && assignFrom != NULL) - ereport(ERROR, - (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("array subscript must have both boundaries"), - errhint("You can't omit the upper or lower" - " boundaries when updating or inserting"), - parser_errposition(pstate, exprLocation(arrayBase)))); - if (isSlice) { if (ai->lidx) @@ -364,7 +356,7 @@ transformArraySubscripts(ParseState *pstate, errmsg("array subscript must have type integer"), parser_errposition(pstate, exprLocation(ai->lidx)))); } - else if (ai->lidx_default == false) + else { /* Make a constant 1 */ subexpr = (Node *) makeConst(INT4OID, @@ -377,26 +369,19 @@ transformArraySubscripts(ParseState *pstate, } lowerIndexpr = lappend(lowerIndexpr, subexpr); } - - if (ai->uidx_default == false) - { - subexpr = transformExpr(pstate, ai->uidx, pstate->p_expr_kind); - /* If it's not int4 already, try to coerce */ - subexpr = coerce_to_target_type(pstate, - subexpr, exprType(subexpr), - INT4OID, -1, - COERCION_ASSIGNMENT, - COERCE_IMPLICIT_CAST, - -1); - if (subexpr == NULL) - ereport(ERROR, - (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("array subscript must have type integer"), - parser_errposition(pstate, exprLocation(ai->uidx)))); - } - else - subexpr = NULL; - + subexpr = transformExpr(pstate, ai->uidx, pstate->p_expr_kind); + /* If it's not int4 already, try to coerce */ + subexpr = coerce_to_target_type(pstate, + subexpr, exprType(subexpr), + INT4OID, -1, + COERCION_ASSIGNMENT, + COERCE_IMPLICIT_CAST, + -1); + if (subexpr == NULL) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("array subscript must have type integer"), + parser_errposition(pstate, exprLocation(ai->uidx)))); upperIndexpr = lappend(upperIndexpr, subexpr); } diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index df41f9fc9b8..1b3fcd629c1 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -650,7 +650,7 @@ transformAssignmentIndirection(ParseState *pstate, if (IsA(n, A_Indices)) { subscripts = lappend(subscripts, n); - if (((A_Indices *) n)->lidx != NULL || ((A_Indices *) n)->lidx_default) + if (((A_Indices *) n)->lidx != NULL) isSlice = true; } else if (IsA(n, A_Star)) |