Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8011ac5

Browse filesBrowse files
author
Svetlana Derevyanko
committed
[PGPRO-9047] Fixed parsing empty string into NULL
Tags: jsquery
1 parent 55bc24e commit 8011ac5
Copy full SHA for 8011ac5

File tree

6 files changed

+19
-11
lines changed
Filter options

6 files changed

+19
-11
lines changed

‎expected/jsquery.out

Copy file name to clipboardExpand all lines: expected/jsquery.out
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ set escape_string_warning=off;
33
set standard_conforming_strings=on;
44
CREATE TABLE test_jsquery (v jsonb);
55
\copy test_jsquery from 'data/test_jsquery.data'
6+
select ''::jsquery;
7+
ERROR: bad jsquery representation
8+
LINE 1: select ''::jsquery;
9+
^
10+
DETAIL: No symbols read at the end of input
611
select 'asd.zzz = 13'::jsquery;
712
jsquery
813
------------------

‎expected/jsquery_1.out

Copy file name to clipboardExpand all lines: expected/jsquery_1.out
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ set escape_string_warning=off;
33
set standard_conforming_strings=on;
44
CREATE TABLE test_jsquery (v jsonb);
55
\copy test_jsquery from 'data/test_jsquery.data'
6+
select ''::jsquery;
7+
ERROR: bad jsquery representation
8+
LINE 1: select ''::jsquery;
9+
^
10+
DETAIL: No symbols read at the end of input
611
select 'asd.zzz = 13'::jsquery;
712
jsquery
813
------------------

‎jsquery_gram.y

Copy file name to clipboardExpand all lines: jsquery_gram.y
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ result:
258258
*result = $1;
259259
(void) yynerrs; /* suppress compiler warning */
260260
}
261-
| /* EMPTY */ { *result = NULL; }
261+
| /* EMPTY */ {
262+
*result = NULL;
263+
yyerror(NULL, "No symbols read"); }
262264
;
263265

264266
array:

‎jsquery_io.c

Copy file name to clipboardExpand all lines: jsquery_io.c
+4-9Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,12 @@ jsquery_in(PG_FUNCTION_ARGS)
162162

163163
appendStringInfoSpaces(&buf, VARHDRSZ);
164164

165-
if (jsquery != NULL)
166-
{
167-
flattenJsQueryParseItem(&buf, jsquery, false);
168-
169-
res = (JsQuery*)buf.data;
170-
SET_VARSIZE(res, buf.len);
165+
flattenJsQueryParseItem(&buf, jsquery, false);
171166

172-
PG_RETURN_JSQUERY(res);
173-
}
167+
res = (JsQuery*)buf.data;
168+
SET_VARSIZE(res, buf.len);
174169

175-
PG_RETURN_NULL();
170+
PG_RETURN_JSQUERY(res);
176171
}
177172

178173
static void

‎jsquery_scan.l

Copy file name to clipboardExpand all lines: jsquery_scan.l
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ yyerror(JsQueryParseItem **result, const char *message)
206206
(errcode(ERRCODE_SYNTAX_ERROR),
207207
errmsg("bad jsquery representation"),
208208
/* translator: %s is typically "syntax error" */
209-
errdetail("%s at end of input", message)));
209+
errdetail("%s at the end of input", message)));
210210
}
211211
else
212212
{

‎sql/jsquery.sql

Copy file name to clipboardExpand all lines: sql/jsquery.sql
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CREATE TABLE test_jsquery (v jsonb);
77

88
\copy test_jsquery from 'data/test_jsquery.data'
99

10+
select ''::jsquery;
1011
select 'asd.zzz = 13'::jsquery;
1112
select 'asd.zzz < 13'::jsquery;
1213
select 'asd(zzz < 13)'::jsquery;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.