diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c index 0c1d99a..0cbc865 100644 --- a/contrib/hstore/hstore_io.c +++ b/contrib/hstore/hstore_io.c @@ -81,7 +81,10 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped) } else if (*(state->ptr) == '=' && !ignoreeq) { - elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin)); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Syntax error near '%c' at position %d", + *(state->ptr), (int32) (state->ptr - state->begin))))); } else if (*(state->ptr) == '\\') { @@ -138,7 +141,9 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped) } else if (*(state->ptr) == '\0') { - elog(ERROR, "Unexpected end of string"); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Unexpected end of string")))); } else { @@ -150,7 +155,9 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped) else if (st == GV_WAITESCIN) { if (*(state->ptr) == '\0') - elog(ERROR, "Unexpected end of string"); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Unexpected end of string")))); RESIZEPRSBUF; *(state->cur) = *(state->ptr); state->cur++; @@ -159,7 +166,9 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped) else if (st == GV_WAITESCESCIN) { if (*(state->ptr) == '\0') - elog(ERROR, "Unexpected end of string"); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Unexpected end of string")))); RESIZEPRSBUF; *(state->cur) = *(state->ptr); state->cur++; @@ -216,11 +225,16 @@ parse_hstore(HSParser *state) } else if (*(state->ptr) == '\0') { - elog(ERROR, "Unexpected end of string"); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Unexpected end of string")))); } else if (!isspace((unsigned char) *(state->ptr))) { - elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin)); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Syntax error near '%c' at position %d", + *(state->ptr), (int32) (state->ptr - state->begin))))); } } else if (st == WGT) @@ -231,17 +245,24 @@ parse_hstore(HSParser *state) } else if (*(state->ptr) == '\0') { - elog(ERROR, "Unexpected end of string"); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Unexpected end of string")))); } else { - elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin)); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Syntax error near '%c' at position %d", + *(state->ptr), (int32) (state->ptr - state->begin))))); } } else if (st == WVAL) { if (!get_val(state, true, &escaped)) - elog(ERROR, "Unexpected end of string"); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Unexpected end of string")))); state->pairs[state->pcur].val = state->word; state->pairs[state->pcur].vallen = hstoreCheckValLen(state->cur - state->word); state->pairs[state->pcur].isnull = false; @@ -268,7 +289,10 @@ parse_hstore(HSParser *state) } else if (!isspace((unsigned char) *(state->ptr))) { - elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin)); + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + (errmsg("Syntax error near '%c' at position %d", + *(state->ptr), (int32) (state->ptr - state->begin))))); } } else