This is an automated email from the ASF dual-hosted git repository.
chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/cbdb-postgres-merge by this
push:
new 81a25608efc Fix test cases in
boolean/char/name/varchar/text/int2/int4/int8/float4/float8
81a25608efc is described below
commit 81a25608efcf87744ba27b6238064209d8825e70
Author: Jinbao Chen <[email protected]>
AuthorDate: Tue Oct 28 22:29:48 2025 +0800
Fix test cases in
boolean/char/name/varchar/text/int2/int4/int8/float4/float8
---
src/backend/utils/adt/numeric.c | 28 ++++------------------------
src/interfaces/ecpg/pgtypeslib/numeric.c | 16 ++++++++--------
src/test/regress/expected/float8.out | 18 ++----------------
src/test/regress/expected/int2.out | 11 -----------
src/test/regress/expected/int4.out | 8 --------
src/test/regress/expected/int8.out | 11 -----------
src/test/regress/expected/text.out | 7 -------
src/test/regress/serial_schedule | 20 ++++++++++----------
src/test/regress/sql/float8.sql | 9 +--------
src/test/regress/sql/int2.sql | 14 --------------
src/test/regress/sql/int4.sql | 11 -----------
src/test/regress/sql/int8.sql | 9 ---------
src/test/regress/sql/text.sql | 9 ---------
13 files changed, 25 insertions(+), 146 deletions(-)
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index d8ed0a0c0c7..5ed2479855f 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -7048,26 +7048,6 @@ zero_numeric_var(NumericVar *var)
var->sign = NUMERIC_POS; /* anything but NAN... */
}
-
-/*
- * zero_var() -
- *
- * Set a variable to ZERO.
- * Note: its dscale is not touched.
- */
-static void
-zero_var(NumericVar *var)
-{
- digitbuf_free(var);
- var->buf = NULL;
- var->digits = NULL;
- var->ndigits = 0;
- var->weight = 0; /* by convention; doesn't
really matter */
- var->sign = NUMERIC_POS; /* anything but NAN... */
-}
-
-
-
/*
* init_var_from_str()
*
@@ -7325,7 +7305,7 @@ set_var_from_non_decimal_integer_str(const char *str,
const char *cp, int sign,
init_var(&tmp_var);
- zero_var(dest);
+ zero_numeric_var(dest);
/*
* Process input digits in groups that fit in int64. Here "tmp" is the
@@ -9750,7 +9730,7 @@ div_var_int(const NumericVar *var, int ival, int
ival_weight,
/* Result zero check */
if (var_ndigits == 0)
{
- zero_var(result);
+ zero_numeric_var(result);
result->dscale = rscale;
return;
}
@@ -9866,7 +9846,7 @@ div_var_int64(const NumericVar *var, int64 ival, int
ival_weight,
/* Result zero check */
if (var_ndigits == 0)
{
- zero_var(result);
+ zero_numeric_var(result);
result->dscale = rscale;
return;
}
@@ -11349,7 +11329,7 @@ power_var_int(const NumericVar *base, int exp, int
exp_dscale,
errmsg("value overflows numeric format")));
if (f + 1 < -NUMERIC_MAX_DISPLAY_SCALE)
{
- zero_var(result);
+ zero_numeric_var(result);
result->dscale = NUMERIC_MAX_DISPLAY_SCALE;
return;
}
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c
b/src/interfaces/ecpg/pgtypeslib/numeric.c
index 35e7b92da40..130a48db068 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -364,7 +364,7 @@ PGTYPESnumeric_to_asc(numeric *num, int dscale)
}
/* ----------
- * zero_var() -
+ * zero_numeric_var() -
*
* Set a variable to ZERO.
* Note: rscale and dscale are not touched.
@@ -663,7 +663,7 @@ PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric
*result)
* result = ZERO
* ----------
*/
- zero_var(result);
+ zero_numeric_var(result);
result->rscale = Max(var1->rscale,
var2->rscale);
result->dscale = Max(var1->dscale,
var2->dscale);
break;
@@ -709,7 +709,7 @@ PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric
*result)
* result = ZERO
* ----------
*/
- zero_var(result);
+ zero_numeric_var(result);
result->rscale = Max(var1->rscale,
var2->rscale);
result->dscale = Max(var1->dscale,
var2->dscale);
break;
@@ -795,7 +795,7 @@ PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric
*result)
* result = ZERO
* ----------
*/
- zero_var(result);
+ zero_numeric_var(result);
result->rscale = Max(var1->rscale,
var2->rscale);
result->dscale = Max(var1->dscale,
var2->dscale);
break;
@@ -841,7 +841,7 @@ PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric
*result)
* result = ZERO
* ----------
*/
- zero_var(result);
+ zero_numeric_var(result);
result->rscale = Max(var1->rscale,
var2->rscale);
result->dscale = Max(var1->dscale,
var2->dscale);
break;
@@ -1099,7 +1099,7 @@ PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric
*result)
*/
if (var1->ndigits == 0)
{
- zero_var(result);
+ zero_numeric_var(result);
result->rscale = rscale;
return 0;
}
@@ -1391,7 +1391,7 @@ PGTYPESnumeric_copy(numeric *src, numeric *dst)
if (dst == NULL)
return -1;
- zero_var(dst);
+ zero_numeric_var(dst);
dst->weight = src->weight;
dst->rscale = src->rscale;
@@ -1571,7 +1571,7 @@ PGTYPESnumeric_from_decimal(decimal *src, numeric *dst)
{
int i;
- zero_var(dst);
+ zero_numeric_var(dst);
dst->weight = src->weight;
dst->rscale = src->rscale;
diff --git a/src/test/regress/expected/float8.out
b/src/test/regress/expected/float8.out
index 7ce74935fed..91cc182bbca 100644
--- a/src/test/regress/expected/float8.out
+++ b/src/test/regress/expected/float8.out
@@ -1,15 +1,11 @@
--
-- FLOAT8
--
-<<<<<<< HEAD
-CREATE TABLE FLOAT8_TBL(i INT DEFAULT 1, f1 float8);
-=======
--
-- Build a table for testing
-- (This temporarily hides the table created in test_setup.sql)
--
-CREATE TEMP TABLE FLOAT8_TBL(f1 float8);
->>>>>>> REL_16_9
+CREATE TEMP TABLE FLOAT8_TBL(i INT DEFAULT 1, f1 float8);
INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 ');
INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30 ');
INSERT INTO FLOAT8_TBL(f1) VALUES (' -34.84');
@@ -911,7 +907,6 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
ERROR: "-10e-400" is out of range for type double precision
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
^
-<<<<<<< HEAD
INSERT INTO FLOAT8_TBL(f1) VALUES ('1e-324');
ERROR: "1e-324" is out of range for type double precision
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('1e-324');
@@ -981,18 +976,9 @@ DELETE FROM FLOAT8_TBL WHERE f1='+naN'::float8;
DELETE FROM FLOAT8_TBL WHERE f1='NaN'::float8;
-- maintain external table consistency across platforms
-- delete all values and reinsert well-behaved ones
-DELETE FROM FLOAT8_TBL;
-INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
-SELECT f1 FROM FLOAT8_TBL;
-=======
DROP TABLE FLOAT8_TBL;
-- Check the float8 values exported for use by other tests
-SELECT * FROM FLOAT8_TBL;
->>>>>>> REL_16_9
+SELECT f1 FROM FLOAT8_TBL;
f1
-----------------------
0
diff --git a/src/test/regress/expected/int2.out
b/src/test/regress/expected/int2.out
index dc55ca25418..4e03a5faee0 100644
--- a/src/test/regress/expected/int2.out
+++ b/src/test/regress/expected/int2.out
@@ -1,16 +1,8 @@
--
-- INT2
--
-<<<<<<< HEAD
-CREATE TABLE INT2_TBL(f1 int2);
-INSERT INTO INT2_TBL(f1) VALUES ('0 ');
-ANALYZE INT2_TBL;
-INSERT INTO INT2_TBL(f1) VALUES (' 1234 ');
-INSERT INTO INT2_TBL(f1) VALUES (' -1234');
-=======
-- int2_tbl was already created and filled in test_setup.sql.
-- Here we just try to insert bad values.
->>>>>>> REL_16_9
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
ERROR: invalid input syntax for type smallint: "34.5"
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('34.5');
@@ -53,8 +45,6 @@ SELECT * FROM INT2_TBL;
-32767
(5 rows)
-<<<<<<< HEAD
-=======
-- Also try it with non-error-throwing API
SELECT pg_input_is_valid('34', 'int2');
pg_input_is_valid
@@ -99,7 +89,6 @@ SELECT * FROM pg_input_error_info('50000', 'int2vector');
value "50000" is out of range for type smallint | | | 22003
(1 row)
->>>>>>> REL_16_9
SELECT * FROM INT2_TBL AS f(a, b);
ERROR: table "f" has 1 columns available but 2 columns specified
SELECT * FROM (TABLE int2_tbl) AS s (a, b);
diff --git a/src/test/regress/expected/int4.out
b/src/test/regress/expected/int4.out
index e9f02443f3d..b1a15888ef8 100644
--- a/src/test/regress/expected/int4.out
+++ b/src/test/regress/expected/int4.out
@@ -1,16 +1,8 @@
--
-- INT4
--
-<<<<<<< HEAD
-CREATE TABLE INT4_TBL(f1 int4);
-INSERT INTO INT4_TBL(f1) VALUES (' 0 ');
-ANALYZE INT4_TBL;
-INSERT INTO INT4_TBL(f1) VALUES ('123456 ');
-INSERT INTO INT4_TBL(f1) VALUES (' -123456');
-=======
-- int4_tbl was already created and filled in test_setup.sql.
-- Here we just try to insert bad values.
->>>>>>> REL_16_9
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
ERROR: invalid input syntax for type integer: "34.5"
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('34.5');
diff --git a/src/test/regress/expected/int8.out
b/src/test/regress/expected/int8.out
index 998356d0041..02b711f9250 100644
--- a/src/test/regress/expected/int8.out
+++ b/src/test/regress/expected/int8.out
@@ -2,19 +2,8 @@
-- INT8
-- Test int8 64-bit integers.
--
-<<<<<<< HEAD
-CREATE TABLE INT8_TBL(q1 int8, q2 int8);
-INSERT INTO INT8_TBL VALUES(' 123 ',' 456');
-ANALYZE INT8_TBL;
-INSERT INTO INT8_TBL VALUES('123 ','4567890123456789');
-INSERT INTO INT8_TBL VALUES('4567890123456789','123');
-INSERT INTO INT8_TBL VALUES(+4567890123456789,'4567890123456789');
-INSERT INTO INT8_TBL VALUES('+4567890123456789','-4567890123456789');
--- bad inputs
-=======
-- int8_tbl was already created and filled in test_setup.sql.
-- Here we just try to insert bad values.
->>>>>>> REL_16_9
INSERT INTO INT8_TBL(q1) VALUES (' ');
ERROR: invalid input syntax for type bigint: " "
LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' ');
diff --git a/src/test/regress/expected/text.out
b/src/test/regress/expected/text.out
index 918dd57607d..36464f4589b 100644
--- a/src/test/regress/expected/text.out
+++ b/src/test/regress/expected/text.out
@@ -14,14 +14,7 @@ SELECT text 'this is a text string' = text 'this is a text
strin' AS false;
f
(1 row)
-<<<<<<< HEAD
-CREATE TABLE TEXT_TBL (f1 text);
-INSERT INTO TEXT_TBL VALUES ('doh!');
-ANALYZE TEXT_TBL;
-INSERT INTO TEXT_TBL VALUES ('hi de ho neighbor');
-=======
-- text_tbl was already created and filled in test_setup.sql.
->>>>>>> REL_16_9
SELECT * FROM TEXT_TBL;
f1
-------------------
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index 9bc67063f3b..f3036be1de7 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -4,18 +4,18 @@ test: test_setup
# test: tablespace
test: boolean
test: char
-# test: name
-# test: varchar
-# test: text
-# test: int2
-# test: int4
-# test: int8
+test: name
+test: varchar
+test: text
+test: int2
+test: int4
+test: int8
# test: oid
# test: xid
-# test: float4
-# test: float8
-# test: bit
-# test: numeric
+test: float4
+test: float8
+test: bit
+test: numeric
# test: txid
# test: uuid
# test: enum
diff --git a/src/test/regress/sql/float8.sql b/src/test/regress/sql/float8.sql
index 5334c122c45..822a0010b4b 100644
--- a/src/test/regress/sql/float8.sql
+++ b/src/test/regress/sql/float8.sql
@@ -2,16 +2,12 @@
-- FLOAT8
--
-<<<<<<< HEAD
-CREATE TABLE FLOAT8_TBL(i INT DEFAULT 1, f1 float8);
-=======
--
-- Build a table for testing
-- (This temporarily hides the table created in test_setup.sql)
--
-CREATE TEMP TABLE FLOAT8_TBL(f1 float8);
->>>>>>> REL_16_9
+CREATE TEMP TABLE FLOAT8_TBL(i INT DEFAULT 1, f1 float8);
INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 ');
INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30 ');
@@ -271,7 +267,6 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
-<<<<<<< HEAD
INSERT INTO FLOAT8_TBL(f1) VALUES ('1e-324');
INSERT INTO FLOAT8_TBL(f1) VALUES ('1e308');
@@ -352,9 +347,7 @@ DELETE FROM FLOAT8_TBL WHERE f1='NaN'::float8;
-- maintain external table consistency across platforms
-- delete all values and reinsert well-behaved ones
-=======
DROP TABLE FLOAT8_TBL;
->>>>>>> REL_16_9
-- Check the float8 values exported for use by other tests
diff --git a/src/test/regress/sql/int2.sql b/src/test/regress/sql/int2.sql
index aa2c5b79e3f..df1e46d4e2e 100644
--- a/src/test/regress/sql/int2.sql
+++ b/src/test/regress/sql/int2.sql
@@ -2,19 +2,8 @@
-- INT2
--
-<<<<<<< HEAD
-CREATE TABLE INT2_TBL(f1 int2);
-
-INSERT INTO INT2_TBL(f1) VALUES ('0 ');
-ANALYZE INT2_TBL;
-
-INSERT INTO INT2_TBL(f1) VALUES (' 1234 ');
-
-INSERT INTO INT2_TBL(f1) VALUES (' -1234');
-=======
-- int2_tbl was already created and filled in test_setup.sql.
-- Here we just try to insert bad values.
->>>>>>> REL_16_9
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
INSERT INTO INT2_TBL(f1) VALUES ('100000');
@@ -28,8 +17,6 @@ INSERT INTO INT2_TBL(f1) VALUES ('');
SELECT * FROM INT2_TBL;
-<<<<<<< HEAD
-=======
-- Also try it with non-error-throwing API
SELECT pg_input_is_valid('34', 'int2');
SELECT pg_input_is_valid('asdf', 'int2');
@@ -41,7 +28,6 @@ SELECT pg_input_is_valid(' 1 3 5 ', 'int2vector');
SELECT * FROM pg_input_error_info('1 asdf', 'int2vector');
SELECT * FROM pg_input_error_info('50000', 'int2vector');
->>>>>>> REL_16_9
SELECT * FROM INT2_TBL AS f(a, b);
SELECT * FROM (TABLE int2_tbl) AS s (a, b);
diff --git a/src/test/regress/sql/int4.sql b/src/test/regress/sql/int4.sql
index b9d468c0bac..e9d89e8111f 100644
--- a/src/test/regress/sql/int4.sql
+++ b/src/test/regress/sql/int4.sql
@@ -2,19 +2,8 @@
-- INT4
--
-<<<<<<< HEAD
-CREATE TABLE INT4_TBL(f1 int4);
-
-INSERT INTO INT4_TBL(f1) VALUES (' 0 ');
-ANALYZE INT4_TBL;
-
-INSERT INTO INT4_TBL(f1) VALUES ('123456 ');
-
-INSERT INTO INT4_TBL(f1) VALUES (' -123456');
-=======
-- int4_tbl was already created and filled in test_setup.sql.
-- Here we just try to insert bad values.
->>>>>>> REL_16_9
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
diff --git a/src/test/regress/sql/int8.sql b/src/test/regress/sql/int8.sql
index 62100948994..8ca07b4b93e 100644
--- a/src/test/regress/sql/int8.sql
+++ b/src/test/regress/sql/int8.sql
@@ -3,17 +3,8 @@
-- Test int8 64-bit integers.
--
-<<<<<<< HEAD
-INSERT INTO INT8_TBL VALUES(' 123 ',' 456');
-ANALYZE INT8_TBL;
-INSERT INTO INT8_TBL VALUES('123 ','4567890123456789');
-INSERT INTO INT8_TBL VALUES('4567890123456789','123');
-INSERT INTO INT8_TBL VALUES(+4567890123456789,'4567890123456789');
-INSERT INTO INT8_TBL VALUES('+4567890123456789','-4567890123456789');
-=======
-- int8_tbl was already created and filled in test_setup.sql.
-- Here we just try to insert bad values.
->>>>>>> REL_16_9
INSERT INTO INT8_TBL(q1) VALUES (' ');
INSERT INTO INT8_TBL(q1) VALUES ('xxx');
diff --git a/src/test/regress/sql/text.sql b/src/test/regress/sql/text.sql
index 31e56d4f4e2..f931bd1140e 100644
--- a/src/test/regress/sql/text.sql
+++ b/src/test/regress/sql/text.sql
@@ -6,16 +6,7 @@ SELECT text 'this is a text string' = text 'this is a text
string' AS true;
SELECT text 'this is a text string' = text 'this is a text strin' AS false;
-<<<<<<< HEAD
-CREATE TABLE TEXT_TBL (f1 text);
-
-INSERT INTO TEXT_TBL VALUES ('doh!');
-ANALYZE TEXT_TBL;
-INSERT INTO TEXT_TBL VALUES ('hi de ho neighbor');
-
-=======
-- text_tbl was already created and filled in test_setup.sql.
->>>>>>> REL_16_9
SELECT * FROM TEXT_TBL;
-- As of 8.3 we have removed most implicit casts to text, so that for example
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]