Skip to content

Commit 1e62f6f

Browse files
authored
[master] set limit 2000 for character type (IvorySQL#691)
* set limit 2000 for character type * add regression case for issue 561
1 parent b93f12f commit 1e62f6f

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

src/backend/oracle_parser/ora_gram.y

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15246,6 +15246,12 @@ CharacterWithLength: character '(' Iconst ')'
1524615246
}
1524715247
else
1524815248
{
15249+
if ($3 > CHAR_TYPE_LENGTH_MAX)
15250+
ereport(ERROR,
15251+
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
15252+
errmsg("specified length too long for its datatype"),
15253+
parser_errposition(@3)));
15254+
1524915255
if (nls_length_semantics == NLS_LENGTH_CHAR)
1525015256
$1 = "oracharchar";
1525115257
else

src/include/utils/ora_compatible.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#define ORA_SEARCH_PATH "sys,\"$user\", public"
2020
#define DB_MODE_PARMATER "ivorysql.database_mode"
2121

22+
#define CHAR_TYPE_LENGTH_MAX 2000
23+
2224
typedef enum DBMode
2325
{
2426
DB_PG = 0,

src/oracle_test/regress/expected/strings.out

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,18 +1946,18 @@ DROP TABLE toasttest;
19461946
-- corner case in packed-varlena handling: even though small, the compressed
19471947
-- datum must be given a 4-byte header because there are no bits to indicate
19481948
-- compression in a 1-byte header
1949-
CREATE TABLE toasttest (c char(4096));
1949+
CREATE TABLE toasttest (c char(2000));
19501950
INSERT INTO toasttest VALUES('x');
19511951
SELECT length(c), c::text FROM toasttest;
19521952
length | c
19531953
--------+---
1954-
4096 | x
1954+
2000 | x
19551955
(1 row)
19561956

19571957
SELECT c FROM toasttest;
1958-
c
1959-
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1960-
x
1958+
c
1959+
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1960+
x
19611961
(1 row)
19621962

19631963
DROP TABLE toasttest;
@@ -1970,6 +1970,10 @@ SELECT length('abcdef') AS "length_6";
19701970
6
19711971
(1 row)
19721972

1973+
CREATE TABLE toasttest (c char(2001));
1974+
ERROR: specified length too long for its datatype
1975+
LINE 1: CREATE TABLE toasttest (c char(2001));
1976+
^
19731977
--
19741978
-- test strpos
19751979
--

0 commit comments

Comments
 (0)