diff --git a/src/backend/nodes/readfast.c b/src/backend/nodes/readfast.c index daed3060d50..204027c75e5 100644 --- a/src/backend/nodes/readfast.c +++ b/src/backend/nodes/readfast.c @@ -119,9 +119,26 @@ } \ var = nn; } +#define READ_STRING_VAR_NULL(var) \ + { int slen; char * nn = NULL; \ + memcpy(&slen, read_str_ptr, sizeof(int)); \ + read_str_ptr+=sizeof(int); \ + if (slen>0) { \ + nn = palloc(slen+1); \ + memcpy(nn,read_str_ptr,slen); \ + read_str_ptr+=(slen); nn[slen]='\0'; \ + } \ + if (slen==0) { \ + nn = palloc(1); \ + nn[0] = '\0'; \ + } \ + var = nn; } + /* Read a character-string field */ #define READ_STRING_FIELD(fldname) READ_STRING_VAR(local_node->fldname) +#define READ_STRING_FIELD_NULL(fldname) READ_STRING_VAR_NULL(local_node->fldname) + /* Read a parse location field (and throw away the value, per notes above) */ #define READ_LOCATION_FIELD(fldname) READ_INT_FIELD(fldname) @@ -892,7 +909,7 @@ _readOidAssignment(void) READ_LOCALS(OidAssignment); READ_OID_FIELD(catalog); - READ_STRING_FIELD(objname); + READ_STRING_FIELD_NULL(objname); READ_OID_FIELD(namespaceOid); READ_OID_FIELD(keyOid1); READ_OID_FIELD(keyOid2); diff --git a/src/test/regress/expected/gp_types.out b/src/test/regress/expected/gp_types.out index 101f69dfa3d..45bde01bd96 100644 --- a/src/test/regress/expected/gp_types.out +++ b/src/test/regress/expected/gp_types.out @@ -41,6 +41,7 @@ SELECT * FROM dml_bitvarying ORDER BY 1; 00 (1 row) +CREATE TYPE size_t AS enum(''); -- -- Interval -- @@ -425,6 +426,7 @@ SELECT float8in(float8out(a)) FROM FLOATS ORDER BY a; COPY FLOATS TO '/tmp/floats'; TRUNCATE FLOATS; COPY FLOATS FROM '/tmp/floats'; +DROP TYPE size_t; SELECT * FROM FLOATS ORDER BY a; a -------- diff --git a/src/test/regress/sql/gp_types.sql b/src/test/regress/sql/gp_types.sql index dd8c6efa1e1..53d4d7cdff9 100644 --- a/src/test/regress/sql/gp_types.sql +++ b/src/test/regress/sql/gp_types.sql @@ -23,6 +23,8 @@ SELECT * FROM dml_bitvarying ORDER BY 1; UPDATE dml_bitvarying SET a = '000'; SELECT * FROM dml_bitvarying ORDER BY 1; +CREATE TYPE size_t AS enum(''); + -- -- Interval -- @@ -172,4 +174,6 @@ COPY FLOATS TO '/tmp/floats'; TRUNCATE FLOATS; COPY FLOATS FROM '/tmp/floats'; +DROP TYPE size_t; + SELECT * FROM FLOATS ORDER BY a;