|
24 | 24 | #include "nodes/nodeFuncs.h"
|
25 | 25 | #include "nodes/supportnodes.h"
|
26 | 26 | #include "optimizer/optimizer.h"
|
| 27 | +#include "parser/scansup.h" |
27 | 28 | #include "port/pg_bitutils.h"
|
28 | 29 | #include "utils/array.h"
|
29 | 30 | #include "utils/arrayaccess.h"
|
@@ -89,7 +90,6 @@ typedef struct ArrayIteratorData
|
89 | 90 | int current_item; /* the item # we're at in the array */
|
90 | 91 | } ArrayIteratorData;
|
91 | 92 |
|
92 |
| -static bool array_isspace(char ch); |
93 | 93 | static int ArrayCount(const char *str, int *dim, char typdelim,
|
94 | 94 | Node *escontext);
|
95 | 95 | static bool ReadArrayStr(char *arrayStr, const char *origStr,
|
@@ -254,7 +254,7 @@ array_in(PG_FUNCTION_ARGS)
|
254 | 254 | * Note: we currently allow whitespace between, but not within,
|
255 | 255 | * dimension items.
|
256 | 256 | */
|
257 |
| - while (array_isspace(*p)) |
| 257 | + while (scanner_isspace(*p)) |
258 | 258 | p++;
|
259 | 259 | if (*p != '[')
|
260 | 260 | break; /* no more dimension items */
|
@@ -338,7 +338,7 @@ array_in(PG_FUNCTION_ARGS)
|
338 | 338 | errdetail("Missing \"%s\" after array dimensions.",
|
339 | 339 | ASSGN)));
|
340 | 340 | p += strlen(ASSGN);
|
341 |
| - while (array_isspace(*p)) |
| 341 | + while (scanner_isspace(*p)) |
342 | 342 | p++;
|
343 | 343 |
|
344 | 344 | /*
|
@@ -434,27 +434,6 @@ array_in(PG_FUNCTION_ARGS)
|
434 | 434 | PG_RETURN_ARRAYTYPE_P(retval);
|
435 | 435 | }
|
436 | 436 |
|
437 |
| -/* |
438 |
| - * array_isspace() --- a non-locale-dependent isspace() |
439 |
| - * |
440 |
| - * We used to use isspace() for parsing array values, but that has |
441 |
| - * undesirable results: an array value might be silently interpreted |
442 |
| - * differently depending on the locale setting. Now we just hard-wire |
443 |
| - * the traditional ASCII definition of isspace(). |
444 |
| - */ |
445 |
| -static bool |
446 |
| -array_isspace(char ch) |
447 |
| -{ |
448 |
| - if (ch == ' ' || |
449 |
| - ch == '\t' || |
450 |
| - ch == '\n' || |
451 |
| - ch == '\r' || |
452 |
| - ch == '\v' || |
453 |
| - ch == '\f') |
454 |
| - return true; |
455 |
| - return false; |
456 |
| -} |
457 |
| - |
458 | 437 | /*
|
459 | 438 | * ArrayCount
|
460 | 439 | * Determines the dimensions for an array string.
|
@@ -654,7 +633,7 @@ ArrayCount(const char *str, int *dim, char typdelim, Node *escontext)
|
654 | 633 | itemdone = true;
|
655 | 634 | nelems[nest_level - 1]++;
|
656 | 635 | }
|
657 |
| - else if (!array_isspace(*ptr)) |
| 636 | + else if (!scanner_isspace(*ptr)) |
658 | 637 | {
|
659 | 638 | /*
|
660 | 639 | * Other non-space characters must be after a
|
@@ -684,7 +663,7 @@ ArrayCount(const char *str, int *dim, char typdelim, Node *escontext)
|
684 | 663 | /* only whitespace is allowed after the closing brace */
|
685 | 664 | while (*ptr)
|
686 | 665 | {
|
687 |
| - if (!array_isspace(*ptr++)) |
| 666 | + if (!scanner_isspace(*ptr++)) |
688 | 667 | ereturn(escontext, -1,
|
689 | 668 | (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
690 | 669 | errmsg("malformed array literal: \"%s\"", str),
|
@@ -884,7 +863,7 @@ ReadArrayStr(char *arrayStr,
|
884 | 863 | indx[ndim - 1]++;
|
885 | 864 | srcptr++;
|
886 | 865 | }
|
887 |
| - else if (array_isspace(*srcptr)) |
| 866 | + else if (scanner_isspace(*srcptr)) |
888 | 867 | {
|
889 | 868 | /*
|
890 | 869 | * If leading space, drop it immediately. Else, copy
|
@@ -1176,7 +1155,7 @@ array_out(PG_FUNCTION_ARGS)
|
1176 | 1155 | overall_length += 1;
|
1177 | 1156 | }
|
1178 | 1157 | else if (ch == '{' || ch == '}' || ch == typdelim ||
|
1179 |
| - array_isspace(ch)) |
| 1158 | + scanner_isspace(ch)) |
1180 | 1159 | needquote = true;
|
1181 | 1160 | }
|
1182 | 1161 | }
|
|
0 commit comments